From eda9214f81b32d9606f425e3777616e8cfc0a44f Mon Sep 17 00:00:00 2001 From: sapier Date: Sun, 6 Apr 2014 15:12:04 +0200 Subject: Bunch of small fixes (coding style, very unlikely errors, warning messages) --- src/client.h | 3 ++- src/connection.cpp | 18 +++++++++--------- src/guiEngine.cpp | 3 ++- src/localplayer.cpp | 3 ++- src/main.cpp | 6 ++++-- src/porting.cpp | 30 +++++++++++++++--------------- src/settings.h | 3 ++- src/tile.cpp | 17 ++++++++++++++--- src/util/pointer.h | 2 +- 9 files changed, 51 insertions(+), 34 deletions(-) diff --git a/src/client.h b/src/client.h index a5fda98d7..885dc9d3b 100644 --- a/src/client.h +++ b/src/client.h @@ -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(); diff --git a/src/connection.cpp b/src/connection.cpp index 32634ac89..ae1e4a1db 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -111,10 +111,10 @@ SharedBuffer makeOriginalPacket( u32 packet_size = data.getSize() + header_size; SharedBuffer 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 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 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<getDesc() <<"RETURNING TYPE_ORIGINAL to user" < 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) diff --git a/src/guiEngine.cpp b/src/guiEngine.cpp index f18473ee0..bba000640 100644 --- a/src/guiEngine.cpp +++ b/src/guiEngine.cpp @@ -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; diff --git a/src/localplayer.cpp b/src/localplayer.cpp index e545dc42a..a7a105fc5 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -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; diff --git a/src/main.cpp b/src/main.cpp index bb0c3a273..376ce2ae2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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(); diff --git a/src/porting.cpp b/src/porting.cpp index e7bef1d33..53b3a3784 100644 --- a/src/porting.cpp +++ b/src/porting.cpp @@ -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 \"" < #include #include "filesys.h" +#include 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); } diff --git a/src/tile.cpp b/src/tile.cpp index b8080c708..78aa4d946 100644 --- a/src/tile.cpp +++ b/src/tile.cpp @@ -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="<queryFeature(irr::video::EVDF_TEXTURE_NPOT)) { + core::dimension2d 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 != ""){ diff --git a/src/util/pointer.h b/src/util/pointer.h index ba43b7844..7922a9b39 100644 --- a/src/util/pointer.h +++ b/src/util/pointer.h @@ -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 -- cgit v1.2.3