fix crash when hovering the mouse over invalid wall types

This commit is contained in:
jacob1 2013-02-24 11:50:20 -05:00
parent 6b1e99a731
commit 7379a6b5ba
2 changed files with 7 additions and 1 deletions

View File

@ -740,6 +740,9 @@ void GameSave::readOPS(char * data, int dataLength)
fanVelX[blockY+y][blockX+x] = (fanData[j++]-127.0f)/64.0f;
fanVelY[blockY+y][blockX+x] = (fanData[j++]-127.0f)/64.0f;
}
if (blockMap[y][x] < 0 || blockMap[y][x] >= UI_WALLCOUNT)
blockMap[y][x] = 0;
}
}
}
@ -1195,6 +1198,9 @@ void GameSave::readPSv(char * data, int dataLength)
blockMap[y][x]=WL_GRAV;
else if (blockMap[y][x]==O_WL_ALLOWENERGY)
blockMap[y][x]=WL_ALLOWENERGY;
if (blockMap[y][x] < 0 || blockMap[y][x] >= UI_WALLCOUNT)
blockMap[y][x] = 0;
}
p++;

View File

@ -1298,7 +1298,7 @@ std::string GameController::ElementResolve(int type)
std::string GameController::WallName(int type)
{
if(gameModel && gameModel->GetSimulation() && gameModel->GetSimulation()->wtypes && type >= 0)
if(gameModel && gameModel->GetSimulation() && gameModel->GetSimulation()->wtypes && type >= 0 && type < UI_WALLCOUNT)
return std::string(gameModel->GetSimulation()->wtypes[type].name);
else
return "";