231 Commits

Author SHA1 Message Date
Robert Špalek
3ef5145b41 Reduced huge code duplication by introducing Game::stopObjectAnimations()
svn-id: r44961
2009-10-12 00:15:34 +00:00
Robert Špalek
6aaf99ec67 Disambiguated _anims.
It's both a pointer to an AnimationManager and list of animation ID's fo
each object.  The latter renamed to _anim so that I can easily search for
them.

Also, fixed the bug promised in the previous commit.

svn-id: r44960
2009-10-12 00:01:39 +00:00
Robert Špalek
62cebbb51e Implemented a few more harmless GPL2 commands
svn-id: r44958
2009-10-11 23:28:40 +00:00
Robert Špalek
f71b32dd96 Loading and caching sound samples in memory.
The sounds are not played yet, but the infrastructure is getting ready.

svn-id: r44957
2009-10-11 23:01:59 +00:00
Robert Špalek
eb56dfa965 Fixed two bugs concerning loading:
1. a room need to be reloaded by force when the loaded game is in the same
room as the game before the load
2. objects from the last room and their animations must be deallocated
before I change the room number

svn-id: r44638
2009-10-04 22:11:46 +00:00
Robert Špalek
42ee5350c3 Hack Game::_shouldExitLoop.
Immediate exit needed when loading a savegame hurts waiting in an inner
(strange) loop inside a GPL program, because animations don't progress at
all.  Reverted to the previous behavior and kept the immediate exit as a
hack for loading the game.

svn-id: r44590
2009-10-04 09:33:07 +00:00
Robert Špalek
1ed6a2668b Load inventory items properly after loading the game.
This solution is quite hacky, but so is the rest of the code, before a
future refactoring done one day.

svn-id: r44588
2009-10-04 09:13:15 +00:00
Robert Špalek
df14027c41 Implemented rudimentary game loading/saving.
Fixed many bugs in the boilerplate.  Saving (only) things that really need to
be saved.  Loading seems to work modulo dialogs and (possibly) inventory.

svn-id: r44586
2009-10-04 05:44:23 +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
4a7cea6813 Fixed event handling. ValGrind fixups.
My yesterday's fix on handling 1 event per call caused the game to be
unbearably slow on Linux.  The old way was much faster.  I have solved too
fast a succession of mouse button down and up by not clearing the mouse flag
when the button goes up instead.

Fixed a memory leak and uninitialized variable after my refactoring of game
location changes; found by ValGrind.

svn-id: r44525
2009-10-01 16:47:34 +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
Robert Špalek
5ad13a3dff Fix 2 ValGrind warnings.
svn-id: r44499
2009-09-30 21:07:04 +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
Robert Špalek
76a0bcb6c4 Implemented the map room, entered when 'm' is pressed.
svn-id: r44474
2009-09-30 04:33:52 +00:00
Robert Špalek
4be9e6cda0 Rewrite from scratch drawReScaled() and cropping now works well.
I left draw() as is for now, although it could also be similarly simplified.
Also, one could easily completely get rid of columnIndices[], but I was too
tired for the time being.

svn-id: r44457
2009-09-29 06:36:39 +00:00
Robert Špalek
00a733f7cf Clean up and unify positioning dragon's animations
svn-id: r44456
2009-09-29 05:54:59 +00:00
Denis Kasak
635769bd5d draci:
* Added const to some methods of Game.
* Removed some code cruft from Game::walkHero() (duplicate calculations and variables).
* Fixed small bug which prevented talking text from being centered above the dragon.

svn-id: r44455
2009-09-29 00:03:09 +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
ccc737a714 Fix a memory leak
svn-id: r44447
2009-09-28 11:28:09 +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
d0db596311 Fix rounding coordinates at the edge of the screen.
svn-id: r44430
2009-09-27 23:57:39 +00:00
Robert Špalek
a04881072a Reduce code duplication when cleaning animations
svn-id: r44422
2009-09-27 21:25:34 +00:00
Filippos Karapetis
e296cef9be Created a macro for lround(), for non-C99 compilers, and used that in places where lround() is used
svn-id: r44337
2009-09-25 09:48:43 +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
7106caca81 Replaced the C99 lround() with floor(), to get draci to compile under non-C99 compilers (e.g. VS)
svn-id: r44328
2009-09-25 07:05:26 +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
8ca10ac3b0 Fixed dialogues logic (some indexes were calculated erroneously +/- 1).
svn-id: r43312
2009-08-12 07:34:31 +00:00
Denis Kasak
c57515b5f8 Moved setting inactive dialogue option colour to an else branch.
svn-id: r43311
2009-08-12 05:38:15 +00:00
Denis Kasak
45e4f88e4e Removed unnecessary else branch in the part of the loop handling substatus Talk.
svn-id: r43310
2009-08-12 05:35:08 +00:00
Denis Kasak
e526983dbe Fixed erroneous comment mentioning gates in Game::runDialogueProg().
svn-id: r43309
2009-08-12 05:22:50 +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
303085c66b Whenever we enter the top-level loop, disable exiting by default (fixes the high-five scene between Bert and Eveline which ended too fast).
svn-id: r43306
2009-08-12 04:22:47 +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
3b0895dd2f Added some debug info for loop statuses and dialogues.
svn-id: r43295
2009-08-12 00:56:44 +00:00
Denis Kasak
9093e179cc Added dialogue selection colouring.
svn-id: r43256
2009-08-11 04:53:30 +00:00
Denis Kasak
51cc821619 Added dialogue support.
svn-id: r43253
2009-08-11 04:03:22 +00:00
Denis Kasak
abedc7e9bb Moved cursor state setting (when entering a new room) from Game::loadRoom() to Game::start() (just after running the gate program). This fixes a black cursor bug when the game starts (the cursor should not be even displayed then).
svn-id: r43162
2009-08-09 04:24:52 +00:00
Denis Kasak
eeb72e3d0d * Implemented Game::loadWalkingMap().
* Extracted title updating from the main loop to a new method, Game::updateTitle().
* Added Game::updateCursor().
* Restructured the main loop to fix many subtle bugs and enable some new functionality concerning object scripts (like support for room-global use scripts).
* Added support for tracking currently selected icons (items, probably should be renamed).
* Changed walkDir, lookDir and useDir members of GameObject to int and adjusted them for zero-based indexing.
* Added Game::getCurrentIcon().
* Return from WalkingMap::findNearestWalkable immediately if the starting point is walkable.

svn-id: r43160
2009-08-09 04:09:24 +00:00
Denis Kasak
c193c80e67 * Test whether an object can be used by evaluating its canUse script (warning: this will break many things currently working until I implement IsIcoAct in my next few commits).
* Removed old HACK note because look / use scripts are now more properly implemented.

svn-id: r43130
2009-08-08 16:17:21 +00:00
Denis Kasak
d2f7268171 Removed TODO concerning the nearest walkable point feature and reworded some obsolete documentation.
svn-id: r43128
2009-08-08 15:53:47 +00:00
Denis Kasak
19d5d66fd7 * Implemented WalkingMap::findNearestWalkable() which mimics a heuristic from the original game that attempts to find walkable spots near the given point
* Implemented moving to the right place when looking / using objects.

svn-id: r43125
2009-08-08 12:31:49 +00:00
Denis Kasak
3ce16763c7 Enabled skipping the current line of text if a mouse click occurs.
svn-id: r43085
2009-08-06 05:17:18 +00:00
Denis Kasak
5ea44b9b5e Moved walkHero() (in the main loop) to the appropriate place (in anticipation of a smart finding a walkable point) and disabled walking during script execution / inventory.
svn-id: r43084
2009-08-06 05:04:21 +00:00
Denis Kasak
09e49a354f Turn off mouse cursor and disable titles when running look / use scripts.
svn-id: r43083
2009-08-06 04:50:37 +00:00