From 118e2ae865bd7a0020586ef72d05bf14d66f4eae Mon Sep 17 00:00:00 2001 From: Sfan5 Date: Tue, 15 Apr 2014 19:49:32 +0200 Subject: [PATCH] Fix all warnings reported by clang --- src/camera.cpp | 1 - src/camera.h | 3 +-- src/cguittfont/irrUString.h | 16 ++++++++-------- src/clientiface.h | 6 +++--- src/clientobject.h | 2 +- src/clouds.h | 1 - src/connection.cpp | 5 ++--- src/connection.h | 5 +---- src/content_cao.cpp | 9 ++++----- src/emerge.cpp | 2 +- src/environment.cpp | 5 ++--- src/environment.h | 1 - src/game.cpp | 2 +- src/guiVolumeChange.cpp | 3 +-- src/guiVolumeChange.h | 6 +----- src/localplayer.cpp | 4 ++-- src/localplayer.h | 6 +++--- src/main.cpp | 1 - src/map.cpp | 4 +++- src/mapgen.h | 2 +- src/mapgen_indev.cpp | 6 +++--- src/mapgen_indev.h | 2 +- src/player.h | 7 ++++++- src/script/cpp_api/s_item.h | 2 +- src/script/lua_api/l_mapgen.cpp | 4 ++-- src/shader.cpp | 6 +----- src/sky.h | 1 - 27 files changed, 49 insertions(+), 63 deletions(-) diff --git a/src/camera.cpp b/src/camera.cpp index 6fbd1dd8..b49e8e74 100644 --- a/src/camera.cpp +++ b/src/camera.cpp @@ -44,7 +44,6 @@ with this program; if not, write to the Free Software Foundation, Inc., Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control, IGameDef *gamedef): - m_smgr(smgr), m_playernode(NULL), m_headnode(NULL), m_cameranode(NULL), diff --git a/src/camera.h b/src/camera.h index 82c8d4be..d1c3b59d 100644 --- a/src/camera.h +++ b/src/camera.h @@ -136,8 +136,7 @@ public: void drawWieldedTool(); private: - // Scene manager and nodes - scene::ISceneManager* m_smgr; + // Nodes scene::ISceneNode* m_playernode; scene::ISceneNode* m_headnode; scene::ICameraSceneNode* m_cameranode; diff --git a/src/cguittfont/irrUString.h b/src/cguittfont/irrUString.h index 21109ea4..132a35ee 100644 --- a/src/cguittfont/irrUString.h +++ b/src/cguittfont/irrUString.h @@ -3395,7 +3395,7 @@ inline ustring16 operator+(const ustring16& left, const short ri template inline ustring16 operator+(const short left, const ustring16& right) { - ustring16 ret(core::stringc(left)); + ustring16 ret((core::stringc(left))); ret += right; return ret; } @@ -3415,7 +3415,7 @@ inline ustring16 operator+(const ustring16& left, const unsigned template inline ustring16 operator+(const unsigned short left, const ustring16& right) { - ustring16 ret(core::stringc(left)); + ustring16 ret((core::stringc(left))); ret += right; return ret; } @@ -3435,7 +3435,7 @@ inline ustring16 operator+(const ustring16& left, const int righ template inline ustring16 operator+(const int left, const ustring16& right) { - ustring16 ret(core::stringc(left)); + ustring16 ret((core::stringc(left))); ret += right; return ret; } @@ -3455,7 +3455,7 @@ inline ustring16 operator+(const ustring16& left, const unsigned template inline ustring16 operator+(const unsigned int left, const ustring16& right) { - ustring16 ret(core::stringc(left)); + ustring16 ret((core::stringc(left))); ret += right; return ret; } @@ -3475,7 +3475,7 @@ inline ustring16 operator+(const ustring16& left, const long rig template inline ustring16 operator+(const long left, const ustring16& right) { - ustring16 ret(core::stringc(left)); + ustring16 ret((core::stringc(left))); ret += right; return ret; } @@ -3495,7 +3495,7 @@ inline ustring16 operator+(const ustring16& left, const unsigned template inline ustring16 operator+(const unsigned long left, const ustring16& right) { - ustring16 ret(core::stringc(left)); + ustring16 ret((core::stringc(left))); ret += right; return ret; } @@ -3515,7 +3515,7 @@ inline ustring16 operator+(const ustring16& left, const float ri template inline ustring16 operator+(const float left, const ustring16& right) { - ustring16 ret(core::stringc(left)); + ustring16 ret((core::stringc(left))); ret += right; return ret; } @@ -3535,7 +3535,7 @@ inline ustring16 operator+(const ustring16& left, const double r template inline ustring16 operator+(const double left, const ustring16& right) { - ustring16 ret(core::stringc(left)); + ustring16 ret((core::stringc(left))); ret += right; return ret; } diff --git a/src/clientiface.h b/src/clientiface.h index 95f8bd30..752e2bb8 100644 --- a/src/clientiface.h +++ b/src/clientiface.h @@ -141,6 +141,8 @@ namespace con { class Connection; } +#define ARRAYSIZE(a) (sizeof(a) / sizeof((a)[0])) + enum ClientState { Invalid, @@ -219,7 +221,6 @@ public: m_nearest_unsent_d(0), m_nearest_unsent_reset_timer(0.0), m_excess_gotblocks(0), - m_nothing_to_send_counter(0), m_nothing_to_send_pause_timer(0.0), m_name(""), m_version_major(0), @@ -355,7 +356,6 @@ private: u32 m_excess_gotblocks; // CPU usage optimization - u32 m_nothing_to_send_counter; float m_nothing_to_send_pause_timer; /* @@ -433,7 +433,7 @@ public: { assert(m_env == 0); m_env = env; } static std::string state2Name(ClientState state) { - assert(state < sizeof(statenames)); + assert((int) state < ARRAYSIZE(statenames)); return statenames[state]; } diff --git a/src/clientobject.h b/src/clientobject.h index 613c635a..233617b5 100644 --- a/src/clientobject.h +++ b/src/clientobject.h @@ -55,7 +55,7 @@ public: virtual void updateLight(u8 light_at_pos){} virtual v3s16 getLightPosition(){return v3s16(0,0,0);} virtual core::aabbox3d* getSelectionBox(){return NULL;} - virtual core::aabbox3d* getCollisionBox(){return NULL;} + virtual bool getCollisionBox(aabb3f *toset){return false;} virtual bool collideWithObjects(){return false;} virtual v3f getPosition(){return v3f(0,0,0);} virtual scene::IMeshSceneNode *getMeshSceneNode(){return NULL;} diff --git a/src/clouds.h b/src/clouds.h index d718e56b..a6883a44 100644 --- a/src/clouds.h +++ b/src/clouds.h @@ -76,7 +76,6 @@ private: video::SMaterial m_material; core::aabbox3d m_box; float m_cloud_y; - float m_brightness; video::SColorf m_color; u32 m_seed; v2f m_camera_pos; diff --git a/src/connection.cpp b/src/connection.cpp index c77ee7f4..32634ac8 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -212,7 +212,7 @@ SharedBuffer makeReliablePacket( ReliablePacketBuffer */ -ReliablePacketBuffer::ReliablePacketBuffer(): m_list_size(0),writeptr(0) {} +ReliablePacketBuffer::ReliablePacketBuffer(): m_list_size(0) {} void ReliablePacketBuffer::print() { @@ -1941,8 +1941,7 @@ void ConnectionSendThread::sendAsPacket(u16 peer_id, u8 channelnum, ConnectionReceiveThread::ConnectionReceiveThread(Connection* parent, unsigned int max_packet_size) : - m_connection(parent), - m_max_packet_size(max_packet_size) + m_connection(parent) { } diff --git a/src/connection.h b/src/connection.h index 0f936eb3..43fd2fb8 100644 --- a/src/connection.h +++ b/src/connection.h @@ -339,13 +339,11 @@ private: RPBSearchResult findPacket(u16 seqnum); std::list m_list; - u16 m_list_size; + u32 m_list_size; u16 m_oldest_non_answered_ack; JMutex m_list_mutex; - - unsigned int writeptr; }; /* @@ -975,7 +973,6 @@ private: Connection* m_connection; - unsigned int m_max_packet_size; }; class Connection diff --git a/src/content_cao.cpp b/src/content_cao.cpp index 5f53fd64..10aa22e7 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -166,7 +166,7 @@ public: void addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc, IrrlichtDevice *irr); - void removeFromScene(); + void removeFromScene(bool permanent); void updateLight(u8 light_at_pos); v3s16 getLightPosition(); void updateNodePos(); @@ -236,7 +236,7 @@ void TestCAO::addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc, updateNodePos(); } -void TestCAO::removeFromScene() +void TestCAO::removeFromScene(bool permanent) { if(m_node == NULL) return; @@ -310,7 +310,7 @@ public: void addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc, IrrlichtDevice *irr); - void removeFromScene(); + void removeFromScene(bool permanent); void updateLight(u8 light_at_pos); v3s16 getLightPosition(); void updateNodePos(); @@ -412,7 +412,7 @@ void ItemCAO::addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc, updateTexture(); } -void ItemCAO::removeFromScene() +void ItemCAO::removeFromScene(bool permanent) { if(m_node == NULL) return; @@ -648,7 +648,6 @@ public: bool getCollisionBox(aabb3f *toset) { if (m_prop.physical) { - aabb3f retval; //update collision box toset->MinEdge = m_prop.collisionbox.MinEdge * BS; toset->MaxEdge = m_prop.collisionbox.MaxEdge * BS; diff --git a/src/emerge.cpp b/src/emerge.cpp index c26fab83..443d7038 100644 --- a/src/emerge.cpp +++ b/src/emerge.cpp @@ -465,7 +465,7 @@ void *EmergeThread::Thread() { v3s16 last_tried_pos(-32768,-32768,-32768); // For error output v3s16 p; - u8 flags; + u8 flags = 0; map = (ServerMap *)&(m_server->m_env->getMap()); emerge = m_server->m_emerge; diff --git a/src/environment.cpp b/src/environment.cpp index 630f8d21..bc1b59d8 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -314,7 +314,6 @@ ServerEnvironment::ServerEnvironment(ServerMap *map, m_map(map), m_script(scriptIface), m_gamedef(gamedef), - m_random_spawn_timer(3), m_send_recommended_timer(0), m_active_block_interval_overload_skip(0), m_game_time(0), @@ -1097,7 +1096,7 @@ void ServerEnvironment::step(float dtime) continue; // Move - player->move(dtime, *m_map, 100*BS); + player->move(dtime, this, 100*BS); } } @@ -2395,7 +2394,7 @@ void ClientEnvironment::step(float dtime) if(player->isLocal() == false) { // Move - player->move(dtime, *m_map, 100*BS); + player->move(dtime, this, 100*BS); } diff --git a/src/environment.h b/src/environment.h index d99e27ba..48d099bf 100644 --- a/src/environment.h +++ b/src/environment.h @@ -374,7 +374,6 @@ private: // Outgoing network message buffer for active objects std::list m_active_object_messages; // Some timers - float m_random_spawn_timer; // used for experimental code float m_send_recommended_timer; IntervalLimiter m_object_management_interval; // List of active blocks diff --git a/src/game.cpp b/src/game.cpp index 2e8d3761..1ad06acb 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -132,7 +132,7 @@ struct LocalFormspecHandler : public TextDest m_client = client; } - void gotText(std::string message) { + void gotText(std::wstring message) { errorstream << "LocalFormspecHandler::gotText old style message received" << std::endl; } diff --git a/src/guiVolumeChange.cpp b/src/guiVolumeChange.cpp index 5e7476bb..f31c650f 100644 --- a/src/guiVolumeChange.cpp +++ b/src/guiVolumeChange.cpp @@ -41,8 +41,7 @@ GUIVolumeChange::GUIVolumeChange(gui::IGUIEnvironment* env, IMenuManager *menumgr, Client* client ): - GUIModalMenu(env, parent, id, menumgr), - m_client(client) + GUIModalMenu(env, parent, id, menumgr) { } diff --git a/src/guiVolumeChange.h b/src/guiVolumeChange.h index 5258ee10..9f8199fa 100644 --- a/src/guiVolumeChange.h +++ b/src/guiVolumeChange.h @@ -44,11 +44,7 @@ public: bool OnEvent(const SEvent& event); - bool pausesGame(){ return true; } - -private: - Client* m_client; - + bool pausesGame() { return true; } }; #endif diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 15a208b8..e545dc42 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -65,7 +65,7 @@ LocalPlayer::~LocalPlayer() { } -void LocalPlayer::move(f32 dtime, ClientEnvironment *env, f32 pos_max_d, +void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d, std::list *collision_info) { Map *map = &env->getMap(); @@ -360,7 +360,7 @@ void LocalPlayer::move(f32 dtime, ClientEnvironment *env, f32 pos_max_d, m_can_jump = false; } -void LocalPlayer::move(f32 dtime, ClientEnvironment *env, f32 pos_max_d) +void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d) { move(dtime, env, pos_max_d, NULL); } diff --git a/src/localplayer.h b/src/localplayer.h index 67deb936..38e7a4cd 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "player.h" #include -class ClientEnvironment; +class Environment; class ClientActiveObject; @@ -46,9 +46,9 @@ public: v3f overridePosition; - void move(f32 dtime, ClientEnvironment *env, f32 pos_max_d, + void move(f32 dtime, Environment *env, f32 pos_max_d); + void move(f32 dtime, Environment *env, f32 pos_max_d, std::list *collision_info); - void move(f32 dtime, ClientEnvironment *env, f32 pos_max_d); void applyControl(float dtime); diff --git a/src/main.cpp b/src/main.cpp index baaf8ebd..c93af0d7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -360,7 +360,6 @@ public: s32 mouse_wheel; private: - IrrlichtDevice *m_device; // The current state of keys KeyList keyIsDown; diff --git a/src/map.cpp b/src/map.cpp index 22ea41e0..ec97fedf 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -2596,6 +2596,7 @@ bool ServerMap::initBlockMake(BlockMakeData *data, v3s16 blockpos) // Sector metadata is loaded from disk if not already loaded. ServerMapSector *sector = createSector(sectorpos); assert(sector); + (void) sector; for(s16 y=blockpos_min.Y-extra_borders.Y; y<=blockpos_max.Y+extra_borders.Y; y++) @@ -3261,12 +3262,13 @@ std::string ServerMap::getSectorDir(v2s16 pos, int layout) return m_savedir + DIR_DELIM + "sectors2" + DIR_DELIM + cc; default: assert(false); + return ""; } } v2s16 ServerMap::getSectorPos(std::string dirname) { - unsigned int x, y; + unsigned int x = 0, y = 0; int r; std::string component; fs::RemoveLastPathComponent(dirname, &component, 1); diff --git a/src/mapgen.h b/src/mapgen.h index 9bc162fe..3c897e02 100644 --- a/src/mapgen.h +++ b/src/mapgen.h @@ -209,7 +209,7 @@ Ore *createOre(OreType type); enum DecorationType { - DECO_SIMPLE, + DECO_SIMPLE = 1, DECO_SCHEMATIC, DECO_LSYSTEM }; diff --git a/src/mapgen_indev.cpp b/src/mapgen_indev.cpp index ac5b4e81..f0154715 100644 --- a/src/mapgen_indev.cpp +++ b/src/mapgen_indev.cpp @@ -26,9 +26,9 @@ with this program; if not, write to the Free Software Foundation, Inc., /////////////////////////////////////////////////////////////////////////////// -void NoiseIndev::init(NoiseIndevParams *np, int seed, int sx, int sy, int sz) { - Noise::init((NoiseParams*)np, seed, sx, sy, sz); - this->npindev = np; +void NoiseIndev::init(NoiseParams *np, int seed, int sx, int sy, int sz) { + Noise::init(np, seed, sx, sy, sz); + this->npindev = (NoiseIndevParams*) np; } NoiseIndev::NoiseIndev(NoiseIndevParams *np, int seed, int sx, int sy) : Noise(np, seed, sx, sy) { diff --git a/src/mapgen_indev.h b/src/mapgen_indev.h index a5b0a667..d8be7dce 100644 --- a/src/mapgen_indev.h +++ b/src/mapgen_indev.h @@ -61,7 +61,7 @@ public: virtual ~NoiseIndev() {}; NoiseIndev(NoiseIndevParams *np, int seed, int sx, int sy); NoiseIndev(NoiseIndevParams *np, int seed, int sx, int sy, int sz); - void init(NoiseIndevParams *np, int seed, int sx, int sy, int sz); + void init(NoiseParams *np, int seed, int sx, int sy, int sz); void transformNoiseMapFarScale(float xx = 0, float yy = 0, float zz = 0); }; diff --git a/src/player.h b/src/player.h index dce16743..4c5939d3 100644 --- a/src/player.h +++ b/src/player.h @@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "irrlichttypes_bloated.h" #include "inventory.h" #include "constants.h" // BS +#include #define PLAYERNAME_SIZE 20 @@ -88,6 +89,7 @@ class IGameDef; struct CollisionInfo; class PlayerSAO; struct HudElement; +class Environment; class Player { @@ -96,7 +98,10 @@ public: Player(IGameDef *gamedef); virtual ~Player() = 0; - virtual void move(f32 dtime, Map &map, f32 pos_max_d) + virtual void move(f32 dtime, Environment *env, f32 pos_max_d) + {} + virtual void move(f32 dtime, Environment *env, f32 pos_max_d, + std::list *collision_info) {} v3f getSpeed() diff --git a/src/script/cpp_api/s_item.h b/src/script/cpp_api/s_item.h index cca1641f..88cc1909 100644 --- a/src/script/cpp_api/s_item.h +++ b/src/script/cpp_api/s_item.h @@ -30,7 +30,7 @@ struct ItemDefinition; class LuaItemStack; class ModApiItemMod; class InventoryList; -class InventoryLocation; +struct InventoryLocation; class ScriptApiItem : virtual public ScriptApiBase diff --git a/src/script/lua_api/l_mapgen.cpp b/src/script/lua_api/l_mapgen.cpp index 56109a9d..9fbb46ee 100644 --- a/src/script/lua_api/l_mapgen.cpp +++ b/src/script/lua_api/l_mapgen.cpp @@ -324,8 +324,8 @@ int ModApiMapgen::l_register_decoration(lua_State *L) BiomeDefManager *bdef = emerge->biomedef; enum DecorationType decotype = (DecorationType)getenumfield(L, index, - "deco_type", es_DecorationType, -1); - if (decotype == -1) { + "deco_type", es_DecorationType, 0); + if (decotype == 0) { errorstream << "register_decoration: unrecognized " "decoration placement type"; return 0; diff --git a/src/shader.cpp b/src/shader.cpp index 4006e256..4013add6 100644 --- a/src/shader.cpp +++ b/src/shader.cpp @@ -210,8 +210,7 @@ public: class MainShaderConstantSetter : public IShaderConstantSetter { public: - MainShaderConstantSetter(IrrlichtDevice *device): - m_device(device) + MainShaderConstantSetter(IrrlichtDevice *device) {} ~MainShaderConstantSetter() {} @@ -255,9 +254,6 @@ public: services->setVertexShaderConstant(world.pointer(), 8, 4); } - -private: - IrrlichtDevice *m_device; }; /* diff --git a/src/sky.h b/src/sky.h index 06a99310..c906bd32 100644 --- a/src/sky.h +++ b/src/sky.h @@ -125,7 +125,6 @@ private: video::SColor m_skycolor; video::SColorf m_cloudcolor_f; v3f m_stars[SKY_STAR_COUNT]; - u16 m_star_indices[SKY_STAR_COUNT*4]; video::S3DVertex m_star_vertices[SKY_STAR_COUNT*4]; LocalPlayer* m_player; }; -- 2.30.2