diff --git a/source/glest_game/ai/ai.cpp b/source/glest_game/ai/ai.cpp index 49531c6e..8e53c5b8 100644 --- a/source/glest_game/ai/ai.cpp +++ b/source/glest_game/ai/ai.cpp @@ -379,7 +379,7 @@ void Ai::update() { } //process ai rules - for(int ruleIdx = 0; ruleIdx < aiRules.size(); ++ruleIdx) { + for(unsigned int ruleIdx = 0; ruleIdx < aiRules.size(); ++ruleIdx) { AiRule *rule = aiRules[ruleIdx]; if(rule == NULL) { throw megaglest_runtime_error("rule == NULL"); @@ -582,7 +582,7 @@ vector Ai::findUnitsHarvestingResourceType(const ResourceType *rt) { Command *command= unit->getCurrCommand(); const BuildCommandType *bct= dynamic_cast(command->getCommandType()); if(bct != NULL) { - for(unsigned int j = 0; j < bct->getBuildingCount(); ++j) { + for(int j = 0; j < bct->getBuildingCount(); ++j) { const UnitType *ut = bct->getBuilding(j); if(ut != NULL) { const Resource *r = ut->getCost(rt); diff --git a/source/glest_game/ai/ai_interface.cpp b/source/glest_game/ai/ai_interface.cpp index 63dd6f72..e504514d 100644 --- a/source/glest_game/ai/ai_interface.cpp +++ b/source/glest_game/ai/ai_interface.cpp @@ -837,7 +837,7 @@ bool AiInterface::isFreeCells(const Vec2i &pos, int size, Field field){ } void AiInterface::removeEnemyWarningPositionFromList(Vec2i &checkPos) { - for(int i = enemyWarningPositionList.size() - 1; i <= 0; --i) { + for(int i = enemyWarningPositionList.size() - 1; i >= 0; --i) { Vec2i &pos = enemyWarningPositionList[i]; if(checkPos == pos) { diff --git a/source/glest_game/ai/path_finder.cpp b/source/glest_game/ai/path_finder.cpp index b041bdb0..f9d42497 100644 --- a/source/glest_game/ai/path_finder.cpp +++ b/source/glest_game/ai/path_finder.cpp @@ -462,7 +462,7 @@ bool PathFinder::addToOpenSet(Unit *unit, Node *node,const Vec2i finalPos, Vec2i direction PathFinder::directionOfMove(Vec2i to, Vec2i from) const { if (from.x == to.x) { if (from.y == to.y) - return -1; + return 0; else if (from.y < to.y) return 4; else // from.y > to.y diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 1f683d6b..0a2bac5c 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -4862,7 +4862,6 @@ int Game::getUpdateLoops() { } else return speed; - return 1; } void Game::showLoseMessageBox() { diff --git a/source/glest_game/global/lang.cpp b/source/glest_game/global/lang.cpp index d852c9e8..850ae56a 100644 --- a/source/glest_game/global/lang.cpp +++ b/source/glest_game/global/lang.cpp @@ -451,7 +451,6 @@ string Lang::getScenarioString(const string &s) { } return "???" + s + "???"; } - return "???" + s + "???"; } string Lang::getTechTreeString(const string &s,const char *defaultValue) { diff --git a/source/glest_game/graphics/renderer.h b/source/glest_game/graphics/renderer.h index c8d21aa0..3321c5c4 100644 --- a/source/glest_game/graphics/renderer.h +++ b/source/glest_game/graphics/renderer.h @@ -367,6 +367,28 @@ private: vbo_fowTexCoords(0), vbo_surfTexCoords(0), vbo_indices(0), indexCount(0), textureHandle(th),textureCRC(0) {} + + inline Layer & operator=(Layer &obj) { + this->vertices = obj.vertices; + this->normals = obj.normals; + this->fowTexCoords = obj.fowTexCoords; + this->surfTexCoords = obj.surfTexCoords; + this->indices = obj.indices; + this->cellToIndicesMap = obj.cellToIndicesMap; + this->rowsToRenderCache = obj.rowsToRenderCache; + this->vbo_vertices = obj.vbo_vertices; + this->vbo_normals = obj.vbo_normals; + this->vbo_fowTexCoords = obj.vbo_fowTexCoords; + this->vbo_surfTexCoords = obj.vbo_surfTexCoords; + this->vbo_indices = obj.vbo_indices; + this->indexCount = obj.indexCount; + this->textureHandle = obj.textureHandle; + this->texturePath = obj.texturePath; + this->textureCRC = obj.textureCRC; + + return *this; + } + ~Layer(); void load_vbos(bool vboEnabled); void render(VisibleQuadContainerCache &qCache); @@ -382,7 +404,7 @@ private: vbo_fowTexCoords, vbo_surfTexCoords, vbo_indices; int indexCount; - const int textureHandle; + int textureHandle; string texturePath; uint32 textureCRC; }; diff --git a/source/glest_game/main/intro.cpp b/source/glest_game/main/intro.cpp index df1d97d3..1538ba31 100644 --- a/source/glest_game/main/intro.cpp +++ b/source/glest_game/main/intro.cpp @@ -571,8 +571,6 @@ void Intro::update() { AutoTest::getInstance().updateIntro(program); return; - - SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); } mouse2d= (mouse2d+1) % Renderer::maxMouse2dAnim; diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index 3bdfd298..7e27dc71 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -394,6 +394,7 @@ Unit::Unit(int id, UnitPathInterface *unitpath, const Vec2i &pos, rotationZ=.0f; rotationX=.0f; + this->fire= NULL; this->unitPath = unitpath; this->unitPath->setMap(map); @@ -470,8 +471,6 @@ Unit::Unit(int id, UnitPathInterface *unitpath, const Vec2i &pos, currField = fLand; } - fire= NULL; - computeTotalUpgrade(); //starting skill @@ -520,8 +519,8 @@ Unit::~Unit() { Renderer::getInstance().cleanupParticleSystems(fireParticleSystems,rsGame); // Must set this to null of it will be used below in stopDamageParticles() - if(Renderer::getInstance().validateParticleSystemStillExists(fire,rsGame) == false) { - fire = NULL; + if(Renderer::getInstance().validateParticleSystemStillExists(this->fire,rsGame) == false) { + this->fire = NULL; } } @@ -571,6 +570,13 @@ Unit::~Unit() { #endif } +ParticleSystem * Unit::getFire() const { + if(Renderer::getInstance().validateParticleSystemStillExists(this->fire,rsGame) == false) { + return NULL; + } + return this->fire; +} + #ifdef LEAK_CHECK_UNITS void Unit::dumpMemoryList() { printf("===== START report of Unfreed Unit pointers =====\n"); @@ -2029,12 +2035,12 @@ bool Unit::update() { rotationX=.0f; } - if(Renderer::getInstance().validateParticleSystemStillExists(fire,rsGame) == false) { - fire = NULL; + if(Renderer::getInstance().validateParticleSystemStillExists(this->fire,rsGame) == false) { + this->fire = NULL; } - if (fire != NULL) { - fire->setPos(getCurrVector()); + if (this->fire != NULL) { + this->fire->setPos(getCurrVector()); } for(UnitParticleSystems::iterator it= unitParticleSystems.begin(); it != unitParticleSystems.end(); ++it) { if(Renderer::getInstance().validateParticleSystemStillExists((*it),rsGame) == true) { @@ -3185,14 +3191,14 @@ void Unit::stopDamageParticles(bool force) { if(force == true || (hp > type->getTotalMaxHp(&totalUpgrade) / 2) ) { //printf("Checking to stop damageparticles for unit [%s - %d] hp = %d\n",this->getType()->getName().c_str(),this->getId(),hp); - if(Renderer::getInstance().validateParticleSystemStillExists(fire,rsGame) == false) { - fire = NULL; + if(Renderer::getInstance().validateParticleSystemStillExists(this->fire,rsGame) == false) { + this->fire = NULL; } // stop fire - if(fire != NULL) { - fire->fade(); - fire = NULL; + if(this->fire != NULL) { + this->fire->fade(); + this->fire = NULL; } // stop additional particles @@ -3358,7 +3364,7 @@ void Unit::startDamageParticles() { } // start fire - if(type->getProperty(UnitType::pBurnable) && fire == NULL) { + if(type->getProperty(UnitType::pBurnable) && this->fire == NULL) { FireParticleSystem *fps = new FireParticleSystem(200); const Game *game = Renderer::getInstance().getGame(); fps->setSpeed(2.5f / game->getWorld()->getUpdateFps(this->getFactionIndex())); @@ -3366,7 +3372,7 @@ void Unit::startDamageParticles() { fps->setRadius(type->getSize()/3.f); fps->setTexture(CoreData::getInstance().getFireTexture()); fps->setParticleSize(type->getSize()/3.f); - fire= fps; + this->fire= fps; fireParticleSystems.push_back(fps); Renderer::getInstance().manageParticleSystem(fps, rsGame); @@ -3809,13 +3815,13 @@ void Unit::saveGame(XmlNode *rootNode) { // Faction *faction; // ParticleSystem *fire; int linkFireIndex = -1; - if(fire != NULL && Renderer::getInstance().validateParticleSystemStillExists(fire,rsGame) == true) { + if(this->fire != NULL && Renderer::getInstance().validateParticleSystemStillExists(this->fire,rsGame) == true) { //fire->saveGame(unitNode); bool fireInSystemList = false; if(fireParticleSystems.empty() == false) { for(unsigned int i = 0; i < fireParticleSystems.size(); ++i) { ParticleSystem *ps= fireParticleSystems[i]; - if(ps == fire) { + if(ps == this->fire) { linkFireIndex = i; fireInSystemList = true; break; @@ -3823,7 +3829,7 @@ void Unit::saveGame(XmlNode *rootNode) { } } if(fireInSystemList == false) { - fire->saveGame(unitNode); + this->fire->saveGame(unitNode); } } // TotalUpgrade totalUpgrade; diff --git a/source/glest_game/type_instances/unit.h b/source/glest_game/type_instances/unit.h index fa28bebb..1d21f497 100644 --- a/source/glest_game/type_instances/unit.h +++ b/source/glest_game/type_instances/unit.h @@ -521,7 +521,7 @@ public: inline float getRotation() const {return rotation;} float getRotationX() const; float getRotationZ() const; - inline ParticleSystem *getFire() const {return fire;} + ParticleSystem *getFire() const; inline int getKills() const {return kills;} inline int getEnemyKills() const {return enemyKills;} inline const Level *getLevel() const {return level;} diff --git a/source/glest_game/world/world.cpp b/source/glest_game/world/world.cpp index c453d779..4b4b23e1 100644 --- a/source/glest_game/world/world.cpp +++ b/source/glest_game/world/world.cpp @@ -2166,12 +2166,16 @@ bool World::showWorldForPlayer(int factionIndex, bool excludeFogOfWarCheck) cons //computes the fog of war texture, contained in the minimap void World::computeFow(int factionIdxToTick) { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s] Line: %d in frame: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,getFrameCount()); + bool showPerfStats = Config::getInstance().getBool("ShowPerfStats","false"); Chrono chronoPerf; char perfBuf[8096]=""; std::vector perfList; if(showPerfStats) chronoPerf.start(); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s] Line: %d in frame: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,getFrameCount()); + minimap.resetFowTex(); if(showPerfStats) { @@ -2179,8 +2183,10 @@ void World::computeFow(int factionIdxToTick) { perfList.push_back(perfBuf); } + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s] Line: %d in frame: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,getFrameCount()); //reset cells if(factionIdxToTick == -1 || factionIdxToTick == this->thisFactionIndex) { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s] Line: %d in frame: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,getFrameCount()); for(int i = 0; i < map.getSurfaceW(); ++i) { for(int j = 0; j < map.getSurfaceH(); ++j) { for(int k = 0; k < GameConstants::maxPlayers + GameConstants::specialFactions; ++k) { @@ -2214,8 +2220,10 @@ void World::computeFow(int factionIdxToTick) { } } } + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s] Line: %d in frame: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,getFrameCount()); } else { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s] Line: %d in frame: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,getFrameCount()); // Deal with observers for(int i = 0; i < map.getSurfaceW(); ++i) { for(int j = 0; j < map.getSurfaceH(); ++j) { @@ -2249,8 +2257,10 @@ void World::computeFow(int factionIdxToTick) { } } } + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s] Line: %d in frame: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,getFrameCount()); } + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s] Line: %d in frame: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,getFrameCount()); if(showPerfStats) { sprintf(perfBuf,"In [%s::%s] Line: %d took msecs: " MG_I64_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoPerf.getMillis()); perfList.push_back(perfBuf); @@ -2276,15 +2286,20 @@ void World::computeFow(int factionIdxToTick) { //fire for(int i=0; ithisFactionIndex) { + bool cellVisibleForFaction = showWorldForPlayer(thisFactionIndex); for(int j=0; jgetUnitCount(); ++j){ Unit *unit= getFaction(i)->getUnit(j); //fire ParticleSystem *fire= unit->getFire(); if(fire != NULL) { - bool cellVisible = showWorldForPlayer(thisFactionIndex); + bool cellVisible = cellVisibleForFaction; if(cellVisible == false) { - cellVisible = map.getSurfaceCell(Map::toSurfCoords(unit->getPos()))->isVisible(thisTeamIndex); + Vec2i sCoords = Map::toSurfCoords(unit->getPos()); + SurfaceCell *sc = map.getSurfaceCell(sCoords); + if(sc != NULL) { + cellVisible = sc->isVisible(thisTeamIndex); + } } fire->setActive(cellVisible); diff --git a/source/shared_lib/sources/graphics/video_player.cpp b/source/shared_lib/sources/graphics/video_player.cpp index 2a3fd5f1..4d4db608 100644 --- a/source/shared_lib/sources/graphics/video_player.cpp +++ b/source/shared_lib/sources/graphics/video_player.cpp @@ -463,8 +463,9 @@ bool VideoPlayer::hasBackEndVideoPlayer() { #ifdef HAS_LIBVLC return true; -#endif +#else return false; +#endif } void VideoPlayer::cleanupPlayer() { diff --git a/source/shared_lib/sources/platform/posix/miniftpclient.cpp b/source/shared_lib/sources/platform/posix/miniftpclient.cpp index d8b2402b..20c0e281 100644 --- a/source/shared_lib/sources/platform/posix/miniftpclient.cpp +++ b/source/shared_lib/sources/platform/posix/miniftpclient.cpp @@ -77,7 +77,7 @@ static size_t my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream) { removeFile(fullFilePath); - return -1; + return 0; } if(out && out->stream == NULL) { @@ -94,7 +94,7 @@ static size_t my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream) { if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Client thread FAILED to open file for writing [%s]\n",fullFilePath.c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"===> FTP Client thread FAILED to open file for writing [%s]\n",fullFilePath.c_str()); SystemFlags::OutputDebug(SystemFlags::debugError,"===> FTP Client thread FAILED to open file for writing [%s]\n",fullFilePath.c_str()); - return -1; /* failure, can't open file to write */ + return 0; /* failure, can't open file to write */ } out->isValidXfer = true; @@ -103,7 +103,7 @@ static size_t my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream) { if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> #2 FTP Client thread FAILED to open file for writing [%s]\n",fullFilePath.c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"===> #2 FTP Client thread FAILED to open file for writing [%s]\n",fullFilePath.c_str()); SystemFlags::OutputDebug(SystemFlags::debugError,"===> #2 FTP Client thread FAILED to open file for writing [%s]\n",fullFilePath.c_str()); - return -1; /* failure, can't open file to write */ + return 0; /* failure, can't open file to write */ } size_t result = fwrite(buffer, size, nmemb, out->stream); diff --git a/source/shared_lib/sources/platform/posix/socket.cpp b/source/shared_lib/sources/platform/posix/socket.cpp index 2d75a210..d6c56ff6 100644 --- a/source/shared_lib/sources/platform/posix/socket.cpp +++ b/source/shared_lib/sources/platform/posix/socket.cpp @@ -963,7 +963,7 @@ void Socket::disconnectSocket() { sock = INVALID_SOCKET; #else ::closesocket(sock); - sock = -1; + sock = INVALID_SOCKET; #endif } safeMutex.ReleaseLock(); @@ -2036,7 +2036,7 @@ void BroadCastClientSocketThread::execute() { bcfd = INVALID_SOCKET; #else ::closesocket(bcfd); - bcfd = -1; + bcfd = INVALID_SOCKET; #endif } @@ -2331,7 +2331,7 @@ Socket *ServerSocket::accept(bool errorOnFail) { newSock = INVALID_SOCKET; #else ::closesocket(newSock); - newSock = -1; + newSock = INVALID_SOCKET; #endif return NULL; @@ -2773,7 +2773,7 @@ void BroadCastSocketThread::execute() { #ifdef WIN32 bcfd[idx] = INVALID_SOCKET; #else - bcfd[idx] = -1; + bcfd[idx] = INVALID_SOCKET; #endif //if(strlen(subnetmask[idx]) > 0) { bcfd[idx] = socket( AF_INET, SOCK_DGRAM, 0 ); @@ -2867,7 +2867,7 @@ void BroadCastSocketThread::execute() { bcfd[idx] = INVALID_SOCKET; #else ::closesocket(bcfd[idx]); - bcfd[idx] = -1; + bcfd[idx] = INVALID_SOCKET; #endif } } diff --git a/source/shared_lib/sources/streflop/libm/flt-32/s_expm1f.cpp b/source/shared_lib/sources/streflop/libm/flt-32/s_expm1f.cpp index 8ec4d4a5..0268e0dd 100644 --- a/source/shared_lib/sources/streflop/libm/flt-32/s_expm1f.cpp +++ b/source/shared_lib/sources/streflop/libm/flt-32/s_expm1f.cpp @@ -49,7 +49,7 @@ Q5 = -2.0109921195e-07f; /* 0xb457edbb */ Simple x; #endif { - Simple y,hi,lo,c,t,e,hxs,hfx,r1; + Simple y,hi,lo,c=0,t,e,hxs,hfx,r1; int32_t k,xsb; u_int32_t hx; diff --git a/source/shared_lib/sources/streflop/libm/flt-32/s_log1pf.cpp b/source/shared_lib/sources/streflop/libm/flt-32/s_log1pf.cpp index 0837d099..7aa5e200 100644 --- a/source/shared_lib/sources/streflop/libm/flt-32/s_log1pf.cpp +++ b/source/shared_lib/sources/streflop/libm/flt-32/s_log1pf.cpp @@ -51,8 +51,8 @@ static Simple zero = 0.0f; Simple x; #endif { - Simple hfsq,f,c,s,z,R,u; - int32_t k,hx,hu,ax; + Simple hfsq,f=0,c=0,s,z,R,u; + int32_t k,hx,hu=0,ax; GET_FLOAT_WORD(hx,x); ax = hx&0x7fffffff;