- added more error checking in case segfault reproduced from: https://forum.megaglest.org/index.php?topic=9612.0;topicseen

This commit is contained in:
SoftCoder 2014-12-21 17:32:04 -08:00
parent b0f7b078f6
commit e65ad1b69c
1 changed files with 14 additions and 0 deletions

View File

@ -170,11 +170,25 @@ bool SurfaceCell::decAmount(int value) {
return object->getResource()->decAmount(value);
}
void SurfaceCell::setExplored(int teamIndex, bool explored) {
if(teamIndex < 0 || teamIndex >= GameConstants::maxPlayers + GameConstants::specialFactions) {
char szBuf[8096]="";
snprintf(szBuf,8096,"Invalid value for teamIndex [%d]",teamIndex);
printf("%s\n",szBuf);
throw megaglest_runtime_error(szBuf);
}
this->explored[teamIndex]= explored;
//printf("Setting explored to %d for teamIndex %d\n",explored,teamIndex);
}
void SurfaceCell::setVisible(int teamIndex, bool visible) {
if(teamIndex < 0 || teamIndex >= GameConstants::maxPlayers + GameConstants::specialFactions) {
char szBuf[8096]="";
snprintf(szBuf,8096,"Invalid value for teamIndex [%d]",teamIndex);
printf("%s\n",szBuf);
throw megaglest_runtime_error(szBuf);
}
this->visible[teamIndex]= visible;
}