- phase 2 of cppcheck verbose fixes
This commit is contained in:
parent
29b610344d
commit
57afc2d715
|
@ -320,7 +320,7 @@ public:
|
||||||
int line=-1;
|
int line=-1;
|
||||||
const int maxbufSize = 1024;
|
const int maxbufSize = 1024;
|
||||||
static char buf[maxbufSize+1]="";
|
static char buf[maxbufSize+1]="";
|
||||||
char *p=NULL;
|
//char *p=NULL;
|
||||||
|
|
||||||
// prepare command to be executed
|
// prepare command to be executed
|
||||||
// our program need to be passed after the -e parameter
|
// our program need to be passed after the -e parameter
|
||||||
|
|
|
@ -106,7 +106,7 @@ void MenuStateGraphicInfo::keyDown(SDL_KeyboardEvent key) {
|
||||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||||
//if(key == configKeys.getCharKey("SaveGUILayout")) {
|
//if(key == configKeys.getCharKey("SaveGUILayout")) {
|
||||||
if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),key) == true) {
|
if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),key) == true) {
|
||||||
bool saved = GraphicComponent::saveAllCustomProperties(containerName);
|
GraphicComponent::saveAllCustomProperties(containerName);
|
||||||
//Lang &lang= Lang::getInstance();
|
//Lang &lang= Lang::getInstance();
|
||||||
//console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
|
//console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,7 +173,7 @@ void MenuStateJoinGame::DiscoveredServers(std::vector<string> serverList) {
|
||||||
autoConnectToServer = false;
|
autoConnectToServer = false;
|
||||||
buttonAutoFindServers.setEnabled(true);
|
buttonAutoFindServers.setEnabled(true);
|
||||||
buttonConnect.setEnabled(true);
|
buttonConnect.setEnabled(true);
|
||||||
if(serverList.size() > 0) {
|
if(serverList.empty() == false) {
|
||||||
string bestIPMatch = "";
|
string bestIPMatch = "";
|
||||||
std::vector<std::string> localIPList = Socket::getLocalIPAddressList();
|
std::vector<std::string> localIPList = Socket::getLocalIPAddressList();
|
||||||
|
|
||||||
|
@ -513,7 +513,7 @@ void MenuStateJoinGame::keyPress(SDL_KeyboardEvent c) {
|
||||||
if(clientInterface->isConnected() == false) {
|
if(clientInterface->isConnected() == false) {
|
||||||
int maxTextSize= 16;
|
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);
|
SDLKey key = extractKeyPressed(c);
|
||||||
|
|
||||||
|
|
|
@ -231,7 +231,7 @@ void MenuStateKeysetup::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
soundRenderer.playFx(coreData.getClickSoundB());
|
soundRenderer.playFx(coreData.getClickSoundB());
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
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));
|
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||||
string userKeysFile = configKeys.getFileName(true);
|
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());
|
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());
|
||||||
|
|
|
@ -827,7 +827,7 @@ void MenuStateMasterserver::simpleTask(BaseThread *callingThread) {
|
||||||
announcementLoaded=true;
|
announcementLoaded=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Lang &lang= Lang::getInstance();
|
//Lang &lang= Lang::getInstance();
|
||||||
try {
|
try {
|
||||||
if(Config::getInstance().getString("Masterserver","") != "") {
|
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());
|
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();
|
ClientInterface* clientInterface= NetworkManager::getInstance().getClientInterface();
|
||||||
Config& config= Config::getInstance();
|
//Config& config= Config::getInstance();
|
||||||
Ip serverIp(ipString);
|
Ip serverIp(ipString);
|
||||||
|
|
||||||
//int serverPort = Config::getInstance().getInt("ServerPort",intToStr(GameConstants::serverPort).c_str());
|
//int serverPort = Config::getInstance().getInt("ServerPort",intToStr(GameConstants::serverPort).c_str());
|
||||||
|
|
|
@ -82,6 +82,7 @@ MenuStateMods::MenuStateMods(Program *program, MainMenu *mainMenu) :
|
||||||
keyButtonsYBase = scrollListsYPos;
|
keyButtonsYBase = scrollListsYPos;
|
||||||
keyButtonsToRender = listBoxLength / keyButtonsLineHeight;
|
keyButtonsToRender = listBoxLength / keyButtonsLineHeight;
|
||||||
labelWidth = 5;
|
labelWidth = 5;
|
||||||
|
keyButtonsXBase = 0;
|
||||||
|
|
||||||
int installButtonYPos = scrollListsYPos-listBoxLength-20;
|
int installButtonYPos = scrollListsYPos-listBoxLength-20;
|
||||||
|
|
||||||
|
@ -245,7 +246,7 @@ MenuStateMods::MenuStateMods(Program *program, MainMenu *mainMenu) :
|
||||||
|
|
||||||
vector<string> mapPathList = config.getPathListForType(ptMaps);
|
vector<string> mapPathList = config.getPathListForType(ptMaps);
|
||||||
std::pair<string,string> mapsPath;
|
std::pair<string,string> mapsPath;
|
||||||
if(mapPathList.size() > 0) {
|
if(mapPathList.empty() == false) {
|
||||||
mapsPath.first = mapPathList[0];
|
mapsPath.first = mapPathList[0];
|
||||||
}
|
}
|
||||||
if(mapPathList.size() > 1) {
|
if(mapPathList.size() > 1) {
|
||||||
|
@ -253,7 +254,7 @@ MenuStateMods::MenuStateMods(Program *program, MainMenu *mainMenu) :
|
||||||
}
|
}
|
||||||
std::pair<string,string> tilesetsPath;
|
std::pair<string,string> tilesetsPath;
|
||||||
vector<string> tilesetsList = Config::getInstance().getPathListForType(ptTilesets);
|
vector<string> tilesetsList = Config::getInstance().getPathListForType(ptTilesets);
|
||||||
if(tilesetsList.size() > 0) {
|
if(tilesetsList.empty() == false) {
|
||||||
tilesetsPath.first = tilesetsList[0];
|
tilesetsPath.first = tilesetsList[0];
|
||||||
if(tilesetsList.size() > 1) {
|
if(tilesetsList.size() > 1) {
|
||||||
tilesetsPath.second = tilesetsList[1];
|
tilesetsPath.second = tilesetsList[1];
|
||||||
|
@ -262,7 +263,7 @@ MenuStateMods::MenuStateMods(Program *program, MainMenu *mainMenu) :
|
||||||
|
|
||||||
std::pair<string,string> techtreesPath;
|
std::pair<string,string> techtreesPath;
|
||||||
vector<string> techtreesList = Config::getInstance().getPathListForType(ptTechs);
|
vector<string> techtreesList = Config::getInstance().getPathListForType(ptTechs);
|
||||||
if(techtreesList.size() > 0) {
|
if(techtreesList.empty() == false) {
|
||||||
techtreesPath.first = techtreesList[0];
|
techtreesPath.first = techtreesList[0];
|
||||||
if(techtreesList.size() > 1) {
|
if(techtreesList.size() > 1) {
|
||||||
techtreesPath.second = techtreesList[1];
|
techtreesPath.second = techtreesList[1];
|
||||||
|
@ -271,7 +272,7 @@ MenuStateMods::MenuStateMods(Program *program, MainMenu *mainMenu) :
|
||||||
|
|
||||||
std::pair<string,string> scenariosPath;
|
std::pair<string,string> scenariosPath;
|
||||||
vector<string> scenariosList = Config::getInstance().getPathListForType(ptScenarios);
|
vector<string> scenariosList = Config::getInstance().getPathListForType(ptScenarios);
|
||||||
if(scenariosList.size() > 0) {
|
if(scenariosList.empty() == false) {
|
||||||
scenariosPath.first = scenariosList[0];
|
scenariosPath.first = scenariosList[0];
|
||||||
if(scenariosList.size() > 1) {
|
if(scenariosList.size() > 1) {
|
||||||
scenariosPath.second = scenariosList[1];
|
scenariosPath.second = scenariosList[1];
|
||||||
|
@ -995,7 +996,7 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||||
|
|
||||||
soundRenderer.playFx(coreData.getClickSoundA());
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
|
|
||||||
if(fileFTPProgressList.size() > 0) {
|
if(fileFTPProgressList.empty() == false) {
|
||||||
mainMessageBoxState = ftpmsg_Quit;
|
mainMessageBoxState = ftpmsg_Quit;
|
||||||
mainMessageBox.init(lang.get("Yes"),lang.get("No"));
|
mainMessageBox.init(lang.get("Yes"),lang.get("No"));
|
||||||
char szBuf[1024]="";
|
char szBuf[1024]="";
|
||||||
|
@ -1431,7 +1432,7 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||||
ModInfo &modInfo = mapCacheList[selectedMapName];
|
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());
|
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;
|
Checksum checksum;
|
||||||
string file = Map::getMapPath(selectedMapName,"",false);
|
string file = Map::getMapPath(selectedMapName,"",false);
|
||||||
checksum.addFile(file);
|
checksum.addFile(file);
|
||||||
|
@ -1974,7 +1975,7 @@ void MenuStateMods::render() {
|
||||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),mutexOwnerId);
|
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),mutexOwnerId);
|
||||||
if(ftpClientThread != NULL && ftpClientThread->getProgressMutex() != NULL) ftpClientThread->getProgressMutex()->setOwnerId(mutexOwnerId);
|
if(ftpClientThread != NULL && ftpClientThread->getProgressMutex() != NULL) ftpClientThread->getProgressMutex()->setOwnerId(mutexOwnerId);
|
||||||
if(fileFTPProgressList.size() > 0) {
|
if(fileFTPProgressList.empty() == false) {
|
||||||
Lang &lang= Lang::getInstance();
|
Lang &lang= Lang::getInstance();
|
||||||
int xLocation = buttonReturn.getX();
|
int xLocation = buttonReturn.getX();
|
||||||
int yLocation = buttonReturn.getY() - 12;
|
int yLocation = buttonReturn.getY() - 12;
|
||||||
|
@ -2028,7 +2029,7 @@ void MenuStateMods::update() {
|
||||||
Chrono chrono;
|
Chrono chrono;
|
||||||
chrono.start();
|
chrono.start();
|
||||||
|
|
||||||
Lang &lang= Lang::getInstance();
|
//Lang &lang= Lang::getInstance();
|
||||||
|
|
||||||
// Tech List
|
// Tech List
|
||||||
if (keyTechScrollBar.getElementCount() != 0) {
|
if (keyTechScrollBar.getElementCount() != 0) {
|
||||||
|
|
|
@ -137,7 +137,7 @@ void MenuStateNewGame::keyDown(SDL_KeyboardEvent key) {
|
||||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||||
//if(key == configKeys.getCharKey("SaveGUILayout")) {
|
//if(key == configKeys.getCharKey("SaveGUILayout")) {
|
||||||
if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),key) == true) {
|
if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),key) == true) {
|
||||||
bool saved = GraphicComponent::saveAllCustomProperties(containerName);
|
GraphicComponent::saveAllCustomProperties(containerName);
|
||||||
//Lang &lang= Lang::getInstance();
|
//Lang &lang= Lang::getInstance();
|
||||||
//console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
|
//console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
|
||||||
}
|
}
|
||||||
|
|
|
@ -715,7 +715,6 @@ void MenuStateOptions::keyDown(SDL_KeyboardEvent key) {
|
||||||
void MenuStateOptions::keyPress(SDL_KeyboardEvent c) {
|
void MenuStateOptions::keyPress(SDL_KeyboardEvent c) {
|
||||||
if(activeInputLabel!=NULL) {
|
if(activeInputLabel!=NULL) {
|
||||||
//printf("[%d]\n",c); fflush(stdout);
|
//printf("[%d]\n",c); fflush(stdout);
|
||||||
int maxTextSize= 16;
|
|
||||||
if(&labelPlayerName==activeInputLabel) {
|
if(&labelPlayerName==activeInputLabel) {
|
||||||
SDLKey key = extractKeyPressed(c);
|
SDLKey key = extractKeyPressed(c);
|
||||||
//if((c>='0' && c<='9')||(c>='a' && c<='z')||(c>='A' && c<='Z')||
|
//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 ?)
|
// (use Shared::Platform::charSet in shared_lib/include/platform/sdl/gl_wrap.h ?)
|
||||||
//(c=='-')||(c=='(')||(c==')')){
|
//(c=='-')||(c=='(')||(c==')')){
|
||||||
if(isAllowedInputTextKey(key)) {
|
if(isAllowedInputTextKey(key)) {
|
||||||
|
const int maxTextSize= 16;
|
||||||
if(activeInputLabel->getText().size()<maxTextSize){
|
if(activeInputLabel->getText().size()<maxTextSize){
|
||||||
string text= activeInputLabel->getText();
|
string text= activeInputLabel->getText();
|
||||||
//text.insert(text.end()-1, key);
|
//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));
|
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||||
//if(c == configKeys.getCharKey("SaveGUILayout")) {
|
//if(c == configKeys.getCharKey("SaveGUILayout")) {
|
||||||
if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),c) == true) {
|
if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),c) == true) {
|
||||||
bool saved = GraphicComponent::saveAllCustomProperties(containerName);
|
GraphicComponent::saveAllCustomProperties(containerName);
|
||||||
//Lang &lang= Lang::getInstance();
|
//Lang &lang= Lang::getInstance();
|
||||||
//console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
|
//console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
|
||||||
}
|
}
|
||||||
|
@ -914,7 +914,7 @@ void MenuStateOptions::saveConfig(){
|
||||||
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
||||||
soundRenderer.stopAllSounds();
|
soundRenderer.stopAllSounds();
|
||||||
program->stopSoundSystem();
|
program->stopSoundSystem();
|
||||||
bool initOk = soundRenderer.init(program->getWindow());
|
soundRenderer.init(program->getWindow());
|
||||||
soundRenderer.loadConfig();
|
soundRenderer.loadConfig();
|
||||||
soundRenderer.setMusicVolume(CoreData::getInstance().getMenuMusic());
|
soundRenderer.setMusicVolume(CoreData::getInstance().getMenuMusic());
|
||||||
program->startSoundSystem();
|
program->startSoundSystem();
|
||||||
|
|
|
@ -240,7 +240,7 @@ void MenuStateRoot::keyDown(SDL_KeyboardEvent key) {
|
||||||
}
|
}
|
||||||
//else if(key == configKeys.getCharKey("SaveGUILayout")) {
|
//else if(key == configKeys.getCharKey("SaveGUILayout")) {
|
||||||
else if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),key) == true) {
|
else if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),key) == true) {
|
||||||
bool saved = GraphicComponent::saveAllCustomProperties(containerName);
|
GraphicComponent::saveAllCustomProperties(containerName);
|
||||||
//Lang &lang= Lang::getInstance();
|
//Lang &lang= Lang::getInstance();
|
||||||
//console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
|
//console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ MenuStateScenario::MenuStateScenario(Program *program, MainMenu *mainMenu, const
|
||||||
//scenario listbox
|
//scenario listbox
|
||||||
findDirs(dirList, results);
|
findDirs(dirList, results);
|
||||||
scenarioFiles = results;
|
scenarioFiles = results;
|
||||||
if(results.size() == 0) {
|
if(results.empty() == true) {
|
||||||
throw runtime_error("There are no scenarios found to load");
|
throw runtime_error("There are no scenarios found to load");
|
||||||
}
|
}
|
||||||
for(int i= 0; i<results.size(); ++i){
|
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));
|
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||||
//if(key == configKeys.getCharKey("SaveGUILayout")) {
|
//if(key == configKeys.getCharKey("SaveGUILayout")) {
|
||||||
if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),key) == true) {
|
if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),key) == true) {
|
||||||
bool saved = GraphicComponent::saveAllCustomProperties(containerName);
|
GraphicComponent::saveAllCustomProperties(containerName);
|
||||||
//Lang &lang= Lang::getInstance();
|
//Lang &lang= Lang::getInstance();
|
||||||
//console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
|
//console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,7 +157,7 @@ void ClientInterface::update() {
|
||||||
// Possible cause of out of synch since we have more commands that need
|
// Possible cause of out of synch since we have more commands that need
|
||||||
// to be sent in this frame
|
// to be sent in this frame
|
||||||
if(requestedCommands.empty() == false) {
|
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());
|
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());
|
string sMsg = "may go out of synch: client requestedCommands.size() = " + intToStr(requestedCommands.size());
|
||||||
|
|
|
@ -150,7 +150,7 @@ void ConnectionSlotThread::execute() {
|
||||||
//setRunningStatus(true);
|
//setRunningStatus(true);
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
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;) {
|
for(;this->slotInterface != NULL;) {
|
||||||
if(getQuitStatus() == true) {
|
if(getQuitStatus() == true) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
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->currentLagCount = 0;
|
||||||
this->gotLagCountWarning = false;
|
this->gotLagCountWarning = false;
|
||||||
this->lastReceiveCommandListTime = 0;
|
this->lastReceiveCommandListTime = 0;
|
||||||
|
this->receivedNetworkGameStatus = false;
|
||||||
|
|
||||||
this->socket = NULL;
|
this->socket = NULL;
|
||||||
this->slotThreadWorker = NULL;
|
this->slotThreadWorker = NULL;
|
||||||
this->slotThreadWorker = new ConnectionSlotThread(this->serverInterface,playerIndex);
|
this->slotThreadWorker = new ConnectionSlotThread(this->serverInterface,playerIndex);
|
||||||
|
@ -879,7 +881,7 @@ vector<NetworkCommand> ConnectionSlot::getPendingNetworkCommandList(bool clearLi
|
||||||
vector<NetworkCommand> ret;
|
vector<NetworkCommand> ret;
|
||||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||||
MutexSafeWrapper safeMutexSlot(&mutexPendingNetworkCommandList,mutexOwnerId);
|
MutexSafeWrapper safeMutexSlot(&mutexPendingNetworkCommandList,mutexOwnerId);
|
||||||
if(vctPendingNetworkCommandList.size() > 0) {
|
if(vctPendingNetworkCommandList.empty() == false) {
|
||||||
ret = vctPendingNetworkCommandList;
|
ret = vctPendingNetworkCommandList;
|
||||||
if(clearList == true) {
|
if(clearList == true) {
|
||||||
vctPendingNetworkCommandList.clear();
|
vctPendingNetworkCommandList.clear();
|
||||||
|
@ -893,7 +895,7 @@ vector<NetworkCommand> ConnectionSlot::getPendingNetworkCommandList(bool clearLi
|
||||||
void ConnectionSlot::clearPendingNetworkCommandList() {
|
void ConnectionSlot::clearPendingNetworkCommandList() {
|
||||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||||
MutexSafeWrapper safeMutexSlot(&mutexPendingNetworkCommandList,mutexOwnerId);
|
MutexSafeWrapper safeMutexSlot(&mutexPendingNetworkCommandList,mutexOwnerId);
|
||||||
if(vctPendingNetworkCommandList.size() > 0) {
|
if(vctPendingNetworkCommandList.empty() == false) {
|
||||||
vctPendingNetworkCommandList.clear();
|
vctPendingNetworkCommandList.clear();
|
||||||
}
|
}
|
||||||
safeMutexSlot.ReleaseLock();
|
safeMutexSlot.ReleaseLock();
|
||||||
|
|
|
@ -133,7 +133,7 @@ public:
|
||||||
|
|
||||||
void update(bool checkForNewClients,int lockedSlotIndex);
|
void update(bool checkForNewClients,int lockedSlotIndex);
|
||||||
void setPlayerIndex(int value) { playerIndex = value; }
|
void setPlayerIndex(int value) { playerIndex = value; }
|
||||||
int getPlayerIndex() {return playerIndex;}
|
int getPlayerIndex() const {return playerIndex;}
|
||||||
|
|
||||||
uint32 getConnectedRemoteIPAddress() const { return connectedRemoteIPAddress; }
|
uint32 getConnectedRemoteIPAddress() const { return connectedRemoteIPAddress; }
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ public:
|
||||||
virtual void close();
|
virtual void close();
|
||||||
//virtual bool getFogOfWar();
|
//virtual bool getFogOfWar();
|
||||||
|
|
||||||
bool getReceivedNetworkGameStatus() { return receivedNetworkGameStatus; }
|
bool getReceivedNetworkGameStatus() const { return receivedNetworkGameStatus; }
|
||||||
void setReceivedNetworkGameStatus(bool value) { receivedNetworkGameStatus = value; }
|
void setReceivedNetworkGameStatus(bool value) { receivedNetworkGameStatus = value; }
|
||||||
|
|
||||||
bool hasValidSocketId();
|
bool hasValidSocketId();
|
||||||
|
|
|
@ -110,7 +110,7 @@ void NetworkInterface::DisplayErrorMessage(string sErr, bool closeSocket) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkInterface::clearChatInfo() {
|
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());
|
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();
|
chatTextList.clear();
|
||||||
}
|
}
|
||||||
|
@ -296,7 +296,7 @@ void FileTransferSocketThread::execute()
|
||||||
outFile.write(data, 512);
|
outFile.write(data, 512);
|
||||||
if(outFile.bad())
|
if(outFile.bad())
|
||||||
{
|
{
|
||||||
int ii = 0;
|
//int ii = 0;
|
||||||
}
|
}
|
||||||
//if(!WriteFile(file,data,512,&written,NULL))
|
//if(!WriteFile(file,data,512,&written,NULL))
|
||||||
// ; //write error
|
// ; //write error
|
||||||
|
@ -310,7 +310,7 @@ void FileTransferSocketThread::execute()
|
||||||
outFile.write(data, remain);
|
outFile.write(data, remain);
|
||||||
if(outFile.bad())
|
if(outFile.bad())
|
||||||
{
|
{
|
||||||
int ii = 0;
|
//int ii = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if(!WriteFile(file,data,remain,&written,NULL))
|
//if(!WriteFile(file,data,remain,&written,NULL))
|
||||||
|
@ -325,7 +325,7 @@ void FileTransferSocketThread::execute()
|
||||||
int32 crc = checksum.getSum();
|
int32 crc = checksum.getSum();
|
||||||
if(file.filecrc != crc)
|
if(file.filecrc != crc)
|
||||||
{
|
{
|
||||||
int ii = 0;
|
//int ii = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if(calc_crc(file)!=info.crc)
|
//if(calc_crc(file)!=info.crc)
|
||||||
|
|
|
@ -236,6 +236,11 @@ private:
|
||||||
public:
|
public:
|
||||||
FileTransferInfo()
|
FileTransferInfo()
|
||||||
{
|
{
|
||||||
|
hostType = eClient;
|
||||||
|
serverIP = "";
|
||||||
|
serverPort = 0;
|
||||||
|
opType = eSend;
|
||||||
|
fileName = "";
|
||||||
}
|
}
|
||||||
FileTransferInfo(const FileTransferInfo &obj)
|
FileTransferInfo(const FileTransferInfo &obj)
|
||||||
{
|
{
|
||||||
|
|
|
@ -45,7 +45,7 @@ public:
|
||||||
GameNetworkInterface* getGameNetworkInterface(bool throwErrorOnNull=true);
|
GameNetworkInterface* getGameNetworkInterface(bool throwErrorOnNull=true);
|
||||||
ServerInterface* getServerInterface(bool throwErrorOnNull=true);
|
ServerInterface* getServerInterface(bool throwErrorOnNull=true);
|
||||||
ClientInterface* getClientInterface(bool throwErrorOnNull=true);
|
ClientInterface* getClientInterface(bool throwErrorOnNull=true);
|
||||||
NetworkRole getNetworkRole() { return networkRole; }
|
NetworkRole getNetworkRole() const { return networkRole; }
|
||||||
};
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
|
|
@ -635,7 +635,7 @@ public:
|
||||||
void addSwitchFlag(SwitchSetupRequestFlagType flag) { data.switchFlags |= flag;}
|
void addSwitchFlag(SwitchSetupRequestFlagType flag) { data.switchFlags |= flag;}
|
||||||
void clearSwitchFlag(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(); }
|
string getNetworkPlayerLanguage() const { return data.language.getString(); }
|
||||||
|
|
||||||
virtual bool receive(Socket* socket);
|
virtual bool receive(Socket* socket);
|
||||||
|
|
|
@ -43,10 +43,12 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NetworkString() {memset(buffer, 0, S);}
|
NetworkString() {memset(buffer, 0, S);}
|
||||||
void operator=(const string& str) {
|
NetworkString & operator=(const string& str) {
|
||||||
// ensure we don't have a buffer overflow
|
// ensure we don't have a buffer overflow
|
||||||
int maxBufferSize = sizeof(buffer) / sizeof(buffer[0]);
|
int maxBufferSize = sizeof(buffer) / sizeof(buffer[0]);
|
||||||
strncpy(buffer, str.c_str(), min(S-1,maxBufferSize-1));
|
strncpy(buffer, str.c_str(), min(S-1,maxBufferSize-1));
|
||||||
|
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
void nullTerminate() {
|
void nullTerminate() {
|
||||||
int maxBufferSize = sizeof(buffer) / sizeof(buffer[0]);
|
int maxBufferSize = sizeof(buffer) / sizeof(buffer[0]);
|
||||||
|
|
|
@ -80,7 +80,7 @@ ServerInterface::ServerInterface(bool publishEnabled) :GameNetworkInterface() {
|
||||||
if(Config::getInstance().getBool("EnableFTPServer","true") == true) {
|
if(Config::getInstance().getBool("EnableFTPServer","true") == true) {
|
||||||
std::pair<string,string> mapsPath;
|
std::pair<string,string> mapsPath;
|
||||||
vector<string> pathList = Config::getInstance().getPathListForType(ptMaps);
|
vector<string> pathList = Config::getInstance().getPathListForType(ptMaps);
|
||||||
if(pathList.size() > 0) {
|
if(pathList.empty() == false) {
|
||||||
mapsPath.first = pathList[0];
|
mapsPath.first = pathList[0];
|
||||||
if(pathList.size() > 1) {
|
if(pathList.size() > 1) {
|
||||||
mapsPath.second = pathList[1];
|
mapsPath.second = pathList[1];
|
||||||
|
@ -89,7 +89,7 @@ ServerInterface::ServerInterface(bool publishEnabled) :GameNetworkInterface() {
|
||||||
|
|
||||||
std::pair<string,string> tilesetsPath;
|
std::pair<string,string> tilesetsPath;
|
||||||
vector<string> tilesetsList = Config::getInstance().getPathListForType(ptTilesets);
|
vector<string> tilesetsList = Config::getInstance().getPathListForType(ptTilesets);
|
||||||
if(tilesetsList.size() > 0) {
|
if(tilesetsList.empty() == false) {
|
||||||
tilesetsPath.first = tilesetsList[0];
|
tilesetsPath.first = tilesetsList[0];
|
||||||
if(tilesetsList.size() > 1) {
|
if(tilesetsList.size() > 1) {
|
||||||
tilesetsPath.second = tilesetsList[1];
|
tilesetsPath.second = tilesetsList[1];
|
||||||
|
@ -98,7 +98,7 @@ ServerInterface::ServerInterface(bool publishEnabled) :GameNetworkInterface() {
|
||||||
|
|
||||||
std::pair<string,string> techtreesPath;
|
std::pair<string,string> techtreesPath;
|
||||||
vector<string> techtreesList = Config::getInstance().getPathListForType(ptTechs);
|
vector<string> techtreesList = Config::getInstance().getPathListForType(ptTechs);
|
||||||
if(techtreesList.size() > 0) {
|
if(techtreesList.empty() == false) {
|
||||||
techtreesPath.first = techtreesList[0];
|
techtreesPath.first = techtreesList[0];
|
||||||
if(techtreesList.size() > 1) {
|
if(techtreesList.size() > 1) {
|
||||||
techtreesPath.second = techtreesList[1];
|
techtreesPath.second = techtreesList[1];
|
||||||
|
@ -619,7 +619,7 @@ void ServerInterface::validateConnectedClients() {
|
||||||
void ServerInterface::signalClientsToRecieveData(std::map<PLATFORM_SOCKET,bool> &socketTriggeredList,
|
void ServerInterface::signalClientsToRecieveData(std::map<PLATFORM_SOCKET,bool> &socketTriggeredList,
|
||||||
std::map<int,ConnectionSlotEvent> &eventList,
|
std::map<int,ConnectionSlotEvent> &eventList,
|
||||||
std::map<int,bool> & mapSlotSignalledList) {
|
std::map<int,bool> & mapSlotSignalledList) {
|
||||||
bool checkForNewClients = true;
|
//bool checkForNewClients = true;
|
||||||
for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) {
|
for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) {
|
||||||
MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(i));
|
MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(i));
|
||||||
ConnectionSlot* connectionSlot = slots[i];
|
ConnectionSlot* connectionSlot = slots[i];
|
||||||
|
@ -651,7 +651,7 @@ void ServerInterface::checkForCompletedClients(std::map<int,bool> & mapSlotSigna
|
||||||
try {
|
try {
|
||||||
std::vector<std::string> errorList = connectionSlot->getThreadErrorList();
|
std::vector<std::string> errorList = connectionSlot->getThreadErrorList();
|
||||||
// Collect any collected errors from threads
|
// Collect any collected errors from threads
|
||||||
if(errorList.size() > 0) {
|
if(errorList.empty() == false) {
|
||||||
for(int iErrIdx = 0; iErrIdx < errorList.size(); ++iErrIdx) {
|
for(int iErrIdx = 0; iErrIdx < errorList.size(); ++iErrIdx) {
|
||||||
string &sErr = errorList[iErrIdx];
|
string &sErr = errorList[iErrIdx];
|
||||||
if(sErr != "") {
|
if(sErr != "") {
|
||||||
|
@ -703,7 +703,7 @@ void ServerInterface::checForLaggingClients(std::map<int,bool> &mapSlotSignalled
|
||||||
try {
|
try {
|
||||||
std::vector<std::string> errorList = connectionSlot->getThreadErrorList();
|
std::vector<std::string> errorList = connectionSlot->getThreadErrorList();
|
||||||
// Show any collected errors from threads
|
// Show any collected errors from threads
|
||||||
if(errorList.size() > 0) {
|
if(errorList.empty() == false) {
|
||||||
for(int iErrIdx = 0; iErrIdx < errorList.size(); ++iErrIdx) {
|
for(int iErrIdx = 0; iErrIdx < errorList.size(); ++iErrIdx) {
|
||||||
string &sErr = errorList[iErrIdx];
|
string &sErr = errorList[iErrIdx];
|
||||||
if(sErr != "") {
|
if(sErr != "") {
|
||||||
|
@ -812,7 +812,7 @@ void ServerInterface::executeNetworkCommandsFromClients() {
|
||||||
ConnectionSlot* connectionSlot= slots[i];
|
ConnectionSlot* connectionSlot= slots[i];
|
||||||
if(connectionSlot != NULL && connectionSlot->isConnected() == true) {
|
if(connectionSlot != NULL && connectionSlot->isConnected() == true) {
|
||||||
vector<NetworkCommand> pendingList = connectionSlot->getPendingNetworkCommandList(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) {
|
for(int idx = 0; exitServer == false && idx < pendingList.size(); ++idx) {
|
||||||
NetworkCommand &cmd = pendingList[idx];
|
NetworkCommand &cmd = pendingList[idx];
|
||||||
this->requestCommand(&cmd);
|
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(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");
|
//printf("\nServerInterface::update -- E\n");
|
||||||
|
|
||||||
std::map<int,ConnectionSlotEvent> eventList;
|
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());
|
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());
|
errorMsgList.push_back(ex.what());
|
||||||
}
|
}
|
||||||
if(errorMsgList.size() > 0){
|
if(errorMsgList.empty() == false){
|
||||||
for(int iErrIdx = 0;iErrIdx < errorMsgList.size();++iErrIdx){
|
for(int iErrIdx = 0;iErrIdx < errorMsgList.size();++iErrIdx){
|
||||||
string & sErr = errorMsgList[iErrIdx];
|
string & sErr = errorMsgList[iErrIdx];
|
||||||
if(sErr != ""){
|
if(sErr != ""){
|
||||||
|
@ -1007,7 +1007,7 @@ void ServerInterface::updateKeyframe(int frameCount) {
|
||||||
// Possible cause of out of synch since we have more commands that need
|
// Possible cause of out of synch since we have more commands that need
|
||||||
// to be sent in this frame
|
// to be sent in this frame
|
||||||
if(requestedCommands.empty() == false) {
|
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());
|
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());
|
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() {
|
void ServerInterface::processBroadCastMessageQueue() {
|
||||||
MutexSafeWrapper safeMutexSlot(&broadcastMessageQueueThreadAccessor,string(__FILE__) + "_" + intToStr(__LINE__));
|
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());
|
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) {
|
for(int i = 0; i < broadcastMessageQueue.size(); ++i) {
|
||||||
pair<const NetworkMessage *,int> &item = broadcastMessageQueue[i];
|
pair<const NetworkMessage *,int> &item = broadcastMessageQueue[i];
|
||||||
|
@ -1361,7 +1361,7 @@ void ServerInterface::queueBroadcastMessage(const NetworkMessage *networkMessage
|
||||||
|
|
||||||
void ServerInterface::processTextMessageQueue() {
|
void ServerInterface::processTextMessageQueue() {
|
||||||
MutexSafeWrapper safeMutexSlot(&textMessageQueueThreadAccessor,string(__FILE__) + "_" + intToStr(__LINE__));
|
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());
|
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) {
|
for(int i = 0; i < textMessageQueue.size(); ++i) {
|
||||||
TextMessageQueue &item = textMessageQueue[i];
|
TextMessageQueue &item = textMessageQueue[i];
|
||||||
|
|
|
@ -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::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);
|
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;) {
|
for(;this->faction != NULL;) {
|
||||||
if(getQuitStatus() == true) {
|
if(getQuitStatus() == true) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
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;
|
cachingDisabled=false;
|
||||||
factionDisconnectHandled=false;
|
factionDisconnectHandled=false;
|
||||||
workerThread = NULL;
|
workerThread = NULL;
|
||||||
|
|
||||||
|
world=NULL;
|
||||||
|
scriptManager=NULL;
|
||||||
|
factionType=NULL;
|
||||||
|
index=0;
|
||||||
|
teamIndex=0;
|
||||||
|
startLocationIndex=0;
|
||||||
|
thisFaction=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Faction::~Faction() {
|
Faction::~Faction() {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
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__);
|
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
|
// 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();
|
for(std::map<const ResourceType *, std::pair<int, std::vector<Unit *> > >::iterator iter = resourceIntervalUsage.begin();
|
||||||
iter != resourceIntervalUsage.end();
|
iter != resourceIntervalUsage.end();
|
||||||
++iter) {
|
++iter) {
|
||||||
|
@ -837,7 +845,7 @@ bool Faction::isResourceTargetInCache(const Vec2i &pos, bool incrementUseCounter
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
if(cachingDisabled == false) {
|
if(cachingDisabled == false) {
|
||||||
if(cacheResourceTargetList.size() > 0) {
|
if(cacheResourceTargetList.empty() == false) {
|
||||||
std::map<Vec2i,int>::iterator iter = cacheResourceTargetList.find(pos);
|
std::map<Vec2i,int>::iterator iter = cacheResourceTargetList.find(pos);
|
||||||
|
|
||||||
result = (iter != cacheResourceTargetList.end());
|
result = (iter != cacheResourceTargetList.end());
|
||||||
|
@ -876,7 +884,7 @@ void Faction::addResourceTargetToCache(const Vec2i &pos,bool incrementUseCounter
|
||||||
|
|
||||||
void Faction::removeResourceTargetFromCache(const Vec2i &pos) {
|
void Faction::removeResourceTargetFromCache(const Vec2i &pos) {
|
||||||
if(cachingDisabled == false) {
|
if(cachingDisabled == false) {
|
||||||
if(cacheResourceTargetList.size() > 0) {
|
if(cacheResourceTargetList.empty() == false) {
|
||||||
std::map<Vec2i,int>::iterator iter = cacheResourceTargetList.find(pos);
|
std::map<Vec2i,int>::iterator iter = cacheResourceTargetList.find(pos);
|
||||||
|
|
||||||
if(iter != cacheResourceTargetList.end()) {
|
if(iter != cacheResourceTargetList.end()) {
|
||||||
|
@ -928,7 +936,7 @@ Vec2i Faction::getClosestResourceTypeTargetFromCache(Unit *unit, const ResourceT
|
||||||
Vec2i result(-1);
|
Vec2i result(-1);
|
||||||
|
|
||||||
if(cachingDisabled == false) {
|
if(cachingDisabled == false) {
|
||||||
if(cacheResourceTargetList.size() > 0) {
|
if(cacheResourceTargetList.empty() == false) {
|
||||||
std::vector<Vec2i> deleteList;
|
std::vector<Vec2i> deleteList;
|
||||||
|
|
||||||
const int harvestDistance = 5;
|
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) {
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) {
|
||||||
char szBuf[4096]="";
|
char szBuf[4096]="";
|
||||||
sprintf(szBuf,"[cleaning old resource targets] deleteList.size() [%ld] cacheResourceTargetList.size() [%ld] result [%s]",
|
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 Faction::getClosestResourceTypeTargetFromCache(const Vec2i &pos, const ResourceType *type) {
|
||||||
Vec2i result(-1);
|
Vec2i result(-1);
|
||||||
if(cachingDisabled == false) {
|
if(cachingDisabled == false) {
|
||||||
if(cacheResourceTargetList.size() > 0) {
|
if(cacheResourceTargetList.empty() == false) {
|
||||||
//std::vector<Vec2i> deleteList;
|
//std::vector<Vec2i> deleteList;
|
||||||
|
|
||||||
const int harvestDistance = 5;
|
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,"%s",szBuf);
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"------------------------------------ END [%d] -------------------------------------------------\n",getFrameCount());
|
//SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"------------------------------------ END [%d] -------------------------------------------------\n",getFrameCount());
|
||||||
|
|
||||||
//if(deleteList.size() > 0) {
|
//if(deleteList.empty() == false) {
|
||||||
// cleanupResourceTypeTargetCache(&deleteList);
|
// cleanupResourceTypeTargetCache(&deleteList);
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
@ -1158,7 +1166,7 @@ Vec2i Faction::getClosestResourceTypeTargetFromCache(const Vec2i &pos, const Res
|
||||||
|
|
||||||
void Faction::cleanupResourceTypeTargetCache(std::vector<Vec2i> *deleteListPtr) {
|
void Faction::cleanupResourceTypeTargetCache(std::vector<Vec2i> *deleteListPtr) {
|
||||||
if(cachingDisabled == false) {
|
if(cachingDisabled == false) {
|
||||||
if(cacheResourceTargetList.size() > 0) {
|
if(cacheResourceTargetList.empty() == false) {
|
||||||
const int cleanupInterval = (GameConstants::updateFps * 5);
|
const int cleanupInterval = (GameConstants::updateFps * 5);
|
||||||
bool needToCleanup = (getFrameCount() % cleanupInterval == 0);
|
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) {
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) {
|
||||||
char szBuf[4096]="";
|
char szBuf[4096]="";
|
||||||
sprintf(szBuf,"[cleaning old resource targets] deleteList.size() [%ld] cacheResourceTargetList.size() [%ld], needToCleanup [%d]",
|
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);
|
const CommandType *cmdType = curUnit->getType()->getFirstCtOfClass(cmdClass);
|
||||||
bool isUnitPossibleCandidate = (cmdType != NULL);
|
bool isUnitPossibleCandidate = (cmdType != NULL);
|
||||||
if(skillClassList.size() > 0) {
|
if(skillClassList.empty() == false) {
|
||||||
isUnitPossibleCandidate = false;
|
isUnitPossibleCandidate = false;
|
||||||
|
|
||||||
for(int j = 0; j < skillClassList.size(); ++j) {
|
for(int j = 0; j < skillClassList.size(); ++j) {
|
||||||
|
@ -1372,7 +1380,7 @@ Unit * Faction::findClosestUnitWithSkillClass( const Vec2i &pos,const CommandCla
|
||||||
isUnitPossibleCandidate = false;
|
isUnitPossibleCandidate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isUnitPossibleCandidate == true && skillClassList.size() > 0) {
|
if(isUnitPossibleCandidate == true && skillClassList.empty() == false) {
|
||||||
isUnitPossibleCandidate = false;
|
isUnitPossibleCandidate = false;
|
||||||
|
|
||||||
for(int j = 0; j < skillClassList.size(); ++j) {
|
for(int j = 0; j < skillClassList.size(); ++j) {
|
||||||
|
|
|
@ -73,7 +73,7 @@ public:
|
||||||
Vec3f getPos() const {return pos;}
|
Vec3f getPos() const {return pos;}
|
||||||
bool isVisible() const {return visible;}
|
bool isVisible() const {return visible;}
|
||||||
const Vec3f & getConstPos() const {return pos;}
|
const Vec3f & getConstPos() const {return pos;}
|
||||||
float getRotation() {return rotation;}
|
float getRotation() const {return rotation;}
|
||||||
const Model *getModel() const;
|
const Model *getModel() const;
|
||||||
Model *getModelPtr() const;
|
Model *getModelPtr() const;
|
||||||
bool getWalkable() const;
|
bool getWalkable() const;
|
||||||
|
|
|
@ -115,7 +115,7 @@ std::string UnitPathBasic::toString() const {
|
||||||
std::string result = "";
|
std::string result = "";
|
||||||
|
|
||||||
result = "unit path blockCount = " + intToStr(blockCount) + " pathQueue size = " + intToStr(pathQueue.size());
|
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();
|
result += " index = " + intToStr(idx) + " " + pathQueue[idx].getString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ UnitReference::UnitReference(){
|
||||||
faction= NULL;
|
faction= NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitReference::operator=(const Unit *unit){
|
UnitReference & UnitReference::operator=(const Unit *unit){
|
||||||
if(unit==NULL){
|
if(unit==NULL){
|
||||||
id= -1;
|
id= -1;
|
||||||
faction= NULL;
|
faction= NULL;
|
||||||
|
@ -170,6 +170,8 @@ void UnitReference::operator=(const Unit *unit){
|
||||||
id= unit->getId();
|
id= unit->getId();
|
||||||
faction= unit->getFaction();
|
faction= unit->getFaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Unit *UnitReference::getUnit() const{
|
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());
|
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
|
// 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) {
|
for(unsigned int i = 0; i < currentAttackBoostOriginatorEffect.currentAttackBoostUnits.size(); ++i) {
|
||||||
// Remove attack boost upgrades from unit
|
// Remove attack boost upgrades from unit
|
||||||
int findUnitId = currentAttackBoostOriginatorEffect.currentAttackBoostUnits[i];
|
int findUnitId = currentAttackBoostOriginatorEffect.currentAttackBoostUnits[i];
|
||||||
|
@ -1615,7 +1617,7 @@ bool Unit::update() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove any units that were previously in range
|
// 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) {
|
for(unsigned int i = 0; i < currentAttackBoostOriginatorEffect.currentAttackBoostUnits.size(); ++i) {
|
||||||
// Remove attack boost upgrades from unit
|
// Remove attack boost upgrades from unit
|
||||||
|
|
||||||
|
@ -1650,7 +1652,7 @@ bool Unit::update() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(showUnitParticles == true) {
|
if(showUnitParticles == true) {
|
||||||
if(currentAttackBoostOriginatorEffect.currentAttackBoostUnits.size() > 0) {
|
if(currentAttackBoostOriginatorEffect.currentAttackBoostUnits.empty() == false) {
|
||||||
if(attackBoost->unitParticleSystemTypeForSourceUnit != NULL) {
|
if(attackBoost->unitParticleSystemTypeForSourceUnit != NULL) {
|
||||||
currentAttackBoostOriginatorEffect.currentAppliedEffect = new UnitAttackBoostEffect();
|
currentAttackBoostOriginatorEffect.currentAppliedEffect = new UnitAttackBoostEffect();
|
||||||
currentAttackBoostOriginatorEffect.currentAppliedEffect->upst = new UnitParticleSystemType();
|
currentAttackBoostOriginatorEffect.currentAppliedEffect->upst = new UnitParticleSystemType();
|
||||||
|
@ -1702,7 +1704,7 @@ bool Unit::update() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(showUnitParticles == true) {
|
if(showUnitParticles == true) {
|
||||||
if(currentAttackBoostOriginatorEffect.currentAttackBoostUnits.size() > 0) {
|
if(currentAttackBoostOriginatorEffect.currentAttackBoostUnits.empty() == false) {
|
||||||
if( attackBoost->unitParticleSystemTypeForSourceUnit != NULL &&
|
if( attackBoost->unitParticleSystemTypeForSourceUnit != NULL &&
|
||||||
currentAttackBoostOriginatorEffect.currentAppliedEffect == NULL) {
|
currentAttackBoostOriginatorEffect.currentAppliedEffect == NULL) {
|
||||||
|
|
||||||
|
@ -2592,7 +2594,7 @@ void Unit::stopDamageParticles(bool force) {
|
||||||
// stop additional particles
|
// stop additional particles
|
||||||
|
|
||||||
|
|
||||||
if(smokeParticleSystems.size() > 0) {
|
if(smokeParticleSystems.empty() == false) {
|
||||||
for(int i = smokeParticleSystems.size()-1; i >= 0; --i) {
|
for(int i = smokeParticleSystems.size()-1; i >= 0; --i) {
|
||||||
UnitParticleSystem *ps = smokeParticleSystems[i];
|
UnitParticleSystem *ps = smokeParticleSystems[i];
|
||||||
ps->fade();
|
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) {
|
for(int i = damageParticleSystems.size()-1; i >= 0; --i) {
|
||||||
UnitParticleSystem *ps = damageParticleSystems[i];
|
UnitParticleSystem *ps = damageParticleSystems[i];
|
||||||
UnitParticleSystemType *pst = NULL;
|
UnitParticleSystemType *pst = NULL;
|
||||||
|
@ -2629,7 +2631,7 @@ void Unit::stopDamageParticles(bool force) {
|
||||||
|
|
||||||
void Unit::checkCustomizedParticleTriggers(bool force) {
|
void Unit::checkCustomizedParticleTriggers(bool force) {
|
||||||
// Now check if we have special hp triggered particles
|
// 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) {
|
for(int i = damageParticleSystems.size()-1; i >= 0; --i) {
|
||||||
UnitParticleSystem *ps = damageParticleSystems[i];
|
UnitParticleSystem *ps = damageParticleSystems[i];
|
||||||
UnitParticleSystemType *pst = NULL;
|
UnitParticleSystemType *pst = NULL;
|
||||||
|
@ -2941,7 +2943,7 @@ void Unit::cleanupOldBadHarvestPos() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(purgeList.size() > 0) {
|
if(purgeList.empty() == false) {
|
||||||
char szBuf[4096]="";
|
char szBuf[4096]="";
|
||||||
sprintf(szBuf,"[cleaning old bad harvest targets] purgeList.size() [%ld]",purgeList.size());
|
sprintf(szBuf,"[cleaning old bad harvest targets] purgeList.size() [%ld]",purgeList.size());
|
||||||
logSynchData(__FILE__,__LINE__,szBuf);
|
logSynchData(__FILE__,__LINE__,szBuf);
|
||||||
|
|
|
@ -95,7 +95,7 @@ private:
|
||||||
public:
|
public:
|
||||||
UnitReference();
|
UnitReference();
|
||||||
|
|
||||||
void operator=(const Unit *unit);
|
UnitReference & operator=(const Unit *unit);
|
||||||
Unit *getUnit() const;
|
Unit *getUnit() const;
|
||||||
|
|
||||||
int getUnitId() const { return id; }
|
int getUnitId() const { return id; }
|
||||||
|
|
|
@ -94,7 +94,7 @@ void UpgradeManager::cancelUpgrade(const UpgradeType *upgradeType) {
|
||||||
upgradesLookup.erase(upgradeType);
|
upgradesLookup.erase(upgradeType);
|
||||||
|
|
||||||
for(map<const UpgradeType *,int>::iterator iterMap = upgradesLookup.begin();
|
for(map<const UpgradeType *,int>::iterator iterMap = upgradesLookup.begin();
|
||||||
iterMap != upgradesLookup.end(); iterMap++) {
|
iterMap != upgradesLookup.end(); ++iterMap) {
|
||||||
if(iterMap->second >= upgrades.size()) {
|
if(iterMap->second >= upgrades.size()) {
|
||||||
iterMap->second--;
|
iterMap->second--;
|
||||||
}
|
}
|
||||||
|
@ -209,7 +209,7 @@ bool UpgradeManager::isUpgrading(const UpgradeType *upgradeType) const {
|
||||||
|
|
||||||
void UpgradeManager::computeTotalUpgrade(const Unit *unit, TotalUpgrade *totalUpgrade) const {
|
void UpgradeManager::computeTotalUpgrade(const Unit *unit, TotalUpgrade *totalUpgrade) const {
|
||||||
totalUpgrade->reset();
|
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()
|
if((*it)->getFactionIndex() == unit->getFactionIndex()
|
||||||
&& (*it)->getType()->isAffected(unit->getType())
|
&& (*it)->getType()->isAffected(unit->getType())
|
||||||
&& (*it)->getState()==usUpgraded)
|
&& (*it)->getState()==usUpgraded)
|
||||||
|
|
|
@ -87,6 +87,7 @@ void CommandType::load(int id, const XmlNode *n, const string &dir,
|
||||||
StopCommandType::StopCommandType(){
|
StopCommandType::StopCommandType(){
|
||||||
commandTypeClass= ccStop;
|
commandTypeClass= ccStop;
|
||||||
clicks= cOne;
|
clicks= cOne;
|
||||||
|
stopSkillType=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StopCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const {
|
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(){
|
MoveCommandType::MoveCommandType(){
|
||||||
commandTypeClass= ccMove;
|
commandTypeClass= ccMove;
|
||||||
clicks= cTwo;
|
clicks= cTwo;
|
||||||
|
moveSkillType=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const {
|
void MoveCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const {
|
||||||
|
@ -180,6 +182,8 @@ string MoveCommandType::toString() const{
|
||||||
AttackCommandType::AttackCommandType(){
|
AttackCommandType::AttackCommandType(){
|
||||||
commandTypeClass= ccAttack;
|
commandTypeClass= ccAttack;
|
||||||
clicks= cTwo;
|
clicks= cTwo;
|
||||||
|
moveSkillType=NULL;
|
||||||
|
attackSkillType=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AttackCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const {
|
void AttackCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const {
|
||||||
|
@ -273,6 +277,8 @@ string AttackCommandType::toString() const{
|
||||||
AttackStoppedCommandType::AttackStoppedCommandType(){
|
AttackStoppedCommandType::AttackStoppedCommandType(){
|
||||||
commandTypeClass= ccAttackStopped;
|
commandTypeClass= ccAttackStopped;
|
||||||
clicks= cOne;
|
clicks= cOne;
|
||||||
|
stopSkillType=NULL;
|
||||||
|
attackSkillType=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AttackStoppedCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const {
|
void AttackStoppedCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const {
|
||||||
|
@ -355,6 +361,8 @@ string AttackStoppedCommandType::toString() const {
|
||||||
BuildCommandType::BuildCommandType() {
|
BuildCommandType::BuildCommandType() {
|
||||||
commandTypeClass= ccBuild;
|
commandTypeClass= ccBuild;
|
||||||
clicks= cTwo;
|
clicks= cTwo;
|
||||||
|
moveSkillType=NULL;
|
||||||
|
buildSkillType=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildCommandType::~BuildCommandType() {
|
BuildCommandType::~BuildCommandType() {
|
||||||
|
@ -455,6 +463,12 @@ string BuildCommandType::toString() const{
|
||||||
HarvestCommandType::HarvestCommandType(){
|
HarvestCommandType::HarvestCommandType(){
|
||||||
commandTypeClass= ccHarvest;
|
commandTypeClass= ccHarvest;
|
||||||
clicks= cTwo;
|
clicks= cTwo;
|
||||||
|
moveSkillType=NULL;
|
||||||
|
moveLoadedSkillType=NULL;
|
||||||
|
harvestSkillType=NULL;
|
||||||
|
stopLoadedSkillType=NULL;
|
||||||
|
maxLoad=0;
|
||||||
|
hitsPerUnit=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HarvestCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const {
|
void HarvestCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const {
|
||||||
|
@ -533,6 +547,8 @@ bool HarvestCommandType::canHarvest(const ResourceType *resourceType) const{
|
||||||
RepairCommandType::RepairCommandType(){
|
RepairCommandType::RepairCommandType(){
|
||||||
commandTypeClass= ccRepair;
|
commandTypeClass= ccRepair;
|
||||||
clicks= cTwo;
|
clicks= cTwo;
|
||||||
|
moveSkillType=NULL;
|
||||||
|
repairSkillType=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
RepairCommandType::~RepairCommandType(){
|
RepairCommandType::~RepairCommandType(){
|
||||||
|
@ -610,6 +626,8 @@ bool RepairCommandType::isRepairableUnitType(const UnitType *unitType) const {
|
||||||
ProduceCommandType::ProduceCommandType(){
|
ProduceCommandType::ProduceCommandType(){
|
||||||
commandTypeClass= ccProduce;
|
commandTypeClass= ccProduce;
|
||||||
clicks= cOne;
|
clicks= cOne;
|
||||||
|
produceSkillType=NULL;
|
||||||
|
producedUnit=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProduceCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const {
|
void ProduceCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const {
|
||||||
|
@ -675,6 +693,8 @@ const ProducibleType *ProduceCommandType::getProduced() const{
|
||||||
UpgradeCommandType::UpgradeCommandType(){
|
UpgradeCommandType::UpgradeCommandType(){
|
||||||
commandTypeClass= ccUpgrade;
|
commandTypeClass= ccUpgrade;
|
||||||
clicks= cOne;
|
clicks= cOne;
|
||||||
|
upgradeSkillType=NULL;
|
||||||
|
producedUpgrade=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpgradeCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const {
|
void UpgradeCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const {
|
||||||
|
@ -732,6 +752,9 @@ const ProducibleType *UpgradeCommandType::getProduced() const{
|
||||||
MorphCommandType::MorphCommandType(){
|
MorphCommandType::MorphCommandType(){
|
||||||
commandTypeClass= ccMorph;
|
commandTypeClass= ccMorph;
|
||||||
clicks= cOne;
|
clicks= cOne;
|
||||||
|
morphSkillType=NULL;
|
||||||
|
morphUnit=NULL;
|
||||||
|
discount=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MorphCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const {
|
void MorphCommandType::update(UnitUpdater *unitUpdater, Unit *unit, int frameIndex) const {
|
||||||
|
|
|
@ -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
|
|
@ -77,6 +77,7 @@ string RequirableType::getReqDesc() const{
|
||||||
|
|
||||||
ProducibleType::ProducibleType(){
|
ProducibleType::ProducibleType(){
|
||||||
cancelImage= NULL;
|
cancelImage= NULL;
|
||||||
|
productionTime=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProducibleType::~ProducibleType(){
|
ProducibleType::~ProducibleType(){
|
||||||
|
|
|
@ -47,7 +47,7 @@ void FactionType::load(const string &dir, const TechTree *techTree, Checksum* ch
|
||||||
name= lastDir(currentPath);
|
name= lastDir(currentPath);
|
||||||
|
|
||||||
// Add special Observer Faction
|
// Add special Observer Faction
|
||||||
Lang &lang= Lang::getInstance();
|
//Lang &lang= Lang::getInstance();
|
||||||
if(name == formatString(GameConstants::OBSERVER_SLOTNAME)) {
|
if(name == formatString(GameConstants::OBSERVER_SLOTNAME)) {
|
||||||
personalityType = fpt_Observer;
|
personalityType = fpt_Observer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -501,6 +501,12 @@ AttackSkillType::AttackSkillType() {
|
||||||
for(int i = 0; i < fieldCount; ++i) {
|
for(int i = 0; i < fieldCount; ++i) {
|
||||||
attackFields[i]= false;
|
attackFields[i]= false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
attackStrength=0;
|
||||||
|
attackVar=0;
|
||||||
|
attackRange=0;
|
||||||
|
attackStartTime=0;
|
||||||
|
splashDamageAll=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AttackSkillType::~AttackSkillType() {
|
AttackSkillType::~AttackSkillType() {
|
||||||
|
@ -672,6 +678,7 @@ string RepairSkillType::toString() const{
|
||||||
|
|
||||||
ProduceSkillType::ProduceSkillType(){
|
ProduceSkillType::ProduceSkillType(){
|
||||||
skillClass= scProduce;
|
skillClass= scProduce;
|
||||||
|
animProgressBound=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProduceSkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt,
|
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(){
|
UpgradeSkillType::UpgradeSkillType(){
|
||||||
skillClass= scUpgrade;
|
skillClass= scUpgrade;
|
||||||
|
animProgressBound=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpgradeSkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt,
|
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(){
|
BeBuiltSkillType::BeBuiltSkillType(){
|
||||||
skillClass= scBeBuilt;
|
skillClass= scBeBuilt;
|
||||||
|
animProgressBound=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BeBuiltSkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt,
|
void BeBuiltSkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt,
|
||||||
|
@ -764,6 +773,7 @@ string BeBuiltSkillType::toString() const{
|
||||||
|
|
||||||
MorphSkillType::MorphSkillType(){
|
MorphSkillType::MorphSkillType(){
|
||||||
skillClass= scMorph;
|
skillClass= scMorph;
|
||||||
|
animProgressBound=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MorphSkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt,
|
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(){
|
DieSkillType::DieSkillType(){
|
||||||
skillClass= scDie;
|
skillClass= scDie;
|
||||||
|
fade=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DieSkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt,
|
void DieSkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt,
|
||||||
|
|
|
@ -293,7 +293,7 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree,
|
||||||
UnitParticleSystemType *unitParticleSystemType= new UnitParticleSystemType();
|
UnitParticleSystemType *unitParticleSystemType= new UnitParticleSystemType();
|
||||||
|
|
||||||
//Texture2D *newTexture = Renderer::getInstance().newTexture2D(rsGame);
|
//Texture2D *newTexture = Renderer::getInstance().newTexture2D(rsGame);
|
||||||
Texture2D *newTexture = NULL;
|
//Texture2D *newTexture = NULL;
|
||||||
|
|
||||||
unitParticleSystemType->load(particleFileNode, dir, currentPath + path,
|
unitParticleSystemType->load(particleFileNode, dir, currentPath + path,
|
||||||
&Renderer::getInstance(),loadedFileList, sourceXMLFile,
|
&Renderer::getInstance(),loadedFileList, sourceXMLFile,
|
||||||
|
|
|
@ -322,13 +322,13 @@ void UpgradeType::load(const string &dir, const TechTree *techTree,
|
||||||
string UpgradeType::getReqDesc() const{
|
string UpgradeType::getReqDesc() const{
|
||||||
|
|
||||||
string str;
|
string str;
|
||||||
int i;
|
//int i;
|
||||||
Lang &lang= Lang::getInstance();
|
Lang &lang= Lang::getInstance();
|
||||||
|
|
||||||
str= ProducibleType::getReqDesc();
|
str= ProducibleType::getReqDesc();
|
||||||
if(getEffectCount()>0){
|
if(getEffectCount()>0){
|
||||||
str+= "\n"+ lang.get("Upgrades")+":\n";
|
str+= "\n"+ lang.get("Upgrades")+":\n";
|
||||||
for(i=0; i<getEffectCount(); ++i){
|
for(int i=0; i<getEffectCount(); ++i){
|
||||||
str+= getEffect(i)->getName()+"\n";
|
str+= getEffect(i)->getName()+"\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,11 @@ SurfaceCell::SurfaceCell() {
|
||||||
surfaceType= -1;
|
surfaceType= -1;
|
||||||
surfaceTexture= NULL;
|
surfaceTexture= NULL;
|
||||||
nearSubmerged = false;
|
nearSubmerged = false;
|
||||||
|
|
||||||
|
for(int i = 0; i < GameConstants::maxPlayers + GameConstants::specialFactions; ++i) {
|
||||||
|
visible[i] = false;
|
||||||
|
explored[i] = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SurfaceCell::~SurfaceCell() {
|
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));
|
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 unitPos= computeDestPos(unit->getPos(), unit->getPos(), pos);
|
||||||
|
|
||||||
Vec2i start = pos - Vec2i(1);
|
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) {
|
for(int i = 0; i < selection->getCount(); ++i) {
|
||||||
const Unit *unit = selection->getUnit(i);
|
const Unit *unit = selection->getUnit(i);
|
||||||
int unitId= unit->getId();
|
//int unitId= unit->getId();
|
||||||
Vec2i unitBuilderPos= computeDestPos(refPos, unit->getPos(), pos);
|
Vec2i unitBuilderPos= computeDestPos(refPos, unit->getPos(), pos);
|
||||||
|
|
||||||
for(int i = start.x; i <= end.x; ++i) {
|
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 {
|
const Vec2i &testPos) const {
|
||||||
bool isInsideDestUnitCells = isInUnitTypeCells(ut, pos,testPos);
|
bool isInsideDestUnitCells = isInUnitTypeCells(ut, pos,testPos);
|
||||||
if(isInsideDestUnitCells == false) {
|
if(isInsideDestUnitCells == false) {
|
||||||
Cell *testCell = getCell(testPos);
|
//Cell *testCell = getCell(testPos);
|
||||||
for(int i=-1; i <= ut->getSize(); ++i){
|
for(int i=-1; i <= ut->getSize(); ++i){
|
||||||
for(int j = -1; j <= ut->getSize(); ++j) {
|
for(int j = -1; j <= ut->getSize(); ++j) {
|
||||||
Vec2i currPos = pos + Vec2i(i, j);
|
Vec2i currPos = pos + Vec2i(i, j);
|
||||||
|
@ -1316,7 +1321,7 @@ void Map::computeInterpolatedHeights(){
|
||||||
|
|
||||||
void Map::smoothSurface(Tileset *tileset) {
|
void Map::smoothSurface(Tileset *tileset) {
|
||||||
float *oldHeights = new float[getSurfaceCellArraySize()];
|
float *oldHeights = new float[getSurfaceCellArraySize()];
|
||||||
int arraySize=getSurfaceCellArraySize();
|
//int arraySize=getSurfaceCellArraySize();
|
||||||
|
|
||||||
for (int i = 0; i < getSurfaceCellArraySize(); ++i) {
|
for (int i = 0; i < getSurfaceCellArraySize(); ++i) {
|
||||||
oldHeights[i] = surfaceCells[i].getHeight();
|
oldHeights[i] = surfaceCells[i].getHeight();
|
||||||
|
|
|
@ -36,6 +36,8 @@ Minimap::Minimap() {
|
||||||
fowPixmap1= NULL;
|
fowPixmap1= NULL;
|
||||||
fogOfWar= true;//Config::getInstance().getBool("FogOfWar");
|
fogOfWar= true;//Config::getInstance().getBool("FogOfWar");
|
||||||
gameSettings= NULL;
|
gameSettings= NULL;
|
||||||
|
tex=NULL;
|
||||||
|
fowTex=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Minimap::init(int w, int h, const World *world, bool fogOfWar) {
|
void Minimap::init(int w, int h, const World *world, bool fogOfWar) {
|
||||||
|
|
|
@ -90,7 +90,7 @@ void TimeFlow::update() {
|
||||||
lastTime= time;
|
lastTime= time;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TimeFlow::isAproxTime(float time){
|
bool TimeFlow::isAproxTime(float time) const {
|
||||||
return (this->time>=time) && (this->time<time+timeInc);
|
return (this->time>=time) && (this->time<time+timeInc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ public:
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
private:
|
private:
|
||||||
bool isAproxTime(float time);
|
bool isAproxTime(float time) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
}} //end namespace
|
}} //end namespace
|
||||||
|
|
|
@ -54,6 +54,7 @@ UnitUpdater::UnitUpdater() {
|
||||||
this->routePlanner = NULL;
|
this->routePlanner = NULL;
|
||||||
this->pathFinder = NULL;
|
this->pathFinder = NULL;
|
||||||
//UnitRangeCellsLookupItemCacheTimerCount = 0;
|
//UnitRangeCellsLookupItemCacheTimerCount = 0;
|
||||||
|
attackWarnRange=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitUpdater::init(Game *game){
|
void UnitUpdater::init(Game *game){
|
||||||
|
@ -872,7 +873,7 @@ void UnitUpdater::updateHarvest(Unit *unit, int frameIndex) {
|
||||||
Vec2i targetPos(-1);
|
Vec2i targetPos(-1);
|
||||||
|
|
||||||
TravelState tsValue = tsImpossible;
|
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());
|
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());
|
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 ||
|
if(unit->getCurrSkill()->getClass() != scRepair ||
|
||||||
(nextToRepaired == false && peerUnitBuilder == NULL)) {
|
(nextToRepaired == false && peerUnitBuilder == NULL)) {
|
||||||
|
@ -2150,10 +2151,10 @@ bool UnitUpdater::unitOnRange(const Unit *unit, int range, Unit **rangedPtr,
|
||||||
Vec2i center = unit->getPos();
|
Vec2i center = unit->getPos();
|
||||||
Vec2f floatCenter = unit->getFloatCenteredPos();
|
Vec2f floatCenter = unit->getFloatCenteredPos();
|
||||||
|
|
||||||
bool foundInCache = true;
|
//bool foundInCache = true;
|
||||||
if(findCachedCellsEnemies(center,range,size,enemies,ast,
|
if(findCachedCellsEnemies(center,range,size,enemies,ast,
|
||||||
unit,commandTarget) == false) {
|
unit,commandTarget) == false) {
|
||||||
foundInCache = false;
|
//foundInCache = false;
|
||||||
//nearby cells
|
//nearby cells
|
||||||
UnitRangeCellsLookupItem cacheItem;
|
UnitRangeCellsLookupItem cacheItem;
|
||||||
for(int i = center.x - range; i < center.x + range + size; ++i) {
|
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) {
|
if(result == true) {
|
||||||
const Unit* teamUnit = NULL;
|
//const Unit* teamUnit = NULL;
|
||||||
const Unit* enemyUnit = NULL;
|
const Unit* enemyUnit = NULL;
|
||||||
bool onlyEnemyUnits = true;
|
bool onlyEnemyUnits = true;
|
||||||
|
|
||||||
if(unit->getTeam() == world->getThisTeamIndex()) {
|
if(unit->getTeam() == world->getThisTeamIndex()) {
|
||||||
teamUnit = unit;
|
//teamUnit = unit;
|
||||||
enemyUnit = enemySeen;
|
enemyUnit = enemySeen;
|
||||||
onlyEnemyUnits = false;
|
onlyEnemyUnits = false;
|
||||||
}
|
}
|
||||||
else if(enemySeen->getTeam() == world->getThisTeamIndex()) {
|
else if(enemySeen->getTeam() == world->getThisTeamIndex()) {
|
||||||
teamUnit = enemySeen;
|
//teamUnit = enemySeen;
|
||||||
enemyUnit = unit;
|
enemyUnit = unit;
|
||||||
onlyEnemyUnits = false;
|
onlyEnemyUnits = false;
|
||||||
}
|
}
|
||||||
|
@ -2332,10 +2333,10 @@ vector<Unit*> UnitUpdater::enemyUnitsOnRange(const Unit *unit,const AttackSkillT
|
||||||
Vec2i center = unit->getPos();
|
Vec2i center = unit->getPos();
|
||||||
Vec2f floatCenter = unit->getFloatCenteredPos();
|
Vec2f floatCenter = unit->getFloatCenteredPos();
|
||||||
|
|
||||||
bool foundInCache = true;
|
//bool foundInCache = true;
|
||||||
if(findCachedCellsEnemies(center,range,size,enemies,ast,
|
if(findCachedCellsEnemies(center,range,size,enemies,ast,
|
||||||
unit,commandTarget) == false) {
|
unit,commandTarget) == false) {
|
||||||
foundInCache = false;
|
//foundInCache = false;
|
||||||
//nearby cells
|
//nearby cells
|
||||||
UnitRangeCellsLookupItem cacheItem;
|
UnitRangeCellsLookupItem cacheItem;
|
||||||
for(int i = center.x - range; i < center.x + range + size; ++i) {
|
for(int i = center.x - range; i < center.x + range + size; ++i) {
|
||||||
|
|
|
@ -75,6 +75,11 @@ World::World(){
|
||||||
scriptManager= NULL;
|
scriptManager= NULL;
|
||||||
this->game = 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__);
|
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;
|
routePlanner = 0;
|
||||||
|
|
||||||
for(std::map<string,StaticSound *>::iterator iterMap = staticSoundList.begin();
|
for(std::map<string,StaticSound *>::iterator iterMap = staticSoundList.begin();
|
||||||
iterMap != staticSoundList.end(); iterMap++) {
|
iterMap != staticSoundList.end(); ++iterMap) {
|
||||||
delete iterMap->second;
|
delete iterMap->second;
|
||||||
}
|
}
|
||||||
staticSoundList.clear();
|
staticSoundList.clear();
|
||||||
|
|
||||||
for(std::map<string,StrSound *>::iterator iterMap = streamSoundList.begin();
|
for(std::map<string,StrSound *>::iterator iterMap = streamSoundList.begin();
|
||||||
iterMap != streamSoundList.end(); iterMap++) {
|
iterMap != streamSoundList.end(); ++iterMap) {
|
||||||
delete iterMap->second;
|
delete iterMap->second;
|
||||||
}
|
}
|
||||||
streamSoundList.clear();
|
streamSoundList.clear();
|
||||||
|
@ -299,7 +304,7 @@ void World::updateAllFactionUnits() {
|
||||||
|
|
||||||
unitListToSort.push_back(new CommandGroupSorter(unit));
|
unitListToSort.push_back(new CommandGroupSorter(unit));
|
||||||
}
|
}
|
||||||
if(unitListToSort.size() > 0) {
|
if(unitListToSort.empty() == false) {
|
||||||
std::sort(unitListToSort.begin(),unitListToSort.end());
|
std::sort(unitListToSort.begin(),unitListToSort.end());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1359,8 +1364,8 @@ void World::initMap() {
|
||||||
// ==================== exploration ====================
|
// ==================== exploration ====================
|
||||||
|
|
||||||
void World::exploreCells(const Vec2i &newPos, int sightRange, int teamIndex) {
|
void World::exploreCells(const Vec2i &newPos, int sightRange, int teamIndex) {
|
||||||
bool cacheLookupPosResult = false;
|
//bool cacheLookupPosResult = false;
|
||||||
bool cacheLookupSightResult = false;
|
//bool cacheLookupSightResult = false;
|
||||||
|
|
||||||
// cache lookup of previously calculated cells + sight range
|
// cache lookup of previously calculated cells + sight range
|
||||||
if(MaxExploredCellsLookupItemCache > 0) {
|
if(MaxExploredCellsLookupItemCache > 0) {
|
||||||
|
@ -1392,11 +1397,11 @@ void World::exploreCells(const Vec2i &newPos, int sightRange, int teamIndex) {
|
||||||
// cache if already found
|
// cache if already found
|
||||||
std::map<Vec2i, std::map<int, ExploredCellsLookupItem> >::iterator iterFind = ExploredCellsLookupItemCache.find(newPos);
|
std::map<Vec2i, std::map<int, ExploredCellsLookupItem> >::iterator iterFind = ExploredCellsLookupItemCache.find(newPos);
|
||||||
if(iterFind != ExploredCellsLookupItemCache.end()) {
|
if(iterFind != ExploredCellsLookupItemCache.end()) {
|
||||||
cacheLookupPosResult = true;
|
//cacheLookupPosResult = true;
|
||||||
|
|
||||||
std::map<int, ExploredCellsLookupItem>::iterator iterFind2 = iterFind->second.find(sightRange);
|
std::map<int, ExploredCellsLookupItem>::iterator iterFind2 = iterFind->second.find(sightRange);
|
||||||
if(iterFind2 != iterFind->second.end()) {
|
if(iterFind2 != iterFind->second.end()) {
|
||||||
cacheLookupSightResult = true;
|
//cacheLookupSightResult = true;
|
||||||
|
|
||||||
std::vector<SurfaceCell *> &cellList = iterFind2->second.exploredCellList;
|
std::vector<SurfaceCell *> &cellList = iterFind2->second.exploredCellList;
|
||||||
for(int idx2 = 0; idx2 < cellList.size(); ++idx2) {
|
for(int idx2 = 0; idx2 < cellList.size(); ++idx2) {
|
||||||
|
|
|
@ -57,7 +57,7 @@ static inline std::vector<string> getExtensionsBmp() {
|
||||||
//static const string extensions[] = {"bmp", ""};
|
//static const string extensions[] = {"bmp", ""};
|
||||||
static std::vector<string> extensions;
|
static std::vector<string> extensions;
|
||||||
|
|
||||||
if(extensions.size() == 0) {
|
if(extensions.empty() == true) {
|
||||||
extensions.push_back("bmp");
|
extensions.push_back("bmp");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ static void term_source (j_decompress_ptr cinfo) {
|
||||||
//static const string extensions[] = {"jpg", "jpeg", ""};
|
//static const string extensions[] = {"jpg", "jpeg", ""};
|
||||||
static inline std::vector<string> getExtensions() {
|
static inline std::vector<string> getExtensions() {
|
||||||
static std::vector<string> extensions;
|
static std::vector<string> extensions;
|
||||||
if(extensions.size() == 0) {
|
if(extensions.empty() == true) {
|
||||||
extensions.push_back("jpg");
|
extensions.push_back("jpg");
|
||||||
extensions.push_back("jpeg");
|
extensions.push_back("jpeg");
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ static void user_flush_data(png_structp png_ptr) {}
|
||||||
static inline std::vector<string> getExtensionsPng() {
|
static inline std::vector<string> getExtensionsPng() {
|
||||||
//static const string extensions[] = {"png", ""};
|
//static const string extensions[] = {"png", ""};
|
||||||
static std::vector<string> extensions;
|
static std::vector<string> extensions;
|
||||||
if(extensions.size() == 0) {
|
if(extensions.empty() == true) {
|
||||||
extensions.push_back("png");
|
extensions.push_back("png");
|
||||||
}
|
}
|
||||||
return extensions;
|
return extensions;
|
||||||
|
@ -63,7 +63,7 @@ PNGReader::PNGReader(): FileReader<Pixmap2D>(getExtensionsPng()) {}
|
||||||
Pixmap2D* PNGReader::read(ifstream& is, const string& path, Pixmap2D* ret) const {
|
Pixmap2D* PNGReader::read(ifstream& is, const string& path, Pixmap2D* ret) const {
|
||||||
//Read file
|
//Read file
|
||||||
is.seekg(0, ios::end);
|
is.seekg(0, ios::end);
|
||||||
size_t length = is.tellg();
|
//size_t length = is.tellg();
|
||||||
is.seekg(0, ios::beg);
|
is.seekg(0, ios::beg);
|
||||||
uint8 *buffer = new uint8[8];
|
uint8 *buffer = new uint8[8];
|
||||||
is.read((char*)buffer, 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 width = info_ptr->width;
|
||||||
int height = info_ptr->height;
|
int height = info_ptr->height;
|
||||||
int color_type = info_ptr->color_type;
|
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
|
//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)) {
|
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);
|
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_read_update_info(png_ptr, info_ptr);
|
||||||
png_bytep* row_pointers = new png_bytep[height];
|
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 {
|
Pixmap3D* PNGReader3D::read(ifstream& is, const string& path, Pixmap3D* ret) const {
|
||||||
//Read file
|
//Read file
|
||||||
is.seekg(0, ios::end);
|
is.seekg(0, ios::end);
|
||||||
size_t length = is.tellg();
|
//size_t length = is.tellg();
|
||||||
is.seekg(0, ios::beg);
|
is.seekg(0, ios::beg);
|
||||||
uint8 *buffer = new uint8[8];
|
uint8 *buffer = new uint8[8];
|
||||||
is.read((char*)buffer, 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 width = info_ptr->width;
|
||||||
int height = info_ptr->height;
|
int height = info_ptr->height;
|
||||||
int color_type = info_ptr->color_type;
|
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
|
//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)) {
|
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);
|
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_read_update_info(png_ptr, info_ptr);
|
||||||
png_bytep* row_pointers = new png_bytep[height];
|
png_bytep* row_pointers = new png_bytep[height];
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ static const int tgaUncompressedBw= 3;
|
||||||
static inline std::vector<string> getExtensionStrings() {
|
static inline std::vector<string> getExtensionStrings() {
|
||||||
//static const string extensions[] = {"tga", ""};
|
//static const string extensions[] = {"tga", ""};
|
||||||
static std::vector<string> extensions;
|
static std::vector<string> extensions;
|
||||||
if(extensions.size() == 0) {
|
if(extensions.empty() == true) {
|
||||||
extensions.push_back("tga");
|
extensions.push_back("tga");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// ==============================================================
|
// ==============================================================
|
||||||
// This file is part of Glest Shared Library (www.glest.org)
|
// 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
|
// You can redistribute this code and/or modify it under
|
||||||
// the terms of the GNU General Public License as published
|
// the terms of the GNU General Public License as published
|
||||||
|
@ -69,7 +69,7 @@ bool ShaderProgramGl::link(string &messages){
|
||||||
|
|
||||||
//bind attributes
|
//bind attributes
|
||||||
for(unsigned int i=0; i<attributes.size(); ++i){
|
for(unsigned int i=0; i<attributes.size(); ++i){
|
||||||
int a= attributes[i].second;
|
//int a= attributes[i].second;
|
||||||
string s= attributes[i].first;
|
string s= attributes[i].first;
|
||||||
glBindAttribLocationARB(handle, attributes[i].second, attributes[i].first.c_str());
|
glBindAttribLocationARB(handle, attributes[i].second, attributes[i].first.c_str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
|
@ -52,17 +52,17 @@ InterpolationData::~InterpolationData(){
|
||||||
|
|
||||||
|
|
||||||
for(std::map<float, std::map<bool, Vec3f *> >::iterator iterVert = cacheVertices.begin();
|
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();
|
for(std::map<bool, Vec3f *>::iterator iterVert2 = iterVert->second.begin();
|
||||||
iterVert2 != iterVert->second.end(); iterVert2++) {
|
iterVert2 != iterVert->second.end(); ++iterVert2) {
|
||||||
delete [] iterVert2->second;
|
delete [] iterVert2->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(std::map<float, std::map<bool, Vec3f *> >::iterator iterVert = cacheNormals.begin();
|
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();
|
for(std::map<bool, Vec3f *>::iterator iterVert2 = iterVert->second.begin();
|
||||||
iterVert2 != iterVert->second.end(); iterVert2++) {
|
iterVert2 != iterVert->second.end(); ++iterVert2) {
|
||||||
delete [] iterVert2->second;
|
delete [] iterVert2->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -409,7 +409,7 @@ GameParticleSystem::GameParticleSystem(int particleCount):
|
||||||
{}
|
{}
|
||||||
|
|
||||||
GameParticleSystem::~GameParticleSystem(){
|
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)->setParent(NULL);
|
||||||
(*it)->fade();
|
(*it)->fade();
|
||||||
}
|
}
|
||||||
|
@ -512,7 +512,7 @@ void GameParticleSystem::setTween(float relative,float absolute) {
|
||||||
|
|
||||||
tween= clamp(tween, 0.0f, 1.0f);
|
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);
|
(*it)->setTween(relative,absolute);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -580,7 +580,7 @@ void UnitParticleSystem::render(ParticleRenderer *pr, ModelRenderer *mr) {
|
||||||
|
|
||||||
void UnitParticleSystem::setRotation(float rotation){
|
void UnitParticleSystem::setRotation(float rotation){
|
||||||
this->rotation= 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);
|
(*it)->setRotation(rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -998,7 +998,7 @@ void ProjectileParticleSystem::rotateChildren() {
|
||||||
float rotation = atan2(direction.x, direction.z);
|
float rotation = atan2(direction.x, direction.z);
|
||||||
#endif
|
#endif
|
||||||
rotation = radToDeg(rotation);
|
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);
|
(*it)->setRotation(rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1169,14 +1169,14 @@ void ParticleManager::render(ParticleRenderer *pr, ModelRenderer *mr) const{
|
||||||
bool ParticleManager::hasActiveParticleSystem(ParticleSystem::ParticleSystemType type) const{
|
bool ParticleManager::hasActiveParticleSystem(ParticleSystem::ParticleSystemType type) const{
|
||||||
bool result= false;
|
bool result= false;
|
||||||
|
|
||||||
size_t particleSystemCount= particleSystems.size();
|
//size_t particleSystemCount= particleSystems.size();
|
||||||
int currentParticleCount= 0;
|
//int currentParticleCount= 0;
|
||||||
|
|
||||||
vector<ParticleSystem *> cleanupParticleSystemsList;
|
vector<ParticleSystem *> cleanupParticleSystemsList;
|
||||||
for(unsigned int i= 0; i < particleSystems.size(); i++){
|
for(unsigned int i= 0; i < particleSystems.size(); i++){
|
||||||
ParticleSystem *ps= particleSystems[i];
|
ParticleSystem *ps= particleSystems[i];
|
||||||
if(ps != NULL){
|
if(ps != NULL){
|
||||||
currentParticleCount+= ps->getAliveParticleCount();
|
//currentParticleCount+= ps->getAliveParticleCount();
|
||||||
|
|
||||||
bool showParticle= true;
|
bool showParticle= true;
|
||||||
if(dynamic_cast<UnitParticleSystem *> (ps) != NULL || dynamic_cast<FireParticleSystem *> (ps) != NULL){
|
if(dynamic_cast<UnitParticleSystem *> (ps) != NULL || dynamic_cast<FireParticleSystem *> (ps) != NULL){
|
||||||
|
|
|
@ -1322,7 +1322,8 @@ void Pixmap3D::loadSlicePng(const string &path, int slice) {
|
||||||
this->path = path;
|
this->path = path;
|
||||||
|
|
||||||
//deletePixels();
|
//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);
|
//printf("Loading 3D pixmap PNG [%s] pixmap [%p] this [%p]\n",path.c_str(),pixmap, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -717,7 +717,7 @@ void MapPreview::loadFromFile(const string &path) {
|
||||||
#else
|
#else
|
||||||
FILE *f1 = fopen(path.c_str(), "rb");
|
FILE *f1 = fopen(path.c_str(), "rb");
|
||||||
#endif
|
#endif
|
||||||
int fileErrno = errno;
|
//int fileErrno = errno;
|
||||||
if (f1 != NULL) {
|
if (f1 != NULL) {
|
||||||
|
|
||||||
//read header
|
//read header
|
||||||
|
|
|
@ -238,7 +238,7 @@ void findDirs(string path, vector<string> &results, bool errorOnNotFound,bool ke
|
||||||
string searchpath = currentPath + "*.";
|
string searchpath = currentPath + "*.";
|
||||||
vector<string> current_results;
|
vector<string> current_results;
|
||||||
findAll(searchpath, current_results, false, errorOnNotFound);
|
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++) {
|
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 = current_results[folder_index];
|
||||||
const string current_folder_path = currentPath + current_folder;
|
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 + "*.";
|
string path = currentPath + "*.";
|
||||||
vector<string> current_results;
|
vector<string> current_results;
|
||||||
findAll(path, current_results, false, errorOnNotFound);
|
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++) {
|
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 = current_results[folder_index];
|
||||||
const string current_folder_path = currentPath + current_folder;
|
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;
|
string path = currentPath + fileFilter;
|
||||||
vector<string> current_results;
|
vector<string> current_results;
|
||||||
findAll(path, current_results, cutExtension, errorOnNotFound);
|
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++) {
|
for(unsigned int folder_index = 0; folder_index < current_results.size(); folder_index++) {
|
||||||
string current_file = current_results[folder_index];
|
string current_file = current_results[folder_index];
|
||||||
if(keepDuplicates == true || std::find(results.begin(),results.end(),current_file) == results.end()) {
|
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);
|
globfree(&globbuf);
|
||||||
|
|
||||||
if(results.size() == 0 && errorOnNotFound == true) {
|
if(results.empty() == true && errorOnNotFound == true) {
|
||||||
throw runtime_error("No files found in: " + mypath);
|
throw runtime_error("No files found in: " + mypath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -591,7 +591,7 @@ string getNetworkInterfaceBroadcastAddress(string ipAddress)
|
||||||
next = next->Next;
|
next = next->Next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
char buf[128];
|
//char buf[128];
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
{
|
{
|
||||||
//sprintf(buf, "unnamed-%i", i);
|
//sprintf(buf, "unnamed-%i", i);
|
||||||
|
@ -901,7 +901,7 @@ bool Socket::hasDataToRead(std::map<PLATFORM_SOCKET,bool> &socketTriggeredList)
|
||||||
|
|
||||||
PLATFORM_SOCKET imaxsocket = 0;
|
PLATFORM_SOCKET imaxsocket = 0;
|
||||||
for(std::map<PLATFORM_SOCKET,bool>::iterator itermap = socketTriggeredList.begin();
|
for(std::map<PLATFORM_SOCKET,bool>::iterator itermap = socketTriggeredList.begin();
|
||||||
itermap != socketTriggeredList.end(); itermap++)
|
itermap != socketTriggeredList.end(); ++itermap)
|
||||||
{
|
{
|
||||||
PLATFORM_SOCKET socket = itermap->first;
|
PLATFORM_SOCKET socket = itermap->first;
|
||||||
if(Socket::isSocketValid(&socket) == true)
|
if(Socket::isSocketValid(&socket) == true)
|
||||||
|
@ -933,7 +933,7 @@ bool Socket::hasDataToRead(std::map<PLATFORM_SOCKET,bool> &socketTriggeredList)
|
||||||
bResult = true;
|
bResult = true;
|
||||||
|
|
||||||
for(std::map<PLATFORM_SOCKET,bool>::iterator itermap = socketTriggeredList.begin();
|
for(std::map<PLATFORM_SOCKET,bool>::iterator itermap = socketTriggeredList.begin();
|
||||||
itermap != socketTriggeredList.end(); itermap++)
|
itermap != socketTriggeredList.end(); ++itermap)
|
||||||
{
|
{
|
||||||
PLATFORM_SOCKET socket = itermap->first;
|
PLATFORM_SOCKET socket = itermap->first;
|
||||||
if (FD_ISSET(socket, &rfds))
|
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 bcSender; // local socket address for the broadcast.
|
||||||
struct sockaddr_in bcaddr; // The broadcast address for the receiver.
|
struct sockaddr_in bcaddr; // The broadcast address for the receiver.
|
||||||
PLATFORM_SOCKET bcfd; // The file descriptor used for the broadcast.
|
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.
|
char buff[10024]; // Buffers the data to be broadcasted.
|
||||||
socklen_t alen;
|
socklen_t alen;
|
||||||
int nb; // The number of bytes read.
|
|
||||||
|
|
||||||
port = htons( Socket::getBroadCastPort() );
|
port = htons( Socket::getBroadCastPort() );
|
||||||
|
|
||||||
|
@ -1780,6 +1779,7 @@ void BroadCastClientSocketThread::execute() {
|
||||||
// Keep getting packets forever.
|
// Keep getting packets forever.
|
||||||
for( time_t elapsed = time(NULL); difftime(time(NULL),elapsed) <= 5; ) {
|
for( time_t elapsed = time(NULL); difftime(time(NULL),elapsed) <= 5; ) {
|
||||||
alen = sizeof(struct sockaddr);
|
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;
|
bool gotData = (nb = recvfrom(bcfd, buff, 10024, 0, (struct sockaddr *) &bcSender, &alen)) > 0;
|
||||||
|
|
||||||
if(gotData == false) {
|
if(gotData == false) {
|
||||||
|
@ -2316,11 +2316,11 @@ void BroadCastSocketThread::execute() {
|
||||||
char buff[buffMaxSize]=""; // Buffers the data to be broadcasted.
|
char buff[buffMaxSize]=""; // Buffers the data to be broadcasted.
|
||||||
char myhostname[100]=""; // hostname of local machine
|
char myhostname[100]=""; // hostname of local machine
|
||||||
//char subnetmask[MAX_NIC_COUNT][100]; // Subnet mask to broadcast to
|
//char subnetmask[MAX_NIC_COUNT][100]; // Subnet mask to broadcast to
|
||||||
struct hostent* myhostent=NULL;
|
//struct hostent* myhostent=NULL;
|
||||||
|
|
||||||
/* get my host name */
|
/* get my host name */
|
||||||
gethostname(myhostname,100);
|
gethostname(myhostname,100);
|
||||||
myhostent = gethostbyname(myhostname);
|
struct hostent*myhostent = gethostbyname(myhostname);
|
||||||
|
|
||||||
// get all host IP addresses
|
// get all host IP addresses
|
||||||
std::vector<std::string> ipList = Socket::getLocalIPAddressList();
|
std::vector<std::string> ipList = Socket::getLocalIPAddressList();
|
||||||
|
|
|
@ -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_STENCIL_SIZE, newStencilBits);
|
||||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, newDepthBits);
|
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
|
#ifdef SDL_GL_SWAP_CONTROL
|
||||||
if(Window::tryVSynch == true) {
|
if(Window::tryVSynch == true) {
|
||||||
/* we want vsync for smooth scrolling */
|
/* we want vsync for smooth scrolling */
|
||||||
|
@ -424,10 +424,10 @@ void Window::toggleFullscreen() {
|
||||||
SDL_Surface *sf = SDL_GetVideoSurface();
|
SDL_Surface *sf = SDL_GetVideoSurface();
|
||||||
SDL_Surface **surface = &sf;
|
SDL_Surface **surface = &sf;
|
||||||
uint32 *flags = NULL;
|
uint32 *flags = NULL;
|
||||||
void *pixels = NULL;
|
//void *pixels = NULL;
|
||||||
SDL_Color *palette = NULL;
|
//SDL_Color *palette = NULL;
|
||||||
SDL_Rect clip;
|
SDL_Rect clip;
|
||||||
int ncolors = 0;
|
//int ncolors = 0;
|
||||||
Uint32 tmpflags = 0;
|
Uint32 tmpflags = 0;
|
||||||
int w = 0;
|
int w = 0;
|
||||||
int h = 0;
|
int h = 0;
|
||||||
|
|
|
@ -52,7 +52,7 @@ void createGlFontBitmaps(uint32 &base, const string &type, int size, int width,
|
||||||
DWORD dwErrorGL = 0;
|
DWORD dwErrorGL = 0;
|
||||||
HDC hDC = 0;
|
HDC hDC = 0;
|
||||||
static std::vector<std::string> systemFontList;
|
static std::vector<std::string> systemFontList;
|
||||||
if(systemFontList.size() == 0) {
|
if(systemFontList.empty() == true) {
|
||||||
LOGFONT lf;
|
LOGFONT lf;
|
||||||
//POSITION pos;
|
//POSITION pos;
|
||||||
//lf.lfCharSet = ANSI_CHARSET;
|
//lf.lfCharSet = ANSI_CHARSET;
|
||||||
|
|
|
@ -153,7 +153,7 @@ bool Checksum::addFileToSum(const string &path) {
|
||||||
memset(buf,0,bufSize);
|
memset(buf,0,bufSize);
|
||||||
if(fgets(buf, bufSize, file) != NULL) {
|
if(fgets(buf, bufSize, file) != NULL) {
|
||||||
//addByte(byte);
|
//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
|
// Ignore Spaces in XML files as they are
|
||||||
// ONLY for formatting
|
// ONLY for formatting
|
||||||
if(isXMLFile == true) {
|
if(isXMLFile == true) {
|
||||||
|
@ -196,7 +196,7 @@ int32 Checksum::getSum() {
|
||||||
|
|
||||||
Checksum newResult;
|
Checksum newResult;
|
||||||
for(std::map<string,int32>::iterator iterMap = fileList.begin();
|
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__));
|
MutexSafeWrapper safeMutexSocketDestructorFlag(&Checksum::fileListCacheSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
if(Checksum::fileListCache.find(iterMap->first) == Checksum::fileListCache.end()) {
|
if(Checksum::fileListCache.find(iterMap->first) == Checksum::fileListCache.end()) {
|
||||||
|
|
|
@ -714,7 +714,7 @@ void Properties::setString(const string &key, const string &value){
|
||||||
string Properties::toString(){
|
string Properties::toString(){
|
||||||
string rStr;
|
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";
|
rStr+= pi->first + "=" + pi->second + "\n";
|
||||||
|
|
||||||
return rStr;
|
return rStr;
|
||||||
|
|
|
@ -337,7 +337,7 @@ void SystemFlags::Close() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for(std::map<SystemFlags::DebugType,SystemFlags::SystemFlagsType>::iterator iterMap = SystemFlags::debugLogFileList->begin();
|
for(std::map<SystemFlags::DebugType,SystemFlags::SystemFlagsType>::iterator iterMap = SystemFlags::debugLogFileList->begin();
|
||||||
iterMap != SystemFlags::debugLogFileList->end(); iterMap++) {
|
iterMap != SystemFlags::debugLogFileList->end(); ++iterMap) {
|
||||||
SystemFlags::SystemFlagsType ¤tDebugLog = iterMap->second;
|
SystemFlags::SystemFlagsType ¤tDebugLog = iterMap->second;
|
||||||
currentDebugLog.Close();
|
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
|
// If the file is already open (shared) by another debug type
|
||||||
// do not over-write the file but share the stream pointer
|
// do not over-write the file but share the stream pointer
|
||||||
for(std::map<SystemFlags::DebugType,SystemFlags::SystemFlagsType>::iterator iterMap = SystemFlags::debugLogFileList->begin();
|
for(std::map<SystemFlags::DebugType,SystemFlags::SystemFlagsType>::iterator iterMap = SystemFlags::debugLogFileList->begin();
|
||||||
iterMap != SystemFlags::debugLogFileList->end(); iterMap++) {
|
iterMap != SystemFlags::debugLogFileList->end(); ++iterMap) {
|
||||||
SystemFlags::SystemFlagsType ¤tDebugLog2 = iterMap->second;
|
SystemFlags::SystemFlagsType ¤tDebugLog2 = iterMap->second;
|
||||||
|
|
||||||
if( iterMap->first != type &&
|
if( iterMap->first != type &&
|
||||||
|
@ -739,7 +739,7 @@ bool fileExists(const string &path) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int fileErrno = errno;
|
//int fileErrno = errno;
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
DWORD error = GetLastError();
|
DWORD error = GetLastError();
|
||||||
string strError = "Could not open file, result: " + intToStr(error) + " - " + intToStr(fileErrno) + " " + strerror(fileErrno) + " [" + path + "]";
|
string strError = "Could not open file, result: " + intToStr(error) + " - " + intToStr(fileErrno) + " " + strerror(fileErrno) + " [" + path + "]";
|
||||||
|
|
|
@ -187,7 +187,7 @@ void XmlTree::load(const string &path, std::map<string,string> mapTagReplacement
|
||||||
Mutex &mutex = CacheManager::getMutexForItem<LoadStack>(loadStackCacheName);
|
Mutex &mutex = CacheManager::getMutexForItem<LoadStack>(loadStackCacheName);
|
||||||
MutexSafeWrapper safeMutex(&mutex);
|
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){
|
if((*it)->loadPath == path){
|
||||||
throw runtime_error(path + " recursively included");
|
throw runtime_error(path + " recursively included");
|
||||||
}
|
}
|
||||||
|
@ -363,7 +363,7 @@ bool XmlNode::hasChild(const string &childName) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XmlNode::hasChildNoSuper(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) {
|
for(unsigned int j = 0; j < children.size(); ++j) {
|
||||||
if(children[j]->getName() == childName) {
|
if(children[j]->getName() == childName) {
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue