Skip to content

Commit

Permalink
KYRA: (EOB/LOL) - cleanup common code
Browse files Browse the repository at this point in the history
(rename some stuff and move EOB/LOL common code to separate files)
  • Loading branch information
athrxx authored and Johannes Schickel committed Dec 26, 2011
1 parent aac7e16 commit 8b618e4
Show file tree
Hide file tree
Showing 39 changed files with 1,419 additions and 1,256 deletions.
4 changes: 2 additions & 2 deletions engines/kyra/chargen.cpp
Expand Up @@ -169,7 +169,7 @@ bool CharacterGenerator::start(EobCharacter *characters, uint8 ***faceShapes) {

for (bool loop = true; loop && (!_vm->shouldQuit()); ) {
_vm->_gui->updateBoxFrameHighLight(_activeBox + 6);
int inputFlag = getInput(_vm->_activeButtons);
int inputFlag = getInput(_vm->_activeButtons);
_vm->removeInputTop();

if (inputFlag) {
Expand Down Expand Up @@ -434,7 +434,7 @@ int CharacterGenerator::viewDeleteCharacter() {
}

void CharacterGenerator::createPartyMember() {
_screen->setScreenDim(2);
_screen->setScreenDim(2);
assert(_vm->_gui);

for (int i = 0; i != 3 && !_vm->shouldQuit(); i++) {
Expand Down
2 changes: 1 addition & 1 deletion engines/kyra/detection.cpp
Expand Up @@ -163,7 +163,7 @@ SaveStateList KyraMetaEngine::listSaves(const char *target) const {
// Skip automatic final saves made by EOB for the purpose of party transfer
if (!scumm_stricmp(file->c_str() + file->size() - 3, "fin"))
continue;

// Obtain the last 3 digits of the filename, since they correspond to the save slot
int slotNum = atoi(file->c_str() + file->size() - 3);

Expand Down
16 changes: 8 additions & 8 deletions engines/kyra/eob1.cpp
Expand Up @@ -173,7 +173,7 @@ void EobEngine::runNpcDialogue(int npcIndex) {
int r = 0;
int a = 0;
Item itm = 0;

switch (npcIndex) {
case 0:
for (r = 1; r == 1; ) {
Expand All @@ -199,7 +199,7 @@ void EobEngine::runNpcDialogue(int npcIndex) {
}
if (!r)
r = DLG2(a ? 13 : 4, 4);

if (!r) {
for (a = 0; a < 6; a++)
createItemOnCurrentBlock(55);
Expand Down Expand Up @@ -230,7 +230,7 @@ void EobEngine::runNpcDialogue(int npcIndex) {
if (deletePartyItems(6, -1)) {
//_npcSequenceSub = 0;
//drawNpcScene(npcIndex);
TXT(28);
TXT(28);
createItemOnCurrentBlock(32);
setScriptFlags(0x100000);
r = 1;
Expand All @@ -254,7 +254,7 @@ void EobEngine::runNpcDialogue(int npcIndex) {
else
resurrectionSelectDialogue();
setScriptFlags(0x20000);
}
}
}
} else {
TXT(24);
Expand Down Expand Up @@ -476,7 +476,7 @@ void EobEngine::turnUndeadAuto() {
for (int i = 0; i < 6; i++) {
if (!testCharacter(i, 0x0d))
continue;

EobCharacter *c = &_characters[i];

if (_itemTypes[_items[c->inventory[0]].type].extraProperties != 6 && _itemTypes[_items[c->inventory[1]].type].extraProperties != 6)
Expand Down Expand Up @@ -553,13 +553,13 @@ void EobEngine::healParty() {
for (int i = 0; i < 6 && cnt; i++) {
if (testCharacter(i, 3))
continue;

_characters[i].flags &= ~4;
neutralizePoison(i);

if (_characters[i].hitPointsCur >= _characters[i].hitPointsMax)
continue;

cnt--;
_characters[i].hitPointsCur += rollDice(1, 8, 9);
if (_characters[i].hitPointsCur > _characters[i].hitPointsMax)
Expand Down
6 changes: 3 additions & 3 deletions engines/kyra/eob1.h
Expand Up @@ -61,15 +61,15 @@ friend class GUI_Eob;
void seq_king();
void seq_hands();
void seq_waterdeepExit();
void seq_tunnel();
void seq_tunnel();

void seq_xdeath();

void loadSetIntroPalette(const char *filename);
void copyBlurRegion(int x1, int y1, int x2, int y2, int w, int h, int step);
void boxMorphTransition(int targetDestX, int targetDestY, int targetFinalX, int targetFinalY, int targetSrcX, int targetSrcY, int targetFinalW, int targetFinalH, int originX1, int originY1, int originW, int originH);
void whirlTransition();

const char *const *_introFilesOpening;
const char *const *_introFilesTower;
const char *const *_introFilesOrb;
Expand All @@ -90,7 +90,7 @@ friend class GUI_Eob;
const uint8 *_introTvlY2;
const uint8 *_introTvlW;
const uint8 *_introTvlH;

const char *const *_finBonusStrings;

// characters
Expand Down
2 changes: 1 addition & 1 deletion engines/kyra/eob2.cpp
Expand Up @@ -387,7 +387,7 @@ void DarkMoonEngine::restParty_npc() {
bool DarkMoonEngine::restParty_extraAbortCondition() {
if (_currentLevel != 3)
return false;

seq_nightmare();

return true;
Expand Down
36 changes: 18 additions & 18 deletions engines/kyra/eobcommon.cpp
Expand Up @@ -22,7 +22,7 @@

#ifdef ENABLE_EOB

#include "kyra/loleobbase.h"
#include "kyra/kyra_rpg.h"
#include "kyra/resource.h"
#include "kyra/sound_intern.h"
#include "kyra/script_eob.h"
Expand All @@ -36,7 +36,7 @@

namespace Kyra {

EobCoreEngine::EobCoreEngine(OSystem *system, const GameFlags &flags) : LolEobBaseEngine(system, flags), _numLargeItemShapes(flags.gameID == GI_EOB1 ? 14 : 11),
EobCoreEngine::EobCoreEngine(OSystem *system, const GameFlags &flags) : KyraRpgEngine(system, flags), _numLargeItemShapes(flags.gameID == GI_EOB1 ? 14 : 11),
_numSmallItemShapes(flags.gameID == GI_EOB1 ? 23 : 26), _numThrownItemShapes(flags.gameID == GI_EOB1 ? 12 : 9), _numItemIconShapes(flags.gameID == GI_EOB1 ? 89 : 112),
_teleporterWallId(flags.gameID == GI_EOB1 ? 52 : 44) {
_screen = 0;
Expand Down Expand Up @@ -164,7 +164,7 @@ EobCoreEngine::EobCoreEngine(OSystem *system, const GameFlags &flags) : LolEobBa
_monsterProximityTable = _findBlockMonstersTable = _wallOfForceDsY = _wallOfForceDsNumW = _wallOfForceDsNumH = _wallOfForceShpId = _wllFlagPreset = _teleporterShapeCoords = 0;
_monsterCloseAttUnkTable = _monsterFrmOffsTable1 = _monsterFrmOffsTable2 = _monsterDirChangeTable = _portalSeq = 0;
_wallOfForceDsX = 0;
_expObjectAnimTbl1Size = _expObjectAnimTbl2Size = _expObjectAnimTbl3Size = _wllFlagPresetSize = _scriptTimersCount = _buttonList1Size = _buttonList2Size =
_expObjectAnimTbl1Size = _expObjectAnimTbl2Size = _expObjectAnimTbl3Size = _wllFlagPresetSize = _scriptTimersCount = _buttonList1Size = _buttonList2Size =
_buttonList3Size = _buttonList4Size = _buttonList5Size = _buttonList6Size = _buttonList7Size = _buttonList8Size = 0;
_inventorySlotsY = _mnDef = 0;
_buttonDefs = 0;
Expand Down Expand Up @@ -310,7 +310,7 @@ Common::Error EobCoreEngine::init() {
//MidiDriverType midiDriver = MidiDriver::detectDevice(MDT_PCSPK | MDT_ADLIB);
_sound = new SoundAdLibPC(this, _mixer);
assert(_sound);
_sound->init();
_sound->init();

syncSoundSettings();

Expand All @@ -335,7 +335,7 @@ Common::Error EobCoreEngine::init() {
setupKeyMap();
_gui = new GUI_Eob(this);
assert(_gui);
_txt = new TextDisplayer_Eob(this, _screen);
_txt = new TextDisplayer_rpg(this, _screen);
assert(_txt);
_inf = new EobInfProcessor(this, _screen);
assert(_inf);
Expand All @@ -345,7 +345,7 @@ Common::Error EobCoreEngine::init() {
_screen->loadFont(Screen::FID_6_FNT, "FONT6.FNT");
_screen->loadFont(Screen::FID_8_FNT, "FONT8.FNT");

Common::Error err = LolEobBaseEngine::init();
Common::Error err = KyraRpgEngine::init();
if (err.getCode() != Common::kNoError)
return err;

Expand Down Expand Up @@ -522,7 +522,7 @@ void EobCoreEngine::startupNew() {
}

void EobCoreEngine::runLoop() {
_envAudioTimer = _system->getMillis() + (rollDice(1, 10, 3) * 18 * _tickLength);
_envAudioTimer = _system->getMillis() + (rollDice(1, 10, 3) * 18 * _tickLength);
_flashShapeTimer = 0;
_drawSceneTimer = _system->getMillis();

Expand Down Expand Up @@ -566,7 +566,7 @@ bool EobCoreEngine::checkPartyStatus(bool handleDeath) {

if (!handleDeath)
return true;

gui_drawAllCharPortraitsWithStats();

if (checkPartyStatusExtra()) {
Expand Down Expand Up @@ -1172,7 +1172,7 @@ void EobCoreEngine::dropCharacter(int charIndex) {
return;

removeCharacterFromParty(charIndex);

if (charIndex < 5)
exchangeCharacters(charIndex, testCharacter(5, 1) ? 5 : 4);

Expand Down Expand Up @@ -1439,7 +1439,7 @@ bool EobCoreEngine::restParty_updateMonsters() {
return true;
}
}

_sound->enableSFX(sfxEnabled);
_sound->enableMusic(musicEnabled);
return false;
Expand Down Expand Up @@ -1468,7 +1468,7 @@ bool EobCoreEngine::restParty_checkHealSpells(int charIndex) {
static const uint8 eob2healSpells[] = { 3, 16, 20 };
const uint8 *spells = _flags.gameID == GI_EOB1 ? eob1healSpells : eob2healSpells;
const int8 *list = _characters[charIndex].clericSpells;

for (int i = 0; i < 80; i++) {
int s = list[i] < 0 ? -list[i] : list[i];
if (s == spells[0] || s == spells[1] || s == spells[2])
Expand Down Expand Up @@ -1551,7 +1551,7 @@ void EobCoreEngine::displayParchment(int id) {

int EobCoreEngine::countResurrectionCandidates() {
_rrCount = 0;
memset(_rrNames, 0, 10 * sizeof(const char*));
memset(_rrNames, 0, 10 * sizeof(const char*));

for (int i = 0; i < 6; i++) {
if (!testCharacter(i, 1))
Expand Down Expand Up @@ -1646,11 +1646,11 @@ void EobCoreEngine::seq_portal() {
if (*(pos - 2) == 3)
snd_playSoundEffect(90);
}

_screen->updateScreen();
delay(2 * _tickLength);
}

delete[] shape0;
for (int i = 0; i < 5; i++) {
delete[] shapes1[i];
Expand All @@ -1663,12 +1663,12 @@ bool EobCoreEngine::checkPassword() {
char answ[20];
Screen::FontId of = _screen->setFont(Screen::FID_8_FNT);
_screen->copyPage(0, 10);

_screen->setScreenDim(13);
gui_drawBox(_screen->_curDim->sx << 3, _screen->_curDim->sy, _screen->_curDim->w << 3, _screen->_curDim->h, _color1_1, _color2_1, -1);
gui_drawBox((_screen->_curDim->sx << 3) + 1, _screen->_curDim->sy + 1, (_screen->_curDim->w << 3) - 2, _screen->_curDim->h - 2, _color1_1, _color2_1, _bkgColor_1);
_screen->modifyScreenDim(13, _screen->_curDim->sx + 1, _screen->_curDim->sy + 2, _screen->_curDim->w - 2, _screen->_curDim->h - 16);

for (int i = 0; i < 3; i++) {
_screen->fillRect(_screen->_curDim->sx << 3, _screen->_curDim->sy, ((_screen->_curDim->sx + _screen->_curDim->w) << 3) - 1, (_screen->_curDim->sy + _screen->_curDim->h) - 1, _bkgColor_1);
int c = rollDice(1, _mnNumWord - 1, -1);
Expand All @@ -1678,7 +1678,7 @@ bool EobCoreEngine::checkPassword() {
_screen->printShadedText(Common::String::format(_mnPrompt[0], _mnDef[(c << 2) + 1], _mnDef[(c << 2) + 2]).c_str(), (_screen->_curDim->sx + 1) << 3, _screen->_curDim->sy, _screen->_curDim->unk8, _bkgColor_1);
memset(answ, 0, 20);
gui_drawBox(76, 100, 133, 14, _color2_1, _color1_1, -1);
gui_drawBox(77, 101, 131, 12, _color2_1, _color1_1, -1);
gui_drawBox(77, 101, 131, 12, _color2_1, _color1_1, -1);
if (_gui->getTextInput(answ, 10, 103, 15, _screen->_curDim->unk8, _bkgColor_1, 8) < 0)
i = 3;
if (!scumm_stricmp(_mnWord[c], answ))
Expand Down Expand Up @@ -1812,7 +1812,7 @@ int EobCoreEngine::projectileWeaponAttack(int charIndex, Item item) {
SWAP(ammoItem, _characters[charIndex].inventory[1]);
else if (_characters[charIndex].inventory[16])
ammoItem = getQueuedItem(&_characters[charIndex].inventory[16], 0, -1);

} else {
for (int i = 0; i < 27; i++) {
if (_items[_characters[charIndex].inventory[i]].type == t) {
Expand Down
22 changes: 11 additions & 11 deletions engines/kyra/eobcommon.h
Expand Up @@ -24,7 +24,7 @@
#define KYRA_EOBCOMMON_H

#if defined(ENABLE_EOB) || defined(ENABLE_LOL)
#include "kyra/loleobbase.h"
#include "kyra/kyra_rpg.h"
#endif // (ENABLE_EOB || ENABLE_LOL)

#ifdef ENABLE_EOB
Expand Down Expand Up @@ -239,8 +239,8 @@ struct EobMenuButtonDef {

class EobInfProcessor;

class EobCoreEngine : public LolEobBaseEngine {
friend class TextDisplayer_Eob;
class EobCoreEngine : public KyraRpgEngine {
friend class TextDisplayer_rpg;
friend class GUI_Eob;
friend class EobInfProcessor;
friend class DarkmoonSequenceHelper;
Expand Down Expand Up @@ -328,7 +328,7 @@ friend class CharacterGenerator;
static const uint8 _charClassModifier[];

const uint8 *_classModifierFlags;

const uint8 *_transferConvertTable;
const uint32 *_transferExpTable;

Expand Down Expand Up @@ -550,7 +550,7 @@ friend class CharacterGenerator;
const uint8 *_monsterProximityTable;
const uint8 *_findBlockMonstersTable;
const char *const *_monsterDustStrings;

const uint8 *_enemyMageSpellList;
const uint8 *_enemyMageSfx;
const uint8 *_beholderSpellList;
Expand Down Expand Up @@ -798,9 +798,9 @@ friend class CharacterGenerator;
const char *const *_validateCursedString;
const char *const *_validateNoDropString;
const char *const *_potionStrings;
const char *const *_wandStrings;
const char *const *_itemMisuseStrings;
const char *const *_wandStrings;
const char *const *_itemMisuseStrings;

const char *const *_suffixStringsRings;
const char *const *_suffixStringsPotions;
const char *const *_suffixStringsWands;
Expand Down Expand Up @@ -832,7 +832,7 @@ friend class CharacterGenerator;

void seq_portal();
bool checkPassword();

virtual int resurrectionSelectDialogue() = 0;
virtual void useHorn(int charIndex, int weaponSlot) {}
virtual bool checkPartyStatusExtra() = 0;
Expand Down Expand Up @@ -900,7 +900,7 @@ friend class CharacterGenerator;
int getDexHitChanceModifier(int charIndex);
int getMonsterAcHitChanceModifier(int charIndex, int monsterAc);
void explodeMonster(EobMonsterInPlay *m);

int _dstMonsterIndex;
bool _preventMonsterFlash;
int16 _foundMonstersArray[5];
Expand Down Expand Up @@ -940,7 +940,7 @@ friend class CharacterGenerator;
void destroyWallOfForce(int index);

int findSingleSpellTarget(int dist);

int findFirstCharacterSpellTarget();
int findNextCharacterSpellTarget(int curCharIndex);
int charDeathSavingThrow(int charIndex, int div);
Expand Down

0 comments on commit 8b618e4

Please sign in to comment.