Skip to content

Commit

Permalink
Merge remote-tracking branch 'sync/master' into prince-malik
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamil Zbróg committed Nov 9, 2013
2 parents cdc1409 + 4095ae1 commit 416110d
Show file tree
Hide file tree
Showing 125 changed files with 3,101 additions and 2,326 deletions.
2 changes: 2 additions & 0 deletions common/scummsys.h
Expand Up @@ -405,6 +405,8 @@
typedef unsigned int uint32;
typedef signed int int32;
typedef unsigned int uint;
typedef signed long long int64;
typedef unsigned long long uint64;
#endif


Expand Down
1 change: 1 addition & 0 deletions engines/agi/detection_tables.h
Expand Up @@ -849,6 +849,7 @@ static const AGIGameDescription gameDescriptions[] = {
FANMADE("Tonight The Shrieking Corpses Bleed (Demo v0.11)", "bcc57a7c8d563fa0c333107ae1c0a6e6"),
FANMADE("Tonight The Shrieking Corpses Bleed (v1.01)", "36b38f621b38e8d104aa0807302dc8c9"),
FANMADE("Turks' Quest - Heir to the Planet", "3d19254b737c8b218e5bc4580542b79a"),
FANMADE("Ultimate AGI Fangame (Demo)", "2d14d6fa2a2136d681e46e06821905bf"),
FANMADE("URI Quest (v0.173 Feb 27)", "3986eefcf546dafc45f920ae91a697c3"),
FANMADE("URI Quest (v0.173 Jan 29)", "494150940d34130605a4f2e67ee40b12"),
{
Expand Down
42 changes: 36 additions & 6 deletions engines/avalanche/avalanche.cpp
Expand Up @@ -57,7 +57,6 @@ AvalancheEngine::AvalancheEngine(OSystem *syst, const AvalancheGameDescription *
_sound = nullptr;

_platform = gd->desc.platform;

initVariables();
}

Expand Down Expand Up @@ -90,15 +89,11 @@ AvalancheEngine::~AvalancheEngine() {
}

void AvalancheEngine::initVariables() {
resetVariables();

for (int i = 0; i < 31; i++) {
_also[i][0] = nullptr;
_also[i][1] = nullptr;
}

_totalTime = 0;

memset(_fxPal, 0, 16 * 16 * 3);

for (int i = 0; i < 15; i++) {
Expand Down Expand Up @@ -129,7 +124,7 @@ void AvalancheEngine::initVariables() {
_him = kPeoplePardon;
_her = kPeoplePardon;
_it = Parser::kPardon;
_roomTime = 0;
_roomCycles = 0;
_doingSpriteRun = false;
_isLoaded = false;
_soundFx = true;
Expand All @@ -146,6 +141,32 @@ void AvalancheEngine::initVariables() {
_seeScroll = false;
_currentMouse = 177;
_holdLeftMouse = false;

_jumpStatus = 0;
_mushroomGrowing = false;
_crapulusWillTell = false;
_enterCatacombsFromLustiesRoom = false;
_teetotal = false;
_malagauche = 0;
_drinking = '\0';
_enteredLustiesRoomAsMonk = false;
_catacombX = 0;
_catacombY = 0;
_avvysInTheCupboard = false;
_geidaFollows = false;
_givenPotionToGeida = false;
_lustieIsAsleep = false;
_beenTiedUp = false;
_sittingInPub = false;
_spurgeTalkCount = 0;
_metAvaroid = false;
_takenMushroom = false;
_givenPenToAyles = false;
_askedDogfoodAboutNim = false;
_ableToAddTimer = false;
_spludwickAtHome = false;
_passedCwytalotInHerts = false;
_lastRoom = _lastRoomNotMap = kRoomDummy;
}

Common::ErrorCode AvalancheEngine::initialize() {
Expand Down Expand Up @@ -363,6 +384,8 @@ bool AvalancheEngine::saveGame(const int16 slot, const Common::String &desc) {
f->writeSint16LE(t.tm_mon);
f->writeSint16LE(t.tm_year);

_totalTime += getTimeInSeconds() - _startTime;

Common::Serializer sz(NULL, f);
synchronize(sz);
f->finalize();
Expand Down Expand Up @@ -425,6 +448,7 @@ bool AvalancheEngine::loadGame(const int16 slot) {
delete f;

_isLoaded = true;
_ableToAddTimer = false;
_seeScroll = true; // This prevents display of the new sprites before the new picture is loaded.

if (_holdTheDawn) {
Expand Down Expand Up @@ -482,6 +506,12 @@ Common::String AvalancheEngine::expandDate(int d, int m, int y) {
return day + ' ' + month + ' ' + intToStr(y + 1900);
}

uint32 AvalancheEngine::getTimeInSeconds() {
TimeDate time;
_system->getTimeAndDate(time);
return time.tm_hour * 3600 + time.tm_min * 60 + time.tm_sec;
}

void AvalancheEngine::updateEvents() {
Common::Event event;

Expand Down
12 changes: 9 additions & 3 deletions engines/avalanche/avalanche.h
Expand Up @@ -111,6 +111,7 @@ class AvalancheEngine : public Engine {
Common::Error loadGameState(int slot);
bool loadGame(const int16 slot);
Common::String expandDate(int d, int m, int y);
uint32 getTimeInSeconds();

void updateEvents();
bool getEvent(Common::Event &event); // A wrapper around _eventMan->pollEvent(), so we can use it in Scrolls::normscroll() for example.
Expand Down Expand Up @@ -210,7 +211,8 @@ class AvalancheEngine : public Engine {
bool _takenPen; // Have you taken the pen (in Cardiff?)
bool _arrowInTheDoor; // Did the arrow hit the wall?
Common::String _favoriteDrink, _favoriteSong, _worstPlaceOnEarth, _spareEvening; // Personalisation str's
uint32 _totalTime; // Your total time playing this game, in ticks.
uint32 _startTime; // When did you start playing this session?
uint32 _totalTime; // Your total time playing this game, in seconds. Updated only at saving and loading.
byte _jumpStatus; // Fixes how high you're jumping.
bool _mushroomGrowing; // Is the mushroom growing in 42?
bool _crapulusWillTell; // Will Crapulus tell you about Spludwick being away?
Expand Down Expand Up @@ -257,12 +259,16 @@ class AvalancheEngine : public Engine {
byte _subjectNum; // The same thing.
People _him, _her;
byte _it;
uint32 _roomTime; // Set to 0 when you enter a room, added to in every loop.
uint32 _roomCycles; // Set to 0 when you enter a room, added to in every loop. Cycles since you've been in this room.

bool _doingSpriteRun; // Only set to True if we're doing a sprite_run at this moment. This stops the trippancy system from moving any of the sprites.
bool _isLoaded; // Is it a loaded gamestate?
bool _soundFx;

// These two have very similar purpose, but it's crucial not to modify _isLoaded later than the actual loading
// or at the begginning of the game, and _ablteToAddTimer must be modified in addTimer().
bool _isLoaded; // Is it a loaded gamestate?
bool _ableToAddTimer;

void callVerb(VerbCode id);
void loadRoom(byte num);
void thinkAbout(byte object, bool type); // Hey!!! Get it and put it!!!
Expand Down
13 changes: 7 additions & 6 deletions engines/avalanche/avalot.cpp
Expand Up @@ -295,7 +295,6 @@ void AvalancheEngine::setup() {

loadGame(loadSlot);
} else {
_isLoaded = false; // Set to true in _vm->loadGame().
newGame();

_soundFx = !_soundFx;
Expand Down Expand Up @@ -639,8 +638,7 @@ void AvalancheEngine::enterRoom(Room roomId, byte ped) {
if (_geidaFollows)
_whereIs[kPeopleGeida - 150] = roomId;

_roomTime = 0;

_roomCycles = 0;

if ((_lastRoom == kRoomMap) && (_lastRoomNotMap != _room))
enterNewTown();
Expand Down Expand Up @@ -1006,7 +1004,6 @@ void AvalancheEngine::enterRoom(Room roomId, byte ped) {
}

_seeScroll = false; // Now it can work again!
_isLoaded = false;
}

void AvalancheEngine::thinkAbout(byte object, bool type) {
Expand Down Expand Up @@ -1461,8 +1458,8 @@ void AvalancheEngine::resetVariables() {
_jumpStatus = 0;
_mushroomGrowing = false;
_spludwickAtHome = false;
_lastRoom = 0;
_lastRoomNotMap = 0;
_lastRoom = kRoomDummy;
_lastRoomNotMap = kRoomDummy;
_crapulusWillTell = false;
_enterCatacombsFromLustiesRoom = false;
_teetotal = false;
Expand All @@ -1482,6 +1479,7 @@ void AvalancheEngine::resetVariables() {
_takenMushroom = false;
_givenPenToAyles = false;
_askedDogfoodAboutNim = false;
_startTime = getTimeInSeconds();

_parser->resetVariables();
_animation->resetVariables();
Expand Down Expand Up @@ -1532,6 +1530,9 @@ void AvalancheEngine::newGame() {
_doingSpriteRun = false;
_avvyInBed = true;

_ableToAddTimer = true; // Set to false in _vm->loadGame().
_isLoaded = false;

enterRoom(kRoomYours, 1);
avvy->_visible = false;
drawScore();
Expand Down
46 changes: 23 additions & 23 deletions engines/avalanche/background.cpp
Expand Up @@ -53,23 +53,23 @@ void Background::update() {

switch (_vm->_room) {
case kRoomOutsideArgentPub:
if ((_vm->_roomTime % 12) == 0)
draw(-1, -1, (_vm->_roomTime / 12) % 4);
if ((_vm->_roomCycles % 12) == 0)
draw(-1, -1, (_vm->_roomCycles / 12) % 4);
break;
case kRoomBrummieRoad:
if ((_vm->_roomTime % 2) == 0)
draw(-1, -1, (_vm->_roomTime / 2) % 4);
if ((_vm->_roomCycles % 2) == 0)
draw(-1, -1, (_vm->_roomCycles / 2) % 4);
break;
case kRoomBridge:
if ((_vm->_roomTime % 2) == 0)
draw(-1, -1, 3 + (_vm->_roomTime / 2) % 4);
if ((_vm->_roomCycles % 2) == 0)
draw(-1, -1, 3 + (_vm->_roomCycles / 2) % 4);
break;
case kRoomYours:
if ((!_vm->_avvyIsAwake) && ((_vm->_roomTime % 4) == 0))
draw(-1, -1, (_vm->_roomTime / 12) % 2);
if ((!_vm->_avvyIsAwake) && ((_vm->_roomCycles % 4) == 0))
draw(-1, -1, (_vm->_roomCycles / 12) % 2);
break;
case kRoomArgentPub:
if (((_vm->_roomTime % 7) == 1) && (_vm->_malagauche != 177)) {
if (((_vm->_roomCycles % 7) == 1) && (_vm->_malagauche != 177)) {
// Malagauche cycle.
_vm->_malagauche++;
switch (_vm->_malagauche) {
Expand All @@ -93,7 +93,7 @@ void Background::update() {
}
}

switch (_vm->_roomTime % 200) {
switch (_vm->_roomCycles % 200) {
case 179:
case 197:
draw(-1, -1, 4); // Dogfood's drinking cycle.
Expand All @@ -109,7 +109,7 @@ void Background::update() {
_vm->_npcFacing = 177; // Impossible value for this.
break;
default:
if (_vm->_roomTime % 200 <= 178) { // Normally.
if (_vm->_roomCycles % 200 <= 178) { // Normally.
byte direction = 1;
uint16 angle = _vm->bearing(1);
if (((angle >= 1) && (angle <= 90)) || ((angle >= 358) && (angle <= 360)))
Expand All @@ -127,8 +127,8 @@ void Background::update() {
}
break;
case kRoomWestHall:
if ((_vm->_roomTime % 3) == 0) {
switch ((_vm->_roomTime / 3) % 6) {
if ((_vm->_roomCycles % 3) == 0) {
switch ((_vm->_roomCycles / 3) % 6) {
case 4:
draw(-1, -1, 0);
break;
Expand All @@ -148,7 +148,7 @@ void Background::update() {
if (!(_vm->_lustieIsAsleep)) {
byte direction = 0;
uint16 angle = _vm->bearing(1);
if ((_vm->_roomTime % 45) > 42)
if ((_vm->_roomCycles % 45) > 42)
direction = 4; // du Lustie blinks.
// Bearing of Avvy from du Lustie.
else if ((angle <= 45) || ((angle >= 315) && (angle <= 360)))
Expand All @@ -165,8 +165,8 @@ void Background::update() {
}
break;
case kRoomAylesOffice:
if ((!_vm->_aylesIsAwake) && (_vm->_roomTime % 14 == 0)) {
switch ((_vm->_roomTime / 14) % 2) {
if ((!_vm->_aylesIsAwake) && (_vm->_roomCycles % 14 == 0)) {
switch ((_vm->_roomCycles / 14) % 2) {
case 0:
draw(-1, -1, 0); // Frame 2: EGA.
break;
Expand All @@ -178,7 +178,7 @@ void Background::update() {
break;
case kRoomRobins:
if (_vm->_tiedUp) {
switch (_vm->_roomTime % 54) {
switch (_vm->_roomCycles % 54) {
case 20:
draw(-1, -1, 3); // Frame 4: Avalot blinks.
break;
Expand All @@ -199,15 +199,15 @@ void Background::update() {
else if ((angle >= 181) && (angle <= 314))
direction = 8; // Right.

if ((_vm->_roomTime % 60) > 57)
if ((_vm->_roomCycles % 60) > 57)
direction--; // Blinks.

if (direction != _vm->_npcFacing) { // Port.
draw(-1, -1, direction - 1);
_vm->_npcFacing = direction;
}

switch (_vm->_roomTime % 50) {
switch (_vm->_roomCycles % 50) {
case 45 :
draw(-1, -1, 8); // Spurge blinks.
break;
Expand All @@ -218,8 +218,8 @@ void Background::update() {
break;
}
case kRoomDucks: {
if ((_vm->_roomTime % 3) == 0) // The fire flickers.
draw(-1, -1, (_vm->_roomTime / 3) % 3);
if ((_vm->_roomCycles % 3) == 0) // The fire flickers.
draw(-1, -1, (_vm->_roomCycles / 3) % 3);

// Bearing of Avvy from Duck.
byte direction = 0;
Expand All @@ -231,7 +231,7 @@ void Background::update() {
else if ((angle >= 181) && (angle <= 314))
direction = 8; // Right.

if ((_vm->_roomTime % 45) > 42)
if ((_vm->_roomCycles % 45) > 42)
direction++; // Duck blinks.

if (direction != _vm->_npcFacing) { // Duck.
Expand All @@ -246,7 +246,7 @@ void Background::update() {

if ((_vm->_bellsAreRinging) && (_vm->getFlag('B'))) {
// They're ringing the bells.
switch (_vm->_roomTime % 4) {
switch (_vm->_roomCycles % 4) {
case 1:
if (_nextBell < 5)
_nextBell = 12;
Expand Down
8 changes: 6 additions & 2 deletions engines/avalanche/parser.cpp
Expand Up @@ -603,8 +603,12 @@ Common::String Parser::rank() {
Common::String Parser::totalTime() {
uint16 h, m, s;

h = (uint16)(_vm->_totalTime / 65535);
s = (uint16)(_vm->_totalTime % 65535);
uint32 curTime = _vm->getTimeInSeconds() - _vm->_startTime;
if (_vm->_isLoaded)
curTime += _vm->_totalTime;

h = (uint16)(curTime / 3600);
s = (uint16)(curTime % 3600);
m = s / 60;
s = s % 60;

Expand Down
8 changes: 4 additions & 4 deletions engines/avalanche/timer.cpp
Expand Up @@ -48,7 +48,7 @@ Timer::Timer(AvalancheEngine *vm) {
* @remarks Originally called 'set_up_timer'
*/
void Timer::addTimer(int32 duration, byte action, byte reason) {
if ((_vm->_isLoaded == false) || (_timerLost == true)) {
if ((_vm->_ableToAddTimer == false) || (_timerLost == true)) {
byte i = 0;
while ((i < 7) && (_times[i]._timeLeft != 0))
i++;
Expand All @@ -61,7 +61,7 @@ void Timer::addTimer(int32 duration, byte action, byte reason) {
_times[i]._action = action;
_times[i]._reason = reason;
} else {
_vm->_isLoaded = false;
_vm->_ableToAddTimer = false;
return;
}
}
Expand Down Expand Up @@ -208,8 +208,8 @@ void Timer::updateTimer() {
}
}
}
_vm->_roomTime++; // Cycles since you've been in this room.
_vm->_totalTime++; // Total amount of time for this game.
_vm->_roomCycles++; // Cycles since you've been in this room.
}

void Timer::loseTimer(byte which) {
Expand Down

0 comments on commit 416110d

Please sign in to comment.