Bunch of small fixes (coding style, very unlikely errors, warning messages) 1201/head
authorsapier <Sapier at GMX dot net>
Sun, 6 Apr 2014 13:12:04 +0000 (15:12 +0200)
committersapier <Sapier at GMX dot net>
Sat, 19 Apr 2014 09:56:19 +0000 (11:56 +0200)
src/client.h
src/connection.cpp
src/guiEngine.cpp
src/localplayer.cpp
src/main.cpp
src/porting.cpp
src/settings.h
src/tile.cpp
src/util/pointer.h

index a5fda98d7c37769d9c65614caac218179dab7c3e..885dc9d3b70f99f9b92110732796e9dd27c5b3f1 100644 (file)
@@ -409,7 +409,8 @@ public:
        void addUpdateMeshTaskWithEdge(v3s16 blockpos, bool ack_to_server=false, bool urgent=false);
        void addUpdateMeshTaskForNode(v3s16 nodepos, bool ack_to_server=false, bool urgent=false);
        
-       void updateCameraOffset(v3s16 camera_offset){ m_mesh_update_thread.m_camera_offset = camera_offset; }
+       void updateCameraOffset(v3s16 camera_offset)
+       { m_mesh_update_thread.m_camera_offset = camera_offset; }
 
        // Get event from queue. CE_NONE is returned if queue is empty.
        ClientEvent getClientEvent();
index 32634ac8948f3979846ca78120f48f9c65f19c33..ae1e4a1db68b39353b5cd45e479cbd479d6c120b 100644 (file)
@@ -111,10 +111,10 @@ SharedBuffer<u8> makeOriginalPacket(
        u32 packet_size = data.getSize() + header_size;
        SharedBuffer<u8> b(packet_size);
 
-       writeU8(&b[0], TYPE_ORIGINAL);
-
-       memcpy(&b[header_size], *data, data.getSize());
-
+       writeU8(&(b[0]), TYPE_ORIGINAL);
+       if (data.getSize() > 0) {
+               memcpy(&(b[header_size]), *data, data.getSize());
+       }
        return b;
 }
 
@@ -2266,14 +2266,14 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
        if(packetdata.getSize() < 1)
                throw InvalidIncomingDataException("packetdata.getSize() < 1");
 
-       u8 type = readU8(&packetdata[0]);
+       u8 type = readU8(&(packetdata[0]));
 
        if(type == TYPE_CONTROL)
        {
                if(packetdata.getSize() < 2)
                        throw InvalidIncomingDataException("packetdata.getSize() < 2");
 
-               u8 controltype = readU8(&packetdata[1]);
+               u8 controltype = readU8(&(packetdata[1]));
 
                if( (controltype == CONTROLTYPE_ACK)
                                && (peer_id <= MAX_UDP_PEERS))
@@ -2398,15 +2398,15 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
        }
        else if(type == TYPE_ORIGINAL)
        {
-               if(packetdata.getSize() < ORIGINAL_HEADER_SIZE)
+               if(packetdata.getSize() <= ORIGINAL_HEADER_SIZE)
                        throw InvalidIncomingDataException
-                                       ("packetdata.getSize() < ORIGINAL_HEADER_SIZE");
+                                       ("packetdata.getSize() <= ORIGINAL_HEADER_SIZE");
                LOG(dout_con<<m_connection->getDesc()
                                <<"RETURNING TYPE_ORIGINAL to user"
                                <<std::endl);
                // Get the inside packet out and return it
                SharedBuffer<u8> payload(packetdata.getSize() - ORIGINAL_HEADER_SIZE);
-               memcpy(*payload, &packetdata[ORIGINAL_HEADER_SIZE], payload.getSize());
+               memcpy(*payload, &(packetdata[ORIGINAL_HEADER_SIZE]), payload.getSize());
                return payload;
        }
        else if(type == TYPE_SPLIT)
index f18473ee001455d54524cd3ba41ecc125bde72b0..bba0006403a5e859a84617e8208469162b8277b5 100644 (file)
@@ -226,7 +226,8 @@ bool GUIEngine::loadMainMenuScript()
                }
                else {
                        infostream
-                               << "GUIEngine: execution of custom menu failed!"
+                               << "GUIEngine: execution of custom menu: \""
+                               << menuscript << "\" failed!"
                                << std::endl
                                << "\tfalling back to builtin menu"
                                << std::endl;
index e545dc42aa746726d46d4d98be92079f174b1d5d..a7a105fc5c8e09791bdc7cffd7cfa1d2d8bf825f 100644 (file)
@@ -268,8 +268,9 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
                                if(nodemgr->get(map->getNode(p)).walkable == false)
                                        continue;
                                // And the node above it has to be nonwalkable
-                               if(nodemgr->get(map->getNode(p+v3s16(0,1,0))).walkable == true)
+                               if(nodemgr->get(map->getNode(p+v3s16(0,1,0))).walkable == true) {
                                        continue;
+                               }
                                if (!physics_override_sneak_glitch) {
                                        if (nodemgr->get(map->getNode(p+v3s16(0,2,0))).walkable)
                                                continue;
index bb0c3a273c9803b11ceababf8120395f8882672b..376ce2ae2659e172a2fa4744db3d80d2c8ef730e 100644 (file)
@@ -266,6 +266,7 @@ public:
                        } else {
                                keyIsDown.unset(event.KeyInput);
                        }
+                       return true;
                }
 
                if(event.EventType == irr::EET_MOUSE_INPUT_EVENT)
@@ -1484,10 +1485,11 @@ int main(int argc, char *argv[])
        bool random_input = g_settings->getBool("random_input")
                        || cmd_args.getFlag("random-input");
        InputHandler *input = NULL;
-       if(random_input)
+       if(random_input) {
                input = new RandomInputHandler();
-       else
+       } else {
                input = new RealInputHandler(device, &receiver);
+       }
 
        scene::ISceneManager* smgr = device->getSceneManager();
 
index e7bef1d33f30c5ec3f718180c0a8b073d244ac18..53b3a37846ecc6621604205b1dd7946aa61a68cd 100644 (file)
@@ -191,7 +191,7 @@ bool threadBindToProcessor(threadid_t tid, int pnumber) {
 
 #elif defined(__sun) || defined(sun)
 
-       return processor_bind(P_LWPID, MAKE_LWPID_PTHREAD(tid), 
+       return processor_bind(P_LWPID, MAKE_LWPID_PTHREAD(tid),
                                                pnumber, NULL) == 0;
 
 #elif defined(_AIX)
@@ -477,7 +477,7 @@ void initializePaths()
                        i != trylist.end(); i++)
        {
                const std::string &trypath = *i;
-               if(!fs::PathExists(trypath) || !fs::PathExists(trypath + "/builtin")){
+               if(!fs::PathExists(trypath) || !fs::PathExists(trypath + DIR_DELIM + "builtin")){
                        dstream<<"WARNING: system-wide share not found at \""
                                        <<trypath<<"\""<<std::endl;
                        continue;
@@ -491,37 +491,37 @@ void initializePaths()
                break;
        }
 
-       path_user = std::string(getenv("HOME")) + "/." + PROJECT_NAME;
+       path_user = std::string(getenv("HOME")) + DIR_DELIM + "." + PROJECT_NAME;
 
        /*
                OS X
        */
        #elif defined(__APPLE__)
 
-    // Code based on
-    // http://stackoverflow.com/questions/516200/relative-paths-not-working-in-xcode-c
-    CFBundleRef main_bundle = CFBundleGetMainBundle();
-    CFURLRef resources_url = CFBundleCopyResourcesDirectoryURL(main_bundle);
-    char path[PATH_MAX];
-    if(CFURLGetFileSystemRepresentation(resources_url, TRUE, (UInt8 *)path, PATH_MAX))
+       // Code based on
+       // http://stackoverflow.com/questions/516200/relative-paths-not-working-in-xcode-c
+       CFBundleRef main_bundle = CFBundleGetMainBundle();
+       CFURLRef resources_url = CFBundleCopyResourcesDirectoryURL(main_bundle);
+       char path[PATH_MAX];
+       if(CFURLGetFileSystemRepresentation(resources_url, TRUE, (UInt8 *)path, PATH_MAX))
        {
                dstream<<"Bundle resource path: "<<path<<std::endl;
                //chdir(path);
-               path_share = std::string(path) + "/share";
+               path_share = std::string(path) + DIR_DELIM + "share";
        }
        else
-    {
-        // error!
+       {
+               // error!
                dstream<<"WARNING: Could not determine bundle resource path"<<std::endl;
-    }
-    CFRelease(resources_url);
+       }
+       CFRelease(resources_url);
 
        path_user = std::string(getenv("HOME")) + "/Library/Application Support/" + PROJECT_NAME;
 
        #else // FreeBSD, and probably many other POSIX-like systems.
 
        path_share = STATIC_SHAREDIR;
-       path_user = std::string(getenv("HOME")) + "/." + PROJECT_NAME;
+       path_user = std::string(getenv("HOME")) + DIR_DELIM + "." + PROJECT_NAME;
 
        #endif
 
index 53e8d8ef5c85d43b30fa7c6889bb5b539824f5e2..13c8e1e65e6a7d42b61933629d624560bca05e97 100644 (file)
@@ -37,6 +37,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include <map>
 #include <set>
 #include "filesys.h"
+#include <cctype>
 
 enum ValueType
 {
@@ -575,7 +576,7 @@ public:
        u32 getFlagStr(std::string name, FlagDesc *flagdesc, u32 *flagmask)
        {
                std::string val = get(name);
-               return (isdigit(val[0])) ? stoi(val) :
+               return (std::isdigit(val[0])) ? stoi(val) :
                        readFlagString(val, flagdesc, flagmask);
        }
 
index b8080c7084b9742a7749bef5b17b7e1daf872634..78aa4d94659fd10a23203b7e9294a771c3e72a5c 100644 (file)
@@ -730,9 +730,6 @@ u32 TextureSource::getTextureIdDirect(const std::string &name)
        m_textureinfo_cache.push_back(ti);
        m_name_to_id[name] = id;
 
-       /*infostream<<"getTextureIdDirect(): "
-                       <<"Returning id="<<id<<" for name \""<<name<<"\""<<std::endl;*/
-
        return id;
 }
 
@@ -962,6 +959,20 @@ bool TextureSource::generateImage(std::string part_of_name, video::IImage *& bas
        {
                video::IImage *image = m_sourcecache.getOrLoad(part_of_name, m_device);
 
+               if (image != NULL) {
+                       if (!driver->queryFeature(irr::video::EVDF_TEXTURE_NPOT)) {
+                               core::dimension2d<u32> dim = image->getDimension();
+
+
+                               if ((dim.Height %2 != 0) ||
+                                               (dim.Width %2 != 0)) {
+                                       errorstream << "TextureSource::generateImage "
+                                                       << part_of_name << " size npot2 x=" << dim.Width
+                                                       << " y=" << dim.Height << std::endl;
+                               }
+                       }
+               }
+
                if(image == NULL)
                {
                        if(part_of_name != ""){
index ba43b7844fc3189dcf4ebc424e38b21d409b6365..7922a9b395734bc074e3a911e5f4cd06dde655fb 100644 (file)
@@ -258,7 +258,7 @@ public:
        }
        T & operator[](unsigned int i) const
        {
-               //assert(i < m_size)
+               assert(i < m_size);
                return data[i];
        }
        T * operator*() const