mirror of
https://github.com/glest/glest-source.git
synced 2025-08-20 15:11:20 +02:00
code cleanup based on cppcheck results
This commit is contained in:
@@ -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"
|
||||
|
@@ -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();
|
||||
|
@@ -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
|
||||
|
@@ -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();
|
||||
|
@@ -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) {
|
||||
|
@@ -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));
|
||||
|
@@ -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() {
|
||||
|
@@ -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!");
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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!");
|
||||
}
|
||||
|
||||
|
@@ -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<tabLevel; ++i)
|
||||
fprintf(outStream, "\t");
|
||||
|
Reference in New Issue
Block a user