From 18577f25277f269c8dd8d2bdcaaccbac72d9370d Mon Sep 17 00:00:00 2001 From: ShadowNinja Date: Wed, 12 Mar 2014 19:37:19 -0400 Subject: [PATCH] Replace usage of long long with u64/s64 --- src/database-dummy.cpp | 2 +- src/database-dummy.h | 5 +++-- src/database.cpp | 10 +++++----- src/database.h | 5 +++-- src/game.cpp | 2 +- src/util/serialize.cpp | 3 ++- src/util/string.h | 2 +- 7 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/database-dummy.cpp b/src/database-dummy.cpp index acc19ca0..c4794d28 100644 --- a/src/database-dummy.cpp +++ b/src/database-dummy.cpp @@ -151,7 +151,7 @@ MapBlock* Database_Dummy::loadBlock(v3s16 blockpos) void Database_Dummy::listAllLoadableBlocks(std::list &dst) { - for(std::map::iterator x = m_database.begin(); x != m_database.end(); ++x) + for(std::map::iterator x = m_database.begin(); x != m_database.end(); ++x) { v3s16 p = getIntegerAsBlock(x->first); //dstream<<"block_i="< #include +#include "database.h" +#include "irrlichttypes.h" class ServerMap; @@ -39,6 +40,6 @@ public: ~Database_Dummy(); private: ServerMap *srvmap; - std::map m_database; + std::map m_database; }; #endif diff --git a/src/database.cpp b/src/database.cpp index b793cd2f..e3d92f91 100644 --- a/src/database.cpp +++ b/src/database.cpp @@ -36,13 +36,13 @@ static s64 pythonmodulo(s64 i, s64 mod) return mod - ((-i) % mod); } -long long Database::getBlockAsInteger(const v3s16 pos) { - return (unsigned long long)pos.Z*16777216 + - (unsigned long long)pos.Y*4096 + - (unsigned long long)pos.X; +s64 Database::getBlockAsInteger(const v3s16 pos) { + return (u64) pos.Z * 16777216 + + (u64) pos.Y * 4096 + + (u64) pos.X; } -v3s16 Database::getIntegerAsBlock(long long i) { +v3s16 Database::getIntegerAsBlock(s64 i) { s32 x = unsignedToSigned(pythonmodulo(i, 4096), 2048); i = (i - x) / 4096; s32 y = unsignedToSigned(pythonmodulo(i, 4096), 2048); diff --git a/src/database.h b/src/database.h index 79cabe6a..4ce80ed9 100644 --- a/src/database.h +++ b/src/database.h @@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include "irr_v3d.h" +#include "irrlichttypes.h" class MapBlock; @@ -33,8 +34,8 @@ public: virtual void saveBlock(MapBlock *block)=0; virtual MapBlock* loadBlock(v3s16 blockpos)=0; - long long getBlockAsInteger(const v3s16 pos); - v3s16 getIntegerAsBlock(long long i); + s64 getBlockAsInteger(const v3s16 pos); + v3s16 getIntegerAsBlock(s64 i); virtual void listAllLoadableBlocks(std::list &dst)=0; virtual int Initialized(void)=0; virtual ~Database() {}; diff --git a/src/game.cpp b/src/game.cpp index 2e98d09e..d4d6d5c0 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -3214,7 +3214,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input, <<") (yaw="<<(wrapDegrees_0_360(camera_yaw)) <<") (t="<setText(narrow_to_wide(os.str()).c_str()); guitext2->setVisible(true); diff --git a/src/util/serialize.cpp b/src/util/serialize.cpp index 12638500..58f569fb 100644 --- a/src/util/serialize.cpp +++ b/src/util/serialize.cpp @@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "porting.h" #include "util/string.h" #include "../exceptions.h" +#include "../irrlichttypes.h" #include #include @@ -428,7 +429,7 @@ bool serializeStructToString(std::string *outstr, bufpos += PADDING(bufpos, u64); nprinted = snprintf(sbuf + pos, sbuflen, is_unsigned ? "%llu, " : "%lli, ", - (unsigned long long)*((u64 *)bufpos)); + *((u64 *)bufpos)); bufpos += sizeof(u64); } break; diff --git a/src/util/string.h b/src/util/string.h index 9bb89f14..bed66417 100644 --- a/src/util/string.h +++ b/src/util/string.h @@ -165,7 +165,7 @@ inline s32 mystoi(const std::string &s, s32 min, s32 max) inline s64 stoi64(const std::string &s) { std::stringstream tmp(s); - long long t; + s64 t; tmp >> t; return t; }