From 7379a6b5ba65ff106ec5656bdeb3a9707e9fac62 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sun, 24 Feb 2013 11:50:20 -0500 Subject: [PATCH] fix crash when hovering the mouse over invalid wall types --- src/client/GameSave.cpp | 6 ++++++ src/game/GameController.cpp | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/client/GameSave.cpp b/src/client/GameSave.cpp index d3ada65e5..791069d47 100644 --- a/src/client/GameSave.cpp +++ b/src/client/GameSave.cpp @@ -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++; diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp index 9e7978b59..c866805ef 100644 --- a/src/game/GameController.cpp +++ b/src/game/GameController.cpp @@ -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 "";