- bug fixes to stabilize the windows build

This commit is contained in:
Mark Vejvoda 2013-02-09 06:57:05 +00:00
parent f06f86904c
commit 9bc6d33f1d
15 changed files with 82 additions and 42 deletions

View File

@ -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<int> Ai::findUnitsHarvestingResourceType(const ResourceType *rt) {
Command *command= unit->getCurrCommand();
const BuildCommandType *bct= dynamic_cast<const BuildCommandType*>(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);

View File

@ -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) {

View File

@ -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

View File

@ -4862,7 +4862,6 @@ int Game::getUpdateLoops() {
}
else
return speed;
return 1;
}
void Game::showLoseMessageBox() {

View File

@ -451,7 +451,6 @@ string Lang::getScenarioString(const string &s) {
}
return "???" + s + "???";
}
return "???" + s + "???";
}
string Lang::getTechTreeString(const string &s,const char *defaultValue) {

View File

@ -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;
};

View File

@ -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;

View File

@ -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;

View File

@ -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;}

View File

@ -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<string> 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; i<getFactionCount(); ++i) {
if(factionIdxToTick == -1 || factionIdxToTick == this->thisFactionIndex) {
bool cellVisibleForFaction = showWorldForPlayer(thisFactionIndex);
for(int j=0; j<getFaction(i)->getUnitCount(); ++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);

View File

@ -463,8 +463,9 @@ bool VideoPlayer::hasBackEndVideoPlayer() {
#ifdef HAS_LIBVLC
return true;
#endif
#else
return false;
#endif
}
void VideoPlayer::cleanupPlayer() {

View File

@ -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);

View File

@ -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
}
}

View File

@ -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;

View File

@ -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;