aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorStrangerke2013-03-24 22:11:52 +0100
committerStrangerke2013-03-24 22:12:50 +0100
commit57abce19b1da832f1f108f6aff22e40649572f97 (patch)
treefe5f35242cef47fb5962503a754595d02a63ac4c /engines
parentb0f0a6cd92d922115916947929060096f91a19d5 (diff)
downloadscummvm-rg350-57abce19b1da832f1f108f6aff22e40649572f97.tar.gz
scummvm-rg350-57abce19b1da832f1f108f6aff22e40649572f97.tar.bz2
scummvm-rg350-57abce19b1da832f1f108f6aff22e40649572f97.zip
HOPKINS: More refactoring of Globals
Diffstat (limited to 'engines')
-rw-r--r--engines/hopkins/globals.cpp6
-rw-r--r--engines/hopkins/globals.h4
-rw-r--r--engines/hopkins/lines.cpp23
-rw-r--r--engines/hopkins/lines.h2
-rw-r--r--engines/hopkins/objects.cpp54
-rw-r--r--engines/hopkins/objects.h2
6 files changed, 46 insertions, 45 deletions
diff --git a/engines/hopkins/globals.cpp b/engines/hopkins/globals.cpp
index eff4c13602..015ebb1561 100644
--- a/engines/hopkins/globals.cpp
+++ b/engines/hopkins/globals.cpp
@@ -94,8 +94,6 @@ Globals::Globals(HopkinsEngine *vm) {
for (int i = 0; i < 36; ++i)
_inventory[i] = 0;
- for (int i = 0; i < 51; ++i)
- Common::fill((byte *)&_sortedDisplay[i], (byte *)&_sortedDisplay[i] + sizeof(SortItem), 0);
// Initialize fields
_language = LANG_EN;
@@ -118,7 +116,6 @@ Globals::Globals(HopkinsEngine *vm) {
_menuMusicOff = 0;
_menuTextOff = 0;
_menuDisplayType = 0;
- _sortedDisplayCount = 0;
_checkDistanceFl = false;
_characterType = 0;
_actionMoveTo = false;
@@ -159,10 +156,7 @@ Globals::Globals(HopkinsEngine *vm) {
_oldRouteFromY = 0;
_oldRouteDestX = 0;
_oldRouteDestY = 0;
- _oldMouseZoneId = 0;
_oldZoneNum = 0;
- _oldMouseX = 0;
- _oldMouseY = 0;
}
Globals::~Globals() {
diff --git a/engines/hopkins/globals.h b/engines/hopkins/globals.h
index 5be467c730..05e563ff40 100644
--- a/engines/hopkins/globals.h
+++ b/engines/hopkins/globals.h
@@ -245,16 +245,12 @@ public:
int _characterMaxPosY;
int _baseMapColor;
int _spriteSize[500];
- int _sortedDisplayCount;
- int _oldMouseZoneId;
- int _oldMouseX, _oldMouseY;
int _characterType;
uint _speed;
byte *_answerBuffer;
Savegame *_saveData;
Language _language;
HopkinsItem _hopkinsItem[70];
- SortItem _sortedDisplay[51];
CreditItem _creditsItem[200];
int _creditsLineNumb;
diff --git a/engines/hopkins/lines.cpp b/engines/hopkins/lines.cpp
index 2cc86bd1dd..33a2c79433 100644
--- a/engines/hopkins/lines.cpp
+++ b/engines/hopkins/lines.cpp
@@ -77,6 +77,9 @@ LinesManager::LinesManager(HopkinsEngine *vm) {
_zoneSkipCount = 0;
_hotspotTextColor = 0;
_forceHideText = false;
+ _oldMouseZoneId = 0;
+ _oldMouseX = 0;
+ _oldMouseY = 0;
}
LinesManager::~LinesManager() {
@@ -2826,9 +2829,9 @@ void LinesManager::checkZone() {
}
if (_vm->_objectsManager->_forceZoneFl) {
_zoneSkipCount = 100;
- _vm->_globals->_oldMouseZoneId = -1;
- _vm->_globals->_oldMouseX = -200;
- _vm->_globals->_oldMouseY = -220;
+ _oldMouseZoneId = -1;
+ _oldMouseX = -200;
+ _oldMouseY = -220;
_vm->_objectsManager->_forceZoneFl = false;
}
@@ -2839,12 +2842,12 @@ void LinesManager::checkZone() {
if (_vm->_globals->_freezeCharacterFl || (_route == (RouteItem *)g_PTRNUL) || _zoneSkipCount > 4) {
_zoneSkipCount = 0;
int zoneId;
- if (_vm->_globals->_oldMouseX != mouseX || _vm->_globals->_oldMouseY != oldMouseY) {
+ if (_oldMouseX != mouseX || _oldMouseY != oldMouseY) {
zoneId = getMouseZone();
} else {
- zoneId = _vm->_globals->_oldMouseZoneId;
+ zoneId = _oldMouseZoneId;
}
- if (_vm->_globals->_oldMouseZoneId != zoneId) {
+ if (_oldMouseZoneId != zoneId) {
_vm->_graphicsManager->SETCOLOR4(251, 100, 100, 100);
_vm->_eventsManager->_mouseCursorId = 4;
_vm->_eventsManager->changeMouseCursor(4);
@@ -2860,7 +2863,7 @@ void LinesManager::checkZone() {
ZONEP[zoneId]._verbFl5 || ZONEP[zoneId]._verbFl6 ||
ZONEP[zoneId]._verbFl7 || ZONEP[zoneId]._verbFl8 ||
ZONEP[zoneId]._verbFl9 || ZONEP[zoneId]._verbFl10) {
- if (_vm->_globals->_oldMouseZoneId != zoneId) {
+ if (_oldMouseZoneId != zoneId) {
_vm->_fontManager->initTextBuffers(5, ZONEP[zoneId]._messageId, _vm->_globals->_zoneFilename, 0, 430, 0, 0, 252);
_vm->_fontManager->showText(5);
_forceHideText = true;
@@ -2883,9 +2886,9 @@ void LinesManager::checkZone() {
}
}
_vm->_objectsManager->_zoneNum = zoneId;
- _vm->_globals->_oldMouseX = mouseX;
- _vm->_globals->_oldMouseY = oldMouseY;
- _vm->_globals->_oldMouseZoneId = zoneId;
+ _oldMouseX = mouseX;
+ _oldMouseY = oldMouseY;
+ _oldMouseZoneId = zoneId;
if (_vm->_globals->_freezeCharacterFl && (_vm->_eventsManager->_mouseCursorId == 4)) {
if (zoneId != -1 && zoneId != 0)
_vm->_objectsManager->handleRightButton();
diff --git a/engines/hopkins/lines.h b/engines/hopkins/lines.h
index 82ad4a37d8..3a4d61555e 100644
--- a/engines/hopkins/lines.h
+++ b/engines/hopkins/lines.h
@@ -123,6 +123,7 @@ private:
int _newRouteIdx;
int _newPosX;
int _newPosY;
+ int _oldMouseX, _oldMouseY;
byte *_largeBuf;
RouteItem *_testRoute0;
@@ -131,6 +132,7 @@ private:
LigneItem _lineItem[400];
RouteItem _bestRoute[8001];
int _zoneSkipCount;
+ int _oldMouseZoneId;
int checkInventoryHotspotsRow(int posX, int minZoneNum, bool lastRow);
void removeZoneLine(int idx);
diff --git a/engines/hopkins/objects.cpp b/engines/hopkins/objects.cpp
index 5bf8342488..27689af6fe 100644
--- a/engines/hopkins/objects.cpp
+++ b/engines/hopkins/objects.cpp
@@ -44,6 +44,10 @@ ObjectsManager::ObjectsManager(HopkinsEngine *vm) {
for (int i = 0; i < 36; ++i)
Common::fill((byte *)&_bob[i], (byte *)&_bob[i] + sizeof(BobItem), 0);
+ _sortedDisplayCount = 0;
+ for (int i = 0; i < 51; ++i)
+ Common::fill((byte *)&_sortedDisplay[i], (byte *)&_sortedDisplay[i] + sizeof(SortItem), 0);
+
_helicopterFl = false;
_priorityFl = false;
_oldBorderPos = Common::Point(0, 0);
@@ -300,7 +304,7 @@ void ObjectsManager::displaySprite() {
uint16 arr[50];
// Handle copying any background areas that text are going to be drawn on
- _vm->_globals->_sortedDisplayCount = 0;
+ _sortedDisplayCount = 0;
for (int idx = 0; idx <= 10; ++idx) {
if (_vm->_fontManager->_textList[idx]._enabledFl && _vm->_fontManager->_text[idx]._textType != 2) {
clipX = _vm->_fontManager->_textList[idx]._pos.x - 2;
@@ -356,64 +360,64 @@ void ObjectsManager::displaySprite() {
checkHidingItem();
}
- if (_priorityFl && _vm->_globals->_sortedDisplayCount) {
+ if (_priorityFl && _sortedDisplayCount) {
for (int i = 1; i <= 48; i++)
arr[i] = i;
do {
loopCondFl = false;
- for (int sortIdx = 1; sortIdx < _vm->_globals->_sortedDisplayCount; sortIdx++) {
- if (_vm->_globals->_sortedDisplay[arr[sortIdx]]._priority > _vm->_globals->_sortedDisplay[arr[sortIdx + 1]]._priority) {
+ for (int sortIdx = 1; sortIdx < _sortedDisplayCount; sortIdx++) {
+ if (_sortedDisplay[arr[sortIdx]]._priority > _sortedDisplay[arr[sortIdx + 1]]._priority) {
SWAP(arr[sortIdx], arr[sortIdx + 1]);
loopCondFl = true;
}
}
} while (loopCondFl);
- for (int sortIdx = 1; sortIdx < _vm->_globals->_sortedDisplayCount + 1; sortIdx++) {
+ for (int sortIdx = 1; sortIdx < _sortedDisplayCount + 1; sortIdx++) {
int idx = arr[sortIdx];
- switch (_vm->_globals->_sortedDisplay[idx]._sortMode) {
+ switch (_sortedDisplay[idx]._sortMode) {
case SORT_BOB:
- setBobInfo(_vm->_globals->_sortedDisplay[idx]._index);
+ setBobInfo(_sortedDisplay[idx]._index);
break;
case SORT_SPRITE:
- DEF_SPRITE(_vm->_globals->_sortedDisplay[idx]._index);
+ DEF_SPRITE(_sortedDisplay[idx]._index);
break;
case SORT_HIDING:
- displayHiding(_vm->_globals->_sortedDisplay[idx]._index);
+ displayHiding(_sortedDisplay[idx]._index);
break;
default:
break;
}
- _vm->_globals->_sortedDisplay[idx]._sortMode = SORT_NONE;
+ _sortedDisplay[idx]._sortMode = SORT_NONE;
}
} else {
- for (int idx = 1; idx < _vm->_globals->_sortedDisplayCount + 1; ++idx) {
- switch (_vm->_globals->_sortedDisplay[idx]._sortMode) {
+ for (int idx = 1; idx < _sortedDisplayCount + 1; ++idx) {
+ switch (_sortedDisplay[idx]._sortMode) {
case SORT_BOB:
- setBobInfo(_vm->_globals->_sortedDisplay[idx]._index);
+ setBobInfo(_sortedDisplay[idx]._index);
break;
case SORT_SPRITE:
- DEF_SPRITE(_vm->_globals->_sortedDisplay[idx]._index);
+ DEF_SPRITE(_sortedDisplay[idx]._index);
break;
case SORT_HIDING:
- displayHiding(_vm->_globals->_sortedDisplay[idx]._index);
+ displayHiding(_sortedDisplay[idx]._index);
break;
default:
break;
}
- _vm->_globals->_sortedDisplay[idx]._sortMode = SORT_NONE;
+ _sortedDisplay[idx]._sortMode = SORT_NONE;
}
}
// Reset the Sort array
for (int idx = 0; idx < 50; ++idx) {
- _vm->_globals->_sortedDisplay[idx]._sortMode = SORT_NONE;
- _vm->_globals->_sortedDisplay[idx]._index = 0;
- _vm->_globals->_sortedDisplay[idx]._priority = 0;
+ _sortedDisplay[idx]._sortMode = SORT_NONE;
+ _sortedDisplay[idx]._index = 0;
+ _sortedDisplay[idx]._priority = 0;
}
- _vm->_globals->_sortedDisplayCount = 0;
+ _sortedDisplayCount = 0;
_vm->_dialogsManager->drawInvent(_oldBorderPos, _oldBorderSpriteIndex, _borderPos, _borderSpriteIndex);
@@ -907,12 +911,12 @@ void ObjectsManager::computeSprite(int idx) {
// Before Sort
void ObjectsManager::beforeSort(SortMode sortMode, int index, int priority) {
- ++_vm->_globals->_sortedDisplayCount;
- assert (_vm->_globals->_sortedDisplayCount <= 48);
+ ++_sortedDisplayCount;
+ assert (_sortedDisplayCount <= 48);
- _vm->_globals->_sortedDisplay[_vm->_globals->_sortedDisplayCount]._sortMode = sortMode;
- _vm->_globals->_sortedDisplay[_vm->_globals->_sortedDisplayCount]._index = index;
- _vm->_globals->_sortedDisplay[_vm->_globals->_sortedDisplayCount]._priority = priority;
+ _sortedDisplay[_sortedDisplayCount]._sortMode = sortMode;
+ _sortedDisplay[_sortedDisplayCount]._index = index;
+ _sortedDisplay[_sortedDisplayCount]._priority = priority;
}
// Display BOB Anim
diff --git a/engines/hopkins/objects.h b/engines/hopkins/objects.h
index 44cd4e723e..80dfb3ad7c 100644
--- a/engines/hopkins/objects.h
+++ b/engines/hopkins/objects.h
@@ -101,6 +101,8 @@ private:
int _curGestureFile;
byte *_gestureBuf;
int _homeRateCounter;
+ int _sortedDisplayCount;
+ SortItem _sortedDisplay[51];
void sprite_alone(const byte *objectData, byte *sprite, int objIndex);
void removeObjectDataBuf();