Commit Graph

123 Commits

Author SHA1 Message Date
Robert Špalek
cc39c5022a Work-around a bug in the original game files.
svn-id: r44645
2009-10-04 22:55:54 +00:00
Max Horn
f242266f6d Change a couple places from 'end of namespace' to 'End of namespace', for consistency
svn-id: r44634
2009-10-04 21:26:33 +00:00
Robert Špalek
43f84746bf Fixed positioning and update of the title under the mouse pointer.
Clamping on the border of the screen works precisely.  When switched to the
inventory, titles of game items are displayed instead of a (sticky) title of
the last object before entering the inventory.  Put some const's where
appropriate.

svn-id: r44550
2009-10-03 05:16:19 +00:00
Robert Špalek
24d649b972 Clean up room changing code and support returning from the map.
Completely changed the interface, removing unused methods and attributes,
renaming other ones to reflect what they do, and moving some methods into the
private section.  Code changing the location, originally scattered over many
pieces of code, has been unified into one place.  Remember the previous room
when entering the map so that one can return there.

Also, the event handler processes one event at a time, preventing lost clicks
on touchpads.

svn-id: r44508
2009-10-01 08:32:35 +00:00
Max Horn
8ba75fc522 Fix code formatting (esp. 'if(' -> 'if (' etc., but also indention and other things)
svn-id: r44495
2009-09-30 16:16:53 +00:00
Max Horn
cc54ad650d Remove trailing whitespaces
svn-id: r44493
2009-09-30 16:04:21 +00:00
Johannes Schickel
c9ca057ae2 - Adapt parts of the Draci code to match our code formatting guidelines
- Remove use of tabs for formatting, now in nearly all cases tabs are only used for indentation
- Use "uint" instead of "unsigned int" in the whole engine for consistency's sake
- Strip some trailing tabs and leading whitespaces

svn-id: r44478
2009-09-30 10:45:14 +00:00
Denis Kasak
0c0135e0ed draci: Added methods Game::positionAnimAsHero(), Game::getHeroX() and Game::getHeroY() and implemented correct positioning of all dragon animations. Fixed exiting the inventory by right-clicking outside it.
svn-id: r44453
2009-09-28 23:10:08 +00:00
Robert Špalek
359d374dc6 Added const's to getPalette() and several uses of getObject()
svn-id: r44434
2009-09-28 04:09:03 +00:00
Robert Špalek
8a78e96838 Make getFile() return a const pointer and clean-up all uses of it.
svn-id: r44433
2009-09-28 03:51:23 +00:00
Robert Špalek
42e3c63b11 get rid of static Common::String's
svn-id: r44431
2009-09-28 02:54:38 +00:00
Robert Špalek
caa3b6707e Improved the interface of Sprite and Animation concerning relative coordinates and scaling.
It is no longer needed to modify the underlying animations when drawing them
on the screen or testing pixels in them.  Read access is enough, because
the displacement of the object is passed as a parameter.

Added some more const's where they logically belong.

svn-id: r44419
2009-09-27 20:49:59 +00:00
Robert Špalek
fc2bb50600 Remove memory leak in animation manager. Get rid of 1 non-const reference parameter.
svn-id: r44413
2009-09-27 18:11:06 +00:00
Robert Špalek
431780297e Added some more const's to the interface of Dragon History
svn-id: r44362
2009-09-25 17:33:00 +00:00
Robert Špalek
f51c81f344 Add const's to many interfaces of engines/draci/
svn-id: r44331
2009-09-25 08:13:39 +00:00
Filippos Karapetis
a74a9c6c01 Silenced some warnings
svn-id: r44329
2009-09-25 07:06:55 +00:00
Denis Kasak
be0cfa50f2 Removed public data variables of Game concerning dialogues and added getters/setters.
svn-id: r43492
2009-08-17 19:37:55 +00:00
Denis Kasak
b0fea939f4 Added inventory and item handling support (monster patch, sorry). Items were previously called "icons" as in the original player. This commit also renamed every such instance to the proper "item".
svn-id: r43487
2009-08-17 18:50:38 +00:00
Denis Kasak
1c0df34b4d Removed _roomChange hack since it's no longer needed.
svn-id: r43392
2009-08-15 02:53:14 +00:00
Denis Kasak
abf10049bb * Implemented LoadPalette, SetPalette and BlackPalette GPL commands.
* Used a more natural condition (whether the scheduled room number is different from the current room number) instead of the _roomChange hack.

svn-id: r43391
2009-08-15 02:42:34 +00:00
Denis Kasak
87e64d27f7 Fixed bug which made the dragon's spoken line in a dialogue end too quickly.
svn-id: r43365
2009-08-14 13:17:53 +00:00
Denis Kasak
8ca10ac3b0 Fixed dialogues logic (some indexes were calculated erroneously +/- 1).
svn-id: r43312
2009-08-12 07:34:31 +00:00
Denis Kasak
534158af87 * When setting the first two game variables (room and gate), first convert them back to 1-based indexing so they play well with the rest of the scripts. This fixes a number of bugs, e.g. the dragon now appears automatically when the game starts and the question mark animation in the intro is played / stopped at an appropriate time.
* Removed hack from Script::start() which loaded animation 657 before playing it to stop a crash. The fix above seems to fix this bug as well.

svn-id: r43308
2009-08-12 05:20:25 +00:00
Denis Kasak
6693b22851 * Split loop status and substatus into two different enums since they are two separate concepts
* Fixed slight glitch where object titles (which normally disappear when objects are used/looked at) reappeared for a moment after the script has finished

svn-id: r43305
2009-08-12 04:18:45 +00:00
Denis Kasak
100603e683 Fixed Script::walkOnPlay() (was setting loop status whereas it was substatus that needed to be set).
svn-id: r43297
2009-08-12 01:03:54 +00:00
Denis Kasak
ee7b9271a2 Implemented GPL command WalkOnPlay.
svn-id: r43255
2009-08-11 04:18:14 +00:00
Denis Kasak
0daad90685 Fix intro crash because of bug in the data files.
svn-id: r43254
2009-08-11 04:14:38 +00:00
Denis Kasak
51cc821619 Added dialogue support.
svn-id: r43253
2009-08-11 04:03:22 +00:00
Denis Kasak
b9a9a5ef88 Implemented GPL function Script::funcObjStat().
svn-id: r43176
2009-08-09 16:58:04 +00:00
Denis Kasak
f68ceeb88c * Implemented GPL functions Script::funcActIco() and Script::funcIsIcoAct().
* Implemented GPL commands Script::loadMap() and Script::roomMap().
* Added temporary HACK to change some speech texts to use the small font because some strings overflow the screen (as stored in the data files).

svn-id: r43161
2009-08-09 04:12:36 +00:00
Denis Kasak
18b5d7ce33 Implemented Script::testExpression().
svn-id: r43129
2009-08-08 15:55:19 +00:00
Denis Kasak
907a35c929 Added ability to end the currently executing GPL program before it finishes via Script::endCurrentProgram().
svn-id: r43086
2009-08-06 07:40:14 +00:00
Denis Kasak
88276e91d9 Fixed second call to Surface::centerOnX() (should have been centerOnY()).
svn-id: r43058
2009-08-05 00:05:36 +00:00
Denis Kasak
d3412ea3a4 Refactored Script::talk() to use the new centering methods.
svn-id: r43052
2009-08-04 19:09:41 +00:00
Denis Kasak
96744e42c7 Fixed bug in the math expression evaluator; when evaluating operators, operands were being popped from the stack in the wrong order.
svn-id: r43019
2009-08-03 01:06:13 +00:00
Denis Kasak
6bd1cfa1bd Implemented the Talk GPL command.
svn-id: r42992
2009-08-02 05:12:42 +00:00
Denis Kasak
18a8b5b3af * Added Game::runGateProgram()
* Added a separate mechanism to Game to keep track both of the current room number and the next room/gate. Periodically, I check whether the new room differs from the old one and, if it does, I do the change. Doing it any other would is nearly impossible because of the way the original scripts were written.
* Added GPL command Script::newRoom(). Rooms can now be traversed by clicking on their exits. Also, the intro animation partly works. Some parts go by far too soon. I assume this is because the engine still lacks a dialogue GPL command.
* Fixed bug where the gates array of a room was not cleared between uses.
* Save old jump value when we enter Script::run() and restore it in the end (mimicking the original engine).
* Fixed small bug where the gate was supposed to be stored as the first in-game variable and not the room number.

svn-id: r42957
2009-07-31 04:32:33 +00:00
Denis Kasak
6ed99df75a Removed some garbage I accidentally pasted into a comment.
svn-id: r42909
2009-07-29 20:42:55 +00:00
Denis Kasak
ad752b268b * Removed some code I forgot to remove in Game::startPlay() (a call to AnimationManager::play())
* Fixed logic checking for object visibility in various GPL commands (I originally misinterpreted the original engine code).

svn-id: r42908
2009-07-29 20:41:53 +00:00
Denis Kasak
393cd99a62 * Implemented the StartPlay and Play GPL commands properly
* Changed Script::load() to use the new animation callbacks

svn-id: r42902
2009-07-29 19:41:30 +00:00
Denis Kasak
dd9303d27e * Implemented GPL function ActPhase (as Script::funcActPhase())
* Trivial implementation of the Play GPL command
* Fixed Script::load() to load animation IDs to objects in increasing order (needed by funcActPhase())

svn-id: r42874
2009-07-29 01:02:50 +00:00
Denis Kasak
20baaf93f5 * Moved walking code to Game::walkHero().
* Implemented WalkOn GPL command.
* Temporarily remaped StayOn and WalkOnPlay to WalkOn (for testing).

svn-id: r42735
2009-07-25 04:36:43 +00:00
Denis Kasak
ceb9f18132 Made Script::run() manually mark the last animation index before it executes a program. This is done to prevent Release wreaking havoc if it is unpaired (i.e. if the script forgot to call a Mark first).
svn-id: r42733
2009-07-25 03:41:28 +00:00
Denis Kasak
ed59a12d53 Implemented ExecUse, ExecLook and ExecInit GPL commands.
svn-id: r42732
2009-07-25 03:37:22 +00:00
Denis Kasak
d28658984d * Added DraciEngine::_initArchive and made Game use it. Fixes a memory bug because Game uses pointers from the init archive which should outlive it (but didn't previously).
* Added support for setting loop status to Game.
* Made some GPL commands check whether we are in the correct loop status before executing.

svn-id: r42731
2009-07-25 03:28:04 +00:00
Denis Kasak
b7e97efb7f * Added handlers for the ObjStat and ObjStat_On GPL commands
* Removed temporary hack I accidentally committed

svn-id: r42730
2009-07-25 02:23:00 +00:00
Denis Kasak
5faceb595f Temporary mapped GPL command StartPlay to handler for Start and reenabled gates' scripts (for added effects and testing).
svn-id: r42684
2009-07-24 05:07:27 +00:00
Denis Kasak
c1ad0c3926 * Added tracking and deleting animations by index (which represents the order in which they were loaded). This is needed by some GPL commands.
* Added Game::getNumObjects() which returns the number of objects in the game
* Fixed segfault (accessing a null Animation *)
* Added some docs to various things

svn-id: r42683
2009-07-24 05:00:53 +00:00
Denis Kasak
e419110569 * Added Game::loop()
* Added WalkingMap::isWalkable()
* Renamed remaining _priority identifiers to _z which were left by mistake in the previous commit

svn-id: r42546
2009-07-17 00:20:57 +00:00
Denis Kasak
ffffc1bea4 * Changed Game members _numMasks, _init, _look, _use and _canUse from uint16 to int
* Modified Game::loadRoom to load gates and execute their scripts
* The first room loaded is now Game::_info._startRoom instead of 0
* Fixed reading of _pers0 and _persStep from the data files (they are 6 instead of 12 bytes)
* Added more debug info to Script and Game

svn-id: r42515
2009-07-15 19:06:24 +00:00
Denis Kasak
04e4bfdbbe * Implemented the following GPL functions: IsIcoOn, IcoStat, IsObjOn, IsObjOff, IsObjAway
* Changed GameObject::_location to an int since we sometimes use location -1.
* Some more uint <-> int changes to prevent comparisons between signed and unsigned.

svn-id: r42452
2009-07-13 19:53:53 +00:00
Denis Kasak
a41d36de0f Fixed bug in the GPL math evaluator (GPL function results were not pushed onto the evaluation stack).
svn-id: r42424
2009-07-12 18:55:44 +00:00
Denis Kasak
6b2991f488 Made Script::run() seek in SEEK_CUR mode when jumping instead of the default SEEK_SET. It also now checks whether there is a non-zero jump value set before doing the jump.
svn-id: r42254
2009-07-08 06:14:17 +00:00
Denis Kasak
d8c33f6836 * Implemented GPL jumps
* Implemented c_If, c_Goto and c_Let opcodes
* Changed the interpreter to work with signed ints instead of uints (the interpreter uses negative values sometimes)
* Fixed documentation of Script::run() which said it is a disassembler (forgot to change it earlier)

svn-id: r42249
2009-07-08 00:34:53 +00:00
Denis Kasak
dd955bb08e * Made Game::_variables private and, instead, added Game::{get,set}Variable() methods.
* Removed obsolete comment about the cyclic field not being used in Game::loadAnimation()

svn-id: r42246
2009-07-07 21:30:36 +00:00
Denis Kasak
bab9293f97 Implementend F_Not GPL function.
svn-id: r42245
2009-07-07 21:24:39 +00:00
Denis Kasak
586af0ab42 * From Game::GameObject removed the following _idxSeq, _numSeq, _animObj, _seqTab (not used anymore), added Common::Array<int> _anims.
* Handled cylic animations properly
* Handled the Z coordinate properly

svn-id: r42244
2009-07-07 21:18:28 +00:00
Denis Kasak
b6b1402368 * Changed Game::_variables to public since the GPL interpreter needs to use it and made it int instead of uint16
* Implemented variable accessing by the math evaluator
* Fixed bug from previous commit (should have used && when checking for ending instructions, not ||)

svn-id: r42242
2009-07-07 20:57:14 +00:00
Denis Kasak
318d406242 Made GPL interpreter exit on both gplend and exit instructions.
svn-id: r42241
2009-07-07 20:46:26 +00:00
Denis Kasak
fd2ab9e3c0 Added enum constant for the dragon object (kDragonObject) and made Script::start() a bit more readable.
svn-id: r42236
2009-07-07 19:50:12 +00:00
Denis Kasak
3b75b8003d Removed two variables that were committed by mistake.
svn-id: r42193
2009-07-06 19:43:21 +00:00
Denis Kasak
b2c24dd640 Implemented Script::funcRandom (GPL function).
svn-id: r42191
2009-07-06 19:26:53 +00:00
Denis Kasak
edaaca97f9 Set up GPL functions properly (the math evaluator now calls the handler if its implemented).
svn-id: r42188
2009-07-06 18:49:51 +00:00
Denis Kasak
237707dd6e Fixed bug where the GPL interpreter left parameters from previous commands on the stack.
svn-id: r42185
2009-07-06 17:29:44 +00:00
Denis Kasak
4e15262e74 Implemented Script::play() GPL opcode.
svn-id: r42184
2009-07-06 17:27:12 +00:00
Denis Kasak
f4ba64d2e4 Implemented GPL operators.
svn-id: r42183
2009-07-06 17:25:34 +00:00
Denis Kasak
fdf9eb84d6 Implemented handler for the Load instruction. Removed Script::dummy().
svn-id: r42102
2009-07-04 18:36:45 +00:00
Denis Kasak
885ce59ce8 Restructured Script so I can start adding callbacks to GPL commands (added DraciEngine * member to Script, added Script::setupCommandList() which initialises the command list array, added Script::dummy() callback for the Load command for testing).
svn-id: r42090
2009-07-04 14:48:36 +00:00
Denis Kasak
6a78781889 Added an offset parameter to Script::run() so we can specify where to start the GPL program execution. Also, the init script for the dragon object is now run inside Game::Game().
svn-id: r41928
2009-06-28 16:28:16 +00:00
Denis Kasak
f61b2d289d Changed Script::run() to accept a GPL2Program struct instead of a byte pointer and a length. Also, Script::run() now executes the GPL program until a gplend instruction rather than to the end of the whole program. Modified GameObject according to the new changes.
svn-id: r41927
2009-06-28 16:19:10 +00:00
Denis Kasak
4c524f5e0a Renamed Script::gpldisasm() to Script::run().
svn-id: r41920
2009-06-27 15:19:03 +00:00
Denis Kasak
97dde5e1ed Put all GPL interpreter related routines inside a Script class.
svn-id: r41919
2009-06-27 15:17:26 +00:00
Denis Kasak
2e30fae261 Renamed gpldisasm.* to script.* in anticipation of using it as a script intepreter.
svn-id: r41918
2009-06-27 15:00:14 +00:00