- phase 2 of cppcheck verbose fixes

This commit is contained in:
Mark Vejvoda 2011-09-01 01:11:23 +00:00
parent 29b610344d
commit 57afc2d715
55 changed files with 511 additions and 149 deletions

View File

@ -320,7 +320,7 @@ public:
int line=-1;
const int maxbufSize = 1024;
static char buf[maxbufSize+1]="";
char *p=NULL;
//char *p=NULL;
// prepare command to be executed
// our program need to be passed after the -e parameter

View File

@ -106,7 +106,7 @@ void MenuStateGraphicInfo::keyDown(SDL_KeyboardEvent key) {
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
//if(key == configKeys.getCharKey("SaveGUILayout")) {
if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),key) == true) {
bool saved = GraphicComponent::saveAllCustomProperties(containerName);
GraphicComponent::saveAllCustomProperties(containerName);
//Lang &lang= Lang::getInstance();
//console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
}

View File

@ -173,7 +173,7 @@ void MenuStateJoinGame::DiscoveredServers(std::vector<string> serverList) {
autoConnectToServer = false;
buttonAutoFindServers.setEnabled(true);
buttonConnect.setEnabled(true);
if(serverList.size() > 0) {
if(serverList.empty() == false) {
string bestIPMatch = "";
std::vector<std::string> localIPList = Socket::getLocalIPAddressList();
@ -513,7 +513,7 @@ void MenuStateJoinGame::keyPress(SDL_KeyboardEvent c) {
if(clientInterface->isConnected() == false) {
int maxTextSize= 16;
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
//Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
SDLKey key = extractKeyPressed(c);

View File

@ -231,7 +231,7 @@ void MenuStateKeysetup::mouseClick(int x, int y, MouseButton mouseButton){
soundRenderer.playFx(coreData.getClickSoundB());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(userProperties.size() > 0) {
if(userProperties.empty() == false) {
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
string userKeysFile = configKeys.getFileName(true);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] save file [%s] userProperties.size() = %lu\n",__FILE__,__FUNCTION__,__LINE__,userKeysFile.c_str(),userProperties.size());

View File

@ -827,7 +827,7 @@ void MenuStateMasterserver::simpleTask(BaseThread *callingThread) {
announcementLoaded=true;
}
Lang &lang= Lang::getInstance();
//Lang &lang= Lang::getInstance();
try {
if(Config::getInstance().getString("Masterserver","") != "") {
@ -943,7 +943,7 @@ bool MenuStateMasterserver::connectToServer(string ipString, int port) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] START ipString='%s'\n",__FILE__,__FUNCTION__,ipString.c_str());
ClientInterface* clientInterface= NetworkManager::getInstance().getClientInterface();
Config& config= Config::getInstance();
//Config& config= Config::getInstance();
Ip serverIp(ipString);
//int serverPort = Config::getInstance().getInt("ServerPort",intToStr(GameConstants::serverPort).c_str());

View File

@ -82,6 +82,7 @@ MenuStateMods::MenuStateMods(Program *program, MainMenu *mainMenu) :
keyButtonsYBase = scrollListsYPos;
keyButtonsToRender = listBoxLength / keyButtonsLineHeight;
labelWidth = 5;
keyButtonsXBase = 0;
int installButtonYPos = scrollListsYPos-listBoxLength-20;
@ -245,7 +246,7 @@ MenuStateMods::MenuStateMods(Program *program, MainMenu *mainMenu) :
vector<string> mapPathList = config.getPathListForType(ptMaps);
std::pair<string,string> mapsPath;
if(mapPathList.size() > 0) {
if(mapPathList.empty() == false) {
mapsPath.first = mapPathList[0];
}
if(mapPathList.size() > 1) {
@ -253,7 +254,7 @@ MenuStateMods::MenuStateMods(Program *program, MainMenu *mainMenu) :
}
std::pair<string,string> tilesetsPath;
vector<string> tilesetsList = Config::getInstance().getPathListForType(ptTilesets);
if(tilesetsList.size() > 0) {
if(tilesetsList.empty() == false) {
tilesetsPath.first = tilesetsList[0];
if(tilesetsList.size() > 1) {
tilesetsPath.second = tilesetsList[1];
@ -262,7 +263,7 @@ MenuStateMods::MenuStateMods(Program *program, MainMenu *mainMenu) :
std::pair<string,string> techtreesPath;
vector<string> techtreesList = Config::getInstance().getPathListForType(ptTechs);
if(techtreesList.size() > 0) {
if(techtreesList.empty() == false) {
techtreesPath.first = techtreesList[0];
if(techtreesList.size() > 1) {
techtreesPath.second = techtreesList[1];
@ -271,7 +272,7 @@ MenuStateMods::MenuStateMods(Program *program, MainMenu *mainMenu) :
std::pair<string,string> scenariosPath;
vector<string> scenariosList = Config::getInstance().getPathListForType(ptScenarios);
if(scenariosList.size() > 0) {
if(scenariosList.empty() == false) {
scenariosPath.first = scenariosList[0];
if(scenariosList.size() > 1) {
scenariosPath.second = scenariosList[1];
@ -995,7 +996,7 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
soundRenderer.playFx(coreData.getClickSoundA());
if(fileFTPProgressList.size() > 0) {
if(fileFTPProgressList.empty() == false) {
mainMessageBoxState = ftpmsg_Quit;
mainMessageBox.init(lang.get("Yes"),lang.get("No"));
char szBuf[1024]="";
@ -1431,7 +1432,7 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
ModInfo &modInfo = mapCacheList[selectedMapName];
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d] remote CRC [%s]\n",__FILE__,__FUNCTION__,__LINE__,modInfo.crc.c_str());
Config &config = Config::getInstance();
//Config &config = Config::getInstance();
Checksum checksum;
string file = Map::getMapPath(selectedMapName,"",false);
checksum.addFile(file);
@ -1974,7 +1975,7 @@ void MenuStateMods::render() {
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),mutexOwnerId);
if(ftpClientThread != NULL && ftpClientThread->getProgressMutex() != NULL) ftpClientThread->getProgressMutex()->setOwnerId(mutexOwnerId);
if(fileFTPProgressList.size() > 0) {
if(fileFTPProgressList.empty() == false) {
Lang &lang= Lang::getInstance();
int xLocation = buttonReturn.getX();
int yLocation = buttonReturn.getY() - 12;
@ -2028,7 +2029,7 @@ void MenuStateMods::update() {
Chrono chrono;
chrono.start();
Lang &lang= Lang::getInstance();
//Lang &lang= Lang::getInstance();
// Tech List
if (keyTechScrollBar.getElementCount() != 0) {

View File

@ -137,7 +137,7 @@ void MenuStateNewGame::keyDown(SDL_KeyboardEvent key) {
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
//if(key == configKeys.getCharKey("SaveGUILayout")) {
if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),key) == true) {
bool saved = GraphicComponent::saveAllCustomProperties(containerName);
GraphicComponent::saveAllCustomProperties(containerName);
//Lang &lang= Lang::getInstance();
//console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
}

View File

@ -715,7 +715,6 @@ void MenuStateOptions::keyDown(SDL_KeyboardEvent key) {
void MenuStateOptions::keyPress(SDL_KeyboardEvent c) {
if(activeInputLabel!=NULL) {
//printf("[%d]\n",c); fflush(stdout);
int maxTextSize= 16;
if(&labelPlayerName==activeInputLabel) {
SDLKey key = extractKeyPressed(c);
//if((c>='0' && c<='9')||(c>='a' && c<='z')||(c>='A' && c<='Z')||
@ -724,6 +723,7 @@ void MenuStateOptions::keyPress(SDL_KeyboardEvent c) {
// (use Shared::Platform::charSet in shared_lib/include/platform/sdl/gl_wrap.h ?)
//(c=='-')||(c=='(')||(c==')')){
if(isAllowedInputTextKey(key)) {
const int maxTextSize= 16;
if(activeInputLabel->getText().size()<maxTextSize){
string text= activeInputLabel->getText();
//text.insert(text.end()-1, key);
@ -742,7 +742,7 @@ void MenuStateOptions::keyPress(SDL_KeyboardEvent c) {
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
//if(c == configKeys.getCharKey("SaveGUILayout")) {
if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),c) == true) {
bool saved = GraphicComponent::saveAllCustomProperties(containerName);
GraphicComponent::saveAllCustomProperties(containerName);
//Lang &lang= Lang::getInstance();
//console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
}
@ -914,7 +914,7 @@ void MenuStateOptions::saveConfig(){
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
soundRenderer.stopAllSounds();
program->stopSoundSystem();
bool initOk = soundRenderer.init(program->getWindow());
soundRenderer.init(program->getWindow());
soundRenderer.loadConfig();
soundRenderer.setMusicVolume(CoreData::getInstance().getMenuMusic());
program->startSoundSystem();

View File

@ -240,7 +240,7 @@ void MenuStateRoot::keyDown(SDL_KeyboardEvent key) {
}
//else if(key == configKeys.getCharKey("SaveGUILayout")) {
else if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),key) == true) {
bool saved = GraphicComponent::saveAllCustomProperties(containerName);
GraphicComponent::saveAllCustomProperties(containerName);
//Lang &lang= Lang::getInstance();
//console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
}

View File

@ -81,7 +81,7 @@ MenuStateScenario::MenuStateScenario(Program *program, MainMenu *mainMenu, const
//scenario listbox
findDirs(dirList, results);
scenarioFiles = results;
if(results.size() == 0) {
if(results.empty() == true) {
throw runtime_error("There are no scenarios found to load");
}
for(int i= 0; i<results.size(); ++i){
@ -476,7 +476,7 @@ void MenuStateScenario::keyDown(SDL_KeyboardEvent key) {
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
//if(key == configKeys.getCharKey("SaveGUILayout")) {
if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),key) == true) {
bool saved = GraphicComponent::saveAllCustomProperties(containerName);
GraphicComponent::saveAllCustomProperties(containerName);
//Lang &lang= Lang::getInstance();
//console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
}

View File

@ -157,7 +157,7 @@ void ClientInterface::update() {
// Possible cause of out of synch since we have more commands that need
// to be sent in this frame
if(requestedCommands.empty() == false) {
char szBuf[4096]="";
//char szBuf[4096]="";
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] WARNING / ERROR, requestedCommands.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,requestedCommands.size());
string sMsg = "may go out of synch: client requestedCommands.size() = " + intToStr(requestedCommands.size());

View File

@ -150,7 +150,7 @@ void ConnectionSlotThread::execute() {
//setRunningStatus(true);
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
unsigned int idx = 0;
//unsigned int idx = 0;
for(;this->slotInterface != NULL;) {
if(getQuitStatus() == true) {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@ -233,6 +233,8 @@ ConnectionSlot::ConnectionSlot(ServerInterface* serverInterface, int playerIndex
this->currentLagCount = 0;
this->gotLagCountWarning = false;
this->lastReceiveCommandListTime = 0;
this->receivedNetworkGameStatus = false;
this->socket = NULL;
this->slotThreadWorker = NULL;
this->slotThreadWorker = new ConnectionSlotThread(this->serverInterface,playerIndex);
@ -879,7 +881,7 @@ vector<NetworkCommand> ConnectionSlot::getPendingNetworkCommandList(bool clearLi
vector<NetworkCommand> ret;
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutexSlot(&mutexPendingNetworkCommandList,mutexOwnerId);
if(vctPendingNetworkCommandList.size() > 0) {
if(vctPendingNetworkCommandList.empty() == false) {
ret = vctPendingNetworkCommandList;
if(clearList == true) {
vctPendingNetworkCommandList.clear();
@ -893,7 +895,7 @@ vector<NetworkCommand> ConnectionSlot::getPendingNetworkCommandList(bool clearLi
void ConnectionSlot::clearPendingNetworkCommandList() {
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutexSlot(&mutexPendingNetworkCommandList,mutexOwnerId);
if(vctPendingNetworkCommandList.size() > 0) {
if(vctPendingNetworkCommandList.empty() == false) {
vctPendingNetworkCommandList.clear();
}
safeMutexSlot.ReleaseLock();

View File

@ -133,7 +133,7 @@ public:
void update(bool checkForNewClients,int lockedSlotIndex);
void setPlayerIndex(int value) { playerIndex = value; }
int getPlayerIndex() {return playerIndex;}
int getPlayerIndex() const {return playerIndex;}
uint32 getConnectedRemoteIPAddress() const { return connectedRemoteIPAddress; }
@ -148,7 +148,7 @@ public:
virtual void close();
//virtual bool getFogOfWar();
bool getReceivedNetworkGameStatus() { return receivedNetworkGameStatus; }
bool getReceivedNetworkGameStatus() const { return receivedNetworkGameStatus; }
void setReceivedNetworkGameStatus(bool value) { receivedNetworkGameStatus = value; }
bool hasValidSocketId();

View File

@ -110,7 +110,7 @@ void NetworkInterface::DisplayErrorMessage(string sErr, bool closeSocket) {
}
void NetworkInterface::clearChatInfo() {
if(chatTextList.size() > 0) {
if(chatTextList.empty() == false) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] chatTextList.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,chatTextList.size());
chatTextList.clear();
}
@ -296,7 +296,7 @@ void FileTransferSocketThread::execute()
outFile.write(data, 512);
if(outFile.bad())
{
int ii = 0;
//int ii = 0;
}
//if(!WriteFile(file,data,512,&written,NULL))
// ; //write error
@ -310,7 +310,7 @@ void FileTransferSocketThread::execute()
outFile.write(data, remain);
if(outFile.bad())
{
int ii = 0;
//int ii = 0;
}
//if(!WriteFile(file,data,remain,&written,NULL))
@ -325,7 +325,7 @@ void FileTransferSocketThread::execute()
int32 crc = checksum.getSum();
if(file.filecrc != crc)
{
int ii = 0;
//int ii = 0;
}
//if(calc_crc(file)!=info.crc)

View File

@ -236,6 +236,11 @@ private:
public:
FileTransferInfo()
{
hostType = eClient;
serverIP = "";
serverPort = 0;
opType = eSend;
fileName = "";
}
FileTransferInfo(const FileTransferInfo &obj)
{

View File

@ -45,7 +45,7 @@ public:
GameNetworkInterface* getGameNetworkInterface(bool throwErrorOnNull=true);
ServerInterface* getServerInterface(bool throwErrorOnNull=true);
ClientInterface* getClientInterface(bool throwErrorOnNull=true);
NetworkRole getNetworkRole() { return networkRole; }
NetworkRole getNetworkRole() const { return networkRole; }
};
}}//end namespace

View File

@ -635,7 +635,7 @@ public:
void addSwitchFlag(SwitchSetupRequestFlagType flag) { data.switchFlags |= flag;}
void clearSwitchFlag(SwitchSetupRequestFlagType flag) { data.switchFlags &= ~flag;}
int getNetworkPlayerStatus() { return data.networkPlayerStatus; }
int getNetworkPlayerStatus() const { return data.networkPlayerStatus; }
string getNetworkPlayerLanguage() const { return data.language.getString(); }
virtual bool receive(Socket* socket);

View File

@ -43,10 +43,12 @@ private:
public:
NetworkString() {memset(buffer, 0, S);}
void operator=(const string& str) {
NetworkString & operator=(const string& str) {
// ensure we don't have a buffer overflow
int maxBufferSize = sizeof(buffer) / sizeof(buffer[0]);
strncpy(buffer, str.c_str(), min(S-1,maxBufferSize-1));
return *this;
}
void nullTerminate() {
int maxBufferSize = sizeof(buffer) / sizeof(buffer[0]);

View File

@ -80,7 +80,7 @@ ServerInterface::ServerInterface(bool publishEnabled) :GameNetworkInterface() {
if(Config::getInstance().getBool("EnableFTPServer","true") == true) {
std::pair<string,string> mapsPath;
vector<string> pathList = Config::getInstance().getPathListForType(ptMaps);
if(pathList.size() > 0) {
if(pathList.empty() == false) {
mapsPath.first = pathList[0];
if(pathList.size() > 1) {
mapsPath.second = pathList[1];
@ -89,7 +89,7 @@ ServerInterface::ServerInterface(bool publishEnabled) :GameNetworkInterface() {
std::pair<string,string> tilesetsPath;
vector<string> tilesetsList = Config::getInstance().getPathListForType(ptTilesets);
if(tilesetsList.size() > 0) {
if(tilesetsList.empty() == false) {
tilesetsPath.first = tilesetsList[0];
if(tilesetsList.size() > 1) {
tilesetsPath.second = tilesetsList[1];
@ -98,7 +98,7 @@ ServerInterface::ServerInterface(bool publishEnabled) :GameNetworkInterface() {
std::pair<string,string> techtreesPath;
vector<string> techtreesList = Config::getInstance().getPathListForType(ptTechs);
if(techtreesList.size() > 0) {
if(techtreesList.empty() == false) {
techtreesPath.first = techtreesList[0];
if(techtreesList.size() > 1) {
techtreesPath.second = techtreesList[1];
@ -619,7 +619,7 @@ void ServerInterface::validateConnectedClients() {
void ServerInterface::signalClientsToRecieveData(std::map<PLATFORM_SOCKET,bool> &socketTriggeredList,
std::map<int,ConnectionSlotEvent> &eventList,
std::map<int,bool> & mapSlotSignalledList) {
bool checkForNewClients = true;
//bool checkForNewClients = true;
for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) {
MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(i));
ConnectionSlot* connectionSlot = slots[i];
@ -651,7 +651,7 @@ void ServerInterface::checkForCompletedClients(std::map<int,bool> & mapSlotSigna
try {
std::vector<std::string> errorList = connectionSlot->getThreadErrorList();
// Collect any collected errors from threads
if(errorList.size() > 0) {
if(errorList.empty() == false) {
for(int iErrIdx = 0; iErrIdx < errorList.size(); ++iErrIdx) {
string &sErr = errorList[iErrIdx];
if(sErr != "") {
@ -703,7 +703,7 @@ void ServerInterface::checForLaggingClients(std::map<int,bool> &mapSlotSignalled
try {
std::vector<std::string> errorList = connectionSlot->getThreadErrorList();
// Show any collected errors from threads
if(errorList.size() > 0) {
if(errorList.empty() == false) {
for(int iErrIdx = 0; iErrIdx < errorList.size(); ++iErrIdx) {
string &sErr = errorList[iErrIdx];
if(sErr != "") {
@ -812,7 +812,7 @@ void ServerInterface::executeNetworkCommandsFromClients() {
ConnectionSlot* connectionSlot= slots[i];
if(connectionSlot != NULL && connectionSlot->isConnected() == true) {
vector<NetworkCommand> pendingList = connectionSlot->getPendingNetworkCommandList(true);
if(pendingList.size() > 0) {
if(pendingList.empty() == false) {
for(int idx = 0; exitServer == false && idx < pendingList.size(); ++idx) {
NetworkCommand &cmd = pendingList[idx];
this->requestCommand(&cmd);
@ -901,7 +901,7 @@ void ServerInterface::update() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
if(gameHasBeenInitiated == false || socketTriggeredList.size() > 0) {
if(gameHasBeenInitiated == false || socketTriggeredList.empty() == false) {
//printf("\nServerInterface::update -- E\n");
std::map<int,ConnectionSlotEvent> eventList;
@ -975,7 +975,7 @@ void ServerInterface::update() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] error detected [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
errorMsgList.push_back(ex.what());
}
if(errorMsgList.size() > 0){
if(errorMsgList.empty() == false){
for(int iErrIdx = 0;iErrIdx < errorMsgList.size();++iErrIdx){
string & sErr = errorMsgList[iErrIdx];
if(sErr != ""){
@ -1007,7 +1007,7 @@ void ServerInterface::updateKeyframe(int frameCount) {
// Possible cause of out of synch since we have more commands that need
// to be sent in this frame
if(requestedCommands.empty() == false) {
char szBuf[1024]="";
//char szBuf[1024]="";
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] WARNING / ERROR, requestedCommands.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,requestedCommands.size());
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] WARNING / ERROR, requestedCommands.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,requestedCommands.size());
@ -1337,7 +1337,7 @@ void ServerInterface::waitUntilReady(Checksum *checksum) {
void ServerInterface::processBroadCastMessageQueue() {
MutexSafeWrapper safeMutexSlot(&broadcastMessageQueueThreadAccessor,string(__FILE__) + "_" + intToStr(__LINE__));
if(broadcastMessageQueue.size() > 0) {
if(broadcastMessageQueue.empty() == false) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] broadcastMessageQueue.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,broadcastMessageQueue.size());
for(int i = 0; i < broadcastMessageQueue.size(); ++i) {
pair<const NetworkMessage *,int> &item = broadcastMessageQueue[i];
@ -1361,7 +1361,7 @@ void ServerInterface::queueBroadcastMessage(const NetworkMessage *networkMessage
void ServerInterface::processTextMessageQueue() {
MutexSafeWrapper safeMutexSlot(&textMessageQueueThreadAccessor,string(__FILE__) + "_" + intToStr(__LINE__));
if(textMessageQueue.size() > 0) {
if(textMessageQueue.empty() == false) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] textMessageQueue.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,textMessageQueue.size());
for(int i = 0; i < textMessageQueue.size(); ++i) {
TextMessageQueue &item = textMessageQueue[i];

View File

@ -159,7 +159,7 @@ void FactionThread::execute() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] ****************** STARTING worker thread this = %p\n",__FILE__,__FUNCTION__,__LINE__,this);
unsigned int idx = 0;
//unsigned int idx = 0;
for(;this->faction != NULL;) {
if(getQuitStatus() == true) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@ -253,12 +253,20 @@ Faction::Faction() {
cachingDisabled=false;
factionDisconnectHandled=false;
workerThread = NULL;
world=NULL;
scriptManager=NULL;
factionType=NULL;
index=0;
teamIndex=0;
startLocationIndex=0;
thisFaction=false;
}
Faction::~Faction() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
Renderer &renderer= Renderer::getInstance();
//Renderer &renderer= Renderer::getInstance();
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@ -667,7 +675,7 @@ void Faction::applyCostsOnInterval(const ResourceType *rtApply) {
}
// Apply consumable resource usage
if(resourceIntervalUsage.size() > 0) {
if(resourceIntervalUsage.empty() == false) {
for(std::map<const ResourceType *, std::pair<int, std::vector<Unit *> > >::iterator iter = resourceIntervalUsage.begin();
iter != resourceIntervalUsage.end();
++iter) {
@ -837,7 +845,7 @@ bool Faction::isResourceTargetInCache(const Vec2i &pos, bool incrementUseCounter
bool result = false;
if(cachingDisabled == false) {
if(cacheResourceTargetList.size() > 0) {
if(cacheResourceTargetList.empty() == false) {
std::map<Vec2i,int>::iterator iter = cacheResourceTargetList.find(pos);
result = (iter != cacheResourceTargetList.end());
@ -876,7 +884,7 @@ void Faction::addResourceTargetToCache(const Vec2i &pos,bool incrementUseCounter
void Faction::removeResourceTargetFromCache(const Vec2i &pos) {
if(cachingDisabled == false) {
if(cacheResourceTargetList.size() > 0) {
if(cacheResourceTargetList.empty() == false) {
std::map<Vec2i,int>::iterator iter = cacheResourceTargetList.find(pos);
if(iter != cacheResourceTargetList.end()) {
@ -928,7 +936,7 @@ Vec2i Faction::getClosestResourceTypeTargetFromCache(Unit *unit, const ResourceT
Vec2i result(-1);
if(cachingDisabled == false) {
if(cacheResourceTargetList.size() > 0) {
if(cacheResourceTargetList.empty() == false) {
std::vector<Vec2i> deleteList;
const int harvestDistance = 5;
@ -1025,7 +1033,7 @@ Vec2i Faction::getClosestResourceTypeTargetFromCache(Unit *unit, const ResourceT
}
}
if(deleteList.size() > 0) {
if(deleteList.empty() == false) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) {
char szBuf[4096]="";
sprintf(szBuf,"[cleaning old resource targets] deleteList.size() [%ld] cacheResourceTargetList.size() [%ld] result [%s]",
@ -1048,7 +1056,7 @@ Vec2i Faction::getClosestResourceTypeTargetFromCache(Unit *unit, const ResourceT
Vec2i Faction::getClosestResourceTypeTargetFromCache(const Vec2i &pos, const ResourceType *type) {
Vec2i result(-1);
if(cachingDisabled == false) {
if(cacheResourceTargetList.size() > 0) {
if(cacheResourceTargetList.empty() == false) {
//std::vector<Vec2i> deleteList;
const int harvestDistance = 5;
@ -1147,7 +1155,7 @@ Vec2i Faction::getClosestResourceTypeTargetFromCache(const Vec2i &pos, const Res
//SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"%s",szBuf);
//SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"------------------------------------ END [%d] -------------------------------------------------\n",getFrameCount());
//if(deleteList.size() > 0) {
//if(deleteList.empty() == false) {
// cleanupResourceTypeTargetCache(&deleteList);
//}
}
@ -1158,7 +1166,7 @@ Vec2i Faction::getClosestResourceTypeTargetFromCache(const Vec2i &pos, const Res
void Faction::cleanupResourceTypeTargetCache(std::vector<Vec2i> *deleteListPtr) {
if(cachingDisabled == false) {
if(cacheResourceTargetList.size() > 0) {
if(cacheResourceTargetList.empty() == false) {
const int cleanupInterval = (GameConstants::updateFps * 5);
bool needToCleanup = (getFrameCount() % cleanupInterval == 0);
@ -1185,7 +1193,7 @@ void Faction::cleanupResourceTypeTargetCache(std::vector<Vec2i> *deleteListPtr)
}
}
if(deleteList.size() > 0) {
if(deleteList.empty() == false) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) {
char szBuf[4096]="";
sprintf(szBuf,"[cleaning old resource targets] deleteList.size() [%ld] cacheResourceTargetList.size() [%ld], needToCleanup [%d]",
@ -1333,7 +1341,7 @@ Unit * Faction::findClosestUnitWithSkillClass( const Vec2i &pos,const CommandCla
const CommandType *cmdType = curUnit->getType()->getFirstCtOfClass(cmdClass);
bool isUnitPossibleCandidate = (cmdType != NULL);
if(skillClassList.size() > 0) {
if(skillClassList.empty() == false) {
isUnitPossibleCandidate = false;
for(int j = 0; j < skillClassList.size(); ++j) {
@ -1372,7 +1380,7 @@ Unit * Faction::findClosestUnitWithSkillClass( const Vec2i &pos,const CommandCla
isUnitPossibleCandidate = false;
}
if(isUnitPossibleCandidate == true && skillClassList.size() > 0) {
if(isUnitPossibleCandidate == true && skillClassList.empty() == false) {
isUnitPossibleCandidate = false;
for(int j = 0; j < skillClassList.size(); ++j) {

View File

@ -73,7 +73,7 @@ public:
Vec3f getPos() const {return pos;}
bool isVisible() const {return visible;}
const Vec3f & getConstPos() const {return pos;}
float getRotation() {return rotation;}
float getRotation() const {return rotation;}
const Model *getModel() const;
Model *getModelPtr() const;
bool getWalkable() const;

View File

@ -115,7 +115,7 @@ std::string UnitPathBasic::toString() const {
std::string result = "";
result = "unit path blockCount = " + intToStr(blockCount) + " pathQueue size = " + intToStr(pathQueue.size());
for(int idx = 0; idx < pathQueue.size(); idx++) {
for(int idx = 0; idx < pathQueue.size(); ++idx) {
result += " index = " + intToStr(idx) + " " + pathQueue[idx].getString();
}
@ -161,7 +161,7 @@ UnitReference::UnitReference(){
faction= NULL;
}
void UnitReference::operator=(const Unit *unit){
UnitReference & UnitReference::operator=(const Unit *unit){
if(unit==NULL){
id= -1;
faction= NULL;
@ -170,6 +170,8 @@ void UnitReference::operator=(const Unit *unit){
id= unit->getId();
faction= unit->getFaction();
}
return *this;
}
Unit *UnitReference::getUnit() const{
@ -1283,7 +1285,7 @@ void Unit::undertake() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] about to undertake unit id = %d [%s] [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->id, this->getFullName().c_str(),this->getDesc().c_str());
// Remove any units that were previously in attack-boost range
if(currentAttackBoostOriginatorEffect.currentAttackBoostUnits.size() > 0 && currentAttackBoostOriginatorEffect.skillType != NULL) {
if(currentAttackBoostOriginatorEffect.currentAttackBoostUnits.empty() == false && currentAttackBoostOriginatorEffect.skillType != NULL) {
for(unsigned int i = 0; i < currentAttackBoostOriginatorEffect.currentAttackBoostUnits.size(); ++i) {
// Remove attack boost upgrades from unit
int findUnitId = currentAttackBoostOriginatorEffect.currentAttackBoostUnits[i];
@ -1615,7 +1617,7 @@ bool Unit::update() {
}
// Remove any units that were previously in range
if(currentAttackBoostOriginatorEffect.currentAttackBoostUnits.size() > 0 && currentAttackBoostOriginatorEffect.skillType != NULL) {
if(currentAttackBoostOriginatorEffect.currentAttackBoostUnits.empty() == false && currentAttackBoostOriginatorEffect.skillType != NULL) {
for(unsigned int i = 0; i < currentAttackBoostOriginatorEffect.currentAttackBoostUnits.size(); ++i) {
// Remove attack boost upgrades from unit
@ -1650,7 +1652,7 @@ bool Unit::update() {
}
if(showUnitParticles == true) {
if(currentAttackBoostOriginatorEffect.currentAttackBoostUnits.size() > 0) {
if(currentAttackBoostOriginatorEffect.currentAttackBoostUnits.empty() == false) {
if(attackBoost->unitParticleSystemTypeForSourceUnit != NULL) {
currentAttackBoostOriginatorEffect.currentAppliedEffect = new UnitAttackBoostEffect();
currentAttackBoostOriginatorEffect.currentAppliedEffect->upst = new UnitParticleSystemType();
@ -1702,7 +1704,7 @@ bool Unit::update() {
}
if(showUnitParticles == true) {
if(currentAttackBoostOriginatorEffect.currentAttackBoostUnits.size() > 0) {
if(currentAttackBoostOriginatorEffect.currentAttackBoostUnits.empty() == false) {
if( attackBoost->unitParticleSystemTypeForSourceUnit != NULL &&
currentAttackBoostOriginatorEffect.currentAppliedEffect == NULL) {
@ -2592,7 +2594,7 @@ void Unit::stopDamageParticles(bool force) {
// stop additional particles
if(smokeParticleSystems.size() > 0) {
if(smokeParticleSystems.empty() == false) {
for(int i = smokeParticleSystems.size()-1; i >= 0; --i) {
UnitParticleSystem *ps = smokeParticleSystems[i];
ps->fade();
@ -2600,7 +2602,7 @@ void Unit::stopDamageParticles(bool force) {
}
}
if(damageParticleSystems.size() > 0) {
if(damageParticleSystems.empty() == false) {
for(int i = damageParticleSystems.size()-1; i >= 0; --i) {
UnitParticleSystem *ps = damageParticleSystems[i];
UnitParticleSystemType *pst = NULL;
@ -2629,7 +2631,7 @@ void Unit::stopDamageParticles(bool force) {
void Unit::checkCustomizedParticleTriggers(bool force) {
// Now check if we have special hp triggered particles
if(damageParticleSystems.size() > 0) {
if(damageParticleSystems.empty() == false) {
for(int i = damageParticleSystems.size()-1; i >= 0; --i) {
UnitParticleSystem *ps = damageParticleSystems[i];
UnitParticleSystemType *pst = NULL;
@ -2941,7 +2943,7 @@ void Unit::cleanupOldBadHarvestPos() {
}
}
if(purgeList.size() > 0) {
if(purgeList.empty() == false) {
char szBuf[4096]="";
sprintf(szBuf,"[cleaning old bad harvest targets] purgeList.size() [%ld]",purgeList.size());
logSynchData(__FILE__,__LINE__,szBuf);

View File

@ -95,7 +95,7 @@ private:
public:
UnitReference();
void operator=(const Unit *unit);
UnitReference & operator=(const Unit *unit);
Unit *getUnit() const;
int getUnitId() const { return id; }

View File

@ -94,7 +94,7 @@ void UpgradeManager::cancelUpgrade(const UpgradeType *upgradeType) {
upgradesLookup.erase(upgradeType);
for(map<const UpgradeType *,int>::iterator iterMap = upgradesLookup.begin();
iterMap != upgradesLookup.end(); iterMap++) {
iterMap != upgradesLookup.end(); ++iterMap) {
if(iterMap->second >= upgrades.size()) {
iterMap->second--;
}
@ -209,7 +209,7 @@ bool UpgradeManager::isUpgrading(const UpgradeType *upgradeType) const {
void UpgradeManager::computeTotalUpgrade(const Unit *unit, TotalUpgrade *totalUpgrade) const {
totalUpgrade->reset();
for(Upgrades::const_iterator it= upgrades.begin(); it!=upgrades.end(); it++) {
for(Upgrades::const_iterator it= upgrades.begin(); it!=upgrades.end(); ++it) {
if((*it)->getFactionIndex() == unit->getFactionIndex()
&& (*it)->getType()->isAffected(unit->getType())
&& (*it)->getState()==usUpgraded)

View File

@ -87,6 +87,7 @@ void CommandType::load(int id, const XmlNode *n, const string &dir,
StopCommandType::StopCommandType(){
commandTypeClass= ccStop;
clicks= cOne;
stopSkillType=NULL;
}
void StopCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const {
@ -130,6 +131,7 @@ void StopCommandType::load(int id, const XmlNode *n, const string &dir,
MoveCommandType::MoveCommandType(){
commandTypeClass= ccMove;
clicks= cTwo;
moveSkillType=NULL;
}
void MoveCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const {
@ -180,6 +182,8 @@ string MoveCommandType::toString() const{
AttackCommandType::AttackCommandType(){
commandTypeClass= ccAttack;
clicks= cTwo;
moveSkillType=NULL;
attackSkillType=NULL;
}
void AttackCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const {
@ -273,6 +277,8 @@ string AttackCommandType::toString() const{
AttackStoppedCommandType::AttackStoppedCommandType(){
commandTypeClass= ccAttackStopped;
clicks= cOne;
stopSkillType=NULL;
attackSkillType=NULL;
}
void AttackStoppedCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const {
@ -355,6 +361,8 @@ string AttackStoppedCommandType::toString() const {
BuildCommandType::BuildCommandType() {
commandTypeClass= ccBuild;
clicks= cTwo;
moveSkillType=NULL;
buildSkillType=NULL;
}
BuildCommandType::~BuildCommandType() {
@ -455,6 +463,12 @@ string BuildCommandType::toString() const{
HarvestCommandType::HarvestCommandType(){
commandTypeClass= ccHarvest;
clicks= cTwo;
moveSkillType=NULL;
moveLoadedSkillType=NULL;
harvestSkillType=NULL;
stopLoadedSkillType=NULL;
maxLoad=0;
hitsPerUnit=0;
}
void HarvestCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const {
@ -533,6 +547,8 @@ bool HarvestCommandType::canHarvest(const ResourceType *resourceType) const{
RepairCommandType::RepairCommandType(){
commandTypeClass= ccRepair;
clicks= cTwo;
moveSkillType=NULL;
repairSkillType=NULL;
}
RepairCommandType::~RepairCommandType(){
@ -610,6 +626,8 @@ bool RepairCommandType::isRepairableUnitType(const UnitType *unitType) const {
ProduceCommandType::ProduceCommandType(){
commandTypeClass= ccProduce;
clicks= cOne;
produceSkillType=NULL;
producedUnit=NULL;
}
void ProduceCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const {
@ -675,6 +693,8 @@ const ProducibleType *ProduceCommandType::getProduced() const{
UpgradeCommandType::UpgradeCommandType(){
commandTypeClass= ccUpgrade;
clicks= cOne;
upgradeSkillType=NULL;
producedUpgrade=NULL;
}
void UpgradeCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const {
@ -732,6 +752,9 @@ const ProducibleType *UpgradeCommandType::getProduced() const{
MorphCommandType::MorphCommandType(){
commandTypeClass= ccMorph;
clicks= cOne;
morphSkillType=NULL;
morphUnit=NULL;
discount=0;
}
void MorphCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const {

View File

@ -0,0 +1,51 @@
// ==============================================================
// This file is part of Glest (www.glest.org)
//
// Copyright (C) 2001-2008 Marti<74>o Figueroa
//
// You can redistribute this code and/or modify it under
// the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version
// ==============================================================
#include "damage_multiplier.h"
#include "leak_dumper.h"
namespace Glest{ namespace Game{
// =====================================================
// class DamageMultiplierTable
// =====================================================
DamageMultiplierTable::DamageMultiplierTable(){
values= NULL;
attackTypeCount=0;
armorTypeCount=0;
}
DamageMultiplierTable::~DamageMultiplierTable(){
delete [] values;
}
void DamageMultiplierTable::init(int attackTypeCount, int armorTypeCount){
this->attackTypeCount= attackTypeCount;
this->armorTypeCount= armorTypeCount;
int valueCount= attackTypeCount*armorTypeCount;
values= new float[valueCount];
for(int i=0; i<valueCount; ++i){
values[i]= 1.f;
}
}
float DamageMultiplierTable::getDamageMultiplier(const AttackType *att, const ArmorType *art) const{
return values[attackTypeCount*art->getId()+att->getId()];
}
void DamageMultiplierTable::setDamageMultiplier(const AttackType *att, const ArmorType *art, float value){
values[attackTypeCount*art->getId()+att->getId()]= value;
}
}}//end namespaces

View File

@ -77,6 +77,7 @@ string RequirableType::getReqDesc() const{
ProducibleType::ProducibleType(){
cancelImage= NULL;
productionTime=0;
}
ProducibleType::~ProducibleType(){

View File

@ -47,7 +47,7 @@ void FactionType::load(const string &dir, const TechTree *techTree, Checksum* ch
name= lastDir(currentPath);
// Add special Observer Faction
Lang &lang= Lang::getInstance();
//Lang &lang= Lang::getInstance();
if(name == formatString(GameConstants::OBSERVER_SLOTNAME)) {
personalityType = fpt_Observer;
}

View File

@ -501,6 +501,12 @@ AttackSkillType::AttackSkillType() {
for(int i = 0; i < fieldCount; ++i) {
attackFields[i]= false;
}
attackStrength=0;
attackVar=0;
attackRange=0;
attackStartTime=0;
splashDamageAll=false;
}
AttackSkillType::~AttackSkillType() {
@ -672,6 +678,7 @@ string RepairSkillType::toString() const{
ProduceSkillType::ProduceSkillType(){
skillClass= scProduce;
animProgressBound=false;
}
void ProduceSkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt,
@ -704,6 +711,7 @@ int ProduceSkillType::getTotalSpeed(const TotalUpgrade *totalUpgrade) const{
UpgradeSkillType::UpgradeSkillType(){
skillClass= scUpgrade;
animProgressBound=false;
}
void UpgradeSkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt,
@ -735,6 +743,7 @@ int UpgradeSkillType::getTotalSpeed(const TotalUpgrade *totalUpgrade) const{
BeBuiltSkillType::BeBuiltSkillType(){
skillClass= scBeBuilt;
animProgressBound=false;
}
void BeBuiltSkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt,
@ -764,6 +773,7 @@ string BeBuiltSkillType::toString() const{
MorphSkillType::MorphSkillType(){
skillClass= scMorph;
animProgressBound=false;
}
void MorphSkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt,
@ -795,6 +805,7 @@ int MorphSkillType::getTotalSpeed(const TotalUpgrade *totalUpgrade) const{
DieSkillType::DieSkillType(){
skillClass= scDie;
fade=false;
}
void DieSkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt,

View File

@ -293,7 +293,7 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree,
UnitParticleSystemType *unitParticleSystemType= new UnitParticleSystemType();
//Texture2D *newTexture = Renderer::getInstance().newTexture2D(rsGame);
Texture2D *newTexture = NULL;
//Texture2D *newTexture = NULL;
unitParticleSystemType->load(particleFileNode, dir, currentPath + path,
&Renderer::getInstance(),loadedFileList, sourceXMLFile,

View File

@ -322,13 +322,13 @@ void UpgradeType::load(const string &dir, const TechTree *techTree,
string UpgradeType::getReqDesc() const{
string str;
int i;
//int i;
Lang &lang= Lang::getInstance();
str= ProducibleType::getReqDesc();
if(getEffectCount()>0){
str+= "\n"+ lang.get("Upgrades")+":\n";
for(i=0; i<getEffectCount(); ++i){
for(int i=0; i<getEffectCount(); ++i){
str+= getEffect(i)->getName()+"\n";
}
}

View File

@ -66,6 +66,11 @@ SurfaceCell::SurfaceCell() {
surfaceType= -1;
surfaceTexture= NULL;
nearSubmerged = false;
for(int i = 0; i < GameConstants::maxPlayers + GameConstants::specialFactions; ++i) {
visible[i] = false;
explored[i] = false;
}
}
SurfaceCell::~SurfaceCell() {
@ -913,7 +918,7 @@ std::pair<float,Vec2i> Map::getUnitDistanceToPos(const Unit *unit,Vec2i pos,cons
}
std::pair<float,Vec2i> result(-1,Vec2i(0));
int unitId= unit->getId();
//int unitId= unit->getId();
Vec2i unitPos= computeDestPos(unit->getPos(), unit->getPos(), pos);
Vec2i start = pos - Vec2i(1);
@ -958,7 +963,7 @@ const Unit * Map::findClosestUnitToPos(const Selection *selection, Vec2i origina
for(int i = 0; i < selection->getCount(); ++i) {
const Unit *unit = selection->getUnit(i);
int unitId= unit->getId();
//int unitId= unit->getId();
Vec2i unitBuilderPos= computeDestPos(refPos, unit->getPos(), pos);
for(int i = start.x; i <= end.x; ++i) {
@ -1011,7 +1016,7 @@ bool Map::isNextToUnitTypeCells(const UnitType *ut, const Vec2i &pos,
const Vec2i &testPos) const {
bool isInsideDestUnitCells = isInUnitTypeCells(ut, pos,testPos);
if(isInsideDestUnitCells == false) {
Cell *testCell = getCell(testPos);
//Cell *testCell = getCell(testPos);
for(int i=-1; i <= ut->getSize(); ++i){
for(int j = -1; j <= ut->getSize(); ++j) {
Vec2i currPos = pos + Vec2i(i, j);
@ -1316,7 +1321,7 @@ void Map::computeInterpolatedHeights(){
void Map::smoothSurface(Tileset *tileset) {
float *oldHeights = new float[getSurfaceCellArraySize()];
int arraySize=getSurfaceCellArraySize();
//int arraySize=getSurfaceCellArraySize();
for (int i = 0; i < getSurfaceCellArraySize(); ++i) {
oldHeights[i] = surfaceCells[i].getHeight();

View File

@ -36,6 +36,8 @@ Minimap::Minimap() {
fowPixmap1= NULL;
fogOfWar= true;//Config::getInstance().getBool("FogOfWar");
gameSettings= NULL;
tex=NULL;
fowTex=NULL;
}
void Minimap::init(int w, int h, const World *world, bool fogOfWar) {

View File

@ -90,7 +90,7 @@ void TimeFlow::update() {
lastTime= time;
}
bool TimeFlow::isAproxTime(float time){
bool TimeFlow::isAproxTime(float time) const {
return (this->time>=time) && (this->time<time+timeInc);
}

View File

@ -52,7 +52,7 @@ public:
void update();
private:
bool isAproxTime(float time);
bool isAproxTime(float time) const;
};
}} //end namespace

View File

@ -54,6 +54,7 @@ UnitUpdater::UnitUpdater() {
this->routePlanner = NULL;
this->pathFinder = NULL;
//UnitRangeCellsLookupItemCacheTimerCount = 0;
attackWarnRange=0;
}
void UnitUpdater::init(Game *game){
@ -872,7 +873,7 @@ void UnitUpdater::updateHarvest(Unit *unit, int frameIndex) {
Vec2i targetPos(-1);
TravelState tsValue = tsImpossible;
UnitPathInterface *path= unit->getPath();
//UnitPathInterface *path= unit->getPath();
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
@ -1536,7 +1537,7 @@ void UnitUpdater::updateRepair(Unit *unit, int frameIndex) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] repaired = %p, nextToRepaired = %d, unit->getCurrSkill()->getClass() = %d\n",__FILE__,__FUNCTION__,__LINE__,repaired,nextToRepaired,unit->getCurrSkill()->getClass());
UnitPathInterface *path= unit->getPath();
//UnitPathInterface *path= unit->getPath();
if(unit->getCurrSkill()->getClass() != scRepair ||
(nextToRepaired == false && peerUnitBuilder == NULL)) {
@ -2150,10 +2151,10 @@ bool UnitUpdater::unitOnRange(const Unit *unit, int range, Unit **rangedPtr,
Vec2i center = unit->getPos();
Vec2f floatCenter = unit->getFloatCenteredPos();
bool foundInCache = true;
//bool foundInCache = true;
if(findCachedCellsEnemies(center,range,size,enemies,ast,
unit,commandTarget) == false) {
foundInCache = false;
//foundInCache = false;
//nearby cells
UnitRangeCellsLookupItem cacheItem;
for(int i = center.x - range; i < center.x + range + size; ++i) {
@ -2232,17 +2233,17 @@ bool UnitUpdater::unitOnRange(const Unit *unit, int range, Unit **rangedPtr,
*/
if(result == true) {
const Unit* teamUnit = NULL;
//const Unit* teamUnit = NULL;
const Unit* enemyUnit = NULL;
bool onlyEnemyUnits = true;
if(unit->getTeam() == world->getThisTeamIndex()) {
teamUnit = unit;
//teamUnit = unit;
enemyUnit = enemySeen;
onlyEnemyUnits = false;
}
else if(enemySeen->getTeam() == world->getThisTeamIndex()) {
teamUnit = enemySeen;
//teamUnit = enemySeen;
enemyUnit = unit;
onlyEnemyUnits = false;
}
@ -2332,10 +2333,10 @@ vector<Unit*> UnitUpdater::enemyUnitsOnRange(const Unit *unit,const AttackSkillT
Vec2i center = unit->getPos();
Vec2f floatCenter = unit->getFloatCenteredPos();
bool foundInCache = true;
//bool foundInCache = true;
if(findCachedCellsEnemies(center,range,size,enemies,ast,
unit,commandTarget) == false) {
foundInCache = false;
//foundInCache = false;
//nearby cells
UnitRangeCellsLookupItem cacheItem;
for(int i = center.x - range; i < center.x + range + size; ++i) {

View File

@ -75,6 +75,11 @@ World::World(){
scriptManager= NULL;
this->game = NULL;
thisFactionIndex=0;
thisTeamIndex=0;
fogOfWar=false;
perfTimerEnabled=false;
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
@ -105,13 +110,13 @@ World::~World() {
routePlanner = 0;
for(std::map<string,StaticSound *>::iterator iterMap = staticSoundList.begin();
iterMap != staticSoundList.end(); iterMap++) {
iterMap != staticSoundList.end(); ++iterMap) {
delete iterMap->second;
}
staticSoundList.clear();
for(std::map<string,StrSound *>::iterator iterMap = streamSoundList.begin();
iterMap != streamSoundList.end(); iterMap++) {
iterMap != streamSoundList.end(); ++iterMap) {
delete iterMap->second;
}
streamSoundList.clear();
@ -299,7 +304,7 @@ void World::updateAllFactionUnits() {
unitListToSort.push_back(new CommandGroupSorter(unit));
}
if(unitListToSort.size() > 0) {
if(unitListToSort.empty() == false) {
std::sort(unitListToSort.begin(),unitListToSort.end());
}
}
@ -1359,8 +1364,8 @@ void World::initMap() {
// ==================== exploration ====================
void World::exploreCells(const Vec2i &newPos, int sightRange, int teamIndex) {
bool cacheLookupPosResult = false;
bool cacheLookupSightResult = false;
//bool cacheLookupPosResult = false;
//bool cacheLookupSightResult = false;
// cache lookup of previously calculated cells + sight range
if(MaxExploredCellsLookupItemCache > 0) {
@ -1392,11 +1397,11 @@ void World::exploreCells(const Vec2i &newPos, int sightRange, int teamIndex) {
// cache if already found
std::map<Vec2i, std::map<int, ExploredCellsLookupItem> >::iterator iterFind = ExploredCellsLookupItemCache.find(newPos);
if(iterFind != ExploredCellsLookupItemCache.end()) {
cacheLookupPosResult = true;
//cacheLookupPosResult = true;
std::map<int, ExploredCellsLookupItem>::iterator iterFind2 = iterFind->second.find(sightRange);
if(iterFind2 != iterFind->second.end()) {
cacheLookupSightResult = true;
//cacheLookupSightResult = true;
std::vector<SurfaceCell *> &cellList = iterFind2->second.exploredCellList;
for(int idx2 = 0; idx2 < cellList.size(); ++idx2) {

View File

@ -57,7 +57,7 @@ static inline std::vector<string> getExtensionsBmp() {
//static const string extensions[] = {"bmp", ""};
static std::vector<string> extensions;
if(extensions.size() == 0) {
if(extensions.empty() == true) {
extensions.push_back("bmp");
}

View File

@ -60,7 +60,7 @@ static void term_source (j_decompress_ptr cinfo) {
//static const string extensions[] = {"jpg", "jpeg", ""};
static inline std::vector<string> getExtensions() {
static std::vector<string> extensions;
if(extensions.size() == 0) {
if(extensions.empty() == true) {
extensions.push_back("jpg");
extensions.push_back("jpeg");
}

View File

@ -48,7 +48,7 @@ static void user_flush_data(png_structp png_ptr) {}
static inline std::vector<string> getExtensionsPng() {
//static const string extensions[] = {"png", ""};
static std::vector<string> extensions;
if(extensions.size() == 0) {
if(extensions.empty() == true) {
extensions.push_back("png");
}
return extensions;
@ -63,7 +63,7 @@ PNGReader::PNGReader(): FileReader<Pixmap2D>(getExtensionsPng()) {}
Pixmap2D* PNGReader::read(ifstream& is, const string& path, Pixmap2D* ret) const {
//Read file
is.seekg(0, ios::end);
size_t length = is.tellg();
//size_t length = is.tellg();
is.seekg(0, ios::beg);
uint8 *buffer = new uint8[8];
is.read((char*)buffer, 8);
@ -96,7 +96,7 @@ Pixmap2D* PNGReader::read(ifstream& is, const string& path, Pixmap2D* ret) const
int width = info_ptr->width;
int height = info_ptr->height;
int color_type = info_ptr->color_type;
int bit_depth = info_ptr->bit_depth;
//int bit_depth = info_ptr->bit_depth;
//We want RGB, 24 bit
if (color_type == PNG_COLOR_TYPE_PALETTE || (color_type == PNG_COLOR_TYPE_GRAY && info_ptr->bit_depth < 8) || (info_ptr->valid & PNG_INFO_tRNS)) {
@ -107,7 +107,8 @@ Pixmap2D* PNGReader::read(ifstream& is, const string& path, Pixmap2D* ret) const
png_set_gray_to_rgb(png_ptr);
}
int number_of_passes = png_set_interlace_handling(png_ptr);
//int number_of_passes = png_set_interlace_handling(png_ptr);
png_set_interlace_handling(png_ptr);
png_read_update_info(png_ptr, info_ptr);
png_bytep* row_pointers = new png_bytep[height];
@ -199,7 +200,7 @@ PNGReader3D::PNGReader3D(): FileReader<Pixmap3D>(getExtensionsPng()) {}
Pixmap3D* PNGReader3D::read(ifstream& is, const string& path, Pixmap3D* ret) const {
//Read file
is.seekg(0, ios::end);
size_t length = is.tellg();
//size_t length = is.tellg();
is.seekg(0, ios::beg);
uint8 *buffer = new uint8[8];
is.read((char*)buffer, 8);
@ -232,7 +233,7 @@ Pixmap3D* PNGReader3D::read(ifstream& is, const string& path, Pixmap3D* ret) con
int width = info_ptr->width;
int height = info_ptr->height;
int color_type = info_ptr->color_type;
int bit_depth = info_ptr->bit_depth;
//int bit_depth = info_ptr->bit_depth;
//We want RGB, 24 bit
if (color_type == PNG_COLOR_TYPE_PALETTE || (color_type == PNG_COLOR_TYPE_GRAY && info_ptr->bit_depth < 8) || (info_ptr->valid & PNG_INFO_tRNS)) {
@ -243,7 +244,8 @@ Pixmap3D* PNGReader3D::read(ifstream& is, const string& path, Pixmap3D* ret) con
png_set_gray_to_rgb(png_ptr);
}
int number_of_passes = png_set_interlace_handling(png_ptr);
//int number_of_passes = png_set_interlace_handling(png_ptr);
png_set_interlace_handling(png_ptr);
png_read_update_info(png_ptr, info_ptr);
png_bytep* row_pointers = new png_bytep[height];

View File

@ -56,7 +56,7 @@ static const int tgaUncompressedBw= 3;
static inline std::vector<string> getExtensionStrings() {
//static const string extensions[] = {"tga", ""};
static std::vector<string> extensions;
if(extensions.size() == 0) {
if(extensions.empty() == true) {
extensions.push_back("tga");
}

View File

@ -1,7 +1,7 @@
// ==============================================================
// This file is part of Glest Shared Library (www.glest.org)
//
// Copyright (C) 2001-2008 Martiño Figueroa
// Copyright (C) 2001-2008 Marti<EFBFBD>o Figueroa
//
// You can redistribute this code and/or modify it under
// the terms of the GNU General Public License as published
@ -69,7 +69,7 @@ bool ShaderProgramGl::link(string &messages){
//bind attributes
for(unsigned int i=0; i<attributes.size(); ++i){
int a= attributes[i].second;
//int a= attributes[i].second;
string s= attributes[i].first;
glBindAttribLocationARB(handle, attributes[i].second, attributes[i].first.c_str());
}

View File

@ -0,0 +1,240 @@
// ==============================================================
// This file is part of Glest Shared Library (www.glest.org)
//
// Copyright (C) 2001-2005 Marti<74>o Figueroa
//
// You can redistribute this code and/or modify it under
// the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version
// ==============================================================
#include "shader_gl.h"
#include <fstream>
#include "opengl.h"
#include "leak_dumper.h"
using namespace std;
namespace Shared{ namespace Graphics{ namespace Gl{
// =====================================================
// class ShaderProgramGl
// =====================================================
ShaderProgramGl::ShaderProgramGl(){
inited= false;
}
void ShaderProgramGl::init(){
if(!inited){
assertGl();
handle= glCreateProgramObjectARB();
assertGl();
inited= true;
}
}
void ShaderProgramGl::end(){
if(inited){
assertGl();
glDeleteObjectARB(handle);
assertGl();
inited= false;
}
}
void ShaderProgramGl::attach(VertexShader *vertexShader, FragmentShader *fragmentShader){
this->vertexShader= vertexShader;
this->fragmentShader= fragmentShader;
}
bool ShaderProgramGl::link(string &messages){
assertGl();
VertexShaderGl *vertexShaderGl= static_cast<VertexShaderGl*>(vertexShader);
FragmentShaderGl *fragmentShaderGl= static_cast<FragmentShaderGl*>(fragmentShader);
const ShaderSource *vss= vertexShaderGl->getSource();
const ShaderSource *fss= fragmentShaderGl->getSource();
messages= "Linking program: " + vss->getPathInfo() + ", " + fss->getPathInfo() + "\n";
//attach
glAttachObjectARB(handle, vertexShaderGl->getHandle());
glAttachObjectARB(handle, fragmentShaderGl->getHandle());
assertGl();
//bind attributes
for(int i=0; i<attributes.size(); ++i){
//int a= attributes[i].second;
string s= attributes[i].first;
glBindAttribLocationARB(handle, attributes[i].second, attributes[i].first.c_str());
}
assertGl();
//link
glLinkProgramARB(handle);
glValidateProgramARB(handle);
assertGl();
//log
GLint logLength= 0;
glGetObjectParameterivARB(handle, GL_OBJECT_INFO_LOG_LENGTH_ARB, &logLength);
char *buffer= new char[logLength+1];
glGetInfoLogARB(handle, logLength+1, NULL, buffer);
messages+= buffer;
delete [] buffer;
assertGl();
//status
GLint status= false;
glGetObjectParameterivARB(handle, GL_OBJECT_LINK_STATUS_ARB, &status);
assertGl();
return status!=0;
}
void ShaderProgramGl::activate(){
assertGl();
glUseProgramObjectARB(handle);
assertGl();
}
void ShaderProgramGl::setUniform(const string &name, int value){
assertGl();
glUniform1iARB(getLocation(name), value);
assertGl();
}
void ShaderProgramGl::setUniform(const string &name, float value){
assertGl();
glUniform1fARB(getLocation(name), value);
assertGl();
}
void ShaderProgramGl::setUniform(const string &name, const Vec2f &value){
assertGl();
glUniform2fvARB(getLocation(name), 1, value.ptr());
assertGl();
}
void ShaderProgramGl::setUniform(const string &name, const Vec3f &value){
assertGl();
glUniform3fvARB(getLocation(name), 1, value.ptr());
assertGl();
}
void ShaderProgramGl::setUniform(const string &name, const Vec4f &value){
assertGl();
glUniform4fvARB(getLocation(name), 1, value.ptr());
assertGl();
}
void ShaderProgramGl::setUniform(const string &name, const Matrix3f &value){
assertGl();
glUniformMatrix3fvARB(getLocation(name), 1, GL_FALSE, value.ptr());
assertGl();
}
void ShaderProgramGl::setUniform(const string &name, const Matrix4f &value){
assertGl();
glUniformMatrix4fvARB(getLocation(name), 1, GL_FALSE, value.ptr());
assertGl();
}
void ShaderProgramGl::bindAttribute(const string &name, int index){
attributes.push_back(AttributePair(name, index));
}
GLint ShaderProgramGl::getLocation(const string &name){
GLint location= glGetUniformLocationARB(handle, name.c_str());
if(location==-1){
throw runtime_error("Can't locate uniform: "+ name);
}
return location;
}
// ===============================================
// class ShaderGl
// ===============================================
ShaderGl::ShaderGl(){
inited= false;
}
void ShaderGl::load(const string &path){
source.load(path);
}
bool ShaderGl::compile(string &messages){
assertGl();
messages= "Compiling shader: " + source.getPathInfo() + "\n";
//load source
GLint length= source.getCode().size();
const GLcharARB *csource= source.getCode().c_str();
glShaderSourceARB(handle, 1, &csource, &length);
//compile
glCompileShaderARB(handle);
//log
GLint logLength= 0;
glGetObjectParameterivARB(handle, GL_OBJECT_INFO_LOG_LENGTH_ARB, &logLength);
char *buffer= new char[logLength+1];
glGetInfoLogARB(handle, logLength+1, NULL, buffer);
messages+= buffer;
delete [] buffer;
//status
GLint status= false;
glGetObjectParameterivARB(handle, GL_OBJECT_COMPILE_STATUS_ARB, &status);
assertGl();
return status!=0;
}
void ShaderGl::end(){
if(inited){
assertGl();
glDeleteObjectARB(handle);
assertGl();
}
}
// ===============================================
// class VertexShaderGl
// ===============================================
void VertexShaderGl::init(){
if(!inited){
assertGl();
handle= glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
assertGl();
inited= true;
}
}
// ===============================================
// class FragmentShaderGl
// ===============================================
void FragmentShaderGl::init(){
if(!inited){
assertGl();
handle= glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
assertGl();
inited= true;
}
}
}}}//end namespace

View File

@ -52,17 +52,17 @@ InterpolationData::~InterpolationData(){
for(std::map<float, std::map<bool, Vec3f *> >::iterator iterVert = cacheVertices.begin();
iterVert != cacheVertices.end(); iterVert++) {
iterVert != cacheVertices.end(); ++iterVert) {
for(std::map<bool, Vec3f *>::iterator iterVert2 = iterVert->second.begin();
iterVert2 != iterVert->second.end(); iterVert2++) {
iterVert2 != iterVert->second.end(); ++iterVert2) {
delete [] iterVert2->second;
}
}
for(std::map<float, std::map<bool, Vec3f *> >::iterator iterVert = cacheNormals.begin();
iterVert != cacheNormals.end(); iterVert++) {
iterVert != cacheNormals.end(); ++iterVert) {
for(std::map<bool, Vec3f *>::iterator iterVert2 = iterVert->second.begin();
iterVert2 != iterVert->second.end(); iterVert2++) {
iterVert2 != iterVert->second.end(); ++iterVert2) {
delete [] iterVert2->second;
}
}

View File

@ -409,7 +409,7 @@ GameParticleSystem::GameParticleSystem(int particleCount):
{}
GameParticleSystem::~GameParticleSystem(){
for(Children::iterator it= children.begin(); it != children.end(); it++){
for(Children::iterator it= children.begin(); it != children.end(); ++it){
(*it)->setParent(NULL);
(*it)->fade();
}
@ -512,7 +512,7 @@ void GameParticleSystem::setTween(float relative,float absolute) {
tween= clamp(tween, 0.0f, 1.0f);
}
for(Children::iterator it= children.begin(); it != children.end(); it++)
for(Children::iterator it= children.begin(); it != children.end(); ++it)
(*it)->setTween(relative,absolute);
}
@ -580,7 +580,7 @@ void UnitParticleSystem::render(ParticleRenderer *pr, ModelRenderer *mr) {
void UnitParticleSystem::setRotation(float rotation){
this->rotation= rotation;
for(Children::iterator it= children.begin(); it != children.end(); it++)
for(Children::iterator it= children.begin(); it != children.end(); ++it)
(*it)->setRotation(rotation);
}
@ -998,7 +998,7 @@ void ProjectileParticleSystem::rotateChildren() {
float rotation = atan2(direction.x, direction.z);
#endif
rotation = radToDeg(rotation);
for(Children::iterator it = children.begin(); it != children.end(); it++)
for(Children::iterator it = children.begin(); it != children.end(); ++it)
(*it)->setRotation(rotation);
}
@ -1169,14 +1169,14 @@ void ParticleManager::render(ParticleRenderer *pr, ModelRenderer *mr) const{
bool ParticleManager::hasActiveParticleSystem(ParticleSystem::ParticleSystemType type) const{
bool result= false;
size_t particleSystemCount= particleSystems.size();
int currentParticleCount= 0;
//size_t particleSystemCount= particleSystems.size();
//int currentParticleCount= 0;
vector<ParticleSystem *> cleanupParticleSystemsList;
for(unsigned int i= 0; i < particleSystems.size(); i++){
ParticleSystem *ps= particleSystems[i];
if(ps != NULL){
currentParticleCount+= ps->getAliveParticleCount();
//currentParticleCount+= ps->getAliveParticleCount();
bool showParticle= true;
if(dynamic_cast<UnitParticleSystem *> (ps) != NULL || dynamic_cast<FireParticleSystem *> (ps) != NULL){

View File

@ -1322,7 +1322,8 @@ void Pixmap3D::loadSlicePng(const string &path, int slice) {
this->path = path;
//deletePixels();
Pixmap3D *pixmap = FileReader<Pixmap3D>::readPath(path,this);
//Pixmap3D *pixmap = FileReader<Pixmap3D>::readPath(path,this);
FileReader<Pixmap3D>::readPath(path,this);
//printf("Loading 3D pixmap PNG [%s] pixmap [%p] this [%p]\n",path.c_str(),pixmap, this);
}

View File

@ -717,7 +717,7 @@ void MapPreview::loadFromFile(const string &path) {
#else
FILE *f1 = fopen(path.c_str(), "rb");
#endif
int fileErrno = errno;
//int fileErrno = errno;
if (f1 != NULL) {
//read header

View File

@ -238,7 +238,7 @@ void findDirs(string path, vector<string> &results, bool errorOnNotFound,bool ke
string searchpath = currentPath + "*.";
vector<string> current_results;
findAll(searchpath, current_results, false, errorOnNotFound);
if(current_results.size() > 0) {
if(current_results.empty() == false) {
for(unsigned int folder_index = 0; folder_index < current_results.size(); folder_index++) {
const string current_folder = current_results[folder_index];
const string current_folder_path = currentPath + current_folder;
@ -263,7 +263,7 @@ void findDirs(const vector<string> &paths, vector<string> &results, bool errorOn
string path = currentPath + "*.";
vector<string> current_results;
findAll(path, current_results, false, errorOnNotFound);
if(current_results.size() > 0) {
if(current_results.empty() == false) {
for(unsigned int folder_index = 0; folder_index < current_results.size(); folder_index++) {
const string current_folder = current_results[folder_index];
const string current_folder_path = currentPath + current_folder;
@ -290,7 +290,7 @@ void findAll(const vector<string> &paths, const string &fileFilter, vector<strin
string path = currentPath + fileFilter;
vector<string> current_results;
findAll(path, current_results, cutExtension, errorOnNotFound);
if(current_results.size() > 0) {
if(current_results.empty() == false) {
for(unsigned int folder_index = 0; folder_index < current_results.size(); folder_index++) {
string current_file = current_results[folder_index];
if(keepDuplicates == true || std::find(results.begin(),results.end(),current_file) == results.end()) {
@ -347,7 +347,7 @@ void findAll(const string &path, vector<string> &results, bool cutExtension, boo
globfree(&globbuf);
if(results.size() == 0 && errorOnNotFound == true) {
if(results.empty() == true && errorOnNotFound == true) {
throw runtime_error("No files found in: " + mypath);
}

View File

@ -591,7 +591,7 @@ string getNetworkInterfaceBroadcastAddress(string ipAddress)
next = next->Next;
}
}
char buf[128];
//char buf[128];
if (name == NULL)
{
//sprintf(buf, "unnamed-%i", i);
@ -901,7 +901,7 @@ bool Socket::hasDataToRead(std::map<PLATFORM_SOCKET,bool> &socketTriggeredList)
PLATFORM_SOCKET imaxsocket = 0;
for(std::map<PLATFORM_SOCKET,bool>::iterator itermap = socketTriggeredList.begin();
itermap != socketTriggeredList.end(); itermap++)
itermap != socketTriggeredList.end(); ++itermap)
{
PLATFORM_SOCKET socket = itermap->first;
if(Socket::isSocketValid(&socket) == true)
@ -933,7 +933,7 @@ bool Socket::hasDataToRead(std::map<PLATFORM_SOCKET,bool> &socketTriggeredList)
bResult = true;
for(std::map<PLATFORM_SOCKET,bool>::iterator itermap = socketTriggeredList.begin();
itermap != socketTriggeredList.end(); itermap++)
itermap != socketTriggeredList.end(); ++itermap)
{
PLATFORM_SOCKET socket = itermap->first;
if (FD_ISSET(socket, &rfds))
@ -1741,10 +1741,9 @@ void BroadCastClientSocketThread::execute() {
struct sockaddr_in bcSender; // local socket address for the broadcast.
struct sockaddr_in bcaddr; // The broadcast address for the receiver.
PLATFORM_SOCKET bcfd; // The file descriptor used for the broadcast.
bool one = true; // Parameter for "setscokopt".
//bool one = true; // Parameter for "setscokopt".
char buff[10024]; // Buffers the data to be broadcasted.
socklen_t alen;
int nb; // The number of bytes read.
port = htons( Socket::getBroadCastPort() );
@ -1780,6 +1779,7 @@ void BroadCastClientSocketThread::execute() {
// Keep getting packets forever.
for( time_t elapsed = time(NULL); difftime(time(NULL),elapsed) <= 5; ) {
alen = sizeof(struct sockaddr);
int nb=0; // The number of bytes read.
bool gotData = (nb = recvfrom(bcfd, buff, 10024, 0, (struct sockaddr *) &bcSender, &alen)) > 0;
if(gotData == false) {
@ -2316,11 +2316,11 @@ void BroadCastSocketThread::execute() {
char buff[buffMaxSize]=""; // Buffers the data to be broadcasted.
char myhostname[100]=""; // hostname of local machine
//char subnetmask[MAX_NIC_COUNT][100]; // Subnet mask to broadcast to
struct hostent* myhostent=NULL;
//struct hostent* myhostent=NULL;
/* get my host name */
gethostname(myhostname,100);
myhostent = gethostbyname(myhostname);
struct hostent*myhostent = gethostbyname(myhostname);
// get all host IP addresses
std::vector<std::string> ipList = Socket::getLocalIPAddressList();

View File

@ -370,7 +370,7 @@ void Window::setupGraphicsScreen(int depthBits, int stencilBits, bool hardware_a
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, newStencilBits);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, newDepthBits);
const SDL_VideoInfo *info = SDL_GetVideoInfo();
//const SDL_VideoInfo *info = SDL_GetVideoInfo();
#ifdef SDL_GL_SWAP_CONTROL
if(Window::tryVSynch == true) {
/* we want vsync for smooth scrolling */
@ -424,10 +424,10 @@ void Window::toggleFullscreen() {
SDL_Surface *sf = SDL_GetVideoSurface();
SDL_Surface **surface = &sf;
uint32 *flags = NULL;
void *pixels = NULL;
SDL_Color *palette = NULL;
//void *pixels = NULL;
//SDL_Color *palette = NULL;
SDL_Rect clip;
int ncolors = 0;
//int ncolors = 0;
Uint32 tmpflags = 0;
int w = 0;
int h = 0;

View File

@ -52,7 +52,7 @@ void createGlFontBitmaps(uint32 &base, const string &type, int size, int width,
DWORD dwErrorGL = 0;
HDC hDC = 0;
static std::vector<std::string> systemFontList;
if(systemFontList.size() == 0) {
if(systemFontList.empty() == true) {
LOGFONT lf;
//POSITION pos;
//lf.lfCharSet = ANSI_CHARSET;

View File

@ -153,7 +153,7 @@ bool Checksum::addFileToSum(const string &path) {
memset(buf,0,bufSize);
if(fgets(buf, bufSize, file) != NULL) {
//addByte(byte);
for(int i = 0; buf[i] != 0 && i < bufSize; i++) {
for(int i = 0; i < bufSize && buf[i] != 0; i++) {
// Ignore Spaces in XML files as they are
// ONLY for formatting
if(isXMLFile == true) {
@ -196,7 +196,7 @@ int32 Checksum::getSum() {
Checksum newResult;
for(std::map<string,int32>::iterator iterMap = fileList.begin();
iterMap != fileList.end(); iterMap++) {
iterMap != fileList.end(); ++iterMap) {
MutexSafeWrapper safeMutexSocketDestructorFlag(&Checksum::fileListCacheSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__));
if(Checksum::fileListCache.find(iterMap->first) == Checksum::fileListCache.end()) {

View File

@ -714,7 +714,7 @@ void Properties::setString(const string &key, const string &value){
string Properties::toString(){
string rStr;
for(PropertyMap::iterator pi= propertyMap.begin(); pi!=propertyMap.end(); pi++)
for(PropertyMap::iterator pi= propertyMap.begin(); pi!=propertyMap.end(); ++pi)
rStr+= pi->first + "=" + pi->second + "\n";
return rStr;

View File

@ -337,7 +337,7 @@ void SystemFlags::Close() {
}
for(std::map<SystemFlags::DebugType,SystemFlags::SystemFlagsType>::iterator iterMap = SystemFlags::debugLogFileList->begin();
iterMap != SystemFlags::debugLogFileList->end(); iterMap++) {
iterMap != SystemFlags::debugLogFileList->end(); ++iterMap) {
SystemFlags::SystemFlagsType &currentDebugLog = iterMap->second;
currentDebugLog.Close();
}
@ -451,7 +451,7 @@ void SystemFlags::logDebugEntry(DebugType type, string debugEntry, time_t debugT
// If the file is already open (shared) by another debug type
// do not over-write the file but share the stream pointer
for(std::map<SystemFlags::DebugType,SystemFlags::SystemFlagsType>::iterator iterMap = SystemFlags::debugLogFileList->begin();
iterMap != SystemFlags::debugLogFileList->end(); iterMap++) {
iterMap != SystemFlags::debugLogFileList->end(); ++iterMap) {
SystemFlags::SystemFlagsType &currentDebugLog2 = iterMap->second;
if( iterMap->first != type &&
@ -739,7 +739,7 @@ bool fileExists(const string &path) {
return true;
}
else {
int fileErrno = errno;
//int fileErrno = errno;
#ifdef WIN32
DWORD error = GetLastError();
string strError = "Could not open file, result: " + intToStr(error) + " - " + intToStr(fileErrno) + " " + strerror(fileErrno) + " [" + path + "]";

View File

@ -187,7 +187,7 @@ void XmlTree::load(const string &path, std::map<string,string> mapTagReplacement
Mutex &mutex = CacheManager::getMutexForItem<LoadStack>(loadStackCacheName);
MutexSafeWrapper safeMutex(&mutex);
for(LoadStack::iterator it= loadStack.begin(); it!= loadStack.end(); it++){
for(LoadStack::iterator it= loadStack.begin(); it!= loadStack.end(); ++it){
if((*it)->loadPath == path){
throw runtime_error(path + " recursively included");
}
@ -363,7 +363,7 @@ bool XmlNode::hasChild(const string &childName) const {
}
bool XmlNode::hasChildNoSuper(const string &childName) const {
int count= 0;
//int count= 0;
for(unsigned int j = 0; j < children.size(); ++j) {
if(children[j]->getName() == childName) {
return true;