aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMax Horn2007-09-08 11:18:35 +0000
committerMax Horn2007-09-08 11:18:35 +0000
commitefbef7880b147678f2bf76624988a32a06c1c449 (patch)
treecee439b1f3f2a808307d380a2081605f42e57005 /engines
parent127900b33c8e7c817e9b676064e832192d8e7bc7 (diff)
downloadscummvm-rg350-efbef7880b147678f2bf76624988a32a06c1c449.tar.gz
scummvm-rg350-efbef7880b147678f2bf76624988a32a06c1c449.tar.bz2
scummvm-rg350-efbef7880b147678f2bf76624988a32a06c1c449.zip
Fixed code formatting (hanging braces); added static/const keywords to data tables; merged Hotspot::doLookAt and doLookThrough code
svn-id: r28880
Diffstat (limited to 'engines')
-rw-r--r--engines/lure/disk.cpp3
-rw-r--r--engines/lure/game.cpp15
-rw-r--r--engines/lure/hotspots.cpp124
-rw-r--r--engines/lure/hotspots.h3
-rw-r--r--engines/lure/res_struct.cpp82
-rw-r--r--engines/lure/res_struct.h9
-rw-r--r--engines/lure/scripts.cpp29
-rw-r--r--engines/lure/surface.cpp13
8 files changed, 107 insertions, 171 deletions
diff --git a/engines/lure/disk.cpp b/engines/lure/disk.cpp
index 838bc7df37..b5465df8d9 100644
--- a/engines/lure/disk.cpp
+++ b/engines/lure/disk.cpp
@@ -144,8 +144,7 @@ uint32 Disk::getEntrySize(uint16 id) {
return size;
}
-MemoryBlock *Disk::getEntry(uint16 id)
-{
+MemoryBlock *Disk::getEntry(uint16 id) {
// Special room area check
uint16 tempId = id & 0x3fff;
if ((tempId == 0x120) || (tempId == 0x311) || (tempId == 8) || (tempId == 0x410)) {
diff --git a/engines/lure/game.cpp b/engines/lure/game.cpp
index 110d577386..f3576bb3bd 100644
--- a/engines/lure/game.cpp
+++ b/engines/lure/game.cpp
@@ -374,8 +374,7 @@ void Game::playerChangeRoom() {
}
}
-void Game::displayChuteAnimation()
-{
+void Game::displayChuteAnimation() {
OSystem &system = *g_system;
Resources &res = Resources::getReference();
Screen &screen = Screen::getReference();
@@ -406,8 +405,7 @@ void Game::displayChuteAnimation()
fields.setField(AREA_FLAG, 1);
}
-void Game::displayBarrelAnimation()
-{
+void Game::displayBarrelAnimation() {
OSystem &system = *g_system;
Screen &screen = Screen::getReference();
Mouse &mouse = Mouse::getReference();
@@ -673,8 +671,7 @@ bool Game::GetTellActions() {
--_numTellCommands;
if (_numTellCommands < 0)
paramIndex = -1;
- else
- {
+ else {
paramIndex = 3;
statusLine = statusLinePos[_numTellCommands][paramIndex];
*statusLine = '\0';
@@ -833,14 +830,12 @@ void Game::doAction(Action action, uint16 hotspotId, uint16 usedId) {
room.setCursorState(CS_ACTION);
// Set the action
- if (action == TELL)
- {
+ if (action == TELL) {
// Tell action needs special handling because of the variable length parameter list - add in a
// placeholder entry, and then replace it's details with the TELL command data
player->currentActions().addFront(NONE, player->roomNumber(), 0, 0);
player->currentActions().top().supportData().setDetails2(TELL, _numTellCommands * 3 + 1, &_tellCommands[0]);
- }
- else
+ } else
// All other action types
player->currentActions().addFront(action, player->roomNumber(), hotspotId, usedId);
}
diff --git a/engines/lure/hotspots.cpp b/engines/lure/hotspots.cpp
index f92fd5c6ff..fbd5bc3437 100644
--- a/engines/lure/hotspots.cpp
+++ b/engines/lure/hotspots.cpp
@@ -420,8 +420,7 @@ uint16 Hotspot::nameId() {
return _data->nameId;
}
-const char *Hotspot::getName()
-{
+const char *Hotspot::getName() {
// If name hasn't been loaded yet, then do so
if (!_nameBuffer[0] && (nameId() != 0))
StringData::getReference().getString(nameId(), _nameBuffer);
@@ -844,12 +843,12 @@ void Hotspot::startTalkDialog() {
/* */
/*-------------------------------------------------------------------------*/
-uint16 validRoomExitHotspots[] = {0x2711, 0x2712, 0x2714, 0x2715, 0x2716, 0x2717,
+static const uint16 validRoomExitHotspots[] = {0x2711, 0x2712, 0x2714, 0x2715, 0x2716, 0x2717,
0x2718, 0x2719, 0x271A, 0x271E, 0x271F, 0x2720, 0x2721, 0x2722, 0x2725, 0x2726,
0x2729, 0x272A, 0x272B, 0x272C, 0x272D, 0x272E, 0x272F, 0};
bool Hotspot::isRoomExit(uint16 id) {
- for (uint16 *p = &validRoomExitHotspots[0]; *p != 0; ++p)
+ for (const uint16 *p = &validRoomExitHotspots[0]; *p != 0; ++p)
if (*p == id) return true;
return false;
}
@@ -1155,12 +1154,10 @@ void Hotspot::doAction(Action action, HotspotData *hotspot) {
void Hotspot::doNothing(HotspotData *hotspot) {
_currentActions.pop();
- if (!_currentActions.isEmpty())
- {
+ if (!_currentActions.isEmpty()) {
setBlockedFlag(false);
currentActions().top().setAction(DISPATCH_ACTION);
- }
- else if (hotspotId() == PLAYER_ID) {
+ } else if (hotspotId() == PLAYER_ID) {
Room::getReference().setCursorState(CS_NONE);
}
}
@@ -1520,59 +1517,32 @@ void Hotspot::doLook(HotspotData *hotspot) {
Dialog::show(Room::getReference().descId());
}
-uint16 hotspotLookAtList[] = {0x411, 0x412, 0x41F, 0x420, 0x421, 0x422, 0x426,
+static const uint16 hotspotLookAtList[] = {0x411, 0x412, 0x41F, 0x420, 0x421, 0x422, 0x426,
0x427, 0x428, 0x429, 0x436, 0x437, 0};
void Hotspot::doLookAt(HotspotData *hotspot) {
- Resources &res = Resources::getReference();
- uint16 sequenceOffset = res.getHotspotAction(hotspot->actionsOffset, LOOK_AT);
-
- if (hotspot->hotspotId >= FIRST_NONCHARACTER_ID) {
- // Check if the hotspot appears in the list of hotspots that don't
- // need to be walked to before being looked at
- uint16 *tempId = &hotspotLookAtList[0];
- while ((*tempId != 0) && (*tempId != hotspot->hotspotId)) ++tempId;
- if (!*tempId) {
- // Hotspot wasn't in the list
- HotspotPrecheckResult result = actionPrecheck(hotspot);
- if (result == PC_WAIT) return;
- else if (result != PC_EXECUTE) {
- endAction();
- return;
- }
- }
- }
-
- faceHotspot(hotspot);
- setActionCtr(0);
- endAction();
-
- if (sequenceOffset >= 0x8000) {
- showMessage(sequenceOffset);
- } else {
- if (sequenceOffset != 0)
- sequenceOffset = Script::execute(sequenceOffset);
-
- if (sequenceOffset == 0) {
- uint16 descId = (hotspot->descId2 != 0) ? hotspot->descId2 : hotspot->descId;
- Dialog::show(descId);
- }
- }
+ doLookAction(hotspot, LOOK_AT);
}
void Hotspot::doLookThrough(HotspotData *hotspot) {
+ doLookAction(hotspot, LOOK_THROUGH);
+}
+
+void Hotspot::doLookAction(HotspotData *hotspot, Action action) {
Resources &res = Resources::getReference();
- uint16 sequenceOffset = res.getHotspotAction(hotspot->actionsOffset, LOOK_THROUGH);
+ uint16 sequenceOffset = res.getHotspotAction(hotspot->actionsOffset, action);
if (hotspot->hotspotId >= FIRST_NONCHARACTER_ID) {
// Check if the hotspot appears in the list of hotspots that don't
// need to be walked to before being looked at
- uint16 *tempId = &hotspotLookAtList[0];
- while ((*tempId != 0) && (*tempId != hotspot->hotspotId)) ++tempId;
+ const uint16 *tempId = &hotspotLookAtList[0];
+ while ((*tempId != 0) && (*tempId != hotspot->hotspotId))
+ ++tempId;
if (!*tempId) {
// Hotspot wasn't in the list
HotspotPrecheckResult result = actionPrecheck(hotspot);
- if (result == PC_WAIT) return;
+ if (result == PC_WAIT)
+ return;
else if (result != PC_EXECUTE) {
endAction();
return;
@@ -1735,7 +1705,7 @@ void Hotspot::doReturn(HotspotData *hotspot) {
endAction();
}
-uint16 bribe_hotspot_list[] = {0x421, 0x879, 0x3E9, 0x8C7, 0x429, 0x8D1,
+static const uint16 bribe_hotspot_list[] = {0x421, 0x879, 0x3E9, 0x8C7, 0x429, 0x8D1,
0x422, 0x8D4, 0x420, 0x8D6, 0x42B, 0x956, 0x3F2, 0xBE6, 0};
void Hotspot::doBribe(HotspotData *hotspot) {
@@ -1751,7 +1721,7 @@ void Hotspot::doBribe(HotspotData *hotspot) {
return;
}
- uint16 *tempId = &bribe_hotspot_list[0];
+ const uint16 *tempId = &bribe_hotspot_list[0];
uint16 sequenceOffset = 0x14B; // Default sequence offset
while (*tempId != 0) {
if (*tempId++ == hotspotId()) {
@@ -2044,8 +2014,7 @@ uint16 Hotspot::getTalkId(HotspotData *charHotspot) {
TalkHeaderData *headerEntry;
// If the hotspot has a talk data override, return it
- if (charHotspot->talkOverride != 0)
- {
+ if (charHotspot->talkOverride != 0) {
// Has an override, so return it and reset back to zero
uint16 result = charHotspot->talkOverride;
charHotspot->talkOverride = 0;
@@ -2513,8 +2482,7 @@ void HotspotTickHandlers::standardCharacterAnimHandler(Hotspot &h) {
// Increment the blocked state
h.setBlockedState((BlockedState) ((int) h.blockedState() + 1));
- if (!h.blockedFlag())
- {
+ if (!h.blockedFlag()) {
// Not already handling blocked, so add a new dummy action so that the new
// action set below will not replace the existing one
h.currentActions().addFront(DISPATCH_ACTION, 0);
@@ -2892,7 +2860,7 @@ void HotspotTickHandlers::followerAnimHandler(Hotspot &h) {
h.currentActions().addFront(DISPATCH_ACTION, player->roomNumber());
else {
// Scan through the translation list for an alternate destination room
- RoomTranslationRecord *p = &roomTranslations[0];
+ const RoomTranslationRecord *p = &roomTranslations[0];
while ((p->srcRoom != 0) && (p->srcRoom != player->roomNumber()))
++p;
h.currentActions().addFront(DISPATCH_ACTION,
@@ -3013,12 +2981,9 @@ void HotspotTickHandlers::droppingTorchAnimHandler(Hotspot &h) {
}
void HotspotTickHandlers::playerSewerExitAnimHandler(Hotspot &h) {
- if (h.frameCtr() > 0)
- {
+ if (h.frameCtr() > 0) {
h.decrFrameCtr();
- }
- else if (h.executeScript())
- {
+ } else if (h.executeScript()) {
Resources &res = Resources::getReference();
// Deactive the dropping animation
@@ -3521,7 +3486,7 @@ void HotspotTickHandlers::barmanAnimHandler(Hotspot &h) {
// All other actions
uint16 xp, id;
- uint16 *frameList;
+ const uint16 *frameList;
uint16 frameNumber;
BarmanAction action = (BarmanAction) (h.frameCtr() & 0x3F);
@@ -3555,12 +3520,10 @@ void HotspotTickHandlers::barmanAnimHandler(Hotspot &h) {
HotspotData *gwyn = res.getHotspot(GOEWIN_ID);
HotspotData *wayne = res.getHotspot(WAYNE_ID);
- if ((player->roomNumber != 35) && (gwyn->roomNumber != 35) && (wayne->roomNumber != 35))
- {
+ if ((player->roomNumber != 35) && (gwyn->roomNumber != 35) && (wayne->roomNumber != 35)) {
if (rnd.getRandomNumber(1) == 1)
id = BG_EXTRA1 << 8;
- else
- {
+ else {
// Set up alternate animation
h.setWidth(32);
h.setAnimation(EWAN_ALT_ANIM_ID);
@@ -3581,15 +3544,13 @@ void HotspotTickHandlers::barmanAnimHandler(Hotspot &h) {
frameList = barEntry.graphics[h.supportValue() >> 8];
frameNumber = frameList[h.supportValue() & 0xff];
- if (frameNumber != 0)
- {
+ if (frameNumber != 0) {
h.setActionCtr(frameNumber);
h.setFrameNumber(frameNumber);
return;
}
- if (h.hotspotId() == EWAN_ID)
- {
+ if (h.hotspotId() == EWAN_ID) {
// Make sure Ewan is back to his standard animation
h.setWidth(16);
h.setAnimation(EWAN_ANIM_ID);
@@ -4298,16 +4259,13 @@ void CurrentActionEntry::saveToStream(WriteStream *stream) {
if (hasSupportData()) {
// Handle the support data
stream->writeByte(_dynamicSupportData);
- if (_dynamicSupportData)
- {
+ if (_dynamicSupportData) {
// Write out the dynamic data
stream->writeByte(supportData().action());
stream->writeSint16LE(supportData().numParams());
for (int index = 0; index < supportData().numParams(); ++index)
stream->writeUint16LE(supportData().param(index));
- }
- else
- {
+ } else {
// Write out the Id for the static entry
stream->writeSint16LE(supportData().id());
}
@@ -4331,8 +4289,7 @@ CurrentActionEntry *CurrentActionEntry::loadFromStream(ReadStream *stream) {
} else {
// Handle support data for the entry
bool dynamicData = stream->readByte() != 0;
- if (dynamicData)
- {
+ if (dynamicData) {
// Load action entry that has dynamic data
result = new CurrentActionEntry(
(CurrentAction) actionNum, roomNumber);
@@ -4345,9 +4302,7 @@ CurrentActionEntry *CurrentActionEntry::loadFromStream(ReadStream *stream) {
result->_supportData->setDetails2(action, numParams, paramList);
delete paramList;
- }
- else
- {
+ } else {
// Load action entry with an NPC schedule entry
uint16 entryId = stream->readUint16LE();
CharacterScheduleEntry *entry = res.charSchedules().getEntry(entryId);
@@ -4431,8 +4386,7 @@ void CurrentActionStack::saveToStream(WriteStream *stream) {
list(buffer);
debugC(ERROR_DETAILED, kLureDebugAnimations, "%s", buffer);
- for (i = _actions.begin(); i != _actions.end(); ++i)
- {
+ for (i = _actions.begin(); i != _actions.end(); ++i) {
CurrentActionEntry *rec = *i;
rec->saveToStream(stream);
}
@@ -4590,8 +4544,7 @@ bool Support::isCharacterInList(uint16 *lst, int numEntries, uint16 charId) {
void HotspotList::saveToStream(WriteStream *stream) {
HotspotList::iterator i;
- for (i = begin(); i != end(); ++i)
- {
+ for (i = begin(); i != end(); ++i) {
Hotspot *hotspot = *i;
debugC(ERROR_INTERMEDIATE, kLureDebugAnimations, "Saving hotspot %xh", hotspot->hotspotId());
bool dynamicObject = hotspot->hotspotId() != hotspot->originalId();
@@ -4611,8 +4564,7 @@ void HotspotList::loadFromStream(ReadStream *stream) {
clear();
uint16 hotspotId = stream->readUint16LE();
- while (hotspotId != 0)
- {
+ while (hotspotId != 0) {
debugC(ERROR_INTERMEDIATE, kLureDebugAnimations, "Loading hotspot %xh", hotspotId);
bool dynamicObject = stream->readByte() != 0;
uint16 destHotspotId = stream->readUint16LE();
@@ -4622,9 +4574,7 @@ void HotspotList::loadFromStream(ReadStream *stream) {
Hotspot *destHotspot = res.getActiveHotspot(destHotspotId);
assert(destHotspot);
hotspot = new Hotspot(destHotspot, hotspotId);
- }
- else
- {
+ } else {
HotspotData *hotspotData = res.getHotspot(hotspotId);
assert(hotspotData);
hotspot = new Hotspot(hotspotData);
diff --git a/engines/lure/hotspots.h b/engines/lure/hotspots.h
index 96a02be2a7..c30faa58c5 100644
--- a/engines/lure/hotspots.h
+++ b/engines/lure/hotspots.h
@@ -342,6 +342,9 @@ private:
void npcPause(HotspotData *hotspot);
void npcStartTalking(HotspotData *hotspot);
void npcJumpAddress(HotspotData *hotspot);
+
+ // Auxillaries
+ void doLookAction(HotspotData *hotspot, Action action);
public:
Hotspot(HotspotData *res);
Hotspot(Hotspot *character, uint16 objType);
diff --git a/engines/lure/res_struct.cpp b/engines/lure/res_struct.cpp
index 3ccd14f99c..f4506406ef 100644
--- a/engines/lure/res_struct.cpp
+++ b/engines/lure/res_struct.cpp
@@ -30,47 +30,47 @@
namespace Lure {
-const Action sortedActions[] = {ASK, BRIBE, BUY, CLOSE, DRINK, EXAMINE, GET, GIVE,
+extern const Action sortedActions[] = {ASK, BRIBE, BUY, CLOSE, DRINK, EXAMINE, GET, GIVE,
GO_TO, LOCK, LOOK, LOOK_AT, LOOK_THROUGH, OPEN, OPERATE, PULL, PUSH, RETURN,
STATUS, TALK_TO, TELL, UNLOCK, USE, NONE};
-int actionNumParams[NPC_JUMP_ADDRESS+1] = {0,
+extern const int actionNumParams[NPC_JUMP_ADDRESS+1] = {0,
1, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 2, 0, 1,
0, 1, 1, 1, 1, 0, 0, 2, 1, 1, 0, 0, 1, 1, 2, 2, 5, 2, 2, 1};
// Barman related frame lists
-uint16 basicPolish[] = {8+13,8+14,8+15,8+16,8+17,8+18,8+17,8+16,8+15,8+14,
+static const uint16 basicPolish[] = {8+13,8+14,8+15,8+16,8+17,8+18,8+17,8+16,8+15,8+14,
8+15,8+16,8+17,8+18,8+17,8+16,8+15,8+14,8+13,0};
-uint16 sidsFetch[] = {12+1,12+2,12+3,12+4,12+5,12+6,12+5,12+6,12+5,12+4,12+3,12+7,12+8,0};
+static const uint16 sidsFetch[] = {12+1,12+2,12+3,12+4,12+5,12+6,12+5,12+6,12+5,12+4,12+3,12+7,12+8,0};
-uint16 nelliesScratch[] = {11+1,11+2,11+3,11+4,11+5,11+4,11+5,11+4,11+5,11+4,11+3,11+2,11+1,0};
+static const uint16 nelliesScratch[] = {11+1,11+2,11+3,11+4,11+5,11+4,11+5,11+4,11+5,11+4,11+3,11+2,11+1,0};
-uint16 nelliesFetch[] = {1,2,3,4,5,4,5,4,3,2,6,7,0};
+static const uint16 nelliesFetch[] = {1,2,3,4,5,4,5,4,3,2,6,7,0};
-uint16 ewansFetch[] = {13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,0};
+static const uint16 ewansFetch[] = {13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,0};
-uint16 ewanExtraGraphic1[]= {
+static const uint16 ewanExtraGraphic1[]= {
28,29,30,31,32,33,34,35,36,37,
38,39,40,41,42,43,44,45,46,47,
48,
40,39,38,37,36,35,34,33,32,31,30,29,28,
0};
-uint16 ewanExtraGraphic2[] = {
+static const uint16 ewanExtraGraphic2[] = {
1,2,3,4,5,6,7,8,9,
10,11,12,13,14,15,16,17,18,19,
20,21,22,23,24,0};
-BarEntry barList[3] = {
+static const BarEntry default_barList[3] = {
{29, SID_ID, {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, {&basicPolish[0], &sidsFetch[0], NULL, NULL}, 13, NULL},
{32, NELLIE_ID, {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, {&nelliesScratch[0], &nelliesFetch[0], NULL, NULL}, 14, NULL},
{35, EWAN_ID, {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, {&ewansFetch[0], &ewansFetch[0],
&ewanExtraGraphic1[0], &ewanExtraGraphic2[0]}, 16, NULL}
};
-RoomTranslationRecord roomTranslations[] = {
+extern const RoomTranslationRecord roomTranslations[] = {
{0x1E, 0x13}, {0x07, 0x08}, {0x1C, 0x12}, {0x26, 0x0F},
{0x27, 0x0F}, {0x28, 0x0F}, {0x29, 0x0F}, {0x22, 0x0A},
{0x23, 0x13}, {0x24, 0x14}, {0x31, 0x2C}, {0x2F, 0x2C},
@@ -521,8 +521,7 @@ void HotspotData::loadFromStream(ReadStream *stream) {
void HotspotDataList::saveToStream(WriteStream *stream) {
iterator i;
- for (i = begin(); i != end(); ++i)
- {
+ for (i = begin(); i != end(); ++i) {
HotspotData *hotspot = *i;
stream->writeUint16LE(hotspot->hotspotId);
hotspot->saveToStream(stream);
@@ -534,8 +533,7 @@ void HotspotDataList::loadFromStream(ReadStream *stream) {
Resources &res = Resources::getReference();
iterator i;
uint16 hotspotId = stream->readUint16LE();
- while (hotspotId != 0)
- {
+ while (hotspotId != 0) {
HotspotData *hotspot = res.getHotspot(hotspotId);
assert(hotspot);
hotspot->loadFromStream(stream);
@@ -967,8 +965,7 @@ RandomActionSet::~RandomActionSet() {
RandomActionSet *RandomActionList::getRoom(uint16 roomNumber) {
iterator i;
- for (i = begin(); i != end(); ++i)
- {
+ for (i = begin(); i != end(); ++i) {
RandomActionSet *v = *i;
if (v->roomNumber() == roomNumber)
return v;
@@ -1108,8 +1105,7 @@ int PausedCharacterList::check(uint16 charId, int numImpinging, uint16 *impingin
// There was, so move to next impinging character entry
continue;
- if ((hotspot->hotspotId() == PLAYER_ID) && !hotspot->coveredFlag())
- {
+ if ((hotspot->hotspotId() == PLAYER_ID) && !hotspot->coveredFlag()) {
hotspot->updateMovement();
return 1;
}
@@ -1141,39 +1137,37 @@ int PausedCharacterList::check(uint16 charId, int numImpinging, uint16 *impingin
// Wrapper class for the barman lists
-BarEntry &BarmanLists::getDetails(uint16 roomNumber)
-{
+BarmanLists::BarmanLists() {
+ for (int index = 0; index < 3; ++index)
+ _barList[index] = default_barList[index];
+}
+
+BarEntry &BarmanLists::getDetails(uint16 roomNumber) {
for (int index = 0; index < 3; ++index)
- if (barList[index].roomNumber == roomNumber)
- return barList[index];
+ if (_barList[index].roomNumber == roomNumber)
+ return _barList[index];
error("Invalid room %d specified for barman details retrieval", roomNumber);
}
-void BarmanLists::saveToStream(Common::WriteStream *stream)
-{
- for (int index = 0; index < 2; ++index)
- {
- uint16 value = (barList[index].currentCustomer - &barList[index].customers[0]) / sizeof(BarEntry);
+void BarmanLists::saveToStream(Common::WriteStream *stream) {
+ for (int index = 0; index < 2; ++index) {
+ uint16 value = (_barList[index].currentCustomer - &_barList[index].customers[0]) / sizeof(BarEntry);
stream->writeUint16LE(value);
- for (int ctr = 0; ctr < NUM_SERVE_CUSTOMERS; ++ctr)
- {
- stream->writeUint16LE(barList[index].customers[ctr].hotspotId);
- stream->writeByte(barList[index].customers[ctr].serveFlags);
+ for (int ctr = 0; ctr < NUM_SERVE_CUSTOMERS; ++ctr) {
+ stream->writeUint16LE(_barList[index].customers[ctr].hotspotId);
+ stream->writeByte(_barList[index].customers[ctr].serveFlags);
}
}
}
-void BarmanLists::loadFromStream(Common::ReadStream *stream)
-{
- for (int index = 0; index < 2; ++index)
- {
+void BarmanLists::loadFromStream(Common::ReadStream *stream) {
+ for (int index = 0; index < 2; ++index) {
int16 value = stream->readUint16LE();
- barList[index].currentCustomer = (value == 0) ? NULL : &barList[index].customers[value];
+ _barList[index].currentCustomer = (value == 0) ? NULL : &_barList[index].customers[value];
- for (int ctr = 0; ctr < NUM_SERVE_CUSTOMERS; ++ctr)
- {
- barList[index].customers[ctr].hotspotId = stream->readUint16LE();
- barList[index].customers[ctr].serveFlags = stream->readByte();
+ for (int ctr = 0; ctr < NUM_SERVE_CUSTOMERS; ++ctr) {
+ _barList[index].customers[ctr].hotspotId = stream->readUint16LE();
+ _barList[index].customers[ctr].serveFlags = stream->readByte();
}
}
}
@@ -1250,8 +1244,7 @@ void ValueTableData::setField(FieldName fieldName, uint16 value) {
setField((uint16) fieldName, value);
}
-void ValueTableData::saveToStream(Common::WriteStream *stream)
-{
+void ValueTableData::saveToStream(Common::WriteStream *stream) {
// Write out the special fields
stream->writeUint16LE(_numGroats);
stream->writeSint16LE(_playerNewPos.position.x);
@@ -1265,8 +1258,7 @@ void ValueTableData::saveToStream(Common::WriteStream *stream)
stream->writeUint16LE(_fieldList[index]);
}
-void ValueTableData::loadFromStream(Common::ReadStream *stream)
-{
+void ValueTableData::loadFromStream(Common::ReadStream *stream) {
// Load special fields
_numGroats = stream->readUint16LE();
_playerNewPos.position.x = stream->readSint16LE();
diff --git a/engines/lure/res_struct.h b/engines/lure/res_struct.h
index d5b80439cc..f6c1966a93 100644
--- a/engines/lure/res_struct.h
+++ b/engines/lure/res_struct.h
@@ -629,7 +629,7 @@ public:
// The following classes holds the data for NPC schedules
-extern int actionNumParams[NPC_JUMP_ADDRESS+1];
+extern const int actionNumParams[NPC_JUMP_ADDRESS+1];
class CharacterScheduleSet;
@@ -741,13 +741,16 @@ struct BarEntry {
uint16 roomNumber;
uint16 barmanId;
ServeEntry customers[NUM_SERVE_CUSTOMERS];
- uint16 *graphics[4];
+ const uint16 *graphics[4];
uint16 gridLine;
ServeEntry *currentCustomer;
};
class BarmanLists {
+ BarEntry _barList[3];
public:
+ BarmanLists();
+
BarEntry &getDetails(uint16 roomNumber);
void saveToStream(Common::WriteStream *stream);
void loadFromStream(Common::ReadStream *stream);
@@ -760,7 +763,7 @@ struct RoomTranslationRecord {
uint8 destRoom;
};
-extern RoomTranslationRecord roomTranslations[];
+extern const RoomTranslationRecord roomTranslations[];
enum StringEnum {S_CREDITS = 25, S_RESTART_GAME = 26, S_SAVE_GAME = 27, S_RESTORE_GAME = 28,
S_QUIT = 29, S_FAST_TEXT = 30, S_SLOW_TEXT = 31, S_SOUND_ON = 32, S_SOUND_OFF = 33,
diff --git a/engines/lure/scripts.cpp b/engines/lure/scripts.cpp
index 68714da526..f24e5c301f 100644
--- a/engines/lure/scripts.cpp
+++ b/engines/lure/scripts.cpp
@@ -38,12 +38,12 @@ namespace Lure {
// This list of hotspot Ids are used by sequence method #5 to deallocate a set
// of hotspot Ids at once
-uint16 dealloc_list_1[] = {0x13F2, 0x418, 0x2711, 0x2712, 0x40D, 0x3EA, 0x411, 0};
-uint16 dealloc_list_2[] = {0x2729, 0x272A, 0x272B, 0x272C, 0x272E, 0x272E, 0x272F, 0};
-uint16 dealloc_list_3[] = {0x3EF, 0x3E9, 0x3EB, 0x3EC, 0x3ED, 0x3EE, 0x3F0, 0x3F1,
+static const uint16 dealloc_list_1[] = {0x13F2, 0x418, 0x2711, 0x2712, 0x40D, 0x3EA, 0x411, 0};
+static const uint16 dealloc_list_2[] = {0x2729, 0x272A, 0x272B, 0x272C, 0x272E, 0x272E, 0x272F, 0};
+static const uint16 dealloc_list_3[] = {0x3EF, 0x3E9, 0x3EB, 0x3EC, 0x3ED, 0x3EE, 0x3F0, 0x3F1,
0x420, 0x429, 0x436, 0x2715, 0x2716, 0x2717, 0x2718, 0x2719, 0x271A, 0x271E,
0x271F, 0x2720, 0x2721, 0x2722, 0x2725, 0x2726, 0};
-uint16 *hotspot_dealloc_set[4] = {&dealloc_list_1[0], &dealloc_list_2[0],
+static const uint16 *hotspot_dealloc_set[4] = {&dealloc_list_1[0], &dealloc_list_2[0],
&dealloc_list_3[1], &dealloc_list_3[0]};
/*------------------------------------------------------------------------*/
@@ -99,7 +99,7 @@ void Script::deactivateHotspotSet(uint16 listIndex, uint16 v2, uint16 v3) {
if (listIndex > 3)
error("Script::deactiveHotspotSet - Invalid list index");
Resources &res = Resources::getReference();
- uint16 *hotspotId = hotspot_dealloc_set[listIndex];
+ const uint16 *hotspotId = hotspot_dealloc_set[listIndex];
while (*hotspotId != 0) {
res.deactivateHotspot(*hotspotId);
@@ -276,8 +276,7 @@ void Script::isSkorlInCell(uint16 v1, uint16 v2, uint16 v3) {
// Called by the script when Ratpouch is pushing the bricks in the Outer Cell
-void Script::ratpouchPushBricks(uint16 v1, uint16 v2, uint16 v3)
-{
+void Script::ratpouchPushBricks(uint16 v1, uint16 v2, uint16 v3) {
Resources &res = Resources::getReference();
// Mark the bricks exit as now open
@@ -308,8 +307,7 @@ void Script::characterChangeRoom(uint16 y, uint16 x, uint16 roomNumber) {
// Pauses Ratpouch for a long period (as good as idefinite)
-void Script::pauseRatpouch(uint16 v1, uint16 v2, uint16 v3)
-{
+void Script::pauseRatpouch(uint16 v1, uint16 v2, uint16 v3) {
Resources &res = Resources::getReference();
Hotspot *ratpouch = res.getActiveHotspot(RATPOUCH_ID);
assert(ratpouch);
@@ -598,7 +596,7 @@ void Script::moveCharacterToPlayer(uint16 characterId, uint16 v2, uint16 v3) {
return;
uint16 destRoom = playerHotspot->roomNumber();
- RoomTranslationRecord *rec;
+ const RoomTranslationRecord *rec;
for (rec = &roomTranslations[0]; rec->srcRoom != 0; ++rec) {
if (rec->srcRoom == destRoom) {
destRoom = rec->destRoom;
@@ -739,7 +737,7 @@ struct SequenceMethodRecord {
SequenceMethodPtr proc;
};
-SequenceMethodRecord scriptMethods[] = {
+static const SequenceMethodRecord scriptMethods[] = {
{0, Script::activateHotspot},
{1, Script::setHotspotScript},
{2, Script::addSound2},
@@ -809,14 +807,14 @@ SequenceMethodRecord scriptMethods[] = {
{66, Script::checkSound},
{0xff, NULL}};
-const char *scriptOpcodes[] = {
+static const char *scriptOpcodes[] = {
"ABORT", "ADD", "SUBTRACT", "MULTIPLY", "DIVIDE", "EQUALS", "NOT_EQUALS",
"LT", "GT", "LTE", "GTE", "AND", "OR", "LOGICAL_AND", "LOGICAL_OR",
"GET_FIELD", "SET_FIELD", "PUSH", "SUBROUTINE", "EXEC", "END",
"COND_JUMP", "JUMP", "ABORT2", "ABORT3", "RANDOM"
};
-const char *scriptMethodNames[67] = {
+static const char *scriptMethodNames[67] = {
"ACTIVATE HOTSPOT", "SET HOTSPOT SCRIPT", "ADD SOUND 2", "SET HOTSPOT FLAG MASK",
"CLEAR SEQUENCE DELAY LIST", "DEACTIVATE HOTSPOT SET", "DEACTIVATE HOTSPOT",
"RESET PATHFINDER", "ADD DELAYED SCRIPT", "KILL SOUND",
@@ -865,7 +863,7 @@ uint16 Script::execute(uint16 startOffset) {
uint16 fieldNum;
uint32 tempVal;
SequenceMethodPtr ptr;
- SequenceMethodRecord *rec;
+ const SequenceMethodRecord *rec;
char debugInfo[MAX_DESC_SIZE];
uint16 offset = startOffset;
@@ -1157,8 +1155,7 @@ int16 HotspotScript::nextVal(MemoryBlock *data, uint16 &offset) {
return value;
}
-bool HotspotScript::execute(Hotspot *h)
-{
+bool HotspotScript::execute(Hotspot *h) {
Resources &r = Resources::getReference();
Room &room = Room::getReference();
MemoryBlock *scriptData = r.hotspotScriptData();
diff --git a/engines/lure/surface.cpp b/engines/lure/surface.cpp
index c179e1420d..005b1b08c4 100644
--- a/engines/lure/surface.cpp
+++ b/engines/lure/surface.cpp
@@ -51,8 +51,7 @@ void Surface::initialise() {
byte *pChar = int_font->data() + (ctr * 8);
fontSize[ctr] = 0;
- for (int yp = 0; yp < FONT_HEIGHT; ++yp)
- {
+ for (int yp = 0; yp < FONT_HEIGHT; ++yp) {
byte v = *pChar++;
for (int xp = 0; xp < FONT_WIDTH; ++xp) {
@@ -156,13 +155,11 @@ void Surface::transparentCopyTo(Surface *dest) {
}
}
-void Surface::copyTo(Surface *dest)
-{
+void Surface::copyTo(Surface *dest) {
copyTo(dest, 0, 0);
}
-void Surface::copyTo(Surface *dest, uint16 x, uint16 y)
-{
+void Surface::copyTo(Surface *dest, uint16 x, uint16 y) {
if ((x == 0) && (dest->width() == _width)) {
// Use fast data transfer
uint32 dataSize = dest->data().size() - (y * _width);
@@ -790,7 +787,7 @@ struct RestartRecord {
RestartRecordPos BtnRestore;
};
-RestartRecord buttonBounds[] = {
+static const RestartRecord buttonBounds[] = {
{ EN_ANY, 48, 14, { 118, 152 }, { 168, 152 } },
{ DE_DEU, 48, 14, { 106, 152 }, { 168, 152 } },
{ UNK_LANG, 48, 14, { 112, 152 }, { 168, 152 } }
@@ -817,7 +814,7 @@ bool RestartRestoreDialog::show() {
Memory::dealloc(firstSave);
// Get the correct button bounds record to use
- RestartRecord *btnRecord = &buttonBounds[0];
+ const RestartRecord *btnRecord = &buttonBounds[0];
while ((btnRecord->Language != engine.getLanguage()) &&
(btnRecord->Language != UNK_LANG))
++btnRecord;