Skip to content

Commit

Permalink
STARTREK: Cleanup away mission chain loading code
Browse files Browse the repository at this point in the history
  • Loading branch information
bluegr committed Aug 15, 2019
1 parent 384715d commit 089c04f
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions engines/startrek/room.cpp
Expand Up @@ -586,20 +586,25 @@ void Room::endMission(int16 score, int16 arg1, int16 arg2) {
// TODO: This is a stopgap measure (loading the next away mission immediately).
// Replace this with the proper code later.
_vm->_gameMode = GAMEMODE_BEAMDOWN;
if (_vm->_missionName == "DEMON")
_vm->_missionToLoad = "TUG";
if (_vm->_missionName == "TUG")
_vm->_missionToLoad = "LOVE";
if (_vm->_missionName == "LOVE")
_vm->_missionToLoad = "MUDD";
if (_vm->_missionName == "MUDD")
_vm->_missionToLoad = "FEATHER";
if (_vm->_missionName == "FEATHER")
_vm->_missionToLoad = "TRIAL";
if (_vm->_missionName == "TRIAL")
_vm->_missionToLoad = "SINS";
if (_vm->_missionName == "SINS")
_vm->_missionToLoad = "VENG";

const char *missionNames[] = {
"DEMON",
"TUG",
"LOVE",
"MUDD",
"FEATHER",
"TRIAL",
"SINS",
"VENG"
};

for (int i = 0; i < ARRAYSIZE(missionNames); i++) {

This comment has been minimized.

Copy link
@mgerhardy

mgerhardy Aug 17, 2019

Contributor

Shouldn't this be ARRAYSIZE(missionNames) - 1?
Theoretically you could point to invalid memory if _missionName is "VENG", no?

This comment has been minimized.

Copy link
@digitall

digitall Aug 17, 2019

Member

@mgerhardy : Nice catch. Yes, you are right there. Will commit the suggested fix.
@bluegr : Hope this is OK with you...

if (_vm->_missionName == missionNames[i]) {
_vm->_missionToLoad = missionNames[i + 1];
break;
}
}

_vm->_roomIndexToLoad = 0;
}

Expand Down

0 comments on commit 089c04f

Please sign in to comment.