HOPKINS: Get rid of magic values

This commit is contained in:
Strangerke 2013-05-06 08:21:50 +02:00
parent 3d5b975c37
commit b1dce29ee8
6 changed files with 30 additions and 31 deletions

View File

@ -89,7 +89,7 @@ Globals::Globals(HopkinsEngine *vm) {
_menuTextOff = 0;
_menuDisplayType = 0;
_checkDistanceFl = false;
_characterType = 0;
_characterType = CHARACTER_HOPKINS;
_actionMoveTo = false;
_actionDirection = DIR_NONE;
@ -185,7 +185,7 @@ void Globals::clearAll() {
}
void Globals::loadCharacterData() {
assert(_characterType >= 0 && _characterType <= 2);
assert(_characterType >= CHARACTER_HOPKINS && _characterType <= CHARACTER_SAMANTHA);
const int *srcList[] = { HOPKINS_PERSO_0, HOPKINS_PERSO_1, HOPKINS_PERSO_2 };
const int *srcP = srcList[_characterType];

View File

@ -172,7 +172,7 @@ public:
int _characterMaxPosY;
int _baseMapColor;
int _spriteSize[500];
int _characterType;
PlayerCharacter _characterType;
uint _speed;
byte *_answerBuffer;
Savegame *_saveData;

View File

@ -172,7 +172,7 @@ bool HopkinsEngine::runWin95Demo() {
_globals->_characterSpriteBuf = _fileIO->loadFile("PERSO.SPR");
}
_globals->_characterType = 0;
_globals->_characterType = CHARACTER_HOPKINS;
_objectsMan->_mapCarPosX = _objectsMan->_mapCarPosY = 0;
memset(_globals->_saveData, 0, 2000);
_globals->_exitId = 0;
@ -453,7 +453,7 @@ bool HopkinsEngine::runLinuxDemo() {
_globals->_eventMode = EVENTMODE_DEFAULT;
_globals->_characterSpriteBuf = _fileIO->loadFile("PERSO.SPR");
_globals->_characterType = 0;
_globals->_characterType = CHARACTER_HOPKINS;
_objectsMan->_mapCarPosX = _objectsMan->_mapCarPosY = 0;
memset(_globals->_saveData, 0, 2000);
_globals->_exitId = 0;
@ -813,7 +813,7 @@ bool HopkinsEngine::runFull() {
}
_globals->_eventMode = EVENTMODE_DEFAULT;
_globals->_characterSpriteBuf = _fileIO->loadFile("PERSO.SPR");
_globals->_characterType = 0;
_globals->_characterType = CHARACTER_HOPKINS;
_objectsMan->_mapCarPosX = _objectsMan->_mapCarPosY = 0;
memset(_globals->_saveData, 0, 2000);
@ -1525,7 +1525,7 @@ bool HopkinsEngine::runFull() {
//_globals->_exitId = WBASE(); // Handles the 3D Doom level (Windows)
_soundMan->stopSound();
_globals->_characterSpriteBuf = _fileIO->loadFile("PERSO.SPR");
_globals->_characterType = 0;
_globals->_characterType = CHARACTER_HOPKINS;
_globals->_eventMode = EVENTMODE_DEFAULT;
_graphicsMan->_lineNbr = SCREEN_WIDTH;
break;
@ -2177,7 +2177,7 @@ void HopkinsEngine::playEnding() {
_globals->_exitId = 300;
}
_globals->_characterSpriteBuf = _fileIO->loadFile("PERSO.SPR");
_globals->_characterType = 0;
_globals->_characterType = CHARACTER_HOPKINS;
_globals->_eventMode = EVENTMODE_DEFAULT;
}
@ -2819,7 +2819,7 @@ void HopkinsEngine::handleOceanMaze(int16 curExitId, Common::String backgroundFi
_objectsMan->removeSprite(0);
_objectsMan->clearScreen();
_globals->_characterSpriteBuf = _fileIO->loadFile("PERSO.SPR");
_globals->_characterType = 0;
_globals->_characterType = CHARACTER_HOPKINS;
}
void HopkinsEngine::syncSoundSettings() {

View File

@ -2481,11 +2481,11 @@ int LinesManager::testLine(int paramX, int paramY, int *testValue, int *foundLin
int LinesManager::computeYSteps(int idx) {
int zoomPct = _vm->_globals->_spriteSize[idx];
if (_vm->_globals->_characterType == 1) {
if (_vm->_globals->_characterType == CHARACTER_HOPKINS_CLONE) {
if (zoomPct < 0)
zoomPct = -zoomPct;
zoomPct = 20 * (5 * zoomPct - 100) / -80;
} else if (_vm->_globals->_characterType == 2) {
} else if (_vm->_globals->_characterType == CHARACTER_SAMANTHA) {
if (zoomPct < 0)
zoomPct = -zoomPct;
zoomPct = 20 * (5 * zoomPct - 165) / -67;

View File

@ -2199,7 +2199,7 @@ void ObjectsManager::changeCharacterHead(PlayerCharacter oldCharacter, PlayerCha
loc = &_vm->_globals->_saveData->_realHopkins;
_vm->_globals->_characterSpriteBuf = _vm->_fileIO->loadFile("PERSO.SPR");
_vm->_globals->_characterType = 0;
_vm->_globals->_characterType = CHARACTER_HOPKINS;
addStaticSprite(_vm->_globals->_characterSpriteBuf, loc->_pos, 0, 64, loc->_zoomFactor, false, 34, 190);
animateSprite(0);
_vm->_globals->loadCharacterData();
@ -2224,7 +2224,7 @@ void ObjectsManager::changeCharacterHead(PlayerCharacter oldCharacter, PlayerCha
loc = &_vm->_globals->_saveData->_samantha;
_vm->_globals->_characterSpriteBuf = _vm->_fileIO->loadFile("PSAMAN.SPR");
_vm->_globals->_characterType = 2;
_vm->_globals->_characterType = CHARACTER_SAMANTHA;
addStaticSprite(_vm->_globals->_characterSpriteBuf, loc->_pos, 0, 64, loc->_zoomFactor, false, 20, 127);
animateSprite(0);
_vm->_globals->loadCharacterData();
@ -2287,9 +2287,9 @@ void ObjectsManager::changeCharacterHead(PlayerCharacter oldCharacter, PlayerCha
// Check Size
void ObjectsManager::computeAndSetSpriteSize() {
int size = _vm->_globals->_spriteSize[getSpriteY(0)];
if (_vm->_globals->_characterType == 1) {
if (_vm->_globals->_characterType == CHARACTER_HOPKINS_CLONE) {
size = 20 * (5 * abs(size) - 100) / -80;
} else if (_vm->_globals->_characterType == 2) {
} else if (_vm->_globals->_characterType == CHARACTER_SAMANTHA) {
size = 20 * (5 * abs(size) - 165) / -67;
}
setSpriteZoom(0, size);
@ -3861,30 +3861,29 @@ void ObjectsManager::sceneControl2(const Common::String &backgroundFile, const C
_vm->_graphicsMan->setColorPercentage(253, 100, 100, 100);
_vm->_graphicsMan->setColorPercentage(251, 100, 100, 100);
_vm->_graphicsMan->setColorPercentage(254, 0, 0, 0);
if (_vm->_globals->_characterType) {
if (!_vm->_globals->_saveData->_data[svAlternateSpriteFl] && !_vm->_globals->_saveData->_data[svField356]) {
_vm->_globals->_characterSpriteBuf = _vm->_fileIO->loadFile("PERSO.SPR");
_vm->_globals->_characterType = 0;
}
}
if (!_vm->_globals->_characterType && _vm->_globals->_saveData->_data[svAlternateSpriteFl] == 1) {
_vm->_globals->_characterSpriteBuf = _vm->_fileIO->loadFile("HOPFEM.SPR");
_vm->_globals->_characterType = 1;
if (_vm->_globals->_characterType != CHARACTER_HOPKINS && !_vm->_globals->_saveData->_data[svAlternateSpriteFl] && !_vm->_globals->_saveData->_data[svField356]) {
_vm->_globals->_characterSpriteBuf = _vm->_fileIO->loadFile("PERSO.SPR");
_vm->_globals->_characterType = CHARACTER_HOPKINS;
}
if (_vm->_globals->_characterType != 2 && _vm->_globals->_saveData->_data[svField356] == 1) {
if (_vm->_globals->_characterType == CHARACTER_HOPKINS && _vm->_globals->_saveData->_data[svAlternateSpriteFl] == 1) {
_vm->_globals->_characterSpriteBuf = _vm->_fileIO->loadFile("HOPFEM.SPR");
_vm->_globals->_characterType = CHARACTER_HOPKINS_CLONE;
}
if (_vm->_globals->_characterType != CHARACTER_SAMANTHA && _vm->_globals->_saveData->_data[svField356] == 1) {
_vm->_globals->_characterSpriteBuf = _vm->_fileIO->loadFile("PSAMAN.SPR");
_vm->_globals->_characterType = 2;
_vm->_globals->_characterType = CHARACTER_SAMANTHA;
}
_vm->_globals->loadCharacterData();
switch (_vm->_globals->_characterType) {
case 0:
case CHARACTER_HOPKINS:
addStaticSprite(_vm->_globals->_characterSpriteBuf, _characterPos, 0, _startSpriteIndex, 0, false, 34, 190);
break;
case 1:
case CHARACTER_HOPKINS_CLONE:
addStaticSprite(_vm->_globals->_characterSpriteBuf, _characterPos, 0, _startSpriteIndex, 0, false, 28, 155);
break;
case 2:
case CHARACTER_SAMANTHA:
addStaticSprite(_vm->_globals->_characterSpriteBuf, _characterPos, 0, _startSpriteIndex, 0, false, 20, 127);
break;
}

View File

@ -955,7 +955,7 @@ int ScriptManager::handleOpcode(const byte *dataP) {
case 56:
_vm->_globals->_characterSpriteBuf = _vm->_fileIO->loadFile("HOPFEM.SPR");
_vm->_globals->_characterType = 1;
_vm->_globals->_characterType = CHARACTER_HOPKINS_CLONE;
_vm->_globals->_saveData->_data[svAlternateSpriteFl] = 1;
_vm->_globals->loadCharacterData();
_vm->_objectsMan->_sprite[0]._deltaX = 28;
@ -965,7 +965,7 @@ int ScriptManager::handleOpcode(const byte *dataP) {
case 57:
_vm->_globals->_characterSpriteBuf = _vm->_fileIO->loadFile("PERSO.SPR");
_vm->_globals->_characterType = 0;
_vm->_globals->_characterType = CHARACTER_HOPKINS;
_vm->_globals->_saveData->_data[svAlternateSpriteFl] = 0;
_vm->_globals->loadCharacterData();
_vm->_objectsMan->_sprite[0]._deltaX = 34;