diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index afd90a58..f0e91d85 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -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 diff --git a/source/glest_game/menu/menu_state_graphic_info.cpp b/source/glest_game/menu/menu_state_graphic_info.cpp index 32cbb7a0..95984d99 100644 --- a/source/glest_game/menu/menu_state_graphic_info.cpp +++ b/source/glest_game/menu/menu_state_graphic_info.cpp @@ -106,7 +106,7 @@ void MenuStateGraphicInfo::keyDown(SDL_KeyboardEvent key) { Config &configKeys = Config::getInstance(std::pair(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"))+ "]"); } diff --git a/source/glest_game/menu/menu_state_join_game.cpp b/source/glest_game/menu/menu_state_join_game.cpp index 2d967ca2..7a974d21 100644 --- a/source/glest_game/menu/menu_state_join_game.cpp +++ b/source/glest_game/menu/menu_state_join_game.cpp @@ -173,7 +173,7 @@ void MenuStateJoinGame::DiscoveredServers(std::vector serverList) { autoConnectToServer = false; buttonAutoFindServers.setEnabled(true); buttonConnect.setEnabled(true); - if(serverList.size() > 0) { + if(serverList.empty() == false) { string bestIPMatch = ""; std::vector 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(cfgMainKeys,cfgUserKeys)); + //Config &configKeys = Config::getInstance(std::pair(cfgMainKeys,cfgUserKeys)); SDLKey key = extractKeyPressed(c); diff --git a/source/glest_game/menu/menu_state_keysetup.cpp b/source/glest_game/menu/menu_state_keysetup.cpp index 2ecf676e..abd5dff9 100644 --- a/source/glest_game/menu/menu_state_keysetup.cpp +++ b/source/glest_game/menu/menu_state_keysetup.cpp @@ -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(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()); diff --git a/source/glest_game/menu/menu_state_masterserver.cpp b/source/glest_game/menu/menu_state_masterserver.cpp index 02312732..0712e82e 100644 --- a/source/glest_game/menu/menu_state_masterserver.cpp +++ b/source/glest_game/menu/menu_state_masterserver.cpp @@ -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()); diff --git a/source/glest_game/menu/menu_state_mods.cpp b/source/glest_game/menu/menu_state_mods.cpp index 5a26027d..44b63275 100644 --- a/source/glest_game/menu/menu_state_mods.cpp +++ b/source/glest_game/menu/menu_state_mods.cpp @@ -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 mapPathList = config.getPathListForType(ptMaps); std::pair 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 tilesetsPath; vector 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 techtreesPath; vector 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 scenariosPath; vector 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) { diff --git a/source/glest_game/menu/menu_state_new_game.cpp b/source/glest_game/menu/menu_state_new_game.cpp index e3a26c46..8bf49ce7 100644 --- a/source/glest_game/menu/menu_state_new_game.cpp +++ b/source/glest_game/menu/menu_state_new_game.cpp @@ -137,7 +137,7 @@ void MenuStateNewGame::keyDown(SDL_KeyboardEvent key) { Config &configKeys = Config::getInstance(std::pair(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"))+ "]"); } diff --git a/source/glest_game/menu/menu_state_options.cpp b/source/glest_game/menu/menu_state_options.cpp index dece3e5c..ed2982af 100644 --- a/source/glest_game/menu/menu_state_options.cpp +++ b/source/glest_game/menu/menu_state_options.cpp @@ -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()getText(); //text.insert(text.end()-1, key); @@ -742,7 +742,7 @@ void MenuStateOptions::keyPress(SDL_KeyboardEvent c) { Config &configKeys = Config::getInstance(std::pair(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(); diff --git a/source/glest_game/menu/menu_state_root.cpp b/source/glest_game/menu/menu_state_root.cpp index c3f26f06..161f3fb2 100644 --- a/source/glest_game/menu/menu_state_root.cpp +++ b/source/glest_game/menu/menu_state_root.cpp @@ -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"))+ "]"); } diff --git a/source/glest_game/menu/menu_state_scenario.cpp b/source/glest_game/menu/menu_state_scenario.cpp index 7fd89cde..87f10070 100644 --- a/source/glest_game/menu/menu_state_scenario.cpp +++ b/source/glest_game/menu/menu_state_scenario.cpp @@ -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(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"))+ "]"); } diff --git a/source/glest_game/network/client_interface.cpp b/source/glest_game/network/client_interface.cpp index 186d3e5b..e6007e93 100644 --- a/source/glest_game/network/client_interface.cpp +++ b/source/glest_game/network/client_interface.cpp @@ -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()); diff --git a/source/glest_game/network/connection_slot.cpp b/source/glest_game/network/connection_slot.cpp index 3a05087e..8485e52b 100644 --- a/source/glest_game/network/connection_slot.cpp +++ b/source/glest_game/network/connection_slot.cpp @@ -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 ConnectionSlot::getPendingNetworkCommandList(bool clearLi vector 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 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(); diff --git a/source/glest_game/network/connection_slot.h b/source/glest_game/network/connection_slot.h index ef520af9..664ec451 100644 --- a/source/glest_game/network/connection_slot.h +++ b/source/glest_game/network/connection_slot.h @@ -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(); diff --git a/source/glest_game/network/network_interface.cpp b/source/glest_game/network/network_interface.cpp index 4ef5a048..b63c517f 100644 --- a/source/glest_game/network/network_interface.cpp +++ b/source/glest_game/network/network_interface.cpp @@ -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) diff --git a/source/glest_game/network/network_interface.h b/source/glest_game/network/network_interface.h index 376f69af..c179e5dc 100644 --- a/source/glest_game/network/network_interface.h +++ b/source/glest_game/network/network_interface.h @@ -236,6 +236,11 @@ private: public: FileTransferInfo() { + hostType = eClient; + serverIP = ""; + serverPort = 0; + opType = eSend; + fileName = ""; } FileTransferInfo(const FileTransferInfo &obj) { diff --git a/source/glest_game/network/network_manager.h b/source/glest_game/network/network_manager.h index d7fe04f7..55135d95 100644 --- a/source/glest_game/network/network_manager.h +++ b/source/glest_game/network/network_manager.h @@ -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 diff --git a/source/glest_game/network/network_message.h b/source/glest_game/network/network_message.h index 54fdd558..f9637a37 100644 --- a/source/glest_game/network/network_message.h +++ b/source/glest_game/network/network_message.h @@ -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); diff --git a/source/glest_game/network/network_types.h b/source/glest_game/network/network_types.h index 64e81b91..61e2088a 100644 --- a/source/glest_game/network/network_types.h +++ b/source/glest_game/network/network_types.h @@ -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]); diff --git a/source/glest_game/network/server_interface.cpp b/source/glest_game/network/server_interface.cpp index d7d34a17..4dd9b095 100644 --- a/source/glest_game/network/server_interface.cpp +++ b/source/glest_game/network/server_interface.cpp @@ -80,7 +80,7 @@ ServerInterface::ServerInterface(bool publishEnabled) :GameNetworkInterface() { if(Config::getInstance().getBool("EnableFTPServer","true") == true) { std::pair mapsPath; vector 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 tilesetsPath; vector 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 techtreesPath; vector 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 &socketTriggeredList, std::map &eventList, std::map & 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 & mapSlotSigna try { std::vector 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 &mapSlotSignalled try { std::vector 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 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 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 &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]; diff --git a/source/glest_game/type_instances/faction.cpp b/source/glest_game/type_instances/faction.cpp index 05d061f4..cdd78ff5 100644 --- a/source/glest_game/type_instances/faction.cpp +++ b/source/glest_game/type_instances/faction.cpp @@ -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 > >::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::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::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 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 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 *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 *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) { diff --git a/source/glest_game/type_instances/object.h b/source/glest_game/type_instances/object.h index 2a8eb0ce..89fec505 100644 --- a/source/glest_game/type_instances/object.h +++ b/source/glest_game/type_instances/object.h @@ -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; diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index f38996e6..3132f6d2 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -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); diff --git a/source/glest_game/type_instances/unit.h b/source/glest_game/type_instances/unit.h index 5923923b..183ff67f 100644 --- a/source/glest_game/type_instances/unit.h +++ b/source/glest_game/type_instances/unit.h @@ -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; } diff --git a/source/glest_game/type_instances/upgrade.cpp b/source/glest_game/type_instances/upgrade.cpp index 8ad1a01f..695c3441 100644 --- a/source/glest_game/type_instances/upgrade.cpp +++ b/source/glest_game/type_instances/upgrade.cpp @@ -94,7 +94,7 @@ void UpgradeManager::cancelUpgrade(const UpgradeType *upgradeType) { upgradesLookup.erase(upgradeType); for(map::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) diff --git a/source/glest_game/types/command_type.cpp b/source/glest_game/types/command_type.cpp index 41d0eedc..8caccfcb 100644 --- a/source/glest_game/types/command_type.cpp +++ b/source/glest_game/types/command_type.cpp @@ -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 { diff --git a/source/glest_game/types/damage_multiplier.cpp b/source/glest_game/types/damage_multiplier.cpp new file mode 100644 index 00000000..d396746b --- /dev/null +++ b/source/glest_game/types/damage_multiplier.cpp @@ -0,0 +1,51 @@ +// ============================================================== +// This file is part of Glest (www.glest.org) +// +// Copyright (C) 2001-2008 Marti�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; igetId()+att->getId()]; +} + +void DamageMultiplierTable::setDamageMultiplier(const AttackType *att, const ArmorType *art, float value){ + values[attackTypeCount*art->getId()+att->getId()]= value; +} + +}}//end namespaces diff --git a/source/glest_game/types/element_type.cpp b/source/glest_game/types/element_type.cpp index a8a4abe5..10391b6b 100644 --- a/source/glest_game/types/element_type.cpp +++ b/source/glest_game/types/element_type.cpp @@ -77,6 +77,7 @@ string RequirableType::getReqDesc() const{ ProducibleType::ProducibleType(){ cancelImage= NULL; + productionTime=0; } ProducibleType::~ProducibleType(){ diff --git a/source/glest_game/types/faction_type.cpp b/source/glest_game/types/faction_type.cpp index 3307e53a..9323a249 100644 --- a/source/glest_game/types/faction_type.cpp +++ b/source/glest_game/types/faction_type.cpp @@ -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; } diff --git a/source/glest_game/types/skill_type.cpp b/source/glest_game/types/skill_type.cpp index 54fdd0e0..5a981d33 100644 --- a/source/glest_game/types/skill_type.cpp +++ b/source/glest_game/types/skill_type.cpp @@ -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, diff --git a/source/glest_game/types/unit_type.cpp b/source/glest_game/types/unit_type.cpp index 98389a3b..e8bce34e 100644 --- a/source/glest_game/types/unit_type.cpp +++ b/source/glest_game/types/unit_type.cpp @@ -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, diff --git a/source/glest_game/types/upgrade_type.cpp b/source/glest_game/types/upgrade_type.cpp index b839ad16..333d9129 100644 --- a/source/glest_game/types/upgrade_type.cpp +++ b/source/glest_game/types/upgrade_type.cpp @@ -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; igetName()+"\n"; } } diff --git a/source/glest_game/world/map.cpp b/source/glest_game/world/map.cpp index 1aa11976..d53a499b 100644 --- a/source/glest_game/world/map.cpp +++ b/source/glest_game/world/map.cpp @@ -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 Map::getUnitDistanceToPos(const Unit *unit,Vec2i pos,cons } std::pair 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(); diff --git a/source/glest_game/world/minimap.cpp b/source/glest_game/world/minimap.cpp index 5ab36c75..98db29c4 100644 --- a/source/glest_game/world/minimap.cpp +++ b/source/glest_game/world/minimap.cpp @@ -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) { diff --git a/source/glest_game/world/time_flow.cpp b/source/glest_game/world/time_flow.cpp index 82c1d52e..05085168 100644 --- a/source/glest_game/world/time_flow.cpp +++ b/source/glest_game/world/time_flow.cpp @@ -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->timeroutePlanner = 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 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) { diff --git a/source/glest_game/world/world.cpp b/source/glest_game/world/world.cpp index 01c759e2..78a219a6 100644 --- a/source/glest_game/world/world.cpp +++ b/source/glest_game/world/world.cpp @@ -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::iterator iterMap = staticSoundList.begin(); - iterMap != staticSoundList.end(); iterMap++) { + iterMap != staticSoundList.end(); ++iterMap) { delete iterMap->second; } staticSoundList.clear(); for(std::map::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 >::iterator iterFind = ExploredCellsLookupItemCache.find(newPos); if(iterFind != ExploredCellsLookupItemCache.end()) { - cacheLookupPosResult = true; + //cacheLookupPosResult = true; std::map::iterator iterFind2 = iterFind->second.find(sightRange); if(iterFind2 != iterFind->second.end()) { - cacheLookupSightResult = true; + //cacheLookupSightResult = true; std::vector &cellList = iterFind2->second.exploredCellList; for(int idx2 = 0; idx2 < cellList.size(); ++idx2) { diff --git a/source/shared_lib/sources/graphics/BMPReader.cpp b/source/shared_lib/sources/graphics/BMPReader.cpp index b2fbe81c..f8d96928 100644 --- a/source/shared_lib/sources/graphics/BMPReader.cpp +++ b/source/shared_lib/sources/graphics/BMPReader.cpp @@ -57,7 +57,7 @@ static inline std::vector getExtensionsBmp() { //static const string extensions[] = {"bmp", ""}; static std::vector extensions; - if(extensions.size() == 0) { + if(extensions.empty() == true) { extensions.push_back("bmp"); } diff --git a/source/shared_lib/sources/graphics/JPGReader.cpp b/source/shared_lib/sources/graphics/JPGReader.cpp index 52d15bf7..8c2a4e8d 100644 --- a/source/shared_lib/sources/graphics/JPGReader.cpp +++ b/source/shared_lib/sources/graphics/JPGReader.cpp @@ -60,7 +60,7 @@ static void term_source (j_decompress_ptr cinfo) { //static const string extensions[] = {"jpg", "jpeg", ""}; static inline std::vector getExtensions() { static std::vector extensions; - if(extensions.size() == 0) { + if(extensions.empty() == true) { extensions.push_back("jpg"); extensions.push_back("jpeg"); } diff --git a/source/shared_lib/sources/graphics/PNGReader.cpp b/source/shared_lib/sources/graphics/PNGReader.cpp index a8bc246c..18fa54e7 100644 --- a/source/shared_lib/sources/graphics/PNGReader.cpp +++ b/source/shared_lib/sources/graphics/PNGReader.cpp @@ -48,7 +48,7 @@ static void user_flush_data(png_structp png_ptr) {} static inline std::vector getExtensionsPng() { //static const string extensions[] = {"png", ""}; static std::vector extensions; - if(extensions.size() == 0) { + if(extensions.empty() == true) { extensions.push_back("png"); } return extensions; @@ -63,7 +63,7 @@ PNGReader::PNGReader(): FileReader(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(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]; diff --git a/source/shared_lib/sources/graphics/TGAReader.cpp b/source/shared_lib/sources/graphics/TGAReader.cpp index 4c8f88ef..a4311b18 100644 --- a/source/shared_lib/sources/graphics/TGAReader.cpp +++ b/source/shared_lib/sources/graphics/TGAReader.cpp @@ -56,7 +56,7 @@ static const int tgaUncompressedBw= 3; static inline std::vector getExtensionStrings() { //static const string extensions[] = {"tga", ""}; static std::vector extensions; - if(extensions.size() == 0) { + if(extensions.empty() == true) { extensions.push_back("tga"); } diff --git a/source/shared_lib/sources/graphics/gl/shader_gl.cpp b/source/shared_lib/sources/graphics/gl/shader_gl.cpp index 52255ccf..887478c2 100644 --- a/source/shared_lib/sources/graphics/gl/shader_gl.cpp +++ b/source/shared_lib/sources/graphics/gl/shader_gl.cpp @@ -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�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 + +#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(vertexShader); + FragmentShaderGl *fragmentShaderGl= static_cast(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 >::iterator iterVert = cacheVertices.begin(); - iterVert != cacheVertices.end(); iterVert++) { + iterVert != cacheVertices.end(); ++iterVert) { for(std::map::iterator iterVert2 = iterVert->second.begin(); - iterVert2 != iterVert->second.end(); iterVert2++) { + iterVert2 != iterVert->second.end(); ++iterVert2) { delete [] iterVert2->second; } } for(std::map >::iterator iterVert = cacheNormals.begin(); - iterVert != cacheNormals.end(); iterVert++) { + iterVert != cacheNormals.end(); ++iterVert) { for(std::map::iterator iterVert2 = iterVert->second.begin(); - iterVert2 != iterVert->second.end(); iterVert2++) { + iterVert2 != iterVert->second.end(); ++iterVert2) { delete [] iterVert2->second; } } diff --git a/source/shared_lib/sources/graphics/particle.cpp b/source/shared_lib/sources/graphics/particle.cpp index ddb39d68..a1b4b41d 100644 --- a/source/shared_lib/sources/graphics/particle.cpp +++ b/source/shared_lib/sources/graphics/particle.cpp @@ -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 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 (ps) != NULL || dynamic_cast (ps) != NULL){ diff --git a/source/shared_lib/sources/graphics/pixmap.cpp b/source/shared_lib/sources/graphics/pixmap.cpp index 62ab3b03..56efd3d9 100644 --- a/source/shared_lib/sources/graphics/pixmap.cpp +++ b/source/shared_lib/sources/graphics/pixmap.cpp @@ -1322,7 +1322,8 @@ void Pixmap3D::loadSlicePng(const string &path, int slice) { this->path = path; //deletePixels(); - Pixmap3D *pixmap = FileReader::readPath(path,this); + //Pixmap3D *pixmap = FileReader::readPath(path,this); + FileReader::readPath(path,this); //printf("Loading 3D pixmap PNG [%s] pixmap [%p] this [%p]\n",path.c_str(),pixmap, this); } diff --git a/source/shared_lib/sources/map/map_preview.cpp b/source/shared_lib/sources/map/map_preview.cpp index bb2c7851..f2169d99 100644 --- a/source/shared_lib/sources/map/map_preview.cpp +++ b/source/shared_lib/sources/map/map_preview.cpp @@ -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 diff --git a/source/shared_lib/sources/platform/common/platform_common.cpp b/source/shared_lib/sources/platform/common/platform_common.cpp index 597597f3..0f2d92dd 100644 --- a/source/shared_lib/sources/platform/common/platform_common.cpp +++ b/source/shared_lib/sources/platform/common/platform_common.cpp @@ -238,7 +238,7 @@ void findDirs(string path, vector &results, bool errorOnNotFound,bool ke string searchpath = currentPath + "*."; vector 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 &paths, vector &results, bool errorOn string path = currentPath + "*."; vector 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 &paths, const string &fileFilter, vector 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 &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); } diff --git a/source/shared_lib/sources/platform/posix/socket.cpp b/source/shared_lib/sources/platform/posix/socket.cpp index 67dd4f24..d49886f6 100644 --- a/source/shared_lib/sources/platform/posix/socket.cpp +++ b/source/shared_lib/sources/platform/posix/socket.cpp @@ -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 &socketTriggeredList) PLATFORM_SOCKET imaxsocket = 0; for(std::map::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 &socketTriggeredList) bResult = true; for(std::map::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 ipList = Socket::getLocalIPAddressList(); diff --git a/source/shared_lib/sources/platform/sdl/window.cpp b/source/shared_lib/sources/platform/sdl/window.cpp index 4babb662..fe2d7773 100644 --- a/source/shared_lib/sources/platform/sdl/window.cpp +++ b/source/shared_lib/sources/platform/sdl/window.cpp @@ -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; diff --git a/source/shared_lib/sources/platform/win32/gl_wrap_billy.cpp b/source/shared_lib/sources/platform/win32/gl_wrap_billy.cpp index 8ad5d06c..e4d47d47 100644 --- a/source/shared_lib/sources/platform/win32/gl_wrap_billy.cpp +++ b/source/shared_lib/sources/platform/win32/gl_wrap_billy.cpp @@ -52,7 +52,7 @@ void createGlFontBitmaps(uint32 &base, const string &type, int size, int width, DWORD dwErrorGL = 0; HDC hDC = 0; static std::vector systemFontList; - if(systemFontList.size() == 0) { + if(systemFontList.empty() == true) { LOGFONT lf; //POSITION pos; //lf.lfCharSet = ANSI_CHARSET; diff --git a/source/shared_lib/sources/util/checksum.cpp b/source/shared_lib/sources/util/checksum.cpp index 2345fbde..8d20dd9e 100644 --- a/source/shared_lib/sources/util/checksum.cpp +++ b/source/shared_lib/sources/util/checksum.cpp @@ -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::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()) { diff --git a/source/shared_lib/sources/util/properties.cpp b/source/shared_lib/sources/util/properties.cpp index 1a4ca27a..dbe106a4 100644 --- a/source/shared_lib/sources/util/properties.cpp +++ b/source/shared_lib/sources/util/properties.cpp @@ -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; diff --git a/source/shared_lib/sources/util/util.cpp b/source/shared_lib/sources/util/util.cpp index cdbf47cd..ec11afee 100644 --- a/source/shared_lib/sources/util/util.cpp +++ b/source/shared_lib/sources/util/util.cpp @@ -337,7 +337,7 @@ void SystemFlags::Close() { } for(std::map::iterator iterMap = SystemFlags::debugLogFileList->begin(); - iterMap != SystemFlags::debugLogFileList->end(); iterMap++) { + iterMap != SystemFlags::debugLogFileList->end(); ++iterMap) { SystemFlags::SystemFlagsType ¤tDebugLog = 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::iterator iterMap = SystemFlags::debugLogFileList->begin(); - iterMap != SystemFlags::debugLogFileList->end(); iterMap++) { + iterMap != SystemFlags::debugLogFileList->end(); ++iterMap) { SystemFlags::SystemFlagsType ¤tDebugLog2 = 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 + "]"; diff --git a/source/shared_lib/sources/xml/xml_parser.cpp b/source/shared_lib/sources/xml/xml_parser.cpp index adfaea0a..028d9f09 100644 --- a/source/shared_lib/sources/xml/xml_parser.cpp +++ b/source/shared_lib/sources/xml/xml_parser.cpp @@ -187,7 +187,7 @@ void XmlTree::load(const string &path, std::map mapTagReplacement Mutex &mutex = CacheManager::getMutexForItem(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;