diff --git a/mk/linux/mg_cppcheck.sh b/mk/linux/mg_cppcheck.sh index eb4a5faad..39eb54bd9 100755 --- a/mk/linux/mg_cppcheck.sh +++ b/mk/linux/mg_cppcheck.sh @@ -9,6 +9,6 @@ OUTFILE=./cppcheck.log CPUS=`lscpu -p | grep -cv '^#'` if [ "$CPUS" = '' ]; then CPUS=1; fi -cppcheck ../../source/ -i ../../source/win32_deps -i ../../source/configurator -j $CPUS --enable=all --force --verbose 2> $OUTFILE +cppcheck ../../source/ -i ../../source/win32_deps -i ../../source/configurator -i ../../source/shared_lib/sources/libircclient -i ../../source/shared_lib/sources/platform/miniupnpc -j $CPUS --enable=all --force --verbose 2> $OUTFILE echo "Results from cppcheck were written to $OUTFILE" diff --git a/source/glest_game/ai/ai_interface.cpp b/source/glest_game/ai/ai_interface.cpp index 6b9fe3f1a..805aa683c 100644 --- a/source/glest_game/ai/ai_interface.cpp +++ b/source/glest_game/ai/ai_interface.cpp @@ -246,6 +246,21 @@ AiInterface::AiInterface(Game &game, int factionIndex, int teamIndex, if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); } +void AiInterface::init() { + world=NULL;; + commander=NULL;; + console=NULL;; + gameSettings=NULL;; + timer=0; + factionIndex=0; + teamIndex=0; + redir=false; + logLevel=0; + fp=NULL;; + aiMutex=NULL; + workerThread=NULL; +} + AiInterface::~AiInterface() { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] deleting AI factionIndex = %d, teamIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,this->factionIndex,this->teamIndex); cacheUnitHarvestResourceLookup.clear(); diff --git a/source/glest_game/ai/ai_interface.h b/source/glest_game/ai/ai_interface.h index af73a5e12..e0cedefdd 100644 --- a/source/glest_game/ai/ai_interface.h +++ b/source/glest_game/ai/ai_interface.h @@ -88,9 +88,11 @@ public: ~AiInterface(); AiInterface(const AiInterface& obj) { + init(); throw megaglest_runtime_error("class AiInterface is NOT safe to copy!"); } AiInterface & operator=(const AiInterface& obj) { + init(); throw megaglest_runtime_error("class AiInterface is NOT safe to assign!"); } @@ -161,6 +163,8 @@ public: private: string getLogFilename() const {return "ai"+intToStr(factionIndex)+".log";} bool executeCommandOverNetwork(); + + void init(); }; }}//end namespace diff --git a/source/glest_game/ai/path_finder.cpp b/source/glest_game/ai/path_finder.cpp index 6dec34790..c9d49765d 100644 --- a/source/glest_game/ai/path_finder.cpp +++ b/source/glest_game/ai/path_finder.cpp @@ -85,6 +85,12 @@ void PathFinder::init(const Map *map) { this->map= map; } +void PathFinder::init() { + minorDebugPathfinder = false; + factionMutex = NULL; + map=NULL; +} + PathFinder::~PathFinder() { for(int i = 0; i < GameConstants::maxPlayers; ++i) { factions[i].nodePool.clear(); diff --git a/source/glest_game/ai/path_finder.h b/source/glest_game/ai/path_finder.h index 20c51b176..b370323d6 100644 --- a/source/glest_game/ai/path_finder.h +++ b/source/glest_game/ai/path_finder.h @@ -160,9 +160,11 @@ public: ~PathFinder(); PathFinder(const PathFinder& obj) { + init(); throw megaglest_runtime_error("class PathFinder is NOT safe to copy!"); } PathFinder & operator=(const PathFinder& obj) { + init(); throw megaglest_runtime_error("class PathFinder is NOT safe to assign!"); } @@ -181,6 +183,8 @@ public: void loadGame(const XmlNode *rootNode); private: + void init(); + TravelState aStar(Unit *unit, const Vec2i &finalPos, bool inBailout, int frameIndex, int maxNodeCount=-1,uint32 *searched_node_count=NULL); //Node *newNode(FactionState &faction,int maxNodeCount); inline static Node *newNode(FactionState &faction, int maxNodeCount) { diff --git a/source/glest_game/menu/menu_state_options_sound.cpp b/source/glest_game/menu/menu_state_options_sound.cpp index 8bd688236..f7e47b860 100644 --- a/source/glest_game/menu/menu_state_options_sound.cpp +++ b/source/glest_game/menu/menu_state_options_sound.cpp @@ -47,7 +47,7 @@ MenuStateOptionsSound::MenuStateOptionsSound(Program *program, MainMenu *mainMen int leftLabelStart=50; int leftColumnStart=leftLabelStart+280; - int rightLabelStart=450; + //int rightLabelStart=450; //int rightColumnStart=rightLabelStart+280; int buttonRowPos=50; int buttonStartPos=170; @@ -139,7 +139,7 @@ MenuStateOptionsSound::MenuStateOptionsSound(Program *program, MainMenu *mainMen listBoxVolumeMusic.registerGraphicComponent(containerName,"listBoxVolumeMusic"); listBoxVolumeMusic.init(currentColumnStart, currentLine, 80); labelVolumeMusic.setText(lang.get("MusicVolume")); - currentLine-=lineOffset; + //currentLine-=lineOffset; for(int i=0; i<=100; i+=5){ listBoxVolumeFx.pushBackItem(intToStr(i)); diff --git a/source/glest_game/network/network_interface.cpp b/source/glest_game/network/network_interface.cpp index 3884c00de..db8e19abb 100644 --- a/source/glest_game/network/network_interface.cpp +++ b/source/glest_game/network/network_interface.cpp @@ -47,7 +47,15 @@ NetworkInterface::NetworkInterface() { networkGameDataSynchCheckOkTile=false; networkGameDataSynchCheckOkTech=false; receivedDataSynchCheck=false; +} +void NetworkInterface::init() { + networkAccessMutex = NULL; + + networkGameDataSynchCheckOkMap=false; + networkGameDataSynchCheckOkTile=false; + networkGameDataSynchCheckOkTech=false; + receivedDataSynchCheck=false; } NetworkInterface::~NetworkInterface() { diff --git a/source/glest_game/network/network_interface.h b/source/glest_game/network/network_interface.h index 2d4a0f8a9..2d6fe1139 100644 --- a/source/glest_game/network/network_interface.h +++ b/source/glest_game/network/network_interface.h @@ -187,6 +187,7 @@ protected: Mutex *networkAccessMutex; + void init(); public: static const int readyWaitTimeout; GameSettings gameSettings; @@ -196,9 +197,11 @@ public: virtual ~NetworkInterface(); NetworkInterface(const NetworkInterface& obj) { + init(); throw megaglest_runtime_error("class NetworkInterface is NOT safe to copy!"); } NetworkInterface & operator=(const NetworkInterface& obj) { + init(); throw megaglest_runtime_error("class NetworkInterface is NOT safe to assign!"); } diff --git a/source/glest_map_editor/program.cpp b/source/glest_map_editor/program.cpp index 4c70945e9..cbfdcfb15 100644 --- a/source/glest_map_editor/program.cpp +++ b/source/glest_map_editor/program.cpp @@ -153,6 +153,14 @@ Program::Program(int w, int h) { renderer.initMapSurface(w, h); } +void Program::init() { + cellSize = 6; + grid=false; + ofsetX = 0; + ofsetY = 0; + map = NULL; +} + Program::~Program() { delete map; map = NULL; diff --git a/source/glest_map_editor/program.h b/source/glest_map_editor/program.h index b9e173fdc..7d28434b7 100644 --- a/source/glest_map_editor/program.h +++ b/source/glest_map_editor/program.h @@ -103,14 +103,17 @@ private: ChangeStack undoStack, redoStack; + void init(); public: Program(int w, int h); ~Program(); Program(const Program& obj) { + init(); throw runtime_error("class Program is NOT safe to copy!"); } Program & operator=(const Program& obj) { + init(); throw runtime_error("class Program is NOT safe to assign!"); } diff --git a/source/shared_lib/sources/util/profiler.cpp b/source/shared_lib/sources/util/profiler.cpp index b890785ba..165532908 100644 --- a/source/shared_lib/sources/util/profiler.cpp +++ b/source/shared_lib/sources/util/profiler.cpp @@ -44,7 +44,7 @@ Section *Section::getChild(const string &name){ void Section::print(FILE *outStream, int tabLevel){ float percent= (parent==NULL || parent->milisElapsed==0)? 100.0f: 100.0f*milisElapsed/parent->milisElapsed; - string pname= parent==NULL? "": parent->getName(); + //string pname= parent==NULL? "": parent->getName(); for(int i=0; i