Skip to content

Commit

Permalink
XEEN: Implement remaining missing code in checkEvents
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Mar 4, 2015
1 parent 8101f8d commit 15d375b
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 3 deletions.
1 change: 1 addition & 0 deletions engines/xeen/party.h
Expand Up @@ -141,6 +141,7 @@ class Party {
DamageType _damageType;
bool _dead;
Treasure _treasure;
Treasure _savedTreasure;
public:
Party(XeenEngine *vm);

Expand Down
49 changes: 46 additions & 3 deletions engines/xeen/scripts.cpp
Expand Up @@ -114,6 +114,8 @@ int Scripts::checkEvents() {
Party &party = *_vm->_party;
Screen &screen = *_vm->_screen;
SoundManager &sound = *_vm->_sound;
Town &town = *_vm->_town;
bool isDarkCc = _vm->_files->_isDarkCc;

_refreshIcons = false;
_itemType = 0;
Expand All @@ -125,9 +127,15 @@ int Scripts::checkEvents() {
//int items = _treasureItems;

if (party._treasure._gold & party._treasure._gems) {
// TODO
// Backup any current treasure data
party._savedTreasure = party._treasure;
party._treasure._hasItems = false;
party._treasure._gold = 0;
party._treasure._gems = 0;
} else {
// TODO
party._savedTreasure._hasItems = false;
party._savedTreasure._gold = 0;
party._savedTreasure._gems = 0;
}

do {
Expand Down Expand Up @@ -176,7 +184,33 @@ int Scripts::checkEvents() {
intf.drawParty(true);
}

// TODO
party.checkPartyDead();
if (party._treasure._hasItems || party._treasure._gold || party._treasure._gems)
party.giveTreasure();

if (_animCounter > 0 && intf._objNumber) {
MazeObject &selectedObj = map._mobData._objects[intf._objNumber - 1];

if (selectedObj._spriteId == (isDarkCc ? 15 : 16)) {
for (uint idx = 0; idx < 16; ++idx) {
MazeObject &obj = map._mobData._objects[idx];
if (obj._spriteId == (isDarkCc ? 62 : 57)) {
selectedObj._id = idx;
selectedObj._spriteId = isDarkCc ? 62 : 57;
break;
}
}
} else if (selectedObj._spriteId == 73) {
for (uint idx = 0; idx < 16; ++idx) {
MazeObject &obj = map._mobData._objects[idx];
if (obj._spriteId == 119) {
selectedObj._id = idx;
selectedObj._spriteId = 119;
break;
}
}
}
}

_animCounter = 0;
_vm->_mode = oldMode;
Expand All @@ -202,6 +236,15 @@ int Scripts::checkEvents() {
w.close();
}

// Restore saved treasure
if (party._savedTreasure._hasItems || party._savedTreasure._gold ||
party._savedTreasure._gems) {
party._treasure = party._savedTreasure;
}

// Clear any town loaded sprites
town.clearSprites();

_v2 = 1;
Common::fill(&intf._charFX[0], &intf._charFX[6], 0);

Expand Down
4 changes: 4 additions & 0 deletions engines/xeen/town.cpp
Expand Up @@ -1192,6 +1192,10 @@ bool Town::isActive() const {
return _townSprites.size() > 0 && !_townSprites[0].empty();
}

void Town::clearSprites() {
_townSprites.clear();
}

/*------------------------------------------------------------------------*/

bool TownMessage::show(XeenEngine *vm, int portrait, const Common::String &name,
Expand Down
2 changes: 2 additions & 0 deletions engines/xeen/town.h
Expand Up @@ -105,6 +105,8 @@ class Town: public ButtonContainer {
void drawTownAnim(bool flag);

bool isActive() const;

void clearSprites();
};

class TownMessage : public ButtonContainer {
Expand Down

0 comments on commit 15d375b

Please sign in to comment.