Replace usage of long long with u64/s64
authorShadowNinja <shadowninja@minetest.net>
Wed, 12 Mar 2014 23:37:19 +0000 (19:37 -0400)
committerShadowNinja <shadowninja@minetest.net>
Wed, 12 Mar 2014 23:37:19 +0000 (19:37 -0400)
src/database-dummy.cpp
src/database-dummy.h
src/database.cpp
src/database.h
src/game.cpp
src/util/serialize.cpp
src/util/string.h

index acc19ca04124f1cbac97bc0cfd056bb2a4161c60..c4794d281a282330f1e8ba2e55eb3199396e7678 100644 (file)
@@ -151,7 +151,7 @@ MapBlock* Database_Dummy::loadBlock(v3s16 blockpos)
 
 void Database_Dummy::listAllLoadableBlocks(std::list<v3s16> &dst)
 {
-       for(std::map<unsigned long long, std::string>::iterator x = m_database.begin(); x != m_database.end(); ++x)
+       for(std::map<u64, std::string>::iterator x = m_database.begin(); x != m_database.end(); ++x)
        {
                v3s16 p = getIntegerAsBlock(x->first);
                //dstream<<"block_i="<<block_i<<" p="<<PP(p)<<std::endl;
index 1474a4a906464d9d2d4ef0dc135d107b823babd9..c0bee97c0c3d1077ace4c937549969d84da1a72b 100644 (file)
@@ -20,9 +20,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #ifndef DATABASE_DUMMY_HEADER
 #define DATABASE_DUMMY_HEADER
 
-#include "database.h"
 #include <map>
 #include <string>
+#include "database.h"
+#include "irrlichttypes.h"
 
 class ServerMap;
 
@@ -39,6 +40,6 @@ public:
        ~Database_Dummy();
 private:
        ServerMap *srvmap;
-       std::map<unsigned long long, std::string> m_database;
+       std::map<u64, std::string> m_database;
 };
 #endif
index b793cd2f29a3675c39c8ac7438e88e17e5fd0d64..e3d92f91578495b2ea55d0146f565334f1431355 100644 (file)
@@ -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);
index 79cabe6a31c37c96ec5d7a7952124bf621a68961..4ce80ed9315bdad82cb92a89e9cad5083e69ec66 100644 (file)
@@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 #include <list>
 #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<v3s16> &dst)=0;
        virtual int Initialized(void)=0;
        virtual ~Database() {};
index 2e98d09e9fc7aec69a76667807773af7873d2ba8..d4d6d5c0e8f86d96efce458cf01ac92704c4b933 100644 (file)
@@ -3214,7 +3214,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
                                <<") (yaw="<<(wrapDegrees_0_360(camera_yaw))
                                <<") (t="<<client.getEnv().getClientMap().getHeat(pos_i)
                                <<"C, h="<<client.getEnv().getClientMap().getHumidity(pos_i)
-                               <<"%) (seed = "<<((unsigned long long)client.getMapSeed())
+                               <<"%) (seed = "<<((u64)client.getMapSeed())
                                <<")";
                        guitext2->setText(narrow_to_wide(os.str()).c_str());
                        guitext2->setVisible(true);
index 126385007a95b39c15f7450f176ee384d7b3fb41..58f569fb7d0ae61b1e4a1ea88c633925df2315a2 100644 (file)
@@ -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 <sstream>
 #include <iomanip>
@@ -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;
index 9bb89f14aaac6d91894ae245d991bd19741b023b..bed66417ee715ffeeddafcdd2a3c9848a949cf10 100644 (file)
@@ -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;
 }