[Scummvm-git-logs] scummvm master -> e5ebcd44b4d3ce9665ce3321343aaefa73f43ae6
sev-
sev at scummvm.org
Wed Jun 30 23:43:30 UTC 2021
This automated email contains information about 500 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
7eb9bcf705 GRAPHICS: Fix MSVC warning
57517dbe21 NANCY: Fix MSVC warning
0902272ab9 DIRECTOR: Fix MSVC warning
8510d6f41b WINTERMUTE: Fix MSVC warning
62e5f32dd8 SAGA2: Initial engine commit
984a6b5739 SAGA2: Remove duplicated functions
051e97c365 SAGA2: Unstub initializeGame()
6c9dc80384 SAGA2: Implement updateLoadMode()
57b3eb2e21 SAGA2: Replace one instance of clamp with CLIP
18c43a8402 SAGA2: Support original CD layout for FTA2
354713cb36 SAGA2: Kill file checking routines
18a51673a2 SAGA2: Kill graphics/audio init in towerfta.cpp
5eab675ee7 SAGA2: Implement openResources() with Common::File
7d0d52ed8e SAGA2: Update debug channels to include resources
25df9a7570 SAGA2: Make some code agree with conventions
055e58738a SAGA2: Rename resource class names according to conventions
dd18bce545 SAGA2: Switch memory routines for portable ones
5497cdf89c SAGA2: Clean up main.cpp a bit
1cce8104b1 SAGA2: Fixed a few warnings
95057bdc18 SAGA2: Read category from resource
1a0d619a7e SAGA2: Change RES_ID to MKTAG in some files
fde112d2b1 SAGA2: Import image decoding routines from SAGA
e7cfeb8bab SAGA2: Move FORBIDDEN_SYMBOL_ALLOW_ALL to individual files
823bdc404d SAGA2: Use Common::File operations for LoadResource
ee924d93ab SAGA2: Cleanup and fixing warnings
91c749d2d6 SAGA2: More comment cleanup
10c78758f4 SAGA2: Restored msgbox.*
04ecb9e275 SAGA2: Remove custom error handling
a9da39baed SAGA2: Change debug message in unpackImage
e9e3313ada SAGA2: Cleanup and removing unused files
863adf7918 SAGA2: Replace image unpack routines with original
b8ab6203e4 SAGA2: Rename abort() methods
a531df5354 SAGA2: Exposed random source
edceb1d824 SAGA2: Remove unneeded messagers and replace them with debugC()
1f1947c39a SAGA2: Remove winini.*
a41d378fed SAGA2: Remove mono.*
b76a1121d6 SAGA2: Const'ness
b036dddc9d SAGA2: Fix warnings
97fa02d7b8 SAGA2: Fix duplicated enums
4319fd55f5 SAGA2: Fix more warnings
8d5c31359e SAGA2: Blit test image to screen
0ad7e918d9 SAGA2: Fix gPort initialization
ac551e3c24 SAGA2: Fix formatting for unpackImage()
5eadf11a37 SAGA2: Fix more formatting
f8024e73cc SAGA2: More warning fixes
cda89805f1 SAGA2: Fix more warnings
a2a6c82bc2 SAGA2: Fix more warnings
36ead351f1 SAGA2: Fix incorrect change
177aa92900 SAGA2: Replace custom assert macros
44455e469e SAGA2: Fix resource loading and add initScripts() prototype
df22001476 SAGA2: Fix if statements to agree with conventions
bb044850a3 SAGA2: Add functions to get resource pointer and size by id
389de83222 SAGA2: Add warnings when ID is not found
6d218247bb SAGA2: Fix initScripts()
e5e85e2ff8 SAGA2: Get rid of some pointer arithmetic
676fd24e9c SAGA2: Initialize Thread in Saga2::run()
0eefd3b657 SAGA2: Make test script runnable
af8adadc73 SAGA2: Fix endianness in reading in lookupExport
3ee9ab9930 SAGA2: Replace rand()
cd6261fca3 SAGA2: Remove iff.*
426e750347 SAGA2: Code formatting
44d293f6fc SAGA2: Load ColorMapRanges from the .exe, kill maprange.cpp
7271d3b52a SAGA2: More removal of forbidden symbols
53d520e2cf SAGA2: Remove osexcept.*
3cb251421b SAGA2: Fix _numEntries
58ad6895eb SAGA2: Organize hresmgr functions
d4e1abcac7 SAGA2: Store (index, pointer) pairs into a HashMap
238380fd5b SAGA2: Cleanup gpointer.cpp
7a053bf1e3 SAGA2: Remove graphics initializer
a02aaadc73 SAGA2: Started cleanup for the video classes
a6f50cc6e0 SAGA2: Skip videoplayer initialization
ccc04196bc SAGA2: Allow looping through the scripts
2b9663ded4 SAGA2: Organize debug messages
08b6aca44b SAGA2: Fix tile initialization
e64f3079bb SAGA2: Fix compilation
4d2202da09 SAGA2: Fix filename in resource functions
5d8c85234f SAGA2: Cleanup some of initMaps()
dfaf98b2a7 SAGA2: Cleanup initMaps() more
308c258b4b SAGA2: Fix resource loading in hResContext constructor
a51985c8fb SAGA2: Cleanup tile.cpp a bit
2fe25abd98 SAGA2: Add kDebugTiles
ee8ffa657d SAGA2: Fix tile cycle initialization
5d86b6c2f6 SAGA2: Remove video routines
c9f74624ac SAGA2: Rename itevideo.cpp -> video.cpp and move it to Saga2Engine
6e47bc1dcd SAGA2: Implement SMK videoplayer and play intro video
65060ab0ca SAGA2: Decrease header dependency
a58fb4ac29 SAGA2: Reduce header dependency
e71207f680 SAGA2: Reduce header dependency in audio.*
d5dca40781 SAGA2: Add draw map test
8d16b5156d SAGA2: Further include dependency reduction
b1ac2cfe01 SAGA2: Cleanup playmode.cpp
137e62441e SAGA2: Cleanup intrface.cpp
5708989481 SAGA2: Fix display-related system initializations
d7ea7c0541 SAGA2: Import drawTile from SAGA
14781813ca SAGA2: Reduce header dependency
eca51bba37 SAGA2: Reduce header dependency
20e0ee7e70 SAGA2: More work on reducing header dependency
a24d6c7a1c SAGA2: More work on includes
a6b19daa9a SAGA2: Fix include order
c571279f1b SAGA2: Reduced header dependency for fta.h
3e79f9cd1b SAGA2: Remove rmemfta.h
0dba551dd5 SAGA2: Further work on include dependency reduction
358c3f7f84 SAGA2: Cleanup path.cpp
238c445ba3 SAGA2: Fix memory-magament issues in speldraw.cpp
78d8cf362e SAGA2: Fix more memory-related errors
46f062d54a SAGA2: Fix warnings
9a8c31cde3 SAGA2: Finish work on the nested includes
b9162e3de5 SAGA2: Cleanup test code on the engine start
6e8a939be7 SAGA2: Fix initSystemTimer() stub
7fbe19751b SAGA2: Cleanup task.h
2d0fdf1fe2 SAGA2: Fix palette loading
3e0d5ec5cd SAGA2: Fix panel loading
392690a107 SAGA2: Fix RES_ID calls
6d3cc8c9e4 SAGA2: Fix Route Data initialization
4a5b055e10 SAGA2: Reduce header dependencies
68bbf3c16c SAGA2: Reduce header dependency
9ba0a2e46c SAGA2: Finish reducing include dependencies
34af614f8e SAGA2: Fix actor sprite initialization
5969577a2b SAGA2: Fix object prototypes initialization
f74ed3eabb SAGA2: Fix objects.cpp more
72b159095f SAGA2: Turn loading from .exe into a data-driven
ea35f4728e SAGA2: Load image cursors from .exe, delete images.*
b8cdec88bd SAGA2: Fix ResourceActor loading
d54d3a0dce SAGA2: Fix ResourceActor size
9bde6969e1 SAGA2: Fix object prototype loading
c628f16be1 SAGA2: Fix game object loading
4e605d24f8 SAGA2: Fix ActiveItemStates initialization
98a454470e SAGA2: Replace memory management methods in tile.cpp
9ac480ef36 SAGA2: Increase maxSensorSize
6a96f6d87c SAGA2: Fix sprite banks loading
05c3ed6ea0 SAGA2: Implement keyboard/mouse event handling
6c9e092973 SAGA2: Implement breakEventLoop()
982f6f8725 SAGA2: Cleanup event-related stubs
1c41a3098a SAGA2: Fix MetaTile loading
6f21e5f7cc SAGA2: Implement palette setting
6edd3ae7b5 SAGA2: Fix warnings
e916e99d5f SAGA2: Fix warnings
96bebe4853 SAGA2: Fix warnings
99d0035d61 SAGA2: Fix pose/colorscheme loading
91d47cb480 SAGA2: Cleanup handles in drawObject
1fd59c3759 SAGA2: Fix warnings
8f19630ded SAGA2: JANITORIAL: Fix code formatting
653998e4f1 SAGA2: Cleanup unneeded stubs
4520b3ffa3 SAGA2: Fix assocList reading
d6caa21992 SAGA2: Fix activeItemData loading
36d672189e SAGA2: Fix global buffer overflow in terrain.cpp
201743952c JANITORIAL: Code formatting
9642a17a0b SAGA2: Fix drawPage initialization
943df6181e SAGA2: Fix mouseimg alloc-dealloc problem
d57f807e55 SAGA2: Insert osystem draw functions
cb9004e2a0 SAGA2: Add debug channel for palettes
f53042a224 SAGA2: Stub checkRestartGame
26cd352872 SAGA2: Fix memory allocation in floating.cpp
e87ff70344 SAGA2: Fix font data reading in gtext.cpp
1c157566a0 SAGA2: Fix textImage.data freeing in mouseimg.cpp
8d862027ba SAGA2: Fix warnings in mouseimg.cpp
f9fe364f14 SAGA2: Fix memory-related errors on exit
6f18b7b25d SAGA2: Disable audio interface temporarily
1d1712df0a SAGA2: Fix displayUpdate condition
98e7e8fab0 SAGA2: Remove unused method
bc34ccb8a3 SAGA2: Rewrite ThreadList for using conventional array
269a21cdef SAGA2: Stub loading async resources
a6ec2a77de SAGA2: Implement few low level drawing routines
6916f47f95 SAGA2: Hid noisy warning
c7c4db7c38 SAGA2: More low-level drawing code
9f38ff10cd SAGA2: Fix unitialized variable
a76d3ff760 SAGA2: Show cursror
d53bc7074c SAGA2: Correctly initialize Points and Rectangles
20d3131c16 Revert "SAGA2: Fix unitialized variable"
716d3148c3 SAGA2: Initialize mainPort and blit its contents
b4acb68254 SAGA2: Shift palette
271a27dbdb SAGA2: Fix some initialization steps
1357f1bade SAGA2: Increase noisy message's debug level
512f1268d7 JANITORIAL: Fix formatting
7d929d67a7 SAGA2: Initial code cleanup for PatrolRoutes
26798e29eb SAGA2: Rewrote PatrolRoute to Common::Stream and portability fixes
57f9908fa4 SAGA2: Fix mainPage initialization
cc1e289597 SAGA2: Set blip relative to mainPort
79e1a95181 SAGA2: Fix gDisplayPage::bltPixels
68dd738ec8 SAGA2: Plug memory leak
1c562392a0 SAGA2: Complete vWDisplayPage::writeTransPixels(). This fixes text rendering
67688d5eb1 SAGA2: Implemented more graphics-related methods
58cd891353 SAGA2: Remove unused graphics primitives
ab19d4437b SAGA2: Remove unnecessary drawing code
555a2053da SAGA2: Fix cursor location
4a7092c449 SAGA2: Fix cursor location again
c35f98e9f0 SAGA2: Remove unneccessary cursor drawing code
9d92c17928 SAGA2: Replace rmem in grabinfo.cpp
b9e04f912e SAGA2: Cleanup grabinfo.cpp
067fcb00d7 SAGA2: Fix save game dialog crash
8051350749 SAGA2: Cleanup uidialog.cpp
d72f53efdc SAGA2: Fix activeItemList loading
b4558ea22c SAGA2: Fix tile rendering
1063a98c22 SAGA2: Implement unpackSprite()
262dc756ad SAGA2: Code cleanup
a6827afb6e SAGA2: Re-added accidentally removed debug code
c432dc7442 SAGA2: Cleanup tileload.cpp
1481a8c9df SAGA2: Work on fixing map loading
419b3f8506 SAGA2: Fix tileBanks loading
24eb580ea3 SAGA2: Remove anonymous struct in actor.h
ffc0ed5fd2 SAGA2: Eliminate global objects in weapons.cpp
c4071bc8e9 SAGA2: Cleanup for weapons.cpp
8833b47fe4 SAGA2: Fix crash because of fetchPlatform
4150f987aa SAGA2: Added more debug output
74a572b12c SAGA2: Fix alloc-dealloc mismatch in cleanupMaps
88b857ce48 SAGA2: Change debug messages
b0d5437227 SAGA2: Made weapon loading portable
4eebd6d6bf SAGA2: Fix remaining warnings in weapons.cpp
97f7a0e529 SAGA2: Drop custom TRUE/FALSE
6d09e62b2b SAGA2: Add more debug messages
9d8887f297 SAGA2: Cleanup weapons.h
c9d0eb45d0 SAGA2: Rename class viariables in weapons.h
364c3469af SAGA2: Implement maskTile() and do cleanups
26f6c564ed SAGA2: Remove ReadTimer()
c7fad67025 SAGA2: Remove input.cpp
2f10c15f9f SAGA2: Fix warning in motion.h
54fb9a226a SAGA2: Added warnings for unsafe pointer arithmetics
75f66d267c SAGA2: Add more debug messages
e3d66a8d05 SAGA2: Cleanup tileload.h
d116f2c34b SAGA2: Rename class variables in tileload.h
59e21d89ad SAGA2: Load tile bank in constructor
87f37e6427 SAGA2: Rename TileBank's class variables
04a5d3936f SAGA2: Rename a few global variables in tile.cpp
9bc9370e37 SAGA2: Make custom alarms use OSystem::getMillis
05275a3129 SAGA2: Temporary crash prevention
4d0272732f SAGA2: Fix crash on thread deletion
9eca51a159 SAGA2: Move platformLRU to Common::List
1e9f393e08 SAGA2: Move appearanceLRU to Common::List
2b67a92944 SAGA2: Code cleanup
e1b7e43878 SAGA2: Remove dlist usage in loadSpriteBanks
805fc06ed2 SAGA2: Load sprite resources portably
4b5ab189f3 SAGA2: Fix alloc-dealloc mismatch in cleanupSprites
dfd278c300 SAGA2: Print out opcodes during execution
6742ee174d SAGA2: Implement Point16 loading with Common::SeekableReadStream
a825bbbcb7 SAGA2: Print stack on execution
9b298a0328 SAGA2: Print out address modes during script execution
0e0bd85b40 Revert "SAGA2: Make custom alarms use OSystem::getMillis"
aee8d39e7c SAGA2: Load TileBank and MapHeader with Common::SeekableReadStream
a4fcdbb8f5 SAGA2: Get rid of pointer arithmetics for metaList
f35c05a9de SAGA2: Rename class variables MetaTile
180a72377f SAGA2: Merge timer.cpp and timers.cpp
2d85ffea2f SAGA2: Disable timer for now
cf61650d1b SAGA2: Rewrite TimerList using Common::List
83af12f5e6 SAGA2: Fix warning
ce603fe4e8 SAGA2: Fix some warnings in tile.cpp
b43ddb3162 SAGA2: Make some buffer reading code portable
0535d6bd19 SAGA2: Replace some buffer usage by stream in tile.cpp
2948280be8 SAGA2: Fix some formatting
c594b9304b SAGA2: Move some tile constants to idtypes.h
3839393223 SAGA2: Move tcoords.h constants into idtypes.h
f9ecdb80ae SAGA2: Move platform metric constants to idtypes.h
f930e14188 SAGA2: Use Common::HashMap for active items hash
ed2fe2befc SAGA2: Create destructors for MapHeader and MetaTileList
fb2612399a SAGA2: Classify activeItemList
da94093b43 SAGA2: Load spellSprites and spellSchemes with streams
796c3a0f7d SAGA2: Use ColorSchemeList in speldraw.cpp
127299672b SAGA2: Load schemeList with stream
c4477edc40 SAGA2: Add stub warning to Thread deconstructor
a9729be225 SAGA2: Move tile.h constants to idtypes.h
706593f763 SAGA2: Load nameList with stream
bc35986f95 SAGA2: Use Common::Array for nameList
193f616225 SAGA2: Clean up vwpage.cpp
35a90c132e SAGA2: Merge vwdraw.cpp and vwpage.cpp
c35aef8ad2 SAGA2: Fix accidental read in tile.cpp
6fe11531b6 SAGA2: Rename platform metric constants
cd48eeca19 SAGA2: Rename tile uv-coord constants
6dad132e83 SAGA2: Rename map sector constants
500a6ba468 SAGA2: Rename metatile metric constants
2ac1b6f55d SAGA2: Rename more constants in idtypes.h
245f586903 SAGA2: More details on address debugging
2a093b51d2 SAGA2: Fix debug output
ac62a48ace SAGA2: Improve stack debug output
23d841a04a SAGA2: Make ActiveItem script-friendly
277245a49e SAGA2: Made ActiveMission script-friendly
c575ca2995 SAGA2: Put GameObject data into a packed struct
baa7cbb498 SAGA2: Make GameObject script-friendly
260a82c3e0 SAGA2: Reenable game timers
b5359d7202 SAGA2: Fix incorrect object accesses
5b1671fb69 SAGA2: Fix overridden methods
1919ef1f5e SAGA2: Fix GameObject referencing in sagafunc.cpp
189b558e94 SAGA2: Remove unnecessary if
7fe61635e0 SAGA2: Fix more override warnings
10d527d5cc SAGA2: Fix warnings
47ea8aa5d7 SAGA2: Replace DList with Common::List in intrface.h
c92315fca6 SAGA2: More warning fixes
8c47310314 SAGA2: Fix thread deletion
50868e2608 SAGA2: Removed DList from Task and TaskList
36e9a264c8 SAGA2: Reworked ActorAssignment to not use dirty pointer hacks
9565ea67a3 SAGA2: Added safeguards to sprite unpacking
a445537f48 SAGA2: Fix stack overflow
ac8c438dac SAGA2: Non-fatal warning on failed resource load
9649d168f8 SAGA2: Disable audio
4f363da243 SAGA2: Accommodate for resource loading errors
a532e97f3e SAGA2: Fix Actor void initialization
8aca55e10b SAGA2: Fix animation access
291add3cd6 SAGA2: Fix player iterator access in player.cpp
5e599dfb6e SAGA2: Fix unsafe world access on objObscured
ca6530a601 SAGA2: Improve address methods debug output
e0a9476145 SAGA2: Fix warning
b585f1bb03 SAGA2: Fix copy/paste error in resource loading
ffa1c98eea SAGA2: Increase level of noisy warning
efda4028a9 SAGA2: Fix some warnings
1ab3ffa869 SAGA2: Fix more warnings
1776549073 SAGA2: Properly read ActorAnimations
e1869af2c4 SAGA2: Cleanup and more sanity checks for resource loading
9fa23205d6 SAGA2: Added more sanity checking
9b76670b45 SAGA2: Made sprite unpacking more robust
0bfaddc55b SAGA2: Cleanip includes in sprite.h
91882aca4e SAGA2: Fix platform fetching
12535d74bc SAGA2: Add fallback for invalid sector access
cbff8ad38e SAGA2: Revert updateFrameCount
949904de3a SAGA2: Stub updatePerfStats
d19784fc91 SAGA2: Remove FPS counters
b34ee434dd SAGA2: Fix in-game timer frequency
d6a2b6a8e0 SAGA2: Rewrite Sensors to use Common::List
e60a181b8e SAGA2: Remove RPool usage from path
868a77f1e9 SAGA2: Fix double free in number of places
6a8aadb1fa SAGA2: Remove pool.*
fee6fb6ead SAGA2: Fix another double free
34ae4988f7 SAGA2: Added more debug output
4119efb93a SAGA2: More debug output to unpackSprite() and disabled most of it
a0b9425f9e SAGA2: Fix alloc-dealloc mismatch in spriteBanks
bdf005cac1 SAGA2: Fix invalid sector activation
8bae7aa52b SAGA2: Add more debug output
eac033d227 SAGA2: Call deleteTask on task destruction
054c920251 SAGA2: Change assert to warning in fetchPlatforms
90b82851f2 SAGA2: Update cycleList usage in sagafunc.cpp
cee4f07c1b SAGA2: Remove DNode from PlatformCacheEntry
46f14c4f1e SAGA2: Fix warnings in actor.cpp
07d27868e7 SAGA2: Fix warnings in spellio.cpp
634732e42f SAGA2: Remove residual debug code
751a6d086a SAGA2: Get rid of rmem in speech.cpp
f0fe90c267 SAGA2: Fix overridden methods
ccc350d400 SAGA2: Fix more warnings in actor.cpp
1cc521808f SAGA2: Fix double free
d295808363 SAGA2: Fix warnings in objects.cpp
7e73510bb4 SAGA2: Fix object name loading
6819c2ae15 SAGA2: Cleanup string copying
d858e593c0 SAGA2: Fix tile draw offset
96f883650f SAGA2: Cleanup mouseimg.cpp
254540bc9d SAGA2: Remove mouse polling warning
e49f37f230 SAGA2: Fix platform cacheing
f7fcec7b62 SAGA2: Fix code formatting
054f0d4870 SAGA2: Fix warnings in tile.cpp
92a0ec784b SAGA2: Fix warnings in target.cpp
485cdce8eb SAGA2: Fix more warnings
5f1d4e1c73 SAGA2: Fixing bug in the original. If there is no weapon, actor itself is a weapon
3979138f24 SAGA2: Rename PortraitType enum
2af306a60a SAGA2: Fix warnings in player.cpp
c5efa4fd80 SAGA2: Fix warnings in panel.cpp
a67ed67448 SAGA2: Fix warnings in sprite.cpp
83fad9d0f1 SAGA2: Fix warnings in moton.cpp
405b8cc230 SAGA2: Fix bugs in the original with the combat action in the savegame
aa8d7544ab SAGA2: Fix warnings in main.cpp
6cda95cefc SAGA2: Fix more warnings
10ea74f5d9 SAGA2: Attempt to fix another original bug
963791245e SAGA2: Fix warnings in speech.cpp
ce490339db SAGA2: Fix another warning
415277d19e SAGA2: Fix more warnings
ca1831e4c0 SAGA2: Cleanup in audiobuf.cpp
16ce00056d SAGA2: Fix warnings in noise.cpp
5e519d2ca5 SAGA2: Remove errors.h
bf9154a01a SAGA2: Fix warnings in path.cpp
cfb64ca4d6 SAGA2: Fix warnings in button.cpp
f4203b3d27 SAGA2: Get rid of checkAlloc()
4a71417f5c SAGA2: Replace custom config code with ScummVM
d7b74d5408 SAGA2: Fix endianness on scriptMakeActor
732c87dd2c SAGA2: Fix ResourceObjectPrototype copy constructor
4748257123 SAGA2: Fix some warnings
09c4a42d32 SAGA2: Add warning for missing methods
fa11dcd1a4 SAGA2: Fix more warnings
f9bc954de0 SAGA2: Added mapping to the SAGA classes
36ea80697b SAGA2: Remove rmem from button.cpp
54d2e7ac11 SAGA2: Kill rmem and rserver
a640006ea6 SAGA2: Fix more warnings
d83fc2c8aa SAGA2: Unstubbed GameMode::SetStack()
b59c9d3334 SAGA2: Remove unused unsafe method
ebe78d8c99 SAGA2: Cleanup gtext.cpp
794fde8f9c SAGA2: Fix more warnings
d8ca5e031a SAGA2: Load actor resources with stream
c452adaf1b SAGA2: Load ResourceGameObject with stream
f367c884cb SAGA2: Fix memory leak
ba5d06a20a SAGA2: Load prototypes with stream
e659aa14d3 SAGA2: Load more stuff with stream
e90a71d2fd SAGA2: Kill hResContext read* functions
44c4ad38e9 SAGA2: Fix rest of the non-global-constructor warnings
37bd0e9c38 SAGA2: Replace elementsof with ARRAYSIZE
2161d9e388 SAGA2: Removed std.h
ef389b13ff SAGA2: Remove DList from path.cpp
8bf479ba43 SAGA2: Raise level of noisy warning
8940f362a2 SAGA2: Add debug output to path.cpp
9b02c77bee SAGA2: Fix ThreadList::next
9a39a34a5d SAGA2: Remove unnecessary warning
d038657294 SAGA2: Change code for readability
5580bcc112 SAGA2: Revert getMillis back to gameTime
5bb5fe9396 SAGA2: Change some classes into packed structs
3ad054d85c SAGA2: Properly mark structs as packed
14811e3202 SAGA2: Fix some gcc warnings
a8600afb26 SAGA2: Amend unsafe and strange pointer arithmetics in lineTerrain()
9f9808e759 SAGA2: Remove unneeded header
27dd030e94 SAGA2: Fix more gcc warnings
14da1dcc51 SAGA2: More gcc warning fixes
45075d5e0c SAGA2: Fix remaining trivial gcc warnings
45a0023da8 SAGA2: Fix bug in the original with poisoning effect
236130d6af SAGA2: Fix bug in the original, when bouncing was leading to death
4b0b742baa SAGA2: Revert stub in objObscured
f39036ff8e SAGA2: Move motion.cpp from DList
d39fa6e86e SAGA2: Fallback for invalid sector deactivation
f60d4a18fc SAGA2: Fix MotionTaskList::newTask
51a6baab82 SAGA2: Fix assignment flag setting
3b9c1f530f SAGA2: Fix copy-paste error in actor.cpp
7a8a5e6e6e SAGA2: Added more debug output
13831e17c1 SAGA2: Add more debug output
708a5b374b SAGA2: Add more debug output
29ab7ab001 SAGA2: Added more debug output
8a9827985d SAGA2: Print out object names
74a5424dce SAGA2: Get rid of DList is tile.cpp
81505c6feb SAGA2: Fix object activation mistake in updateImage
4c0d6d0e63 SAGA2: Print Task type on deletion
6f9d0728d3 SAGA2: Fix unremoved GotoTask
279f41d02c SAGA2: Added debug print method
88f0158077 SAGA2: Fix delete on TaskStack::abortTask
99c8e3f59a SAGA2: Fix double free in removeAllTimers
540d58a135 SAGA2: Add more debug output
080ad92b23 SAGA2: Hid a noisy log message deeper
b0cf10eb67 SAGA2: Add speech debug output
abad186530 SAGA2: Fix timer delete on removeAllTimers
5761c83004 SAGA2: Remove DList from speech.cpp
8e7ef16608 SAGA2: Remove Dlist usage from band.cpp
cf8b7945b8 SAGA2: Move bandList from global to SagaEngine
a85940e77d SAGA2: Unstub mouse-related interface functions
8f9c326747 SAGA2: Raise level of script stack debug messages
8748806a5c SAGA2: Add more debug messages
932b20ace6 SAGA2: Fix warnings
8da92d2af5 SAGA2: Cleanup speech.cpp
b210e1691f SAGA2: Get rid of some global constructors in uidialog.cpp
23953b6d9c SAGA2: Rename some constants in uidialog.cpp
3cd0cc90d2 SAGA2: Cleanup noise.cpp
389990009e SAGA2: Initial work on sound subsystem
b72d66a393 SAGA2: Initial code for voice playback
1df171e36b SAGA2: Delete timers on list removal
cf7e412b59 SAGA2: Get rid of some global constructors
1aad98b3bf SAGA2: Remove more global constructors
c290115f74 SAGA2: Move some uidialog.cpp constants to idtypes.h
349028e262 SAGA2: Remove more global constructors
17af3b9c2c SAGA2: Fix rate for the shorten audio
03409d77cd SAGA2: Added more debug output to sound
0e6d008ef9 SAGA2: Improved debug output
7fc299c4e4 SAGA2: Added stub for stillDoingVoice()
596706948d SAGA2: Re-enable audio
56b351d645 SAGA2: Add SoundQueue
06d708fd9a SAGA2: Increase level of noisy stub warning
f37fceb82b SAGA2: Add sound/music handles for SoundQueue
a19250b36b SAGA2: Add isSpeechPlaying(soundSegment) stub
e4ca5a7864 SAGA2: Get rid of some global constructors
deb8ee29a4 SAGA2: Remove global constructors in floating.cpp
e1b48b6215 SAGA2: Remove some global constructors in intrface.cpp
c2af56f012 SAGA2: Move appearanceLRU to Saga2Engine
d63e2c1ca5 SAGA2: Remove some global constructors in path.cpp
9d55dced84 SAGA2: Fix code formatting for consistency
cea3e83f72 SAGA2: Remove global constructors from msgbox.cpp
2e4246faa3 SAGA2: Print non-printables in debug messages
6aa642a54a SAGA2: Remove commas at ends of enumerations
725f11ca60 SAGA2: Fix more warnings with enumarations
dab42f94f2 SAGA2: Remove test-purposes code
408bd41daf SAGA2: Fix more enum warnings
50a0807d2f SAGA2: Fix automap panel initalization
6179f9fac5 SAGA2: Fix global constructor warnings on noise.cpp
a79b1379e4 SAGA2: Fix more warnings
c683a1df47 SAGA2: Fix intrface initialization
21077e5d13 SAGA2: More enum warnings fixed
bede93482c SAGA2: Fix uidialog.cpp static initializers
eeb969fa35 SAGA2: Fix more enum warnings
c308387589 SAGA2: Fix another warning
7fe3baf184 SAGA2: Clear some WindowDecoration global constructor warnings
c586d3c590 SAGA2: Clear global constructor warnings in uidialog.cpp
e6f0beb243 SAGA2: Clear more global constructors
4c1376844f SAGA2: Fix more WindowDecoration global constructors
46e38b5a5b SAGA2: Cleanup Win32-specific code
5dc97185ee SAGA2: Fix remaining WindowDecoration constructor warnings
307e094d4f SAGA2: Stubbed musicBuffer methods
b02941237d SAGA2: Fix unreferenced symbols
654964aad0 SAGA2: Fix global constructors in document.cpp
6f70073b56 SAGA2: Fix initializer list warnings
07153ec2cb SAGA2: Remove unneeded file
c14b9f9389 SAGA2: Fix MSVC compilation
3c14a99f7c SAGA2: Fix non-portable cast from pointer to long
e9671a73eb SAGA2: Fix MSVC warnings
16356103a4 SAGA2: Fix codacy warnings
f8b24c5e58 SAGA2: Fix initialization warning in path.cpp
176c81b074 SAGA2: Fix StaticWindow warnings
4a8f7d500f SAGA2: Fix uninitialized variables
4048869485 SAGA2: Move mainPort to Saga2Engine
19c3be9104 SAGA2: Fix some global constructor warnings
53b4eb47a6 SAGA2: Fix some warnings in motion.cpp
1d88f03012 SAGA2: Fix global constructor warnings in motion.cpp
85b1c8e842 SAGA2: Move mouseInfo to Saga2Engine
30071b6046 SAGA2: Move ImageCache to Saga2Engine
b0031f51bb SAGA2: Fix some global constructor warnings
e5ebcd44b4 SAGA2: Fix code formatting
Commit: 7eb9bcf70580f52fcd16c6b5f1743c49c81b6be5
https://github.com/scummvm/scummvm/commit/7eb9bcf70580f52fcd16c6b5f1743c49c81b6be5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:35:58+02:00
Commit Message:
GRAPHICS: Fix MSVC warning
Changed paths:
graphics/surface.cpp
diff --git a/graphics/surface.cpp b/graphics/surface.cpp
index a319767e8a..b90c51c644 100644
--- a/graphics/surface.cpp
+++ b/graphics/surface.cpp
@@ -589,8 +589,8 @@ void Surface::debugPrint(int debuglevel, int width, int height, int x, int y, in
const byte *srcRow = (const byte *)getBasePtr(xx, yy + ys);
for (int xs = 0; xs < scale && xx + xs < w; xs++) {
- byte r, g, b, a;
- uint32 color;
+ byte r = 0, g = 0, b = 0, a = 0;
+ uint32 color = 0;
switch (format.bytesPerPixel) {
case 1: {
Commit: 57517dbe21f53f6d03fd08cdfe7f2433b21a237a
https://github.com/scummvm/scummvm/commit/57517dbe21f53f6d03fd08cdfe7f2433b21a237a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:35:58+02:00
Commit Message:
NANCY: Fix MSVC warning
Changed paths:
engines/nancy/ui/textbox.cpp
diff --git a/engines/nancy/ui/textbox.cpp b/engines/nancy/ui/textbox.cpp
index 7223e1aef5..55ba0dbe1e 100644
--- a/engines/nancy/ui/textbox.cpp
+++ b/engines/nancy/ui/textbox.cpp
@@ -168,7 +168,7 @@ void Textbox::drawTextbox() {
// Remove hotspot tokens and mark that we need to calculate the bounds
// A single text line should only have one hotspot, but there's at least
// one malformed line in TVD that breaks this
- uint32 hotspotPos, lastHotspotPos;
+ uint32 hotspotPos, lastHotspotPos = 0;
while (hotspotPos = currentLine.find(_hotspotToken), hotspotPos != String::npos) {
currentLine.erase(hotspotPos, ARRAYSIZE(_hotspotToken) - 1);
Commit: 0902272ab93826f2e070fb7e7c946d5a4845d498
https://github.com/scummvm/scummvm/commit/0902272ab93826f2e070fb7e7c946d5a4845d498
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:35:58+02:00
Commit Message:
DIRECTOR: Fix MSVC warning
Changed paths:
engines/director/lingo/lingo-bytecode.cpp
diff --git a/engines/director/lingo/lingo-bytecode.cpp b/engines/director/lingo/lingo-bytecode.cpp
index c94247df5c..5714d36348 100644
--- a/engines/director/lingo/lingo-bytecode.cpp
+++ b/engines/director/lingo/lingo-bytecode.cpp
@@ -721,7 +721,7 @@ void LC::cb_v4theentitypush() {
case kTEAString:
{
Datum stringArg = g_lingo->pop();
- ChunkType chunkType;
+ ChunkType chunkType = kChunkChar;
switch (entity) {
case kTheChars:
chunkType = kChunkChar;
Commit: 8510d6f41be3b3d90c956e5212ffec312a2ecc37
https://github.com/scummvm/scummvm/commit/8510d6f41be3b3d90c956e5212ffec312a2ecc37
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:35:58+02:00
Commit Message:
WINTERMUTE: Fix MSVC warning
Changed paths:
engines/wintermute/base/gfx/x/active_animation.cpp
diff --git a/engines/wintermute/base/gfx/x/active_animation.cpp b/engines/wintermute/base/gfx/x/active_animation.cpp
index de69634a14..0ec9c3ec71 100644
--- a/engines/wintermute/base/gfx/x/active_animation.cpp
+++ b/engines/wintermute/base/gfx/x/active_animation.cpp
@@ -73,7 +73,7 @@ bool ActiveAnimation::update(int slot, bool prevFrameOnly, float lerpValue, bool
return false;
}
- uint32 localTime;
+ uint32 localTime = 0;
//_gameRef->LOG(0, "%s %d %d %f %d", m_Animation->m_Name, Slot, PrevFrameOnly, LerpValue, ForceStartFrame);
if (prevFrameOnly) {
localTime = _lastLocalTime;
Commit: 62e5f32dd8ff36e63e5d5be598bd352cf745a8b6
https://github.com/scummvm/scummvm/commit/62e5f32dd8ff36e63e5d5be598bd352cf745a8b6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:44+02:00
Commit Message:
SAGA2: Initial engine commit
Changed paths:
A engines/saga2/actor.cpp
A engines/saga2/actor.h
A engines/saga2/annoy.h
A engines/saga2/arrowptr.cpp
A engines/saga2/assign.cpp
A engines/saga2/assign.h
A engines/saga2/audio.cpp
A engines/saga2/audio.h
A engines/saga2/audiobuf.cpp
A engines/saga2/audiobuf.h
A engines/saga2/audiocmp.h
A engines/saga2/audiodec.h
A engines/saga2/audioerr.h
A engines/saga2/audiofnc.h
A engines/saga2/audiogvc.h
A engines/saga2/audiomem.h
A engines/saga2/audiores.cpp
A engines/saga2/audiores.h
A engines/saga2/audiosmp.h
A engines/saga2/audiosys.h
A engines/saga2/audiotmr.cpp
A engines/saga2/audiotmr.h
A engines/saga2/audproto.h
A engines/saga2/audqueue.h
A engines/saga2/audtweak.h
A engines/saga2/automap.cpp
A engines/saga2/automap.h
A engines/saga2/band.cpp
A engines/saga2/band.h
A engines/saga2/beegee.cpp
A engines/saga2/beegee.h
A engines/saga2/bitarray.h
A engines/saga2/blitters.cpp
A engines/saga2/blitters.h
A engines/saga2/button.cpp
A engines/saga2/button.h
A engines/saga2/calender.cpp
A engines/saga2/calender.h
A engines/saga2/cmisc.h
A engines/saga2/code.h
A engines/saga2/combat.h
A engines/saga2/config.cpp
A engines/saga2/config.h
A engines/saga2/configure.engine
A engines/saga2/contain.cpp
A engines/saga2/contain.h
A engines/saga2/detection.cpp
A engines/saga2/detection.h
A engines/saga2/dice.h
A engines/saga2/display.cpp
A engines/saga2/display.h
A engines/saga2/dispnode.cpp
A engines/saga2/dispnode.h
A engines/saga2/dlist.cpp
A engines/saga2/dlist.h
A engines/saga2/document.cpp
A engines/saga2/document.h
A engines/saga2/effects.cpp
A engines/saga2/effects.h
A engines/saga2/enchant.cpp
A engines/saga2/enchant.h
A engines/saga2/errbase.cpp
A engines/saga2/errbase.h
A engines/saga2/errclass.cpp
A engines/saga2/errclass.h
A engines/saga2/errlist.cpp
A engines/saga2/errlist.h
A engines/saga2/errors.cpp
A engines/saga2/errors.h
A engines/saga2/errtype.h
A engines/saga2/exit.cpp
A engines/saga2/floating.cpp
A engines/saga2/floating.h
A engines/saga2/fontlib.h
A engines/saga2/fta.h
A engines/saga2/gamemode.cpp
A engines/saga2/gamerate.h
A engines/saga2/gbevel.h
A engines/saga2/gblitter.h
A engines/saga2/gdraw.cpp
A engines/saga2/gdraw.h
A engines/saga2/gpointer.cpp
A engines/saga2/gpointer.h
A engines/saga2/grabinfo.cpp
A engines/saga2/grabinfo.h
A engines/saga2/grequest.cpp
A engines/saga2/grequest.h
A engines/saga2/gtext.cpp
A engines/saga2/gtextbox.cpp
A engines/saga2/gtextbox.h
A engines/saga2/hresmgr.cpp
A engines/saga2/hresmgr.h
A engines/saga2/idtypes.h
A engines/saga2/iff.cpp
A engines/saga2/iff.h
A engines/saga2/imagcach.cpp
A engines/saga2/imagcach.h
A engines/saga2/images.cpp
A engines/saga2/images.h
A engines/saga2/input.cpp
A engines/saga2/input.h
A engines/saga2/interp.cpp
A engines/saga2/intrface.cpp
A engines/saga2/intrface.h
A engines/saga2/ioerrors.h
A engines/saga2/itevideo.cpp
A engines/saga2/itevideo.h
A engines/saga2/keybored.cpp
A engines/saga2/loadmsg.cpp
A engines/saga2/loadmsg.h
A engines/saga2/loadsave.cpp
A engines/saga2/loadsave.h
A engines/saga2/localize.h
A engines/saga2/magic.cpp
A engines/saga2/magic.h
A engines/saga2/main.cpp
A engines/saga2/mainmap.cpp
A engines/saga2/mainmap.h
A engines/saga2/mapfeatr.cpp
A engines/saga2/mapfeatr.h
A engines/saga2/maprange.cpp
A engines/saga2/messager.cpp
A engines/saga2/messager.h
A engines/saga2/metaengine.cpp
A engines/saga2/methods.r
A engines/saga2/mission.cpp
A engines/saga2/mission.h
A engines/saga2/modal.cpp
A engines/saga2/modal.h
A engines/saga2/module.mk
A engines/saga2/mono.cpp
A engines/saga2/mono.h
A engines/saga2/motion.cpp
A engines/saga2/motion.h
A engines/saga2/mouseimg.cpp
A engines/saga2/mouseimg.h
A engines/saga2/music.h
A engines/saga2/nice_err.cpp
A engines/saga2/nice_err.h
A engines/saga2/noise.cpp
A engines/saga2/objects.cpp
A engines/saga2/objects.h
A engines/saga2/objproto.cpp
A engines/saga2/objproto.h
A engines/saga2/oncall.h
A engines/saga2/osexcept.cpp
A engines/saga2/osexcept.h
A engines/saga2/palette.h
A engines/saga2/panel.cpp
A engines/saga2/panel.h
A engines/saga2/path.cpp
A engines/saga2/patrol.cpp
A engines/saga2/patrol.h
A engines/saga2/pclass.r
A engines/saga2/player.cpp
A engines/saga2/player.h
A engines/saga2/playmode.cpp
A engines/saga2/pool.cpp
A engines/saga2/pool.h
A engines/saga2/priqueue.h
A engines/saga2/program.h
A engines/saga2/property.cpp
A engines/saga2/property.h
A engines/saga2/pt2angle.cpp
A engines/saga2/queues.h
A engines/saga2/rect.cpp
A engines/saga2/rect.h
A engines/saga2/rmem.cpp
A engines/saga2/rmem.h
A engines/saga2/rmembase.h
A engines/saga2/rmemfta.h
A engines/saga2/rserver.cpp
A engines/saga2/saga2.cpp
A engines/saga2/saga2.h
A engines/saga2/sagafunc.cpp
A engines/saga2/savefile.cpp
A engines/saga2/savefile.h
A engines/saga2/script.h
A engines/saga2/sensor.cpp
A engines/saga2/sensor.h
A engines/saga2/setup.h
A engines/saga2/speech.cpp
A engines/saga2/speech.h
A engines/saga2/spelcast.cpp
A engines/saga2/speldata.cpp
A engines/saga2/speldefs.h
A engines/saga2/speldraw.cpp
A engines/saga2/spellbuk.h
A engines/saga2/spellini.cpp
A engines/saga2/spellio.cpp
A engines/saga2/spellio.h
A engines/saga2/spellloc.cpp
A engines/saga2/spells.h
A engines/saga2/spellsiz.cpp
A engines/saga2/spellspr.cpp
A engines/saga2/spellsta.cpp
A engines/saga2/spelshow.h
A engines/saga2/spelvals.h
A engines/saga2/sprite.cpp
A engines/saga2/sprite.h
A engines/saga2/std.h
A engines/saga2/stimtype.h
A engines/saga2/tagnoise.h
A engines/saga2/target.cpp
A engines/saga2/target.h
A engines/saga2/task.cpp
A engines/saga2/task.h
A engines/saga2/tcoords.h
A engines/saga2/terrain.cpp
A engines/saga2/terrain.h
A engines/saga2/testmap.h
A engines/saga2/tile.cpp
A engines/saga2/tile.h
A engines/saga2/tileline.cpp
A engines/saga2/tileline.h
A engines/saga2/tileload.cpp
A engines/saga2/tileload.h
A engines/saga2/tilemode.cpp
A engines/saga2/tilemode.h
A engines/saga2/tilevect.h
A engines/saga2/timer.cpp
A engines/saga2/timers.cpp
A engines/saga2/timers.h
A engines/saga2/tower.cpp
A engines/saga2/tower.h
A engines/saga2/towerfta.cpp
A engines/saga2/towerfta.h
A engines/saga2/towerwin.h
A engines/saga2/transit.cpp
A engines/saga2/transit.h
A engines/saga2/tromode.cpp
A engines/saga2/tromode.h
A engines/saga2/uidialog.cpp
A engines/saga2/uidialog.h
A engines/saga2/uimetrcs.h
A engines/saga2/uitext.h
A engines/saga2/vbacksav.cpp
A engines/saga2/vbacksav.h
A engines/saga2/vdraw.h
A engines/saga2/verify.cpp
A engines/saga2/version.h
A engines/saga2/video.cpp
A engines/saga2/video.h
A engines/saga2/videobox.cpp
A engines/saga2/videobox.h
A engines/saga2/videomem.cpp
A engines/saga2/videomem.h
A engines/saga2/videos.h
A engines/saga2/vidhook.cpp
A engines/saga2/vidsmk.cpp
A engines/saga2/vpage.h
A engines/saga2/vpal.cpp
A engines/saga2/vpal.h
A engines/saga2/vwdraw.cpp
A engines/saga2/vwpage.cpp
A engines/saga2/vwpage.h
A engines/saga2/weapons.cpp
A engines/saga2/weapons.h
A engines/saga2/winini.cpp
A engines/saga2/winini.h
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
new file mode 100644
index 0000000000..1915ac18ec
--- /dev/null
+++ b/engines/saga2/actor.cpp
@@ -0,0 +1,3568 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Based on the original sources
+ * Faery Tale II -- The Halls of the Dead
+ * (c) 1993-1996 The Wyrmkeep Entertainment Co.
+ */
+
+#include "saga2/std.h"
+#include "saga2/rmemfta.h"
+#include "saga2/dispnode.h"
+#include "saga2/tile.h"
+#include "saga2/motion.h"
+#include "saga2/grabinfo.h"
+#include "saga2/task.h"
+#include "saga2/actor.h"
+#include "saga2/player.h"
+#include "saga2/assign.h"
+#include "saga2/setup.h"
+#include "saga2/stimtype.h"
+#include "saga2/band.h"
+#include "saga2/sensor.h"
+#include "saga2/tromode.h"
+#include "saga2/messager.h"
+#include "saga2/weapons.h"
+#include "saga2/localize.h"
+
+
+// Include files needed for SAGA script dispatch
+#include "saga2/script.h"
+#include "saga2/methods.r" // generated by SAGA
+
+namespace Saga2 {
+
+/* ===================================================================== *
+ Constants
+ * ===================================================================== */
+
+// this is currently set to an arbitrary value for testing purposes.
+const uint16 defaultReach = 24;
+
+const uint32 actorListID = RES_ID('A', 'C', 'T', 'O');
+
+/* ===================================================================== *
+ Externals
+ * ===================================================================== */
+
+extern uint8 identityColors[256];
+
+extern hResContext *listRes; // object list resource handle
+
+extern ProtoObj *objectProtos;
+extern ActorProto *actorProtos;
+
+extern Actor *actorList;
+extern int16 actorCount;
+
+extern int32 actorListSize;
+
+extern int16 actorLimboCount;
+
+extern PlayerActor playerList[]; // Master list of all PlayerActors
+
+bool unstickObject(GameObject *obj);
+
+extern ObjectSoundFXs *objectSoundFXTable; // the global object sound effects table
+
+#if DEBUG
+extern bool massAndBulkCount;
+#endif
+
+/* ===================================================================== *
+ Globals -- might as well stick it here as anywhere.
+ * ===================================================================== */
+
+int16 factionTable[ maxFactions ][ factionNumColumns ];
+
+// Indicates wether actor states should be paused
+bool actorStatesPaused;
+
+// Indicates wether player actors should have combat behavior
+bool combatBehaviorEnabled;
+
+/* ===================================================================== *
+ ActorProto member functions
+ * ===================================================================== */
+
+//-----------------------------------------------------------------------
+// Return a bit mask indicating the properties of this object type
+
+uint16 ActorProto::containmentSet(void) {
+ // All actors may also be weapons (indicating natural attacks)
+ return ProtoObj::containmentSet() | isWeapon;
+}
+
+//-----------------------------------------------------------------------
+// Determine if the specified object can be contained by this object
+
+bool ActorProto::canContain(ObjectID dObj, ObjectID item) {
+ assert(isActor(dObj));
+ assert(isObject(item) || isActor(item));
+
+ GameObject *itemPtr = GameObject::objectAddress(item);
+
+ // Actors can contain any object, except worlds and other actors
+ return isObject(item)
+ && ((itemPtr->containmentSet() & ProtoObj::isIntangible) == 0
+ || itemPtr->possessor() == dObj);
+}
+
+//-----------------------------------------------------------------------
+// Determine if the specified object can be contained by this object at
+// the specified slot
+
+bool ActorProto::canContainAt(
+ ObjectID dObj,
+ ObjectID item,
+ const TilePoint &) {
+ assert(isActor(dObj));
+ assert(isObject(item) || isActor(item));
+
+ GameObject *itemPtr = GameObject::objectAddress(item);
+
+ // Actors can contain any object, except worlds and other actors
+ // REM: must add test to determine if specified slot is valid.
+ return isObject(item)
+ && ((itemPtr->containmentSet() & ProtoObj::isIntangible) == 0
+ || itemPtr->possessor() == dObj);
+}
+
+weaponID ActorProto::getWeaponID(void) {
+ return weaponDamage;
+}
+
+//-----------------------------------------------------------------------
+// use this actor
+
+bool ActorProto::useAction(ObjectID dObj, ObjectID enactor) {
+ assert(isActor(dObj));
+
+ Actor *a = (Actor *)GameObject::objectAddress(dObj);
+
+ if (a->isDead())
+ return ((PhysicalContainerProto *)this)->PhysicalContainerProto::useAction(dObj, enactor);
+
+ return FALSE;
+}
+
+//-----------------------------------------------------------------------
+// Determine if this actor can be opened
+
+bool ActorProto::canOpen(ObjectID dObj, ObjectID) {
+ assert(isActor(dObj));
+
+ return ((Actor *)GameObject::objectAddress(dObj))->isDead();
+}
+
+//-----------------------------------------------------------------------
+// open this actor
+
+// Kludge!
+extern int16 openMindType;
+
+bool ActorProto::openAction(ObjectID dObj, ObjectID) {
+ assert(isActor(dObj));
+
+ ContainerNode *cn;
+
+ GameObject *dObjPtr = GameObject::objectAddress(dObj);
+
+ assert(!dObjPtr->isOpen() && !dObjPtr->isLocked());
+
+ cn = CreateContainerNode(dObj, FALSE, openMindType);
+ cn->markForShow(); // Deferred open
+ dObjPtr->objectFlags |= GameObject::objectOpen; // Set open bit;
+ return TRUE;
+}
+
+//-----------------------------------------------------------------------
+// close this actor
+
+bool ActorProto::closeAction(ObjectID dObj, ObjectID) {
+ assert(isActor(dObj));
+
+ GameObject *dObjPtr = GameObject::objectAddress(dObj);
+ ContainerNode *cn = globalContainerList.find(dObj, ContainerNode::deadType);
+
+ assert(dObjPtr->isOpen());
+ assert(cn);
+
+ // Delete the container (lazy delete)
+ cn->markForDelete();
+
+ // Clear open bit
+ dObjPtr->objectFlags &= ~GameObject::objectOpen;
+ return TRUE;
+}
+
+//-----------------------------------------------------------------------
+
+bool ActorProto::strikeAction(
+ ObjectID dObj,
+ ObjectID enactor,
+ ObjectID item) {
+ assert(isActor(dObj));
+ assert(isActor(enactor));
+ assert(isObject(item) || isActor(item));
+
+ Actor *a = (Actor *)GameObject::objectAddress(enactor);
+ ActorAttributes *effStats = a->getStats();
+ GameObject *itemPtr = GameObject::objectAddress(item);
+ ObjectSoundFXs *soundFXs;
+ Location al = Location(a->getLocation(), a->IDParent());
+
+ if (itemPtr->acceptStrike(enactor, dObj, effStats->getSkillLevel(skillIDBludgeon)))
+ return TRUE;
+
+ soundFXs = &objectSoundFXTable[ soundFXClass ];
+
+ makeCombatSound(soundFXs->soundFXMissed, al);
+ return FALSE;
+}
+
+bool ActorProto::damageAction(
+ ObjectID dObj,
+ ObjectID enactor,
+ ObjectID target) {
+ assert(isActor(dObj));
+ assert(isActor(enactor));
+ assert(isObject(target) || isActor(target));
+
+ Actor *a = (Actor *)GameObject::objectAddress(enactor);
+ ActorAttributes *effStats = a->getStats();
+ WeaponStuff *ws = &getWeapon(getWeaponID());
+ GameObject *targetPtr = GameObject::objectAddress(target);
+ uint8 damageSoundID;
+ Location al = Location(a->getLocation(), a->IDParent());
+
+ damageSoundID = targetPtr->proto()->getDamageSound(
+ objectSoundFXTable[ soundFXClass ]);
+
+
+ if (damageSoundID != 0)
+ makeCombatSound(damageSoundID, al);
+
+ ws->implement(
+ a,
+ GameObject::objectAddress(target),
+ GameObject::objectAddress(dObj),
+ effStats->getSkillLevel(skillIDBrawn));
+
+ return TRUE;
+}
+
+//-----------------------------------------------------------------------
+// Routine that is called when an object is dragged & dropped
+// onto an actor.
+
+bool ActorProto::acceptDropAction(
+ ObjectID dObj, // object dropped on
+ ObjectID enactor, // person doing dropping
+ ObjectID droppedID, // ID of dropped object
+ int count) {
+ assert(isActor(dObj));
+
+ Actor *a = (Actor *)GameObject::objectAddress(dObj);
+ GameObject *droppedObj = GameObject::objectAddress(droppedID);
+
+ if (a->isDead()) {
+ a->dropInventoryObject(droppedObj, count);
+ return TRUE;
+ }
+
+ Location newLoc;
+ uint16 dropType;
+ // For now, we'll just drop the object into the actor's
+ // inventory.
+ //
+ // REM: We might want to arrange the inventory item in a
+ // semi-sensible way, like putting the new item at the
+ // head of the list. (Do this by changing the newLoc coord
+ // fields...)
+ //
+ // REM: We might want to ask the object how it feels about
+ // being given to an actor...
+
+ // NOTE: Added check so that dropping an object on an actor who
+ // already has the object will do nothing.
+ if (droppedObj->IDParent() == dObj) return TRUE;
+
+ dropType = droppedObj->containmentSet();
+
+ scriptResult result;
+ scriptCallFrame scf;
+
+ scf.invokedObject = dObj;
+ scf.enactor = enactor;
+ scf.directObject = droppedID;
+ scf.indirectObject = dObj;
+
+ if (dropType & isIntangible) {
+ // Set up the arguments we want to pass to the script
+
+ scf.value = droppedObj->proto()->lockType
+ + senseIdeaGreeting;
+
+ // Invoke the script...
+
+ if (dropType & isConcept) {
+ result = runObjectMethod(dObj, Method_Actor_onTalkTo, scf);
+ } else if (dropType & isPsych) {
+ // What to do???
+ } else if (dropType & (isSpell | isSkill)) {
+ // What to do???
+ // Cast the spell on the actor?
+ }
+
+ /* isConcept = (1<< 9),
+ isPsych = (1<<10),
+ isSpell = (1<<11),
+ isSkill = (1<<12),
+ isEnchantment = (1<<13),
+ isTargetable = (1<<14), */
+
+// mouseInfo.setIntent( GrabInfo::WalkTo );
+ } else {
+ scf.value = count;
+
+ result = runObjectMethod(dObj, Method_Actor_onReceive, scf);
+
+ if (result == scriptResultFinished
+ && scf.returnVal != actionResultNotDone)
+ return scf.returnVal == actionResultSuccess;
+
+ // Place the object in the actor's inventory (if possible)
+ if (!a->placeObject(enactor, droppedID, TRUE, count))
+ a->dropInventoryObject(droppedObj, count);
+ }
+
+ return TRUE;
+}
+
+//-----------------------------------------------------------------------
+// Call the actor's "greet" script.
+
+bool ActorProto::greetActor(
+ ObjectID dObj, // object dropped on
+ ObjectID enactor) { // person doing dropping
+ assert(isActor(dObj));
+
+ scriptCallFrame scf;
+
+ scf.invokedObject = dObj;
+ scf.enactor = enactor;
+ scf.directObject = Nothing;
+ scf.indirectObject = Nothing;
+ scf.value = senseIdeaGreeting;
+
+ return runObjectMethod(dObj, Method_Actor_onTalkTo, scf);
+}
+
+//-----------------------------------------------------------------------
+// cause damage directly
+
+bool ActorProto::acceptDamageAction(
+ ObjectID dObj,
+ ObjectID enactor,
+ int8 absDamage,
+ effectDamageTypes dType,
+ int8 dice,
+ uint8 sides,
+ int8) {
+ assert(isActor(dObj));
+ assert(isObject(enactor) || isActor(enactor));
+
+ int8 pdm = 0; //=perDieMod+(resistant ? -2 : 0);
+ int16 damage = 0;
+ Actor *a = (Actor *)GameObject::objectAddress(dObj);
+ Actor *enactorPtr;
+ int16 &vitality = a->effectiveStats.vitality;
+ bool resistant = a->resists((effectResistTypes) dType);
+ PlayerActorID pID;
+
+
+ if (!a->isImmuneTo((effectImmuneTypes) dType)) {
+ damage = absDamage;
+
+ if (dice)
+ for (int d = 0; d < abs(dice); d++)
+ damage += ((rand() % sides) + pdm + 1) * (dice > 0 ? 1 : -1);
+ }
+
+ if (damage > 0 && resistant)
+ damage /= 2;
+
+ if (damage > 0 && isMagicDamage(dType) && makeSavingThrow())
+ damage /= 2;
+
+ if (damage < 0)
+ return acceptHealing(dObj, enactor, -damage);
+
+ // Apply applicable armor adjustments
+ if (dType == damageImpact
+ || dType == damageSlash
+ || dType == damageProjectile) {
+ ArmorAttributes armorAttribs;
+
+ a->totalArmorAttributes(armorAttribs);
+ damage /= armorAttribs.damageDivider;
+ damage = MAX(damage - armorAttribs.damageAbsorbtion, 0);
+ }
+
+ if (damage == 0) return FALSE;
+
+ if (isActor(enactor))
+ enactorPtr = (Actor *)GameObject::objectAddress(enactor);
+ else {
+ ObjectID possessorID;
+
+ possessorID = GameObject::objectAddress(enactor)->possessor();
+ enactorPtr = possessorID != Nothing
+ ? (Actor *)GameObject::objectAddress(possessorID)
+ : NULL;
+ }
+
+ if (vitality > 0) {
+ Location al = Location(a->getLocation(), a->IDParent());
+ if (gruntStyle > 0
+ && ((flags & ResourceObjectPrototype::objPropNoSurface)
+ || (damage > 2 && (rand() % vitality) < (damage * 2))))
+ makeGruntSound(gruntStyle, al);
+
+ if (enactorPtr != NULL) {
+ enactorPtr->handleSuccessfulStrike(
+ a,
+ damage < vitality ? damage : vitality);
+ }
+
+ // If we've just lost all vitality, we're dead, else make a
+ // morale check
+ if (damage >= vitality) {
+ MotionTask::die(*a);
+ AddFactionTally(a->faction, factionNumKills, 1);
+ if (enactorPtr != NULL)
+ enactorPtr->handleSuccessfulKill(a);
+ } else
+ a->handleDamageTaken(damage);
+
+ vitality -= damage;
+
+ if (actorToPlayerID(a, pID)) {
+ updateBrotherControls(pID);
+
+ if (vitality > 0) {
+ int16 baseVitality,
+ oldVitality;
+
+ baseVitality = a->getBaseStats()->vitality;
+ oldVitality = vitality + damage;
+
+ if (baseVitality >= vitality * 3
+ && baseVitality < oldVitality * 3) {
+ StatusMsg(WOUNDED_STATUS, a->objName());
+ } else if (baseVitality * 2 >= vitality * 3
+ && baseVitality * 2 < oldVitality * 3) {
+ StatusMsg(HURT_STATUS, a->objName());
+ }
+ }
+ }
+
+ WriteStatusF(5, "Damage: %d", damage);
+ }
+
+ return TRUE;
+}
+
+//-----------------------------------------------------------------------
+// cause healing directly
+
+bool ActorProto::acceptHealingAction(
+ ObjectID dObj,
+ ObjectID,
+ int8 healing) {
+ assert(isActor(dObj));
+
+ Actor *a = (Actor *)GameObject::objectAddress(dObj);
+ int16 &vitality = a->effectiveStats.vitality;
+ int16 maxVitality = (a->getBaseStats())->vitality;
+ PlayerActorID pID;
+
+ if (vitality > 0 && !a->hasEffect(actorDiseased)) {
+
+ // If we've just lost all vitality, we're dead, else make a
+ // morale check
+
+ vitality += healing;
+ vitality = clamp(0, vitality, maxVitality);
+
+ if (actorToPlayerID(a, pID))
+ updateBrotherControls(pID);
+
+ WriteStatusF(5, "Healing: %d", healing);
+ } else
+ return FALSE;
+
+ return TRUE;
+}
+
+//-----------------------------------------------------------------------
+// Accept strike from an object (allows this actor to cause damage to
+// the striking object).
+
+bool ActorProto::acceptStrikeAction(
+ ObjectID dObj,
+ ObjectID enactor,
+ ObjectID strikingObj,
+ uint8 skillIndex) {
+ assert(isActor(dObj));
+ assert(isActor(enactor));
+
+ const int toHitBase = 100;
+ const int avgHitChance = toHitBase / 2;
+ const int skillScalingFactor =
+ (avgHitChance
+ + ActorAttributes::skillLevels - 1)
+ / ActorAttributes::skillLevels;
+ const int dodgingBonus = 10;
+
+ Actor *a = (Actor *)GameObject::objectAddress(dObj);
+ ActorAttributes *effStats = a->getStats();
+ WeaponProto *weaponProto = (WeaponProto *)GameObject::protoAddress(strikingObj);
+ GameObject *weapon = GameObject::objectAddress(strikingObj);
+
+ assert(weapon->proto()->containmentSet() & ProtoObj::isWeapon);
+
+ WeaponStuff &ws = getWeapon(weaponProto->getWeaponID());
+ Actor *enactorPtr = (Actor *)GameObject::objectAddress(enactor);
+ ArmorAttributes armorAttribs;
+
+ uint8 hitChance;
+
+ if (a->isDead())
+ return weapon->damage(enactor, dObj);
+
+ a->handleOffensiveAct((Actor *)GameObject::objectAddress(enactor));
+
+ // Sum up the armor attributes
+ a->totalArmorAttributes(armorAttribs);
+
+ // Determine "to hit" percentage
+ hitChance = avgHitChance
+ + ((int)skillIndex
+ - (int)effStats->getSkillLevel(skillIDAgility))
+ * skillScalingFactor;
+
+ // Factor in armor bonus
+ hitChance -= armorAttribs.defenseBonus;
+
+ // Factor in dodging bonus if any
+ if (a->moveTask != NULL && a->moveTask->isDodging(enactorPtr))
+ hitChance -= dodgingBonus;
+
+ hitChance = MAX<uint8>(hitChance, 5);
+
+ // Randomly determine hit success
+ if (rand() % toHitBase < hitChance) {
+ // Hit has succeeded
+
+ GameObject *blockingObj = a->blockingObject(enactorPtr);
+ bool blocked = FALSE;
+
+ // Test for block success
+ if (blockingObj != NULL) {
+ hitChance = avgHitChance
+ + ((int)skillIndex
+ - (int)blockingObj->proto()->getSkillValue(dObj))
+ * skillScalingFactor;
+
+ if (rand() % toHitBase >= hitChance) {
+ // The shield was hit
+ blockingObj->acceptStrike(
+ enactor,
+ strikingObj,
+ skillIndex);
+ blocked = TRUE;
+
+ // Cause skill growth
+ blockingObj->proto()->applySkillGrowth(dObj, 5);
+ }
+ }
+
+ if (!blocked) {
+ // The strike got through
+ weapon->damage(enactor, dObj);
+
+ // Notify the attacker of a successful strike
+ enactorPtr->handleSuccessfulStrike(weapon);
+
+ if (!a->isDead()) {
+ int16 mass = a->proto()->mass;
+
+ if (mass <= 100
+ || (rand() % 156) >= mass - 100) {
+ if ((rand() & 0x7) == 0)
+ MotionTask::fallDown(*a, *enactorPtr);
+ else
+ MotionTask::acceptHit(*a, *enactorPtr);
+ }
+ }
+ }
+
+ return TRUE;
+ } else {
+ // This actor has dodged the blow, apply agility growth
+
+ PlayerActorID playerID;
+
+ if (actorIDToPlayerID(dObj, playerID)) {
+ PlayerActor *player = getPlayerActorAddress(playerID);
+
+ player->skillAdvance(skillIDAgility, 1);
+ }
+ }
+
+ return FALSE;
+}
+
+//-----------------------------------------------------------------------
+// Insert another object into this object at the specified slot
+
+bool ActorProto::acceptInsertionAtAction(
+ ObjectID dObj,
+ ObjectID,
+ ObjectID item,
+ const TilePoint &where,
+ int16 num) {
+ enum {
+ notInUse,
+ heldInLeftHand,
+ heldInRightHand,
+ worn,
+ } inUseType;
+ int wornWhere;
+
+ assert(isActor(dObj));
+ assert(isObject(item));
+
+ GameObject *dObjPtr = GameObject::objectAddress(dObj);
+ Actor *a = (Actor *)dObjPtr;
+ GameObject *itemPtr = GameObject::objectAddress(item);
+ GameObject *extractedObj = NULL;
+ Location oldLoc(itemPtr->getLocation(), itemPtr->IDParent());
+
+ bool result;
+
+ // Split the merged object if needed.
+ if (itemPtr->isMergeable() // If mergeable
+ && num < itemPtr->getExtra()) { // And not dropping whole pile
+ if (num == 0) return FALSE; // If mergeing zero, then do nothing
+
+ extractedObj = itemPtr->extractMerged(itemPtr->getExtra() - num);
+ if (extractedObj == NULL)
+ return FALSE;
+
+ extractedObj->move(oldLoc);
+ }
+
+ // Determine if this object is simply being moved within this actor
+ if (oldLoc.context == dObj) {
+ // Determine if and where the object is in use by this actor
+ if (a->leftHandObject == item)
+ inUseType = heldInLeftHand;
+ else if (a->rightHandObject == item)
+ inUseType = heldInRightHand;
+ else {
+ int i;
+
+ inUseType = notInUse;
+
+ for (i = 0; i < ARMOR_COUNT; i++) {
+ if (a->armorObjects[ i ] == item) {
+ inUseType = worn;
+ wornWhere = i;
+ break;
+ }
+ }
+ }
+ } else
+ inUseType = notInUse;
+
+ // Do the deed
+ itemPtr->move(Location(0, 0, 0, ImportantLimbo));
+ if (dObjPtr->canFitBulkwise(itemPtr)
+ && dObjPtr->canFitMasswise(itemPtr)) {
+ itemPtr->move(Location(where, dObj));
+ result = TRUE;
+ } else {
+ itemPtr->move(oldLoc);
+ if (extractedObj != NULL)
+ GameObject::mergeWith(extractedObj, itemPtr, extractedObj->getExtra());
+ result = FALSE;
+ }
+
+ // Re-equip the item if necessary
+ if (inUseType != notInUse) {
+ switch (inUseType) {
+ case heldInLeftHand:
+ a->holdInLeftHand(item);
+ break;
+
+ case heldInRightHand:
+ a->holdInRightHand(item);
+ break;
+
+ case worn:
+ a->wear(item, wornWhere);
+ break;
+ }
+ }
+
+ return result;
+}
+
+//-----------------------------------------------------------------------
+// Initiate a natural attack motion
+
+void ActorProto::initiateAttack(ObjectID attacker, ObjectID target) {
+ assert(isActor(attacker));
+ assert(isObject(target) || isActor(target));
+
+ Actor *attackerPtr = (Actor *)GameObject::objectAddress(attacker);
+ GameObject *targetPtr = GameObject::objectAddress(target);
+
+ // Start the attack motion
+ if (attackerPtr->appearance != NULL) {
+ if (attackerPtr->isActionAvailable(actionSwingHigh))
+ MotionTask::oneHandedSwing(*attackerPtr, *targetPtr);
+ else if (attackerPtr->isActionAvailable(actionTwoHandSwingHigh))
+ MotionTask::twoHandedSwing(*attackerPtr, *targetPtr);
+ } else
+ MotionTask::oneHandedSwing(*attackerPtr, *targetPtr);
+}
+
+//-----------------------------------------------------------------------
+// Given an object sound effect record, which sound should be made
+// when this object is damaged
+
+uint8 ActorProto::getDamageSound(const ObjectSoundFXs &soundFXs) {
+ return !(flags & ResourceObjectPrototype::objPropNoSurface)
+ ? !(flags & ResourceObjectPrototype::objPropHardSurface)
+ ? soundFXs.soundFXHitFlesh
+ : soundFXs.soundFXHitHard
+ : 0;
+}
+
+//-----------------------------------------------------------------------
+// Do the background processing, if needed, for this object.
+
+void ActorProto::doBackgroundUpdate(GameObject *obj) {
+ // get the ID for this object
+ ObjectID actorID = obj->thisID();
+
+ // find out if this object is an actor
+ if (isActor(actorID)) {
+ // get a pointer to that actor
+ GameObject *actorObj = GameObject::objectAddress(actorID);
+ Actor *a = (Actor *)actorObj;
+
+ if (!a->isActivated()) {
+ // If this is a temporary actor waiting for expiration,
+ // then decrement the expiration counter and possibly
+ // delete the actor
+ if ((a->flags & Actor::temporary) || a->isDead()) {
+ if (a->deactivationCounter <= 0) {
+ a->deleteObjectRecursive();
+ return;
+ } else a->deactivationCounter--;
+ } else {
+ // If the actor has failed morale there is a random
+ // chance of him regaining his courage
+ if ((a->flags & Actor::afraid) && rand() % 128 == 0)
+ a->flags &= ~Actor::afraid;
+ }
+ }
+
+
+ // execute that actor's vitality update function
+ ((Actor *)actorObj)->vitalityUpdate();
+
+
+ // do any updates directly related only to the brothers
+ if (isPlayerActor(actorID)) {
+
+ switch (actorID) {
+ case ActorBaseID + FTA_JULIAN:
+ playerList[ FTA_JULIAN ].recoveryUpdate();
+ break;
+
+ case ActorBaseID + FTA_PHILIP:
+ playerList[ FTA_PHILIP ].recoveryUpdate();
+ break;
+
+ case ActorBaseID + FTA_KEVIN:
+ playerList[ FTA_KEVIN ].recoveryUpdate();
+ break;
+
+ default:
+ // no action
+ break;
+ }
+ }
+ }
+
+
+ // check for other updates
+ ProtoObj::doBackgroundUpdate(obj);
+
+}
+
+// ------------------------------------------------------------------------
+// Cause the user's associated skill to grow
+
+void ActorProto::applySkillGrowth(ObjectID enactor, uint8 points) {
+ assert(isActor(enactor));
+
+ PlayerActorID playerID;
+
+ if (actorIDToPlayerID(enactor, playerID)) {
+ PlayerActor *player = getPlayerActorAddress(playerID);
+
+ player->skillAdvance(skillIDBludgeon, points);
+
+ if (rand() & 1)
+ player->skillAdvance(skillIDBrawn, points);
+ }
+}
+
+// ------------------------------------------------------------------------
+
+bool ActorProto::canFitBulkwise(GameObject *container, GameObject *obj) {
+#if DEBUG
+ if (massAndBulkCount)
+#endif
+ {
+ uint16 maxBulk = container->bulkCapacity();
+ uint16 totalBulk = container->totalContainedBulk();
+
+ return totalBulk + obj->totalBulk() <= maxBulk;
+ }
+
+#if DEBUG
+ return TRUE;
+#endif
+}
+
+// ------------------------------------------------------------------------
+
+bool ActorProto::canFitMasswise(GameObject *container, GameObject *obj) {
+ assert(isActor(container));
+
+#if DEBUG
+ if (massAndBulkCount)
+#endif
+ {
+ Actor *a = (Actor *)container;
+ uint16 maxCapacity,
+ totalMass;
+
+ // get the maxium amount of weight this character should be able to carry
+ maxCapacity = container->massCapacity();
+
+ totalMass = a->totalContainedMass();
+
+ return totalMass + obj->totalMass() <= maxCapacity;
+ }
+
+#if DEBUG
+ return TRUE;
+#endif
+}
+
+// ------------------------------------------------------------------------
+// Return the maximum mass capacity for the specified container
+
+uint16 ActorProto::massCapacity(GameObject *container) {
+ assert(isActor(container));
+ Actor *a = (Actor *)container;
+ ActorAttributes *effStats = a->getStats();
+
+ return baseCarryingCapacity
+ + effStats->getSkillLevel(skillIDBrawn)
+ * carryingCapacityBonusPerBrawn;
+}
+
+// ------------------------------------------------------------------------
+// Return the maximum bulk capacity for the specified container
+
+uint16 ActorProto::bulkCapacity(GameObject *) {
+ return bulk * 4;
+}
+
+/* ===================================================================== *
+ ActorArchive struct
+ * ===================================================================== */
+
+// This data structure is used in the creation of an actor archive. It
+// includes all of the fixed size data fields which must be preserved in
+// a save file without any of the overhead such as a base class or virtual
+// member functions. Some of the Actor data members, such as moveTask
+// currentTask and currentTransaction, are omitted because the links
+// to these other objects will archived with their respective 'Task' object.
+// Also, the assignment member was not included because it is a complex
+// variable sized data structure which will be asked to archive itself.
+
+struct ActorArchive {
+ uint8 faction;
+ uint8 colorScheme;
+ int32 appearanceID;
+ int8 attitude,
+ mood;
+ uint8 disposition;
+ Direction currentFacing;
+ int16 tetherLocU;
+ int16 tetherLocV;
+ int16 tetherDist;
+ ObjectID leftHandObject,
+ rightHandObject;
+ uint16 knowledge[ 16 ];
+ uint16 schedule;
+ uint8 conversationMemory[ 4 ];
+ uint8 currentAnimation,
+ currentPose,
+ animationFlags;
+ uint8 flags;
+ ActorPose poseInfo;
+ int16 cycleCount;
+ int16 kludgeCount;
+ uint32 enchantmentFlags;
+ uint8 currentGoal,
+ deactivationCounter;
+ ActorAttributes effectiveStats;
+ uint8 actionCounter;
+ uint16 effectiveResistance;
+ uint16 effectiveImmunity;
+ int16 recPointsPerUpdate; // fractional vitality recovery
+ int16 currentRecoveryPoints;
+ ObjectID leaderID;
+ BandID followersID;
+ ObjectID armorObjects[ ARMOR_COUNT ];
+ ObjectID currentTargetID;
+ int16 scriptVar[ actorScriptVars ];
+};
+
+/* ===================================================================== *
+ Actor member functions
+ * ===================================================================== */
+
+//-----------------------------------------------------------------------
+// Initialize all fields in the actor structure to neutral values.
+
+void Actor::init(
+ int16 protoIndex,
+ uint16 nameIndex,
+ uint16 scriptIndex,
+ int32 appearanceNum,
+ uint8 colorSchemeIndex,
+ uint8 factionNum,
+ uint8 initFlags) {
+ int i;
+
+ // Fixup the prototype pointer to point to an actor prototype
+ prototype = (ProtoObj *)&actorProtos[ protoIndex ];
+
+ // Initialize object fields
+// nameIndex = 0;
+ setNameIndex(nameIndex);
+ setScript(scriptIndex);
+ parentID = siblingID = childID = Nothing;
+ objectFlags = 0;
+ massCount = 0;
+ currentTAG = NoActiveItem;
+ hitPoints = 0;
+
+ // Initialize actor field
+ faction = factionNum;
+ colorScheme = colorSchemeIndex;
+ appearanceID = appearanceNum;
+ attitude = 0;
+ mood = 0;
+ disposition = 0;
+ currentFacing = dirDown;
+ tetherLocU = 0;
+ tetherLocV = 0;
+ tetherDist = 0;
+ leftHandObject = Nothing;
+ rightHandObject = Nothing;
+ schedule = 0;
+ memset(&knowledge, 0, sizeof(knowledge));
+
+ // Initialize the rest of the data members
+ *((uint32 *)conversationMemory) = 0L;
+ currentAnimation = actionStand;
+ currentPose = 0;
+ animationFlags = 0;
+ flags = 0;
+ if (!(initFlags & actorPermanent))
+ flags |= temporary;
+ memset(&poseInfo, 0, sizeof(poseInfo));
+ appearance = NULL;
+ cycleCount = 0;
+ kludgeCount = 0;
+ moveTask = NULL;
+ enchantmentFlags = 0L;
+ curTask = NULL;
+ currentGoal = actorGoalFollowAssignment;
+ deactivationCounter = 0;
+ memset(assignmentBuf, 0, sizeof(assignmentBuf));
+
+ memcpy(
+ &effectiveStats,
+ &((ActorProto *)prototype)->baseStats,
+ sizeof(effectiveStats));
+ effectiveStats.vitality = MAX<int16>(effectiveStats.vitality, 1);
+
+ actionCounter = 0;
+ effectiveResistance = 0;
+ effectiveImmunity = 0;
+ recPointsPerUpdate = BASE_REC_RATE;
+ currentRecoveryPoints = 0;
+ leader = NULL;
+ followers = NULL;
+ for (i = 0; i < ARMOR_COUNT; i++)
+ armorObjects[ i ] = Nothing;
+ currentTarget = NULL;
+ for (i = 0; i < actorScriptVars; i++)
+ scriptVar[ i ] = 0;
+
+ evalActorEnchantments(this);
+}
+
+//-----------------------------------------------------------------------
+// Actor constructor -- copies the resource fields and simply NULL's most
+// of the rest of the data members
+
+Actor::Actor(const ResourceActor &res) : GameObject(res) {
+ int i;
+
+ // Fixup the prototype pointer to point to an actor prototype
+ prototype = prototype != NULL
+ ? (ProtoObj *)&actorProtos[ prototype - objectProtos ]
+ : NULL;
+
+ // Copy the resource fields
+ faction = res.faction;
+ colorScheme = res.colorScheme;
+ appearanceID = res.appearanceID;
+ attitude = res.attitude;
+ mood = res.mood;
+ disposition = res.disposition;
+ currentFacing = res.currentFacing;
+ tetherLocU = res.tetherLocU;
+ tetherLocV = res.tetherLocV;
+ tetherDist = res.tetherDist;
+ leftHandObject = res.leftHandObject;
+ rightHandObject = res.rightHandObject;
+ schedule = res.schedule;
+ memcpy(&knowledge, &res.knowledge, sizeof(knowledge));
+
+ // Initialize the rest of the data members
+ *((uint32 *)conversationMemory) = 0L;
+ currentAnimation = actionStand;
+ currentPose = 0;
+ animationFlags = 0;
+ flags = 0;
+ memset(&poseInfo, 0, sizeof(poseInfo));
+ appearance = NULL;
+ cycleCount = 0;
+ kludgeCount = 0;
+ moveTask = NULL;
+ enchantmentFlags = 0L;
+ curTask = NULL;
+ currentGoal = actorGoalFollowAssignment;
+ deactivationCounter = 0;
+ memset(assignmentBuf, 0, sizeof(assignmentBuf));
+
+ memcpy(
+ &effectiveStats,
+ &((ActorProto *)prototype)->baseStats,
+ sizeof(effectiveStats));
+ effectiveStats.vitality = MAX<uint16>(effectiveStats.vitality, 1);
+
+ actionCounter = 0;
+ effectiveResistance = 0;
+ effectiveImmunity = 0;
+ recPointsPerUpdate = BASE_REC_RATE;
+ currentRecoveryPoints = 0;
+ leader = NULL;
+ followers = NULL;
+ for (i = 0; i < ARMOR_COUNT; i++)
+ armorObjects[ i ] = Nothing;
+ currentTarget = NULL;
+ for (i = 0; i < actorScriptVars; i++)
+ scriptVar[ i ] = 0;
+
+ evalActorEnchantments(this);
+}
+
+//-----------------------------------------------------------------------
+// Reconstruct from archive buffer
+
+Actor::Actor(void **buf) : GameObject(buf) {
+ void *bufferPtr = *buf;
+ int i;
+
+ // Fixup the prototype pointer to point to an actor prototype
+ prototype = prototype != NULL
+ ? (ProtoObj *)&actorProtos[ prototype - objectProtos ]
+ : NULL;
+
+ ActorArchive *a = (ActorArchive *)bufferPtr;
+
+ // Read individual fields from buffer
+ faction = a->faction;
+ colorScheme = a->colorScheme;
+ appearanceID = a->appearanceID;
+ attitude = a->attitude;
+ mood = a->mood;
+ disposition = a->disposition;
+ currentFacing = a->currentFacing;
+ tetherLocU = a->tetherLocU;
+ tetherLocV = a->tetherLocV;
+ tetherDist = a->tetherDist;
+ leftHandObject = a->leftHandObject;
+ rightHandObject = a->rightHandObject;
+ memcpy(&knowledge, &a->knowledge, sizeof(knowledge));
+ schedule = a->schedule;
+ *((uint32 *)conversationMemory) = *((uint32 *)a->conversationMemory);
+ currentAnimation = a->currentAnimation;
+ currentPose = a->currentPose;
+ animationFlags = a->animationFlags;
+ flags = a->flags;
+ memcpy(&poseInfo, &a->poseInfo, sizeof(poseInfo));
+ cycleCount = a->cycleCount;
+ kludgeCount = a->kludgeCount;
+ enchantmentFlags = a->enchantmentFlags;
+ currentGoal = a->currentGoal;
+ deactivationCounter = a->deactivationCounter;
+ memcpy(&effectiveStats, &a->effectiveStats, sizeof(effectiveStats));
+ actionCounter = a->actionCounter;
+ effectiveResistance = a->effectiveResistance;
+ effectiveImmunity = a->effectiveImmunity;
+ recPointsPerUpdate = a->recPointsPerUpdate;
+ currentRecoveryPoints = a->currentRecoveryPoints;
+ leader = a->leaderID != Nothing
+ ? (Actor *)GameObject::objectAddress(a->leaderID)
+ : NULL;
+ followers = a->followersID != NoBand
+ ? getBandAddress(a->followersID)
+ : NULL;
+ for (i = 0; i < ARMOR_COUNT; i++)
+ armorObjects[ i ] = a->armorObjects[ i ];
+ currentTarget = a->currentTargetID != Nothing
+ ? GameObject::objectAddress(a->currentTargetID)
+ : NULL;
+ for (i = 0; i < actorScriptVars; i++)
+ scriptVar[ i ] = a->scriptVar[ i ];
+
+ bufferPtr = &a[ 1 ];
+
+ if (flags & hasAssignment) {
+ freeAssignment();
+ bufferPtr = constructAssignment(this, bufferPtr);
+ }
+
+ appearance = NULL;
+ moveTask = NULL;
+ curTask = NULL;
+
+ // Return address of memory after actor archive
+ *buf = bufferPtr;
+}
+
+//-----------------------------------------------------------------------
+// Destructor
+
+Actor::~Actor(void) {
+ if (appearance != NULL) ReleaseActorAppearance(appearance);
+
+ ActorAssignment *assign = getAssignment();
+ // I don't know why I have to specify the ActorAssignment delete
+ // operator, but "delete assign" will crash the program
+ if (assign != NULL) ActorAssignment::operator delete (assign);
+
+}
+
+//-----------------------------------------------------------------------
+// Return the number of bytes needed to archive this actor
+
+int32 Actor::archiveSize(void) {
+ int32 size = GameObject::archiveSize();
+
+ size += sizeof(ActorArchive);
+ if (flags & hasAssignment)
+ size += assignmentArchiveSize(this);
+
+ return size;
+}
+
+//-----------------------------------------------------------------------
+// Archive this actor in a buffer
+
+void *Actor::archive(void *buf) {
+ int i;
+ ProtoObj *holdProto = prototype;
+
+ // Modify the protoype temporarily so the GameObject::archive()
+ // will store the index correctly
+ if (prototype != NULL)
+ prototype = &objectProtos[(ActorProto *)prototype - actorProtos ];
+
+ // Let the base class archive its data
+ buf = GameObject::archive(buf);
+
+ // Restore the prototype pointer
+ prototype = holdProto;
+
+ ActorArchive *a = (ActorArchive *)buf;
+
+ // Store individual fields in buffer
+ a->faction = faction;
+ a->colorScheme = colorScheme;
+ a->appearanceID = appearanceID;
+ a->attitude = attitude;
+ a->mood = mood;
+ a->disposition = disposition;
+ a->currentFacing = currentFacing;
+ a->tetherLocU = tetherLocU;
+ a->tetherLocV = tetherLocV;
+ a->tetherDist = tetherDist;
+ a->leftHandObject = leftHandObject;
+ a->rightHandObject = rightHandObject;
+ memcpy(&a->knowledge, &knowledge, sizeof(a->knowledge));
+ a->schedule = schedule;
+ *((uint32 *)a->conversationMemory) = *((uint32 *)conversationMemory);
+ a->currentAnimation = currentAnimation;
+ a->currentPose = currentPose;
+ a->animationFlags = animationFlags;
+ a->flags = flags;
+ memcpy(&a->poseInfo, &poseInfo, sizeof(a->poseInfo));
+ a->cycleCount = cycleCount;
+ a->kludgeCount = kludgeCount;
+ a->enchantmentFlags = enchantmentFlags;
+ a->currentGoal = currentGoal;
+ a->deactivationCounter = deactivationCounter;
+ memcpy(&a->effectiveStats, &effectiveStats, sizeof(a->effectiveStats));
+ a->actionCounter = actionCounter;
+ a->effectiveResistance = effectiveResistance;
+ a->effectiveImmunity = effectiveImmunity;
+ a->recPointsPerUpdate = recPointsPerUpdate;
+ a->currentRecoveryPoints = currentRecoveryPoints;
+ a->leaderID = leader != NULL ? leader->thisID() : Nothing;
+ a->followersID = followers != NULL ? getBandID(followers) : NoBand;
+ for (i = 0; i < elementsof(a->armorObjects); i++)
+ a->armorObjects[ i ] = armorObjects[ i ];
+ a->currentTargetID = currentTarget != NULL ? currentTarget->thisID() : Nothing;
+ for (i = 0; i < actorScriptVars; i++)
+ a->scriptVar[ i ] = scriptVar[ i ];
+
+ buf = &a[ 1 ];
+
+ if (flags & hasAssignment)
+ buf = archiveAssignment(this, buf);
+
+ return buf;
+}
+
+#if 0
+MonoMessager amm;
+#endif
+//-----------------------------------------------------------------------
+// Return a newly created actor
+
+Actor *Actor::newActor(
+ int16 protoNum,
+ uint16 nameIndex,
+ uint16 scriptIndex,
+ int32 appearanceNum,
+ uint8 colorSchemeIndex,
+ uint8 factionNum,
+ uint8 initFlags) {
+ GameObject *limbo = objectAddress(ActorLimbo);
+ Actor *a;
+
+ if (limbo->IDChild() == Nothing) {
+ int16 i;
+
+ // Search actor list for first scavangable actor
+ for (i = playerActors; i < actorCount; i++) {
+ a = &actorList[ i ];
+
+ if ((a->flags & temporary)
+ && !a->isActivated()
+ && isWorld(a->IDParent()))
+ break;
+ }
+
+ // REM: If things start getting really tight, we can
+ // start recycling common objects...
+
+ if (i >= actorCount) return NULL;
+ } else {
+ actorLimboCount--;
+ a = (Actor *)limbo->child();
+ }
+
+ a->setLocation(Location(0, 0, 0, Nothing));
+ a->init(
+ protoNum,
+ nameIndex,
+ scriptIndex,
+ appearanceNum,
+ colorSchemeIndex,
+ factionNum,
+ initFlags);
+
+ if (a->flags & temporary) {
+ incTempActorCount(protoNum);
+#if 0
+ amm("Created temp actor %d new count:%d", a->thisID() - 32768, getTempActorCount(protoNum));
+#endif
+ }
+
+ return a;
+}
+
+//-----------------------------------------------------------------------
+// Delete this actor
+
+void Actor::deleteActor(void) {
+ if (flags & temporary) {
+ uint16 protoNum = (ActorProto *)prototype - actorProtos;
+
+ decTempActorCount(protoNum);
+#if 0
+ amm("Deleting temp actor %d new count:%d", thisID() - 32768, getTempActorCount(protoNum));
+#endif
+ }
+
+ // Kill task
+ if (curTask != NULL) {
+ curTask->abort();
+ delete curTask;
+ curTask = NULL;
+ }
+
+ // Kill motion task
+ if (moveTask != NULL) moveTask->remove();
+
+ // If banded, remove from band
+ if (leader != NULL) {
+ assert(isActor(leader));
+
+ leader->removeFollower(this);
+ leader = NULL;
+ } else if (followers != NULL) {
+ int16 i;
+
+ for (i = 0; i < followers->size(); i++) {
+ Actor *follower = (*followers)[ i ];
+
+ follower->leader = NULL;
+ follower->evaluateNeeds();
+ }
+
+ delete followers;
+ followers = NULL;
+ }
+
+ // Place in limbo
+ if (!(objectFlags & objectNoRecycle)) {
+ append(ActorLimbo);
+ actorLimboCount++;
+ }
+}
+
+
+//-----------------------------------------------------------------------
+// Cause the actor to stop his current motion task is he is interruptable
+
+void Actor::stopMoving(void) {
+ if (moveTask != NULL && isInterruptable())
+ moveTask->remove();
+}
+
+//-----------------------------------------------------------------------
+// Cause this actor to die
+
+void Actor::die(void) {
+ if (!isDead()) return;
+
+ ObjectID dObj = thisID();
+ scriptCallFrame scf;
+ PlayerActorID playerID;
+
+ scf.invokedObject = dObj;
+ scf.enactor = dObj;
+ scf.directObject = dObj;
+ scf.indirectObject = Nothing;
+ scf.value = 0;
+
+ runObjectMethod(dObj, Method_Actor_onDie, scf);
+
+ // Kill task
+ if (curTask != NULL) {
+ curTask->abort();
+ delete curTask;
+ curTask = NULL;
+ }
+
+ // Kill motion task
+ if (moveTask != NULL) moveTask->remove();
+
+ // If banded, remove from band
+ if (leader != NULL) {
+ assert(isActor(leader));
+
+ leader->removeFollower(this);
+ leader = NULL;
+ }
+
+ if (actorToPlayerID(this, playerID))
+ handlePlayerActorDeath(playerID);
+}
+
+//-----------------------------------------------------------------------
+// Cause this actor to come back to life
+
+void Actor::imNotQuiteDead(void) {
+ if (isDead()) {
+ PlayerActorID pID;
+
+ effectiveStats.vitality = 1;
+ if (actorToPlayerID(this, pID))
+ updateBrotherControls(pID);
+
+ evaluateNeeds();
+ }
+}
+
+//-----------------------------------------------------------------------
+// Cuase the actor to re-assess his/her vitality
+
+void Actor::vitalityUpdate(void) {
+ // If we're dead, don't heal
+ if (isDead()) return;
+
+ // get the base stats for this actor
+ ActorAttributes *baseStats = getBaseStats();
+
+ // first find out if this actor is wounded
+ if (effectiveStats.vitality < baseStats->vitality) {
+ // whole vitality number goes here
+ int16 recover;
+ int16 fractionRecover;
+
+ // get the whole number first
+ recover = recPointsPerUpdate / recPointsPerVitality;
+
+ // get the fraction
+ fractionRecover = recPointsPerUpdate % recPointsPerVitality;
+
+ // if there is an overrun
+ if (currentRecoveryPoints + fractionRecover > recPointsPerVitality) {
+ // add the overrun to the whole number
+ recover++;
+ currentRecoveryPoints = (currentRecoveryPoints + fractionRecover) - recPointsPerVitality;
+ } else {
+ currentRecoveryPoints += fractionRecover;
+ }
+
+
+ if (effectiveStats.vitality + recover >=
+ baseStats->vitality) {
+ effectiveStats.vitality = baseStats->vitality;
+ } else {
+ effectiveStats.vitality += recover;
+
+ //WriteStatusF( 5, " Healed: %d, rec: %d, part: %d ", effectiveStats.vitality,
+ // recover, currentRecoveryPoints );
+ }
+ }
+}
+
+
+//-----------------------------------------------------------------------
+// Perform actor specific activation tasks
+
+void Actor::activateActor(void) {
+#if 0
+ if (thisID() > 32768)
+ amm("Activated %d ", thisID() - 32768);
+#endif
+ evaluateNeeds();
+}
+
+//-----------------------------------------------------------------------
+// Perfrom actor specific deactivation tasks
+
+void Actor::deactivateActor(void) {
+#if 0
+ if (thisID() > 32768)
+ amm("De-activated %d ", thisID() - 32768);
+#endif
+ // Kill task
+ if (curTask != NULL) {
+ curTask->abort();
+ delete curTask;
+ curTask = NULL;
+ }
+
+ // Kill motion task
+ if (moveTask != NULL) moveTask->remove();
+
+ // If banded, remove from band
+ if (leader != NULL) {
+ assert(isActor(leader));
+
+ leader->removeFollower(this);
+ leader = NULL;
+ }
+
+ // Temporary actors get deleted upon deactivation
+ if ((flags & temporary) || isDead()) {
+ deactivationCounter = 10; // actor lasts for 50 seconds
+ }
+}
+
+//-----------------------------------------------------------------------
+// Delobotomize this actor
+
+void Actor::delobotomize(void) {
+ if (!(flags & lobotomized)) return;
+
+ ObjectID dObj = thisID();
+ scriptCallFrame scf;
+
+ flags &= ~lobotomized;
+
+ scf.invokedObject = dObj;
+ scf.enactor = dObj;
+ scf.directObject = dObj;
+ scf.indirectObject = Nothing;
+ scf.value = 0;
+
+ runObjectMethod(dObj, Method_Actor_onDelobotomize, scf);
+
+ evaluateNeeds();
+}
+
+//-----------------------------------------------------------------------
+// Lobotomize this actor
+
+void Actor::lobotomize(void) {
+ if (flags & lobotomized) return;
+
+ ObjectID dObj = thisID();
+ scriptCallFrame scf;
+
+ // Kill task
+ if (curTask != NULL) {
+ curTask->abort();
+ delete curTask;
+ curTask = NULL;
+ }
+
+ // Kill motion task
+ if (moveTask != NULL) moveTask->remove();
+
+ flags |= lobotomized;
+
+ scf.invokedObject = dObj;
+ scf.enactor = dObj;
+ scf.directObject = dObj;
+ scf.indirectObject = Nothing;
+ scf.value = 0;
+
+ runObjectMethod(dObj, Method_Actor_onLobotomize, scf);
+}
+
+//-----------------------------------------------------------------------
+// Return a pointer to the base stats for this actor. If this actor
+// is a non-player actor, the base stats are in the prototype. If this
+// actor is a player actor, the base stats are in the PlayerActor
+// structure.
+
+ActorAttributes *Actor::getBaseStats(void) {
+ if (disposition < dispositionPlayer)
+ return &((ActorProto *)prototype)->baseStats;
+ else
+ return &playerList[ disposition - dispositionPlayer ].baseStats;
+}
+
+//-----------------------------------------------------------------------
+// Return the racial base enchantment flags. If this actor
+// is a non-player actor, the base stats are in the prototype.
+
+uint32 Actor::getBaseEnchantmentEffects(void) {
+ //if ( disposition < dispositionPlayer )
+ return ((ActorProto *)prototype)->baseEffectFlags;
+}
+
+//-----------------------------------------------------------------------
+// Return the object base resistance flags. If this actor
+// is a non-player actor, the base stats are in the prototype.
+
+uint16 Actor::getBaseResistance(void) {
+ //if ( disposition < dispositionPlayer )
+ return ((ActorProto *)prototype)->resistance;
+}
+
+//-----------------------------------------------------------------------
+// Return the object base immunity flags. If this actor
+// is a non-player actor, the base stats are in the prototype.
+
+uint16 Actor::getBaseImmunity(void) {
+ //if ( disposition < dispositionPlayer )
+ return ((ActorProto *)prototype)->immunity;
+}
+
+//-----------------------------------------------------------------------
+// Return the base recovery rate
+
+uint16 Actor::getBaseRecovery(void) {
+ return BASE_REC_RATE;
+}
+
+//-----------------------------------------------------------------------
+// Determine if specified point is within actor's reach
+
+bool Actor::inReach(const TilePoint &tp) {
+ return inRange(tp, defaultReach);
+}
+
+//-----------------------------------------------------------------------
+// Determine if specified point is within an objects use range
+
+bool Actor::inUseRange(const TilePoint &tp, GameObject *obj) {
+ uint16 range = obj->proto()->maximumRange;
+
+ return inRange(tp, MAX(range, defaultReach));
+}
+
+//-----------------------------------------------------------------------
+// Determine if actor is immobile (i.e. can't walk)
+
+bool Actor::isImmobile(void) {
+ return isDead()
+ || hasEffect(actorImmobile)
+ || hasEffect(actorAsleep)
+ || hasEffect(actorParalyzed);
+}
+
+//-----------------------------------------------------------------------
+// Return a pointer to this actor's currently readied offensive object
+
+GameObject *Actor::offensiveObject(void) {
+ if (rightHandObject != Nothing) {
+ assert(isObject(rightHandObject));
+
+ GameObject *obj = GameObject::objectAddress(rightHandObject);
+
+ // Any object in an actor's right hand should be a weapon
+ assert(obj->containmentSet() & ProtoObj::isWeapon);
+
+ return obj;
+ }
+
+ if (leftHandObject != Nothing) {
+ assert(isObject(leftHandObject));
+
+ GameObject *obj = GameObject::objectAddress(leftHandObject);
+
+ if (obj->containmentSet() & ProtoObj::isWeapon)
+ return obj;
+ }
+
+ // If not carrying a weapon attack with self
+ return this;
+}
+
+//-----------------------------------------------------------------------
+// Returns pointers to this actor's readied primary defensive object
+// and optionally their scondary defensive object
+
+void Actor::defensiveObject(GameObject **priPtr, GameObject **secPtr) {
+ assert(priPtr != NULL);
+
+ GameObject *leftHandObjPtr,
+ *rightHandObjPtr,
+ *primary = NULL,
+ *secondary = NULL;
+
+ // Get a pointer to the left hand object
+ leftHandObjPtr = leftHandObject != Nothing
+ ? (assert(isObject(leftHandObject))
+ , GameObject::objectAddress(leftHandObject))
+ : NULL;
+
+ // Get a pointer to the right hand object
+ rightHandObjPtr = rightHandObject != Nothing
+ ? (assert(isObject(rightHandObject))
+ , GameObject::objectAddress(rightHandObject))
+ : NULL;
+
+ if (leftHandObjPtr != NULL) {
+ GameObject **rightHandObjDest;
+
+ if (leftHandObjPtr->proto()->canBlock()) {
+ // Left hand object is primary. Right hand object may be
+ // secondary
+ primary = leftHandObjPtr;
+ rightHandObjDest = &secondary;
+ } else
+ // Right hand object may be primary
+ rightHandObjDest = &primary;
+
+ if (rightHandObjPtr != NULL && rightHandObjPtr->proto()->canBlock())
+ // Right hand object is defensive
+ *rightHandObjDest = rightHandObjPtr;
+ } else {
+ if (rightHandObjPtr != NULL && rightHandObjPtr->proto()->canBlock())
+ // Right hand object is primary defensive object
+ primary = rightHandObjPtr;
+ }
+
+ // Return the primary pointer
+ *priPtr = primary;
+ // Return the secondary pointer
+ if (secPtr != NULL) *secPtr = secondary;
+}
+
+//-----------------------------------------------------------------------
+// Returns a pointer to the object with which this actor is currently
+// blocking, if any
+
+GameObject *Actor::blockingObject(Actor *attacker) {
+ return moveTask != NULL
+ ? moveTask->blockingObject(attacker)
+ : NULL;
+}
+
+//-----------------------------------------------------------------------
+// Return the total used armor attributes
+
+void Actor::totalArmorAttributes(ArmorAttributes &armorAttribs) {
+ int i;
+ ProtoObj *thisProto = proto();
+
+ // Plug in actor's natural values
+ armorAttribs.damageAbsorbtion = thisProto->damageAbsorbtion;
+ armorAttribs.damageDivider = MAX<uint8>(thisProto->damageDivider, 1);
+ armorAttribs.defenseBonus = thisProto->defenseBonus;
+
+ // Accumulate values for all armor objects
+ for (i = 0; i < ARMOR_COUNT; i++) {
+ if (armorObjects[ i ] != Nothing) {
+ ProtoObj *armorProto = GameObject::protoAddress(armorObjects[ i ]);
+
+ assert(armorProto != NULL);
+
+ armorAttribs.damageAbsorbtion += armorProto->damageAbsorbtion;
+ if (armorProto->damageDivider != 0)
+ armorAttribs.damageDivider *= armorProto->damageDivider;
+ armorAttribs.defenseBonus += armorProto->defenseBonus;
+ }
+ }
+}
+
+//-----------------------------------------------------------------------
+// Determine if specified point is within actor's attack range
+
+bool Actor::inAttackRange(const TilePoint &tp) {
+ GameObject *weapon = offensiveObject();
+ uint16 range = weapon != NULL ? weapon->proto()->maximumRange : 0;
+
+ return inRange(tp, MAX(range, defaultReach));
+}
+
+//-----------------------------------------------------------------------
+// Initiate an attack upon a specified target
+
+void Actor::attack(GameObject *target) {
+ GameObject *weapon = offensiveObject();
+
+ if (weapon != NULL)
+ weapon->proto()->initiateAttack(thisID(), target->thisID());
+}
+
+//-----------------------------------------------------------------------
+// Stop all attacks on a specified target
+
+void Actor::stopAttack(GameObject *target) {
+ if (moveTask && moveTask->isAttack() && moveTask->targetObj == target)
+ moveTask->finishAttack();
+}
+
+//-----------------------------------------------------------------------
+// Determine if this actor can block an attack
+
+bool Actor::canDefend(void) {
+ if (isDead()) return FALSE;
+
+ // Look at left hand object, generally the defensive object
+ if (leftHandObject != Nothing) {
+ GameObject *obj = GameObject::objectAddress(leftHandObject);
+
+ if (obj->proto()->canBlock()) return TRUE;
+ }
+
+ // Look at right hand object, generally the offensive object
+ if (rightHandObject != Nothing) {
+ GameObject *obj = GameObject::objectAddress(rightHandObject);
+
+ if (obj->proto()->canBlock()) return TRUE;
+ }
+
+ return FALSE;
+}
+
+//-----------------------------------------------------------------------
+// Return a numeric value which roughly estimates this actor's
+// offensive strength
+
+int16 Actor::offenseScore(void) {
+ // REM: at this time this calculation is somewhat arbitrary
+
+ int16 score = 0;
+ GameObject *weapon = offensiveObject();
+
+ if (weapon != NULL) {
+ ProtoObj *proto = weapon->proto();
+
+ score += proto->weaponDamage + (proto->maximumRange / tileUVSize);
+ }
+
+ // Add average mana
+ score += (effectiveStats.redMana
+ + effectiveStats.orangeMana
+ + effectiveStats.yellowMana
+ + effectiveStats.greenMana
+ + effectiveStats.blueMana
+ + effectiveStats.violetMana)
+ / 6;
+
+ score += effectiveStats.spellcraft + effectiveStats.brawn;
+
+ return score;
+}
+
+//-----------------------------------------------------------------------
+// Return a numeric value which roughly estimates this actor's
+// defensive strength
+
+int16 Actor::defenseScore(void) {
+ // REM: at this time this calculation is somewhat arbitrary
+
+ int16 score = 0;
+ GameObject *shield;
+ ArmorAttributes armorAttribs;
+
+ defensiveObject(&shield);
+
+ if (shield != NULL) {
+ ProtoObj *proto = shield->proto();
+
+ score += proto->defenseBonus;
+ }
+
+ totalArmorAttributes(armorAttribs);
+
+ score += (armorAttribs.defenseBonus + armorAttribs.damageAbsorbtion)
+ * armorAttribs.damageDivider;
+
+ score += effectiveStats.agility + effectiveStats.vitality;
+
+ return score;
+}
+
+//-----------------------------------------------------------------------
+// Return the sprite color translation table based upon the actor's
+// color scheme
+
+void Actor::getColorTranslation(ColorTable map) {
+ // If actor has color table loaded, then calculate the
+ // translation table.
+ if (appearance
+ && appearance->schemeList
+ && *appearance->schemeList) {
+ buildColorTable(map,
+ (*appearance->schemeList)[ colorScheme ].bank,
+ 11);
+ } else memcpy(map, identityColors, 256);
+}
+
+//-----------------------------------------------------------------------
+// Set the current animation sequence for the actor.
+//
+// Each time the nextAnimationFrame() is called, it will increment
+// to the next frame in the sequence.
+
+int16 Actor::setAction(int16 newState, int16 flags) {
+ ActorAnimation *anim;
+ int16 numPoses;
+
+ // Refresh the handles
+// RLockHandle( appearance->animations );
+// RUnlockHandle( appearance->animations );
+
+ if (appearance == NULL) return 0;
+
+ // If this animation has no frames, then return FALSE
+ anim = (*appearance->poseList)->animation(newState);
+ numPoses = anim->count[ currentFacing ];
+ if (numPoses <= 0) return 0;
+
+ // Set up the animation
+ currentAnimation = newState;
+ animationFlags = flags;
+
+ // If they haven't set the "no reset" flag, then
+ if (!(flags & animateNoRestart)) {
+ if (flags & animateReverse) currentPose = numPoses - 1;
+ else currentPose = 0;
+ } else {
+ currentPose = clamp(0, currentPose, numPoses - 1);
+ }
+
+ return numPoses;
+}
+
+//-----------------------------------------------------------------------
+// returns TRUE if the action is available in the current direction.
+//
+
+bool Actor::isActionAvailable(int16 newState, bool anyDir) {
+ ActorAnimation *anim;
+
+ // Refresh the handles
+// RLockHandle( appearance->animations );
+// RUnlockHandle( appearance->animations );
+
+ if (appearance == NULL) return FALSE;
+
+ // If this animation has no frames, then return FALSE
+ anim = (*appearance->poseList)->animation(newState);
+
+ if (anyDir) {
+ for (int i = 0; i < numPoseFacings; i++) {
+ if (anim->count[ i ] > 0) return TRUE;
+ }
+ } else {
+ if (anim->count[ currentFacing ] > 0) return TRUE;
+ }
+
+ return FALSE;
+}
+
+//-----------------------------------------------------------------------
+// Return the number of animation frames in the specified action for the
+// specified direction
+
+int16 Actor::animationFrames(int16 actionType, Direction dir) {
+ if (appearance == NULL) return 0;
+
+ ActorAnimation *anim;
+
+ anim = (*appearance->poseList)->animation(actionType);
+
+ return anim->count[ dir ];
+}
+
+//-----------------------------------------------------------------------
+// Update the current animation sequence to the next frame.
+// Returns TRUE if the animation sequence has finished.
+
+bool Actor::nextAnimationFrame(void) {
+ ActorAnimation *anim;
+ int16 numPoses;
+
+ // Refresh the handles
+// RLockHandle( appearance->animations );
+// RUnlockHandle( appearance->animations );
+
+ if (appearance == NULL) {
+ if (animationFlags & animateOnHold) {
+ return FALSE;
+ } else if (animationFlags & animateRepeat) {
+ animationFlags |= animateOnHold;
+ return FALSE;
+ } else {
+ animationFlags |= animateFinished;
+ return TRUE;
+ }
+ } else animationFlags &= ~animateOnHold;
+
+ // Get the number of frames in the animation
+ anim = (*appearance->poseList)->animation(currentAnimation);
+ numPoses = anim->count[ currentFacing ];
+ if (numPoses <= 0) {
+ animationFlags |= animateFinished;
+ return TRUE; // no poses, return DONE
+ }
+
+ // If the sprite could not be displayed because it has not
+ // been loaded, then don't update the animation state --
+ // wait until the sprite gets loaded, and then continue
+ // with the action.
+ if (animationFlags & animateNotLoaded) return FALSE;
+
+ // If the animation has reached the last frame, then exit.
+ if (animationFlags & animateFinished) return TRUE;
+
+ if (animationFlags & animateRandom) {
+ // Select a random frame from the series.
+ currentPose = rand() % numPoses;
+ } else if (animationFlags & animateReverse) {
+ // Note that the logic for forward repeats is slightly
+ // different for reverse repeats. Specifically, the
+ // "alternate" flag is always checked when going forward,
+ // but it's only checked when going backwards if the repeat
+ // flag is also set. This means that an "alternate" with
+ // no "repeat" will ping-pong exactly once.
+
+ if (currentPose > 0) {
+ currentPose--;
+
+ // Check if this is the last frame
+ if (currentPose <= 0 && !(animationFlags & animateRepeat)) {
+ animationFlags |= animateFinished;
+ }
+ } else if (animationFlags & animateRepeat) {
+ // If we're repeating, check for a back & forth,
+ // or for a wraparound. Also checks for case of
+ // a degenerate series (1 frame only)
+
+ if (animationFlags & animateAlternate) {
+ animationFlags &= ~animateReverse;
+ currentPose = MIN(1, numPoses - 1);
+ } else {
+ currentPose = numPoses - 1;
+ }
+ }
+ } else {
+ if (currentPose < numPoses - 1) {
+ // Increment the pose number
+ currentPose++;
+
+ // Check if this is the last frame
+ if (currentPose >= numPoses - 1 &&
+ !(animationFlags & (animateAlternate | animateRepeat)))
+ animationFlags |= animateFinished;
+ } else if (animationFlags & animateAlternate) {
+ // At the end of the sequence, reverse direction
+ animationFlags |= animateReverse;
+ currentPose = MAX(currentPose - 1, 0);
+ } else if (animationFlags & animateRepeat) {
+ // Wrap back to beginning
+ currentPose = 0;
+ } else //If Last Frame And Not Animate Repeat or Alternate
+ animationFlags |= animateFinished;
+ }
+ return FALSE;
+}
+
+//-----------------------------------------------------------------------
+// Drop the all of the actor's inventory
+
+void Actor::dropInventory(void) {
+ GameObject *obj,
+ *nextObj;
+
+ for (obj = childID != Nothing
+ ? GameObject::objectAddress(childID)
+ : NULL;
+ obj != NULL;
+ obj = nextObj) {
+ nextObj = obj->IDNext() != Nothing
+ ? GameObject::objectAddress(obj->IDNext())
+ : NULL;
+
+ // Delete intangible objects and drop tangible objects
+ if (obj->containmentSet() & ProtoObj::isIntangible)
+ obj->deleteObjectRecursive();
+ else
+ dropInventoryObject(obj, obj->isMergeable() ? obj->getExtra() : 1);
+ }
+}
+
+//-----------------------------------------------------------------------
+// Place an object into this actor's right or left hand
+
+void Actor::holdInRightHand(ObjectID objID) {
+ assert(isObject(objID));
+ rightHandObject = objID;
+
+ if (isPlayerActor(this)) globalContainerList.setUpdate(thisID());
+ evalActorEnchantments(this);
+}
+
+void Actor::holdInLeftHand(ObjectID objID) {
+ assert(isObject(objID));
+ leftHandObject = objID;
+
+ if (isPlayerActor(this)) globalContainerList.setUpdate(thisID());
+ evalActorEnchantments(this);
+}
+
+//-----------------------------------------------------------------------
+// Wear a piece of armor
+
+void Actor::wear(ObjectID objID, uint8 where) {
+ assert(where < ARMOR_COUNT);
+
+ PlayerActorID playerID;
+
+#if DEBUG
+ if (objID != Nothing) {
+ assert(isObject(objID));
+
+ GameObject *obj = GameObject::objectAddress(objID);
+
+ assert(obj->proto()->containmentSet() & ProtoObj::isArmor);
+ }
+#endif
+
+ armorObjects[ where ] = objID;
+
+ if (isPlayerActor(this)) globalContainerList.setUpdate(thisID());
+ evalActorEnchantments(this);
+
+ if (actorToPlayerID(this, playerID)) {
+ updateBrotherArmor(playerID);
+ }
+}
+
+//-----------------------------------------------------------------------
+// Called when the actor is on the display list and has no motion task.
+
+void Actor::updateAppearance(int32) {
+// static uint16 count;
+// count++;
+
+ if (isDead() || !isActivated() || (flags & lobotomized)) return;
+
+#if DEBUG*0
+ WriteStatusF(4, "Wait Count %d Attitude %d", cycleCount, attitude);
+#endif
+
+#if DEBUG*0
+ extern void ShowObjectSection(GameObject * obj);
+ if (this != getCenterActor())
+ if (lineOfSight(getCenterActor(), this, terrainSurface))
+ ShowObjectSection(this);
+#endif
+
+ if (appearance) {
+ if (animationFrames(actionStand, currentFacing) == 1) {
+ if (flags & fightStance) {
+ GameObject *weapon = offensiveObject();
+
+ if (weapon == this) weapon = NULL;
+
+ if (weapon != NULL) {
+ ProtoObj *weaponProto = weapon->proto();
+
+ setAction(weaponProto->fightStanceAction(thisID()), 0);
+ } else {
+ if (isActionAvailable(actionSwingHigh))
+ setAction(actionSwingHigh, 0);
+ else
+ setAction(actionTwoHandSwingHigh, 0);
+ }
+
+ cycleCount = 0;
+ } else {
+ if (cycleCount > 0) { //If In Wait State Between Wait Animation
+ cycleCount--;
+
+ setAction(actionStand, 0); //Just stand still
+ } else { // Wait Animation
+ if (cycleCount == 0) { //If Just Starting Wait Animation
+ cycleCount--;
+ switch (attitude) { //Emotion And Character Type
+ //Currently Attitude Not Set So Always Hits Zero
+ case 0:
+ //Returns True If Successful No Checking Yet
+ SetAvailableAction(0, actionWaitAgressive,
+ actionWaitImpatient,
+ actionWaitFriendly,
+ actionStand,
+ -1);//Second To Last Parameter Is The Default
+ break;
+
+ case 1:
+ SetAvailableAction(0, actionWaitImpatient,
+ actionWaitFriendly,
+ actionWaitAgressive,
+ actionStand,
+ -1);
+ break;
+
+ case 2:
+ SetAvailableAction(0, actionWaitFriendly,
+ actionWaitImpatient,
+ actionWaitAgressive,
+ actionStand,
+ -1);
+
+ }
+ } else //Assume -1
+ if (nextAnimationFrame())//If Last Frame In Wait Animation
+ cycleCount = rand() % 20;
+ }
+ }
+ } else {
+ if (currentAnimation != actionStand
+ || (animationFlags & animateRepeat) == 0)
+ setAction(actionStand, animateRepeat);
+ else
+ nextAnimationFrame();
+ }
+ }// End if (appearance)
+}
+
+bool Actor::SetAvailableAction(int16 flags, ...) {
+ bool result = FALSE;
+ va_list Actions;
+ va_start(Actions, flags); //Initialize To First Argument Even Though We Dont Use It In The Loop
+
+ for (;;) { //Infinite Loop
+ int thisAction = va_arg(Actions, int); //Increment To Second Argument Ignoring Flags
+ if (thisAction < 0) break; //Check If Last Parameter Since Last Always Should Be -1
+ if (setAction(thisAction, flags)) { //Try To Set This Action
+ result = TRUE; //If Successful
+ break;
+ }
+ }
+ va_end(Actions); //Clean Up
+ return result;
+}
+
+//-----------------------------------------------------------------------
+// Set a new goal for this actor
+
+void Actor::setGoal(uint8 newGoal) {
+ if (currentGoal != newGoal) {
+ if (curTask != NULL) {
+ curTask->abort();
+ delete curTask;
+ curTask = NULL;
+ }
+
+ currentGoal = newGoal;
+ }
+}
+
+//-----------------------------------------------------------------------
+// Reevaluate actor's built-in needs
+
+void Actor::evaluateNeeds(void) {
+ if (!isDead()
+ && isActivated()
+ && !(flags & lobotomized)) {
+ if (disposition >= dispositionPlayer) {
+ if (combatBehaviorEnabled) {
+ SenseInfo info;
+
+ if (canSenseActorProperty(
+ info,
+ maxSenseRange,
+ actorPropIDEnemy)
+ || canSenseActorPropertyIndirectly(
+ info,
+ maxSenseRange,
+ actorPropIDEnemy)) {
+ PlayerActorID playerID = disposition - dispositionPlayer;
+
+ if (isAggressive(playerID))
+ setGoal(actorGoalAttackEnemy);
+ else {
+ if (leader != NULL && inBandingRange())
+ setGoal(actorGoalAvoidEnemies);
+ else
+ setGoal(actorGoalPreserveSelf);
+ }
+ } else if (leader != NULL && inBandingRange()) {
+ setGoal(actorGoalFollowLeader);
+ } else {
+ setGoal(actorGoalFollowAssignment);
+ }
+ } else if (leader != NULL && inBandingRange()) {
+ setGoal(actorGoalFollowLeader);
+ } else {
+ setGoal(actorGoalFollowAssignment);
+ }
+ } else {
+ if (disposition == dispositionEnemy
+ && appearance != NULL
+ && !hasEffect(actorNotDefenseless)) {
+ GameObject *obj;
+ bool foundWeapon;;
+ ContainerIterator iter(this);
+
+ while (iter.next(&obj) != Nothing) {
+ ProtoObj *proto = obj->proto();
+
+ if ((proto->containmentSet() & ProtoObj::isWeapon)
+ && isActionAvailable(proto->fightStanceAction(thisID()))) {
+ foundWeapon = TRUE;
+ break;
+ }
+ }
+
+ if (!foundWeapon
+ && (isActionAvailable(actionSwingHigh)
+ || isActionAvailable(actionTwoHandSwingHigh)))
+ foundWeapon = TRUE;
+
+ if (!foundWeapon)
+ flags |= afraid;
+ }
+
+ if (flags & afraid || hasEffect(actorFear) || hasEffect(actorRepelUndead)) {
+ setGoal(actorGoalPreserveSelf);
+ } else if (leader != NULL && inBandingRange()) {
+ setGoal(leader->evaluateFollowerNeeds(this));
+ } else {
+ SenseInfo info;
+
+ if (disposition == dispositionEnemy
+ && (getAssignment() == NULL
+ || canSenseProtaganist(
+ info,
+ maxSenseRange)
+ || canSenseProtaganistIndirectly(
+ info,
+ maxSenseRange))) {
+ setGoal(actorGoalAttackEnemy);
+ } else {
+ setGoal(actorGoalFollowAssignment);
+ }
+ }
+ }
+ }
+}
+
+//-----------------------------------------------------------------------
+// Update the state of this actor.
+
+static int32 updatesViaScript = 0;
+
+void Actor::updateState(void) {
+ // The actor should not be set permanently uninterruptable when
+ // the actor does not have a motion task
+ assert(isMoving() || actionCounter != maxuint8);
+
+ GameObject::updateState();
+
+ if (flags & lobotomized)
+ return;
+
+ // Update the action counter
+ if (actionCounter != 0 && actionCounter != maxuint8)
+ actionCounter--;
+
+ if (appearance != NULL
+ && isDead()
+ && isInterruptable()
+ && (moveTask == NULL
+ || moveTask->motionType != MotionTask::motionTypeDie)) {
+ int16 deadState = isActionAvailable(actionDead)
+ ? actionDead
+ : isActionAvailable(actionDie)
+ ? actionDie
+ : actionStand;
+
+ if (currentAnimation != deadState)
+ MotionTask::die(*this);
+ return;
+ }
+
+ if (!isDead()) {
+ if (this == getCenterActor()) return;
+
+ if (flags & specialAttack) {
+ flags &= ~specialAttack;
+
+ if (currentTarget != NULL) {
+ scriptCallFrame scf;
+ ObjectID dObj = thisID();
+
+ scf.invokedObject = dObj;
+ scf.enactor = dObj;
+ scf.directObject = dObj;
+ scf.indirectObject = currentTarget->thisID();
+ scf.value = 0;
+
+ runObjectMethod(dObj, Method_Actor_onSpecialAttack, scf);
+
+ // If this actor is now deactivated or lobotomized
+ // return immediately
+ if (isDead() || !isActivated() || (flags & lobotomized))
+ return;
+ }
+ }
+
+ switch (currentGoal) {
+ case actorGoalFollowAssignment: {
+ ActorAssignment *assign = getAssignment();
+
+ // Iterate until there is no assignment, or the current
+ // assignment is valid
+ while (assign != NULL && !assign->isValid()) {
+ updatesViaScript++;
+ scriptCallFrame scf;
+ ObjectID dObj = thisID();
+
+ delete assign;
+
+ // Notify the scripts that the assignment has ended
+ scf.invokedObject = dObj;
+ scf.enactor = dObj;
+ scf.directObject = dObj;
+ scf.indirectObject = Nothing;
+ scf.value = 0;
+
+ runObjectMethod(dObj, Method_Actor_onEndAssignment, scf);
+
+ // If this actor is now deactivated or lobotomized
+ // return immediately
+ if (isDead() || !isActivated() || (flags & lobotomized))
+ return;
+
+ // Re-get the assignment
+ assign = getAssignment();
+ }
+
+ // If there is no assignment at this point, call the
+ // schedule to setup a new assignment.
+ if (assign == NULL && schedule != 0) {
+ updatesViaScript++;
+ assert(curTask == NULL);
+
+ scriptCallFrame scf;
+
+ scf.invokedObject = Nothing;
+ scf.enactor = Nothing;
+ scf.directObject = thisID();
+ scf.indirectObject = Nothing;
+ scf.value = 0;
+
+ runScript(schedule, scf);
+
+ // Re-get the assignment
+ assign = getAssignment();
+ }
+
+ // Have the assignment create a new task
+ if (assign != NULL && curTask == NULL)
+ curTask = assign->createTask();
+ }
+ break;
+
+ case actorGoalPreserveSelf:
+
+ if (leader != NULL || followers != NULL)
+ disband();
+
+ if (curTask == NULL) {
+ if ((curTask = new TaskStack(this)) != NULL) {
+ Task *task = NEW_TASK
+ GoAwayFromActorTask(
+ curTask,
+ ActorPropertyTarget(
+ disposition == dispositionEnemy
+ ? actorPropIDPlayerActor
+ : actorPropIDEnemy),
+ TRUE);
+
+ if (task != NULL)
+ curTask->setTask(task);
+ else {
+ delete curTask;
+ curTask = NULL;
+ }
+ }
+ }
+ break;
+
+ case actorGoalAttackEnemy:
+
+ if (curTask == NULL) {
+ if ((curTask = new TaskStack(this)) != NULL) {
+ uint8 disp = leader != NULL
+ ? leader->disposition
+ : disposition;
+
+ Task *task = NEW_TASK HuntToKillTask(
+ curTask,
+ ActorPropertyTarget(
+ disp == dispositionEnemy
+ ? actorPropIDPlayerActor
+ : actorPropIDEnemy));
+
+ if (task != NULL)
+ curTask->setTask(task);
+ else {
+ delete curTask;
+ curTask = NULL;
+ }
+ }
+ }
+ break;
+
+ case actorGoalFollowLeader:
+
+ assert(isActor(leader));
+ assert(followers == NULL);
+
+ if (curTask == NULL)
+ curTask = leader->createFollowerTask(this);
+
+ break;
+
+ case actorGoalAvoidEnemies:
+
+ assert(isActor(leader));
+ assert(followers == NULL);
+
+ if (curTask == NULL) {
+ if ((curTask = new TaskStack(this)) != NULL) {
+ Task *task = NEW_TASK BandAndAvoidEnemiesTask(curTask);
+
+ if (task != NULL)
+ curTask->setTask(task);
+ else {
+ delete curTask;
+ curTask = NULL;
+ }
+ }
+ }
+ }
+ }
+}
+
+//-----------------------------------------------------------------------
+// This routine is used to notify the actor that a task has ended. The
+// actor should handle the situation appropriately
+
+void Actor::handleTaskCompletion(TaskResult result) {
+ // The task is done, get rid of it
+ delete curTask;
+ curTask = NULL;
+
+ switch (currentGoal) {
+ case actorGoalFollowAssignment: {
+ ActorAssignment *assign = getAssignment();
+
+ // If we've gotten to this point, there had better be an
+ // assignment, or something is amiss
+ assert(assign != NULL);
+
+ // Notify the assignment
+ assign->handleTaskCompletion(result);
+ }
+ break;
+ }
+}
+
+//-----------------------------------------------------------------------
+// This function will cause the actor to react to an offensive act
+
+void Actor::handleOffensiveAct(Actor *attacker) {
+ ObjectID dObj = thisID();
+ scriptCallFrame scf;
+
+ scf.invokedObject = dObj;
+ scf.enactor = dObj;
+ scf.directObject = dObj;
+ scf.indirectObject = attacker->thisID();
+ scf.value = 0;
+
+ runObjectMethod(dObj, Method_Actor_onAttacked, scf);
+
+ if (disposition == dispositionFriendly) {
+ if (attacker->disposition >= dispositionPlayer) {
+ disposition = dispositionEnemy;
+ evaluateNeeds();
+ }
+ }
+}
+
+//-----------------------------------------------------------------------
+// This function will cause the actor to react appropriately to taking
+// damage.
+
+void Actor::handleDamageTaken(uint8 damage) {
+ uint8 combatBehavior = ((ActorProto *)prototype)->combatBehavior;
+
+ if (combatBehavior == behaviorHungry) return;
+
+ GameObject *weapon = offensiveObject();
+
+ if (offensiveObject() == this
+ && !isActionAvailable(actionSwingHigh)
+ && !isActionAvailable(actionTwoHandSwingHigh)
+ && !hasEffect(actorNotDefenseless)) {
+ flags |= afraid;
+ return;
+ }
+
+ if (combatBehavior != behaviorHungry
+ && (flags & temporary)
+ && !hasEffect(actorFear)
+ && !hasEffect(actorRepelUndead)) {
+ if (flags & afraid) {
+ // Let's give monsters a small chance of regaining their courage
+ if ((uint16)rand() <= 0x3fff)
+ flags &= ~afraid;
+ } else {
+ int16 i,
+ fellowBandMembers,
+ vitality = effectiveStats.vitality;
+ uint32 moraleBase = ((int32)damage << 16) / vitality,
+ bonus = 0;
+
+ // Adjustment added by Talin to globally reduce the amount of cowardice
+ // in the game. I may reduce it further depending on playtesting.
+ moraleBase /= 3;
+
+ // Adjust morale base according to the combat behavior
+ if (combatBehavior == behaviorCowardly)
+ moraleBase += moraleBase / 2;
+ else if (combatBehavior == behaviorBerserk)
+ moraleBase -= moraleBase / 2;
+
+ // Determine how many fellow band members this actor has.
+ if (leader != NULL)
+ fellowBandMembers = leader->followers->size();
+ else if (followers != NULL)
+ fellowBandMembers = followers->size();
+ else
+ fellowBandMembers = 0;
+
+ // REM: this calculation can be done via a lookup table
+ for (i = 0; i < fellowBandMembers; i++)
+ bonus += ((1 << 16) - bonus) >> 4;
+
+ // Adjust the morale base to acount for the number of fellow band
+ // members
+ moraleBase -= bonus * moraleBase >> 16;
+
+ // Test this actor's morale
+ if ((uint16)rand() <= moraleBase)
+ flags |= afraid;
+ }
+ }
+}
+
+//-----------------------------------------------------------------------
+// This function is called when this actor successfully causes damage
+// to another actor.
+
+void Actor::handleSuccessfulStrike(Actor *target, int8 damage) {
+ PlayerActorID playerID;
+
+ if (actorToPlayerID(this, playerID)) {
+ PlayerActor *player = getPlayerActorAddress(playerID);
+ int16 ratio;
+
+ // If it's a weak monster, then reduce amount of vitality advanced.
+ // If we are twice as vital, then get half the exp's. If we are three times
+ // as vital, get 1/3 the exp. etc.
+ ratio = clamp(1, getBaseStats()->vitality / target->getBaseStats()->vitality, 4);
+
+ player->vitalityAdvance(damage / ratio);
+ }
+}
+
+//-----------------------------------------------------------------------
+// This function is called when this actor successfully kills another
+// actor.
+
+void Actor::handleSuccessfulKill(Actor *target) {
+ PlayerActorID playerID;
+
+ if (this != target && actorToPlayerID(this, playerID)) {
+ static const char vowels[] = "AEIOU";
+
+ PlayerActor *player = getPlayerActorAddress(playerID);
+ int16 ratio;
+ int16 points = target->getBaseStats()->vitality;
+ const char *monsterName = target->objName();
+ const char *aStr;
+
+ // If it's a weak monster, then reduce amount of vitality advanced.
+ // If we are twice as vital, then get half the exp's. If we are three times
+ // as vital, get 1/3 the exp. etc.
+ ratio = clamp(1, getBaseStats()->vitality / points, 4);
+
+ player->vitalityAdvance(points / ratio);
+
+ aStr = target->getNameIndex() == 0
+ ? strchr(vowels, toupper(monsterName[ 0 ])) == NULL
+ ? "a "
+ : "an "
+ : "";
+ StatusMsg("%s has killed %s%s.", objName(), aStr, monsterName);
+ }
+}
+
+//-----------------------------------------------------------------------
+// Determine if this actor can block a blow from the specified relative
+// direction with the specified defensive object.
+
+bool Actor::canBlockWith(GameObject *defenseObj, Direction relativeDir) {
+ assert(defenseObj->proto()->canBlock());
+ assert(relativeDir >= 0 && relativeDir < 8);
+
+ // Assuming that the actor may increment or decrement their facing
+ // to block, these masks represent the possible relative facings
+ // based upon the current relative facing
+ static uint8 dirMaskArray[ 8 ] = {
+ 0x83, // 10000011
+ 0x07, // 00000111
+ 0x0E, // 00001110
+ 0x1C, // 00011100
+ 0x38, // 00111000
+ 0x70, // 01110000
+ 0xE0, // 11100000
+ 0xC1 // 11000001
+ };
+
+ return (defenseObj->proto()->defenseDirMask()
+ & dirMaskArray[ relativeDir ])
+ != 0;
+}
+
+//-----------------------------------------------------------------------
+// This function is called to notify this actor of an impending attack
+
+void Actor::evaluateMeleeAttack(Actor *attacker) {
+ if (isInterruptable() && !isDead()) {
+ Direction relativeDir;
+ GameObject *defenseObj,
+ *primary,
+ *secondary;
+ bool canBlockWithPrimary;
+
+ // Compute the attacker's direction relative to this actor's
+ // facing
+ relativeDir = ((attacker->location - location).quickDir()
+ - currentFacing) & 0x7;
+
+ // Get pointers to this actors primary and secondary defensive
+ // objects
+ defensiveObject(&primary, &secondary);
+
+ canBlockWithPrimary = primary != NULL
+ && canBlockWith(primary, relativeDir);
+
+ if (canBlockWithPrimary) {
+ bool canBlockWithSecondary;
+
+ canBlockWithSecondary = secondary != NULL
+ && canBlockWith(
+ secondary,
+ relativeDir);
+
+ if (canBlockWithSecondary) {
+ // If we can block with either primary or secondary
+ // there is a 25% chance of using the secondary
+ defenseObj = ((rand() & 0x3) != 0) ? primary : secondary;
+ } else {
+ // The primary defensive object will be used
+ defenseObj = primary;
+ }
+ } else
+ defenseObj = NULL;
+
+ if (defenseObj != NULL) {
+ // Start a defensive motion
+ defenseObj->proto()->initiateDefense(
+ defenseObj->thisID(),
+ thisID(),
+ attacker->thisID());
+ } else {
+ if (isActionAvailable(actionJumpUp))
+ MotionTask::dodge(*this, *attacker);
+ }
+ }
+}
+
+//-----------------------------------------------------------------------
+// Cause this actor to accept another actor as his leader. If the actor
+// has followers, this will band those followers to the new leader as
+// well.
+
+void Actor::bandWith(Actor *newLeader) {
+ assert(leader == NULL);
+
+ // If the actor we're banding with is not the leader, then band
+ // with his leader
+ if (newLeader->leader != NULL) {
+ newLeader = newLeader->leader;
+ assert(newLeader->leader == NULL);
+ }
+
+ // If this actor himself does not have followers then its really
+ // simple, otherwise we need to band all of this actor's followers
+ // with the new leader.
+ if (followers == NULL) {
+ if (newLeader->addFollower(this)) leader = newLeader;
+ } else {
+ int16 i,
+ oldFollowerCount = followers->size();
+ Actor **oldFollowers = new Actor * [ oldFollowerCount ];
+
+ if (oldFollowers != NULL) {
+ // Copy the list followers
+ for (i = 0; i < oldFollowerCount; i++) {
+ oldFollowers[ i ] = (*followers)[ i ];
+ assert(oldFollowers[ i ]->leader == this);
+ }
+
+ // Disband all of the old followers
+ for (i = 0; i < oldFollowerCount; i++)
+ oldFollowers[ i ]->disband();
+
+ assert(followers == NULL);
+
+ // Add this actor and all of the old followers to the new
+ // leader's followers.
+ if (newLeader->addFollower(this)) {
+ leader = newLeader;
+
+ for (i = 0; i < oldFollowerCount; i++)
+ oldFollowers[ i ]->bandWith(newLeader);
+ }
+
+ delete [] oldFollowers;
+ }
+ }
+
+ evaluateNeeds();
+}
+
+//-----------------------------------------------------------------------
+// Simply causes this actor to be removed from his current band.
+
+void Actor::disband(void) {
+ if (leader != NULL) {
+ leader->removeFollower(this);
+ leader = NULL;
+
+ evaluateNeeds();
+ } else if (followers != NULL) {
+ int16 i;
+
+ for (i = 0; i < followers->size(); i++) {
+ Actor *follower = (*followers)[ i ];
+
+ follower->leader = NULL;
+ follower->evaluateNeeds();
+ }
+
+ delete followers;
+ followers = NULL;
+ }
+}
+
+//-----------------------------------------------------------------------
+// Add the specified actor to the list of this actor's followers.
+
+bool Actor::addFollower(Actor *newBandMember) {
+ // The new band member should not be a leader of another band or
+ // a follower of another leader
+ assert(newBandMember->leader == NULL);
+ assert(newBandMember->followers == NULL);
+
+ // Allocate a new band, if needed
+ if (followers == NULL && (followers = new Band(this)) == NULL)
+ return FALSE;
+
+ return followers->add(newBandMember);
+}
+
+//-----------------------------------------------------------------------
+// Remove the specified actor from this actor's list of followers.
+
+void Actor::removeFollower(Actor *bandMember) {
+ assert(bandMember->leader == this);
+ assert(followers != NULL);
+
+ int16 i;
+
+ followers->remove(bandMember);
+ if (followers->size() == 0) {
+ delete followers;
+ followers = NULL;
+ } else {
+ uint16 moraleBonus = 0;
+
+ for (i = 0; i < followers->size(); i++)
+ moraleBonus += ((1 << 16) - moraleBonus) >> 4;
+
+ for (i = 0; i < followers->size(); i++) {
+ Actor *follower = (*followers)[ i ];
+ ActorProto *proto = (ActorProto *)follower->prototype;
+ uint8 combatBehavior = proto->combatBehavior;
+
+ if (follower->currentGoal == actorGoalAttackEnemy
+ && combatBehavior != behaviorHungry) {
+ uint32 moraleBase;
+
+ moraleBase = combatBehavior == behaviorCowardly
+ ? (1 << 16) / 4
+ : combatBehavior == behaviorSmart
+ ? (1 << 16) / 8
+ : (1 << 16) / 16;
+
+ moraleBase -= moraleBase * moraleBonus >> 16;
+
+ if ((uint16)rand() <= moraleBase)
+ follower->flags |= afraid;
+ }
+ }
+ }
+}
+
+//-----------------------------------------------------------------------
+// Create a task for a follower of this actor. This is called when a
+// follower has no task.
+
+TaskStack *Actor::createFollowerTask(Actor *bandMember) {
+ assert(bandMember->leader == this);
+
+ TaskStack *ts = NULL;
+
+ if ((ts = new TaskStack(bandMember)) != NULL) {
+ Task *task = NEW_TASK BandTask(ts);
+
+ if (task != NULL)
+ ts->setTask(task);
+ else {
+ delete ts;
+ ts = NULL;
+ }
+ }
+
+ return ts;
+}
+
+//-----------------------------------------------------------------------
+// Evaluate a follower's needs and give him an approriate goal.
+
+uint8 Actor::evaluateFollowerNeeds(Actor *follower) {
+ assert(follower->leader == this);
+
+ SenseInfo info;
+
+ if ((disposition == dispositionEnemy
+ && follower->canSenseProtaganist(info, maxSenseRange))
+ || (disposition >= dispositionPlayer
+ && follower->canSenseActorProperty(
+ info,
+ maxSenseRange,
+ actorPropIDEnemy)))
+ return actorGoalAttackEnemy;
+
+ return actorGoalFollowLeader;
+}
+
+#if DEBUG
+
+uint32 objectTerrain(GameObject *obj, StandingTileInfo &);
+
+void showObjectTerrain(GameObject *obj) {
+ StandingTileInfo sti;
+ uint32 terrain = objectTerrain(obj, sti);
+ char terrLetters[] = "NERWSHWFRSL0000";
+ char str[ 33 ];
+
+ for (int i = 0; i < 32; i++) {
+ str[ i ] = terrain & (1 << i) ? terrLetters[ i ] : '-';
+ }
+ str[ 32 ] = '\0';
+
+// WriteStatusF( 4, str );
+}
+#endif
+
+// Returns 0 if not moving, 1 if path being calculated,
+// 2 if path being followed.
+bool Actor::pathFindState(void) {
+ if (moveTask == NULL) return 0;
+ if (moveTask->pathFindTask) return 1;
+ return 2;
+}
+
+//-----------------------------------------------------------------------
+// Add knowledge package to actor
+
+bool Actor::addKnowledge(uint16 kID) {
+ for (int i = 0; i < elementsof(knowledge); i++) {
+ if (knowledge[ i ] == 0) {
+ knowledge[ i ] = kID;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+//-----------------------------------------------------------------------
+// Remove knowledge package from actor
+
+bool Actor::removeKnowledge(uint16 kID) {
+ for (int i = 0; i < elementsof(knowledge); i++) {
+ if (knowledge[ i ] == kID) {
+ knowledge[ i ] = 0;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+//-----------------------------------------------------------------------
+// Remove all knowledge package from actor
+
+void Actor::clearKnowledge(void) {
+ for (int i = 0; i < elementsof(knowledge); i++) {
+ knowledge[ i ] = 0;
+ }
+}
+
+//-----------------------------------------------------------------------
+// Called to evaluate actor knowledge
+
+void Actor::useKnowledge(scriptCallFrame &scf) {
+ uint16 bestResponsePri = 0,
+ bestResponseClass = 0,
+ bestResponseCode = 0;
+
+ // First, search for the class with the best response
+
+ for (int i = 0; i < elementsof(knowledge); i++) {
+ if (knowledge[ i ]) {
+ scriptResult res;
+
+ // Run the script to eval the response of this
+ // knowledge package
+
+ res = runMethod(knowledge[ i ],
+ builtinAbstract,
+ 0,
+ Method_KnowledgePackage_evalResponse,
+ scf);
+
+ // If script ran OK, then look at result
+
+ if (res == scriptResultFinished) {
+ // break up return code into priority and
+ // response code
+
+ int16 pri = scf.returnVal >> 8,
+ response = scf.returnVal & 0xff;
+
+ if (pri > 0) {
+ // Add a bit of jitter to response
+
+ pri += rand() & 3;
+
+ if (pri > bestResponsePri) {
+ bestResponsePri = pri;
+ bestResponseClass = knowledge[ i ];
+ bestResponseCode = response;
+ }
+ }
+ }
+ }
+ }
+
+ // Then, callback whichever one responded best
+
+ if (bestResponsePri > 0) {
+ // Run the script to eval the response of this
+ // knowledge package
+
+ scf.responseType = bestResponseCode;
+
+ runMethod(bestResponseClass,
+ builtinAbstract,
+ 0,
+ Method_KnowledgePackage_executeResponse,
+ scf);
+ } else {
+ scf.returnVal = actionResultNotDone;
+ }
+}
+
+//-----------------------------------------------------------------------
+// Polling function to determine if any of this actor's followers can
+// sense a protaganist within a specified range
+
+bool Actor::canSenseProtaganistIndirectly(SenseInfo &info, int16 range) {
+ if (followers != NULL) {
+ int i;
+
+ for (i = 0; i < followers->size(); i++) {
+ if ((*followers)[ i ]->canSenseProtaganist(info, range))
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+//-----------------------------------------------------------------------
+// Polling function to determine if any of this actor's followers can
+// sense a specific actor within a specified range
+
+bool Actor::canSenseSpecificActorIndirectly(
+ SenseInfo &info,
+ int16 range,
+ Actor *a) {
+ if (followers != NULL) {
+ int i;
+
+ for (i = 0; i < followers->size(); i++) {
+ if ((*followers)[ i ]->canSenseSpecificActor(info, range, a))
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+//-----------------------------------------------------------------------
+// Polling function to determine if any of this actor's followers can
+// sense a specific object within a specified range
+
+bool Actor::canSenseSpecificObjectIndirectly(
+ SenseInfo &info,
+ int16 range,
+ ObjectID obj) {
+ if (followers != NULL) {
+ int i;
+
+ for (i = 0; i < followers->size(); i++) {
+ if ((*followers)[ i ]->canSenseSpecificObject(info, range, obj))
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+//-----------------------------------------------------------------------
+// Polling function to determine if any of this actor's followers can
+// sense an actor with a specified property within a specified range
+
+bool Actor::canSenseActorPropertyIndirectly(
+ SenseInfo &info,
+ int16 range,
+ ActorPropertyID prop) {
+ if (followers != NULL) {
+ int i;
+
+ for (i = 0; i < followers->size(); i++) {
+ if ((*followers)[ i ]->canSenseActorProperty(info, range, prop))
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+//-----------------------------------------------------------------------
+// Polling function to determine if any of this actor's followers can
+// sense an object with a specified property within a specified range
+
+bool Actor::canSenseObjectPropertyIndirectly(
+ SenseInfo &info,
+ int16 range,
+ ObjectPropertyID prop) {
+ if (followers != NULL) {
+ int i;
+
+ for (i = 0; i < followers->size(); i++) {
+ if ((*followers)[ i ]->canSenseObjectProperty(info, range, prop))
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+
+//-----------------------------------------------------------------------
+// Mana check - spell casting uses this to check whether an actor
+// has enough mana to cast a spell & to remove that mana if
+// it's there
+
+#define NO_MONSTER_MANA 1
+
+bool Actor::takeMana(ActorManaID i, int8 dMana) {
+#if NO_MONSTER_MANA
+ if (!isPlayerActor(this))
+ return TRUE;
+#endif
+ VERIFY(i >= manaIDRed && i <= manaIDViolet);
+ if ((&effectiveStats.redMana)[i] < dMana)
+ return FALSE;
+ (&effectiveStats.redMana)[i] -= dMana;
+ updateIndicators();
+ return TRUE;
+}
+
+bool Actor::hasMana(ActorManaID i, int8 dMana) {
+#if NO_MONSTER_MANA
+ if (!isPlayerActor(this))
+ return TRUE;
+#endif
+ VERIFY(i >= manaIDRed && i <= manaIDViolet);
+ if ((&effectiveStats.redMana)[i] < dMana)
+ return FALSE;
+ return TRUE;
+}
+
+//-----------------------------------------------------------------------
+// Saving throw funcion
+
+bool Actor::makeSavingThrow(void) {
+ return FALSE;
+}
+
+//-------------------------------------------------------------------
+// Determine if the actors are currently initialized
+
+bool areActorsInitialized(void) {
+ return actorList != NULL;
+}
+
+int16 GetRandomBetween(int start, int end) {
+ // Here's a more efficient way to express this.
+
+ if (start == end) return start;
+ else return (rand() % abs(end - start)) + start;
+
+}
+
+static int useLine = 0;
+
+void updateActorStates(void) {
+ if (actorStatesPaused) return;
+
+ static const int32 evalRate = 8;
+ static const int32 evalRateMask = evalRate - 1;
+ static int32 baseActorIndex = evalRateMask;
+ extern Actor *actorList;
+ extern int16 actorCount;
+
+ int32 actorIndex;
+
+ actorIndex = baseActorIndex = (baseActorIndex + 1) & evalRateMask;
+ while (actorIndex < actorCount) {
+ Actor *a = &actorList[ actorIndex ];
+
+ if (isWorld(a->IDParent()))
+ a->evaluateNeeds();
+
+ actorIndex += evalRate;
+ }
+
+ updatesViaScript = 0;
+ for (actorIndex = 0; actorIndex < actorCount; actorIndex++) {
+ Actor *a = &actorList[ actorIndex ];
+
+ if (isWorld(a->IDParent()) && a->isActivated())
+ a->updateState();
+ }
+
+
+ //WriteStatusF((useLine%10)+10,"%d actor updates by script",updatesViaScript);
+ //WriteStatusF(((useLine+1)%10)+10," ");
+ //useLine++;
+}
+
+//-------------------------------------------------------------------
+
+void pauseActorStates(void) {
+ actorStatesPaused = TRUE;
+}
+
+//-------------------------------------------------------------------
+
+void resumeActorStates(void) {
+ actorStatesPaused = FALSE;
+}
+
+//-------------------------------------------------------------------
+
+void setCombatBehavior(bool enabled) {
+ PlayerActor *player;
+ LivingPlayerActorIterator iter;
+
+ combatBehaviorEnabled = enabled;
+
+ for (player = iter.first(); player != NULL; player = iter.next())
+ player->getActor()->evaluateNeeds();
+}
+
+//-------------------------------------------------------------------
+// Initialize the actor list
+
+void initActors(void) {
+ // Load actors
+
+ int i,
+ resourceActorCount;
+ ResourceActor *resourceActorList;
+
+ resourceActorCount = listRes->size(actorListID)
+ / sizeof(ResourceActor);
+
+ if (resourceActorCount < 1)
+ error("Unable to load Actors");
+
+ // Add extra space for alias actors
+ actorCount = resourceActorCount + extraActors;
+
+ // Allocate memory for the actor list
+ actorListSize = actorCount * sizeof(Actor);
+ actorList = (Actor *)RNewClearPtr(actorListSize, NULL, "actor list");
+
+ if (!actorList)
+ error("Unable to load Actors");
+
+ // Allocate memory for the resource actors
+ resourceActorList =
+ (ResourceActor *)RNewClearPtr(resourceActorCount
+ * sizeof(ResourceActor),
+ NULL, "res actor list");
+
+ if (!resourceActorList || listRes->seek(actorListID) == 0)
+ error("Unable to load Actors");
+
+ // Read the resource actors
+ listRes->read(resourceActorList,
+ sizeof(ResourceActor) * resourceActorCount);
+
+ for (i = 0; i < resourceActorCount; i++) {
+ Actor *a = &actorList[ i ];
+
+ // Initialize the actors with the resource data
+ new (a) Actor(resourceActorList[ i ]);
+ }
+
+ // Place all of the extra actors in actor limbo
+ for (; i < actorCount; i++) {
+ Actor *a = &actorList[ i ];
+
+ new (a) Actor;
+ }
+
+ actorList[ 0 ].disposition = dispositionPlayer + 0;
+ actorList[ 1 ].disposition = dispositionPlayer + 1;
+ actorList[ 2 ].disposition = dispositionPlayer + 2;
+
+
+ // Wait for the object initialization to append the actors to their
+ // parents' child lists
+
+ RDisposePtr(resourceActorList);
+}
+
+//-------------------------------------------------------------------
+// Save actor list to a save file
+
+void saveActors(SaveFileConstructor &saveGame) {
+ int16 i;
+ int32 archiveBufSize = 0;
+ void *archiveBuffer;
+ int16 *bufferPtr;
+
+ // Accumulate size of archive buffer
+
+ // Add size of actor count
+ archiveBufSize += sizeof(int16);
+
+ for (i = 0; i < actorCount; i++)
+ archiveBufSize += actorList[ i ].archiveSize();
+
+ archiveBuffer = RNewPtr(archiveBufSize, NULL, "archive buffer");
+ if (archiveBuffer == NULL)
+ error("Unable to allocate actor archive buffer");
+
+ bufferPtr = (int16 *)archiveBuffer;
+
+ // Store the number of actors in the archive buffer
+ *bufferPtr++ = actorCount;
+
+ // Store the actor data in the archive buffer
+ for (i = 0; i < actorCount; i++)
+ bufferPtr = (int16 *)actorList[ i ].archive(bufferPtr);
+
+ // Write the archive buffer to the save file
+ saveGame.writeChunk(
+ MakeID('A', 'C', 'T', 'R'),
+ archiveBuffer,
+ archiveBufSize);
+
+ RDisposePtr(archiveBuffer);
+}
+
+//-------------------------------------------------------------------
+// Load the actor list from a save file
+
+void loadActors(SaveFileReader &saveGame) {
+ int16 i;
+ int32 archiveBufSize;
+ void *archiveBuffer;
+ void *bufferPtr;
+
+ // Read in the actor count
+ saveGame.read(&actorCount, sizeof(actorCount));
+
+ // Allocate the actor array
+ actorListSize = actorCount * sizeof(Actor);
+ actorList = (Actor *)RNewPtr(actorListSize, NULL, "actor list");
+ if (actorList == NULL)
+ error("Unable to load Actors");
+
+ // Allocate memory for the archive buffer
+ archiveBufSize = saveGame.bytesLeftInChunk();
+ archiveBuffer = RNewPtr(archiveBufSize, NULL, "archive buffer");
+ if (archiveBuffer == NULL)
+ error("Unable to load Actors");
+
+ saveGame.read(archiveBuffer, archiveBufSize);
+
+ for (i = 0, bufferPtr = archiveBuffer;
+ i < actorCount;
+ i++)
+ // Initilize actors with archive data
+ new (&actorList[ i ]) Actor(&bufferPtr);
+
+ assert(bufferPtr == &((char *)archiveBuffer)[ archiveBufSize ]);
+
+ // Deallocate the archive buffer
+ RDisposePtr(archiveBuffer);
+}
+
+//-------------------------------------------------------------------
+// Cleanup the actor list
+
+void cleanupActors(void) {
+ if (actorList != NULL) {
+ int16 i;
+
+ for (i = 0; i < actorCount; i++)
+ actorList[ i ].~Actor();
+
+ RDisposePtr(actorList);
+ actorList = NULL;
+ }
+}
+
+/* ============================================================================ *
+ Actor faction tallies
+ * ============================================================================ */
+
+int16 AddFactionTally(int faction, enum factionTallyTypes act, int amt) {
+#if DEBUG
+ if (faction >= maxFactions)
+ error("Scripter: Tell Talin to increase maxFactions!\n");
+ assert(faction >= 0);
+ assert(act >= 0);
+ assert(act < factionNumColumns);
+#endif
+ /*
+ // If faction attitude counts get to big then down-scale all of them
+ // in proportion.
+ if ( factionTable[ faction ][ act ] + amt > maxint16 )
+ {
+ for (int i = 0; i < factionNumColumns; i++)
+ factionTable[ faction ][ i ] >>= 1;
+ }
+
+ // Otherwise, if it doesn;t underflow, then add it in.
+ if ( factionTable[ faction ][ act ] + amt > minint16 )
+ {
+ factionTable[ faction ][ act ] += amt;
+ }
+ */
+ factionTable[ faction ][ act ] = clamp(minint16,
+ factionTable[ faction ][ act ] + amt,
+ maxint16);
+
+ return factionTable[ faction ][ act ];
+}
+
+// Get the attitude a particular faction has for a char.
+int16 GetFactionTally(int faction, enum factionTallyTypes act) {
+#if DEBUG
+ if (faction >= maxFactions)
+ error("Scripter: Tell Talin to increase maxFactions!\n");
+ assert(faction >= 0);
+ assert(act >= 0);
+ assert(act < factionNumColumns);
+#endif
+
+ return factionTable[ faction ][ act ];
+}
+
+//-------------------------------------------------------------------
+// Initialize the faction tally table
+
+void initFactionTallies(void) {
+ memset(&factionTable, 0, sizeof(factionTable));
+}
+
+//-------------------------------------------------------------------
+// Save the faction tallies to a save file
+
+void saveFactionTallies(SaveFileConstructor &saveGame) {
+ saveGame.writeChunk(
+ MakeID('F', 'A', 'C', 'T'),
+ &factionTable,
+ sizeof(factionTable));
+}
+
+//-------------------------------------------------------------------
+// Load the faction tallies from a save file
+
+void loadFactionTallies(SaveFileReader &saveGame) {
+ saveGame.read(&factionTable, sizeof(factionTable));
+}
+
+}
diff --git a/engines/saga2/actor.h b/engines/saga2/actor.h
new file mode 100644
index 0000000000..3201d56c15
--- /dev/null
+++ b/engines/saga2/actor.h
@@ -0,0 +1,1135 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Based on the original sources
+ * Faery Tale II -- The Halls of the Dead
+ * (c) 1993-1996 The Wyrmkeep Entertainment Co.
+ */
+
+#ifndef SAGA2_ACTOR_H
+#define SAGA2_ACTOR_H
+
+#include "saga2/objects.h"
+#include "saga2/tile.h"
+#include "saga2/effects.h"
+
+namespace Saga2 {
+
+#ifdef _WIN32 // Set structure alignment packing value to 1 byte
+#pragma pack( push, 1 )
+#endif
+
+/* ===================================================================== *
+ Constants
+ * ===================================================================== */
+
+class ActorAssignment;
+class Band;
+class MotionTask;
+class TaskStack;
+
+const int bandingDist = sectorSize * 2;
+const int actorScriptVars = 4;
+
+/* ===================================================================== *
+ Actor character attributes
+ * ===================================================================== */
+
+// Defines the colors of MANA
+
+enum ActorSkillID {
+ skillIDArchery = 0,
+ skillIDSwordcraft,
+ skillIDShieldcraft,
+ skillIDBludgeon,
+ skillIDThrowing, // gone
+ skillIDSpellcraft,
+ skillIDStealth, // gone
+ skillIDAgility,
+ skillIDBrawn,
+ skillIDLockpick, // gone
+ skillIDPilfer, // gone
+ skillIDFirstAid, // gone
+ skillIDSpotHidden, // gone
+ numSkills,
+};
+
+enum ArmorObjectTypes {
+ SHIRT_ARMOR = 0,
+ BOOT_ARMOR,
+ BRACER_ARMOR,
+ HELM_ARMOR,
+ NECKLACE_ARMOR,
+ CLOAK_ARMOR,
+ RING_ARMOR,
+
+ ARMOR_COUNT
+};
+
+/* ===================================================================== *
+ ArmorAttributes struct
+ * ===================================================================== */
+
+struct ArmorAttributes {
+ uint8 damageAbsorbtion,
+ damageDivider,
+ defenseBonus;
+};
+
+/* ===================================================================== *
+ ActorAttributes structure
+ * ===================================================================== */
+
+// this enum acts as a layer of indirection for the unioned allSkills
+// array.
+
+
+// This defines the basic skills possessed by an actor
+struct ActorAttributes {
+ enum skillInfo {
+ skillBasePercent = 100,
+ skillFracPointsPerLevel = 5, // this being twenty and levels at 5
+ skillLevels = 20, // will make the advancement calc quick & easy
+ skillMaxLevel = skillFracPointsPerLevel * skillLevels,
+ };
+
+ enum vitalityInfo {
+ vitalityLimit = 256,
+ };
+
+ union {
+ struct {
+
+ // Automatic skills
+ uint8 archery, // Accuracy of missile weapons
+ swordcraft, // Accuracy of bladed melee weapons
+ shieldcraft, // Actor's ability to use a shield
+ bludgeon, // Accuracy of non-bladed melee weapons
+ throwing, // Ability to throw objects accurately
+ spellcraft, // Accuracy of spell combat
+ stealth, // Ability to remain unnoticed
+ agility, // Ability to dodge
+ brawn, // Ability to lift, and damage of weapons
+ lockpick; // Ability to pick locks
+
+ // Manual skills
+ uint8 pilfer, // Ability to "lift" an item
+ firstAid, // Ability to heal recent injuries
+ spotHidden; // Ability to spot hidden objects
+
+
+ };
+
+ uint8 allSkills[ numSkills ]; // number of skills
+ };
+
+
+ // Pad byte for alignment
+ int8 pad;
+
+ // Hit-points
+ int16 vitality;
+
+ // Magic energy
+ union {
+ struct {
+ int16 redMana,
+ orangeMana,
+ yellowMana,
+ greenMana,
+ blueMana,
+ violetMana;
+ };
+
+ int16 allManas[ numManas ];
+ };
+
+ uint8 &skill(int16 id) {
+ return allSkills[ id ];
+ }
+ int16 &mana(int16 id) {
+ return allManas[ id ];
+ }
+
+ uint8 getSkillLevel(int16 id) {
+ return skill(id) / skillFracPointsPerLevel + 1;
+ }
+}; // 28 bytes
+
+
+const int baseCarryingCapacity = 100;
+const int carryingCapacityBonusPerBrawn = 200 / ActorAttributes::skillLevels;
+
+/* ===================================================================== *
+ ResourceActorProtoExtension structure
+ * ===================================================================== */
+
+enum combatBehaviorTypes {
+ behaviorHungry,
+ behaviorCowardly,
+ behaviorBerserk,
+ behaviorSmart,
+};
+
+// This defines the additional data fields needed for actor prototypes
+struct ResourceActorProtoExtension {
+
+ ActorAttributes baseStats; // Base stats for non-player actors
+
+ // Defines behavior for combat tactics.
+ uint8 combatBehavior;
+ uint8 gruntStyle;
+
+ uint32 baseEffectFlags; // special effects, see EFFECTS.H
+
+ // Default constructor -- do nothing
+ ResourceActorProtoExtension(void) {}
+
+ // Copy constructor
+ ResourceActorProtoExtension(ResourceActorProtoExtension &ext) {
+ memcpy(this, &ext, sizeof(ResourceActorProtoExtension));
+ }
+}; // 28 bytes
+
+/* ===================================================================== *
+ ResourceActorPrototype structure
+ * ===================================================================== */
+
+// Defines the actor prototype data as read from the resource file
+struct ResourceActorPrototype {
+ ResourceObjectPrototype proto; // Standard prototype data
+ ResourceActorProtoExtension ext; // Extended actor data
+};
+
+/* ===================================================================== *
+ ActorProto prototype behavior for Actors
+ * ===================================================================== */
+
+class ActorProto : public ProtoObj, public ResourceActorProtoExtension {
+
+private:
+ enum {
+ ViewableRows = 3,
+ ViewableCols = 3,
+ maxRows = 3,
+ maxCols = 3,
+ };
+
+public:
+ ActorProto(ResourceActorPrototype &a) :
+ ProtoObj(a.proto),
+ ResourceActorProtoExtension(a.ext) {
+ }
+
+ // returns the containment type flags for this object
+ virtual uint16 containmentSet(void);
+
+ // returns TRUE if this object can contain another object
+ virtual bool canContain(ObjectID dObj, ObjectID item);
+
+ // Determine if this object can contain another object at a
+ // specified slot
+ virtual bool canContainAt(
+ ObjectID dObj,
+ ObjectID item,
+ const TilePoint &where);
+
+ weaponID getWeaponID(void);
+
+ // use this actor
+ bool useAction(ObjectID dObj, ObjectID enactor);
+
+ // open this actor
+ bool canOpen(ObjectID dObj, ObjectID enactor);
+ bool openAction(ObjectID dObj, ObjectID enactor);
+
+ // close this actor
+ bool closeAction(ObjectID dObj, ObjectID enactor);
+
+ bool strikeAction(
+ ObjectID dObj,
+ ObjectID enactor,
+ ObjectID item);
+
+ bool damageAction(
+ ObjectID dObj,
+ ObjectID enactor,
+ ObjectID target);
+
+ // drop another object onto this actor.
+ bool acceptDropAction(
+ ObjectID dObj,
+ ObjectID enactor,
+ ObjectID droppedObj,
+ int count);
+
+ // cause damage directly
+ bool acceptDamageAction(
+ ObjectID dObj,
+ ObjectID enactor,
+ int8 absDamage,
+ effectDamageTypes dType,
+ int8 dice,
+ uint8 sides,
+ int8 perDieMod);
+
+ // cause healing directly
+ bool acceptHealingAction(ObjectID dObj, ObjectID enactor, int8 healing);
+
+ // Accept strike from an object (allows this actor to cause
+ // damage to the striking object).
+ bool acceptStrikeAction(
+ ObjectID dObj,
+ ObjectID enactor,
+ ObjectID strikingObj,
+ uint8 skillIndex);
+
+ // Handle the results of an object being inserted into this object
+ // at the specified slot
+ bool acceptInsertionAtAction(
+ ObjectID dObj,
+ ObjectID enactor,
+ ObjectID item,
+ const TilePoint &where,
+ int16 num = 1);
+
+ // Initiate an attack using this type of object
+ virtual void initiateAttack(ObjectID attacker, ObjectID target);
+
+ // Given an object sound effect record, which sound should be made
+ // when this object is damaged
+ virtual uint8 getDamageSound(const ObjectSoundFXs &soundFXs);
+
+ // Do the background processing, if needed, for this object.
+ void doBackgroundUpdate(GameObject *obj);
+
+ // Cause the user's associated skill to grow
+ void applySkillGrowth(ObjectID enactor, uint8 points = 1);
+
+ bool greetActor(
+ ObjectID dObj, // object dropped on
+ ObjectID enactor); // person doing dropping
+
+public:
+ virtual uint16 getViewableRows(void) {
+ return ViewableRows;
+ }
+ virtual uint16 getViewableCols(void) {
+ return ViewableCols;
+ }
+ virtual uint16 getMaxRows(void) {
+ return maxRows;
+ }
+ virtual uint16 getMaxCols(void) {
+ return maxCols;
+ }
+
+ virtual bool canFitBulkwise(GameObject *container, GameObject *obj);
+ virtual bool canFitMasswise(GameObject *container, GameObject *obj);
+
+ virtual uint16 massCapacity(GameObject *container);
+ virtual uint16 bulkCapacity(GameObject *container);
+};
+
+/* ============================================================================ *
+ Actor: Describes an instance of a character
+ * ============================================================================ */
+
+enum actorCreationFlags {
+ actorPermanent = (1 << 0),
+};
+
+enum DispositionType {
+ dispositionFriendly,
+ dispositionEnemy,
+
+ dispositionPlayer
+};
+
+enum actionSequenceOptions {
+
+ // Flags set by call to setAction
+ animateRepeat = (1 << 0), // repeat animation when done
+ animateReverse = (1 << 1), // animate in reverse direction
+ animateAlternate = (1 << 2), // both directions, back & forth
+ animateRandom = (1 << 3), // pick a random frame
+ animateNoRestart = (1 << 4), // don't reset from start
+
+ // This flag is set if the animation has been put on hold until
+ // the actor's appearance is reloaded.
+ animateOnHold = (1 << 5),
+
+ // This flag is set if the final frame of the animation has
+ // been reached.
+ animateFinished = (1 << 6),
+
+ // This flag gets set if the sprite could not be displayed
+ // because it's bank hasn't been loaded yet.
+ animateNotLoaded = (1 << 7),
+};
+
+// Various types of action sequences
+
+
+enum ActorAnimationTypes {
+
+ // Various types of stands
+ actionStand = 0, // standing still
+ actionWaitAgressive, // an agressive wait cycle
+ actionWaitImpatient, // an impatient wait cycle
+ actionWaitFriendly, // a a friendly wait cycle
+
+ // Walking and running
+ actionWalk, // walking motion
+ actionRun, // running motion
+
+ // Squatting
+ actionDuck, // stoop to dodge sword
+ actionStoop, // stoop to pick up object
+
+ // Jumping
+ actionFreeFall, // how he looks in ballistic
+ actionFreeFallRunning, // a running leap (free fall)
+ actionJumpUp, // begin jump straight up
+ actionJumpFwd, // begin jump forward
+ actionJumpBack, // begin jump back in surprise
+ actionLand, // land after jump
+ actionFallBadly, // after a very long fall
+
+ // Climbing
+ actionClimbLadder, // climb a ladder (2 directions)
+
+ // Talking & interacting
+ actionTalk, // talking
+ actionGesture, // gesture with hands or body
+ actionGiveItem, // give or take item
+
+ // Two-handed weapon use
+ actionTwoHandSwingHigh, // full overhead swing aim high
+ actionTwoHandSwingLow, // full overhead swing aim low
+ actionTwoHandSwingLeftHigh, // partial swing on left (high)
+ actionTwoHandSwingLeftLow, // partial swing on left (low)
+ actionTwoHandSwingRightHigh, // partial swing on rgt (high)
+ actionTwoHandSwingRightLow, // partial swing on rgt (low)
+ actionTwoHandParry, // hold sword up to parry
+
+ // One-handed weapon use
+ actionSwingHigh, // one-handed swing (high)
+ actionSwingLow, // one-handed swing (low)
+ actionParryHigh, // one-handed parry (high)
+ actionParryLow, // one-handed parry (low)
+ actionShieldParry, // parry with shield
+
+ actionThrowObject, // throw
+
+ // Other combat actions
+ actionFireBow, // fire an arrow
+ actionCastSpell, // cast a magic spell
+ actionUseWand, // cast a magic spell w/wand
+ actionUseStaff, // cast a magic spell w/staff
+ actionHit, // show impact of blow
+ actionKnockedDown, // knocked down by opponent
+ actionDie, // death agony
+
+ // Passive actions
+ actionSleep, // sleeping
+ actionDead, // dead body on ground
+ actionSit, // sitting at table
+
+ // Misc actions built from other frames
+ actionListenAtDoor, // listening at doors
+ actionShoveDoor, // try to force a door open
+ actionSpecial1, // special Action
+ actionSpecial2, // special Action
+ actionSpecial3, // special Action
+ actionSpecial4, // special Action
+ actionSpecial5, // special Action
+ actionSpecial6, // special Action
+ actionSpecial7, // special Action
+ actionSpecial8, // special Action
+};
+
+enum ActorGoalTypes {
+ actorGoalFollowAssignment,
+ actorGoalPreserveSelf,
+ actorGoalAttackEnemy,
+ actorGoalFollowLeader,
+ actorGoalAvoidEnemies,
+};
+
+// The actor structure will be divided into two parts. The
+// ResourceActor structure defines the data as it is stored in the
+// resource file. The Actor structure has a copy of all of the
+// ResourceActor data members, plus data members which will be
+// initialized and used during run time.
+
+struct ResourceActor : public ResourceGameObject {
+
+ // Social loyalty
+ uint8 faction; // actor's faction
+
+ // Appearance attribute
+ uint8 colorScheme; // indirect color map
+
+ int32 appearanceID; // appearnce of this actor
+
+ // Personality attributes
+ int8 attitude, // cooperativeness
+ mood; // happiness
+ uint8 disposition; // actor disposition
+ // 0 = friendly, 1 = enemy,
+ // 2 = Julian, 3 = Philip,
+ // 4 = Kevin
+
+ // Character orientation
+ Direction currentFacing; // current facing direction
+
+ // Tether info
+ int16 tetherLocU; // tether U coordinate
+ int16 tetherLocV; // tether V coordinate
+ int16 tetherDist; // length of tether
+
+ // Held objects
+ ObjectID leftHandObject, // object held in left hand.
+ rightHandObject; // object held in right hand.
+
+ // Knowledge packets
+ uint16 knowledge[ 16 ];
+
+ // Schedule script ID
+ uint16 schedule;
+
+ // Pad bytes
+ uint8 reserved[ 18 ];
+
+};
+
+class Actor : public GameObject {
+ friend class ActorProto;
+ friend class MotionTask;
+ friend class Task;
+ friend class TaskStack;
+
+public:
+
+ // Resource fields
+
+ // Social loyalty
+ uint8 faction; // actor's faction
+
+ // Appearance attribute
+ uint8 colorScheme; // indirect color map
+
+ int32 appearanceID; // appearnce of this actor
+
+ // Personality attributes
+ int8 attitude, // cooperativeness
+ mood; // happiness
+ uint8 disposition; // actor disposition
+ // 0 = friendly, 1 = enemy,
+ // 2 = Julian, 3 = Philip,
+ // 4 = Kevin
+
+ // Character orientation
+ Direction currentFacing; // current facing direction
+
+ // Tether info
+ int16 tetherLocU; // tether U coordinate
+ int16 tetherLocV; // tether V coordinate
+ int16 tetherDist; // length of tether
+
+ // Held objects
+ ObjectID leftHandObject, // object held in left hand.
+ rightHandObject; // object held in right hand.
+
+ // Knowledge packets
+ uint16 knowledge[ 16 ];
+
+ // Schedule script ID
+ uint16 schedule;
+
+ // Run-time fields
+
+ uint8 conversationMemory[ 4 ];// last things talked about
+
+ // Sprite animation variables
+ uint8 currentAnimation, // current action sequence
+ currentPose, // current pose in sequence
+ animationFlags; // current posing flags
+
+ // Various actor flags
+ enum {
+ lobotomized = (1 << 0),
+ temporary = (1 << 1),
+ afraid = (1 << 2),
+ hasAssignment = (1 << 3),
+ specialAttack = (1 << 4),
+ fightStance = (1 << 5),
+ };
+
+ uint8 flags;
+
+ // Contains sprite index and positioning info for the current
+ // actor state.
+ ActorPose poseInfo; // current animation state
+
+ // Pointer to the appearance record (sprite array) for this actor.
+ ActorAppearance *appearance; // appearance structs
+
+ int16 cycleCount; // misc counter for actions
+ int16 kludgeCount; // another misc counter
+
+ uint32 enchantmentFlags; // flags indicating racial
+ // abilities and enchantments
+
+ // Movement attributes
+ MotionTask *moveTask;
+
+ // Current task
+ TaskStack *curTask;
+
+ // Current goal type
+ uint8 currentGoal;
+
+ // Used for deltayed deactivation (and also to word-align struct)
+ uint8 deactivationCounter;
+
+ // Assignment
+ uint8 assignmentBuf[ 24 ]; // memory reserved for actor
+ // assignments
+
+ // Current effective stats
+ ActorAttributes effectiveStats;
+
+ uint8 actionCounter; // coordinate moves in combat
+
+ uint16 effectiveResistance; // resistances (see EFFECTS.H)
+ uint16 effectiveImmunity; // immunities (see EFFECTS.H)
+
+ int16 recPointsPerUpdate; // fractional vitality recovery
+
+ int16 currentRecoveryPoints; // fraction left from last recovery
+
+ enum vitalityRecovery {
+ recPointsPerVitality = 10,
+ };
+
+
+ Actor *leader; // This actor's leader
+ Band *followers; // This actor's band of followers
+
+ ObjectID armorObjects[ ARMOR_COUNT ]; // armor objects being worn
+
+ GameObject *currentTarget;
+
+ int16 scriptVar[ actorScriptVars ]; // scratch variables for scripter use
+
+ // Member functions
+
+private:
+ // Initialize actor record
+ void init(
+ int16 protoIndex,
+ uint16 nameIndex,
+ uint16 scriptIndex,
+ int32 appearanceNum,
+ uint8 colorSchemeIndex,
+ uint8 factionNum,
+ uint8 initFlags);
+
+public:
+ // Default constructor
+ Actor(void) {}
+
+ // Constructor - initial actor construction
+ Actor(const ResourceActor &res);
+
+ // Reconstruct from archive buffer
+ Actor(void **buf);
+
+ // Destructor
+ ~Actor(void);
+
+ // Return the number of bytes needed to archive this actor
+ int32 archiveSize(void);
+
+ // Archive this actor in a buffer
+ void *archive(void *buf);
+
+ static Actor *newActor(
+ int16 protoNum,
+ uint16 nameIndex,
+ uint16 scriptIndex,
+ int32 appearanceNum,
+ uint8 colorSchemeIndex,
+ uint8 factionNum,
+ uint8 initFlags);
+
+ // Delete this actor
+ void deleteActor(void);
+
+private:
+ // Turn incrementally
+ void turn(Direction targetDir) {
+ Direction relativeDir = (targetDir - currentFacing) & 0x7;
+
+ currentFacing =
+ (relativeDir < 4
+ ? currentFacing + 1
+ : currentFacing - 1)
+ & 0x7;
+ }
+public:
+
+ // Cause the actor to stop his current motion task is he is
+ // interruptable
+ void stopMoving(void);
+
+ // Cause this actor to die
+ void die(void);
+
+ // Cause this actor to return from the dead
+ void imNotQuiteDead(void);
+
+ // makes the actor do a vitality change test
+ void vitalityUpdate(void);
+
+ // Perform actor specific activation tasks
+ void activateActor(void);
+
+ // Perform actor specific deactivation tasks
+ void deactivateActor(void);
+
+ // De-lobotomize this actor
+ void delobotomize(void);
+
+ // Lobotomize this actor
+ void lobotomize(void);
+
+ // Allocate the assignment buffer for a new assignment
+ void *allocAssignment(size_t sz) {
+ ASSERT(sz <= sizeof(assignmentBuf));
+ if (!(flags & hasAssignment)) {
+ flags |= hasAssignment;
+ return &assignmentBuf;
+ } else
+ return NULL;
+ }
+
+ // Free the emmbedded assignment buffer
+ void freeAssignment(void) {
+ flags &= ~hasAssignment;
+ }
+
+ // Return a pointer to the actor's current assignment
+ ActorAssignment *getAssignment(void) {
+ return flags & hasAssignment
+ ? (ActorAssignment *)&assignmentBuf
+ : NULL;
+ }
+
+ // determine wether this actor has a specified property
+ bool hasProperty(const ActorProperty &actorProp) {
+ // The function call operator is used explicitly because
+ // Visual C++ 4.0 doesn't like it otherwise.
+ return actorProp.operator()(this);
+ }
+
+ // Determine if specified point is within actor's arms' reach
+ bool inReach(const TilePoint &tp);
+
+ // Determine if specified point is within an objects use range
+ bool inUseRange(const TilePoint &tp, GameObject *obj);
+
+ // Determine if actor is dead
+ bool isDead(void) {
+ return effectiveStats.vitality <= 0;
+ }
+
+ // Determine if actor is immobile (i.e. can't walk)
+ bool isImmobile(void);
+
+ // Return a pointer to this actor's currently readied offensive
+ // object
+ GameObject *offensiveObject(void);
+
+ // Returns pointers to this actor's readied primary defensive object
+ // and optionally their scondary defensive object
+ void defensiveObject(GameObject **priPtr, GameObject **secPtr = NULL);
+
+ // Returns a pointer to the object with which this actor is
+ // currently blocking, if any
+ GameObject *blockingObject(Actor *attacker);
+
+ // Return the total used armor attributes
+ void totalArmorAttributes(ArmorAttributes &armorAttribs);
+
+ // Determine if specified point is within actor's attack range
+ bool inAttackRange(const TilePoint &tp);
+
+ // Attack the specified object with the currently selected weapon
+ void attack(GameObject *obj);
+
+ // Stop any attack on the specified object
+ void stopAttack(GameObject *obj);
+
+ // Determine if this actor can block an attack with objects
+ // currently being held
+ bool canDefend(void);
+
+ // Return a numeric value which roughly estimates this actor's
+ // offensive strength
+ int16 offenseScore(void);
+
+ // Return a numeric value which roughly estimates this actor's
+ // defensive strenght
+ int16 defenseScore(void);
+
+ // Handle the effect of a successful hit on an opponent in combat
+ void handleSuccessfulStrike(GameObject *weapon) {
+ weapon->proto()->applySkillGrowth(thisID());
+ }
+
+ // Return the value of this actor's disposition
+ int16 getDisposition(void) {
+ return disposition;
+ }
+
+ // Give the actor a new disposition
+ int16 setDisposition(int16 newDisp) {
+ int16 oldDisp = disposition;
+ if (newDisp < dispositionPlayer) disposition = newDisp;
+ return oldDisp;
+ }
+
+ // Return a pointer to the effective stats
+ ActorAttributes *getStats(void) {
+ return &effectiveStats;
+ }
+
+ // Return a pointer to this actor's base stats
+ ActorAttributes *getBaseStats(void);
+
+ // Return the color remapping table
+ void getColorTranslation(ColorTable map);
+
+ // Determine if this actor is interruptable
+ bool isInterruptable(void) {
+ return actionCounter == 0;
+ }
+
+ // Determine if this actor is permanently uninterruptable
+ bool isPermanentlyUninterruptable(void) {
+ return actionCounter == maxuint8;
+ }
+
+ // Set the inturruptability for this actor
+ void setInterruptablity(bool val) {
+ actionCounter = val ? 0 : maxuint8;
+ }
+
+ // Set action time counter for this actor
+ // REM: the action points will eventually need to be scaled based
+ // upon enchantments and abilities
+ void setActionPoints(uint8 points) {
+ actionCounter = points;
+ }
+
+ // Drop the all of the actor's inventory
+ void dropInventory(void);
+
+ // Place an object into this actor's right or left hand
+ void holdInRightHand(ObjectID objID);
+ void holdInLeftHand(ObjectID objID);
+
+ // Wear a piece of armor
+ void wear(ObjectID objID, uint8 where);
+
+ // Update the appearance of an actor with no motion task.
+ void updateAppearance(int32 deltaTime);
+
+ // Used To Find Wait State When Preffered Not Available
+ bool SetAvailableAction(int16, ...);
+
+ // Set the current animation sequence that the actor is doing.
+ // Returns the number of poses in the sequence, or 0 if there
+ // are no poses in the sequence.
+ int16 setAction(int16 newState, int16 flags);
+
+ // returns TRUE if the action is available in the current
+ // direction.
+ bool isActionAvailable(int16 newState, bool anyDir = FALSE);
+
+ // Return the number of animation frames in the specified action
+ // for the specified direction
+ int16 animationFrames(int16 actionType, Direction dir);
+
+ // Update the current animation sequence to the next frame
+ bool nextAnimationFrame(void);
+
+ // calculate which sprite frames to show. Return FALSE if
+ // sprite frames are not loaded.
+ bool calcSpriteFrames(void);
+
+ // Calculate the frame list entry, given the current actor's
+ // body state, and facing direction.
+// FrameListEntry *calcFrameState( int16 bodyState );
+
+ // Returns 0 if not moving, 1 if path being calculated,
+ // 2 if path being followed.
+ bool pathFindState(void);
+
+ // High level actor behavior functions
+private:
+ void setGoal(uint8 newGoal);
+
+public:
+ void evaluateNeeds(void);
+
+ // Called every frame to update the state of this actor
+ void updateState(void);
+
+ void handleTaskCompletion(TaskResult result);
+ void handleOffensiveAct(Actor *attacker);
+ void handleDamageTaken(uint8 damage);
+ void handleSuccessfulStrike(Actor *target, int8 damage);
+ void handleSuccessfulKill(Actor *target);
+
+private:
+ static bool canBlockWith(GameObject *defenseObj, Direction relativeDir);
+public:
+ void evaluateMeleeAttack(Actor *attacker);
+
+ // Banding related functions
+ void bandWith(Actor *newLeader);
+ void disband(void);
+
+ bool inBandingRange(void) {
+ ASSERT(leader != NULL);
+
+ return leader->IDParent() == IDParent()
+ && (leader->getLocation() - getLocation()).quickHDistance()
+ <= bandingDist;
+ }
+
+private:
+ bool addFollower(Actor *newBandMember);
+ void removeFollower(Actor *bandMember);
+
+ TaskStack *createFollowerTask(Actor *bandMember);
+ uint8 evaluateFollowerNeeds(Actor *follower);
+
+public:
+ // Knowledge-related member functions
+ bool addKnowledge(uint16 kID);
+ bool removeKnowledge(uint16 kID);
+ void clearKnowledge(void);
+ void useKnowledge(scriptCallFrame &scf);
+
+ bool canSenseProtaganistIndirectly(SenseInfo &info, int16 range);
+ bool canSenseSpecificActorIndirectly(
+ SenseInfo &info,
+ int16 range,
+ Actor *a);
+ bool canSenseSpecificObjectIndirectly(
+ SenseInfo &info,
+ int16 range,
+ ObjectID obj);
+ bool canSenseActorPropertyIndirectly(
+ SenseInfo &info,
+ int16 range,
+ ActorPropertyID prop);
+ bool canSenseObjectPropertyIndirectly(
+ SenseInfo &info,
+ int16 range,
+ ObjectPropertyID prop);
+
+ // Take mana from actor's mana pool (if possible)
+ bool takeMana(ActorManaID i, int8 dMana);
+
+ bool hasMana(ActorManaID i, int8 dMana);
+
+ uint32 getBaseEnchantmentEffects(void);
+ uint16 getBaseResistance(void);
+ uint16 getBaseImmunity(void);
+ uint16 getBaseRecovery(void);
+
+ bool resists(effectResistTypes r) {
+ return effectiveResistance & (1 << r);
+ }
+ bool isImmuneTo(effectImmuneTypes r) {
+ return effectiveImmunity & (1 << r);
+ }
+ bool hasEffect(effectOthersTypes e) {
+ return (enchantmentFlags & (1 << e)) != 0;
+ }
+
+ void setResist(effectResistTypes r, bool on) {
+ effectiveResistance = on ?
+ effectiveResistance | (1 << r) :
+ effectiveResistance & ~(1 << r);
+ }
+
+ void setImmune(effectImmuneTypes r, bool on) {
+ effectiveImmunity = on ?
+ effectiveImmunity | (1 << r) :
+ effectiveImmunity & ~(1 << r);
+ }
+
+ void setEffect(effectOthersTypes e, bool on) {
+ enchantmentFlags = on ?
+ enchantmentFlags | (1 << e) :
+ enchantmentFlags & ~(1 << e);
+ }
+
+ bool makeSavingThrow(void);
+
+ void setFightStance(bool val) {
+ if (val)
+ flags |= fightStance;
+ else
+ flags &= ~fightStance;
+ }
+};
+
+inline bool isPlayerActor(Actor *a) {
+ return a->disposition >= dispositionPlayer;
+}
+
+inline bool isPlayerActor(ObjectID obj) {
+ return isActor(obj)
+ && isPlayerActor((Actor *)GameObject::objectAddress(obj));
+}
+
+inline bool isEnemy(Actor *a) {
+ return !a->isDead() && a->disposition == dispositionEnemy;
+}
+
+inline bool isEnemy(ObjectID obj) {
+ return isActor(obj)
+ && isEnemy((Actor *)GameObject::objectAddress(obj));
+}
+
+void updateActorStates(void);
+
+void pauseActorStates(void);
+void resumeActorStates(void);
+
+void setCombatBehavior(bool enabled);
+
+// Determine if the actors are currently initialized
+bool areActorsInitialized(void);
+
+void clearEnchantments(Actor *a);
+void addEnchantment(Actor *a, uint16 enchantmentID);
+
+/* ============================================================================ *
+ Actor factions table
+ * ============================================================================ */
+
+// Let's assume 64 factions maximum for now
+const int maxFactions = 64;
+
+enum factionTallyTypes {
+ factionNumKills = 0, // # of times faction member killed by PC
+ factionNumThefts, // # of times PC steals from faction member
+ factionNumFavors, // accumulated by SAGA script.
+
+ factionNumColumns
+};
+
+// Get the attitude a particular faction has for a char.
+int16 GetFactionTally(int faction, enum factionTallyTypes act);
+
+// Increment / Decrement faction attitude
+// Whenever an actor is killed, call:
+// AddFactionAttitude( actor.faction, factionNumKills, 1 );
+// Whenever an actor is robbed, call:
+// AddFactionAttitude( actor.faction, factionNumThefts, 1 );
+int16 AddFactionTally(int faction, enum factionTallyTypes act, int amt);
+
+// Initialize the faction tally table
+void initFactionTallies(void);
+
+// Save the faction tallies to a save file
+void saveFactionTallies(SaveFileConstructor &saveGame);
+
+// Load the faction tallies from a save file
+void loadFactionTallies(SaveFileReader &saveGame);
+
+// Cleanup the faction tally table
+inline void cleanupFactionTallies(void) { /* Nothing to do */ }
+
+/* ============================================================================ *
+ Magic: Actor Enchantment bits
+ * ============================================================================ */
+
+// These are are all the enchantment effects that can be represented
+// as a single bit.
+
+
+
+// THESE ARE NO LONGER VALID SEE EFFECTS.H
+
+#if 0
+enum enchantmentEffects {
+ actorFlamingAura = (1 << 0), // surrounded by damaging aura
+ actorImmunePhysical = (1 << 1), // immune to physical weapons
+ actorImmuneProjectile = (1 << 2), // immune to projectiles
+ actorImmuneHandToHand = (1 << 3), // immune to non-projectiles
+ actorImmuneMagicMissile = (1 << 4), // immune to magical projectiles
+ actorImmuneFire = (1 << 5), // immune to fire
+ actorImmuneFireMagic = (1 << 6), // immune to magical fire
+ actorImmuneLava = (1 << 7), // immune to hot terrain
+ actorImmuneCold = (1 << 8), // immune to cold
+ actorImmuneMental = (1 << 9), // immune to mental attack
+ actorImmuneDirectMagic = (1 << 10), // immune to direct magic
+ actorImmuneLifeDrain = (1 << 11), // immune to Life Drain
+ actorLandWalking = (1 << 12), // can walk on land
+ actorDesolidified = (1 << 13), // can walk through walls
+ actorFloating = (1 << 14), // actor is floating
+ actorFallSlowly = (1 << 15), // protected against falling
+ actorLevitating = (1 << 16), // actor is levitating
+ actorWaterWalking = (1 << 17), // can walk on water
+ actorFlying = (1 << 18), // flying spell
+ actorBlind = (1 << 19), // actor is blind
+ actorPanic = (1 << 20), // actor runs away from danger
+ actorParalyzed = (1 << 21), // actor can not move
+ actorMoveFast = (1 << 22), // move faster than normal
+ actorMoveSlow = (1 << 23), // move slower than normal
+ actorAttackFast = (1 << 24), // attack faster than normal
+ actorAttackSlow = (1 << 25), // attack slower than normal
+ actorAsleep = (1 << 26), // actor goes to sleep
+ actorSoulSight = (1 << 27), // can see invisible
+ actorClairvoyant = (1 << 28), // player can scroll view
+ actorDetectPoison = (1 << 29), // poison objects highlighted
+ actorInvisible = (1 << 30), // no-one can see this actor
+ actorHasNoSmell = (1 << 31), // can't be tracked
+};
+#endif
+
+#ifdef _WIN32 // Reset old structure alignment
+#pragma pack( pop )
+#endif
+
+} // end of namespace Saga2
+
+#endif
diff --git a/engines/saga2/annoy.h b/engines/saga2/annoy.h
new file mode 100644
index 0000000000..7bfd3fcfae
--- /dev/null
+++ b/engines/saga2/annoy.h
@@ -0,0 +1,128 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Based on the original sources
+ * Faery Tale II -- The Halls of the Dead
+ * (c) 1993-1996 The Wyrmkeep Entertainment Co.
+ */
+
+#ifndef SAGA2_ANNOY_H
+#define SAGA2_ANNOY_H
+
+/* ===================================================================== *
+ Nested includes
+ * ===================================================================== */
+
+#include "saga2/tcoords.h"
+
+/* ===================================================================== *
+ Constants
+ * ===================================================================== */
+
+namespace Saga2 {
+
+//-----------------------------------------------------------------------
+// known annoying test sounds
+
+#define TEST_OPEN 1
+#define TEST_CLOSE 2
+#define TEST_USE 3
+#define TEST_THROW 4
+
+/* ===================================================================== *
+ Imports
+ * ===================================================================== */
+
+class Location;
+
+/* ===================================================================== *
+ Prototypes
+ * ===================================================================== */
+
+//-----------------------------------------------------------------------
+// play routines
+
+void playMusic(uint32 s);
+
+void playSound(uint32 s);
+void playSoundAt(uint32 s, Location playAt);
+void playSoundAt(uint32 s, Point32 playAt);
+
+void playVoice(uint32 s);
+bool sayVoiceAt(uint32 s[], Location l);
+bool sayVoiceAt(uint32 s[], Point32 l);
+
+void playLoop(uint32 s);
+void playLoopAt(uint32 s, Location l);
+void playLoopAt(uint32 s, Point32 l);
+void moveLoop(Point32 loc);
+
+//-----------------------------------------------------------------------
+// play routines for SAGA
+
+void PlaySound(char IDstr[]);
+void PlayVoice(char IDstr[]);
+void PlayLoop(char IDstr[]);
+void PlayMusic(char IDstr[]);
+void PlayLongSound(char IDstr[]);
+
+//-----------------------------------------------------------------------
+// general maintainence
+
+bool initAudio(void);
+void startAudio(void);
+void suspendAudio(void);
+void resumeAudio(void);
+void cleanupAudio(void);
+void writeConfig(void);
+
+void audioEventLoop(void);
+bool stillDoingVoice(uint32 sampno);
+
+//-----------------------------------------------------------------------
+// environmental sounds
+
+void audioEnvironmentUseSet(int16 audioSet, int32 auxID, Point32 relPos);
+void audioEnvironmentCheck(void);
+
+void audioEnvironmentSetAggression(bool onOff);
+void audioEnvironmentSetDaytime(bool onOff);
+void audioEnvironmentSuspend(bool onOff);
+void audioEnvironmentSetWorld(int mapNum);
+
+//-----------------------------------------------------------------------
+// environmental music
+
+void clearActiveFactions(void);
+void useActiveFactions(void);
+
+
+//-----------------------------------------------------------------------
+// prototypes
+
+#if DEBUG
+int annoyingTestSound(int32); // prototype for annoying test sound calls
+int annoyingTestMusic(int32);
+#endif
+
+}
+
+#endif //ANNOY_H
diff --git a/engines/saga2/arrowptr.cpp b/engines/saga2/arrowptr.cpp
new file mode 100644
index 0000000000..6d3cf64a03
--- /dev/null
+++ b/engines/saga2/arrowptr.cpp
@@ -0,0 +1,60 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Based on the original sources
+ * Faery Tale II -- The Halls of the Dead
+ * (c) 1993-1996 The Wyrmkeep Entertainment Co.
+ */
+
+/* ===================================================================== *
+ pointer.cpp -- Created from pointer1.bbm
+ Image Size: 11 Wide by 17 High.
+ Converted by iff2c.
+ * ===================================================================== */
+
+#include "saga2/std.h"
+#include "saga2/gdraw.h"
+
+namespace Saga2 {
+
+static char arrowPtrData[] = {
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Row 0
+ 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Row 1
+ 0x01, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Row 2
+ 0x01, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Row 3
+ 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Row 4
+ 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, // Row 5
+ 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, // Row 6
+ 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, // Row 7
+ 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, // Row 8
+ 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, // Row 9
+ 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, // Row 10
+ 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, // Row 11
+ 0x01, 0x02, 0x01, 0x00, 0x01, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, // Row 12
+ 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, // Row 13
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x00, 0x00, // Row 14
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x00, 0x00, // Row 15
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, // Row 16
+};
+
+gStaticImage arrowPtr(11, 17, (uint8 *)arrowPtrData);
+
+} // end of namespace Saga2
diff --git a/engines/saga2/assign.cpp b/engines/saga2/assign.cpp
new file mode 100644
index 0000000000..28b3800f98
--- /dev/null
+++ b/engines/saga2/assign.cpp
@@ -0,0 +1,846 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Based on the original sources
+ * Faery Tale II -- The Halls of the Dead
+ * (c) 1993-1996 The Wyrmkeep Entertainment Co.
+ */
+
+/* ===================================================================== *
+ Includes
+ * ===================================================================== */
+
+#include "saga2/std.h"
+#include "saga2/assign.h"
+#include "saga2/patrol.h"
+
+namespace Saga2 {
+
+/* ===================================================================== *
+ ActorAssignment member functions
+ * ===================================================================== */
+
+//----------------------------------------------------------------------
+// Constructor -- reconstruct from archive buffer
+
+ActorAssignment::ActorAssignment(void **buf) {
+ uint16 *a = (uint16 *)*buf;
+
+ startFrame = *a++;
+ endFrame = *a++;
+
+ *buf = a;
+}
+
+//----------------------------------------------------------------------
+// ActorAssignment destructor
+
+ActorAssignment::~ActorAssignment(void) {
+ Actor *a = getActor();
+
+ // Determine if the actor has a task initiated by this assignment
+ if (a->currentGoal == actorGoalFollowAssignment
+ && a->curTask != NULL) {
+ // If so, abort it
+ a->curTask->abort();
+ delete a->curTask;
+ a->curTask = NULL;
+ }
+}
+
+//----------------------------------------------------------------------
+// Return the number of bytes need to archive the data in this
+// assignment
+
+inline int32 ActorAssignment::archiveSize(void) const {
+ return sizeof(startFrame) + sizeof(endFrame);
+}
+
+//----------------------------------------------------------------------
+// Save the data in this object to a buffer
+
+void *ActorAssignment::archive(void *buf) const {
+ uint16 *a = (uint16 *)buf;
+
+ *a++ = startFrame;
+ *a++ = endFrame;
+
+ return a;
+}
+
+//----------------------------------------------------------------------
+// Return a pointer to the specified actor's reserved memory for
+// assignments if it is not already being used.
+
+void *ActorAssignment::operator new (
+ size_t bytes,
+ Actor *a) {
+ return a->allocAssignment(bytes);
+}
+
+//----------------------------------------------------------------------
+// Simply mark the actor's assignment as not being used.
+
+void ActorAssignment::operator delete (void *p) {
+ ((ActorAssignment *)p)->getActor()->freeAssignment();
+}
+
+//----------------------------------------------------------------------
+// Determine if the time limit for this assignment has been exceeded
+
+bool ActorAssignment::isValid(void) {
+ uint16 frame = calender.frameInDay();
+
+ return frame < endFrame
+ || (startFrame >= endFrame && frame >= startFrame);
+}
+
+//----------------------------------------------------------------------
+// Create a TaskStack for this actor and plug in the assignment's Task.
+
+TaskStack *ActorAssignment::createTask(void) {
+ if (!taskNeeded()) return NULL;
+
+ Actor *a = getActor();
+ TaskStack *ts = NULL;
+
+ if ((ts = new TaskStack(a)) != NULL) {
+ Task *task = getTask(ts);
+
+ if (task != NULL)
+ ts->setTask(task);
+ else {
+ delete ts;
+ ts = NULL;
+ }
+ }
+
+ return ts;
+}
+
+//----------------------------------------------------------------------
+// This function is called to notify the assignment of the completion
+// of a task which the assignment had created.
+
+void ActorAssignment::handleTaskCompletion(TaskResult) {
+ // Do nothing
+}
+
+//----------------------------------------------------------------------
+// Plug a new task into the actor, if the actor is currently following
+// his assignment
+
+void ActorAssignment::startTask(void) {
+ Actor *a = getActor();
+
+ if (a->currentGoal == actorGoalFollowAssignment)
+ a->curTask = createTask();
+}
+
+//----------------------------------------------------------------------
+// Determine if this assignment needs to create a task at this time
+
+bool ActorAssignment::taskNeeded(void) {
+ return TRUE;
+}
+
+/* ===================================================================== *
+ PatrolRouteAssignment member functions
+ * ===================================================================== */
+
+//----------------------------------------------------------------------
+// Constructor -- initial object construction
+
+PatrolRouteAssignment::PatrolRouteAssignment(
+ uint16 until,
+ int16 rteNo,
+ uint8 patrolFlags,
+ int16 start,
+ int16 end) :
+ ActorAssignment(until),
+ routeNo(rteNo),
+ startingWayPoint(start),
+ endingWayPoint(end),
+ routeFlags(patrolFlags),
+ flags(0) {
+}
+
+//----------------------------------------------------------------------
+// Restore the data for this object from a buffer
+
+PatrolRouteAssignment::PatrolRouteAssignment(void **buf) :
+ ActorAssignment(buf) {
+ void *bufferPtr = *buf;
+
+ // Restore route number
+ routeNo = *((int16 *)bufferPtr);
+ // Restore the starting way point
+ startingWayPoint = *((int16 *)bufferPtr + 1);
+ // Restore the ending way point
+ endingWayPoint = *((int16 *)bufferPtr + 2);
+ bufferPtr = (int16 *)bufferPtr + 3;
+
+ // Restore the route flags
+ routeFlags = *((uint8 *)bufferPtr);
+ // Restore the assignment flags
+ flags = *((uint8 *)bufferPtr + 1);
+ bufferPtr = (uint8 *)bufferPtr + 2;
+
+ *buf = bufferPtr;
+}
+
+//----------------------------------------------------------------------
+// Return the number of bytes need to archive the data in this
+// assignment
+
+inline int32 PatrolRouteAssignment::archiveSize(void) const {
+ return ActorAssignment::archiveSize()
+ + sizeof(routeNo)
+ + sizeof(startingWayPoint)
+ + sizeof(endingWayPoint)
+ + sizeof(routeFlags)
+ + sizeof(flags);
+}
+
+//----------------------------------------------------------------------
+// Save the data in this object to a buffer
+
+void *PatrolRouteAssignment::archive(void *buf) const {
+ // Let the base class write its data to the buffer
+ buf = ActorAssignment::archive(buf);
+
+ // Store the route number
+ *((int16 *)buf) = routeNo;
+ // Store the starting way point
+ *((int16 *)buf + 1) = startingWayPoint;
+ // Store the ending way point
+ *((int16 *)buf + 2) = endingWayPoint;
+ buf = (int16 *)buf + 3;
+
+ // Store the route flags
+ *((uint8 *)buf) = routeFlags;
+ // Store the assignment flags
+ *((uint8 *)buf + 1) = flags;
+ buf = (uint8 *)buf + 2;
+
+ return buf;
+}
+
+//----------------------------------------------------------------------
+// Return an integer representing the class of this object for archival
+// reasons.
+
+int16 PatrolRouteAssignment::type(void) const {
+ return patrolRouteAssignment;
+}
+
+//----------------------------------------------------------------------
+// This function is called to notify the assignment of the completion
+// of a task which the assignment had created.
+
+void PatrolRouteAssignment::handleTaskCompletion(TaskResult result) {
+ if (result == taskSucceeded) flags |= routeCompleted;
+}
+
+//----------------------------------------------------------------------
+// Determine if assignment is still valid
+
+bool PatrolRouteAssignment::isValid(void) {
+ // If the route has already been completed, then the assignment is
+ // no longer valid
+ if (flags & routeCompleted) return FALSE;
+
+ return ActorAssignment::isValid();
+}
+
+//----------------------------------------------------------------------
+// Determine if this assignment needs to create a task at this time
+
+bool PatrolRouteAssignment::taskNeeded(void) {
+ // If the route has already been completed, then no task is needed
+ return !(flags & routeCompleted);
+}
+
+//----------------------------------------------------------------------
+// Construct a Task for this assignment
+
+Task *PatrolRouteAssignment::getTask(TaskStack *ts) {
+ int16 startPoint = startingWayPoint;
+ uint8 mapNum = getActor()->getMapNum();
+
+ startingWayPoint = -1;
+
+ if (startPoint == -1) {
+ int16 i;
+ uint16 bestDist = maxuint16;
+ const PatrolRoute &route = patrolRouteList[ mapNum ][ routeNo ];
+ TilePoint actorLoc = getActor()->getLocation();
+
+ for (i = 0; i < route.vertices(); i++) {
+ uint16 dist = lineDist(route[ i ], route[(i + 1) % route.vertices() ], actorLoc);
+
+ if (dist < bestDist) {
+ bestDist = dist;
+ startPoint = (routeFlags & patrolRouteReverse) ? i : (i + 1) % route.vertices();
+ }
+ }
+ }
+
+ // Construct a patrol route iterator.
+ PatrolRouteIterator
+ iter = PatrolRouteIterator(
+ mapNum,
+ routeNo,
+ routeFlags,
+ startPoint);
+
+ // Construct a FollowPatrolRouteTask
+ return endingWayPoint != -1
+ ? NEW_TASK FollowPatrolRouteTask(ts, iter, endingWayPoint)
+ : NEW_TASK FollowPatrolRouteTask(ts, iter);
+}
+
+/* ===================================================================== *
+ HuntToBeNearLocationAssignment member functions
+ * ===================================================================== */
+
+//----------------------------------------------------------------------
+// An initialization function which provides a common ground for
+// the initial constructors.
+
+void HuntToBeNearLocationAssignment::initialize(
+ const Target &targ,
+ uint16 r) {
+ ASSERT(targ.size() <= sizeof(targetMem));
+ // Make a copy of the target
+ targ.clone(targetMem);
+
+ range = r;
+}
+
+//----------------------------------------------------------------------
+// Constructor -- constructs from archive buffer
+
+HuntToBeNearLocationAssignment::HuntToBeNearLocationAssignment(void **buf) :
+ ActorAssignment(buf) {
+ void *bufferPtr = *buf;
+
+ // Restore the target
+ bufferPtr = constructTarget(targetMem, bufferPtr);
+
+ // Restore the range
+ range = *((uint16 *)bufferPtr);
+
+ *buf = (uint16 *)bufferPtr + 1;
+}
+
+//----------------------------------------------------------------------
+// Return the number of bytes need to archive the data in this
+// assignment
+
+inline int32 HuntToBeNearLocationAssignment::archiveSize(void) const {
+ return ActorAssignment::archiveSize()
+ + targetArchiveSize(getTarget())
+ + sizeof(range);
+}
+
+//----------------------------------------------------------------------
+// Write the data from this assignment object to a buffer in order
+// to save it on disk
+
+void *HuntToBeNearLocationAssignment::archive(void *buf) const {
+ // Let the base class archive its data
+ buf = ActorAssignment::archive(buf);
+
+ // Store the target
+ buf = archiveTarget(getTarget(), buf);
+
+ // Store the range
+ *((uint16 *)buf) = range;
+
+ return (uint16 *)buf + 1;
+}
+
+//----------------------------------------------------------------------
+// Return an integer representing the class of this object for archival
+// reasons.
+
+int16 HuntToBeNearLocationAssignment::type(void) const {
+ return huntToBeNearLocationAssignment;
+}
+
+//----------------------------------------------------------------------
+// Determine if this assignment needs to create a task at this time
+
+bool HuntToBeNearLocationAssignment::taskNeeded(void) {
+ Actor *a = getActor();
+ TilePoint actorLoc = a->getLocation();
+
+ return !a->inRange(getTarget()->where(a->world(), actorLoc), range);
+}
+
+//----------------------------------------------------------------------
+// Construct a Task for this assignment
+
+Task *HuntToBeNearLocationAssignment::getTask(TaskStack *ts) {
+ return NEW_TASK HuntToBeNearLocationTask(ts, *getTarget(), range);
+}
+
+/* ===================================================================== *
+ HuntToBeNearActorAssignment member functions
+ * ===================================================================== */
+
+//----------------------------------------------------------------------
+// An initialization function which provides a common ground for the
+// initial constructors.
+
+void HuntToBeNearActorAssignment::initialize(
+ const ActorTarget &at,
+ uint16 r,
+ bool trackFlag) {
+ ASSERT(at.size() <= sizeof(targetMem));
+
+ // Copy the target
+ at.clone(targetMem);
+
+ range = r;
+ flags = trackFlag ? track : 0;
+}
+
+//----------------------------------------------------------------------
+// Constructor -- constructs from archive buffer
+
+HuntToBeNearActorAssignment::HuntToBeNearActorAssignment(void **buf) :
+ ActorAssignment(buf) {
+ void *bufferPtr = *buf;
+
+ // Restore the target
+ bufferPtr = constructTarget(targetMem, bufferPtr);
+
+ // Restore the range
+ range = *((uint16 *)bufferPtr);
+ bufferPtr = (uint16 *)bufferPtr + 1;
+
+ // Restore the flags
+ flags = *((uint8 *)bufferPtr);
+ bufferPtr = (uint8 *)bufferPtr + 1;
+
+ *buf = bufferPtr;
+}
+
+//----------------------------------------------------------------------
+// Return the number of bytes need to archive the data in this
+// assignment
+
+inline int32 HuntToBeNearActorAssignment::archiveSize(void) const {
+ return ActorAssignment::archiveSize()
+ + targetArchiveSize(getTarget())
+ + sizeof(range)
+ + sizeof(flags);
+}
+
+//----------------------------------------------------------------------
+// Write the data from this assignment object to a buffer in order
+// to save it on disk
+
+void *HuntToBeNearActorAssignment::archive(void *buf) const {
+ // Let the base class archive its data
+ buf = ActorAssignment::archive(buf);
+
+ // Store the target
+ buf = archiveTarget(getTarget(), buf);
+
+ // Store the range
+ *((uint16 *)buf) = range;
+ buf = (uint16 *)buf + 1;
+
+ // Store the flags
+ *((uint8 *)buf) = flags;
+ buf = (uint8 *)buf + 1;
+
+ return buf;
+}
+
+//----------------------------------------------------------------------
+// Return an integer representing the class of this object for archival
+// reasons.
+
+int16 HuntToBeNearActorAssignment::type(void) const {
+ return huntToBeNearActorAssignment;
+}
+
+//----------------------------------------------------------------------
+// Determine if this assignment needs to create a task at this time
+
+bool HuntToBeNearActorAssignment::taskNeeded(void) {
+ Actor *a = getActor();
+ TilePoint actorLoc = a->getLocation(),
+ targetLoc = getTarget()->where(a->world(), actorLoc);
+
+ return !a->inRange(targetLoc, range)
+ || a->inRange(targetLoc, HuntToBeNearActorTask::tooClose);
+}
+
+//----------------------------------------------------------------------
+// Construct a Task for this assignment
+
+Task *HuntToBeNearActorAssignment::getTask(TaskStack *ts) {
+ return NEW_TASK HuntToBeNearActorTask(
+ ts,
+ *getTarget(),
+ range,
+ (flags & track) != FALSE);
+}
+
+/* ===================================================================== *
+ HuntToKillAssignment member functions
+ * ===================================================================== */
+
+//----------------------------------------------------------------------
+// An initialization function which provides a common ground for the
+// initial constructors.
+
+void HuntToKillAssignment::initialize(
+ const ActorTarget &at,
+ bool trackFlag,
+ bool specificActorFlag) {
+ ASSERT(at.size() <= sizeof(targetMem));
+
+ // Copy the target
+ at.clone(targetMem);
+
+ flags = (trackFlag ? track : 0)
+ | (specificActorFlag ? specificActor : 0);
+}
+
+//----------------------------------------------------------------------
+// Constructor -- constructs from archive buffer
+
+HuntToKillAssignment::HuntToKillAssignment(void **buf) :
+ ActorAssignment(buf) {
+ void *bufferPtr = *buf;
+
+ // Restore the target
+ bufferPtr = constructTarget(targetMem, bufferPtr);
+
+ // Restore the flags
+ flags = *((uint8 *)bufferPtr);
+ bufferPtr = (uint8 *)bufferPtr + 1;
+
+ *buf = bufferPtr;
+}
+
+//----------------------------------------------------------------------
+// Return the number of bytes need to archive the data in this
+// assignment
+
+inline int32 HuntToKillAssignment::archiveSize(void) const {
+ return ActorAssignment::archiveSize()
+ + targetArchiveSize(getTarget())
+ + sizeof(flags);
+}
+
+//----------------------------------------------------------------------
+// Write the data from this assignment object to a buffer in order
+// to save it on disk
+
+void *HuntToKillAssignment::archive(void *buf) const {
+ // Let the base class archive its data
+ buf = ActorAssignment::archive(buf);
+
+ // Store the target
+ buf = archiveTarget(getTarget(), buf);
+
+ // Store the flags
+ *((uint8 *)buf) = flags;
+ buf = (uint8 *)buf + 1;
+
+ return buf;
+}
+
+//----------------------------------------------------------------------
+// Determine if this assignment is still valid
+
+bool HuntToKillAssignment::isValid(void) {
+ // If the target actor is already dead, then this is not a valid
+ // assignment
+ if (flags & specificActor) {
+ SpecificActorTarget *sat = (SpecificActorTarget *)getTarget();
+
+ if (sat->getTargetActor()->isDead()) return FALSE;
+ }
+
+ // Otherwise, determine if the base class thinks this is a valid
+ // assignment
+ return ActorAssignment::isValid();
+}
+
+//----------------------------------------------------------------------
+// Return an integer representing the class of this object for archival
+// reasons.
+
+int16 HuntToKillAssignment::type(void) const {
+ return huntToKillAssignment;
+}
+
+//----------------------------------------------------------------------
+// Determine if this assignment needs to create a task at this time
+
+bool HuntToKillAssignment::taskNeeded(void) {
+ // If we're hunting a specific actor, we only need a task if that
+ // actor is still alive.
+ if (flags & specificActor) {
+ SpecificActorTarget *sat = (SpecificActorTarget *)getTarget();
+
+ return !sat->getTargetActor()->isDead();
+ }
+
+ // Otherwise, we'll always want to create a task
+ return TRUE;
+}
+
+//----------------------------------------------------------------------
+// Construct a Task for this assignment
+
+Task *HuntToKillAssignment::getTask(TaskStack *ts) {
+ return NEW_TASK HuntToKillTask(
+ ts,
+ *getTarget(),
+ (flags & track) != FALSE);
+}
+
+/* ===================================================================== *
+ TetheredAssignment member functions
+ * ===================================================================== */
+
+//----------------------------------------------------------------------
+// Constructor -- constructs from archive buffer
+
+TetheredAssignment::TetheredAssignment(void **buf) : ActorAssignment(buf) {
+ int16 *a = (int16 *)*buf;
+
+ // Read data from buffer
+ minU = *a++;
+ minV = *a++;
+ maxU = *a++;
+ maxV = *a++;
+
+ *buf = a;
+}
+
+//----------------------------------------------------------------------
+// Return the number of bytes need to archive the data in this
+// assignment
+
+inline int32 TetheredAssignment::archiveSize(void) const {
+ return ActorAssignment::archiveSize()
+ + sizeof(minU)
+ + sizeof(minV)
+ + sizeof(maxU)
+ + sizeof(maxV);
+}
+
+//----------------------------------------------------------------------
+// Write the data from this assignment object to a buffer in order
+// to save it on disk
+
+void *TetheredAssignment::archive(void *buf) const {
+ // Let the base class archive its data
+ buf = ActorAssignment::archive(buf);
+
+ int16 *a = (int16 *)buf;
+
+ // Copy data to buffer
+ *a++ = minU;
+ *a++ = minV;
+ *a++ = maxU;
+ *a++ = maxV;
+
+ return a;
+}
+
+/* ===================================================================== *
+ TetheredWanderAssignment member functions
+ * ===================================================================== */
+
+//----------------------------------------------------------------------
+// Constructor -- initial assignment construction
+
+TetheredWanderAssignment::TetheredWanderAssignment(
+ uint16 until,
+ const TileRegion ®) :
+ TetheredAssignment(until, reg) {
+}
+
+//----------------------------------------------------------------------
+// Return an integer representing the class of this object for archival
+// reasons.
+
+int16 TetheredWanderAssignment::type(void) const {
+ return tetheredWanderAssignment;
+}
+
+//----------------------------------------------------------------------
+// Construct a Task for this assignment
+
+Task *TetheredWanderAssignment::getTask(TaskStack *ts) {
+ return NEW_TASK TetheredWanderTask(ts, minU, minV, maxU, maxV);
+}
+
+/* ===================================================================== *
+ AttendAssignment member functions
+ * ===================================================================== */
+
+//----------------------------------------------------------------------
+// Constructor -- initial assignment construction
+
+AttendAssignment::AttendAssignment(uint16 until, GameObject *o) :
+ ActorAssignment(until),
+ obj(o) {
+}
+
+//----------------------------------------------------------------------
+// Constructor -- constructs from archive buffer
+
+AttendAssignment::AttendAssignment(void **buf) : ActorAssignment(buf) {
+ ObjectID *bufferPtr = (ObjectID *)*buf;
+ ObjectID objID;
+
+ // Get the object ID
+ objID = *bufferPtr++;
+
+ // Convert the object ID to an object pointer
+ obj = objID != Nothing ? GameObject::objectAddress(objID) : NULL;
+
+ *buf = bufferPtr;
+}
+
+//----------------------------------------------------------------------
+// Return the number of bytes need to archive the data in this
+// assignment
+
+inline int32 AttendAssignment::archiveSize(void) const {
+ return ActorAssignment::archiveSize()
+ + sizeof(ObjectID);
+}
+
+//----------------------------------------------------------------------
+// Write the data from this assignment object to a buffer in order
+// to save it on disk
+
+void *AttendAssignment::archive(void *buf) const {
+ // Let the base class write its data to the buffer
+ buf = ActorAssignment::archive(buf);
+
+ ObjectID objID;
+
+ // Convert the object pointer to an object ID
+ objID = obj != NULL ? obj->thisID() : Nothing;
+
+ // Store the object ID
+ *((ObjectID *)buf) = objID;
+
+ return (ObjectID *)buf + 1;
+}
+
+//----------------------------------------------------------------------
+// Return an integer representing the class of this object for archival
+// reasons.
+
+int16 AttendAssignment::type(void) const {
+ return attendAssignment;
+}
+
+//----------------------------------------------------------------------
+// Construct a Task for this assignment
+
+Task *AttendAssignment::getTask(TaskStack *ts) {
+ return NEW_TASK AttendTask(ts, obj);
+}
+
+/* ===================================================================== *
+ Misc functions
+ * ===================================================================== */
+
+//----------------------------------------------------------------------
+// Reconstruct the ActorAssignment object from the archive buffer
+
+void *constructAssignment(Actor *a, void *buf) {
+ // Get the type which is the first word in the archive buffer
+ int16 type = *((int16 *)buf);
+
+ buf = (int16 *)buf + 1;
+
+ // Based upon the type, call the correct constructor
+ switch (type) {
+ case patrolRouteAssignment:
+ new (a) PatrolRouteAssignment(&buf);
+ break;
+
+ case huntToBeNearActorAssignment:
+ new (a) HuntToBeNearActorAssignment(&buf);
+ break;
+
+ case huntToBeNearLocationAssignment:
+ new (a) HuntToBeNearLocationAssignment(&buf);
+ break;
+
+ case tetheredWanderAssignment:
+ new (a) TetheredWanderAssignment(&buf);
+ break;
+
+ case attendAssignment:
+ new (a) AttendAssignment(&buf);
+ break;
+ }
+
+ return buf;
+}
+
+//----------------------------------------------------------------------
+// Return the number of bytes necessary to archive this actor's
+// assignment in an archive buffer
+
+int32 assignmentArchiveSize(Actor *a) {
+ ActorAssignment *assign = a->getAssignment();
+
+ return assign != NULL ? sizeof(int16) + assign->archiveSize() : 0;
+}
+
+//----------------------------------------------------------------------
+// Write the specified actor's assignment to an archive buffer
+
+void *archiveAssignment(Actor *a, void *buf) {
+ ActorAssignment *assign = a->getAssignment();
+
+ if (assign != NULL) {
+ // Store the type in the buffer and increment the pointer
+ *((int16 *)buf) = assign->type();
+ buf = (int16 *)buf + 1;
+
+ // Have the assignment archive itself in the buffer
+ buf = assign->archive(buf);
+ }
+
+ return buf;
+}
+
+}
diff --git a/engines/saga2/assign.h b/engines/saga2/assign.h
new file mode 100644
index 0000000000..cc11a0275d
--- /dev/null
+++ b/engines/saga2/assign.h
@@ -0,0 +1,514 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Based on the original sources
+ * Faery Tale II -- The Halls of the Dead
+ * (c) 1993-1996 The Wyrmkeep Entertainment Co.
+ */
+
+#ifndef SAGA2_ASSIGN_H
+#define SAGA2_ASSIGN_H
+
+/* ===================================================================== *
+ Includes
+ * ===================================================================== */
+
+#include "saga2/actor.h"
+#include "saga2/task.h"
+#include "saga2/calender.h"
+
+namespace Saga2 {
+
+/* ===================================================================== *
+ Constants
+ * ===================================================================== */
+
+const uint16 indefinitely = CalenderTime::framesPerDay;
+
+// Constants representing the non-virtual ActorAssignment classes
+enum AssignmentTypes {
+ patrolRouteAssignment,
+ huntToBeNearLocationAssignment,
+ huntToBeNearActorAssignment,
+ huntToKillAssignment,
+ tetheredWanderAssignment,
+ attendAssignment,
+};
+
+/* ===================================================================== *
+ ActorAssignment class
+ * ===================================================================== */
+
+class ActorAssignment {
+ uint16 startFrame, // Time in day when this was constructed
+ endFrame; // End time of the assignment
+
+public:
+ // Constructor
+ ActorAssignment(uint16 until) :
+ startFrame(calender.frameInDay()),
+ endFrame(until) {
+ }
+
+ // Constructor -- reconstruct from archive buffer
+ ActorAssignment(void **buf);
+
+ // Destructor
+ virtual ~ActorAssignment(void);
+
+ // Return the number of bytes need to archive the data in this
+ // assignment
+ virtual int32 archiveSize(void) const;
+
+ // Write the data from this assignment object to a buffer in order
+ // to save it on disk
+ virtual void *archive(void *buf) const;
+
+ // Allocate memory embedded in the Actor structure
+ void *operator new (size_t, Actor *a);
+
+ // Deallocate memory from the Actor structure
+ void operator delete (void *p);
+
+ // Construct a TaskStack for this assignment
+ TaskStack *createTask(void);
+
+ // This function is called to notify the assignment of the
+ // completion of a task which the assignment had created.
+ virtual void handleTaskCompletion(TaskResult result);
+
+ // Determine if assignment's time limit is up
+ virtual bool isValid(void);
+
+ // Return a pointer to the actor to which this assignment belongs
+ Actor *getActor(void) const {
+ // FIXME: This is utterly evil
+ warning("getActor(): dangerous pointer arithmetic, this will not work");
+ return (Actor *)(this - offsetof(Actor, assignmentBuf));
+ }
+
+ // Return an integer representing the class of this assignment
+ virtual int16 type(void) const = 0;
+
+protected:
+ void startTask(void);
+
+ // Determine if this assignment needs to create a task at this time
+ virtual bool taskNeeded(void);
+
+ // Create a Task for this assignment
+ virtual Task *getTask(TaskStack *ts) = 0;
+};
+
+/* ===================================================================== *
+ PatrolRouteAssignment class
+ * ===================================================================== */
+
+class PatrolRouteAssignment : public ActorAssignment {
+ int16 routeNo, // Patrol route number
+ startingWayPoint, // Way point at which to start (-1 = default)
+ endingWayPoint; // Way point at which to end (-1 = default)
+ uint8 routeFlags, // Flags indicating how patrol route should
+ // be followed
+ flags; // Flags representing the state of this
+ // assignment
+
+ enum {
+ routeCompleted = (1 << 0),
+ };
+
+public:
+ // Constructor -- initial object construction
+ PatrolRouteAssignment(
+ uint16 until,
+ int16 rteNo,
+ uint8 patrolFlags,
+ int16 start = -1,
+ int16 end = -1);
+
+ // Constructor -- constructs from archive buffer
+ PatrolRouteAssignment(void **buf);
+
+ // Return the number of bytes need to archive the data in this
+ // assignment
+ int32 archiveSize(void) const;
+
+ // Write the data from this assignment object to a buffer in order
+ // to save it on disk
+ void *archive(void *buf) const;
+
+ // Return an integer representing the type of this assignment
+ int16 type(void) const;
+
+ // This function is called to notify the assignment of the
+ // completion of a task which the assignment had created.
+ void handleTaskCompletion(TaskResult result);
+
+ // Determine if assignment is still valid
+ bool isValid(void);
+
+protected:
+ // Determine if this assignment needs to create a task at this time
+ bool taskNeeded(void);
+
+ // Construct a Task for this assignment
+ Task *getTask(TaskStack *ts);
+};
+
+/* ===================================================================== *
+ HuntToBeNearLocationAssignment class
+ * ===================================================================== */
+
+class HuntToBeNearLocationAssignment : public ActorAssignment {
+ TargetPlaceHolder targetMem;
+ uint16 range;
+
+ // An initialization function which provides a common ground for
+ // the initial constructors.
+ void initialize(const Target &targ, uint16 r);
+
+public:
+ // Constructors -- initial assignment construction
+
+ // Construct with no time limit and a specific TilePoint
+ HuntToBeNearLocationAssignment(const TilePoint &tp, uint16 r) :
+ ActorAssignment(indefinitely) {
+ initialize(LocationTarget(tp), r);
+ }
+
+ // Construct with time limit and a specific TilePoint
+ HuntToBeNearLocationAssignment(
+ uint16 until,
+ const TilePoint &tp,
+ uint16 r) :
+ ActorAssignment(until) {
+ initialize(LocationTarget(tp), r);
+ }
+
+ // Construct with no time limit and an abstract target
+ HuntToBeNearLocationAssignment(const Target &targ, uint16 r) :
+ ActorAssignment(indefinitely) {
+ initialize(targ, r);
+ }
+
+ // Construct with time limit and an abstract target
+ HuntToBeNearLocationAssignment(
+ uint16 until,
+ const Target &targ,
+ uint16 r) :
+ ActorAssignment(until) {
+ initialize(targ, r);
+ }
+
+
+ // Constructor -- constructs from archive buffer
+ HuntToBeNearLocationAssignment(void **buf);
+
+ // Return the number of bytes need to archive the data in this
+ // assignment
+ int32 archiveSize(void) const;
+
+ // Write the data from this assignment object to a buffer in order
+ // to save it on disk
+ void *archive(void *buf) const;
+
+ int16 type(void) const;
+
+protected:
+ bool taskNeeded(void);
+
+ Task *getTask(TaskStack *ts);
+
+ Target *getTarget(void) const {
+ return (Target *)targetMem;
+ }
+};
+
+/* ===================================================================== *
+ HuntToBeNearActorAssignment class
+ * ===================================================================== */
+
+class HuntToBeNearActorAssignment : public ActorAssignment {
+ TargetPlaceHolder targetMem;
+ uint16 range;
+ uint8 flags;
+
+ enum {
+ track = (1 << 0), // This hunt is a track.
+ };
+
+ // An initialization function which provides a common ground for
+ // the initial constructors.
+ void initialize(
+ const ActorTarget &at,
+ uint16 r,
+ bool trackFlag);
+
+public:
+ // Constructors -- initial assignment construction
+
+ // Construct with no time limit and specific actor
+ HuntToBeNearActorAssignment(
+ Actor *a,
+ uint16 r,
+ bool trackFlag = FALSE) :
+ ActorAssignment(indefinitely) {
+ ASSERT(isActor(a) && a != getActor());
+ initialize(SpecificActorTarget(a), r, trackFlag);
+ }
+
+ // Construct with time limit and specific actor
+ HuntToBeNearActorAssignment(
+ uint16 until,
+ Actor *a,
+ uint16 r,
+ bool trackFlag = FALSE) :
+ ActorAssignment(until) {
+ ASSERT(isActor(a) && a != getActor());
+ initialize(SpecificActorTarget(a), r, trackFlag);
+ }
+
+ // Construct with no time limit and abstract actor target
+ HuntToBeNearActorAssignment(
+ const ActorTarget &at,
+ uint16 r,
+ bool trackFlag = FALSE) :
+ ActorAssignment(indefinitely) {
+ initialize(at, r, trackFlag);
+ }
+
+ // Construct with time limit and abstract actor target
+ HuntToBeNearActorAssignment(
+ uint16 until,
+ const ActorTarget &at,
+ uint16 r,
+ bool trackFlag = FALSE) :
+ ActorAssignment(until) {
+ initialize(at, r, trackFlag);
+ }
+
+ // Constructor -- reconstructs from archive buffer
+ HuntToBeNearActorAssignment(void **buf);
+
+ // Return the number of bytes need to archive the data in this
+ // assignment
+ int32 archiveSize(void) const;
+
+ // Write the data from this assignment object to a buffer in order
+ // to save it on disk
+ void *archive(void *buf) const;
+
+ int16 type(void) const;
+
+protected:
+ bool taskNeeded(void);
+
+ Task *getTask(TaskStack *ts);
+
+ ActorTarget *getTarget(void) const {
+ return (ActorTarget *)targetMem;
+ }
+};
+
+/* ===================================================================== *
+ HuntToKillAssignment class
+ * ===================================================================== */
+
+class HuntToKillAssignment : public ActorAssignment {
+ TargetPlaceHolder targetMem;
+ uint8 flags;
+
+ enum {
+ track = (1 << 0), // This hunt is a track.
+ specificActor = (1 << 1), // The actor target is a specific actor
+ };
+
+ // An initialization function which provides a common ground for
+ // the initial constructors.
+ void initialize(
+ const ActorTarget &at,
+ bool trackFlag,
+ bool specificActorFlag);
+
+public:
+ // Constructors -- initial assignment construction
+
+ // Construct with no time limit and specific actor
+ HuntToKillAssignment(Actor *a, bool trackFlag = FALSE) :
+ ActorAssignment(indefinitely) {
+ ASSERT(isActor(a) && a != getActor());
+ initialize(SpecificActorTarget(a), trackFlag, TRUE);
+ }
+
+ // Construct with time limit and specific actor
+ HuntToKillAssignment(
+ uint16 until,
+ Actor *a,
+ bool trackFlag = FALSE) :
+ ActorAssignment(until) {
+ ASSERT(isActor(a) && a != getActor());
+ initialize(SpecificActorTarget(a), trackFlag, TRUE);
+ }
+
+ // Construct with no time limit and abstract actor target
+ HuntToKillAssignment(
+ const ActorTarget &at,
+ bool trackFlag = FALSE) :
+ ActorAssignment(indefinitely) {
+ initialize(at, trackFlag, FALSE);
+ }
+
+ // Construct with time limit and abstract actor target
+ HuntToKillAssignment(
+ uint16 until,
+ const ActorTarget &at,
+ bool trackFlag = FALSE) :
+ ActorAssignment(until) {
+ initialize(at, trackFlag, FALSE);
+ }
+
+ // Constructor -- reconstructs from archive buffer
+ HuntToKillAssignment(void **buf);
+
+ // Return the number of bytes need to archive the data in this
+ // assignment
+ int32 archiveSize(void) const;
+
+ // Write the data from this assignment object to a buffer in order
+ // to save it on disk
+ void *archive(void *buf) const;
+
+ // Determine if assignment's time limit is up or if the actor is
+ // already dead
+ bool isValid(void);
+
+ int16 type(void) const;
+
+protected:
+ bool taskNeeded(void);
+
+ Task *getTask(TaskStack *ts);
+
+ ActorTarget *getTarget(void) const {
+ return (ActorTarget *)targetMem;
+ }
+};
+
+/* ===================================================================== *
+ TetheredAssignment class
+ * ===================================================================== */
+
+class TetheredAssignment : public ActorAssignment {
+protected:
+ // Tether region
+ int16 minU, // Minimum U coordinate in tether
+ minV, // Minimum V coordinate in tether
+ maxU, // Maximum U coordinate in tether
+ maxV; // Maximum V coordinate in tether
+
+public:
+ // Constructor -- initial assignment construction
+ TetheredAssignment(uint16 until, const TileRegion ®) :
+ ActorAssignment(until),
+ minU(reg.min.u),
+ minV(reg.min.v),
+ maxU(reg.max.u),
+ maxV(reg.max.v) {
+ }
+
+ TetheredAssignment(void **buf);
+
+ // Return the number of bytes need to archive the data in this
+ // assignment
+ int32 archiveSize(void) const;
+
+ // Write the data from this assignment object to a buffer in order
+ // to save it on disk
+ void *archive(void *buf) const;
+};
+
+/* ===================================================================== *
+ TetheredWanderAssignment class
+ * ===================================================================== */
+
+class TetheredWanderAssignment : public TetheredAssignment {
+public:
+ // Constructor -- initial assignment construction
+ TetheredWanderAssignment(uint16 until, const TileRegion ®);
+
+ // Constructor -- constructs from archive buffer
+ TetheredWanderAssignment(void **buf) : TetheredAssignment(buf) {}
+
+ // Return an integer representing the type of this assignment
+ int16 type(void) const;
+
+protected:
+ // Construct a Task for this assignment
+ Task *getTask(TaskStack *ts);
+};
+
+/* ===================================================================== *
+ AttendAssignment class
+ * ===================================================================== */
+
+class AttendAssignment : public ActorAssignment {
+ GameObject *obj; // Object to which to attend
+
+public:
+ // Constructor -- initial assignment construction
+ AttendAssignment(uint16 until, GameObject *o);
+
+ // Constructor -- constructs from archive buffer
+ AttendAssignment(void **buf);
+
+ // Return the number of bytes need to archive the data in this
+ // assignment
+ int32 archiveSize(void) const;
+
+ // Write the data from this assignment object to a buffer in order
+ // to save it on disk
+ void *archive(void *buf) const;
+
+ // Return an integer representing the type of this assignment
+ int16 type(void) const;
+
+protected:
+ // Construct a Task for this assignment
+ Task *getTask(TaskStack *ts);
+};
+
+/* ===================================================================== *
+ Prototypes
+ * ===================================================================== */
+
+// Reconstruct the ActorAssignment object from the archive buffer
+void *constructAssignment(Actor *a, void *buf);
+
+// Return the number of bytes necessary to archive this actor's
+// assignment in an archive buffer
+int32 assignmentArchiveSize(Actor *a);
+
+// Write the specified actor's assignment to an archive buffer
+void *archiveAssignment(Actor *a, void *buf);
+
+}
+
+#endif
diff --git a/engines/saga2/audio.cpp b/engines/saga2/audio.cpp
new file mode 100644
index 0000000000..a7a385b8cd
--- /dev/null
+++ b/engines/saga2/audio.cpp
@@ -0,0 +1,186 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Based on the original sources
+ * Faery Tale II -- The Halls of the Dead
+ * (c) 1993-1996 The Wyrmkeep Entertainment Co.
+ */
+
+#include "saga2/std.h"
+#include "saga2/audio.h"
+
+namespace Saga2 {
+
+void *audioAlloc(size_t s, char desc[])
+{
+ warning("STUB: audioAlloc()");
+ return nullptr;
+ //return malloc(s);
+}
+
+void audioFree(void *mem)
+{
+ warning("STUB: audioFree()");
+ //delete mem;
+}
+
+audioInterface *audio;
+
+audioInterface::audioInterface(const char *driver_path, const char *undriver_path) {
+ warning("STUB: audioInteraface::audioInterface()");
+}
+
+audioInterface::~audioInterface() {
+ warning("STUB: audioInteraface::~audioInterface()");
+}
+
+void audioInterface::initAudioInterface(audioInterfaceSettings &ais) {
+ warning("STUB: audioInterface::initAudioInterface()");
+}
+
+void audioInterface::cleanupAudioInterface(void) {
+ warning("STUB: audioInterface::cleanupAudioInterface()");
+}
+
+void audioInterface::suspendGameClock(void) {
+ warning("STUB: audioInterace::suspendGameClock()");
+}
+void audioInterface::resumeGameClock(void) {
+ warning("STUB: audioInterface::resumeGameClock()");
+}
+
+bool audioInterface::playFlag(void) {
+ warning("STUB: audioInterface::playFlag()");
+}
+void audioInterface::playMe(void) {
+ warning("STUB: audioInterface::PlayMe()");
+}
+void audioInterface::queueMusic(soundSegment s, decoderSet *, int16 loopFactor, sampleLocation where) {
+ warning("STUB: audioInterface::queueMusic()");
+}
+void audioInterface::stopMusic(void) {
+ warning("STUB: audioInterface::stopMusic()");
+}
+bool audioInterface::goodMIDICard(void) {
+ warning("STUB: audioInterface::goodMIDICard()");
+ return false;
+}
+
+void audioInterface::queueSound(soundSegment s, decoderSet *, int16 loopFactor, sampleLocation where) {
+ warning("STUB: audioInterface::queueSound()");
+}
+void audioInterface::queueLoop(soundSegment s, decoderSet *sDec, int16 loopFactor, sampleLocation where) {
+ warning("STUB: audioInterface::queueLoop()");
+}
+void audioInterface::stopLoop(void) {
+ warning("STUB: audioInterface::stopLoop()");
+}
+void audioInterface::setLoopPosition(sampleLocation newLoc) {
+ warning("STUB: audioInterface::setLoopPosition()");
+}
+
+void audioInterface::queueVoice(soundSegment s, decoderSet *, sampleLocation where) {
+ warning("STUB: audioInterface::queueVoice(soundSegment, decoderSet *, sampleLocation)");
+}
+void audioInterface::queueVoice(soundSegment s[], decoderSet *, sampleLocation where) {
+ warning("STUB: audioInterface::queueVoice(soundSegment [], decoderSet *, sampleLocation)");
+}
+void audioInterface::stopVoice(void) {
+ warning("STUB: audioInterface::stopVoice()");
+}
+bool audioInterface::talking(void) {
+ warning("STUB: audioInterface::talking()");
+ return false;
+}
+bool audioInterface::saying(soundSegment s) {
+ warning("STUB: audioInterface::saying()");
+ return false;
+}
+
+bool audioInterface::active(void) {
+ warning("STUB: audioInterface::active()");
+ return false;
+}
+void audioInterface::enable(volumeTarget i, bool onOff) {
+ warning("STUB: audioInterface::enable()");
+}
+void audioInterface::setVolume(volumeTarget targ, volumeMode op, Volume val) {
+ warning("STUB: audioInterface::setVolume()");
+}
+Volume audioInterface::getVolume(volumeTarget src) {
+ warning("STUB: audioInterface::getVolume()");
+ return 0;
+}
+void audioInterface::setMusicFadeStyle(int16 tOut, int16 tIn, int16 tOver) {
+ warning("STUB: audioInterface::setMusicFadeStyle()");
+}
+void audioInterface::suspend(void) {
+ warning("STUB: audioInterface::suspend()");
+}
+void audioInterface::resume(void) {
+ warning("STUB: audioInterface::resume()");
+}
+
+audioAttenuationFunction audioInterface::setAttenuator(audioAttenuationFunction newAF) {
+ warning("STUB: audioInterface::setAttenuator()");
+ return nullptr;
+}
+
+soundDecoder::soundDecoder() {
+ warning("STUB: soundDecoder::soundDecoder()");
+}
+
+soundDecoder::~soundDecoder() {
+ warning("STUB: soundDecoder::~soundDecoder()");
+}
+
+soundDecoder::soundDecoder(INPLACEDECODER *, INPLACEDECODER *, INPLACEDECODER *) {
+ warning("STUB: soundDecoder::soundDecoder(INPLACEDECODER *, INPLACEDECODER *, INPLACEDECODER *)");
+}
+
+soundDecoder::soundDecoder(BUFFERDECODER *, BUFFERDECODER *, BUFFERDECODER *, int16, audioInterface *, int16) {
+ warning("STUB: soundDecoder::soundDecoder(BUFFERDECODER *, BUFFERDECODER *, BUFFERDECODER *, int16, audioInterface *, int16)");
+}
+
+soundDecoder::soundDecoder(BUFFERLOADER *, BUFFERLOADER *, BUFFERLOADER *) {
+ warning("STUB: soundDecoder::soundDecoder(BUFFERLOADER *, BUFFERLOADER *, BUFFERLOADER *)");
+}
+
+void decoderSet::addDecoder(soundDecoder *sodec) {
+ warning("STUB: soundDecoder::addDecoder()");
+}
+
+BUFFERDEC(flushDecompress) {
+ warning("STUB: flushDecompress()");
+ return 0;
+}
+
+BUFFERDEC(seekDecompress) {
+ warning("STUB: seekDecompress()");
+ return 0;
+}
+
+BUFFERDEC(readDecompress) {
+ warning("STUB: readDecompress()");
+ return 0;
+}
+
+} // end of namespace Saga2
diff --git a/engines/saga2/audio.h b/engines/saga2/audio.h
new file mode 100644
index 0000000000..dc40e19515
--- /dev/null
+++ b/engines/saga2/audio.h
@@ -0,0 +1,89 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * aint32 with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Based on the original sources
+ * Faery Tale II -- The Halls of the Dead
+ * (c) 1993-1996 The Wyrmkeep Entertainment Co.
+ */
+
+#ifndef SAGA2_AUDIO_H
+#define SAGA2_AUDIO_H
+
+/* ===================================================================== *
+ the library(s) must be recompiled if you change these settings
+ * ===================================================================== */
+
+#define DEBUG_AUDIO 2
+#define STATUS_MESSAGES DEBUG
+#define QUEUES_EXTERNAL_ALLOCATION 1
+#define USE_REAL_WAIL 1
+
+// TODO: FIXME. STUB
+typedef int HDIGDRIVER;
+typedef int HTIMER;
+typedef int HMDIDRIVER;
+typedef int HSAMPLE;
+typedef int HSEQUENCE;
+
+// AIL stubs
+#define SMP_DONE 0x0002
+#define SMP_STOPPED 0x0008
+
+void AIL_init_sample(HSAMPLE S);
+HSAMPLE AIL_allocate_sample_handle(HDIGDRIVER dig);
+void AIL_release_sample_handle(HSAMPLE S);
+HSEQUENCE AIL_allocate_sequence_handle(HMDIDRIVER mdi);
+void AIL_end_sample(HSAMPLE S);
+void AIL_set_sample_type(HSAMPLE S, int32 format, uint32 flags);
+uint32 AIL_sample_status(HSAMPLE S);
+void AIL_set_sample_address(HSAMPLE S, void *start, uint32 len);
+int32 AIL_sample_buffer_ready(HSAMPLE S);
+void AIL_end_sequence(HSEQUENCE S);
+void AIL_load_sample_buffer(HSAMPLE S, uint32 buff_num, void *buffer, uint32 len);
+void AIL_start_sample(HSAMPLE S);
+uint32 AIL_sequence_status(HSEQUENCE S);
+void AIL_set_sample_loop_count (HSAMPLE S, int32 loop_count);
+void AIL_set_sequence_loop_count(HSEQUENCE S, int32 loop_count);
+void AIL_start_sequence(HSEQUENCE S);
+void AIL_set_sample_volume(HSAMPLE S, int32 volume);
+void AIL_set_sample_playback_rate(HSAMPLE S, int32 playback_rate);
+void AIL_lock(void);
+void AIL_unlock(void);
+void AIL_release_sequence_handle(HSEQUENCE S);
+int32 AIL_init_sequence(HSEQUENCE S, void *start, int32 sequence_num);
+int32 AIL_sample_volume(HSAMPLE S);
+int32 AIL_sequence_volume(HSEQUENCE S);
+void AIL_set_sequence_volume(HSEQUENCE S, int32 volume, int32 milliseconds);
+
+#include "saga2/rect.h"
+#include "saga2/errclass.h"
+#include "saga2/audiotmr.h"
+#include "saga2/audiomem.h"
+#include "saga2/audioerr.h"
+#include "saga2/queues.h"
+#include "saga2/audiobuf.h"
+#include "saga2/audiodec.h"
+#include "saga2/audiosmp.h"
+#include "saga2/audqueue.h"
+#include "saga2/audiosys.h"
+#include "saga2/audiofnc.h"
+
+#endif
diff --git a/engines/saga2/audiobuf.cpp b/engines/saga2/audiobuf.cpp
new file mode 100644
index 0000000000..5bd280ef11
--- /dev/null
+++ b/engines/saga2/audiobuf.cpp
@@ -0,0 +1,915 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Based on the original sources
+ * Faery Tale II -- The Halls of the Dead
+ * (c) 1993-1996 The Wyrmkeep Entertainment Co.
+ */
+
+#include "saga2/std.h"
+#include "saga2/audio.h"
+#include "saga2/audioerr.h"
+#include "saga2/errclass.h"
+
+namespace Saga2 {
+
+extern audioInterface *audio;
+
+/*******************************************************************/
+/* */
+/* Buffer Classes */
+/* Buffer : base class */
+/* workBuffer : temporary work buffer */
+/* soundBuffer : AIL double buffered sound */
+/* singleBuffer : AIL single buffered sound */
+/* musicBuffer : AIL XMIDI song */
+/* cacheBuffer : in memory storage */
+/* */
+/* Member functions */
+/* ctor, dtor : constructors & destructors */
+/* format : associate a particular audio format with a buffer */
+/* laden : determine whether the buffer can be written to */
+/* sample_status : returns play status of buffer */
+/* washed : cleans the buffer if it's available */
+/* gave : notify buffer that something was put into it */
+/* took : notify buffer that something was read from it */
+/* fill : tell buffer to consider itself full when it's not */
+/* play : called internally to play audio */
+/* activate : tell buffer it's being used */
+/* release : tell buffer its no longer in use */
+/* reset : forcibly clears the buffer */
+/* setVolume : sets the volume ( if appropriate ) of a buffer */
+/* */
+/*******************************************************************/
+
+Buffer::Buffer(size_t newSize) {
+ VERIFY(newSize > 0);
+
+ internallyAllocated = TRUE;
+ size = newSize;
+ data[0] = audioAlloc(newSize, "Audio data buffer"); //( void * ) new char[newSize];
+ audio_lock(data[0], size); //musicRes->size( s ));
+ data[1] = NULL;
+
+ wData = data[0];
+ wSize = size;
+ rData = data[0];
+ rSize = 0;
+}
+
+Buffer::~Buffer(void) {
+ if (internallyAllocated) {
+ VERIFY(data[0]);
+ audio_unlock(data[0], size);
+ audioFree(data[0]); //delete [] data[0];
+ data[0] = NULL;
+ }
+}
+
+/***********************************/
+
+workBuffer::workBuffer(size_t newSize, int16 newID)
+ : Buffer(newSize) {
+ bufID = newID;
+ fillBuffer = 0;
+ targetSated = FALSE;
+}
+
+workBuffer::~workBuffer(void) {
+}
+
+/***********************************/
+
+cacheBuffer::cacheBuffer(size_t newSize, int16 newID)
+ : Buffer(newSize) {
+ bufID = newID;
+ hasData = 0;
+}
+
+cacheBuffer::~cacheBuffer(void) {
+}
+
+/***********************************/
+
+
+doubleBuffer::doubleBuffer(size_t newSize, audioInterface *sd, int16 newID)
+ : Buffer(newSize) {
+ if (sd && sd->enabled(volVoice)) {
+ VERIFY(sd);
+ //VERIFY( sd->dig );
+
+ bufID = newID;
+ fillBuffer = 0;
+ targetPos = 0;
+ targetSated = FALSE;
+ ailSampleHandle = AIL_allocate_sample_handle(sd->dig);
+ if (ailSampleHandle == NULL)
+ audioFatal("Unable to allocate audio handle");
+ AIL_init_sample(ailSampleHandle);
+ AILLOCated = -1;
+ audioSet = 0;
+
+ data[1] = audioAlloc(newSize, "audio double buffer"); // ( void * ) new char[newSize];
+ audio_lock(data[1], newSize); //musicRes->size( s ));
+ //drain( 1 );
+ }
+}
+
+doubleBuffer::~doubleBuffer(void) {
+ VERIFY(ailSampleHandle);
+ if (data[1]) {
+ audio_unlock(data[1], size);
+ audioFree(data[1]); //delete [] data[1];
+ data[1] = NULL;
+ }
+ if (ailSampleHandle) {
+ AIL_release_sample_handle(ailSampleHandle);
+ }
+}
+
+
+/***********************************/
+
+
+singleBuffer::singleBuffer(size_t newSize, audioInterface *sd, int16 newID)
+ : Buffer(newSize) {
+ if (sd && sd->enabled(volSound)) {
+ VERIFY(sd);
+ VERIFY(sd->dig);
+
+ bufID = newID;
+ fillBuffer = 0;
+ targetSated = FALSE;
+ ailSampleHandle = AIL_allocate_sample_handle(sd->dig);
+ if (ailSampleHandle == NULL)
+ audioFatal("Unable to allocate audio handle");
+ AIL_init_sample(ailSampleHandle);
+ AILLOCated = -1;
+ audioSet = 0;
+ data[1] = NULL;
+ lastRSize = 0;
+ }
+}
+
+singleBuffer::~singleBuffer(void) {
+ VERIFY(ailSampleHandle);
+ if (ailSampleHandle) {
+ AIL_release_sample_handle(ailSampleHandle);
+ }
+}
+
+
+/***********************************/
+
+
+musicBuffer::musicBuffer(size_t newSize, audioInterface *sd, int16 newID)
+ : Buffer(newSize) {
+ if (sd && sd->enabled(volMusic)) {
+ VERIFY(sd);
+ VERIFY(sd->mid);
+
+ bufID = newID;
+ fillBuffer = 0;
+ targetSated = FALSE;
+ ailSampleHandle = AIL_allocate_sequence_handle(sd->mid);
+ if (ailSampleHandle == NULL)
+ audioFatal("Unable to allocate music handle");
+ data[1] = NULL;
+ audioSet = 0;
+ }
+}
+
+musicBuffer::~musicBuffer(void) {
+ VERIFY(ailSampleHandle);
+ if (ailSampleHandle) {
+ AIL_release_sequence_handle(ailSampleHandle);
+ }
+}
+
+
+/*******************************************************************/
+/* */
+/* This routine shifts the read buffer to the start of the buffer */
+/* as a whole. This creates room for writing. */
+
+void workBuffer::shiftdown(int16 bufNo) {
+ long dif = size - (wSize + rSize);
+
+ VERIFY(bufNo == 0);
+ VERIFY(dif >= 0);
+ VERIFY(dif <= (size - (rSize + wSize)));
+ VERIFY(((char *)(data[bufNo]) + rSize) < ((char *) rData));
+ VERIFY(dif > rSize);
+ VERIFY(dif > wSize);
+ VERIFY(data[bufNo]);
+ VERIFY(rData);
+
+ if (dif > 0 && rSize > 0) {
+ char *tbuf = (char *) audioAlloc(rSize, "audio work buffer"); //new char[rSize];
+ memcpy(tbuf, rData, rSize);
+ memcpy(data[bufNo], tbuf, rSize);
+ rData = data[bufNo];
+ wSize += dif;
+ wData = (void *)(((char *) data[bufNo]) + (size - wSize));
+ audioFree(tbuf);
+ }
+
+}
+
+/*******************************************************************/
+/* */
+/* Associate a particular audio format witha buffer */
+
+
+void Buffer::format(soundSample *) {
+}
+
+
+// work buffers could care less about format
+
+void workBuffer::format(soundSample *) {
+}
+
+// work buffers could care less about format
+
+void cacheBuffer::format(soundSample *) {
+
+}
+
+// sound buffers need to let AIL know about the formatting
+
+void doubleBuffer::format(soundSample *ss) {
+ if (audioSet == 0) {
+ VERIFY(ailSampleHandle);
+ AIL_init_sample(ailSampleHandle);
+ AIL_set_sample_type(ailSampleHandle, ss->format(), ss->flags());
+ AIL_set_sample_playback_rate(ailSampleHandle, ss->speed);
+ AIL_set_sample_volume(ailSampleHandle, ss->getVolume());
+ activate(washed());
+ targetPos = 0;
+ audioSet = 1;
+ }
+}
+
+void singleBuffer::format(soundSample *ss) {
+ VERIFY(ailSampleHandle);
+ AIL_init_sample(ailSampleHandle);
+ AIL_set_sample_type(ailSampleHandle, ss->format(), ss->flags());
+ AIL_set_sample_playback_rate(ailSampleHandle, ss->speed);
+ AIL_set_sample_volume(ailSampleHandle, ss->getVolume());
+ activate(washed());
+ audioSet = 1;
+}
+
+void musicBuffer::format(soundSample *) {
+}
+
+/*******************************************************************/
+/* */
+/* laden() determine whether a buffer can be written to. */
+
+bool Buffer::laden(void) {
+ if (-1 == washed()) return TRUE;
+ activate(0);
+ return FALSE;
+}
+
+// fairly trivial for work buffers
+
+bool workBuffer::laden(void) {
+ if (-1 == washed())
+ return TRUE;
+ activate(0);
+ return FALSE;
+}
+
+// sound buffers need to find out from AIL whether a buffer is free
+
+bool doubleBuffer::laden(void) {
+ VERIFY(ailSampleHandle);
+ if (-1 == washed())
+ return TRUE;
+ else if (targetSated)
+ activate(fillBuffer);
+ return (FALSE);
+}
+
+bool singleBuffer::laden(void) {
+ VERIFY(ailSampleHandle);
+ if (targetSated)
+ activate(0);
+ return (FALSE);
+}
+
+bool musicBuffer::laden(void) {
+ if (targetSated)
+ activate(0);
+ return (FALSE);
+}
+
+bool cacheBuffer::laden(void) {
+ if (-1 == washed())
+ return TRUE;
+ activate(0);
+ return FALSE;
+}
+
+
+/*******************************************************************/
+/* */
+/* sample_status - find out whats going on with abuffer */
+
+uint32 Buffer::sample_status(void) {
+ return (SMP_DONE);
+}
+
+uint32 workBuffer::sample_status(void) {
+ return (SMP_DONE);
+}
+
+
+uint32 doubleBuffer::sample_status(void) {
+ VERIFY(ailSampleHandle);
+#if 0
+ int32 newPos = AIL_sample_position(ailSampleHandle);
+ if (targetPos == 0 || newPos >= targetPos) { //( newPos==lastPos && lastPos==distPos)
+ return (SMP_DONE);
+ }
+ distPos = lastPos;
+ lastPos = newPos;
+#endif
+ return (AIL_sample_status(ailSampleHandle));
+}
+
+uint32 singleBuffer::sample_status(void) {
+ VERIFY(ailSampleHandle);
+ return (AIL_sample_status(ailSampleHandle));
+}
+
+uint32 musicBuffer::sample_status(void) {
+ return (AIL_sequence_status(ailSampleHandle));
+}
+
+uint32 cacheBuffer::sample_status(void) {
+ return (SMP_DONE);
+}
+
+/*******************************************************************/
+/* */
+/* washed() used internally to find a buffer with writeable */
+/* space left. */
+
+
+int16 Buffer::washed(void) {
+ if ((rSize + wSize) == 0) {
+ wSize = size;
+ wData = data[0];
+ rSize = 0;
+ rData = data[0];
+ return 0;
+ }
+ return 0;
+}
+
+int16 workBuffer::washed(void) {
+ if ((rSize + wSize) == 0) {
+ fillBuffer = 0;
+ wSize = size;
+ wData = data[fillBuffer];
+ rSize = 0;
+ rData = data[0];
+ return 0;
+ }
+ return 0;
+}
+
+int16 doubleBuffer::washed(void) {
+ VERIFY(ailSampleHandle);
+ if (AILLOCated > -1) return AILLOCated;
+ AILLOCated = AIL_sample_buffer_ready(ailSampleHandle);
+ return AILLOCated;
+}
+
+int16 singleBuffer::washed(void) {
+ return 0;
+}
+
+int16 musicBuffer::washed(void) {
+ return 0;
+}
+
+int16 cacheBuffer::washed(void) {
+ return 0;
+}
+
+
+/*******************************************************************/
+/* */
+/* gave() notifies a buffer that it has been written to */
+/* took() notifies a buffer that it has been read from */
+/* */
+
+void Buffer::gave(size_t dSize) {
+ VERIFY(dSize <= wSize);
+ wSize -= dSize;
+ rSize += dSize;
+ if (wSize)
+ wData = (void *)(((char *) data[0]) + (size - wSize));
+
+}
+
+void workBuffer::gave(size_t dSize) {
+ VERIFY(dSize <= wSize);
+ wSize -= dSize;
+ rSize += dSize;
+ if (wSize) {
+ wData = (void *)(((char *) data[fillBuffer]) + (size - wSize));
+ }
+
+}
+
+// when sound buffers get full they automatically trigger AIL
+
+void doubleBuffer::gave(size_t dSize) {
+ VERIFY(ailSampleHandle);
+ VERIFY(dSize <= wSize);
+ wSize -= dSize;
+ rSize += dSize;
+ if (wSize) {
+ wData = (void *)(((char *) data[fillBuffer]) + (size - wSize));
+ } else {
+ VERIFY(AILLOCated >= 0);
+ play(AILLOCated);
+ activate(1 - fillBuffer);
+ }
+}
+
+void singleBuffer::gave(size_t dSize) {
+ VERIFY(ailSampleHandle);
+ VERIFY(dSize <= wSize);
+ lastRSize = rSize;
+ wSize -= dSize;
+ rSize += dSize;
+ if (wSize) {
+ wData = (void *)(((char *) data[fillBuffer]) + (size - wSize));
+ } else {
+ play(0);
+ }
+}
+
+void musicBuffer::gave(size_t dSize) {
+ VERIFY(ailSampleHandle);
+ VERIFY(dSize <= wSize);
+ wSize -= dSize;
+ rSize += dSize;
+ if (wSize) {
+ wData = (void *)(((char *) data[fillBuffer]) + (size - wSize));
+ } else {
+ //fill( 0 )
+ //play( 0 );
+ }
+}
+
+void cacheBuffer::gave(size_t dSize) {
+ VERIFY(dSize <= wSize);
+ wSize -= dSize;
+ rSize += dSize;
+ if (wSize) {
+ wData = (void *)(((char *) data[0]) + (size - wSize));
+ }
+
+}
+
+// when work buffers get fully drained they reset themselves
+
+void Buffer::took(size_t dSize) {
+ VERIFY(dSize <= rSize);
+ rSize -= dSize;
+ if (rSize > 0)
+ rData = (void *)(((char *) rData) + dSize);
+ if (rSize + wSize == 0)
+ activate(0);
+}
+
+void workBuffer::took(size_t dSize) {
+ VERIFY(dSize <= rSize);
+ rSize -= dSize;
+ if (rSize > 0) {
+ rData = (void *)(((char *) rData) + dSize);
+ }
+ if (rSize + wSize == 0) {
+ activate(0);
+ }
+}
+
+void doubleBuffer::took(size_t dSize) {
+ VERIFY(dSize <= rSize);
+ rSize -= dSize;
+ if (rSize > 0)
+ rData = (void *)(((char *) rData) + dSize);
+}
+
+void singleBuffer::took(size_t dSize) {
+ VERIFY(dSize <= rSize);
+ lastRSize = rSize;
+ rSize -= dSize;
+ if (rSize > 0)
+ rData = (void *)(((char *) rData) + dSize);
+}
+
+void musicBuffer::took(size_t dSize) {
+ VERIFY(dSize <= rSize);
+ rSize -= dSize;
+ if (rSize > 0)
+ rData = (void *)(((char *) rData) + dSize);
+}
+
+void cacheBuffer::took(size_t dSize) {
+ VERIFY(dSize <= rSize);
+}
+
+/*******************************************************************/
+/* */
+/* fill() - notify the buffer that it should deal with */
+/* the current buffer data even though it is not a full buffer */
+
+void Buffer::fill(void) {
+ if (rSize) {
+ play(0);
+ activate(0);
+ }
+}
+
+// for work buffers flush any readable data and reset
+
+void workBuffer::fill(void) {
+ if (rSize) {
+ play(0);
+ activate(0);
+ }
+}
+
+// sound buffers pass what they have to AIL
+
+void doubleBuffer::fill(void) {
+ VERIFY(ailSampleHandle);
+ VERIFY(AILLOCated >= 0);
+ if (rSize) {
+ play(AILLOCated);
+ activate(1 - fillBuffer);
+ } else {
+ play(AILLOCated);
+ }
+}
+
+void singleBuffer::fill(void) {
+ VERIFY(ailSampleHandle);
+ if (rSize) {
+ play(0);
+ }
+}
+
+void musicBuffer::fill(void) {
+ VERIFY(ailSampleHandle);
+ play(0);
+}
+
+void cacheBuffer::fill(void) {
+ if (rSize) {
+ hasData = 1;
+ }
+}
+
+/*******************************************************************/
+/* */
+/* When a buffer is no longer needed this call resets it. */
+
+void Buffer::abort(void) {
+}
+
+void Buffer::release(void) {
+}
+
+void workBuffer::abort(void) {
+ if (rSize)
+ took(rSize);
+ release();
+}
+
+void workBuffer::release(void) {
+}
+
+void doubleBuffer::abort(void) {
+ if (rSize)
+ took(rSize);
+ release();
+ targetPos = 0;
+}
+
+void doubleBuffer::release(void) {
+ VERIFY(ailSampleHandle);
+ VERIFY(rSize == 0);
+
+ if (washed() <= -1) {
+ if (sample_status() != SMP_STOPPED)
+ AIL_end_sample(ailSampleHandle);
+ } else if (AILLOCated >= 0) {
+ AIL_load_sample_buffer(ailSampleHandle, AILLOCated, rData, rSize);
+ AILLOCated = -1;
+ }
+
+ AIL_end_sample(ailSampleHandle);
+ audioSet = 0;
+ audio->resetState((audioInterface::BufferRequest) ID());
+ VERIFY(AILLOCated == -1);
+}
+
+void singleBuffer::abort(void) {
+ AIL_end_sample(ailSampleHandle);
+ if (rSize)
+ took(rSize);
+ release();
+}
+
+void singleBuffer::release(void) {
+ VERIFY(ailSampleHandle);
+ VERIFY(rSize == 0);
+// AIL_end_sample( ailSampleHandle );
+ audioSet = 0;
+ VERIFY(AILLOCated == -1);
+}
+
+void musicBuffer::abort(void) {
+ if (rSize)
+ took(rSize);
+ release();
+}
+
+void musicBuffer::release(void) {
+ VERIFY(ailSampleHandle);
+// new
+ AIL_end_sequence(ailSampleHandle);
+ audioSet = 0;
+}
+
+void cacheBuffer::abort(void) {
+}
+
+void cacheBuffer::release(void) {
+}
+
+/*******************************************************************/
+/* */
+/* Used internally - for sound buffers this is the call that */
+/* causes data to be passed along to AIL */
+
+void Buffer::play(int16) {
+ took(rSize);
+}
+
+void workBuffer::play(int16 bufNo) {
+ VERIFY(bufNo == 0);
+ took(rSize);
+}
+
+void doubleBuffer::play(int16 bufNo) {
+ VERIFY(bufNo >= 0 && bufNo <= 1);
+ VERIFY(ailSampleHandle);
+ targetPos = (int32)((char *) rData - (char *)data[AILLOCated]) + rSize;
+ AIL_load_sample_buffer(ailSampleHandle, AILLOCated, rData, rSize);
+ took(rSize);
+ AILLOCated = -1;
+}
+
+void singleBuffer::play(int16 bufNo) {
+ VERIFY(bufNo == 0);
+ VERIFY(ailSampleHandle);
+ AIL_set_sample_address(ailSampleHandle, rData, rSize);
+ AIL_set_sample_loop_count(ailSampleHandle, loopCount);
+ AIL_start_sample(ailSampleHandle);
+ took(rSize);
+}
+
+void singleBuffer::replay(void) {
+ VERIFY(ailSampleHandle);
+ rSize = lastRSize; //((uint8 *)rData)-((uint8 *)data[0]) ;
+ rData = data[0];
+ VERIFY(rSize);
+ AIL_set_sample_address(ailSampleHandle, rData, rSize);
+ AIL_set_sample_loop_count(ailSampleHandle, loopCount);
+ AIL_start_sample(ailSampleHandle);
+}
+
+void musicBuffer::play(int16 bufNo) {
+ VERIFY(bufNo == 0);
+ VERIFY(ailSampleHandle);
+ if (AIL_init_sequence(ailSampleHandle, rData, 0) <= 0) {
+ error("musicBuffer::play");
+ }
+ audioSet = 1;
+ AIL_set_sequence_loop_count(ailSampleHandle, loopCount);
+ AIL_start_sequence(ailSampleHandle);
+ took(rSize);
+}
+
+void cacheBuffer::play(int16) {
+ hasData = 1;
+}
+
+/*******************************************************************/
+/* */
+/* Used internally to keep track of and prepare buffers for writing*/
+
+void Buffer::activate(int16) {
+ if (washed() > -1) {
+ wSize = size;
+ wData = data[0];
+ rSize = 0;
+ rData = data[0];
+ }
+}
+
+void workBuffer::activate(int16 bufNo) {
+ VERIFY(bufNo == 0);
+ VERIFY(rSize == 0);
+ if (washed() > -1) {
+ fillBuffer = 0;
+ wSize = size;
+ wData = data[fillBuffer];
+ rSize = 0;
+ rData = data[0];
+ }
+}
+
+void doubleBuffer::activate(int16 bufNo) {
+ int32 n;
+ VERIFY(ailSampleHandle);
+ n = bufNo;
+ if (washed() > -1) {
+ targetSated = FALSE;
+ fillBuffer = AILLOCated;
+ wSize = size;
+ wData = data[fillBuffer];
+ rSize = 0;
+ rData = data[fillBuffer];
+ } else {
+ fillBuffer = AILLOCated;
+ wSize = 0;
+ wData = data[0];
+ rSize = 0;
+ rData = data[0];
+ targetSated = TRUE;
+ }
+}
+
+void singleBuffer::activate(int16 bufNo) {
+ int32 n;
+ VERIFY(ailSampleHandle);
+ n = bufNo;
+ targetSated = FALSE;
+ fillBuffer = 0;
+ wSize = size;
+ wData = data[fillBuffer];
+ rSize = 0;
+ rData = data[fillBuffer];
+}
+
+void musicBuffer::activate(int16 bufNo) {
+ int32 n;
+ VERIFY(ailSampleHandle);
+ n = bufNo;
+ audioSet = 0;
+ if (washed() > -1) {
+ targetSated = FALSE;
+ fillBuffer = 0;
+ wSize = size;
+ wData = data[fillBuffer];
+ rSize = 0;
+ rData = data[fillBuffer];
+ } else {
+ fillBuffer = 0;
+ wSize = 0;
+ wData = data[0];
+ rSize = 0;
+ rData = data[0];
+ targetSated = TRUE;
+ }
+}
+
+void cacheBuffer::activate(int16 bufNo) {
+ VERIFY(bufNo == 0);
+}
+
+/*******************************************************************/
+/* Initializes a buffer */
+
+void Buffer::reset(void) {
+ wSize = size;
+ wData = data[0];
+ rSize = 0;
+ rData = data[0];
+}
+
+void workBuffer::reset(void) {
+ if (rSize) took(rSize);
+ VERIFY(rSize == 0);
+ activate(0);
+}
+
+void doubleBuffer::reset(void) {
+ VERIFY(AILLOCated == -1);
+ AIL_init_sample(ailSampleHandle);
+ audioSet = 0;
+ targetPos = 0;
+}
+
+void singleBuffer::reset(void) {
+// VERIFY( AILLOCated==-1 );
+ AIL_init_sample(ailSampleHandle);
+ audioSet = 0;
+}
+
+void musicBuffer::reset(void) {
+ AIL_end_sequence(ailSampleHandle);
+ audioSet = 0;
+ activate(0);
+}
+
+void cacheBuffer::reset(void) {
+ VERIFY(rSize == 0);
+ activate(0);
+}
+
+/*******************************************************************/
+/* Initializes a buffer */
+
+void Buffer::setVolume(int8) {
+}
+
+void workBuffer::setVolume(int8) {
+}
+
+void doubleBuffer::setVolume(int8 v) {
+ if (AIL_sample_volume(ailSampleHandle) != v) {
+ AIL_lock();
+ AIL_set_sample_volume(ailSampleHandle, v);
+ AIL_unlock();
+ }
+}
+
+void singleBuffer::setVolume(int8 v) {
+ if (AIL_sample_volume(ailSampleHandle) != v) {
+ AIL_lock();
+ AIL_set_sample_volume(ailSampleHandle, v);
+ AIL_unlock();
+ }
+}
+
+void musicBuffer::setVolume(int8 v) {
+ if (audioSet) {
+ if (AIL_sequence_volume(ailSampleHandle) != v) {
+ AIL_lock();
+ AIL_set_sequence_volume(ailSampleHandle, v, 0);
+ AIL_unlock();
+ }
+ }
+}
+
+void cacheBuffer::setVolume(int8) {
+}
+
+void musicBuffer::fadeUp(int16 time, int8 volume) {
+ if (audioSet) {
+ AIL_lock();
+ AIL_set_sequence_volume(ailSampleHandle, volume, time);
+ AIL_unlock();
+ }
+}
+
+void musicBuffer::fadeDown(int16 time) {
+ if (audioSet) {
+ AIL_lock();
+ AIL_set_sequence_volume(ailSampleHandle, 0, time);
+ AIL_unlock();
+ }
+}
+
+} // end of namespace Saga2
diff --git a/engines/saga2/audiobuf.h b/engines/saga2/audiobuf.h
new file mode 100644
index 0000000000..7bc44f71d5
--- /dev/null
+++ b/engines/saga2/audiobuf.h
@@ -0,0 +1,352 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Based on the original sources
+ * Faery Tale II -- The Halls of the Dead
+ * (c) 1993-1996 The Wyrmkeep Entertainment Co.
+ */
+
+#ifndef SAGA2_AUDIOBUF_H
+#define SAGA2_AUDIOBUF_H
+
+namespace Saga2 {
+
+class Buffer;
+class workBuffer;
+class doubleBuffer;
+class singleBuffer;
+class musicBuffer;
+class cacheBuffer;
+
+class soundDecoder;
+class decoderSet;
+
+class soundSample;
+
+class soundQueue;
+
+class audioInterface;
+
+/* ===================================================================== *
+ Simple base buffer class
+ * ===================================================================== */
+
+enum soundBufferStatus {
+ bufferNull = 0,
+ bufferFree, // buffer available for use
+ bufferDone, // buffer is done playing
+ bufferLoad, // buffer is being filled
+ bufferFull, // buffer is full & ready to go
+ bufferPlay, // buffer is playing
+ bufferWork, // indicates a permanent work buffer
+ bufferUsed,
+};
+
+
+class Buffer {
+private:
+ bool internallyAllocated; // buffer allocated in ctor
+
+protected:
+ uint32 size; // true size of buffer( s )
+ void *data[2]; // pointers to buffer( s )
+
+public:
+ // These two fields comprise the virtual write buffer
+ uint32 wSize; // virtual remaining write size
+ void *wData; // virtual write data buffer
+
+ // These two fields comprise the virtual read buffer
+ uint32 rSize; // virtual remaining read size
+ void *rData; // virtual read data buffer
+
+ // Note that buffers do not follow canonical form
+ void *operator new (size_t s) {
+ return audioAlloc(s, "audio buffer mgr");
+ }
+ void operator delete (void *m) {
+ audioFree(m);
+ }
+ Buffer(size_t newSize);
+ virtual ~Buffer(void);
+
+ virtual int16 ID(void) {
+ return -1; // for buffer Manager
+ }
+
+ virtual uint32 sample_status(void); // gives the status of the buffer as a whole
+ virtual void reset(void); // initialize buffer
+ virtual void format(soundSample *ss); // set various sound attribs.
+ virtual bool laden(void); // check for full targets
+
+ virtual void gave(size_t dSize); // notify amount written
+ virtual void took(size_t dSize); // notify amount read
+ virtual void fill(void); // convince buffer it is full
+ virtual void abort(void); // kill sound & return buffer to its heap
+ virtual void release(void); // return buffer to its heap
+ virtual void setVolume(int8 val); // internal : set buffer to fill & play
+
+protected:
+ virtual int16 washed(void); // internal : check for a clean buffer
+ virtual void play(int16 bufNo = 0); // internal : use the data
+ virtual void activate(int16 bufNo); // internal : set buffer to fill & play
+};
+
+
+class workBuffer : public Buffer {
+private:
+ int16 bufID; // for buffer manager
+ int16 fillBuffer, // buffer being filled
+ targetSated; // target full
+
+public:
+ int16 ID(void) {
+ return bufID; // for buffer Manager
+ }
+ void shiftdown(int16 bufNo = 0);
+
+ workBuffer(size_t newSize, int16 newID);
+ ~workBuffer(void);
+ void *operator new (size_t s) {
+ return audioAlloc(s, "audio wk bfr mgr");
+ }
+ void operator delete (void *m) {
+ audioFree(m);
+ }
+
+ uint32 sample_status(void); // gives the status of the buffer as a whole
+ void reset(void); // initialize buffer
+ void format(soundSample *ss); // set various sound attribs.
+ bool laden(void); // check for full targets
+
+ void gave(size_t dSize); // notify amount written
+ void took(size_t dSize); // notify amount read
+ void fill(void); // convince buffer it is full
+ void abort(void); // kill sound & return buffer to its heap
+ void release(void); // return buffer to its heap
+ void setVolume(int8 val); // internal : set buffer to fill & play
+
+protected:
+ int16 washed(void); // check for a clean buffer
+ void play(int16 bufNo = 0); // internal: use the data
+ void activate(int16 bufNo); // set buffer to fill & play
+};
+
+
+class doubleBuffer : public Buffer {
+private:
+ int16 bufID; // for buffer manager
+ int16 AILLOCated; // last buffer ( 0, 1 ) reported free
+ int16 fillBuffer, // buffer being filled
+ targetSated; // target full
+ int32 lastPos, distPos; // workaround for AIL sample status
+ int32 targetPos;
+
+public:
+ HSAMPLE ailSampleHandle; // sample handle
+ int audioSet;
+
+
+public:
+ int16 ID(void) {
+ return bufID; // for buffer Manager
+ }
+ void abort(void); // abort playback
+
+ doubleBuffer(size_t newSize, audioInterface *sd, int16 newID);
+ ~doubleBuffer(void);
+ void *operator new (size_t s) {
+ return audioAlloc(s, "aud dble buf mgr");
+ }
+ void operator delete (void *m) {
+ audioFree(m);
+ }
+
+ uint32 sample_status(void); // gives the status of the buffer as a whole
+ void reset(void); // initialize buffer
+ void format(soundSample *ss); // set various sound attribs.
+ bool laden(void); // check for full targets
+
+ void gave(size_t dSize); // notify amount written
+ void took(size_t dSize); // notify amount read
+ void fill(void); // convince buffer it is full
+// void abort( void ); // kill sound & return buffer to its heap
+ void release(void); // return buffer to its heap
+ void setVolume(int8 val); // internal : set buffer to fill & play
+
+protected:
+ int16 washed(void); // check for a clean buffer
+ void play(int16 bufNo = 0); // internal: use the data
+ void activate(int16 bufNo); // set buffer to fill & play
+};
+
+
+class singleBuffer : public Buffer {
+private:
+ int16 bufID; // for buffer manager
+ int16 AILLOCated; // last buffer ( 0, 1 ) reported free
+ int16 fillBuffer, // buffer being filled
+ targetSated; // target full
+ int16 loopCount;
+
+public:
+ HSAMPLE ailSampleHandle; // sample handle
+ int16 audioSet;
+ uint32 lastRSize; // virtual remaining read size
+
+public:
+ int16 ID(void) {
+ return bufID; // for buffer Manager
+ }
+
+ singleBuffer(size_t newSize, audioInterface *sd, int16 newID);
+ ~singleBuffer(void);
+ void *operator new (size_t s) {
+ return audioAlloc(s, "aud sgl buf mgr");
+ }
+ void operator delete (void *m) {
+ audioFree(m);
+ }
+
+ uint32 sample_status(void); // gives the status of the buffer as a whole
+ void reset(void); // initialize buffer
+ void format(soundSample *ss); // set various sound attribs.
+ bool laden(void); // check for full targets
+
+ void gave(size_t dSize); // notify amount written
+ void took(size_t dSize); // notify amount read
+ void fill(void); // convince buffer it is full
+ void replay(void); // kill sound & return buffer to its heap
+ void abort(void); // kill sound & return buffer to its heap
+ void release(void); // return buffer to its heap
+ void setVolume(int8 val); // internal : set buffer to fill & play
+
+ void setLoopCount(int16 loops) {
+ loopCount = loops;
+ }
+ int16 getLoopCount(void) {
+ return loopCount;
+ }
+
+protected:
+ int16 washed(void); // check for a clean buffer
+ void play(int16 bufNo = 0); // internal: use the data
+ void activate(int16 bufNo); // set buffer to fill & play
+};
+
+class musicBuffer : public Buffer {
+private:
+ int16 bufID; // for buffer manager
+ //int16 AILLOCated; // last buffer ( 0, 1 ) reported free
+ int16 fillBuffer, // buffer being filled
+ targetSated; // target full
+ int16 loopCount;
+
+
+public:
+ HSEQUENCE ailSampleHandle; // sample handle
+ int16 audioSet;
+
+public:
+ int16 ID(void) {
+ return bufID; // for buffer Manager
+ }
+
+ musicBuffer(size_t newSize, audioInterface *sd, int16 newID);
+ ~musicBuffer(void);
+ void *operator new (size_t s) {
+ return audioAlloc(s, "aud music buf mgr");
+ }
+ void operator delete (void *m) {
+ audioFree(m);
+ }
+
+ uint32 sample_status(void); // gives the status of the buffer as a whole
+ void reset(void); // initialize buffer
+ void format(soundSample *ss); // set various sound attribs.
+ bool laden(void); // check for full targets
+
+ void gave(size_t dSize); // notify amount written
+ void took(size_t dSize); // notify amount read
+ void fill(void); // convince buffer it is full
+ void abort(void); // kill sound & return buffer to its heap
+ void release(void); // return buffer to its heap
+ void setVolume(int8 val); // internal : set buffer to fill & play
+
+ void setLoopCount(int16 loops) {
+ VERIFY(audioSet);
+ loopCount = loops;
+ }
+ int16 getLoopCount(void) {
+ return loopCount;
+ }
+
+protected:
+ int16 washed(void); // check for a clean buffer
+ void play(int16 bufNo = 0); // internal: use the data
+ void activate(int16 bufNo); // set buffer to fill & play
+
+public:
+ void fadeUp(int16 time, int8 volume);
+ void fadeDown(int16 time);
+};
+
+class cacheBuffer : public Buffer {
+private:
+ int16 bufID; // for buffer manager
+ soundSample *sformat;
+ int16 hasData;
+
+public:
+ int16 ID(void) {
+ return bufID; // for buffer Manager
+ }
+
+ cacheBuffer(size_t newSize, int16 newID);
+ ~cacheBuffer(void);
+ void *operator new (size_t s) {
+ return audioAlloc(s, "aud cache buf mgr");
+ }
+ void operator delete (void *m) {
+ audioFree(m);
+ }
+
+ uint32 sample_status(void); // gives the status of the buffer as a whole
+ void reset(void); // initialize buffer
+ void format(soundSample *ss); // set various sound attribs.
+ bool laden(void); // check for full targets
+
+ void gave(size_t dSize); // notify amount written
+ void took(size_t dSize); // notify amount read
+ void fill(void); // convince buffer it is full
+ void abort(void); // kill sound & return buffer to its heap
+ void release(void); // return buffer to its heap
+ void setVolume(int8 val); // internal : set buffer to fill & play
+
+protected:
+ int16 washed(void); // check for a clean buffer
+ void play(int16 bufNo = 0); // internal: use the data
+ void activate(int16 bufNo); // set buffer to fill & play
+};
+
+} // end of namespace Saga2
+
+#endif
diff --git a/engines/saga2/audiocmp.h b/engines/saga2/audiocmp.h
new file mode 100644
index 0000000000..a4d74ee00c
--- /dev/null
+++ b/engines/saga2/audiocmp.h
@@ -0,0 +1,119 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Based on the original sources
+ * Faery Tale II -- The Halls of the Dead
+ * (c) 1993-1996 The Wyrmkeep Entertainment Co.
+ */
+
+#ifndef SAGA2_AUDIOCMP_H
+#define SAGA2_AUDIOCMP_H
+
+#include "saga2/audiogvc.h"
+
+namespace Saga2 {
+
+/* ===================================================================== *
+ Tweak values
+ * ===================================================================== */
+
+#define MAXIMAL_COMPRESSION 8
+#define EXPECTED_COMPRESSION 4
+
+/* ===================================================================== *
+ Decompression engine
+ * ===================================================================== */
+
+class soundDecompression {
+public:
+
+ workBuffer *filei; // input 'file' ( buffer )
+ workBuffer *workBuf; // input 'file' ( buffer ) copy
+ Buffer *fileo; // output 'file' ( buffer )
+ Buffer *targBuf; // output 'file' ( buffer ) copy
+
+ soundDecoder *readFrom; // input decoder
+ soundSample *sampleAttrib; // audio attributes
+
+ uint32 rVal; // decoder return value
+
+ long **buffer, * *offset;
+ long default_offset, lpcqoffset;
+ int version, bitshift ;
+ int hiloint, hilo ;
+ int ftype ;
+ int blocksize, nchan;
+ int i, chan, nwrap, nskip, ndiscard ;
+ int *qlpc, maxnlpc, nmean ;
+ int quanterror, nfilename;
+ int minsnr;
+ int decompState;
+ char *magic, *old_magic, *filenamei, *filenameo ;
+ char *tmpfilename ;
+ char *maxresnstr;
+
+ bool decerr, deceof; // error, eof detect on input buffer
+ bool deserr, deseof; // error, eof detect on output buffer
+
+ soundDecompression(void);
+ soundDecompression(Buffer *sb, soundDecoder *sd, soundSample *ss, workBuffer *wb);
+ void *operator new (size_t s) {
+ return audioAlloc(s, "audio decmp data");
+ }
+ void operator delete (void *m) {
+ audioFree(m);
+ }
+
+ void reset(void); // initializefor new 'file'
+ void setFType(int16 dft); // set the file type
+
+ size_t readb(Buffer *sb, Buffer *tb);
+ bool openb(Buffer *sb, Buffer *tb);
+
+ bool beof(void) {
+ return deceof;
+ }
+ bool berr(void) {
+ return decerr;
+ }
+ bool weof(void) {
+ return fileo->laden();
+ }
+ bool werr(void) {
+ return deserr;
+ }
+
+};
+
+/* ===================================================================== *
+ File Emulation for buffers
+ * ===================================================================== */
+
+Buffer *buffopen(char n[], char att[]); // emulate fopen
+size_t buffread(void *, size_t, size_t, Buffer *); // emulate fread
+int buffgetc(Buffer *); // emulate fgetc
+char buffputc(char, Buffer *); // emulate fputc
+int16 buffclose(Buffer *); // emulate fclose
+size_t buffwrite(void *, size_t, size_t, Buffer *); // emulate fwrite
+
+} // end of namespace Saga2
+
+#endif //DECOMP_H
diff --git a/engines/saga2/audiodec.h b/engines/saga2/audiodec.h
new file mode 100644
index 0000000000..b6ad989e2d
--- /dev/null
+++ b/engines/saga2/audiodec.h
@@ -0,0 +1,229 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Based on the original sources
+ * Faery Tale II -- The Halls of the Dead
+ * (c) 1993-1996 The Wyrmkeep Entertainment Co.
+ */
+
+#ifndef SAGA2_AUDIODEC_H
+#define SAGA2_AUDIODEC_H
+
+namespace Saga2 {
+
+/* ===================================================================== *
+
+ Sound Sample Decoders
+ These are audio buffer decoders & fillers used in playback.
+ They are intended to be chained together.
+ They come in three flavors:
+
+ decodeInPlace - which operate on existing buffers
+ mute() - zeroes out buffer
+
+ decodeBuffer - which require work buffers
+ unShorten() - undoes Shorten 1.22 compression
+ thunk8to16() - converts 8 bit samples to 16 bit
+
+ decodeSource - aliases to soundSource calls
+
+ NOTE : If you are trying to follow the flow of the code, and you get
+ lost around here, you can probably pick things up again in the
+ audiofnc modules or in some locally defined decoders
+
+ * ===================================================================== */
+
+enum soundDecoderType {
+ decodeInPlace,
+ decodeBuffer,
+ decodeSource,
+};
+
+/* ===================================================================== *
+ Visual C sucks
+ * ===================================================================== */
+
+#ifdef _WIN32
+typedef int16 __cdecl INPLACEDECODER(Buffer &, soundDecoder *, soundSample &);
+typedef int16 __cdecl BUFFERDECODER(Buffer &, soundDecoder *, soundSample &, workBuffer *);
+typedef int16 __cdecl BUFFERLOADER(Buffer &, soundSample &);
+#else
+typedef int16 INPLACEDECODER(Buffer &, soundDecoder *, soundSample &);
+typedef int16 BUFFERDECODER(Buffer &, soundDecoder *, soundSample &, workBuffer *);
+typedef int16 BUFFERLOADER(Buffer &, soundSample &);
+#endif
+
+union soundServer {
+ INPLACEDECODER *pDec;
+ BUFFERDECODER *bDec;
+ BUFFERLOADER *lDec;
+ void *operator new (size_t s) {
+ return audioAlloc(s, "aud snd server");
+ }
+ void operator delete (void *m) {
+ audioFree(m);
+ }
+ soundServer() {
+ pDec = NULL;
+ }
+ soundServer(soundDecoderType sdt, void *fn) {
+ switch (sdt) {
+ case decodeInPlace:
+ pDec = (INPLACEDECODER *) fn;
+ break;
+ case decodeBuffer :
+ bDec = (BUFFERDECODER *) fn;
+ break;
+ case decodeSource :
+ lDec = (BUFFERLOADER *) fn;
+ break;
+ }
+ }
+ soundServer(const soundServer &src) {
+ pDec = src.pDec;
+ }
+ soundServer &operator=(const soundServer &src) {
+ this->pDec = src.pDec;
+ return *this;
+ }
+ inline bool operator==(const soundServer &src2) const {
+ return pDec == src2.pDec;
+ }
+ inline operator bool() const {
+ return pDec != NULL;
+ }
+};
+
+/*******************************************************************/
+/* Decoder status flags */
+
+enum decoderStatuses {
+ msgBufferFull = 1 << 0, // targetbuffer filled
+ msgSegmentEnd = 1 << 1, // source segment exhausted
+ msgBufferFree = 1 << 2, // waiting for a free buffer
+ msgSamplePause = 1 << 3, // partial load - continue next time
+ msgSampleDone = 1 << 4, // sample complete
+ msgWaitForBuffer = 1 << 5, // waiting for free buffer
+ msgIOError = 1 << 6, // an I/O error occurred reading the file
+};
+
+class soundDecoder {
+ bool inUse; // to avoid buffer tangles
+ soundDecoderType type; // in-place, buffered, loader
+ soundServer openf; // open/seek function
+ soundServer readf; // read/load function
+ soundServer closef; // close function
+
+public:
+ soundDecoder *next; // linked list
+ workBuffer *wkBuffer; // pointer to work buffer ( if any )
+
+private:
+ soundDecoder();
+public:
+#ifdef _WIN32
+ soundDecoder(INPLACEDECODER *, INPLACEDECODER *, INPLACEDECODER *);
+ soundDecoder(BUFFERDECODER *, BUFFERDECODER *, BUFFERDECODER *, int16, audioInterface *, int16);
+ soundDecoder(BUFFERLOADER *, BUFFERLOADER *, BUFFERLOADER *);
+#else
+ soundDecoder(INPLACEDECODER, INPLACEDECODER, INPLACEDECODER);
+ soundDecoder(BUFFERDECODER, BUFFERDECODER, BUFFERDECODER, int16, audioInterface *, int16);
+ soundDecoder(BUFFERLOADER, BUFFERLOADER, BUFFERLOADER);
+#endif
+ ~soundDecoder(void);
+ void *operator new (size_t s) {
+ return audioAlloc(s, "audio decoder");
+ }
+ void operator delete (void *m) {
+ audioFree(m);
+ }
+ soundDecoder &operator=(const soundDecoder &src);
+ soundDecoder(const soundDecoder &src);
+ bool operator==(const soundDecoder &src2) const;
+ inline operator bool() const {
+ return (bool) readf != NULL;
+ }
+
+ void setNext(soundDecoder *sd) {
+ next = sd;
+ }
+
+ int16 use(Buffer &, soundDecoder *, soundSample &);
+ int16 seek(Buffer &, soundDecoder *, soundSample &);
+ int16 flush(Buffer &, soundDecoder *, soundSample &);
+
+ void reset(void);
+
+ //void notBusy( void ); // idle time function
+
+};
+
+
+/*******************************************************************/
+/* */
+/* DecoderSet class : class used to process sound */
+/* */
+/*******************************************************************/
+
+class decoderSet { //: private DList
+public:
+ soundDecoder *decode;
+
+ decoderSet(void) {
+ decode = NULL;
+ }
+ ~decoderSet(void) {
+ if (decode) delete decode;
+ decode = NULL;
+ }
+ void *operator new (size_t s) {
+ return audioAlloc(s, "audio decdr set");
+ }
+ void operator delete (void *m) {
+ audioFree(m);
+ }
+ void addDecoder(soundDecoder *sodec);
+
+#if DEBUG_AUDIO
+ void check(void);
+#else
+ inline void check(void) {}
+#endif
+
+ void reset(void);
+ void format(soundSample *ss); // set various sound attribs.
+
+ int16 openCall(Buffer *sobu, soundQueue *queue);
+ int16 openCall(Buffer *sobu, soundSample *queue);
+
+ int16 loadCall(Buffer *sobu, soundQueue *queue);
+ int16 loadCall(Buffer *sobu, soundSample *queue);
+
+ int16 closeCall(Buffer *sobu, soundQueue *queue);
+ int16 closeCall(Buffer *sobu, soundSample *queue);
+
+private:
+ //void notBusy( void ); // idle time function
+};
+
+} // end of namespace Saga2
+
+#endif
diff --git a/engines/saga2/audioerr.h b/engines/saga2/audioerr.h
new file mode 100644
index 0000000000..9f7b284c68
--- /dev/null
+++ b/engines/saga2/audioerr.h
@@ -0,0 +1,121 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Based on the original sources
+ * Faery Tale II -- The Halls of the Dead
+ * (c) 1993-1996 The Wyrmkeep Entertainment Co.
+ */
+
+#ifndef SAGA2_AUDIOERR_H
+#define SAGA2_AUDIOERR_H 1
+
+#include "saga2/errors.h"
+#include "saga2/errclass.h"
+
+namespace Saga2 {
+
+const int32 audioErrorOffset = 0xE0;
+
+enum soundErrors {
+ serrNoError = audioErrorOffset,
+ serrOpenFailed,
+ serrReadFailed,
+ serrNoFreeBuffers,
+ serrBufferSizeTooSmall,
+ serrPlayError,
+ serrCompUnexpectedEOF,
+ serrCompNoMagicNum,
+ serrCompBadAlign,
+ serrCompBadFloat,
+ serrCompBadType,
+ serrCompUnkType,
+ serrCompUnsupType,
+ serrCompOddType,
+ serrCompNoType,
+ serrCompInternal,
+ serrCompWriteFailed,
+ serrCompPutFailed,
+ serrCompReadFailed,
+ serrCompEOFInStream,
+ serrVersionMismatch,
+ serrFATAL,
+ serrMaxErr,
+};
+
+/* ===================================================================== *
+ Audio error classes
+ * ===================================================================== */
+
+class AudioError : public gError {
+public:
+ AudioError(soundErrors errID);
+ AudioError(char *msg);
+};
+
+class AudioFatal : public AudioError {
+public:
+ AudioFatal();
+ AudioFatal(char *msg);
+};
+
+
+/* ===================================================================== *
+ Error macros
+ * ===================================================================== */
+
+inline void SegFatal(soundErrors errID) {
+ error("Sound error %d", errID);
+}
+
+inline void audioFatal(char *msg) {
+ error("Sound error %s", msg);
+}
+
+char *IDName(long s);
+
+/* ===================================================================== *
+ Logging macro
+ * ===================================================================== */
+
+#if DEBUG
+
+#include <io.h>
+#define AUDIO_LOG_FILE "AUDIOERR.LOG"
+#define AUDIO_MAX_LOG_SIZE 16384
+
+inline void audioLog(char *s) {
+ FILE *fp = fopen(AUDIO_LOG_FILE, "at");
+ if (fp) {
+ if (filelength(fileno(fp)) > AUDIO_MAX_LOG_SIZE) {
+ fclose(fp);
+ remove(AUDIO_LOG_FILE);
+ fp = fopen(AUDIO_LOG_FILE, "at");
+ fprintf(fp, "LOG CLEARED AT TIME %d\n==========================", gameTime);
+ }
+ fprintf(fp, "%s\n", s);
+ fclose(fp);
+ }
+}
+#endif
+
+} // end of namespace Saga2
+
+#endif
diff --git a/engines/saga2/audiofnc.h b/engines/saga2/audiofnc.h
new file mode 100644
index 0000000000..ca84aeceef
--- /dev/null
+++ b/engines/saga2/audiofnc.h
@@ -0,0 +1,90 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Based on the original sources
+ * Faery Tale II -- The Halls of the Dead
+ * (c) 1993-1996 The Wyrmkeep Entertainment Co.
+ */
+
+#ifndef SAGA2_AUDIOFNC_H
+#define SAGA2_AUDIOFNC_H
+
+#include "saga2/audiobuf.h"
+
+namespace Saga2 {
+
+/* ===================================================================== *
+ DECODERS
+ Decoders are generally declared in groups of three functions
+ - An Open/Seek routine to prepare for reading
+ - A Read routine to move the actual data
+ - A Flush/Close routine to clean up
+
+ Three types of decoder currently exist
+ - In Place Decoders : operate on a buffer in place
+ - Buffered Decoders : require a temporary work buffer
+ - Buffer Loaders : read buffers from disk etc.
+ * ===================================================================== */
+
+
+/*******************************************************************/
+/* Declaration Macros */
+
+#define INPLACEDEC( procname ) \
+ int16 procname( Buffer &sb, soundDecoder *sd, soundSample &ss )
+#define BUFFERDEC( procname ) \
+ int16 procname( Buffer &sb, soundDecoder *sd, soundSample &ss, workBuffer *wb )
+#define BUFFERLOD( procname ) \
+ int16 procname( Buffer &sb, soundSample &ss )
+
+/*******************************************************************/
+/* LOADERS */
+
+// static buffer source
+
+BUFFERLOD(seekBuffer);
+BUFFERLOD(readBuffer);
+BUFFERLOD(flushBuffer);
+
+// FILE* source
+
+BUFFERLOD(readFile);
+BUFFERLOD(seekFile);
+BUFFERLOD(flushFile);
+
+/*******************************************************************/
+/* TRANSLATORS */
+
+INPLACEDEC(stereoToMonoSeek);
+INPLACEDEC(stereoToMono);
+INPLACEDEC(stereoToMonoFlush);
+
+
+/*******************************************************************/
+/* BUFFERED DECODERS */
+
+BUFFERDEC(readDecompress);
+BUFFERDEC(seekDecompress);
+BUFFERDEC(flushDecompress);
+
+} // end of namespace Saga2
+
+#endif
diff --git a/engines/saga2/audiogvc.h b/engines/saga2/audiogvc.h
new file mode 100644
index 0000000000..40a21aa0ab
--- /dev/null
+++ b/engines/saga2/audiogvc.h
@@ -0,0 +1,296 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Based on the original sources
+ * Faery Tale II -- The Halls of the Dead
+ * (c) 1993-1996 The Wyrmkeep Entertainment Co.
+ */
+
+#ifndef SAGA2_AUDIOGVC_H
+#define SAGA2_AUDIOGVC_H
+
+namespace Saga2 {
+
+#define BUGFIX_RELEASE "22"
+
+#define HAVE_STDARG_H 1
+
+
+# define OLD_MAGIC "ajkg"
+# define MAGIC "dgvc"
+
+// file formats
+
+enum decompFTypes {
+ dft_au, // Unix .AU file
+ dft_ulaw, // mu-law encoding
+ dft_s8, // signed 8 bit PCM
+ dft_u8, // unsigned 8 bit PCM
+ dft_s16, // signed 16 bit PCM
+ dft_u16, // unsigned 16 bit PCM
+ dft_s16x, // signed 16 bit PCM
+ dft_u16x, // unsigned 16 bit PCM
+ dft_s16hl, // signed 16 bit PCM 680x0 ordering
+ dft_u16hl, // unsigned 16 bit PCM 680x0 ordering
+ dft_s16lh, // signed 16 bit PCM 80x86 ordering
+ dft_u16lh, // unsigned 16 bit PCM 80x86 ordering
+};
+
+#define DEFAULT_FTYPE ( dft_s16 )
+
+
+
+
+# define FORMAT_VERSION 1
+# define MIN_SUPPORTED_VERSION 0
+# define MAX_SUPPORTED_VERSION 2
+# define MAX_VERSION 7
+# define UNDEFINED_UINT -1
+# define DEFAULT_BLOCK_SIZE 256
+# define DEFAULT_V0NMEAN 0
+# define DEFAULT_V2NMEAN 4
+# define DEFAULT_MAXNLPC 0
+# define DEFAULT_NCHAN 1
+# define DEFAULT_NSKIP 0
+# define DEFAULT_NDISCARD 0
+# define NBITPERLONG 32
+# define DEFAULT_MINSNR 99
+# define DEFAULT_MAXRESNSTR "32.0"
+# define DEFAULT_QUANTERROR 0
+# define MINBITRATE 2.5
+
+# define MAX_LPC_ORDER 64
+# define CHANSIZE 0
+# define ENERGYSIZE 3
+# define BITSHIFTSIZE 2
+# define NWRAP 3
+
+# define FNSIZE 2
+# define FN_DIFF0 0
+# define FN_DIFF1 1
+# define FN_DIFF2 2
+# define FN_DIFF3 3
+# define FN_QUIT 4
+# define FN_BLOCKSIZE 5
+# define FN_BITSHIFT 6
+# define FN_QLPC 7
+# define FN_ZERO 8
+
+# define ULONGSIZE 2
+# define NSKIPSIZE 1
+# define LPCQSIZE 2
+# define LPCQUANT 5
+# define XBYTESIZE 7
+
+# define TYPESIZE 4
+# define TYPE_AU 0
+# define TYPE_S8 1
+# define TYPE_U8 2
+# define TYPE_S16HL 3
+# define TYPE_U16HL 4
+# define TYPE_S16LH 5
+# define TYPE_U16LH 6
+# define TYPE_ULAW 7
+# define TYPE_EOF 8
+
+#ifndef MIN
+# define MIN( a, b ) ((( a )<( b ))?( a ):( b ))
+#endif
+
+#ifndef MAX
+# define MAX( a, b ) ((( a )>( b ))?( a ):( b ))
+#endif
+
+#if defined( unix ) && !defined( linux )
+# define labs abs
+#endif
+
+# define ROUNDEDSHIFTDOWN( x, n ) ((( n ) == 0 ) ? ( x ) : (( x ) >> (( n ) - 1 )) >> 1 )
+
+#ifndef M_LN2
+#define M_LN2 0.69314718055994530942
+#endif
+
+/* BUFSIZ must be a multiple of four to contain a whole number of words */
+#ifndef BUFSIZ
+# define BUFSIZ 1024
+#endif
+
+#define putc_exit( val, stream )\
+ { char rval;\
+ if(( rval = buffputc(( val ), ( stream ))) != ( char ) ( val ))\
+ SegFatal( serrCompPutFailed );\
+ }
+//update_exit( 1, "write failed: putc returns EOF\n");
+
+extern int getc_exit_val;
+#define getc_exit( stream )\
+ ((( getc_exit_val = buffgetc( stream )) == EOF ) ? \
+ update_exit( 1, "read failed: getc returns EOF\n"), 0: getc_exit_val )
+
+#undef uchar
+#define uchar unsigned char
+#undef ushort
+#define ushort unsigned short
+#undef ulong
+#define ulong unsigned long
+
+#if defined( __STDC__ ) || defined( __GNUC__ ) || defined( sgi ) || !defined( unix )
+typedef signed char schar;
+#define PROTO( ARGS ) ARGS
+#else
+typedef char schar;
+#define PROTO( ARGS ) ()
+#endif
+
+#ifdef NEED_OLD_PROTOTYPES
+/*******************************************/
+/* this should be in string.h or strings.h */
+extern int strcmp PROTO((const char *, const char *));
+extern char *strcpy PROTO((char *, const char *));
+extern char *strcat PROTO((char *, const char *));
+extern int strlen PROTO((const char *));
+
+/**************************************/
+/* defined in stdlib.h if you have it */
+extern void *malloc PROTO((unsigned long));
+extern void free PROTO((void *));
+extern int atoi PROTO((const char *));
+extern void swab PROTO((char *, char *, int));
+extern int buffseek PROTO((doubleBuffer *, long, int));
+
+/***************************/
+/* other misc system calls */
+extern int unlink PROTO((const char *));
+extern void exit PROTO((int));
+#endif
+
+/************************/
+/* defined in shorten.c */
+extern long init_offset PROTO((long **, int, int, int));
+
+/*********************/
+/* defined in ulaw.c */
+extern uchar linear2ulaw PROTO((long));
+extern int ulaw2linear PROTO((uchar));
+
+/********************/
+/* defined in lpc.c */
+extern int wav2lpc PROTO((long *, int, long, int *, int, int, float *, float *));
+
+/*********************/
+/* defined in poly.c */
+extern int wav2poly PROTO((long *, int, long, int, float *, float *));
+
+/*********************/
+/* defined in exit.c */
+
+extern void basic_exit PROTO((int));
+
+#ifdef HAVE_STDARG_H
+extern void perror_exit PROTO((char *, ...));
+extern void usage_exit PROTO((int, char *, ...));
+extern void update_exit PROTO((int, char *, ...));
+# else
+extern void perror_exit PROTO(());
+extern void usage_exit PROTO(());
+extern void update_exit PROTO(());
+# endif
+
+/***********************/
+/* defined in hsgetopt.c */
+extern void hs_resetopt PROTO((void));
+extern int hs_getopt PROTO((int, char **, char *));
+extern int hs_optind;
+extern char *hs_optarg;
+
+/**********************/
+/* defined in array.c */
+extern void *pmalloc PROTO((ulong));
+extern long **long2d PROTO((ulong, ulong));
+
+/****************************/
+/* defined in dupfileinfo.c */
+extern int dupfileinfo PROTO((char *, char *));
+
+
+// PROTO() is an annoying parameter definition macro to allow compatibility
+// with the K&R style parameter declarations
+
+/**********************/
+/* defined in fixio.c */
+extern void init_sizeof_sample PROTO((void));
+extern void fread_type_init PROTO((void));
+extern void fread_type_quit PROTO((void));
+extern void fwrite_type_init PROTO((void));
+extern int fread_type PROTO((long **, int, int, int, Buffer *));
+extern void fwrite_type PROTO((long **, int, int, int, Buffer *));
+extern void fwrite_type_quit PROTO((void));
+extern int find_bitshift PROTO((long *, int, int));
+extern void fix_bitshift PROTO((long *, int, int, int));
+
+/**********************/
+/* defined in vario.c */
+extern void var_put_init PROTO((void));
+extern void uvar_put PROTO((ulong, int, Buffer *));
+extern void var_put PROTO((long, int, Buffer *));
+extern void ulong_put PROTO((ulong, Buffer *));
+extern void var_put_quit PROTO((Buffer *));
+
+extern void var_get_init PROTO((void));
+extern long uvar_get PROTO((int, Buffer *));
+extern long var_get PROTO((int, Buffer *));
+extern ulong ulong_get PROTO((Buffer *));
+extern void var_get_quit PROTO((void));
+
+extern int sizeof_uvar PROTO((ulong, int));
+extern int sizeof_var PROTO((long, int));
+
+extern void mkmasktab PROTO((void));
+extern void word_put PROTO((ulong, Buffer *));
+extern ulong word_get PROTO((Buffer *));
+
+
+extern int shorten PROTO((Buffer *, Buffer *, int, char **));
+
+
+long init_offset(long **offset, int nchan, int nblock, int ftype) ;
+float Satof(char *string) ;
+float *parseList(char *maxresnstr, int nchan) ;
+int16 getFType(decompFTypes dft);
+int unShorten(Buffer *stdi, Buffer *stdo, int, char **);
+
+# define V2LPCQOFFSET ( 1 << LPCQUANT );
+
+# define UINT_PUT( val, nbit, file ) \
+ if ( version == 0 ) uvar_put(( unsigned long ) val, nbit, file ); \
+ else ulong_put(( unsigned long ) val, file )
+
+# define UINT_GET( nbit, file ) \
+ (( version == 0 ) ? uvar_get( nbit, file ) : ulong_get( file ))
+
+# define VAR_PUT( val, nbit, file ) \
+ if ( version == 0 ) var_put(( unsigned long ) val, nbit - 1, file ); \
+ else var_put(( unsigned long ) val, nbit, file )
+
+} // end of namespace Saga2
+
+#endif
diff --git a/engines/saga2/audiomem.h b/engines/saga2/audiomem.h
new file mode 100644
index 0000000000..9a04834dd5
--- /dev/null
+++ b/engines/saga2/audiomem.h
@@ -0,0 +1,52 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Based on the original sources
+ * Faery Tale II -- The Halls of the Dead
+ * (c) 1993-1996 The Wyrmkeep Entertainment Co.
+ */
+
+
+#ifndef SAGA2_AUDIOMEM_H
+#define SAGA2_AUDIOMEM_H
+
+namespace Saga2{
+
+/* ===================================================================== *
+ Memory alloc/free
+ * ===================================================================== */
+
+void *audioAlloc(size_t s, char []);
+void audioFree(void *mem);
+
+#define audionew( s ) (( s* )audioAlloc( sizeof( s )))
+#define audiodelete( m ) ( audioFree( m ))
+
+/* ===================================================================== *
+ VMM locking
+ * ===================================================================== */
+
+bool audio_lock(void *p, size_t s);
+bool audio_unlock(void *p, size_t s);
+
+} // end of namespace Saga2
+
+#endif
diff --git a/engines/saga2/audiores.cpp b/engines/saga2/audiores.cpp
new file mode 100644
index 0000000000..dde15e3b5d
--- /dev/null
+++ b/engines/saga2/audiores.cpp
@@ -0,0 +1,198 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * aint32 with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Based on the original sources
+ * Faery Tale II -- The Halls of the Dead
+ * (c) 1993-1996 The Wyrmkeep Entertainment Co.
+ */
+
+#include "saga2/std.h"
+#include "saga2/audio.h"
+#include "saga2/hresmgr.h"
+#include "saga2/audiores.h"
+#include "saga2/fta.h"
+
+namespace Saga2 {
+
+#define ASYNCH_AUDIO 0
+#define ASYNCH_READ_SIZE 65536L
+
+/* ===================================================================== *
+ Imports
+ * ===================================================================== */
+
+extern audioInterface *audio;
+extern bool debugStatuses;
+extern bool debugResource;
+extern int32 maxClicks;
+extern int32 clickSizes[];
+extern uint8 *clickData[];
+
+
+bool bufCheckResID(hResContext *hrc, uint32 s) {
+ return s != 0;
+}
+
+bool hResCheckResID(hResContext *hrc, uint32 s) {
+ if (hrc != NULL)
+ return hrc->seek(s);
+ return FALSE;
+}
+
+bool hResCheckResID(hResContext *hrc, uint32 s[]) {
+ int i = 0;
+ if (s != NULL) {
+ if (s[0] == 0)
+ return FALSE;
+ while (s[i]) {
+ if (!hResCheckResID(hrc, s[i]))
+ return FALSE;
+ i++;
+ }
+ }
+ return TRUE;
+}
+
+/* ===================================================================== *
+ HRes loader code
+ * ===================================================================== */
+
+
+
+
+//-----------------------------------------------------------------------
+// open / seek
+
+int16 hResSeek(Buffer &sb, soundSample &ss, hResContext *hrc, bool Cheksize) {
+ if (hrc->seek(ss.curSeg) == FALSE) {
+#if DEBUG
+ char msg[80];
+ sprintf(msg, "Audio: %s is an invalid res ID\n", IDName(ss.curSeg));
+ audioLog(msg);
+ if (debugResource) {
+ WriteStatusF(6, msg);
+ }
+#endif
+ return serrOpenFailed;
+ }
+ if (Cheksize && sb.wSize < hrc->bytesleft()) {
+ int bufferSize = sb.wSize;
+ int soundSize = hrc->bytesleft();
+#if DEBUG
+ if (debugResource) {
+ char msg[80];
+ sprintf(msg, "Buffer too small %d sample: %d", bufferSize, soundSize);
+ audioLog(msg);
+ }
+#endif
+ return serrBufferSizeTooSmall;
+ }
+ ss.channels = soundSample::channelMono;
+ ss.speed = soundRate22K;
+ ss.dataSize = soundSample::granularity16Bit;
+ return 0;
+}
+
+//-----------------------------------------------------------------------
+// read
+
+int16 hResRead(Buffer &sb, soundSample &ss, hResContext *hrc) {
+ size_t bread;
+ size_t count = MIN<uint>(sb.wSize, hrc->bytesleft());
+ int16 rVal = 0;
+
+#if ASYNCH_AUDIO
+ bool partial = FALSE;
+ count = min(count, ASYNCH_READ_SIZE);
+ if (count > ASYNCH_READ_SIZE) {
+ count = ASYNCH_READ_SIZE;
+ partial = TRUE;
+ }
+#endif
+
+ bread = hrc->readbytes(sb.wData, count);
+ sb.gave(bread);
+
+ VERIFY(bread <= count);
+
+#if ASYNCH_AUDIO
+ if (partial)
+ rVal |= msgSamplePause;
+#endif
+ if (bread == count)
+ rVal |= msgBufferFull;
+ if (hrc->eor())
+ rVal |= msgSegmentEnd;
+ return rVal;
+}
+
+//-----------------------------------------------------------------------
+// flush / close
+
+int16 hResFlush(Buffer &sb, soundSample &ss, hResContext *hrc) {
+ return 0;
+}
+
+/* ===================================================================== *
+ In memory loader code
+ * ===================================================================== */
+
+//-----------------------------------------------------------------------
+// open / seek
+
+int16 bufSeek(Buffer &sb, soundSample &ss) {
+ if (ss.curSeg >= maxClicks) {
+ return serrOpenFailed;
+ }
+ ss.channels = soundSample::channelMono;
+ ss.speed = soundRate22K;
+ ss.dataSize = soundSample::granularity16Bit;
+ return 0;
+}
+
+//-----------------------------------------------------------------------
+// read
+
+int16 bufRead(Buffer &sb, soundSample &ss) {
+ size_t bread;
+ size_t count = MIN<uint>(sb.wSize, clickSizes[ss.curSeg]);
+ int16 rVal = 0;
+
+ bread = count;
+ memcpy(sb.wData, clickData[ss.curSeg], count);
+ sb.gave(bread);
+
+ VERIFY(bread <= count);
+
+ if (bread == count)
+ rVal |= msgBufferFull;
+ rVal |= msgSegmentEnd;
+ return rVal;
+}
+
+//-----------------------------------------------------------------------
+// flush / close
+
+int16 bufFlush(Buffer &sb, soundSample &ss) {
+ return 0;
+}
+
+} // end of namespace Saga2
diff --git a/engines/saga2/audiores.h b/engines/saga2/audiores.h
new file mode 100644
index 0000000000..3cb6f6bee3
--- /dev/null
+++ b/engines/saga2/audiores.h
@@ -0,0 +1,45 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * aint32 with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Based on the original sources
+ * Faery Tale II -- The Halls of the Dead
+ * (c) 1993-1996 The Wyrmkeep Entertainment Co.
+ */
+
+#ifndef SAGA2_AUDIORES_H
+#define SAGA2_AUDIORES_H
+
+namespace Saga2 {
+
+int16 hResSeek(Buffer &sb, soundSample &ss, hResContext *hrc, bool Cheksize);
+int16 hResRead(Buffer &sb, soundSample &ss, hResContext *hrc);
+int16 hResFlush(Buffer &sb, soundSample &ss, hResContext *hrc);
+
+//-----------------------------------------------------------------------
+// Buffer readers
+
+int16 bufSeek(Buffer &sb, soundSample &ss);
+int16 bufRead(Buffer &sb, soundSample &ss);
+int16 bufFlush(Buffer &sb, soundSample &ss);
+
+} // end of namespace Saga2
+
+#endif
diff --git a/engines/saga2/audiosmp.h b/engines/saga2/audiosmp.h
new file mode 100644
index 0000000000..e65bcec334
--- /dev/null
+++ b/engines/saga2/audiosmp.h
@@ -0,0 +1,208 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Based on the original sources
+ * Faery Tale II -- The Halls of the Dead
+ * (c) 1993-1996 The Wyrmkeep Entertainment Co.
+ */
+
+#ifndef SAGA2_AUDIOSMP_H
+#define SAGA2_AUDIOSMP_H
+
+namespace Saga2 {
+/* ===================================================================== *
+
+ Sound Sample Attributes
+
+ id - resource id, file offset, etc
+ status - processing status
+
+ channels - mono or stereo
+ rate - sampling rate 11K/22K/44K
+ granularity - 8 bit or 16 bit
+
+ flags:
+ looped - keep playing that song Sam
+
+ * ===================================================================== */
+
+#define ENDSAMP 0xFFFFFFFF
+
+typedef uint32 soundSampleID;
+typedef uint32 soundSegment;
+typedef soundSegment *segmentArray;
+typedef int8 Volume;
+typedef Point32 sampleLocation;
+
+enum soundSampleRate {
+ soundRate11K = 11025,
+ soundRate22K = 22050,
+ soundRate44K = 44100,
+};
+
+
+class soundSample { //: private DList
+public:
+ // sampleFlags
+ enum soundSampleStatus {
+ sampleNone,
+ sampleMore,
+ sampleStop,
+ samplePart,
+ sampleDone,
+ sampleKill,
+ };
+
+ enum soundSampleChannels {
+ channelMono,
+ channelStereo,
+ channelLeftOnly,
+ channelRightOnly,
+ };
+
+ enum soundSampleGranularity {
+ granularity8Bit,
+ granularity16Bit,
+ };
+
+
+ // sampleFlags
+ enum soundSampleFlags {
+ sampleLooped = 0x0001,
+ sampleSigned = 0x0002,
+ sampleRvrsed = 0x0004,
+ };
+private:
+ bool initialized;
+ soundSampleChannels defaultChannels;
+ soundSampleRate defaultSpeed;
+ soundSampleGranularity defaultDataSize;
+protected:
+// sampleLocation location;
+ Volume volume;
+
+public:
+ soundSampleChannels channels;
+ soundSampleRate speed;
+ soundSampleGranularity dataSize;
+ uint32 sampleFlags;
+ uint32 loopCount;
+ soundSampleStatus status;
+ soundSegment curSeg;
+ soundSegment headSeg;
+ void *sourceBuffer;
+ decoderSet *decoder;
+ PublicQueue<uint32> segmentList;
+
+ soundSample(soundSegment sa[]); //, sampleLocation pos=Point32( 0, 0 ));
+ soundSample(soundSegment seg); //, sampleLocation pos=Point32( 0, 0 ));
+ virtual ~soundSample();
+ void *operator new (size_t s) {
+ return audioAlloc(s, "audio sample");
+ }
+ void operator delete (void *m) {
+ audioFree(m);
+ }
+
+ soundSample &operator=(const soundSample &src);
+ soundSample(const soundSample &src);
+ bool operator==(const soundSample &src2) const;
+
+ virtual Volume getVolume(void);
+ virtual void setVolume(Volume v);
+
+ virtual void moveTo(Point32) {}
+
+ int init(void) {
+ defaultChannels = channelMono;
+ defaultSpeed = soundRate22K;
+ defaultDataSize = granularity16Bit;
+ initialized = TRUE;
+ return 0;
+ }
+
+ void setDefaultProfile(soundSampleChannels c, soundSampleRate r, soundSampleGranularity g) {
+ if (initialized != TRUE) init();
+ defaultChannels = c;
+ defaultSpeed = r;
+ defaultDataSize = g;
+ }
+
+ soundSampleChannels getDefaultChannels(void) {
+ return defaultChannels;
+ }
+ soundSampleRate getDefaultSpeed(void) {
+ return defaultSpeed;
+ }
+ soundSampleGranularity getDefaultDataSize(void) {
+ return defaultDataSize;
+ }
+
+ uint32 format(void);
+ uint32 flags(void);
+};
+
+/* ===================================================================== *
+ A moving sample class (not currently enabled)
+ * ===================================================================== */
+
+typedef Volume(*audioAttenuationFunction)(sampleLocation loc, Volume maxVol);
+#define ATTENUATOR( name ) Volume name( sampleLocation loc, Volume maxVol )
+typedef Point32 sampleVelocity;
+typedef Point32 sampleAcceleration;
+
+
+class positionedSample : public soundSample {
+ sampleLocation Pos;
+public:
+ positionedSample(soundSegment sa[], sampleLocation pos = Point32(0, 0));
+ positionedSample(soundSegment seg, sampleLocation pos = Point32(0, 0));
+ virtual Volume getVolume(void);
+ void moveTo(Point32 newLoc) {
+ Pos = newLoc;
+ }
+ virtual void setVolume(Volume v);
+
+};
+
+class movingSample : public positionedSample {
+private:
+ sampleLocation Pos;
+ sampleVelocity dPos;
+ sampleAcceleration ddPos;
+ uint32 t0;
+ void updateLocation(void);
+public:
+ movingSample(soundSegment sa[], sampleLocation pos, sampleVelocity vel, sampleAcceleration acc);
+ movingSample(soundSegment seg, sampleLocation pos, sampleVelocity vel, sampleAcceleration acc);
+ ~movingSample() {};
+ void *operator new (size_t s) {
+ return audioAlloc(s, "moving sample");
+ }
+ void operator delete (void *m) {
+ audioFree(m);
+ }
+ Volume getVolume(void);
+};
+
+} // end of namespace Saga2
+
+#endif
diff --git a/engines/saga2/audiosys.h b/engines/saga2/audiosys.h
new file mode 100644
index 0000000000..5dfd929d22
--- /dev/null
+++ b/engines/saga2/audiosys.h
@@ -0,0 +1,380 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Based on the original sources
+ * Faery Tale II -- The Halls of the Dead
+ * (c) 1993-1996 The Wyrmkeep Entertainment Co.
+ */
+
+#ifndef SAGA2_AUDIOSYS_H
+#define SAGA2_AUDIOSYS_H
+
+#include "saga2/audiobuf.h"
+
+namespace Saga2 {
+
+/*******************************************************************/
+/* DRIVERS subdirectory */
+
+#define DRIVER_PATH "DRIVERS"
+#define UNDRIVER_PATH ".."
+
+/*******************************************************************/
+/* typedefs */
+
+typedef Buffer *pSBUFFER;
+typedef positionedSample *pSAMPLE;
+
+/*******************************************************************/
+/* Debug handling */
+
+#define STATUS_MESSAGES DEBUG
+#define ALLOW_MOVING_SAMPLES 0
+#define ZERO_VOLUME_DISABLES 1
+#define ALLOW_AUDIO_RECYCLING 1
+
+
+/*******************************************************************/
+/* Volume controls */
+
+#define Here Point32(0,0)
+
+/*******************************************************************/
+/* Volume controls */
+
+typedef int8 Volume;
+
+enum volumeTarget {
+ volSound = 1L << 0, // sound volume
+ volVoice = 1L << 1, // voice volume
+ volSandV, // sound & voice
+ volLoops = 1L << 2, // looped sounds
+ volSandL, // sound and music
+ volVandL, // voice and music
+ volSVandL, // voice and music
+ volMusic = 1L << 3, // music
+ volSandM, // sound and music
+ volVandM, // voice and music
+ volSVandM, // sound voice and music
+ volLandM, // loops and music
+ volSLandM, // sound loops and music
+ volVLandM, // voice loops and music
+ volAll, // all four
+ volSoundMaster = 1L << 4, // master sound volume level
+ volMusicMaster = 1L << 5, // master music volume level
+};
+
+enum volumeMode {
+ volumeSetTo = 0L, // absolute mode
+ volumeUpDown, // relative mode
+};
+
+/*******************************************************************/
+/* Audio Fade */
+
+struct audioFade {
+ int16 fadeOutTime,
+ fadeInTime, // Actually it starts fading in immediately
+ overlapTime;
+};
+
+
+/*******************************************************************/
+/* Audio Interface Settings */
+
+struct audioInterfaceSettings {
+ int16 soundBuffers; // Buffers aside from Music, Voice & loop buffers
+ uint32 voiceBufferSize; // Size of voice buffer
+ uint32 musicBufferSize; // Size of music buffers
+ uint32 soundBufferSize; // Size of sound effects buffers
+ uint32 loopBufferSize; // Size of looped effect buffer
+
+ audioInterfaceSettings(int16 sb, uint32 vbs, uint32 mbs, uint32 sbs, uint32 lbs) {
+ soundBuffers = sb;
+ voiceBufferSize = vbs;
+ musicBufferSize = mbs;
+ soundBufferSize = sbs;
+ loopBufferSize = lbs;
+ }
+ void *operator new (size_t s) {
+ return audioAlloc(s, "audio settings");
+ }
+ void operator delete (void *m) {
+ audioFree(m);
+ }
+private:
+ audioInterfaceSettings();
+};
+
+
+/*******************************************************************/
+/* */
+/* Audio Interface Class */
+/* */
+/*******************************************************************/
+
+class audioInterface {
+public:
+ enum BufferRequest {
+ requestRecycled = -2L,
+ requestFailed = -1L,
+ requestVoice = 0L,
+ requestMusic0 = 1L,
+ requestMusic1 = 2L,
+ requestLoop = 3L,
+ requestSound0 = 4L,
+ requestSound1 = 5L,
+ requestSound2 = 6L,
+ maxBuffers = 7L,
+ requestMusic = 8L,
+ requestSound = 9L,
+ };
+
+private:
+ enum sampleFlags {
+ sampleClear = 0L,
+ sampleMoving = 1L << 0,
+ sampleQueued = 1L << 1,
+ };
+
+ enum sampleStopLevel {
+ sStopCleanup = 0L,
+ sStopSegment = 1L,
+ sStopSample = 2L,
+ sStopQueue = 3L,
+ };
+
+ enum queueFlags {
+ qrQueueEmpty = 0L,
+ qrBufNotAlloc = 1L,
+ qrSegNotOpen = 2L,
+ qrBufNotReady = 3L,
+ qrWaiting = 4L,
+ qrPlayDone = 5L,
+ qrFinishing = 6L,
+ qrFinished = 7L,
+ qrCleanup = 8L,
+ };
+
+ int16 instance;
+ int16 initialized;
+
+ HTIMER gameTimer;
+
+ soundQueue *queue; // the queue
+ queueFlags queueRes;
+
+ BufferRequest numBuffers;
+
+ int16 flags[maxBuffers];
+ int16 state[maxBuffers];
+ pSBUFFER SampHand[maxBuffers];
+ pSAMPLE samples[maxBuffers];
+ soundSegment lastID[maxBuffers]; // ID of music currently playing
+
+ BufferRequest voiceBuffer; // buffer to feed voice into
+ BufferRequest activeLoop; // currently playing loop
+ BufferRequest activeMusic;
+
+ BufferRequest nextMBuf;
+ soundSegment playing; // ID of music currently playing
+ soundSegment looping; // ID of music currently playing
+
+
+ audioFade fader;
+
+
+ Volume SoundVolume, // Sound Master Volume
+ MusicVolume, // Music Master Volume
+ mVolume, // music volume
+ sVolume, // sound volume
+ vVolume, // voice volume
+ lVolume; // loops volume
+
+ int16 sEnabled, // sound enabled
+ vEnabled, // voice enabled
+ mEnabled, // music enabled
+ lEnabled; // loops enabled
+ bool suspended;
+
+ int32 mQuality; // MIDI driver quality
+ int32 suspendCalls;
+
+public:
+ HDIGDRIVER dig; // AIL sample driver
+ HMDIDRIVER mid; // AIL MIDI driver
+ audioAttenuationFunction attenuator;
+
+
+private:
+ char status[256]; // audio status messages
+ int16 verbosity;
+#if defined(_WIN32) && defined(USE_REAL_WAIL)
+ LPDIRECTSOUND lpDS;
+#endif
+
+public:
+ void *operator new (size_t s) {
+ return audioAlloc(s, "audio interface");
+ }
+ void operator delete (void *m) {
+ audioFree(m);
+ }
+
+ // ctor, dtor, initialization
+ audioInterface(const char *driver_path = DRIVER_PATH, const char *undriver_path = UNDRIVER_PATH);
+ ~audioInterface();
+
+ // init, cleanup
+ void initAudioInterface(audioInterfaceSettings &ais);
+ void cleanupAudioInterface(void);
+
+ // timer calls
+ void adjustGameSpeed(int32 multiplyBy, int32 thenDivideBy);
+ void suspendGameClock(void);
+ void resumeGameClock(void);
+
+ // event loop calls
+ bool playFlag(void);
+ void playMe(void);
+
+ // music calls
+ void queueMusic(soundSegment s, decoderSet *, int16 loopFactor = 1, sampleLocation where = Here);
+ void stopMusic(void);
+ soundSegment currentMusic(void) {
+ return playing; // ID of music currently playing
+ }
+ bool goodMIDICard(void);
+
+ // sound calls
+ void queueSound(soundSegment s, decoderSet *, int16 loopFactor = 1, sampleLocation where = Here);
+ //void queueSoundAt( soundSegment s, decoderSet *, sampleLocation where, int16 loopFactor=1);
+ void queueSoundSample(positionedSample *ss, decoderSet *sDec, int16 loopFactor);
+
+ // loop calls
+ void queueLoop(soundSegment s, decoderSet *sDec, int16 loopFactor = 0, sampleLocation where = Here);
+ //void queueLoopAt( soundSegment s, decoderSet *sDec, sampleLocation where , int16 loopFactor=0 );
+ void queueLoopSample(positionedSample *ss, decoderSet *sDec, int16 loopFactor = 0);
+ void stopLoop(void);
+ void setLoopPosition(sampleLocation newLoc);
+ soundSegment currentLoop(void) {
+ return looping; // ID of music currently playing
+ }
+
+ // voice calls
+ void queueVoice(soundSegment s, decoderSet *, sampleLocation where = Here);
+ void queueVoice(soundSegment s[], decoderSet *, sampleLocation where = Here);
+ void stopVoice(void);
+ void endVoice(sampleStopLevel ssl = sStopCleanup);
+ void resetState(BufferRequest br);
+ bool talking(void);
+ bool saying(soundSegment s);
+
+ // volume and enabled calls
+ bool active(void);
+ bool activeDIG(void) {
+ return dig != NULL;
+ }
+ bool enabled(volumeTarget i);
+ void enable(volumeTarget i, bool onOff);
+ void disable(volumeTarget i) {
+ enable(i, FALSE);
+ }
+ void setVolume(volumeTarget targ, volumeMode op, Volume val);
+ Volume getVolume(volumeTarget src);
+ void setMusicFadeStyle(int16 tOut, int16 tIn, int16 tOver);
+ void suspend(void);
+ void resume(void);
+
+ //debugging calls
+ char *statusMessage(void);
+ void shutoffAudio(void);
+ void setVerbosity(int16 n) {
+ verbosity = n;
+ }
+ int16 getQueueSize(void) {
+ return queue->getSize();
+ }
+
+ // moving sample calls
+ audioAttenuationFunction setAttenuator(audioAttenuationFunction newAF);
+
+
+private:
+ void load_drivers(const char *driver_path = DRIVER_PATH, const char *undriver_path = UNDRIVER_PATH);
+ void load_dig_driver(void);
+ void load_mid_driver(void);
+ bool notEmpty(void);
+ BufferRequest needBuffer(positionedSample *ss, BufferRequest needBufNo);
+ void format(void);
+ void openSample(decoderSet *decList, Buffer *); // open/seek function
+ void closeSample(decoderSet *decList, Buffer *); // close/flush function
+ void playSample(decoderSet *decList, BufferRequest, positionedSample *); // read/load function
+ sampleFlags playQueue(decoderSet *decList, BufferRequest, soundQueue *); // read/load function
+ void playMusic(decoderSet *decList, BufferRequest targBuffer, positionedSample *ss, int16 loopFactor);
+ void makeWriteable(Buffer *sb); // buffer release
+
+ void setSoundMasterVolume(Volume val);
+ void setMusicMasterVolume(Volume val);
+ void setBufferVolume(BufferRequest, Volume val);
+ void setMusicVolume(Volume val);
+ void setSoundVolume(Volume val);
+ void setVoiceVolume(Volume val);
+ void setLoopsVolume(Volume val);
+ inline bool checkMask(volumeTarget t, volumeTarget m, bool e, volumeTarget vtm) {
+ if ((t & m)
+#if ZERO_VOLUME_DISABLES
+ && (getVolume(m) > 0) && (getVolume(vtm) > 0)
+#endif
+ )
+ return e;
+ return TRUE;
+ }
+
+
+ void crossFade(musicBuffer *mbOut, musicBuffer *mbIn);
+ void fadeIn(musicBuffer *mbIn);
+
+ void audioFatalError(char *s);
+ void audioError(char *s);
+ void audioEPrintf(char *s, ...);
+ void audioErrorID(int);
+ void audioStatus(char *s);
+ void audioStatCat(char *s);
+
+ void setSample(BufferRequest sampNo, positionedSample *ss);
+
+#ifdef __WATCOMC__
+#pragma off ( unreferenced ) ;
+#endif
+ static ATTENUATOR(defaultAttenuator) {
+ return maxVol;
+ }
+#ifdef __WATCOMC__
+#pragma on ( unreferenced ) ;
+#endif
+};
+
+void disableAudio(void);
+
+} // end of namespace Saga2
+
+#endif
diff --git a/engines/saga2/audiotmr.cpp b/engines/saga2/audiotmr.cpp
new file mode 100644
index 0000000000..82e099afdc
--- /dev/null
+++ b/engines/saga2/audiotmr.cpp
@@ -0,0 +1,51 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Based on the original sources
+ * Faery Tale II -- The Halls of the Dead
+ * (c) 1993-1996 The Wyrmkeep Entertainment Co.
+ */
+
+#include "saga2/std.h"
+#include "saga2/audio.h"
+
+namespace Saga2 {
+
+volatile int32 bufferState;
+
+#ifdef __WATCOMC__
+#pragma off ( check_stack )
+#endif
+
+#if !defined(_WIN32) || defined(USE_REAL_WAIL)
+TIMERFUNCTION(timerHookFunc) {
+// if ( suspendCalls==0 )
+ gameTime++;
+}
+
+
+TIMERFUNCTION(EOB_callback) {
+ bufferState++;
+}
+
+#endif
+
+} // end of namespace Saga2
diff --git a/engines/saga2/audiotmr.h b/engines/saga2/audiotmr.h
new file mode 100644
index 0000000000..6c20620288
--- /dev/null
+++ b/engines/saga2/audiotmr.h
@@ -0,0 +1,46 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Based on the original sources
+ * Faery Tale II -- The Halls of the Dead
+ * (c) 1993-1996 The Wyrmkeep Entertainment Co.
+ */
+
+#ifndef SAGA2_AUDIOTMR_H
+#define SAGA2_AUDIOTMR_H
+
+namespace Saga2 {
+
+#define TICKSPERSECOND ( 728L/10L )
+
+#define TIMERFUNCTION(name) void name( uint32 user )
+
+/* ===================================================================== *
+ Global game time
+ * ===================================================================== */
+
+extern volatile int32 gameTime;
+
+TIMERFUNCTION(timerHookFunc);
+
+} // end of namespace Saga2
+
+#endif
diff --git a/engines/saga2/audproto.h b/engines/saga2/audproto.h
new file mode 100644
index 0000000000..eb81a7181d
--- /dev/null
+++ b/engines/saga2/audproto.h
@@ -0,0 +1,42 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Based on the original sources
+ * Faery Tale II -- The Halls of the Dead
+ * (c) 1993-1996 The Wyrmkeep Entertainment Co.
+ */
+
+#ifndef SAGA2_AUDPROTO_H
+#define SAGA2_AUDPROTO_H
+
+namespace Saga2 {
+
+// Prototypes
+
+int initAudio(void);
+int startAudio(void);
+HDIGDRIVER &digitalAudioDriver(void);
+void disableAudio(...);
+
+} // end of namespace Saga2
+
+#endif //SAGA2_AUDPROTO_H
+
diff --git a/engines/saga2/audqueue.h b/engines/saga2/audqueue.h
new file mode 100644
index 0000000000..6004f2bb6b
--- /dev/null
+++ b/engines/saga2/audqueue.h
@@ -0,0 +1,67 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Based on the original sources
+ * Faery Tale II -- The Halls of the Dead
+ * (c) 1993-1996 The Wyrmkeep Entertainment Co.
+ */
+
+#ifndef SAGA2_AUDQUEUE_H
+#define SAGA2_AUDQUEUE_H
+
+namespace Saga2 {
+
+class soundQueue {
+public:
+ positionedSample *tip;
+ soundSegment curSeg;
+ soundSegment headSeg;
+private:
+ PublicPtrQueue<positionedSample> sampleList;
+
+public:
+ soundQueue(void) {
+ tip = NULL;
+ }
+ ~soundQueue(void);
+ void *operator new (size_t s) {
+ return audioAlloc(s, "aud smpl queue");
+ }
+ void operator delete (void *m) {
+ audioFree(m);
+ }
+
+ positionedSample *firstSample(void);
+ positionedSample *nextSample(void);
+
+ soundSegment firstSegment(void);
+ soundSegment nextSegment(void);
+
+ void pushSample(positionedSample *sam, decoderSet *);
+ bool findSample(soundSegment s);
+
+ int16 getSize(void);
+ int16 getSampleSize(void);
+};
+
+} // end of namespace Saga2
+
+#endif
diff --git a/engines/saga2/audtweak.h b/engines/saga2/audtweak.h
new file mode 100644
index 0000000000..bbcc0e16b2
--- /dev/null
+++ b/engines/saga2/audtweak.h
@@ -0,0 +1,99 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Based on the original sources
+ * Faery Tale II -- The Halls of the Dead
+ * (c) 1993-1996 The Wyrmkeep Entertainment Co.
+ */
+
+#ifndef SAGA2_AUDTWEAK_H
+#define SAGA2_AUDTWEAK_H
+
+namespace Saga2 {
+
+enum audioTerrains {
+ audioTerrainForest = 1,
+ audioTerrainSurf,
+ audioTerrainCity,
+ audioTerrainCavern,
+ audioTerrainColdWind,
+ audioTerrainJungle,
+ audioTerrainLava,
+ audioTerrainRiver,
+ audioTerrainFire,
+
+ audioTerrainLIMIT,
+};
+
+struct IntermittentAudioRecord {
+ int noSoundOdds;
+ int soundOdds[4];
+};
+
+const IntermittentAudioRecord intermittentAudioRecords[audioTerrainLIMIT] = {
+ //
+ // none 1 2 3 4
+ //
+ { 0, { 0, 0, 0, 0 } }, // no record
+ { 1, { 1, 0, 0, 0 } }, // Forest
+ { 0, { 0, 0, 0, 0 } }, // Surf
+ { 0, { 0, 0, 0, 0 } }, // City
+ { 0, { 0, 0, 0, 0 } }, // Cavern
+ { 0, { 0, 0, 0, 0 } }, // ColdWind
+ { 0, { 0, 0, 0, 0 } }, // Jungle
+ { 0, { 0, 0, 0, 0 } }, // Lava
+ { 0, { 0, 0, 0, 0 } }, // River
+ { 0, { 0, 0, 0, 0 } } // Fire
+};
+
+
+// Factional music mapping
+// Built in factions
+// 0 = suspended
+// 1 = daytime 1
+// 2 = daytime 2
+// 3 = underground
+// 4 = nighttime
+// 5 = aggressive
+// Faction based
+// 6 = faction 0
+// 7 = faction 1
+// etc
+
+inline int8 musicMapping(int16 musicChoice) {
+ if (musicChoice < 1) {
+ return 0;
+ } else if (musicChoice < 6) {
+ return musicChoice;
+ } else if (musicChoice == 6) {
+ return 6;
+ } else if (musicChoice > 11 && musicChoice < 14) {
+ return 7;
+ } else if (musicChoice > 8 && musicChoice < 12) {
+ return 8;
+ } else {
+ return 6;
+ }
+}
+
+} // end of namespace Saga2
+
+#endif
diff --git a/engines/saga2/automap.cpp b/engines/saga2/automap.cpp
new file mode 100644
index 0000000000..65cf4d869c
--- /dev/null
+++ b/engines/saga2/automap.cpp
@@ -0,0 +1,668 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
Commit: 984a6b573965711a00db5fe80dc4012e9225098b
https://github.com/scummvm/scummvm/commit/984a6b573965711a00db5fe80dc4012e9225098b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:44+02:00
Commit Message:
SAGA2: Remove duplicated functions
Changed paths:
engines/saga2/gdraw.cpp
diff --git a/engines/saga2/gdraw.cpp b/engines/saga2/gdraw.cpp
index 0f4cc534be..1596a88078 100644
--- a/engines/saga2/gdraw.cpp
+++ b/engines/saga2/gdraw.cpp
@@ -898,55 +898,6 @@ void gPort::scrollPixels(
}
}
-void gPort::drawTextInBox(
- char *str,
- int16 length,
- const Rect16 &r,
- int16 pos,
- Point16 borders )
-{
- int16 height,width;
- int16 x, y;
- Rect16 newClip,
- saveClip = clip;
-
- if (!font)
- return;
-
- height = font->height;
- width = TextWidth ( font, str, length, textStyles );
-
- if (textStyles & (textStyleUnderScore|textStyleUnderBar))
- {
- if (font->baseLine + 2 >= font->height) height++;
- }
-
- // Calculate x position of text string
-
- if (pos & textPosLeft) x = r.x + borders.x;
- else if (pos & textPosRight) x = r.x + r.width - width - borders.x;
- else x = r.x + (r.width - width) / 2;
-
- // Calculate y position of text string
-
- if (pos & textPosHigh) y = r.y + borders.y;
- else if (pos & textPosLow) y = r.y + r.height - height - borders.y;
- else y = r.y + (r.height - height) / 2;
-
- // Calculate clipping region
-
- clip = intersect( clip, r );
-
- // Draw the text
-
- moveTo( x, y );
- drawText( str, length );
-
- // Restore the clipping region
-
- clip = saveClip;
-}
-
/* ======================================================================= *
Image Mapping
@@ -1086,13 +1037,4 @@ void DisposeTempPort(gPort &port) {
port.map = NULL;
}
-void gPort::drawText(
- char *str, /* string to draw */
- int16 length) {
- if (length < 0) length = strlen( str );
-
- if (length > 0)
- penPos.x += drawClippedString( str, length, penPos.x, penPos.y );
-}
-
} // end of namespace Saga2
Commit: 051e97c36509fb2bf850705793f52c7765634867
https://github.com/scummvm/scummvm/commit/051e97c36509fb2bf850705793f52c7765634867
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:44+02:00
Commit Message:
SAGA2: Unstub initializeGame()
Changed paths:
engines/saga2/mainmap.cpp
engines/saga2/saga2.cpp
diff --git a/engines/saga2/mainmap.cpp b/engines/saga2/mainmap.cpp
index 395520a490..a14532a96e 100644
--- a/engines/saga2/mainmap.cpp
+++ b/engines/saga2/mainmap.cpp
@@ -52,8 +52,10 @@ void cleanupErrorHandlers() {
}
bool initializeGame() {
- warning("STUB: initializeGame()");
- return false;
+ if (setupGame())
+ return TRUE;
+
+ return FALSE;
}
void shutdownGame() {
warning("STUB: shutdownGame");
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index 73330d22da..f30c50ae16 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -71,13 +71,6 @@ Common::Error Saga2Engine::run() {
loadExeResources();
- // Simple main event loop
- Common::Event evt;
- while (!shouldQuit()) {
- g_system->getEventManager()->pollEvent(evt);
- g_system->delayMillis(10);
- }
-
main_saga2();
return Common::kNoError;
Commit: 6c9dc80384eeda37bf3c898d74cbabcfc10ca169
https://github.com/scummvm/scummvm/commit/6c9dc80384eeda37bf3c898d74cbabcfc10ca169
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:44+02:00
Commit Message:
SAGA2: Implement updateLoadMode()
Changed paths:
engines/saga2/loadmsg.cpp
engines/saga2/saga2.cpp
diff --git a/engines/saga2/loadmsg.cpp b/engines/saga2/loadmsg.cpp
index afc5279f4a..053a3735b3 100644
--- a/engines/saga2/loadmsg.cpp
+++ b/engines/saga2/loadmsg.cpp
@@ -26,98 +26,37 @@
#include "saga2/std.h"
-#include "saga2/gdraw.h"
-#include "saga2/vwpage.h"
-#include "saga2/loadmsg.h"
-#include "saga2/palette.h"
-#include "saga2/display.h"
-
+#include "graphics/palette.h"
namespace Saga2 {
-struct wPaletteEntry {
- uint8 r,
- g,
- b,
- pad;
-};
-
-// An entire palette of 256 colors
-
-struct wPalette {
- wPaletteEntry entry[ 256 ];
-};
-
-
-static gPalette normalPalette; // Currently loaded palette
-
-
-void w2gPalette(wPalette *w, gPalette *g) {
- for (int i = 0; i < 256; i++) {
- g->entry[ i ].r = w->entry[i].r >> 2;
- g->entry[ i ].g = w->entry[i].g >> 2;
- g->entry[ i ].b = w->entry[i].b >> 2;
- }
-}
-
-
-void useWPalette(wPalette *wp) {
- w2gPalette(wp, &normalPalette);
- setCurrentPalette(&normalPalette);
-}
-
-
-
-//void usePalette( void *p, size_t s);
-//extern "C" void cdecl _BltPixels( uint8 *srcPtr, uint32 srcMod,
-// uint8 *dstPtr, uint32 dstMod,
-// uint32 width, uint32 height );
-
-extern gDisplayPort mainPort; // default rendering port
-extern uint8 normalPal[1024];
extern uint32 loadingWindowWidth;
extern uint32 loadingWindowHeight;
-extern uint8 loadingWindowData[];
-extern uint8 loadingWindowPalette[];
+extern uint8 *loadingWindowData;
+extern uint8 *loadingWindowPalette;
-int16 showBitmapAtX = 0;
-int16 showBitmapAtY = 0;
-
-gPixelMap mess;
-
-#ifdef _WIN32
-extern CFTWindow *pWindow;
-void displayEventLoop(void);
-#endif
-
-static bool inLoadMode = FALSE;
+static bool inLoadMode = false;
void initLoadMode(void) {
- inLoadMode = TRUE;
+ inLoadMode = true;
}
void updateLoadMode(void) {
if (inLoadMode) {
-#ifdef _WIN32
- resumeDDGraphics();
-#endif
- mess.data = &loadingWindowData[0];
- mess.size.x = loadingWindowWidth;
- mess.size.y = loadingWindowHeight;
- mainPort.bltPixels(mess, 0, 0, showBitmapAtX, showBitmapAtY, loadingWindowWidth, loadingWindowHeight);
-#ifdef _WIN32
- pWindow->Flip();
- //mainPort.bltPixels( mess,0,0,showBitmapAtX,showBitmapAtY,loadingWindowWidth,loadingWindowHeight);
- //pWindow->Flip();
-#endif
- useWPalette((wPalette *) loadingWindowPalette); //normalPal
-#ifdef _WIN32
- suspendDDGraphics();
-#endif
+ byte normalPalette[768];
+
+ for (int i = 0; i < 256; i++) {
+ normalPalette[i * 3 + 0] = loadingWindowPalette[i * 4 + 0];
+ normalPalette[i * 3 + 1] = loadingWindowPalette[i * 4 + 1];
+ normalPalette[i * 3 + 2] = loadingWindowPalette[i * 4 + 2];
+ }
+
+ g_system->getPaletteManager()->setPalette(normalPalette, 0, 256);
+ g_system->copyRectToScreen(loadingWindowData, loadingWindowWidth, 0, 0, loadingWindowWidth, loadingWindowHeight);
}
}
void closeLoadMode(void) {
- inLoadMode = FALSE;
+ inLoadMode = false;
//blackOut();
}
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index f30c50ae16..ce1a501d2b 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -35,6 +35,7 @@
#include "saga2/saga2.h"
#include "saga2/std.h"
+#include "saga2/loadmsg.h"
namespace Saga2 {
@@ -61,7 +62,7 @@ Saga2Engine::~Saga2Engine() {
Common::Error Saga2Engine::run() {
// Initialize graphics using following:
- initGraphics(320, 200);
+ initGraphics(640, 480);
// Additional setup.
debug("Saga2Engine::init");
@@ -71,6 +72,17 @@ Common::Error Saga2Engine::run() {
loadExeResources();
+ loadingScreen();
+
+ // Simple main event loop
+ Common::Event evt;
+ while (!shouldQuit()) {
+ g_system->getEventManager()->pollEvent(evt);
+
+ g_system->updateScreen();
+ g_system->delayMillis(10);
+ }
+
main_saga2();
return Common::kNoError;
Commit: 57b3eb2e2101703be4170584780cf5d9b60bee3f
https://github.com/scummvm/scummvm/commit/57b3eb2e2101703be4170584780cf5d9b60bee3f
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:45+02:00
Commit Message:
SAGA2: Replace one instance of clamp with CLIP
Changed paths:
engines/saga2/calender.cpp
diff --git a/engines/saga2/calender.cpp b/engines/saga2/calender.cpp
index 87db594c56..1889a881e5 100644
--- a/engines/saga2/calender.cpp
+++ b/engines/saga2/calender.cpp
@@ -124,7 +124,7 @@ int CalenderTime::lightLevel(int maxLevel) {
// to framesAtNoon*2/3. Then we clip off the part of the
// curve below zero, and above 1/3, giving 1/3 night,
// 1/6 morning, 1/3 day, and 1/6 evening.
- solarLevel = clamp(globalConfig.showNight ? /* 0 */ (dayBias * 5 / 4) : (framesAtNoon / 3),
+ solarLevel = CLIP(globalConfig.showNight ? /* 0 */ (dayBias * 5 / 4) : (framesAtNoon / 3),
solarAngle * 2 + season - framesAtNoon / 3 + dayBias * 2,
framesAtNoon / 3);
Commit: 18c43a8402370fdd48008a19fe238c6604cd20bc
https://github.com/scummvm/scummvm/commit/18c43a8402370fdd48008a19fe238c6604cd20bc
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:45+02:00
Commit Message:
SAGA2: Support original CD layout for FTA2
Changed paths:
engines/saga2/detection.cpp
engines/saga2/detection.h
engines/saga2/saga2.cpp
diff --git a/engines/saga2/detection.cpp b/engines/saga2/detection.cpp
index a8fafc6d94..d41c01446c 100644
--- a/engines/saga2/detection.cpp
+++ b/engines/saga2/detection.cpp
@@ -68,6 +68,7 @@ static const SAGA2GameDescription gameDescriptions[] = {
{"scripts.hrs", GAME_SCRIPTFILE, "95f33928f6c4f02ee04d2ec5c3314c30", 1041948},
{"ftasound.hrs", GAME_SOUNDFILE, "ce930cb38922e6a03461f55d51b4e165", 12403350},
{"ftaimage.hrs", GAME_IMAGEFILE, "09bb003733b20f924e2e373d2ddcd394", 21127397},
+ {"fta2win.exe", GAME_EXECUTABLE, "9a94854fef932483754a8f929caa0dba", 1093120},
AD_LISTEND
},
Common::EN_ANY,
@@ -81,10 +82,17 @@ static const SAGA2GameDescription gameDescriptions[] = {
};
} // End of namespace Saga2
+static const char *directoryGlobs[] = {
+ "res",
+ "win",
+ 0
+};
+
class Saga2MetaEngineDetection : public AdvancedMetaEngineDetection {
public:
Saga2MetaEngineDetection() : AdvancedMetaEngineDetection(Saga2::gameDescriptions, sizeof(Saga2::SAGA2GameDescription), Saga2::saga2Games) {
- warning("Detection");
+ _maxScanDepth = 2;
+ _directoryGlobs = directoryGlobs;
}
const char *getEngineId() const override {
diff --git a/engines/saga2/detection.h b/engines/saga2/detection.h
index b5dea966cc..74028829b2 100644
--- a/engines/saga2/detection.h
+++ b/engines/saga2/detection.h
@@ -47,7 +47,8 @@ enum GameFileTypes {
GAME_PATCHFILE = 1 << 10, // IHNM patch file (patch.re_/patch.res)
// SAGA 2 (Dinotopia, FTA2)
GAME_IMAGEFILE = 1 << 11, // Game images
- GAME_OBJRESOURCEFILE = 1 << 12 // Game object data
+ GAME_OBJRESOURCEFILE = 1 << 12, // Game object data
+ GAME_EXECUTABLE = 1 << 13
};
struct SAGA2GameDescription {
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index ce1a501d2b..ba4eae1fcc 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -48,6 +48,8 @@ Saga2Engine::Saga2Engine(OSystem *syst)
// Don't forget to register your random source
_rnd = new Common::RandomSource("saga2");
+ SearchMan.addSubDirectoryMatching(gameDataDir, "res");
+
debug("Saga2Engine::Saga2Engine");
}
Commit: 354713cb36b690b602c0a7fb317a0f83e4912c66
https://github.com/scummvm/scummvm/commit/354713cb36b690b602c0a7fb317a0f83e4912c66
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:45+02:00
Commit Message:
SAGA2: Kill file checking routines
Changed paths:
engines/saga2/config.cpp
engines/saga2/config.h
engines/saga2/main.cpp
engines/saga2/towerfta.cpp
engines/saga2/towerfta.h
engines/saga2/towerwin.h
diff --git a/engines/saga2/config.cpp b/engines/saga2/config.cpp
index 431d8d8c3a..83f316f8a8 100644
--- a/engines/saga2/config.cpp
+++ b/engines/saga2/config.cpp
@@ -82,34 +82,6 @@ static void defaultConfig(configuration &config) {
strcpy(config.savedGamePath, ".\\");
}
-//-----------------------------------------------------------------------
-// reads settings from INI file
-
-void readConfig(void) {
- defaultConfig(globalConfig);
-
- globalConfig.musicVolume = GetPrivateProfileInt("Sound", "MusicVolume", 127, iniFile);
- globalConfig.soundVolume = GetPrivateProfileInt("Sound", "SoundVolume", 127, iniFile);
- globalConfig.voiceVolume = GetPrivateProfileInt("Sound", "VoiceVolume", 127, iniFile);
- globalConfig.autoAggression = GetPrivateProfileInt("Options", "AutoAggression", TRUE, iniFile);
- globalConfig.autoWeapon = GetPrivateProfileInt("Options", "AutoWeapon", FALSE, iniFile);
- globalConfig.speechText = GetPrivateProfileInt("Options", "SpeechText", TRUE, iniFile);
- globalConfig.showNight = GetPrivateProfileInt("Options", "Night", TRUE, iniFile);
-#ifdef _WIN32
- globalConfig.windowed = GetPrivateProfileInt("Options", "Windowed", FALSE, iniFile);
-#endif
- GetPrivateProfileString("Paths", "SoundFile", ".\\", globalConfig.soundResfilePath, sizeof(globalConfig.soundResfilePath), iniFile);
- GetPrivateProfileString("Paths", "VoiceFile", ".\\", globalConfig.voiceResfilePath, sizeof(globalConfig.voiceResfilePath), iniFile);
- GetPrivateProfileString("Paths", "ImageFile", ".\\", globalConfig.imageResfilePath, sizeof(globalConfig.imageResfilePath), iniFile);
- GetPrivateProfileString("Paths", "VideoPath", ".\\", globalConfig.videoFilePath, sizeof(globalConfig.videoFilePath), iniFile);
- GetPrivateProfileString("Paths", "MainResFile", ".\\", globalConfig.mainResfilePath, sizeof(globalConfig.mainResfilePath), iniFile);
- GetPrivateProfileString("Paths", "DataFile", ".\\", globalConfig.dataResfilePath, sizeof(globalConfig.dataResfilePath), iniFile);
- GetPrivateProfileString("Paths", "ScriptFile", ".\\", globalConfig.scriptResfilePath, sizeof(globalConfig.scriptResfilePath), iniFile);
- GetPrivateProfileString("Paths", "Saves", ".\\", globalConfig.savedGamePath, sizeof(globalConfig.savedGamePath), iniFile);
- if (globalConfig.savedGamePath[strlen(globalConfig.savedGamePath) - 1] != '\\')
- strcat(globalConfig.savedGamePath, "\\");
-}
-
//-----------------------------------------------------------------------
// saves settings to INI file
diff --git a/engines/saga2/config.h b/engines/saga2/config.h
index c704b9209c..0831c89ec5 100644
--- a/engines/saga2/config.h
+++ b/engines/saga2/config.h
@@ -64,7 +64,6 @@ struct configuration {
FTA2 INI file code
* ===================================================================== */
-void readConfig(void);
void writeConfig(void);
void findProgramDir(char *argv);
void restoreProgramDir(void);
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 98ba9591a2..034d7bd664 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -189,7 +189,6 @@ void SystemKeyHandler(short, short);
void waitForVideoFile(char *fileName);
void memtest(void);
-void readConfig(void);
void runPathFinder(void);
bool setupGame(void);
@@ -813,64 +812,6 @@ void closeResources(void) {
resFile = NULL;
}
-//-----------------------------------------------------------------------
-// Routine to initialize an arbitrary resource file
-
-static bool lookForResource(
- char *basePath, // path to data file
- char *fileName, // file name & extension
- configProblem errID) { // in case something goes wrong
- char filespec[260];
- bool fe;
-
- strncpy(filespec, basePath, 260);
- if (filespec[strlen(filespec) - 1] != '\\')
- strcat(filespec, "\\");
-
- strcat(filespec, fileName);
-
- fe = fileExists(filespec);
-
- while (!fe && retryConfigError(cpResDiskMissing, "Looking for a program data file")) {
- SystemEventLoop();
- fe = fileExists(filespec);
- }
-// (driveInfo(filespec)==driveCDROM) &&
-
- if (!fe) {
- error("lookForResource: %s: %d", filespec, errID);
- return FALSE;
- }
-
- if (!fileReadable(filespec)) {
- error("lookforResource: %s: %d", filespec, cpResFileLocked);
- return FALSE;
- }
-
-
- return TRUE;
-}
-
-//-----------------------------------------------------------------------
-// Routine to initialize all the resource files
-
-bool testResourceConfig(void) {
-
- if (
- lookForResource(globalConfig.imageResfilePath, IMAGE_RESFILE, cpResFileMissing) &&
- lookForResource(globalConfig.mainResfilePath, OBJECT_RESFILE, cpResFileMissing) &&
- lookForResource(globalConfig.dataResfilePath, AUX_RESFILE, cpResFileMissing) &&
- lookForResource(globalConfig.scriptResfilePath, SCRIPT_RESFILE, cpResFileMissing) &&
- lookForResource(globalConfig.voiceResfilePath, VOICE_RESFILE, cpResFileMissing) &&
- lookForResource(globalConfig.soundResfilePath, SOUND_RESFILE, cpResFileMissing)) {
- waitForVideoFile("INTRO.SMK");
- return TRUE;
- }
- return FALSE;
-
-}
-
-
/********************************************************************/
/* */
/* GLOBAL DATA SAVE / RESTORE */
diff --git a/engines/saga2/towerfta.cpp b/engines/saga2/towerfta.cpp
index d7fd32afab..1772944e7c 100644
--- a/engines/saga2/towerfta.cpp
+++ b/engines/saga2/towerfta.cpp
@@ -65,7 +65,6 @@ TowerLayer tower[fullyInitialized] = {
{ errLoggersInitialized, &initErrorLoggers, &termErrorLoggers, cpInternal },
{ breakHandlerInitialized, &initCtlBreakTrap, &termCtlBreakTrap, cpInternal },
{ configTestInitialized, &initSystemConfig, &termTowerBase, cpInternal },
- { configInitialized, &readConfigFile, &termTowerBase, cpInternal },
{ memoryInitialized, &initMemPool, &termMemPool, cpInsufVirtMemFree },
{ graphicsSystemInitialized, &initGraphicsSystem, &termGraphicsSystem, cpDDrawInitFail },
{ videoInitialized, &initVideoPlayer, &termVideoPlayer, cpInternal },
@@ -121,7 +120,6 @@ void cleanupMousePointer(void);
//void mainEnable( void );
//void mainDisable( void );
//void lightsOut( void );
-bool testResourceConfig(void);
void resetInputDevices(void);
#ifdef _WIN32
// void localCursorOn( void );
@@ -185,16 +183,6 @@ INITIALIZER(initSystemConfig) {
// ------------------------------------------------------------------------
-INITIALIZER(readConfigFile) {
- readConfig();
- return testResourceConfig();
- //return TRUE;
-}
-
-// uses null cleanup
-
-// ------------------------------------------------------------------------
-
extern INITIALIZER(initMemPool);
TERMINATOR(termMemPool) {
diff --git a/engines/saga2/towerfta.h b/engines/saga2/towerfta.h
index ed193284bb..aa0d1d861a 100644
--- a/engines/saga2/towerfta.h
+++ b/engines/saga2/towerfta.h
@@ -43,9 +43,6 @@ TERMINATOR(termCtlBreakTrap);
INITIALIZER(initSystemConfig);
// uses null cleanup
-INITIALIZER(readConfigFile);
-// uses null cleanup
-
INITIALIZER(initMemPool);
TERMINATOR(termMemPool);
diff --git a/engines/saga2/towerwin.h b/engines/saga2/towerwin.h
index 6459459107..548f4ef533 100644
--- a/engines/saga2/towerwin.h
+++ b/engines/saga2/towerwin.h
@@ -36,7 +36,6 @@ enum initializationStates {
errLoggersInitialized,
breakHandlerInitialized,
configTestInitialized,
- configInitialized,
delayedErrInitialized,
graphicsSystemInitialized,
procResEnabled,
Commit: 18a51673a2e793050964a2e8ee8aa16384ccb504
https://github.com/scummvm/scummvm/commit/18a51673a2e793050964a2e8ee8aa16384ccb504
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:45+02:00
Commit Message:
SAGA2: Kill graphics/audio init in towerfta.cpp
Changed paths:
engines/saga2/audio.cpp
engines/saga2/noise.cpp
engines/saga2/towerfta.cpp
engines/saga2/towerfta.h
engines/saga2/towerwin.h
diff --git a/engines/saga2/audio.cpp b/engines/saga2/audio.cpp
index a7a385b8cd..e836f8386a 100644
--- a/engines/saga2/audio.cpp
+++ b/engines/saga2/audio.cpp
@@ -29,6 +29,14 @@
namespace Saga2 {
+void initAudio() {
+ warning("STUB: initAudio()");
+}
+
+void cleanupAudio() {
+ warning("STUB: cleanupAudio()");
+}
+
void *audioAlloc(size_t s, char desc[])
{
warning("STUB: audioAlloc()");
diff --git a/engines/saga2/noise.cpp b/engines/saga2/noise.cpp
index 04ac0a6ab8..dbcbaef97b 100644
--- a/engines/saga2/noise.cpp
+++ b/engines/saga2/noise.cpp
@@ -219,50 +219,6 @@ static ATTENUATOR(volumeFromDist) {
Module code
* ===================================================================== */
-//-----------------------------------------------------------------------
-// init - this allocates timers, but no audio
-
-bool initAudio(void) {
- // read audio INI file settings
-#if DEBUG
- debugStatuses = GetPrivateProfileInt("Debug", "Status", 0, iniFile);
- debugResource = GetPrivateProfileInt("Debug", "Resource", 0, iniFile);
- randomAudioTesting = GetPrivateProfileInt("Debug", "AudioStress", 0, iniFile);
- debugAudioThemes = GetPrivateProfileInt("Debug", "AudioThemes", 0, iniFile);
-#endif
-
-
- voiceRes = NULL;
- musicRes = NULL;
- soundRes = NULL;
- loopRes = NULL;
- longRes = NULL;
-
- //allocate primary audio interface
- audio = new audioInterface;
- if (audio == NULL) return FALSE;
-
-
- // check for missing drivers
-#ifndef REQUIRE_AUDIO
- if (audio->dig == NULL && !retryConfigError(cpNoDIGAudioCheck, "Digital sound driver not loaded"))
- return FALSE;
-
- if (audio->mid == NULL && !retryConfigError(cpNoMDIAudioCheck, "MIDI music driver not loaded"))
- return FALSE;
-#else
-#ifndef _WIN32
- REQUIRE(audio->dig, cpNoDIGAudio);
- REQUIRE(audio->mid, cpNoMDIAudio);
- //if ( audio->dig==NULL )
- // return FALSE;
- //if ( audio->mid==NULL )
- // return FALSE;
-#endif
-#endif
- return TRUE;
-}
-
//-----------------------------------------------------------------------
// after system initialization - startup code
@@ -381,34 +337,6 @@ void startAudio(void) {
audio->disable(volSound);
}
-//-----------------------------------------------------------------------
-// cleanup
-
-
-void cleanupAudio(void) {
- if (audio) {
- audio->cleanupAudioInterface();
-
- delete audio;
- audio = NULL;
-
- killIt(clickData[1]);
- killIt(clickData[2]);
-
- killIt(voiceDec);
- killIt(musicDec);
- killIt(soundDec);
- killIt(longSoundDec);
- killIt(loopDec);
- killIt(memDec);
- killIt(musicRes);
- killIt(soundRes);
- killIt(longRes);
- killIt(loopRes);
- killIt(voiceRes);
- }
-}
-
//-----------------------------------------------------------------------
// audio event loop
diff --git a/engines/saga2/towerfta.cpp b/engines/saga2/towerfta.cpp
index 1772944e7c..ab7930de20 100644
--- a/engines/saga2/towerfta.cpp
+++ b/engines/saga2/towerfta.cpp
@@ -70,8 +70,6 @@ TowerLayer tower[fullyInitialized] = {
{ videoInitialized, &initVideoPlayer, &termVideoPlayer, cpInternal },
{ introInitialized, &initPlayIntro, &termPlayOutro, cpInternal },
{ timerInitialized, &initSystemTimer, &termSystemTimer, cpDTimerInitFail },
- { audioInitialized, &initAudio, &termAudio, cpDSoundInitFail },
- { SVGAInitialized, &initGraphics, &termGraphics, cpInternal },
{ resourcesInitialized, &initResourceFiles, &termResourceFiles, cpResFileMissing },
{ serversInitialized, &initResourceServers, &termResourceServers, cpInternal },
{ pathFinderInitialized, &initPathFinders, &termPathFinders, cpInternal },
@@ -232,24 +230,6 @@ TERMINATOR(termSystemTimer) {
}
-// ------------------------------------------------------------------------
-
-extern INITIALIZER(initAudio);
-
-TERMINATOR(termAudio) {
- cleanupAudio();
-}
-
-
-// ------------------------------------------------------------------------
-
-extern INITIALIZER(initGraphics);
-
-TERMINATOR(termGraphics) {
- cleanupGraphics();
-}
-
-
// ------------------------------------------------------------------------
INITIALIZER(initResourceFiles) {
diff --git a/engines/saga2/towerfta.h b/engines/saga2/towerfta.h
index aa0d1d861a..876230bb98 100644
--- a/engines/saga2/towerfta.h
+++ b/engines/saga2/towerfta.h
@@ -58,12 +58,6 @@ TERMINATOR(termPlayOutro);
INITIALIZER(initSystemTimer);
TERMINATOR(termSystemTimer);
-INITIALIZER(initAudio);
-TERMINATOR(termAudio);
-
-INITIALIZER(initGraphics);
-TERMINATOR(termGraphics);
-
INITIALIZER(initResourceFiles);
TERMINATOR(termResourceFiles);
diff --git a/engines/saga2/towerwin.h b/engines/saga2/towerwin.h
index 548f4ef533..37ba6337fc 100644
--- a/engines/saga2/towerwin.h
+++ b/engines/saga2/towerwin.h
@@ -40,9 +40,7 @@ enum initializationStates {
graphicsSystemInitialized,
procResEnabled,
memoryInitialized,
- audioInitialized,
videoInitialized,
- SVGAInitialized,
resourcesInitialized,
serversInitialized,
pathFinderInitialized,
Commit: 5eab675ee712afa173a0f29a642f05fb77d0cd00
https://github.com/scummvm/scummvm/commit/5eab675ee712afa173a0f29a642f05fb77d0cd00
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:45+02:00
Commit Message:
SAGA2: Implement openResources() with Common::File
Changed paths:
engines/saga2/hresmgr.cpp
engines/saga2/hresmgr.h
engines/saga2/main.cpp
engines/saga2/rserver.cpp
engines/saga2/saga2.cpp
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index 745e165f05..695041f01d 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -27,6 +27,7 @@
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/errclass.h"
+#include "common/debug.h"
#include "saga2/hresmgr.h"
@@ -76,6 +77,7 @@ hResContext::hResContext() {
parent = NULL;
data = NULL;
numEntries = 0;
+ handle = &_file;
}
hResContext::hResContext(hResContext *sire, hResID id, const char desc[]) {
@@ -89,6 +91,7 @@ hResContext::hResContext(hResContext *sire, hResID id, const char desc[]) {
numEntries = 0;
bytecount = 0;
bytepos = 0;
+ handle = &_file;
if (!res->valid) return;
@@ -168,19 +171,22 @@ uint32 hResContext::count(hResID id) {
return count;
}
-HR_FILE *hResContext::openExternal(HR_FILE *fh) {
+Common::File *hResContext::openExternal(Common::File *fh) {
char name[160];
int len;
uint16 size;
+ Common::File *file;
+ file = &_file;
bytecount = 0;
bytepos = 0;
strcpy(name, res->externalPath);
len = strlen(name);
- if (HR_READ(&size, sizeof size, 1, fh) != 1) return NULL;
- HR_READ(&name[len], size, 1, fh);
+ size = fh->readUint32LE();
+ fh->read(&name, sizeof(name));
name[len + size] = 0;
- return HR_OPEN(name, "rb");
+ file->open(name);
+ return file;
}
// this function sets handle
@@ -412,6 +418,15 @@ void hResContext::release(RHANDLE p) {
Resource file
* ===================================================================== */
+void hResource::readResource(hResEntry &element) {
+ element.id = _file.readUint32LE();
+ element.offset = _file.readUint32LE();
+ element.size = _file.readUint32LE();
+ uint32 id = element.id;
+ //debug(3, "readResource: id %u, offset %u, size %u", element.id, (uint)element.offset, (uint)element.size);
+ debug(3, "%c%c%c%c, offset: %d, size: %d", (id >> 24), (id >> 16) & 0xFF, (id >> 8) & 0xFF, id & 0xFF, element.offset, element.size);
+}
+
hResource::hResource(char *resname, char *extname, const char desc[]) {
hResEntry origin;
uint32 size;
@@ -427,28 +442,25 @@ hResource::hResource(char *resname, char *extname, const char desc[]) {
strncpy(externalPath, extname ? extname : "", EXTERNAL_PATH_SIZE);
- if ((handle = HR_OPEN(resname, "rb")) == NULL) return;
-
- if (HR_READ(&origin, sizeof origin, 1, handle) != 1) return;
+ _file.open(resname);
+ readResource(origin);
if (origin.id != HRES_ID) return;
- HR_SEEK(handle, origin.offset - sizeof(uint32), SEEK_SET);
- if (HR_READ(&firstGroupOffset, sizeof firstGroupOffset, 1, handle) != 1) {
- return;
- }
+ _file.seek(origin.offset - sizeof(uint32), SEEK_SET);
+ firstGroupOffset = _file.readUint32LE();
// allocate buffers for root, groups and data
- base = (hResEntry *)RNewPtr(origin.resSize(), NULL, desc);
+ base = (hResEntry *)malloc(origin.resSize());
size = origin.offset - firstGroupOffset - sizeof(uint32);
- groups = (hResEntry *)RNewPtr(size, NULL, desc);
+ groups = (hResEntry *)malloc(size);
if (base == NULL || groups == NULL) return;
- if (HR_READ(base, origin.resSize(), 1, handle) != 1) return;
- HR_SEEK(handle, firstGroupOffset, SEEK_SET);
- if (HR_READ(groups, size, 1, handle) != 1) return;
+ readResource(*base);
+ _file.seek(firstGroupOffset, SEEK_SET);
+ readResource(*groups);
res = this;
numEntries = origin.resSize() / sizeof origin;
@@ -456,9 +468,9 @@ hResource::hResource(char *resname, char *extname, const char desc[]) {
}
hResource::~hResource() {
- if (base) RDisposePtr(base);
- if (groups) RDisposePtr(groups);
- if (handle) HR_CLOSE(handle);
+ if (base) free(base);
+ if (groups) free(groups);
+ if (handle) free(handle);
}
hResContext *hResource::newContext(hResID id, const char desc[]) {
diff --git a/engines/saga2/hresmgr.h b/engines/saga2/hresmgr.h
index a2e38978ce..2d30fdd82f 100644
--- a/engines/saga2/hresmgr.h
+++ b/engines/saga2/hresmgr.h
@@ -27,6 +27,8 @@
#ifndef SAGA2_HRESMGR_H
#define SAGA2_HRESMGR_H
+#include "common/file.h"
+
#include "saga2/rmem.h"
#include "saga2/ioerrors.h"
@@ -75,9 +77,8 @@ class hResource;
struct hResEntry {
hResID id; // id of this entry or BAD_ID
- size_t offset; // offset in file
-private:
- size_t size; // size in file
+ uint32 offset; // offset in file
+ uint32 size; // size in file
public:
hResEntry() {
@@ -129,12 +130,13 @@ protected:
hResContext *parent;
hResEntry *base;
RHANDLE *data; // allocated array of handles
- HR_FILE *handle;
+ Common::File _file;
+ Common::File *handle;
uint32 bytecount;
uint32 bytepos;
hResEntry *findEntry(hResID id, RHANDLE **capture = NULL);
- HR_FILE *openExternal(HR_FILE *fh);
+ Common::File *openExternal(Common::File *fh);
public:
bool valid;
@@ -163,7 +165,7 @@ public:
RHANDLE load(hResID id, const char [], bool async = FALSE, bool cacheable = TRUE);
RHANDLE loadIndex(int16 index, const char[], bool cacheable = TRUE);
void release(RHANDLE p);
- HR_FILE *resFileHandle(void) {
+ Common::File *resFileHandle(void) {
return handle;
}
@@ -190,6 +192,7 @@ public:
hResContext *newContext(hResID id, const char []);
void disposeContext(hResContext *con);
+ void readResource(hResEntry &element);
};
/* ===================================================================== *
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 034d7bd664..bc7c9ce1cb 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -736,26 +736,19 @@ static bool openResource(
char *fileName, // file name & extension
char *description, // description of this resource
configProblem errID) { // in case something goes wrong
- char filespec[260];
-
- strncpy(filespec, basePath, 260);
- if (filespec[strlen(filespec) - 1] != '\\')
- strcat(filespec, "\\");
- strcat(filespec, fileName);
-
if (hr) delete hr;
hr = NULL;
- hr = NEW_PRES hResource(filespec, defaultPath, description);
+ hr = NEW_PRES hResource(fileName, defaultPath, description);
while ((hr == NULL || !hr->valid) && retryConfigError(cpResDiskMissing, description)) {
if (hr) delete hr;
hr = NULL;
- hr = NEW_PRES hResource(filespec, defaultPath, description);
+ hr = NEW_PRES hResource(fileName, defaultPath, description);
}
if (hr == NULL || !hr->valid) {
- error("openResource: %s: %d", filespec, errID);
+ error("openResource: %s: %d", fileName, errID);
// return FALSE;
}
return TRUE;
diff --git a/engines/saga2/rserver.cpp b/engines/saga2/rserver.cpp
index 7bb701b375..b058b61949 100644
--- a/engines/saga2/rserver.cpp
+++ b/engines/saga2/rserver.cpp
@@ -165,8 +165,9 @@ void RequestResource(
}
void initServers(void) {
+ warning("STUB: initServers()");
+#if 0
int16 i;
-
resourceServer = NEW_PRES ResourceServer(resFile->resFileHandle());
if (resourceServer == NULL) {
error("Unable to start up resource server!\n");
@@ -175,6 +176,7 @@ void initServers(void) {
for (i = 0; i < numResRequests; i++) {
NEW_PRES ResourceRequest(resourceRequestPool);
}
+#endif
}
void cleanupServers(void) {
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index ba4eae1fcc..c77bb5a676 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -39,6 +39,7 @@
namespace Saga2 {
+bool openResources();
void main_saga2();
Saga2Engine::Saga2Engine(OSystem *syst)
@@ -69,6 +70,8 @@ Common::Error Saga2Engine::run() {
// Additional setup.
debug("Saga2Engine::init");
+ openResources();
+
// Your main even loop should be (invoked from) here.
debug("Saga2Engine::go: Hello, World!");
Commit: 7d0d52ed8e240262ec149538e8ba43507c867fc1
https://github.com/scummvm/scummvm/commit/7d0d52ed8e240262ec149538e8ba43507c867fc1
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:45+02:00
Commit Message:
SAGA2: Update debug channels to include resources
Changed paths:
engines/saga2/detection.cpp
engines/saga2/detection.h
engines/saga2/hresmgr.cpp
engines/saga2/saga2.h
diff --git a/engines/saga2/detection.cpp b/engines/saga2/detection.cpp
index d41c01446c..490837df42 100644
--- a/engines/saga2/detection.cpp
+++ b/engines/saga2/detection.cpp
@@ -20,10 +20,15 @@
*
*/
+#include "saga2/saga2.h"
+#include "saga2/detection.h"
#include "base/plugins.h"
#include "engines/advancedDetector.h"
-#include "saga2/detection.h"
+static const DebugChannelDef debugFlagList[] = {
+ {Saga2::kDebugResources, "Resources", "Debug the resources"},
+ DEBUG_CHANNEL_END
+};
namespace Saga2 {
static const PlainGameDescriptor saga2Games[] = {
@@ -106,6 +111,10 @@ public:
const char *getOriginalCopyright() const override {
return "SAGA2 (C) Wyrmkeep Entertainment";
}
+
+ const DebugChannelDef *getDebugChannels() const override {
+ return debugFlagList;
+ }
};
REGISTER_PLUGIN_STATIC(SAGA2_DETECTION, PLUGIN_TYPE_ENGINE_DETECTION, Saga2MetaEngineDetection);
diff --git a/engines/saga2/detection.h b/engines/saga2/detection.h
index 74028829b2..771b6ad564 100644
--- a/engines/saga2/detection.h
+++ b/engines/saga2/detection.h
@@ -23,6 +23,8 @@
#ifndef SAGA2_DETECTION_H
#define SAGA2_DETECTION_H
+#include "advancedDetector.h"
+
namespace Saga2 {
enum GameIds {
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index 695041f01d..582d60ae4b 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -25,13 +25,12 @@
*/
#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/rmemfta.h"
#include "saga2/errclass.h"
-#include "common/debug.h"
-
#include "saga2/hresmgr.h"
-
#include "saga2/fta.h"
+#include "common/debug.h"
namespace Saga2 {
@@ -423,8 +422,7 @@ void hResource::readResource(hResEntry &element) {
element.offset = _file.readUint32LE();
element.size = _file.readUint32LE();
uint32 id = element.id;
- //debug(3, "readResource: id %u, offset %u, size %u", element.id, (uint)element.offset, (uint)element.size);
- debug(3, "%c%c%c%c, offset: %d, size: %d", (id >> 24), (id >> 16) & 0xFF, (id >> 8) & 0xFF, id & 0xFF, element.offset, element.size);
+ debugC(kDebugResources, "%s, offset: %d, size: %d", tag2str(id), element.offset, element.size);
}
hResource::hResource(char *resname, char *extname, const char desc[]) {
diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h
index fee007c10f..9f46d2ff32 100644
--- a/engines/saga2/saga2.h
+++ b/engines/saga2/saga2.h
@@ -34,6 +34,10 @@ namespace Saga2 {
class Console;
+enum {
+ kDebugResources = 1 << 0,
+};
+
class Saga2Engine : public Engine {
private:
// We need random numbers
Commit: 25df9a7570248d569309007fcf9b77078137e412
https://github.com/scummvm/scummvm/commit/25df9a7570248d569309007fcf9b77078137e412
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:45+02:00
Commit Message:
SAGA2: Make some code agree with conventions
Changed paths:
engines/saga2/hresmgr.cpp
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index 582d60ae4b..acca16d749 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -68,57 +68,54 @@ extern char *idname(long s);
* ===================================================================== */
hResContext::hResContext() {
-#if DEBUG
- strncpy(description, "NULL context", 32);
-#endif
- valid = FALSE;
- base = NULL;
- parent = NULL;
- data = NULL;
+ valid = false;
+ base = nullptr;
+ parent = nullptr;
+ data = nullptr;
numEntries = 0;
handle = &_file;
}
hResContext::hResContext(hResContext *sire, hResID id, const char desc[]) {
hResEntry *entry;
-#if DEBUG
- strncpy(description, desc, 32);
-#endif
- valid = FALSE;
+ valid = false;
res = sire->res;
numEntries = 0;
bytecount = 0;
bytepos = 0;
handle = &_file;
- if (!res->valid) return;
+ if (!res->valid)
+ return;
parent = sire;
- if ((entry = parent->findEntry(id)) == NULL) return;
+ if ((entry = parent->findEntry(id)) == nullptr)
+ return;
numEntries = entry->resSize() / sizeof * entry;
base = (hResEntry *)((uint8 *)res->groups +
(entry->offset - res->firstGroupOffset));
- data = (RHANDLE *)RNewClearPtr(numEntries * sizeof(RHANDLE), NULL, desc);
- if (data == NULL) return;
+ data = (RHANDLE *)malloc(numEntries * sizeof(RHANDLE));
+ if (data == nullptr)
+ return;
- valid = TRUE;
+ valid = true;
}
hResContext::~hResContext() {
if (data) {
if (valid) {
for (int i = 0; i < numEntries; i++) {
- RDisposeHandle(data[ i ]);
- data[i] = NULL;
+ free(data[ i ]);
+ data[i] = nullptr;
}
}
- RDisposePtr(data);
- data = NULL;
+ free(data);
+ data = nullptr;
}
}
@@ -128,7 +125,7 @@ hResEntry *hResContext::findEntry(hResID id, RHANDLE **capture) {
bytecount = 0;
bytepos = 0;
- if (!valid) return NULL;
+ if (!valid) return nullptr;
for (i = 0, entry = base; i < numEntries; i++, entry++) {
if (entry->id == id) {
@@ -137,7 +134,7 @@ hResEntry *hResContext::findEntry(hResID id, RHANDLE **capture) {
}
}
- return NULL;
+ return nullptr;
}
uint32 hResContext::size(hResID id) {
@@ -145,7 +142,7 @@ uint32 hResContext::size(hResID id) {
if (!valid) return 0;
- if ((entry = findEntry(id)) == NULL) return 0;
+ if ((entry = findEntry(id)) == nullptr) return 0;
return entry->resSize();
}
@@ -195,9 +192,9 @@ bool hResContext::seek(hResID id) {
bytecount = 0;
bytepos = 0;
- if (!valid) return FALSE;
+ if (!valid) return false;
- if ((entry = findEntry(id)) == NULL) return FALSE;
+ if ((entry = findEntry(id)) == nullptr) return false;
bytecount = entry->resSize();
bytepos = entry->resOffset();
@@ -209,12 +206,12 @@ bool hResContext::seek(hResID id) {
// resource data is actually a path name
handle = openExternal(res->handle);
- return (handle != NULL);
+ return (handle != nullptr);
}
handle = res->handle;
- return TRUE;
+ return true;
}
void hResContext::rest(void) {
@@ -222,12 +219,12 @@ void hResContext::rest(void) {
bytepos = 0;
if (valid && handle && handle != res->handle) {
HR_CLOSE(handle);
- handle = NULL;
+ handle = nullptr;
}
}
bool hResContext::read(void *buffer, int32 size) {
- if (!valid) return FALSE;
+ if (!valid) return false;
bytecount = 0;
bytepos = 0;
return (HR_READ(buffer, size, 1, handle) == 1);
@@ -250,25 +247,25 @@ uint32 hResContext::readbytes(void *buffer, uint32 size) {
}
bool hResContext::skip(int32 amount) {
- if (!valid) return FALSE;
+ if (!valid) return false;
HR_SEEK(res->handle, amount, SEEK_CUR);
bytecount -= amount;
bytepos -= amount;
- return TRUE;
+ return true;
}
bool hResContext::get(hResID id, void *buffer, int32 size) {
- bool result = FALSE;
+ bool result = false;
- if (!valid) return FALSE;
+ if (!valid) return false;
bytecount = 0;
bytepos = 0;
if (size == NATURAL_SIZE) {
hResEntry *entry;
- if ((entry = findEntry(id)) == NULL) return FALSE;
+ if ((entry = findEntry(id)) == nullptr) return false;
size = entry->resSize();
}
@@ -286,25 +283,27 @@ RHANDLE hResContext::load(hResID id, const char desc[], bool async, bool cacheab
hResEntry *entry;
RHANDLE *capture;
- if (!valid) return FALSE;
+ if (!valid)
+ return nullptr;
bytecount = 0;
bytepos = 0;
- if ((entry = findEntry(id, &capture)) == NULL) return FALSE;
+ if ((entry = findEntry(id, &capture)) == nullptr)
+ return nullptr;
- if (*capture != NULL && **capture != NULL) {
+ if (*capture != nullptr && **capture != nullptr) {
RLockHandle(*capture);
entry->use();
} else {
- if (*capture == NULL)
- *capture = RNewHandle(entry->resSize(), NULL, desc);
+ if (*capture == nullptr)
+ *capture = RNewHandle(entry->resSize(), nullptr, desc);
else {
- if (RAllocHandleData(*capture, entry->resSize(), desc) == NULL)
- return NULL;
+ if (RAllocHandleData(*capture, entry->resSize(), desc) == nullptr)
+ return nullptr;
}
- if (*capture == NULL) return NULL;
+ if (*capture == nullptr) return nullptr;
RLockHandle(*capture);
if (cacheable)
@@ -313,14 +312,14 @@ RHANDLE hResContext::load(hResID id, const char desc[], bool async, bool cacheab
// If it's an external resource, then load synchronously
#ifdef WINKLUDGE
- async = FALSE;
+ async = false;
#endif
- if (entry->isExternal() || async == FALSE) {
+ if (entry->isExternal() || async == false) {
if (seek(id) && read(**capture, entry->resSize())) {
entry->use();
} else {
RDisposeHandle(*capture);
- *capture = NULL;
+ *capture = nullptr;
}
rest();
@@ -342,23 +341,24 @@ RHANDLE hResContext::loadIndex(int16 index, const char desc[], bool cacheable) {
hResEntry *entry;
RHANDLE *capture; //, handle;
- if (!valid) return FALSE;
+ if (!valid)
+ return nullptr;
bytecount = 0;
bytepos = 0;
entry = &base[ index ];
capture = &data[ index ];
- if (*capture != NULL && **capture != NULL) {
+ if (*capture != nullptr && **capture != nullptr) {
RLockHandle(*capture);
entry->use();
} else {
- if (*capture == NULL)
- *capture = RNewHandle(entry->resSize(), NULL, desc);
+ if (*capture == nullptr)
+ *capture = RNewHandle(entry->resSize(), nullptr, desc);
else
RAllocHandleData(*capture, entry->resSize(), desc);
- if (*capture == NULL) return NULL;
+ if (*capture == nullptr) return nullptr;
RLockHandle(*capture);
if (cacheable)
@@ -366,9 +366,9 @@ RHANDLE hResContext::loadIndex(int16 index, const char desc[], bool cacheable) {
HR_SEEK(res->handle, entry->resOffset(), SEEK_SET);
- if (read(**capture, entry->resSize()) == FALSE) {
+ if (read(**capture, entry->resSize()) == false) {
RDisposeHandle(*capture);
- *capture = NULL;
+ *capture = nullptr;
}
entry->use();
rest();
@@ -384,7 +384,7 @@ void hResContext::release(RHANDLE p) {
hResEntry *entry;
RHANDLE *d;
- if (valid && p != NULL) {
+ if (valid && p != nullptr) {
entry = base;
d = data;
@@ -398,7 +398,7 @@ void hResContext::release(RHANDLE p) {
entry->abandon();
if (!entry->isUsed()) {
RDisposeHandle(p);
- *d = NULL;
+ *d = nullptr;
}
return;
}
@@ -432,10 +432,10 @@ hResource::hResource(char *resname, char *extname, const char desc[]) {
strncpy(description, desc, 32);
#endif
- valid = FALSE;
- base = NULL;
- parent = NULL;
- data = NULL;
+ valid = false;
+ base = nullptr;
+ parent = nullptr;
+ data = nullptr;
numEntries = 0;
strncpy(externalPath, extname ? extname : "", EXTERNAL_PATH_SIZE);
@@ -454,7 +454,7 @@ hResource::hResource(char *resname, char *extname, const char desc[]) {
size = origin.offset - firstGroupOffset - sizeof(uint32);
groups = (hResEntry *)malloc(size);
- if (base == NULL || groups == NULL) return;
+ if (base == nullptr || groups == nullptr) return;
readResource(*base);
_file.seek(firstGroupOffset, SEEK_SET);
@@ -462,7 +462,7 @@ hResource::hResource(char *resname, char *extname, const char desc[]) {
res = this;
numEntries = origin.resSize() / sizeof origin;
- valid = TRUE;
+ valid = true;
}
hResource::~hResource() {
@@ -474,8 +474,8 @@ hResource::~hResource() {
hResContext *hResource::newContext(hResID id, const char desc[]) {
hResContext *result;
- result = NEW_PRES hResContext(this, id, desc);
- if (result == NULL || !result->valid) {
+ result = new hResContext(this, id, desc);
+ if (result == nullptr || !result->valid) {
#if DEBUG
error("Error accessing resource group %s.", idname(id));
#else
@@ -497,12 +497,12 @@ void hResource::disposeContext(hResContext *con) {
//-----------------------------------------------------------------------
// For handles which have been purged, but the handle structure is
// still hanging around, we can free the handle structure and
-// set the actual handle pointer to NULL.
+// set the actual handle pointer to nullptr.
void washHandle(RHANDLE &handle) {
- if (handle != NULL && *handle == NULL) {
+ if (handle != nullptr && *handle == nullptr) {
RDisposeHandle(handle);
- handle = NULL;
+ handle = nullptr;
}
}
Commit: 055e58738a41d2ec8135545c2d2b091af98830e9
https://github.com/scummvm/scummvm/commit/055e58738a41d2ec8135545c2d2b091af98830e9
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:45+02:00
Commit Message:
SAGA2: Rename resource class names according to conventions
Changed paths:
engines/saga2/hresmgr.cpp
engines/saga2/hresmgr.h
engines/saga2/main.cpp
engines/saga2/objects.cpp
engines/saga2/patrol.cpp
engines/saga2/speldata.cpp
engines/saga2/sprite.cpp
engines/saga2/towerfta.cpp
engines/saga2/weapons.cpp
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index acca16d749..921b3683ad 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -34,10 +34,6 @@
namespace Saga2 {
-#if DEBUG
-extern char *idname(long s);
-#endif
-
/* ===================================================================== *
Calls which do disk access
bool hResContext::seek(hResID id)
@@ -68,54 +64,54 @@ extern char *idname(long s);
* ===================================================================== */
hResContext::hResContext() {
- valid = false;
- base = nullptr;
- parent = nullptr;
- data = nullptr;
- numEntries = 0;
- handle = &_file;
+ _valid = false;
+ _base = nullptr;
+ _parent = nullptr;
+ _data = nullptr;
+ _numEntries = 0;
+ _handle = &_file;
}
hResContext::hResContext(hResContext *sire, hResID id, const char desc[]) {
hResEntry *entry;
- valid = false;
- res = sire->res;
- numEntries = 0;
- bytecount = 0;
- bytepos = 0;
- handle = &_file;
+ _valid = false;
+ _res = sire->_res;
+ _numEntries = 0;
+ _bytecount = 0;
+ _bytepos = 0;
+ _handle = &_file;
- if (!res->valid)
+ if (!_res->_valid)
return;
- parent = sire;
+ _parent = sire;
- if ((entry = parent->findEntry(id)) == nullptr)
+ if ((entry = _parent->findEntry(id)) == nullptr)
return;
- numEntries = entry->resSize() / sizeof * entry;
+ _numEntries = entry->resSize() / sizeof * entry;
- base = (hResEntry *)((uint8 *)res->groups +
- (entry->offset - res->firstGroupOffset));
+ _base = (hResEntry *)((uint8 *)_res->groups +
+ (entry->offset - _res->firstGroupOffset));
- data = (RHANDLE *)malloc(numEntries * sizeof(RHANDLE));
- if (data == nullptr)
+ _data = (RHANDLE *)malloc(_numEntries * sizeof(RHANDLE));
+ if (_data == nullptr)
return;
- valid = true;
+ _valid = true;
}
hResContext::~hResContext() {
- if (data) {
- if (valid) {
- for (int i = 0; i < numEntries; i++) {
- free(data[ i ]);
- data[i] = nullptr;
+ if (_data) {
+ if (_valid) {
+ for (int i = 0; i < _numEntries; i++) {
+ free(_data[ i ]);
+ _data[i] = nullptr;
}
}
- free(data);
- data = nullptr;
+ free(_data);
+ _data = nullptr;
}
}
@@ -123,13 +119,13 @@ hResEntry *hResContext::findEntry(hResID id, RHANDLE **capture) {
hResEntry *entry;
int16 i;
- bytecount = 0;
- bytepos = 0;
- if (!valid) return nullptr;
+ _bytecount = 0;
+ _bytepos = 0;
+ if (!_valid) return nullptr;
- for (i = 0, entry = base; i < numEntries; i++, entry++) {
+ for (i = 0, entry = _base; i < _numEntries; i++, entry++) {
if (entry->id == id) {
- if (capture) *capture = &data[ i ];
+ if (capture) *capture = &_data[ i ];
return entry;
}
}
@@ -140,7 +136,7 @@ hResEntry *hResContext::findEntry(hResID id, RHANDLE **capture) {
uint32 hResContext::size(hResID id) {
hResEntry *entry;
- if (!valid) return 0;
+ if (!_valid) return 0;
if ((entry = findEntry(id)) == nullptr) return 0;
@@ -148,7 +144,7 @@ uint32 hResContext::size(hResID id) {
}
uint32 hResContext::count(void) {
- return numEntries;
+ return _numEntries;
}
uint32 hResContext::count(hResID id) {
@@ -156,11 +152,11 @@ uint32 hResContext::count(hResID id) {
hResEntry *entry;
int16 i;
- bytecount = 0;
- bytepos = 0;
- if (!valid) return 0;
+ _bytecount = 0;
+ _bytepos = 0;
+ if (!_valid) return 0;
- for (i = 0, entry = base; i < numEntries; i++, entry++) {
+ for (i = 0, entry = _base; i < _numEntries; i++, entry++) {
if ((entry->id & 0x00ffffff) == (id & 0x00ffffff)) count++;
}
@@ -174,9 +170,9 @@ Common::File *hResContext::openExternal(Common::File *fh) {
Common::File *file;
file = &_file;
- bytecount = 0;
- bytepos = 0;
- strcpy(name, res->externalPath);
+ _bytecount = 0;
+ _bytepos = 0;
+ strcpy(name, _res->externalPath);
len = strlen(name);
size = fh->readUint32LE();
fh->read(&name, sizeof(name));
@@ -185,82 +181,82 @@ Common::File *hResContext::openExternal(Common::File *fh) {
return file;
}
-// this function sets handle
+// this function sets _handle
bool hResContext::seek(hResID id) {
hResEntry *entry;
- bytecount = 0;
- bytepos = 0;
- if (!valid) return false;
+ _bytecount = 0;
+ _bytepos = 0;
+ if (!_valid) return false;
if ((entry = findEntry(id)) == nullptr) return false;
- bytecount = entry->resSize();
- bytepos = entry->resOffset();
+ _bytecount = entry->resSize();
+ _bytepos = entry->resOffset();
- if (HR_SEEK(res->handle, bytepos, SEEK_SET) != 0)
+ if (HR_SEEK(_res->_handle, _bytepos, SEEK_SET) != 0)
error("Error seeking resource file:\n");
if (entry->isExternal()) {
- // resource data is actually a path name
+ // resource _data is actually a path name
- handle = openExternal(res->handle);
- return (handle != nullptr);
+ _handle = openExternal(_res->_handle);
+ return (_handle != nullptr);
}
- handle = res->handle;
+ _handle = _res->_handle;
return true;
}
void hResContext::rest(void) {
- bytecount = 0;
- bytepos = 0;
- if (valid && handle && handle != res->handle) {
- HR_CLOSE(handle);
- handle = nullptr;
+ _bytecount = 0;
+ _bytepos = 0;
+ if (_valid && _handle && _handle != _res->_handle) {
+ HR_CLOSE(_handle);
+ _handle = nullptr;
}
}
bool hResContext::read(void *buffer, int32 size) {
- if (!valid) return false;
- bytecount = 0;
- bytepos = 0;
- return (HR_READ(buffer, size, 1, handle) == 1);
+ if (!_valid) return false;
+ _bytecount = 0;
+ _bytepos = 0;
+ return (HR_READ(buffer, size, 1, _handle) == 1);
}
bool hResContext::eor(void) {
- return (bytecount < 1);
+ return (_bytecount < 1);
}
uint32 hResContext::readbytes(void *buffer, uint32 size) {
int32 bytesRead;
- if (!valid || bytecount < 1) return 0;
+ if (!_valid || _bytecount < 1) return 0;
- if (HR_SEEK(res->handle, bytepos, SEEK_SET) != 0)
+ if (HR_SEEK(_res->_handle, _bytepos, SEEK_SET) != 0)
error("Error seeking resource file:");
- bytesRead = HR_READ(buffer, 1, MIN(size, bytecount), handle);
- bytecount -= bytesRead;
- bytepos += bytesRead;
+ bytesRead = HR_READ(buffer, 1, MIN(size, _bytecount), _handle);
+ _bytecount -= bytesRead;
+ _bytepos += bytesRead;
return bytesRead;
}
bool hResContext::skip(int32 amount) {
- if (!valid) return false;
+ if (!_valid) return false;
- HR_SEEK(res->handle, amount, SEEK_CUR);
- bytecount -= amount;
- bytepos -= amount;
+ HR_SEEK(_res->_handle, amount, SEEK_CUR);
+ _bytecount -= amount;
+ _bytepos -= amount;
return true;
}
bool hResContext::get(hResID id, void *buffer, int32 size) {
bool result = false;
- if (!valid) return false;
- bytecount = 0;
- bytepos = 0;
+ if (!_valid) return false;
+ _bytecount = 0;
+ _bytepos = 0;
if (size == NATURAL_SIZE) {
hResEntry *entry;
@@ -283,10 +279,10 @@ RHANDLE hResContext::load(hResID id, const char desc[], bool async, bool cacheab
hResEntry *entry;
RHANDLE *capture;
- if (!valid)
+ if (!_valid)
return nullptr;
- bytecount = 0;
- bytepos = 0;
+ _bytecount = 0;
+ _bytepos = 0;
if ((entry = findEntry(id, &capture)) == nullptr)
return nullptr;
@@ -339,15 +335,15 @@ RHANDLE hResContext::load(hResID id, const char desc[], bool async, bool cacheab
RHANDLE hResContext::loadIndex(int16 index, const char desc[], bool cacheable) {
hResEntry *entry;
- RHANDLE *capture; //, handle;
+ RHANDLE *capture; //, _handle;
- if (!valid)
+ if (!_valid)
return nullptr;
- bytecount = 0;
- bytepos = 0;
+ _bytecount = 0;
+ _bytepos = 0;
- entry = &base[ index ];
- capture = &data[ index ];
+ entry = &_base[ index ];
+ capture = &_data[ index ];
if (*capture != nullptr && **capture != nullptr) {
RLockHandle(*capture);
@@ -364,7 +360,7 @@ RHANDLE hResContext::loadIndex(int16 index, const char desc[], bool cacheable) {
if (cacheable)
RCacheHandle(*capture);
- HR_SEEK(res->handle, entry->resOffset(), SEEK_SET);
+ HR_SEEK(_res->_handle, entry->resOffset(), SEEK_SET);
if (read(**capture, entry->resSize()) == false) {
RDisposeHandle(*capture);
@@ -377,23 +373,18 @@ RHANDLE hResContext::loadIndex(int16 index, const char desc[], bool cacheable) {
}
void hResContext::release(RHANDLE p) {
-// if (p) RUnlockHandle( p ); // make movable, cacheable
- bytecount = 0;
- bytepos = 0;
+ _bytecount = 0;
+ _bytepos = 0;
hResEntry *entry;
RHANDLE *d;
- if (valid && p != nullptr) {
- entry = base;
- d = data;
+ if (_valid && p != nullptr) {
+ entry = _base;
+ d = _data;
while (entry->id != BAD_ID) {
if ((RHANDLE)p == *d) {
-#if DEBUG
- if (entry->useCount() > 32)
- throw gError("Suspicious usage count!\n");
-#endif
entry->abandon();
if (!entry->isUsed()) {
@@ -405,11 +396,6 @@ void hResContext::release(RHANDLE p) {
entry++;
d++;
}
-
-//#define fatal throw gError
-
-// fatal( "RESOURCE RELEASE PROBLEM\n" );
-
}
}
@@ -428,15 +414,12 @@ void hResource::readResource(hResEntry &element) {
hResource::hResource(char *resname, char *extname, const char desc[]) {
hResEntry origin;
uint32 size;
-#if DEBUG
- strncpy(description, desc, 32);
-#endif
- valid = false;
- base = nullptr;
- parent = nullptr;
- data = nullptr;
- numEntries = 0;
+ _valid = false;
+ _base = nullptr;
+ _parent = nullptr;
+ _data = nullptr;
+ _numEntries = 0;
strncpy(externalPath, extname ? extname : "", EXTERNAL_PATH_SIZE);
@@ -448,39 +431,35 @@ hResource::hResource(char *resname, char *extname, const char desc[]) {
_file.seek(origin.offset - sizeof(uint32), SEEK_SET);
firstGroupOffset = _file.readUint32LE();
- // allocate buffers for root, groups and data
+ // allocate buffers for root, groups and _data
- base = (hResEntry *)malloc(origin.resSize());
+ _base = (hResEntry *)malloc(origin.resSize());
size = origin.offset - firstGroupOffset - sizeof(uint32);
groups = (hResEntry *)malloc(size);
- if (base == nullptr || groups == nullptr) return;
+ if (_base == nullptr || groups == nullptr) return;
- readResource(*base);
+ readResource(*_base);
_file.seek(firstGroupOffset, SEEK_SET);
readResource(*groups);
- res = this;
- numEntries = origin.resSize() / sizeof origin;
- valid = true;
+ _res = this;
+ _numEntries = origin.resSize() / sizeof origin;
+ _valid = true;
}
hResource::~hResource() {
- if (base) free(base);
+ if (_base) free(_base);
if (groups) free(groups);
- if (handle) free(handle);
+ if (_handle) free(_handle);
}
hResContext *hResource::newContext(hResID id, const char desc[]) {
hResContext *result;
result = new hResContext(this, id, desc);
- if (result == nullptr || !result->valid) {
-#if DEBUG
- error("Error accessing resource group %s.", idname(id));
-#else
+ if (result == nullptr || !result->_valid) {
error("Error accessing resource group.");
-#endif
}
return result;
}
diff --git a/engines/saga2/hresmgr.h b/engines/saga2/hresmgr.h
index 2d30fdd82f..c2e56dea2d 100644
--- a/engines/saga2/hresmgr.h
+++ b/engines/saga2/hresmgr.h
@@ -122,31 +122,28 @@ public:
class hResContext {
protected:
-#if DEBUG
- char description[32];
-#endif
- uint16 numEntries;
- hResource *res;
- hResContext *parent;
- hResEntry *base;
- RHANDLE *data; // allocated array of handles
+ uint16 _numEntries;
+ hResource *_res;
+ hResContext *_parent;
+ hResEntry *_base;
+ RHANDLE *_data; // allocated array of handles
Common::File _file;
- Common::File *handle;
- uint32 bytecount;
- uint32 bytepos;
+ Common::File *_handle;
+ uint32 _bytecount;
+ uint32 _bytepos;
hResEntry *findEntry(hResID id, RHANDLE **capture = NULL);
Common::File *openExternal(Common::File *fh);
public:
- bool valid;
+ bool _valid;
hResContext();
hResContext(hResContext *sire, hResID id, const char []);
~hResContext();
uint32 getResID(void) {
- return base->id;
+ return _base->id;
}
uint32 size(hResID id);
@@ -157,7 +154,7 @@ public:
uint32 readbytes(void *buffer, uint32 size);
bool eor(void);
inline size_t bytesleft(void) {
- return bytecount;
+ return _bytecount;
}
bool read(void *buffer, int32 size);
bool skip(int32 amount);
@@ -166,11 +163,11 @@ public:
RHANDLE loadIndex(int16 index, const char[], bool cacheable = TRUE);
void release(RHANDLE p);
Common::File *resFileHandle(void) {
- return handle;
+ return _handle;
}
RHANDLE dataHandle(int16 index) {
- return data[ index ];
+ return _data[ index ];
}
};
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index bc7c9ce1cb..b089688d00 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -741,13 +741,13 @@ static bool openResource(
hr = NEW_PRES hResource(fileName, defaultPath, description);
- while ((hr == NULL || !hr->valid) && retryConfigError(cpResDiskMissing, description)) {
+ while ((hr == NULL || !hr->_valid) && retryConfigError(cpResDiskMissing, description)) {
if (hr) delete hr;
hr = NULL;
hr = NEW_PRES hResource(fileName, defaultPath, description);
}
- if (hr == NULL || !hr->valid) {
+ if (hr == NULL || !hr->_valid) {
error("openResource: %s: %d", fileName, errID);
// return FALSE;
}
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 39c0306eb1..779698ebcc 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -2676,7 +2676,7 @@ void initObjectSoundFXTable(void) {
itemRes = auxResFile->newContext(
RES_ID('I', 'T', 'E', 'M'),
"item resources");
- if (itemRes == NULL || !itemRes->valid)
+ if (itemRes == NULL || !itemRes->_valid)
error("Error accessing item resource group.\n");
objectSoundFXTable =
diff --git a/engines/saga2/patrol.cpp b/engines/saga2/patrol.cpp
index 8d1eca25af..56cc6a34d4 100644
--- a/engines/saga2/patrol.cpp
+++ b/engines/saga2/patrol.cpp
@@ -261,7 +261,7 @@ void initPatrolRoutes(void) {
patrolRouteRes = auxResFile->newContext(
RES_ID('P', 'T', 'R', 'L'),
"patrol route resource");
- if (patrolRouteRes == NULL || !patrolRouteRes->valid)
+ if (patrolRouteRes == NULL || !patrolRouteRes->_valid)
error("Error accessing patrol route resource group.");
// Allocate the patrol route list array
diff --git a/engines/saga2/speldata.cpp b/engines/saga2/speldata.cpp
index e41bb1ad9f..1211ebb20a 100644
--- a/engines/saga2/speldata.cpp
+++ b/engines/saga2/speldata.cpp
@@ -196,7 +196,7 @@ static void loadMagicData(void) {
spellRes = auxResFile->newContext(
RES_ID('S', 'P', 'E', 'L'),
"spell resources");
- if (spellRes == NULL || !spellRes->valid)
+ if (spellRes == NULL || !spellRes->_valid)
error("Error accessing spell resource group.\n");
i = 1;
ADD_SHOW(eAreaInvisible, 0, 0, 0, 0, diFlagInc, ecFlagNone, 30, RES_ID('S', 'T', 'A', 0), 23, 24);
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index 0036731b0e..cc9fa6c0d1 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -738,17 +738,17 @@ void initSprites(void) {
int i;
spriteRes = resFile->newContext(spriteGroupID, "sprite resources");
- if (!spriteRes->valid)
+ if (!spriteRes->_valid)
error("Error accessing sprite resource group.");
frameRes = resFile->newContext(frameGroupID, "frame resources");
- VERIFY(frameRes && frameRes->valid);
+ VERIFY(frameRes && frameRes->_valid);
poseRes = resFile->newContext(poseGroupID, "pose resources");
- VERIFY(poseRes && poseRes->valid);
+ VERIFY(poseRes && poseRes->_valid);
schemeRes = resFile->newContext(schemeGroupID, "scheme resources");
- VERIFY(schemeRes && schemeRes->valid);
+ VERIFY(schemeRes && schemeRes->_valid);
// object sprites
objectSprites = (SpriteSet **)spriteRes->load(objectSpriteID, "object sprites");
diff --git a/engines/saga2/towerfta.cpp b/engines/saga2/towerfta.cpp
index ab7930de20..1151f9137f 100644
--- a/engines/saga2/towerfta.cpp
+++ b/engines/saga2/towerfta.cpp
@@ -292,10 +292,10 @@ TERMINATOR(termAudioChannels) {
INITIALIZER(initResourceHandles) {
tileRes = resFile->newContext(RES_ID('T', 'I', 'L', 'E'), "tile resources");
- if (!tileRes->valid)
+ if (!tileRes->_valid)
return FALSE;
listRes = objResFile->newContext(RES_ID('L', 'I', 'S', 'T'), "list resources");
- if (!listRes->valid)
+ if (!listRes->_valid)
return FALSE;
resImports = (ResImportTable *)LoadResource(listRes, RES_ID('I', 'M', 'P', 'O'), "res imports");
if (!resImports)
diff --git a/engines/saga2/weapons.cpp b/engines/saga2/weapons.cpp
index d35e928cd2..ef311edc08 100644
--- a/engines/saga2/weapons.cpp
+++ b/engines/saga2/weapons.cpp
@@ -317,7 +317,7 @@ static void loadWeaponData(void) {
spellRes = auxResFile->newContext(
RES_ID('I', 'T', 'E', 'M'),
"weapon resources");
- if (spellRes == NULL || !spellRes->valid)
+ if (spellRes == NULL || !spellRes->_valid)
error("Error accessing weapon resource group.");
// get spell effects
Commit: dd18bce54517d16904cfcc0085903951d2898744
https://github.com/scummvm/scummvm/commit/dd18bce54517d16904cfcc0085903951d2898744
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:45+02:00
Commit Message:
SAGA2: Switch memory routines for portable ones
Changed paths:
engines/saga2/hresmgr.cpp
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index 921b3683ad..4b2792605e 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -288,23 +288,13 @@ RHANDLE hResContext::load(hResID id, const char desc[], bool async, bool cacheab
return nullptr;
if (*capture != nullptr && **capture != nullptr) {
- RLockHandle(*capture);
-
entry->use();
} else {
if (*capture == nullptr)
- *capture = RNewHandle(entry->resSize(), nullptr, desc);
- else {
- if (RAllocHandleData(*capture, entry->resSize(), desc) == nullptr)
- return nullptr;
- }
+ *capture = (RHANDLE)malloc(entry->resSize());
if (*capture == nullptr) return nullptr;
- RLockHandle(*capture);
- if (cacheable)
- RCacheHandle(*capture);
-
// If it's an external resource, then load synchronously
#ifdef WINKLUDGE
@@ -314,7 +304,7 @@ RHANDLE hResContext::load(hResID id, const char desc[], bool async, bool cacheab
if (seek(id) && read(**capture, entry->resSize())) {
entry->use();
} else {
- RDisposeHandle(*capture);
+ free(*capture);
*capture = nullptr;
}
@@ -346,24 +336,17 @@ RHANDLE hResContext::loadIndex(int16 index, const char desc[], bool cacheable) {
capture = &_data[ index ];
if (*capture != nullptr && **capture != nullptr) {
- RLockHandle(*capture);
entry->use();
} else {
if (*capture == nullptr)
- *capture = RNewHandle(entry->resSize(), nullptr, desc);
- else
- RAllocHandleData(*capture, entry->resSize(), desc);
+ *capture = (RHANDLE)malloc(entry->resSize());
if (*capture == nullptr) return nullptr;
- RLockHandle(*capture);
- if (cacheable)
- RCacheHandle(*capture);
-
- HR_SEEK(_res->_handle, entry->resOffset(), SEEK_SET);
+ _res->_handle->seek(entry->resOffset(), SEEK_SET);
if (read(**capture, entry->resSize()) == false) {
- RDisposeHandle(*capture);
+ free(*capture);
*capture = nullptr;
}
entry->use();
Commit: 5497cdf89c9feb0a4413ac01d8f8dfaff2ee984b
https://github.com/scummvm/scummvm/commit/5497cdf89c9feb0a4413ac01d8f8dfaff2ee984b
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:46+02:00
Commit Message:
SAGA2: Clean up main.cpp a bit
Changed paths:
engines/saga2/main.cpp
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index b089688d00..b42c96fdec 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -81,10 +81,10 @@ extern char commandLineHelp[];
* ===================================================================== */
// command line options
-bool cliWriteStatusF = FALSE;
-bool cliScriptDebug = FALSE;
-bool cliSpeechText = FALSE;
-bool cliDrawInv = FALSE;
+bool cliWriteStatusF = false;
+bool cliScriptDebug = false;
+bool cliSpeechText = false;
+bool cliDrawInv = false;
uint32 cliMemory = 0;
// User-interface variables
@@ -96,14 +96,13 @@ gMousePointer pointer(mainPort); // the actual pointer
BackWindow *mainWindow; // main window...
// Memory allocation heap
-RHeapPtr gameHeap;
long memorySize = 8000000L;
// Global game state
-bool gameRunning = TRUE; // true while game running
-bool allPlayerActorsDead = FALSE;
-//bool graphicsInit = FALSE; // TRUE if graphics init OK
-bool checkExit = FALSE; // true while game running
+bool gameRunning = true; // true while game running
+bool allPlayerActorsDead = false;
+//bool graphicsInit = false; // true if graphics init OK
+bool checkExit = false; // true while game running
int gameKiller = 0; // will contain the exception that ends the game
// Resource files
@@ -126,10 +125,10 @@ uint16 writeStatusFY = 354;
* ===================================================================== */
// game states
-static bool cleanExit = TRUE;
-bool gameInitialized = FALSE; // true when game initialized
-bool fullInitialized = FALSE;
-bool delayReDraw = FALSE;
+static bool cleanExit = true;
+bool gameInitialized = false; // true when game initialized
+bool fullInitialized = false;
+bool delayReDraw = false;
// main heap
static uint8 *heapMemory;
@@ -205,7 +204,7 @@ void updateMouse(void);
void WriteStatusF2(int16 line, char *msg, ...);
bool initUserDialog(void);
void cleanupUserDialog(void);
-int16 OptionsDialog(bool disableSaveResume = FALSE);
+int16 OptionsDialog(bool disableSaveResume = false);
static void mainLoop(bool &cleanExit, int argc, char *argv[]);
void displayUpdate(void);
@@ -221,13 +220,7 @@ void updatePerfStats(void);
void termFaultHandler(void);
MAIN_RETURN_TYPE main_saga2() {
- gameInitialized = FALSE;
-
-#if DEBUG
- SureLogMessager slm = SureLogMessager("Timing", "TIMING.LOG", (int16) 0, (SureLogMessager::logOpenFlags)(SureLogMessager::logOpenAppend | SureLogMessager::logTimeStamp));
- slm("Program Entry");
-#endif
-
+ gameInitialized = false;
mainDisable();
initCleanup();
@@ -240,40 +233,18 @@ MAIN_RETURN_TYPE main_saga2() {
gameInitialized = initializeGame();
cleanExit = gameInitialized;
-#if DEBUG
- slm("Initialization Complete");
-#endif
if (gameInitialized) {
-
- // Fault handling wrapper
-#if DEBUG
-#else
OSExceptBlk {
-#endif
-
-
- mainLoop(cleanExit, 0, NULL);
-
-
-#if DEBUG
-#else
- }
- OSExcepTrap {
- cleanExit = FALSE;
- OSExceptHnd;
- }
-#endif
+ mainLoop(cleanExit, 0, NULL);
+ }
+ OSExcepTrap {
+ cleanExit = false;
+ OSExceptHnd;
+ }
}
-#if DEBUG
- slm("Shutting Down");
-#endif
shutdownGame();
- gameInitialized = FALSE;
-
-#if DEBUG
- slm("Program Exit");
-#endif
+ gameInitialized = false;
if (cleanExit)
exitMain;
@@ -292,8 +263,8 @@ static void mainLoop(bool &cleanExit, int argc, char *argv[]) {
if (displayEnabled())
displayUpdate();
checkRestartGame(exeFile);
- fullInitialized = TRUE;
- EventLoop(gameRunning, FALSE);
+ fullInitialized = true;
+ EventLoop(gameRunning, false);
}
/********************************************************************/
@@ -332,7 +303,7 @@ void cleanupGame(void) {
/* */
/********************************************************************/
-void processEventLoop(bool updateScreen = TRUE);
+void processEventLoop(bool updateScreen = true);
//-----------------------------------------------------------------------
// Main loop
@@ -357,7 +328,7 @@ void processEventLoop(bool updateScreen) {
statusshow("checking for exceptions");
if (FatalErrorFlag()) {
- //gameRunning=FALSE;
+ //gameRunning=false;
endGame();
return;
}
@@ -365,7 +336,7 @@ void processEventLoop(bool updateScreen) {
statusshow("checking user abort");
breakEventLoop();
if (checkExit && verifyUserExit()) { //( SystemError::SystemErrorRetry(cpUserAbort,"")!=0 ) )
- //gameRunning=FALSE;
+ //gameRunning=false;
endGame();
return;
}
@@ -407,14 +378,9 @@ void processEventLoop(bool updateScreen) {
}
if (allPlayerActorsDead) {
- allPlayerActorsDead = FALSE;
+ allPlayerActorsDead = false;
setLostroMode();
}
-
-#if DEBUG
- statusshow("mem integrity update");
- RMemIntegrity();
-#endif
}
void displayUpdate(void) {
@@ -506,7 +472,7 @@ bool readCommandLine(int argc, char *argv[]) {
//SystemError::useHandler(&cmdLineFatal);
parseCommandLine(argc, argv);
- return TRUE;
+ return true;
//SystemError::useHandler(NULL);
}
@@ -689,7 +655,7 @@ void *LoadResource(hResContext *con, uint32 id, const char desc[]) {
}
// Allocate the buffer
- buffer = (uint8 *)RNewPtr(size, NULL, desc);
+ buffer = (uint8 *)malloc(size);
con->read(buffer, size);
con->rest();
@@ -749,9 +715,9 @@ static bool openResource(
if (hr == NULL || !hr->_valid) {
error("openResource: %s: %d", fileName, errID);
-// return FALSE;
+// return false;
}
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -781,9 +747,9 @@ bool openResources(void) {
openResource(soundResFile, globalConfig.soundResfilePath,
"..\\sound\\", SOUND_RESFILE,
"Sound resource file", cpResFileMissing)) {
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
@@ -844,14 +810,14 @@ struct GlobalsArchive {
void initGlobals(void) {
objectIndex = 0;
actorIndex = 0;
- brotherBandingEnabled = TRUE;
- centerActorIndicatorEnabled = FALSE;
- interruptableMotionsPaused = FALSE;
- objectStatesPaused = FALSE;
- actorStatesPaused = FALSE;
- actorTasksPaused = FALSE;
- combatBehaviorEnabled = FALSE;
- backgroundSimulationPaused = FALSE;
+ brotherBandingEnabled = true;
+ centerActorIndicatorEnabled = false;
+ interruptableMotionsPaused = false;
+ objectStatesPaused = false;
+ actorStatesPaused = false;
+ actorTasksPaused = false;
+ combatBehaviorEnabled = false;
+ backgroundSimulationPaused = false;
}
//-----------------------------------------------------------------------
@@ -908,10 +874,10 @@ void loadGlobals(SaveFileReader &saveGame) {
bool verifyUserExit(void) {
if (!gameRunning)
- return TRUE;
+ return true;
if (SystemError::SystemErrorRetry(cpUserAbort, "") != 0)
- return TRUE;
- return FALSE;
+ return true;
+ return false;
}
//-----------------------------------------------------------------------
@@ -932,29 +898,13 @@ bool initGUIMessagers(void) {
sprintf(debItem, "Status%1.1d", i);
Status[i] = NEW_MSGR StatusLineMessager(debItem, i, &mainPort);
if (Status[i] == NULL)
- return FALSE;
+ return false;
sprintf(debItem, "Status%2.2d", i + 10);
Status2[i] = NEW_MSGR StatusLineMessager(debItem, i, &mainPort, 468, 21 + (11 * i));
}
for (int j = 0; j < 3; j++)
ratemess[j] = NEW_MSGR StatusLineMessager("FrameRates", j, &mainPort, 5, 450 + (11 * j), 500);
-#if DEBUG
- startLogging();
-
- // REM: At this point we can show error messages on-screen
-
- WriteStatusF(0, "-0-");
- WriteStatusF(1, "-1-");
- WriteStatusF(2, "-2-");
- WriteStatusF(3, "-3-");
- WriteStatusF(4, "-4-");
- WriteStatusF(5, "-5-");
- WriteStatusF(6, "-6-");
- WriteStatusF(7, "-7-");
- WriteStatusF(8, "-8-");
- WriteStatusF(9, "-9-");
-#endif
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -969,9 +919,6 @@ void cleanupMessagers(void) {
// cleanup visual messagers
void cleanupGUIMessagers(void) {
-#if DEBUG
- stopLogging();
-#endif
for (int i = 0; i < 10; i++) {
if (Status[i]) delete Status[i];
Status[i] = NULL;
@@ -1058,7 +1005,7 @@ void memoryFatal(char *msg, ...) {
if (wdm) delete wdm;
if (mm) delete mm;
RShowMem();
- //gameRunning=FALSE;
+ //gameRunning=false;
endGame();
}
@@ -1116,20 +1063,8 @@ void oldUpdatePerfStats(void) {
lastL = l;
}
}
-
-#if DEBUG
- if (gameHeap->free != prevMem) {
- prevMem = gameHeap->free;
- WriteStatusF(0, "Mem Free: %8.8d", gameHeap->free);
- }
-#endif
eloopsPerSecond = int(l);
framesPerSecond = int(f);
-#if DEBUG
- WriteStatusF2(0, "Loops /Sec: %4.2f", l);
- WriteStatusF2(1, "Frames/Sec: %4.2f", f);
-#endif
-
}
@@ -1185,10 +1120,9 @@ bool initMemPool(void) {
uint32 take = pickHeapSize(memorySize);
memorySize = take;
if (NULL == (heapMemory = (uint8 *)malloc(take)))
- return FALSE;
- gameHeap = RNewHeap(heapMemory, take);
+ return false;
//initMemHandler();
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -1196,9 +1130,10 @@ bool initMemPool(void) {
void cleanupMemPool(void) {
//clearMemHandler();
- if (gameHeap) RDisposeHeap(gameHeap);
- if (heapMemory) free(heapMemory);
- heapMemory = NULL;
+ if (heapMemory) {
+ free(heapMemory);
+ heapMemory = nullptr;
+ }
}
//-----------------------------------------------------------------------
@@ -1207,7 +1142,7 @@ void cleanupMemPool(void) {
void *mustAlloc(uint32 size, const char desc[]) {
void *ptr;
- ptr = RNewPtr(size, gameHeap, desc);
+ ptr = malloc(size);
// REM: Before we give up completely, try unloading some things...
if (ptr == NULL)
error("Local heap allocation size %d bytes failed.", size);
@@ -1220,24 +1155,13 @@ void *mustAlloc(uint32 size, const char desc[]) {
RHANDLE mustAllocHandle(uint32 size, const char desc[]) {
void **ptr;
- ptr = RNewHandle(size, gameHeap, desc);
+ ptr = (void **)malloc(size);
// REM: Before we give up completely, try unloading some things...
if (ptr == NULL)
error("Local handle allocation size %d bytes failed.", size);
return ptr;
}
-//-----------------------------------------------------------------------
-// throws an exception if passed a NULL pointer. Used for testing
-// memory allocations.
-
-#if 0
-void checkAlloc(void *ptr) {
- // REM: Before we give up completely, try unloading some things...
- if (ptr == NULL)
- error("Object allocation failed.");
-}
-#endif
/********************************************************************/
/* */
@@ -1250,7 +1174,7 @@ extern "C" {
void breakEventKludge(void) {
if (verifyUserExit())
endGame();
- //gameRunning=FALSE;
+ //gameRunning=false;
}
}
Commit: 1cce8104b11972025c17beaacb762b0a64cef3d2
https://github.com/scummvm/scummvm/commit/1cce8104b11972025c17beaacb762b0a64cef3d2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:46+02:00
Commit Message:
SAGA2: Fixed a few warnings
Changed paths:
engines/saga2/objproto.h
diff --git a/engines/saga2/objproto.h b/engines/saga2/objproto.h
index 90f570a4fd..bd28a1b489 100644
--- a/engines/saga2/objproto.h
+++ b/engines/saga2/objproto.h
@@ -1056,8 +1056,8 @@ public:
class ProjectileProto : public WeaponProto {
public:
- ProjectileProto(ResourceObjectPrototype &proto) :
- WeaponProto(proto) {}
+ ProjectileProto(ResourceObjectPrototype &proto) : WeaponProto(proto) {}
+ virtual ~ProjectileProto() {}
// return the address of the sprite when held in hand
virtual Sprite *getOrientedSprite(GameObject *obj, int16 offset);
@@ -1085,6 +1085,7 @@ public:
class ArrowProto : public ProjectileProto {
public:
ArrowProto(ResourceObjectPrototype &proto) : ProjectileProto(proto) {}
+ virtual ~ArrowProto() {}
virtual bool useOnAction(ObjectID dObj, ObjectID enactor, ObjectID item);
virtual bool strikeAction(
@@ -1111,6 +1112,7 @@ public:
class ArmorProto : public InventoryProto {
public:
ArmorProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {}
+ virtual ~ArmorProto() {}
virtual uint16 containmentSet(void);
@@ -1137,6 +1139,7 @@ public:
class ShieldProto : public InventoryProto {
public:
ShieldProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {}
+ virtual ~ShieldProto() {}
virtual uint16 containmentSet(void);
@@ -1192,6 +1195,7 @@ public:
class ToolProto : public InventoryProto {
public:
ToolProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {}
+ virtual ~ToolProto() {}
// Set up targeting cursor
virtual bool setUseCursor(ObjectID dObj);
@@ -1210,6 +1214,7 @@ public:
class DocumentProto : public InventoryProto {
public:
DocumentProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {}
+ virtual ~DocumentProto() {}
virtual uint16 containmentSet(void);
@@ -1232,6 +1237,7 @@ public:
class BookProto : public DocumentProto {
public:
BookProto(ResourceObjectPrototype &proto) : DocumentProto(proto) {}
+ virtual ~BookProto() {}
//Read It
virtual bool useAction(ObjectID dObj, ObjectID enactor);
@@ -1247,6 +1253,7 @@ public:
class ScrollProto : public DocumentProto {
public:
ScrollProto(ResourceObjectPrototype &proto) : DocumentProto(proto) {}
+ virtual ~ScrollProto() {}
//Read It
virtual bool useAction(ObjectID dObj, ObjectID enactor);
@@ -1263,6 +1270,7 @@ public:
class AutoMapProto : public InventoryProto {
public:
AutoMapProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {}
+ virtual ~AutoMapProto() {}
//Shows Auto Map Display
virtual bool openAction(ObjectID dObj, ObjectID enactor);
@@ -1279,6 +1287,7 @@ public:
class IntangibleObjProto : public ProtoObj {
public:
IntangibleObjProto(ResourceObjectPrototype &proto) : ProtoObj(proto) {}
+ virtual ~IntangibleObjProto() {}
virtual bool useAction(ObjectID dObj, ObjectID enactor);
@@ -1320,6 +1329,7 @@ public:
class IdeaProto : public IntangibleObjProto {
public:
IdeaProto(ResourceObjectPrototype &proto) : IntangibleObjProto(proto) {}
+ virtual ~IdeaProto() {}
//Talk To A Person
uint16 containmentSet(void);
@@ -1336,6 +1346,7 @@ public:
class MemoryProto : public IntangibleObjProto {
public:
MemoryProto(ResourceObjectPrototype &proto) : IntangibleObjProto(proto) {}
+ virtual ~MemoryProto() {}
//Get Info On Person Your Talking To
uint16 containmentSet(void);
@@ -1352,6 +1363,7 @@ public:
class PsychProto : public IntangibleObjProto {
public:
PsychProto(ResourceObjectPrototype &proto) : IntangibleObjProto(proto) {}
+ virtual ~PsychProto() {}
//Get Explanation Of Icon
uint16 containmentSet(void);
@@ -1370,6 +1382,7 @@ public:
class SkillProto : public IntangibleObjProto {
public:
SkillProto(ResourceObjectPrototype &proto) : IntangibleObjProto(proto) {}
+ virtual ~SkillProto() {}
//Perform A Skill or Cast a spell
virtual bool useAction(ObjectID dObj, ObjectID enactor);
@@ -1418,6 +1431,7 @@ public:
class IntangibleContainerProto : public ProtoObj {
public:
IntangibleContainerProto(ResourceObjectPrototype &proto) : ProtoObj(proto) {}
+ virtual ~IntangibleContainerProto() {}
virtual bool canContain(ObjectID dObj, ObjectID item);
virtual bool useAction(ObjectID dObj, ObjectID enactor);
@@ -1440,6 +1454,7 @@ public:
class IdeaContainerProto : public IntangibleContainerProto {
public:
IdeaContainerProto(ResourceObjectPrototype &proto) : IntangibleContainerProto(proto) {}
+ virtual ~IdeaContainerProto() {}
//Holding Idea Objects
// bool use( ObjectID dObj, ObjectID enactor );
@@ -1456,6 +1471,7 @@ public:
class MemoryContainerProto : public IntangibleContainerProto {
public:
MemoryContainerProto(ResourceObjectPrototype &proto) : IntangibleContainerProto(proto) {}
+ virtual ~MemoryContainerProto() {}
//Holding Memories Of People You Met
// bool use( ObjectID dObj, ObjectID enactor );
@@ -1471,9 +1487,8 @@ public:
class PsychContainerProto : public IntangibleContainerProto {
public:
- PsychContainerProto(ResourceObjectPrototype &proto) : IntangibleContainerProto(proto) {
-
- }
+ PsychContainerProto(ResourceObjectPrototype &proto) : IntangibleContainerProto(proto) {}
+ virtual ~PsychContainerProto() {}
//Holding Psychological Objects
// bool use( ObjectID dObj, ObjectID enactor );
@@ -1490,6 +1505,7 @@ public:
class SkillContainerProto : public IntangibleContainerProto {
public:
SkillContainerProto(ResourceObjectPrototype &proto) : IntangibleContainerProto(proto) {}
+ virtual ~SkillContainerProto() {}
//Holding Skills And Spells
// bool use( ObjectID dObj, ObjectID enactor );
@@ -1506,6 +1522,7 @@ public:
class MindContainerProto : public IntangibleContainerProto {
public:
MindContainerProto(ResourceObjectPrototype &proto) : IntangibleContainerProto(proto) {}
+ virtual ~MindContainerProto() {}
//Contains Skill Psych Memory And Idea Containers
// virtual bool use( ObjectID dObj, ObjectID enactor );
@@ -1522,6 +1539,7 @@ public:
class EnchantmentProto : public ProtoObj {
public:
EnchantmentProto(ResourceObjectPrototype &proto) : ProtoObj(proto) {}
+ virtual ~EnchantmentProto() {}
// Do the background processing, if needed, for this object.
void doBackgroundUpdate(GameObject *obj);
@@ -1539,6 +1557,7 @@ public:
class GeneratorProto : public ProtoObj {
public:
GeneratorProto(ResourceObjectPrototype &proto) : ProtoObj(proto) {}
+ virtual ~GeneratorProto() {}
//Base class for monster, encounter, and mission generators
@@ -1555,6 +1574,7 @@ public:
class MonsterGeneratorProto : public GeneratorProto {
public:
MonsterGeneratorProto(ResourceObjectPrototype &proto) : GeneratorProto(proto) {}
+ virtual ~MonsterGeneratorProto() {}
//Monster generators
// REM: We don't want to generate monsters as a background activity, since
@@ -1572,6 +1592,7 @@ public:
class EncounterGeneratorProto : public GeneratorProto {
public:
EncounterGeneratorProto(ResourceObjectPrototype &proto) : GeneratorProto(proto) {}
+ virtual ~EncounterGeneratorProto() {}
//Encounter generator
@@ -1589,6 +1610,7 @@ public:
class MissionGeneratorProto : public GeneratorProto {
public:
MissionGeneratorProto(ResourceObjectPrototype &proto) : GeneratorProto(proto) {}
+ virtual ~MissionGeneratorProto() {}
// Check every 10 seconds to see if we want to generate a mission.
void doBackgroundUpdate(GameObject *obj);
Commit: 95057bdc18efc49d202747399d434f5133ef56dc
https://github.com/scummvm/scummvm/commit/95057bdc18efc49d202747399d434f5133ef56dc
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:46+02:00
Commit Message:
SAGA2: Read category from resource
Changed paths:
engines/saga2/hresmgr.cpp
engines/saga2/hresmgr.h
engines/saga2/main.cpp
engines/saga2/saga2.cpp
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index 4b2792605e..c73da2521e 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -92,8 +92,8 @@ hResContext::hResContext(hResContext *sire, hResID id, const char desc[]) {
_numEntries = entry->resSize() / sizeof * entry;
- _base = (hResEntry *)((uint8 *)_res->groups +
- (entry->offset - _res->firstGroupOffset));
+ _base = (hResEntry *)((uint8 *)_res->_groups +
+ (entry->offset - _res->_firstGroupOffset));
_data = (RHANDLE *)malloc(_numEntries * sizeof(RHANDLE));
if (_data == nullptr)
@@ -123,12 +123,16 @@ hResEntry *hResContext::findEntry(hResID id, RHANDLE **capture) {
_bytepos = 0;
if (!_valid) return nullptr;
+ debugC(kDebugResources, "findEntry: looking for %d (%s)", id, tag2str(id));
for (i = 0, entry = _base; i < _numEntries; i++, entry++) {
+ debugC(kDebugResources, "%d: Trying ID: %d (%s)", i, entry->id, tag2str(entry->id));
if (entry->id == id) {
if (capture) *capture = &_data[ i ];
+ debugC(kDebugResources, "findEntry: found %d (%s)", entry->id, tag2str(entry->id));
return entry;
}
}
+ debugC(kDebugResources, "findEntry: No entry found");
return nullptr;
}
@@ -136,9 +140,11 @@ hResEntry *hResContext::findEntry(hResID id, RHANDLE **capture) {
uint32 hResContext::size(hResID id) {
hResEntry *entry;
- if (!_valid) return 0;
+ if (!_valid)
+ return 0;
- if ((entry = findEntry(id)) == nullptr) return 0;
+ if ((entry = findEntry(id)) == nullptr)
+ return 0;
return entry->resSize();
}
@@ -172,7 +178,7 @@ Common::File *hResContext::openExternal(Common::File *fh) {
_bytecount = 0;
_bytepos = 0;
- strcpy(name, _res->externalPath);
+ strcpy(name, _res->_externalPath);
len = strlen(name);
size = fh->readUint32LE();
fh->read(&name, sizeof(name));
@@ -195,8 +201,7 @@ bool hResContext::seek(hResID id) {
_bytecount = entry->resSize();
_bytepos = entry->resOffset();
- if (HR_SEEK(_res->_handle, _bytepos, SEEK_SET) != 0)
- error("Error seeking resource file:\n");
+ _res->_handle->seek(_bytepos, SEEK_SET);
if (entry->isExternal()) {
// resource _data is actually a path name
@@ -387,10 +392,11 @@ void hResContext::release(RHANDLE p) {
* ===================================================================== */
void hResource::readResource(hResEntry &element) {
- element.id = _file.readUint32LE();
+ element.id = _file.readUint32BE();
element.offset = _file.readUint32LE();
element.size = _file.readUint32LE();
uint32 id = element.id;
+
debugC(kDebugResources, "%s, offset: %d, size: %d", tag2str(id), element.offset, element.size);
}
@@ -404,27 +410,34 @@ hResource::hResource(char *resname, char *extname, const char desc[]) {
_data = nullptr;
_numEntries = 0;
- strncpy(externalPath, extname ? extname : "", EXTERNAL_PATH_SIZE);
+ strncpy(_externalPath, extname ? extname : "", EXTERNAL_PATH_SIZE);
+ debugC(kDebugResources, "Opening resource: %s", resname);
_file.open(resname);
readResource(origin);
- if (origin.id != HRES_ID) return;
+ if (origin.id != HRES_ID)
+ return;
_file.seek(origin.offset - sizeof(uint32), SEEK_SET);
- firstGroupOffset = _file.readUint32LE();
+ _firstGroupOffset = _file.readUint32LE();
- // allocate buffers for root, groups and _data
+ // allocate buffers for root, groups and data
_base = (hResEntry *)malloc(origin.resSize());
- size = origin.offset - firstGroupOffset - sizeof(uint32);
- groups = (hResEntry *)malloc(size);
+ size = origin.offset - _firstGroupOffset - sizeof(uint32);
+ _groups = (hResEntry *)malloc(size);
- if (_base == nullptr || groups == nullptr) return;
+ if (_base == nullptr || _groups == nullptr) return;
readResource(*_base);
- _file.seek(firstGroupOffset, SEEK_SET);
- readResource(*groups);
+ _numEntries = origin.resSize() / sizeof origin;
+
+ debugC(kDebugResources, "Reading %d categories:", _numEntries);
+ _file.seek(_firstGroupOffset, SEEK_SET);
+ for (int i = 0; i < _numEntries; ++i) {
+ readResource(_groups[i]);
+ }
_res = this;
_numEntries = origin.resSize() / sizeof origin;
@@ -433,7 +446,7 @@ hResource::hResource(char *resname, char *extname, const char desc[]) {
hResource::~hResource() {
if (_base) free(_base);
- if (groups) free(groups);
+ if (_groups) free(_groups);
if (_handle) free(_handle);
}
diff --git a/engines/saga2/hresmgr.h b/engines/saga2/hresmgr.h
index c2e56dea2d..46880a4489 100644
--- a/engines/saga2/hresmgr.h
+++ b/engines/saga2/hresmgr.h
@@ -179,9 +179,9 @@ class hResource : public hResContext {
friend class hResContext;
- uint32 firstGroupOffset;
- char externalPath[EXTERNAL_PATH_SIZE];
- hResEntry *groups;
+ uint32 _firstGroupOffset;
+ char _externalPath[EXTERNAL_PATH_SIZE];
+ hResEntry *_groups;
public:
hResource(char *resname, char *extname, const char []);
@@ -206,7 +206,7 @@ inline hResID RES_ID(uint8 a, uint8 b, uint8 c, uint8 d) {
}
#endif
-#define HRES_ID RES_ID('H','R','E','S')
+#define HRES_ID MKTAG('H','R','E','S')
// Handle-washing function.
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index b42c96fdec..f7cbf75675 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -62,12 +62,13 @@ namespace Saga2 {
Constants
* ===================================================================== */
-const uint32 gameTimeID = RES_ID('T', 'I', 'M', 'E');
+const uint32 gameTimeID = MKTAG('T', 'I', 'M', 'E');
/* ===================================================================== *
Imports
* ===================================================================== */
+extern WindowDecoration autoMapDecorations[];
extern gToolBase G_BASE;
extern configuration globalConfig;
extern char *gameTimeStr;
@@ -753,6 +754,21 @@ bool openResources(void) {
}
+void openImageTest() {
+ hResContext *decRes;
+
+ decRes = resFile->newContext(MKTAG('A', 'M', 'A', 'P'), "Automap Resources");
+ //checkAlloc(summaryData = LoadResource(decRes,
+ // MKTAG('S', 'U', 'M', currentMapNum),
+ // "summary data"));
+
+ WindowDecoration *dec = &autoMapDecorations[0];
+ dec->image = LoadResource(decRes, MKTAG('M', 'A', 'P', 0), "MAP0");
+ //dec->image = ImageCache.requestImage(decRes, MKTAG('M', 'A', 'P', 0) | MKTAG('B', 'R', 'D', dec->imageNumber));
+ Point16 pos(0, 0);
+ //drawCompressedImage(mainPort, pos, dec->image);
+}
+
//-----------------------------------------------------------------------
// Routine to cleanup all the resource files
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index c77bb5a676..ab54ee4121 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -39,6 +39,7 @@
namespace Saga2 {
+void openImageTest();
bool openResources();
void main_saga2();
@@ -70,7 +71,9 @@ Common::Error Saga2Engine::run() {
// Additional setup.
debug("Saga2Engine::init");
- openResources();
+ if (openResources()) {
+ openImageTest();
+ }
// Your main even loop should be (invoked from) here.
debug("Saga2Engine::go: Hello, World!");
Commit: 1a0d619a7eba36f4ce67067e9569da981fe5d2c5
https://github.com/scummvm/scummvm/commit/1a0d619a7eba36f4ce67067e9569da981fe5d2c5
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:46+02:00
Commit Message:
SAGA2: Change RES_ID to MKTAG in some files
Changed paths:
engines/saga2/actor.cpp
engines/saga2/automap.cpp
engines/saga2/beegee.cpp
engines/saga2/button.cpp
engines/saga2/contain.cpp
engines/saga2/document.cpp
engines/saga2/document.h
engines/saga2/floating.cpp
engines/saga2/interp.cpp
engines/saga2/intrface.cpp
engines/saga2/intrface.h
engines/saga2/magic.cpp
engines/saga2/noise.cpp
engines/saga2/uidialog.cpp
engines/saga2/uidialog.h
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 1915ac18ec..ce05c322a3 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -57,7 +57,7 @@ namespace Saga2 {
// this is currently set to an arbitrary value for testing purposes.
const uint16 defaultReach = 24;
-const uint32 actorListID = RES_ID('A', 'C', 'T', 'O');
+const uint32 actorListID = MKTAG('A', 'C', 'T', 'O');
/* ===================================================================== *
Externals
diff --git a/engines/saga2/automap.cpp b/engines/saga2/automap.cpp
index 65cf4d869c..a17d093ed0 100644
--- a/engines/saga2/automap.cpp
+++ b/engines/saga2/automap.cpp
@@ -194,10 +194,10 @@ void CAutoMap::locateRegion(void) {
WorldMapData *wMap = &mapList[ currentWorld->mapNum ];
int i;
- areaRes = auxResFile->newContext(RES_ID('A', 'M', 'A', 'P'), "AreaList");
+ areaRes = auxResFile->newContext(MKTAG('A', 'M', 'A', 'P'), "AreaList");
VERIFY(areaRes != NULL);
- trRes = (uint16 *)LoadResource(areaRes, RES_ID('Z', 'O', 'N', currentWorld->mapNum), "AreaList");
+ trRes = (uint16 *)LoadResource(areaRes, MKTAG('Z', 'O', 'N', currentWorld->mapNum), "AreaList");
VERIFY(trRes != NULL);
regionCount = *trRes;
@@ -538,11 +538,11 @@ int16 openAutoMap() {
updateMapFeatures(currentMapNum);
// init the resource context handle
- decRes = resFile->newContext(RES_ID('A', 'M', 'A', 'P'), "Automap Resources");
+ decRes = resFile->newContext(MKTAG('A', 'M', 'A', 'P'), "Automap Resources");
// debug
checkAlloc(summaryData = LoadResource(decRes,
- RES_ID('S', 'U', 'M', currentMapNum),
+ MKTAG('S', 'U', 'M', currentMapNum),
"summary data"));
// get the graphics associated with the buttons
diff --git a/engines/saga2/beegee.cpp b/engines/saga2/beegee.cpp
index df789118bd..2ed850cf4e 100644
--- a/engines/saga2/beegee.cpp
+++ b/engines/saga2/beegee.cpp
@@ -114,14 +114,14 @@ int16 themeCount[MaxThemes];
Prototypes
* ===================================================================== */
-#define musicResID(i) RES_ID('X','M','I',i)
+#define musicResID(i) MKTAG('X','M','I',i)
inline metaTileNoise getSound(MetaTilePtr mt) {
int hmm = mt->HeavyMetaMusic();
return (hmm >= 0 && hmm < MaxThemes) ? hmm : 0;
}
inline uint32 metaNoiseID(metaTileNoise mtnID) {
- return mtnID ? RES_ID('T', 'E', 'R', mtnID) : 0;
+ return mtnID ? MKTAG('T', 'E', 'R', mtnID) : 0;
}
void _playLoop(uint32 s);
diff --git a/engines/saga2/button.cpp b/engines/saga2/button.cpp
index 6c9d2a518d..249a2f57d9 100644
--- a/engines/saga2/button.cpp
+++ b/engines/saga2/button.cpp
@@ -86,7 +86,7 @@ gCompImage::gCompImage(gPanelList &list,
for (i = 0, rNum = resNum; i < numImages; i++, rNum++) {
compImages[ i ] = LoadResource(resContext,
- RES_ID(a, b, c, rNum),
+ MKTAG(a, b, c, rNum),
" gCompImage ");
}
@@ -391,17 +391,17 @@ gCompButton::gCompButton(gPanelList &list, const Rect16 &box, hResID contextID,
gCompButton::gCompButton(gPanelList &list, const Rect16 &box, hResContext *con, char a, char b, char c, int16 butNum_1, int16 butNum_2, uint16 ident,
AppFunc *cmd) : gCompImage(list, box, NULL, ident, cmd), extent(box) {
- loadImages(con, RES_ID(a, b, c, butNum_1), RES_ID(a, b, c, butNum_2));
+ loadImages(con, MKTAG(a, b, c, butNum_1), MKTAG(a, b, c, butNum_2));
}
gCompButton::gCompButton(gPanelList &list, const Rect16 &box, hResID contextID, char a, char b, char c, int16 butNum_1, int16 butNum_2, uint16 ident,
AppFunc *cmd) : gCompImage(list, box, NULL, ident, cmd), extent(box) {
- loadImages(contextID, RES_ID(a, b, c, butNum_1), RES_ID(a, b, c, butNum_2));
+ loadImages(contextID, MKTAG(a, b, c, butNum_1), MKTAG(a, b, c, butNum_2));
}
gCompButton::gCompButton(gPanelList &list, const Rect16 &box, hResContext *con, int16 butNum, uint16 ident,
AppFunc *cmd) : gCompImage(list, box, NULL, ident, cmd), extent(box) {
- loadImages(con, RES_ID('B', 'T', 'N', butNum), RES_ID('B', 'T', 'N', butNum + 1));
+ loadImages(con, MKTAG('B', 'T', 'N', butNum), MKTAG('B', 'T', 'N', butNum + 1));
}
gCompButton::gCompButton(gPanelList &list, const Rect16 &box, void **images, int16 numRes, uint16 ident,
@@ -617,7 +617,7 @@ gToggleCompButton::gToggleCompButton(gPanelList &list, const Rect16 &box, void *
bool gToggleCompButton::activate(gEventType why) {
if (why == gEventKeyDown || why == gEventMouseDown) {
-// playSound( RES_ID('C','B','T',3) );
+// playSound( MKTAG('C','B','T',3) );
selected = !selected;
window.update(extent);
@@ -690,7 +690,7 @@ gMultCompButton::gMultCompButton(gPanelList &list, const Rect16 &box, hResContex
images = (void **) TALLOC(sizeof(void *)*numRes, memInterface);
for (i = 0, k = resStart; i < numRes; i++, k++) {
- images[ i ] = LoadResource(con, RES_ID(a, b, c, k), "Multi btn image");
+ images[ i ] = LoadResource(con, MKTAG(a, b, c, k), "Multi btn image");
checkAlloc(images[ i ]);
}
@@ -774,7 +774,7 @@ bool gMultCompButton::activate(gEventType why) {
gPanel::deactivate();
notify(gEventNewValue, current); // notify App of successful hit
playMemSound(1);
-// playSound( RES_ID('C','B','T',5) );
+// playSound( MKTAG('C','B','T',5) );
}
return FALSE;
}
diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index ec60151461..c0666ac334 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -45,7 +45,7 @@ namespace Saga2 {
uint8 weight = 0;
uint8 encum = 0;
-const hResID containerGroupID = RES_ID('C', 'O', 'N', 'T');
+const hResID containerGroupID = MKTAG('C', 'O', 'N', 'T');
const int maxOpenDistance = 32;
// selector image pointer
@@ -120,10 +120,10 @@ ContainerAppearanceDef physicalContainerAppearance(
Rect16(13 + 8 + 44, 37, 44, 42), // scroll button rectangle
Rect16(13 + 118, 50, 36, 36), // icon rectangle
Rect16(13 + 139, 37, 88, 43), // massBulk rectangle
- RES_ID('P', 'C', 'L', 0), // CloseBox normal image
- RES_ID('P', 'C', 'L', 1), // CloseBox selected image
- RES_ID('P', 'S', 'L', 0), // Scroll button normal image
- RES_ID('P', 'S', 'L', 1), // Scroll button selected image
+ MKTAG('P', 'C', 'L', 0), // CloseBox normal image
+ MKTAG('P', 'C', 'L', 1), // CloseBox selected image
+ MKTAG('P', 'S', 'L', 0), // Scroll button normal image
+ MKTAG('P', 'S', 'L', 1), // Scroll button selected image
Point16(13, 8), // Icon origin
Point16(22, 22), // Icon spacing
0, 0, // Visible rows and columns (filled in later)
@@ -164,10 +164,10 @@ ContainerAppearanceDef deathContainerAppearance(
Rect16(120 + 18, 24, 44, 42), // scroll button rectangle
Rect16(0, 0, 0, 0), // icon rectangle
Rect16(0, 0, 0, 0), // massBulk rectangle
- RES_ID('D', 'C', 'L', 0), // CloseBox normal image
- RES_ID('D', 'C', 'L', 1), // CloseBox selected image
- RES_ID('D', 'S', 'L', 0), // Scroll button normal image
- RES_ID('D', 'S', 'L', 1), // Scroll button selected image
+ MKTAG('D', 'C', 'L', 0), // CloseBox normal image
+ MKTAG('D', 'C', 'L', 1), // CloseBox selected image
+ MKTAG('D', 'S', 'L', 0), // Scroll button normal image
+ MKTAG('D', 'S', 'L', 1), // Scroll button selected image
Point16(27, -4), // Icon origin
Point16(22, 22), // Icon spacing
0, 0, // Visible rows and columns (filled in later)
@@ -208,10 +208,10 @@ ContainerAppearanceDef mentalContainerAppearance(
Rect16(103, 40 - 18 - 4, 44, 44), // scroll button rectangle
Rect16(0, 0, 0, 0), // icon rectangle
Rect16(0, 0, 0, 0), // massBulk rectangle
- RES_ID('C', 'L', 'S', 0), // CloseBox normal image
- RES_ID('C', 'L', 'S', 1), // CloseBox selected image
- RES_ID('S', 'E', 'L', 0), // Scroll button normal image
- RES_ID('S', 'E', 'L', 1), // Scroll button selected image
+ MKTAG('C', 'L', 'S', 0), // CloseBox normal image
+ MKTAG('C', 'L', 'S', 1), // CloseBox selected image
+ MKTAG('S', 'E', 'L', 0), // Scroll button normal image
+ MKTAG('S', 'E', 'L', 1), // Scroll button selected image
Point16(3, 0), // Icon origin
Point16(4, 4), // Icon spacing
4, 4, // Visible rows and columns
@@ -231,10 +231,10 @@ ContainerAppearanceDef enchantmentContainerAppearance(
Rect16(57, 50, 44, 43), // scroll button rectangle
Rect16(38, 7, 32, 32), // icon rectangle
Rect16(0, 0, 0, 0), // massBulk rectangle
- RES_ID('A', 'A', 'A', 0), // CloseBox normal image
- RES_ID('A', 'A', 'A', 0), // CloseBox selected image
- RES_ID('A', 'A', 'A', 0), // Scroll button normal image
- RES_ID('A', 'A', 'A', 0), // Scroll button selected image
+ MKTAG('A', 'A', 'A', 0), // CloseBox normal image
+ MKTAG('A', 'A', 'A', 0), // CloseBox selected image
+ MKTAG('A', 'A', 'A', 0), // Scroll button normal image
+ MKTAG('A', 'A', 'A', 0), // Scroll button selected image
Point16(12, 98), // Icon origin
Point16(16, 13), // Icon spacing
2, 2, // Visible rows and columns
@@ -1764,10 +1764,10 @@ ContainerNode *OpenMindContainer(PlayerActorID player, int16 open, int16 type) {
void initContainers(void) {
if (containerRes == NULL)
- containerRes = resFile->newContext(RES_ID('C', 'O', 'N', 'T'), "cont.resources");
+ containerRes = resFile->newContext(MKTAG('C', 'O', 'N', 'T'), "cont.resources");
checkAlloc(containerRes);
- checkAlloc(selImage = ImageCache.requestImage(imageRes, RES_ID('A', 'M', 'N', 'T')));
+ checkAlloc(selImage = ImageCache.requestImage(imageRes, MKTAG('A', 'M', 'N', 'T')));
}
void cleanupContainers(void) {
diff --git a/engines/saga2/document.cpp b/engines/saga2/document.cpp
index 94a3d7a2b7..5c8ab6a5b3 100644
--- a/engines/saga2/document.cpp
+++ b/engines/saga2/document.cpp
@@ -79,8 +79,8 @@ CDocumentAppearance scrollAppearance(
Rect16(184, 206, 44, 42), // Close button rect
scrollDecorations,
elementsof(scrollDecorations),
- RES_ID('S', 'C', 'R', 'L'),
- RES_ID('S', 'R', 'L', 0)
+ MKTAG('S', 'C', 'R', 'L'),
+ MKTAG('S', 'R', 'L', 0)
);
/* ===================================================================== *
@@ -106,8 +106,8 @@ CDocumentAppearance bookAppearance(
Rect16(231, 217, 34, 27), // Close button rect
bookDecorations,
elementsof(bookDecorations),
- RES_ID('B', 'O', 'O', 'K'),
- RES_ID('B', 'K', 'D', 0)
+ MKTAG('B', 'O', 'O', 'K'),
+ MKTAG('B', 'K', 'D', 0)
);
/* ===================================================================== *
@@ -128,8 +128,8 @@ CDocumentAppearance parchAppearance(
Rect16(164, 229, 20, 20), // Close button rect
parchDecorations,
elementsof(parchDecorations),
- RES_ID('P', 'A', 'R', 'C'),
- RES_ID('P', 'C', 'H', 0)
+ MKTAG('P', 'A', 'R', 'C'),
+ MKTAG('P', 'C', 'H', 0)
);
// deliminator defines
@@ -566,7 +566,7 @@ bool CDocument::checkForImage(char *string,
if (illustrationCon) resFile->disposeContext(illustrationCon);
// resource handle
- illustrationCon = resFile->newContext(RES_ID(argv[0], argv[1], argv[2], argv[3]),
+ illustrationCon = resFile->newContext(MKTAG(argv[0], argv[1], argv[2], argv[3]),
"book internal resources");
// set image for next page
if (offPageIndex < maxPages) {
@@ -580,7 +580,7 @@ bool CDocument::checkForImage(char *string,
if (!images[ offPageIndex ]) {
// get the image
images[ offPageIndex ] = LoadResource(illustrationCon,
- RES_ID(argv[4], argv[5], argv[6], num),
+ MKTAG(argv[4], argv[5], argv[6], num),
"book internal image");
}
@@ -588,7 +588,7 @@ bool CDocument::checkForImage(char *string,
numEat = 9;
} else {
images[ offPageIndex ] = LoadResource(illustrationCon,
- RES_ID(argv[4], argv[5], argv[6], argv[7]),
+ MKTAG(argv[4], argv[5], argv[6], argv[7]),
"book internal image");
numEat = 8;
}
@@ -919,7 +919,7 @@ int16 openScroll(uint16 textScript) {
hResContext *decRes;
// init the resource context handle
- decRes = resFile->newContext(RES_ID('S', 'C', 'R', 'L'), "book resources");
+ decRes = resFile->newContext(MKTAG('S', 'C', 'R', 'L'), "book resources");
// get the graphics associated with the buttons
checkAlloc(closeBtnImage = loadButtonRes(decRes, buttonResID, numBtnImages));
diff --git a/engines/saga2/document.h b/engines/saga2/document.h
index 65b90bcce8..2813326d58 100644
--- a/engines/saga2/document.h
+++ b/engines/saga2/document.h
@@ -41,7 +41,7 @@ int16 openParchment(uint16);
// constants
-const uint32 bookGroupID = RES_ID('B', 'O', 'O', 'K');
+const uint32 bookGroupID = MKTAG('B', 'O', 'O', 'K');
const int maxVisiblePages = 2;
diff --git a/engines/saga2/floating.cpp b/engines/saga2/floating.cpp
index f044b0da03..4be2c0b102 100644
--- a/engines/saga2/floating.cpp
+++ b/engines/saga2/floating.cpp
@@ -135,7 +135,7 @@ void DecoratedWindow::setDecorations(
// request an image pointer from the imageCache
dec->image = ImageCache.requestImage(con,
- RES_ID('B', 'R', 'D', dec->imageNumber));
+ MKTAG('B', 'R', 'D', dec->imageNumber));
}
}
@@ -154,7 +154,7 @@ void DecoratedWindow::setDecorations(
for (i = 0; i < numDecorations; i++, dec++) {
// request an image pointer from the image Cache
dec->image = ImageCache.requestImage(con,
- id | RES_ID(0, 0, 0, dec->imageNumber));
+ id | MKTAG(0, 0, 0, dec->imageNumber));
}
}
@@ -163,7 +163,7 @@ void DecoratedWindow::setDecorations(
int16 count,
hResContext *con,
char a, char b, char c) {
- setDecorations(dec, count, con, RES_ID(a, b, c, 0));
+ setDecorations(dec, count, con, MKTAG(a, b, c, 0));
}
// Free the decorations from the memory pool
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 826102d62b..590e95e593 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -41,9 +41,9 @@ namespace Saga2 {
#define IMMED_WORD(w) ((w = *pc++),(w |= (*pc++)<<8))
#define BRANCH(w) pc = *codeSeg + (w)
-const uint32 sagaID = RES_ID('S', 'A', 'G', 'A'),
- dataSegID = RES_ID('_', '_', 'D', 'A'),
- exportSegID = RES_ID('_', 'E', 'X', 'P');
+const uint32 sagaID = MKTAG('S', 'A', 'G', 'A'),
+ dataSegID = MKTAG('_', '_', 'D', 'A'),
+ exportSegID = MKTAG('_', 'E', 'X', 'P');
const int initialStackFrameSize = 10;
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index fb97e87e6b..cc89cc23b5 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -360,7 +360,7 @@ ResName broNames[] = { { 'J', 'U', 'L', 0 },
{ 'K', 'E', 'V', 0 }
};
-const uint32 containerGroupID = RES_ID('C', 'O', 'N', 'T');
+const uint32 containerGroupID = MKTAG('C', 'O', 'N', 'T');
// button position views
@@ -818,12 +818,12 @@ CMassWeightIndicator::CMassWeightIndicator(gPanelList *panel, const Point16 &pos
// setup mass/bulk indicator imagery
if (death) {
- checkAlloc(massBulkImag = ImageCache.requestImage(containerRes, RES_ID('D', 'J', 'B', massBulkResNum)));
+ checkAlloc(massBulkImag = ImageCache.requestImage(containerRes, MKTAG('D', 'J', 'B', massBulkResNum)));
checkAlloc(pieIndImag = loadImageRes(containerRes, pieIndResNum, numPieIndImages, 'D', 'A', 'J'));
} else {
- checkAlloc(massBulkImag = ImageCache.requestImage(containerRes, RES_ID('G', 'J', 'B', massBulkResNum)));
+ checkAlloc(massBulkImag = ImageCache.requestImage(containerRes, MKTAG('G', 'J', 'B', massBulkResNum)));
checkAlloc(pieIndImag = loadImageRes(containerRes, pieIndResNum, numPieIndImages, 'G', 'A', 'J'));
}
@@ -951,7 +951,7 @@ CManaIndicator::CManaIndicator(gPanelList &list) : gCompImage(list,
ASSERT(resFile);
// init the resource handle with the mana resource group
- resContext = resFile->newContext(RES_ID('M', 'A', 'N', 'A'),
+ resContext = resFile->newContext(MKTAG('M', 'A', 'N', 'A'),
"mana context");
// load star images
@@ -966,9 +966,9 @@ CManaIndicator::CManaIndicator(gPanelList &list) : gCompImage(list,
numRings,
'R', 'N', 'G'));
- checkAlloc(backImage = ImageCache.requestImage(resContext, RES_ID('B', 'A', 'C', 'K')));
+ checkAlloc(backImage = ImageCache.requestImage(resContext, MKTAG('B', 'A', 'C', 'K')));
- checkAlloc(wellImage = ImageCache.requestImage(resContext, RES_ID('W', 'E', 'L', 'L')));
+ checkAlloc(wellImage = ImageCache.requestImage(resContext, MKTAG('W', 'E', 'L', 'L')));
// hmm this could be cleaner...
starRingEndPos[ 0 ] = Point16(redEndX, redEndY);
@@ -1338,7 +1338,7 @@ CHealthIndicator::CHealthIndicator(AppFunc *cmd) {
checkAlloc(starImag = loadButtonRes(healthRes, starStart, starNum, 'S', 'T', 'A'));
// load in the health star border
- checkAlloc(starFrameImag = ImageCache.requestImage(healthRes, RES_ID('B', 'T', 'N', starFrameResNum)));
+ checkAlloc(starFrameImag = ImageCache.requestImage(healthRes, MKTAG('B', 'T', 'N', starFrameResNum)));
// set the image indexes to nominal startup values
for (i = 0; i < numControls + 1; i++) {
@@ -1596,7 +1596,7 @@ void **loadButtonRes(hResContext *con, int16 resID, int16 numRes) {
for (i = 0, k = resID; i < numRes; i++, k++) {
// get an image from the image cache
- images[ i ] = ImageCache.requestImage(con, RES_ID('B', 'T', 'N', k));
+ images[ i ] = ImageCache.requestImage(con, MKTAG('B', 'T', 'N', k));
}
return images;
@@ -1612,7 +1612,7 @@ void **loadButtonRes(hResContext *con, int16 resID, int16 numRes, char a, char b
void **images = (void **) TALLOC(sizeof(void *)*numRes, memInterface);
for (i = 0, k = resID; i < numRes; i++, k++) {
- images[ i ] = ImageCache.requestImage(con, RES_ID(a, b, c, k));
+ images[ i ] = ImageCache.requestImage(con, MKTAG(a, b, c, k));
}
return images;
@@ -1673,17 +1673,17 @@ void SetupUserControls(void) {
checkAlloc(julBtnImag = loadButtonRes(imageRes, julBtnResNum, numBtnImages));
checkAlloc(phiBtnImag = loadButtonRes(imageRes, phiBtnResNum, numBtnImages));
checkAlloc(kevBtnImag = loadButtonRes(imageRes, kevBtnResNum, numBtnImages));
- checkAlloc(broBtnFrameImag = ImageCache.requestImage(imageRes, RES_ID('F', 'R', 'A', 'M')));
+ checkAlloc(broBtnFrameImag = ImageCache.requestImage(imageRes, MKTAG('F', 'R', 'A', 'M')));
// set up the portrait name plates
for (n = 0; n < kNumViews; n++) {
- checkAlloc(namePlateImages[ n ] = ImageCache.requestImage(imageRes, RES_ID('B', 'T', 'N', namePlateResNum[ n ])));
+ checkAlloc(namePlateImages[ n ] = ImageCache.requestImage(imageRes, MKTAG('B', 'T', 'N', namePlateResNum[ n ])));
}
// get the frame image
- checkAlloc(namePlateFrameImag = ImageCache.requestImage(imageRes, RES_ID('B', 'T', 'N', 15)));
- checkAlloc(armorImag = ImageCache.requestImage(imageRes, RES_ID('B', 'T', 'N', 34)));
+ checkAlloc(namePlateFrameImag = ImageCache.requestImage(imageRes, MKTAG('B', 'T', 'N', 15)));
+ checkAlloc(armorImag = ImageCache.requestImage(imageRes, MKTAG('B', 'T', 'N', 34)));
// clean out the old context
if (imageRes) resFile->disposeContext(imageRes);
diff --git a/engines/saga2/intrface.h b/engines/saga2/intrface.h
index fe45c91119..2626a6bcbe 100644
--- a/engines/saga2/intrface.h
+++ b/engines/saga2/intrface.h
@@ -99,8 +99,8 @@ void cleanupUIState(void);
void StatusMsg(char *msg, ...); // frametime def
-const uint32 faceGroupID = RES_ID('F', 'A', 'C', 'E');
-const uint32 mentGroupID = RES_ID('C', 'O', 'N', 'T');
+const uint32 faceGroupID = MKTAG('F', 'A', 'C', 'E');
+const uint32 mentGroupID = MKTAG('C', 'O', 'N', 'T');
/* ===================================================================== *
diff --git a/engines/saga2/magic.cpp b/engines/saga2/magic.cpp
index 49ff8ad107..704a668d55 100644
--- a/engines/saga2/magic.cpp
+++ b/engines/saga2/magic.cpp
@@ -286,7 +286,7 @@ bool implementSpell(GameObject *enactor, Location &target, SkillProto *spell)
bool r = a->takeMana(ami, sProto.getManaAmt());
if (!r) {
Location cal = Location(a->getLocation(), a->IDParent());
- Saga2::playSoundAt(RES_ID('S', 'P', 'L', spellFailSound), cal);
+ Saga2::playSoundAt(MKTAG('S', 'P', 'L', spellFailSound), cal);
return FALSE;
}
PlayerActorID playerID;
@@ -326,7 +326,7 @@ bool implementSpell(GameObject *enactor, ActiveItem *target, SkillProto *spell)
bool r = a->takeMana(ami, sProto.getManaAmt());
if (!r) {
Location cal = Location(a->getLocation(), a->IDParent());
- Saga2::playSoundAt(RES_ID('S', 'P', 'L', spellFailSound), cal);
+ Saga2::playSoundAt(MKTAG('S', 'P', 'L', spellFailSound), cal);
return FALSE;
}
PlayerActorID playerID;
@@ -364,7 +364,7 @@ bool implementSpell(GameObject *enactor, GameObject *target, SkillProto *spell)
bool r = a->takeMana(ami, sProto.getManaAmt());
if (!r) {
Location cal = Location(a->getLocation(), a->IDParent());
- Saga2::playSoundAt(RES_ID('S', 'P', 'L', spellFailSound), cal);
+ Saga2::playSoundAt(MKTAG('S', 'P', 'L', spellFailSound), cal);
return FALSE;
}
PlayerActorID playerID;
diff --git a/engines/saga2/noise.cpp b/engines/saga2/noise.cpp
index dbcbaef97b..d934975d86 100644
--- a/engines/saga2/noise.cpp
+++ b/engines/saga2/noise.cpp
@@ -47,11 +47,11 @@ Point32 VeryFarAway = Point32(32767, 32766);
const uint32 fullVolumeDist = 75;
const uint32 offVolumeDist = 200;
-const uint32 baseMusicID = RES_ID('M', 'I', 'L', 'O'),
- goodMusicID = RES_ID('M', 'I', 'H', 'I'),
- soundID = RES_ID('L', 'O', 'U', 'D'),
- loopedID = RES_ID('L', 'O', 'O', 'P'),
- voiceID = RES_ID('T', 'A', 'L', 'K');
+const uint32 baseMusicID = MKTAG('M', 'I', 'L', 'O'),
+ goodMusicID = MKTAG('M', 'I', 'H', 'I'),
+ soundID = MKTAG('L', 'O', 'U', 'D'),
+ loopedID = MKTAG('L', 'O', 'O', 'P'),
+ voiceID = MKTAG('T', 'A', 'L', 'K');
/* ===================================================================== *
Imports
@@ -308,11 +308,11 @@ void startAudio(void) {
if (audio->activeDIG()) {
// kludgy in memory click sounds
clickSizes[0] = 0;
- clickSizes[1] = soundRes->size(RES_ID('C', 'L', 'K', 1));
- clickSizes[2] = soundRes->size(RES_ID('C', 'L', 'K', 2));
+ clickSizes[1] = soundRes->size(MKTAG('C', 'L', 'K', 1));
+ clickSizes[2] = soundRes->size(MKTAG('C', 'L', 'K', 2));
clickData[0] = NULL;
- clickData[1] = (uint8 *) LoadResource(soundRes, RES_ID('C', 'L', 'K', 1), "Click 1");
- clickData[2] = (uint8 *) LoadResource(soundRes, RES_ID('C', 'L', 'K', 2), "Click 2");
+ clickData[1] = (uint8 *) LoadResource(soundRes, MKTAG('C', 'L', 'K', 1), "Click 1");
+ clickData[2] = (uint8 *) LoadResource(soundRes, MKTAG('C', 'L', 'K', 2), "Click 2");
}
disMusic = !GetPrivateProfileInt("Sound", "Music", 1, iniFile);
@@ -360,11 +360,11 @@ void audioEventLoop(void) {
* ===================================================================== */
void makeCombatSound(uint8 cs, Location l) {
- playSoundAt(RES_ID('C', 'B', 'T', cs), l);
+ playSoundAt(MKTAG('C', 'B', 'T', cs), l);
}
void makeGruntSound(uint8 cs, Location l) {
- playSoundAt(RES_ID('G', 'N', 'T', cs), l);
+ playSoundAt(MKTAG('G', 'N', 'T', cs), l);
}
@@ -690,13 +690,13 @@ uint32 parse_res_id(char IDstr[]) {
for (i = 0, j = 0; i < strlen(IDstr); i++) {
if (IDstr[i] == ':') {
a2 = atoi(IDstr + i + 1);
- return RES_ID(a[0], a[1], a[2], a2);
+ return MKTAG(a[0], a[1], a[2], a2);
} else {
a[j++] = IDstr[i];
}
}
}
- return RES_ID(a[0], a[1], a[2], a[3]);
+ return MKTAG(a[0], a[1], a[2], a[3]);
}
//-----------------------------------------------------------------------
@@ -761,14 +761,14 @@ void PlayMusic(char IDstr[]) {
int annoyingTestSound(int32 sampID) {
if (debugStatuses) {
- WriteStatusF(6, "Queued sound : %X ", RES_ID('T', 'S', 'T', sampID));
+ WriteStatusF(6, "Queued sound : %X ", MKTAG('T', 'S', 'T', sampID));
}
- playSound(RES_ID('S', 'F', 'X', sampID));
+ playSound(MKTAG('S', 'F', 'X', sampID));
return 0;
}
int annoyingTestSound2(int32 sampID) {
- playSound(RES_ID('T', 'S', 'T', sampID));
+ playSound(MKTAG('T', 'S', 'T', sampID));
return 0;
}
@@ -777,7 +777,7 @@ int annoyingTestSound2(int32 sampID) {
//-----------------------------------------------------------------------
int annoyingTestVoice(int32 sampID) {
- playVoice(RES_ID('T', 'S', 'T', sampID));
+ playVoice(MKTAG('T', 'S', 'T', sampID));
return 0;
}
@@ -787,9 +787,9 @@ int annoyingTestVoice(int32 sampID) {
int annoyingTestMusic(int32 sampID) {
#if defined(_WIN32) && !defined(USE_REAL_WAIL)
- playMusic(RES_ID('M', 'I', 'D', sampID));
+ playMusic(MKTAG('M', 'I', 'D', sampID));
#else
- playMusic(RES_ID('X', 'M', 'I', sampID));
+ playMusic(MKTAG('X', 'M', 'I', sampID));
#endif
return 0;
}
@@ -798,7 +798,7 @@ static char convBuf[5];
inline uint32 extendID(int16 smallID) {
sprintf(convBuf, "%4.4d", smallID);
- return smallID ? RES_ID(convBuf[0] + 'A' - '0', convBuf[1], convBuf[2], convBuf[3]) : 0 ;
+ return smallID ? MKTAG(convBuf[0] + 'A' - '0', convBuf[1], convBuf[2], convBuf[3]) : 0 ;
}
int16 aResponse[20] = {
@@ -829,13 +829,13 @@ void voiceTest2(void) {
PlayLoop(":0");
break;
case 5:
- playLoop(RES_ID('T', 'E', 'R', 2));
+ playLoop(MKTAG('T', 'E', 'R', 2));
break;
case 6:
- playLoop(RES_ID('T', 'E', 'R', 3));
+ playLoop(MKTAG('T', 'E', 'R', 3));
break;
case 7:
- playLoop(RES_ID('T', 'E', 'R', 8));
+ playLoop(MKTAG('T', 'E', 'R', 8));
break;
}
}
@@ -847,13 +847,13 @@ void soundTest1(void) {
playSound(0);
break;
case 1:
- playSound(RES_ID('S', 'F', 'X', 5));
+ playSound(MKTAG('S', 'F', 'X', 5));
break;
case 2:
- playSound(RES_ID('S', 'F', 'X', 8));
+ playSound(MKTAG('S', 'F', 'X', 8));
break;
case 3:
- playSound(RES_ID('S', 'F', 'X', 20));
+ playSound(MKTAG('S', 'F', 'X', 20));
break;
case 4:
PlaySound("SFX:11");
@@ -862,10 +862,10 @@ void soundTest1(void) {
PlaySound("SFX:15");
break;
case 6:
- playSound(RES_ID('S', 'F', 'X', 3));
+ playSound(MKTAG('S', 'F', 'X', 3));
break;
case 7:
- playSound(RES_ID('B', 'A', 'D', 47)); // put down a card
+ playSound(MKTAG('B', 'A', 'D', 47)); // put down a card
}
}
@@ -879,13 +879,13 @@ void soundTest2(void) {
PlayMusic(":0");
break;
case 2:
- playMusic(RES_ID('X', 'M', 'I', 1));
+ playMusic(MKTAG('X', 'M', 'I', 1));
break;
case 3:
- playMusic(RES_ID('X', 'M', 'I', 2));
+ playMusic(MKTAG('X', 'M', 'I', 2));
break;
case 4:
- playMusic(RES_ID('X', 'M', 'I', 3));
+ playMusic(MKTAG('X', 'M', 'I', 3));
break;
case 5:
PlayMusic("XMI:1");
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index 14232a308c..209532e4c4 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -1552,7 +1552,7 @@ void placardWindow(int8 type, char *text) {
hResContext *resContext;
// init the resource context handle
- resContext = resFile->newContext(RES_ID('I', 'M', 'A', 'G'), "Placard resources");
+ resContext = resFile->newContext(MKTAG('I', 'M', 'A', 'G'), "Placard resources");
// do type related assignments
diff --git a/engines/saga2/uidialog.h b/engines/saga2/uidialog.h
index 31046f88b9..827e859a66 100644
--- a/engines/saga2/uidialog.h
+++ b/engines/saga2/uidialog.h
@@ -30,7 +30,7 @@
namespace Saga2 {
// constants
-const uint32 dialogGroupID = RES_ID('D', 'I', 'A', 'L');
+const uint32 dialogGroupID = MKTAG('D', 'I', 'A', 'L');
// this should eventually point to the script that contains the credits
const uint16 creditsScriptNum = 0; // this has a scripts now
Commit: fde112d2b1f01091a4fed977956dca1cf63bfc7c
https://github.com/scummvm/scummvm/commit/fde112d2b1f01091a4fed977956dca1cf63bfc7c
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:46+02:00
Commit Message:
SAGA2: Import image decoding routines from SAGA
Changed paths:
engines/saga2/blitters.cpp
engines/saga2/main.cpp
engines/saga2/playmode.cpp
diff --git a/engines/saga2/blitters.cpp b/engines/saga2/blitters.cpp
index fecd99d713..daa9f66bae 100644
--- a/engines/saga2/blitters.cpp
+++ b/engines/saga2/blitters.cpp
@@ -25,9 +25,420 @@
*/
#include "saga2/std.h"
+#include "saga2/saga2.h"
+#include "common/memstream.h"
+#include "common/debug.h"
namespace Saga2 {
+class ByteArray : public Common::Array<byte> {
+public:
+ /**
+ * Return a pointer to the start of the buffer underlying this byte array,
+ * or NULL if the buffer is empty.
+ */
+ byte *getBuffer() {
+ return empty() ? NULL : &front();
+ }
+
+ const byte *getBuffer() const {
+ return empty() ? NULL : &front();
+ }
+
+ void assign(const ByteArray &src) {
+ resize(src.size());
+ if (!empty()) {
+ memcpy(&front(), &src.front(), size());
+ }
+ }
+};
+
+typedef struct {
+ int width;
+ int height;
+} ImgHeader;
+
+static int granulate(int value, int granularity) {
+ int remainder;
+
+ if (value == 0)
+ return 0;
+
+ if (granularity == 0)
+ return 0;
+
+ remainder = value % granularity;
+
+ if (remainder == 0) {
+ return value;
+ } else {
+ return (granularity - remainder + value);
+ }
+}
+
+bool decodeBGImage(ByteArray imageData, ByteArray outputBuffer, int *w, int *h, bool flip);
+bool decodeBGImageRLE(const byte *inbuf, size_t inbuf_len, ByteArray &outbuf);
+void flipImage(byte *imageBuffer, int columns, int scanlines);
+void unbankBGImage(byte *dst_buf, const byte *src_buf, int columns, int scanlines);
+
+bool decodeBGImage(ByteArray imageData, ByteArray outputBuffer, int *w, int *h, bool flip) {
+ ImgHeader hdr;
+ int modex_height;
+ const byte *RLE_data_ptr;
+ size_t RLE_data_len;
+ ByteArray decodeBuffer;
+
+ const int32 SAGA_IMAGE_DATA_OFFSET = 776;
+
+ if (imageData.size() <= SAGA_IMAGE_DATA_OFFSET) {
+ error("decodeBGImage() Image size is way too small (%d)", (int)imageData.size());
+ }
+
+ Common::MemoryReadStream readS(imageData.getBuffer(), imageData.size());
+
+ hdr.width = readS.readUint16LE();
+ hdr.height = readS.readUint16LE();
+ // The next four bytes of the image header aren't used.
+ readS.readUint16LE();
+ readS.readUint16LE();
+
+ RLE_data_ptr = &imageData.front() + SAGA_IMAGE_DATA_OFFSET;
+ RLE_data_len = imageData.size() - SAGA_IMAGE_DATA_OFFSET;
+
+ modex_height = granulate(hdr.height, 4);
+
+ decodeBuffer.resize(hdr.width * modex_height);
+
+ outputBuffer.resize(hdr.width * hdr.height);
+
+ if (!decodeBGImageRLE(RLE_data_ptr, RLE_data_len, decodeBuffer)) {
+ return false;
+ }
+
+ unbankBGImage(outputBuffer.getBuffer(), decodeBuffer.getBuffer(), hdr.width, hdr.height);
+
+ *w = hdr.width;
+ *h = hdr.height;
+
+ return true;
+}
+
+bool decodeBGImageRLE(const byte *inbuf, size_t inbuf_len, ByteArray &outbuf) {
+ const byte *inbuf_ptr;
+ byte *outbuf_ptr;
+ byte *outbuf_start;
+ uint32 inbuf_remain;
+
+ const byte *inbuf_end;
+ byte *outbuf_end;
+ uint32 outbuf_remain;
+
+ byte mark_byte;
+ int test_byte;
+
+ uint32 runcount;
+
+ byte bitfield;
+ byte bitfield_byte1;
+ byte bitfield_byte2;
+
+ byte *backtrack_ptr;
+ int backtrack_amount;
+
+ uint16 c, b;
+
+ int decode_err = 0;
+
+ inbuf_ptr = inbuf;
+ inbuf_remain = inbuf_len;
+
+ outbuf_start = outbuf_ptr = outbuf.getBuffer();
+ outbuf_remain = outbuf.size();
+ outbuf_end = (outbuf_start + outbuf_remain) - 1;
+ memset(outbuf_start, 0, outbuf_remain);
+
+ inbuf_end = (inbuf + inbuf_len) - 1;
+
+
+ while ((inbuf_remain > 1) && (outbuf_remain > 0) && !decode_err) {
+
+ if ((inbuf_ptr > inbuf_end) || (outbuf_ptr > outbuf_end)) {
+ return false;
+ }
+
+ mark_byte = *inbuf_ptr++;
+ inbuf_remain--;
+
+ test_byte = mark_byte & 0xC0; // Mask all but two high order bits
+
+ switch (test_byte) {
+ case 0xC0: // 1100 0000
+ // Uncompressed run follows: Max runlength 63
+ runcount = mark_byte & 0x3f;
+ if ((inbuf_remain < runcount) || (outbuf_remain < runcount)) {
+ return false;
+ }
+
+ for (c = 0; c < runcount; c++) {
+ *outbuf_ptr++ = *inbuf_ptr++;
+ }
+
+ inbuf_remain -= runcount;
+ outbuf_remain -= runcount;
+ continue;
+ break;
+ case 0x80: // 1000 0000
+ // Compressed run follows: Max runlength 63
+ runcount = (mark_byte & 0x3f) + 3;
+ if (!inbuf_remain || (outbuf_remain < runcount)) {
+ return false;
+ }
+
+ for (c = 0; c < runcount; c++) {
+ *outbuf_ptr++ = *inbuf_ptr;
+ }
+
+ inbuf_ptr++;
+ inbuf_remain--;
+ outbuf_remain -= runcount;
+ continue;
+
+ break;
+
+ case 0x40: // 0100 0000
+ // Repeat decoded sequence from output stream:
+ // Max runlength 10
+
+ runcount = ((mark_byte >> 3) & 0x07U) + 3;
+ backtrack_amount = *inbuf_ptr;
+
+ if (!inbuf_remain || (backtrack_amount > (outbuf_ptr - outbuf_start)) || (runcount > outbuf_remain)) {
+ return false;
+ }
+
+ inbuf_ptr++;
+ inbuf_remain--;
+
+ backtrack_ptr = outbuf_ptr - backtrack_amount;
+
+ for (c = 0; c < runcount; c++) {
+ *outbuf_ptr++ = *backtrack_ptr++;
+ }
+
+ outbuf_remain -= runcount;
+ continue;
+ break;
+ default: // 0000 0000
+ break;
+ }
+
+ // Mask all but the third and fourth highest order bits
+ test_byte = mark_byte & 0x30;
+
+ switch (test_byte) {
+
+ case 0x30: // 0011 0000
+ // Bitfield compression
+ runcount = (mark_byte & 0x0F) + 1;
+
+ if ((inbuf_remain < (runcount + 2)) || (outbuf_remain < (runcount * 8))) {
+ return false;
+ }
+
+ bitfield_byte1 = *inbuf_ptr++;
+ bitfield_byte2 = *inbuf_ptr++;
+
+ for (c = 0; c < runcount; c++) {
+ bitfield = *inbuf_ptr;
+ for (b = 0; b < 8; b++) {
+ if (bitfield & 0x80) {
+ *outbuf_ptr = bitfield_byte2;
+ } else {
+ *outbuf_ptr = bitfield_byte1;
+ }
+ bitfield <<= 1;
+ outbuf_ptr++;
+ }
+ inbuf_ptr++;
+ }
+
+ inbuf_remain -= (runcount + 2);
+ outbuf_remain -= (runcount * 8);
+ continue;
+ break;
+ case 0x20: // 0010 0000
+ // Uncompressed run follows
+ runcount = ((mark_byte & 0x0F) << 8) + *inbuf_ptr;
+ if ((inbuf_remain < (runcount + 1)) || (outbuf_remain < runcount)) {
+ return false;
+ }
+
+ inbuf_ptr++;
+
+ for (c = 0; c < runcount; c++) {
+ *outbuf_ptr++ = *inbuf_ptr++;
+ }
+
+ inbuf_remain -= (runcount + 1);
+ outbuf_remain -= runcount;
+ continue;
+
+ break;
+
+ case 0x10: // 0001 0000
+ // Repeat decoded sequence from output stream
+ backtrack_amount = ((mark_byte & 0x0F) << 8) + *inbuf_ptr;
+ if (inbuf_remain < 2) {
+ return false;
+ }
+
+ inbuf_ptr++;
+ runcount = *inbuf_ptr++;
+
+ if ((backtrack_amount > (outbuf_ptr - outbuf_start)) || (outbuf_remain < runcount)) {
+ return false;
+ }
+
+ backtrack_ptr = outbuf_ptr - backtrack_amount;
+
+ for (c = 0; c < runcount; c++) {
+ *outbuf_ptr++ = *backtrack_ptr++;
+ }
+
+ inbuf_remain -= 2;
+ outbuf_remain -= runcount;
+ continue;
+ break;
+ default:
+ return false;
+ }
+ }
+
+ return true;
+}
+
+void flipImage(byte *imageBuffer, int columns, int scanlines) {
+ int line;
+ ByteArray tmp_scan;
+
+ byte *flip_p1;
+ byte *flip_p2;
+ byte *flip_tmp;
+
+ int flipcount = scanlines / 2;
+
+ tmp_scan.resize(columns);
+ flip_tmp = tmp_scan.getBuffer();
+ if (flip_tmp == NULL) {
+ return;
+ }
+
+ flip_p1 = imageBuffer;
+ flip_p2 = imageBuffer + (columns * (scanlines - 1));
+
+ for (line = 0; line < flipcount; line++) {
+ memcpy(flip_tmp, flip_p1, columns);
+ memcpy(flip_p1, flip_p2, columns);
+ memcpy(flip_p2, flip_tmp, columns);
+ flip_p1 += columns;
+ flip_p2 -= columns;
+ }
+}
+
+void unbankBGImage(byte *dst_buf, const byte *src_buf, int columns, int scanlines) {
+ int x, y;
+ int temp;
+ int quadruple_rows;
+ int remain_rows;
+ int rowjump_src;
+ int rowjump_dest;
+ const byte *src_p;
+ const byte *srcptr1, *srcptr2, *srcptr3, *srcptr4;
+ byte *dstptr1, *dstptr2, *dstptr3, *dstptr4;
+
+ quadruple_rows = scanlines - (scanlines % 4);
+ remain_rows = scanlines - quadruple_rows;
+
+ assert(scanlines > 0);
+
+ src_p = src_buf;
+
+ srcptr1 = src_p;
+ srcptr2 = src_p + 1;
+ srcptr3 = src_p + 2;
+ srcptr4 = src_p + 3;
+
+ dstptr1 = dst_buf;
+ dstptr2 = dst_buf + columns;
+ dstptr3 = dst_buf + columns * 2;
+ dstptr4 = dst_buf + columns * 3;
+
+ rowjump_src = columns * 4;
+ rowjump_dest = columns * 4;
+
+ // Unbank groups of 4 first
+ for (y = 0; y < quadruple_rows; y += 4) {
+ for (x = 0; x < columns; x++) {
+ temp = x * 4;
+ dstptr1[x] = srcptr1[temp];
+ dstptr2[x] = srcptr2[temp];
+ dstptr3[x] = srcptr3[temp];
+ dstptr4[x] = srcptr4[temp];
+ }
+
+ // This is to avoid generating invalid pointers -
+ // usually innocuous, but undefined
+ if (y < quadruple_rows - 4) {
+ dstptr1 += rowjump_dest;
+ dstptr2 += rowjump_dest;
+ dstptr3 += rowjump_dest;
+ dstptr4 += rowjump_dest;
+ srcptr1 += rowjump_src;
+ srcptr2 += rowjump_src;
+ srcptr3 += rowjump_src;
+ srcptr4 += rowjump_src;
+ }
+ }
+
+ // Unbank rows remaining
+ switch (remain_rows) {
+ case 1:
+ dstptr1 += rowjump_dest;
+ srcptr1 += rowjump_src;
+ for (x = 0; x < columns; x++) {
+ temp = x * 4;
+ dstptr1[x] = srcptr1[temp];
+ }
+ break;
+ case 2:
+ dstptr1 += rowjump_dest;
+ dstptr2 += rowjump_dest;
+ srcptr1 += rowjump_src;
+ srcptr2 += rowjump_src;
+ for (x = 0; x < columns; x++) {
+ temp = x * 4;
+ dstptr1[x] = srcptr1[temp];
+ dstptr2[x] = srcptr2[temp];
+ }
+ break;
+ case 3:
+ dstptr1 += rowjump_dest;
+ dstptr2 += rowjump_dest;
+ dstptr3 += rowjump_dest;
+ srcptr1 += rowjump_src;
+ srcptr2 += rowjump_src;
+ srcptr3 += rowjump_src;
+ for (x = 0; x < columns; x++) {
+ temp = x * 4;
+ dstptr1[x] = srcptr1[temp];
+ dstptr2[x] = srcptr2[temp];
+ dstptr3[x] = srcptr3[temp];
+ }
+ break;
+ default:
+ break;
+ }
+}
void _BltPixels(uint8 *srcPtr, uint32 srcMod, uint8 *dstPtr, uint32 dstMod, uint32 width, uint32 height) {
warning("STUB: _BltPixels()");
@@ -47,6 +458,20 @@ void _HLine(uint8 *dstPtr, uint32 width, uint32 color) {
void unpackImage(gPixelMap *map, int32 width, int32 rowCount, int8 *srcData) {
warning("STUB: unpackImage()");
+ ByteArray compressedBuffer;
+ ByteArray outputBuffer;
+ int *w = nullptr;
+ int *h = nullptr;
+
+ compressedBuffer.resize(map->bytes());
+ for (int i = 0; i < map->bytes(); ++i)
+ compressedBuffer[i] = srcData[i];
+
+ if (!decodeBGImage(compressedBuffer, outputBuffer, w, h, false)) {
+ error("Could not unpack sprite");
+ }
+ debugC(kDebugResources, "hello");
+ map->data = outputBuffer.getBuffer();
}
void unpackSprite(gPixelMap *map, uint8 *sprData) {
@@ -82,7 +507,8 @@ void _LoadPalette(uint8 *rgbArray, uint32 startColor, uint32 numColors) {
}
bool initGraphics(void) {
- warning("STUB: initGraphics");
+ warning("STUB: initGraphics()");
+ return false;
}
bool initProcessResources(void) {
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index f7cbf75675..9e8cb51cb4 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -766,7 +766,7 @@ void openImageTest() {
dec->image = LoadResource(decRes, MKTAG('M', 'A', 'P', 0), "MAP0");
//dec->image = ImageCache.requestImage(decRes, MKTAG('M', 'A', 'P', 0) | MKTAG('B', 'R', 'D', dec->imageNumber));
Point16 pos(0, 0);
- //drawCompressedImage(mainPort, pos, dec->image);
+ drawCompressedImage(mainPort, pos, dec->image);
}
//-----------------------------------------------------------------------
diff --git a/engines/saga2/playmode.cpp b/engines/saga2/playmode.cpp
index f1c1360181..9ec7d4b488 100644
--- a/engines/saga2/playmode.cpp
+++ b/engines/saga2/playmode.cpp
@@ -333,9 +333,8 @@ void drawCompressedImage(gPort &port, const Point16 pos, void *image) {
map.size = hdr->size;
if (hdr->compress) {
- map.data = (uint8 *)RNewPtr(map.bytes(), NULL, "sprite decompression map");
+ map.data = (uint8 *)malloc(map.bytes());
if (map.data == NULL) return;
-
unpackImage(&map, map.size.x, map.size.y, hdr->data);
} else map.data = (uint8 *)hdr->data;
@@ -344,7 +343,7 @@ void drawCompressedImage(gPort &port, const Point16 pos, void *image) {
pos.x, pos.y,
map.size.x, map.size.y);
- if (hdr->compress) RDisposePtr(map.data);
+ if (hdr->compress) free(map.data);
}
void drawCompressedImageGhosted(gPort &port, const Point16 pos, void *image) {
Commit: e7cfeb8bab8b005125c42714bb3a250d76b1cb70
https://github.com/scummvm/scummvm/commit/e7cfeb8bab8b005125c42714bb3a250d76b1cb70
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:46+02:00
Commit Message:
SAGA2: Move FORBIDDEN_SYMBOL_ALLOW_ALL to individual files
Changed paths:
engines/saga2/actor.cpp
engines/saga2/arrowptr.cpp
engines/saga2/assign.cpp
engines/saga2/audio.cpp
engines/saga2/audiobuf.cpp
engines/saga2/audiores.cpp
engines/saga2/audiotmr.cpp
engines/saga2/automap.cpp
engines/saga2/band.cpp
engines/saga2/beegee.cpp
engines/saga2/blitters.cpp
engines/saga2/button.cpp
engines/saga2/calender.cpp
engines/saga2/calender.h
engines/saga2/config.cpp
engines/saga2/contain.cpp
engines/saga2/display.cpp
engines/saga2/dispnode.cpp
engines/saga2/dlist.cpp
engines/saga2/document.cpp
engines/saga2/effects.cpp
engines/saga2/enchant.cpp
engines/saga2/errbase.cpp
engines/saga2/errclass.cpp
engines/saga2/errlist.cpp
engines/saga2/errors.cpp
engines/saga2/exit.cpp
engines/saga2/floating.cpp
engines/saga2/gamemode.cpp
engines/saga2/gdraw.cpp
engines/saga2/gpointer.cpp
engines/saga2/grabinfo.cpp
engines/saga2/grequest.cpp
engines/saga2/gtext.cpp
engines/saga2/gtextbox.cpp
engines/saga2/hresmgr.cpp
engines/saga2/iff.cpp
engines/saga2/imagcach.cpp
engines/saga2/images.cpp
engines/saga2/input.cpp
engines/saga2/interp.cpp
engines/saga2/intrface.cpp
engines/saga2/itevideo.cpp
engines/saga2/keybored.cpp
engines/saga2/loadmsg.cpp
engines/saga2/loadsave.cpp
engines/saga2/magic.cpp
engines/saga2/main.cpp
engines/saga2/mainmap.cpp
engines/saga2/mapfeatr.cpp
engines/saga2/maprange.cpp
engines/saga2/messager.cpp
engines/saga2/mission.cpp
engines/saga2/modal.cpp
engines/saga2/mono.cpp
engines/saga2/motion.cpp
engines/saga2/mouseimg.cpp
engines/saga2/nice_err.cpp
engines/saga2/noise.cpp
engines/saga2/objects.cpp
engines/saga2/objproto.cpp
engines/saga2/osexcept.cpp
engines/saga2/panel.cpp
engines/saga2/path.cpp
engines/saga2/patrol.cpp
engines/saga2/player.cpp
engines/saga2/playmode.cpp
engines/saga2/pool.cpp
engines/saga2/property.cpp
engines/saga2/pt2angle.cpp
engines/saga2/rect.cpp
engines/saga2/rmem.cpp
engines/saga2/rserver.cpp
engines/saga2/saga2.cpp
engines/saga2/sagafunc.cpp
engines/saga2/savefile.cpp
engines/saga2/sensor.cpp
engines/saga2/speech.cpp
engines/saga2/spelcast.cpp
engines/saga2/speldata.cpp
engines/saga2/speldraw.cpp
engines/saga2/spellini.cpp
engines/saga2/spellio.cpp
engines/saga2/spellloc.cpp
engines/saga2/spellsiz.cpp
engines/saga2/spellspr.cpp
engines/saga2/spellsta.cpp
engines/saga2/sprite.cpp
engines/saga2/std.h
engines/saga2/target.cpp
engines/saga2/task.cpp
engines/saga2/terrain.cpp
engines/saga2/tile.cpp
engines/saga2/tileline.cpp
engines/saga2/tileload.cpp
engines/saga2/tilemode.cpp
engines/saga2/timer.cpp
engines/saga2/timers.cpp
engines/saga2/tower.cpp
engines/saga2/towerfta.cpp
engines/saga2/transit.cpp
engines/saga2/tromode.cpp
engines/saga2/uidialog.cpp
engines/saga2/vbacksav.cpp
engines/saga2/verify.cpp
engines/saga2/video.cpp
engines/saga2/videobox.cpp
engines/saga2/videomem.cpp
engines/saga2/vidhook.cpp
engines/saga2/vidsmk.cpp
engines/saga2/vpal.cpp
engines/saga2/vwdraw.cpp
engines/saga2/vwpage.cpp
engines/saga2/weapons.cpp
engines/saga2/winini.cpp
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index ce05c322a3..e4512cf3ef 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/dispnode.h"
diff --git a/engines/saga2/arrowptr.cpp b/engines/saga2/arrowptr.cpp
index 6d3cf64a03..0794c7f97d 100644
--- a/engines/saga2/arrowptr.cpp
+++ b/engines/saga2/arrowptr.cpp
@@ -30,6 +30,8 @@
Converted by iff2c.
* ===================================================================== */
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/gdraw.h"
diff --git a/engines/saga2/assign.cpp b/engines/saga2/assign.cpp
index 28b3800f98..777060bb5d 100644
--- a/engines/saga2/assign.cpp
+++ b/engines/saga2/assign.cpp
@@ -28,6 +28,8 @@
Includes
* ===================================================================== */
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/assign.h"
#include "saga2/patrol.h"
diff --git a/engines/saga2/audio.cpp b/engines/saga2/audio.cpp
index e836f8386a..5482d935fd 100644
--- a/engines/saga2/audio.cpp
+++ b/engines/saga2/audio.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/audio.h"
diff --git a/engines/saga2/audiobuf.cpp b/engines/saga2/audiobuf.cpp
index 5bd280ef11..a9988bc5ef 100644
--- a/engines/saga2/audiobuf.cpp
+++ b/engines/saga2/audiobuf.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/audio.h"
#include "saga2/audioerr.h"
diff --git a/engines/saga2/audiores.cpp b/engines/saga2/audiores.cpp
index dde15e3b5d..f8ad3dcc02 100644
--- a/engines/saga2/audiores.cpp
+++ b/engines/saga2/audiores.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/audio.h"
#include "saga2/hresmgr.h"
diff --git a/engines/saga2/audiotmr.cpp b/engines/saga2/audiotmr.cpp
index 82e099afdc..4ffcec8e76 100644
--- a/engines/saga2/audiotmr.cpp
+++ b/engines/saga2/audiotmr.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/audio.h"
diff --git a/engines/saga2/automap.cpp b/engines/saga2/automap.cpp
index a17d093ed0..77ee152577 100644
--- a/engines/saga2/automap.cpp
+++ b/engines/saga2/automap.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/automap.h"
#include "saga2/tile.h"
diff --git a/engines/saga2/band.cpp b/engines/saga2/band.cpp
index ecd8f28795..204f5c29ce 100644
--- a/engines/saga2/band.cpp
+++ b/engines/saga2/band.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/band.h"
diff --git a/engines/saga2/beegee.cpp b/engines/saga2/beegee.cpp
index 2ed850cf4e..9938e088c0 100644
--- a/engines/saga2/beegee.cpp
+++ b/engines/saga2/beegee.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/fta.h"
#include "saga2/tile.h"
diff --git a/engines/saga2/blitters.cpp b/engines/saga2/blitters.cpp
index daa9f66bae..fb3512298c 100644
--- a/engines/saga2/blitters.cpp
+++ b/engines/saga2/blitters.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/saga2.h"
#include "common/memstream.h"
diff --git a/engines/saga2/button.cpp b/engines/saga2/button.cpp
index 249a2f57d9..bc3c1976af 100644
--- a/engines/saga2/button.cpp
+++ b/engines/saga2/button.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/cmisc.h"
diff --git a/engines/saga2/calender.cpp b/engines/saga2/calender.cpp
index 1889a881e5..9ef9ecc08a 100644
--- a/engines/saga2/calender.cpp
+++ b/engines/saga2/calender.cpp
@@ -24,6 +24,9 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
+#include "saga2/std.h"
#include "saga2/calender.h"
#include "saga2/intrface.h"
#include "saga2/config.h"
diff --git a/engines/saga2/calender.h b/engines/saga2/calender.h
index 024ebc68c5..840fbfad7c 100644
--- a/engines/saga2/calender.h
+++ b/engines/saga2/calender.h
@@ -27,7 +27,6 @@
#ifndef SAGA2_CALENDER_H
#define SAGA2_CALENDER_H
-#include "saga2/std.h"
#include "saga2/savefile.h"
namespace Saga2 {
diff --git a/engines/saga2/config.cpp b/engines/saga2/config.cpp
index 83f316f8a8..799e5c20f3 100644
--- a/engines/saga2/config.cpp
+++ b/engines/saga2/config.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/config.h"
diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index c0666ac334..d6a268eb53 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/objects.h"
#include "saga2/contain.h"
diff --git a/engines/saga2/display.cpp b/engines/saga2/display.cpp
index 76e5575ec0..4765d82c7a 100644
--- a/engines/saga2/display.cpp
+++ b/engines/saga2/display.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/display.h"
#include "saga2/nice_err.h"
diff --git a/engines/saga2/dispnode.cpp b/engines/saga2/dispnode.cpp
index ea8a50356d..3dde17e709 100644
--- a/engines/saga2/dispnode.cpp
+++ b/engines/saga2/dispnode.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/dispnode.h"
diff --git a/engines/saga2/dlist.cpp b/engines/saga2/dlist.cpp
index b85baced55..f4afb5dfe6 100644
--- a/engines/saga2/dlist.cpp
+++ b/engines/saga2/dlist.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/dlist.h"
diff --git a/engines/saga2/document.cpp b/engines/saga2/document.cpp
index 5c8ab6a5b3..d54a7f481c 100644
--- a/engines/saga2/document.cpp
+++ b/engines/saga2/document.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/document.h"
#include "saga2/cmisc.h"
diff --git a/engines/saga2/effects.cpp b/engines/saga2/effects.cpp
index 3fce3a772d..080dd073af 100644
--- a/engines/saga2/effects.cpp
+++ b/engines/saga2/effects.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/cmisc.h"
#include "saga2/spellbuk.h"
diff --git a/engines/saga2/enchant.cpp b/engines/saga2/enchant.cpp
index 96222e384c..092a760513 100644
--- a/engines/saga2/enchant.cpp
+++ b/engines/saga2/enchant.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/objects.h"
#include "saga2/actor.h"
diff --git a/engines/saga2/errbase.cpp b/engines/saga2/errbase.cpp
index 8de81a3ec7..0108c8ad6e 100644
--- a/engines/saga2/errbase.cpp
+++ b/engines/saga2/errbase.cpp
@@ -28,6 +28,8 @@
Includes
* ===================================================================== */
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/errbase.h"
diff --git a/engines/saga2/errclass.cpp b/engines/saga2/errclass.cpp
index 723ec70b06..ca63770ae6 100644
--- a/engines/saga2/errclass.cpp
+++ b/engines/saga2/errclass.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/errclass.h"
diff --git a/engines/saga2/errlist.cpp b/engines/saga2/errlist.cpp
index 6a6978b4ca..923218abaa 100644
--- a/engines/saga2/errlist.cpp
+++ b/engines/saga2/errlist.cpp
@@ -28,6 +28,8 @@
Includes
* ===================================================================== */
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/errlist.h"
diff --git a/engines/saga2/errors.cpp b/engines/saga2/errors.cpp
index dd649f12e2..317528d490 100644
--- a/engines/saga2/errors.cpp
+++ b/engines/saga2/errors.cpp
@@ -28,6 +28,8 @@
Includes
* ===================================================================== */
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/errlist.h"
#include "saga2/errtype.h"
diff --git a/engines/saga2/exit.cpp b/engines/saga2/exit.cpp
index db60982ec9..08ecff06e5 100644
--- a/engines/saga2/exit.cpp
+++ b/engines/saga2/exit.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
namespace Saga2 {
diff --git a/engines/saga2/floating.cpp b/engines/saga2/floating.cpp
index 4be2c0b102..d3f548c1bb 100644
--- a/engines/saga2/floating.cpp
+++ b/engines/saga2/floating.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/fta.h"
diff --git a/engines/saga2/gamemode.cpp b/engines/saga2/gamemode.cpp
index 838b550d3e..dcbbca9ec3 100644
--- a/engines/saga2/gamemode.cpp
+++ b/engines/saga2/gamemode.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
diff --git a/engines/saga2/gdraw.cpp b/engines/saga2/gdraw.cpp
index 1596a88078..603ac8cecf 100644
--- a/engines/saga2/gdraw.cpp
+++ b/engines/saga2/gdraw.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/gdraw.h"
#include "saga2/gblitter.h"
diff --git a/engines/saga2/gpointer.cpp b/engines/saga2/gpointer.cpp
index 7643930e0d..28b585fbbb 100644
--- a/engines/saga2/gpointer.cpp
+++ b/engines/saga2/gpointer.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/vdraw.h"
#include "saga2/gpointer.h"
diff --git a/engines/saga2/grabinfo.cpp b/engines/saga2/grabinfo.cpp
index caf37fa1fc..10cc5361fb 100644
--- a/engines/saga2/grabinfo.cpp
+++ b/engines/saga2/grabinfo.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/gdraw.h"
#include "saga2/images.h"
diff --git a/engines/saga2/grequest.cpp b/engines/saga2/grequest.cpp
index ab8651b04c..b925b60a84 100644
--- a/engines/saga2/grequest.cpp
+++ b/engines/saga2/grequest.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/grequest.h"
diff --git a/engines/saga2/gtext.cpp b/engines/saga2/gtext.cpp
index c1ad035adc..4a1525a438 100644
--- a/engines/saga2/gtext.cpp
+++ b/engines/saga2/gtext.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/errors.h"
#include "saga2/gdraw.h"
diff --git a/engines/saga2/gtextbox.cpp b/engines/saga2/gtextbox.cpp
index 32dcc2b19e..06d035e6d7 100644
--- a/engines/saga2/gtextbox.cpp
+++ b/engines/saga2/gtextbox.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/cmisc.h"
#include "saga2/fta.h"
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index c73da2521e..8969e7ec92 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/saga2.h"
#include "saga2/rmemfta.h"
diff --git a/engines/saga2/iff.cpp b/engines/saga2/iff.cpp
index f4e89c8f46..f438de126e 100644
--- a/engines/saga2/iff.cpp
+++ b/engines/saga2/iff.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/errors.h"
#include "saga2/iff.h"
diff --git a/engines/saga2/imagcach.cpp b/engines/saga2/imagcach.cpp
index a6909735b1..0b2a7c7f20 100644
--- a/engines/saga2/imagcach.cpp
+++ b/engines/saga2/imagcach.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/fta.h"
diff --git a/engines/saga2/images.cpp b/engines/saga2/images.cpp
index a9acedb15f..73b94c6cb2 100644
--- a/engines/saga2/images.cpp
+++ b/engines/saga2/images.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/gdraw.h"
diff --git a/engines/saga2/input.cpp b/engines/saga2/input.cpp
index 6a13ffd4bc..9d6161934f 100644
--- a/engines/saga2/input.cpp
+++ b/engines/saga2/input.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/input.h"
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 590e95e593..c1f615d65a 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/fta.h"
#include "saga2/script.h"
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index cc89cc23b5..d127ad0fd3 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/objects.h"
#include "saga2/button.h"
diff --git a/engines/saga2/itevideo.cpp b/engines/saga2/itevideo.cpp
index 2eaebaa4d4..07282c0143 100644
--- a/engines/saga2/itevideo.cpp
+++ b/engines/saga2/itevideo.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/video.h"
diff --git a/engines/saga2/keybored.cpp b/engines/saga2/keybored.cpp
index f4eca418d7..555f41eda6 100644
--- a/engines/saga2/keybored.cpp
+++ b/engines/saga2/keybored.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/tilemode.h"
diff --git a/engines/saga2/loadmsg.cpp b/engines/saga2/loadmsg.cpp
index 053a3735b3..8f64daabd0 100644
--- a/engines/saga2/loadmsg.cpp
+++ b/engines/saga2/loadmsg.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "graphics/palette.h"
diff --git a/engines/saga2/loadsave.cpp b/engines/saga2/loadsave.cpp
index afd0f6f9c0..8669c8c545 100644
--- a/engines/saga2/loadsave.cpp
+++ b/engines/saga2/loadsave.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/loadsave.h"
#include "saga2/savefile.h"
diff --git a/engines/saga2/magic.cpp b/engines/saga2/magic.cpp
index 704a668d55..c890b6a3ef 100644
--- a/engines/saga2/magic.cpp
+++ b/engines/saga2/magic.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/magic.h"
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 9e8cb51cb4..bf03915551 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/rmemfta.h"
diff --git a/engines/saga2/mainmap.cpp b/engines/saga2/mainmap.cpp
index a14532a96e..3639604f52 100644
--- a/engines/saga2/mainmap.cpp
+++ b/engines/saga2/mainmap.cpp
@@ -25,6 +25,8 @@
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/fta.h"
#include "saga2/mainmap.h"
diff --git a/engines/saga2/mapfeatr.cpp b/engines/saga2/mapfeatr.cpp
index 3fa888048e..f8b88b7bbe 100644
--- a/engines/saga2/mapfeatr.cpp
+++ b/engines/saga2/mapfeatr.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/mapfeatr.h"
#include "saga2/automap.h"
diff --git a/engines/saga2/maprange.cpp b/engines/saga2/maprange.cpp
index 2ea3720549..282b830bc5 100644
--- a/engines/saga2/maprange.cpp
+++ b/engines/saga2/maprange.cpp
@@ -30,6 +30,8 @@
Converted by iff2c.
* ===================================================================== */
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
namespace Saga2 {
diff --git a/engines/saga2/messager.cpp b/engines/saga2/messager.cpp
index 15c203107d..094da7eb4b 100644
--- a/engines/saga2/messager.cpp
+++ b/engines/saga2/messager.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/messager.h"
diff --git a/engines/saga2/mission.cpp b/engines/saga2/mission.cpp
index 75fa4a45e2..fa1cb96869 100644
--- a/engines/saga2/mission.cpp
+++ b/engines/saga2/mission.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/mission.h"
diff --git a/engines/saga2/modal.cpp b/engines/saga2/modal.cpp
index c627383473..bea28d22f7 100644
--- a/engines/saga2/modal.cpp
+++ b/engines/saga2/modal.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/fta.h"
#include "saga2/modal.h"
diff --git a/engines/saga2/mono.cpp b/engines/saga2/mono.cpp
index 522b2ddc97..b79edeeb6d 100644
--- a/engines/saga2/mono.cpp
+++ b/engines/saga2/mono.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/mono.h"
diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp
index 5be9ca9098..576d336645 100644
--- a/engines/saga2/motion.cpp
+++ b/engines/saga2/motion.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/cmisc.h"
#include "saga2/dispnode.h"
diff --git a/engines/saga2/mouseimg.cpp b/engines/saga2/mouseimg.cpp
index 6c95592de5..1d61669bea 100644
--- a/engines/saga2/mouseimg.cpp
+++ b/engines/saga2/mouseimg.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/fta.h"
diff --git a/engines/saga2/nice_err.cpp b/engines/saga2/nice_err.cpp
index 3324af9a0a..694446d383 100644
--- a/engines/saga2/nice_err.cpp
+++ b/engines/saga2/nice_err.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/cmisc.h"
diff --git a/engines/saga2/noise.cpp b/engines/saga2/noise.cpp
index d934975d86..ac11709794 100644
--- a/engines/saga2/noise.cpp
+++ b/engines/saga2/noise.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/fta.h"
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 779698ebcc..e0eee83a1b 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/objects.h"
diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp
index 4425647534..cc1fee6efd 100644
--- a/engines/saga2/objproto.cpp
+++ b/engines/saga2/objproto.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/sprite.h"
#include "saga2/objects.h"
diff --git a/engines/saga2/osexcept.cpp b/engines/saga2/osexcept.cpp
index d78b60d8f1..f09a8afdb4 100644
--- a/engines/saga2/osexcept.cpp
+++ b/engines/saga2/osexcept.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/osexcept.h"
diff --git a/engines/saga2/panel.cpp b/engines/saga2/panel.cpp
index 46970db0ee..9f6d3eaa26 100644
--- a/engines/saga2/panel.cpp
+++ b/engines/saga2/panel.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/panel.h"
diff --git a/engines/saga2/path.cpp b/engines/saga2/path.cpp
index 689b8f4aea..89f117431d 100644
--- a/engines/saga2/path.cpp
+++ b/engines/saga2/path.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/dispnode.h"
#include "saga2/tcoords.h"
diff --git a/engines/saga2/patrol.cpp b/engines/saga2/patrol.cpp
index 56cc6a34d4..c1984e6f2a 100644
--- a/engines/saga2/patrol.cpp
+++ b/engines/saga2/patrol.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/fta.h"
#include "saga2/patrol.h"
diff --git a/engines/saga2/player.cpp b/engines/saga2/player.cpp
index b262949c6d..6adfa1db6c 100644
--- a/engines/saga2/player.cpp
+++ b/engines/saga2/player.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/cmisc.h"
#include "saga2/player.h"
diff --git a/engines/saga2/playmode.cpp b/engines/saga2/playmode.cpp
index 9ec7d4b488..0e24d1191d 100644
--- a/engines/saga2/playmode.cpp
+++ b/engines/saga2/playmode.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/tcoords.h"
diff --git a/engines/saga2/pool.cpp b/engines/saga2/pool.cpp
index c26e1834ac..e3a90fbdc0 100644
--- a/engines/saga2/pool.cpp
+++ b/engines/saga2/pool.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/pool.h"
diff --git a/engines/saga2/property.cpp b/engines/saga2/property.cpp
index 805ffdd848..c10a839e9f 100644
--- a/engines/saga2/property.cpp
+++ b/engines/saga2/property.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/player.h"
#include "saga2/tile.h"
diff --git a/engines/saga2/pt2angle.cpp b/engines/saga2/pt2angle.cpp
index 11f12b9d20..e71a90c66c 100644
--- a/engines/saga2/pt2angle.cpp
+++ b/engines/saga2/pt2angle.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
namespace Saga2 {
diff --git a/engines/saga2/rect.cpp b/engines/saga2/rect.cpp
index a3b676b34d..1b3c305a0a 100644
--- a/engines/saga2/rect.cpp
+++ b/engines/saga2/rect.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/rect.h"
diff --git a/engines/saga2/rmem.cpp b/engines/saga2/rmem.cpp
index cb8c4d6f23..040fc7c493 100644
--- a/engines/saga2/rmem.cpp
+++ b/engines/saga2/rmem.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#define NO_LOCAL_MEMORY_OVERRIDES 1
diff --git a/engines/saga2/rserver.cpp b/engines/saga2/rserver.cpp
index b058b61949..7b78c258bc 100644
--- a/engines/saga2/rserver.cpp
+++ b/engines/saga2/rserver.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/dlist.h"
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index ab54ee4121..a8ba326b4f 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -34,6 +34,8 @@
#include "saga2/saga2.h"
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/loadmsg.h"
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index fc7e913469..4078af8da8 100644
--- a/engines/saga2/sagafunc.cpp
+++ b/engines/saga2/sagafunc.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/fta.h"
#include "saga2/script.h"
diff --git a/engines/saga2/savefile.cpp b/engines/saga2/savefile.cpp
index 356416e97d..8738a0a145 100644
--- a/engines/saga2/savefile.cpp
+++ b/engines/saga2/savefile.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/savefile.h"
#include "saga2/config.h"
diff --git a/engines/saga2/sensor.cpp b/engines/saga2/sensor.cpp
index 2567c679f9..da852eecca 100644
--- a/engines/saga2/sensor.cpp
+++ b/engines/saga2/sensor.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/sensor.h"
#include "saga2/pool.h"
diff --git a/engines/saga2/speech.cpp b/engines/saga2/speech.cpp
index 572209a6f6..7c9d02dbcf 100644
--- a/engines/saga2/speech.cpp
+++ b/engines/saga2/speech.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/fta.h"
#include "saga2/fontlib.h"
diff --git a/engines/saga2/spelcast.cpp b/engines/saga2/spelcast.cpp
index 47dbdee8b8..506315c19e 100644
--- a/engines/saga2/spelcast.cpp
+++ b/engines/saga2/spelcast.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/magic.h"
diff --git a/engines/saga2/speldata.cpp b/engines/saga2/speldata.cpp
index 1211ebb20a..ac6954dce4 100644
--- a/engines/saga2/speldata.cpp
+++ b/engines/saga2/speldata.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/dispnode.h"
diff --git a/engines/saga2/speldraw.cpp b/engines/saga2/speldraw.cpp
index 2f3a60a487..3eb9428bf4 100644
--- a/engines/saga2/speldraw.cpp
+++ b/engines/saga2/speldraw.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/dispnode.h"
diff --git a/engines/saga2/spellini.cpp b/engines/saga2/spellini.cpp
index b792876ed4..f03c2eafe4 100644
--- a/engines/saga2/spellini.cpp
+++ b/engines/saga2/spellini.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/spellbuk.h"
#include "saga2/spelvals.h"
diff --git a/engines/saga2/spellio.cpp b/engines/saga2/spellio.cpp
index d75f562df5..af2d6b620b 100644
--- a/engines/saga2/spellio.cpp
+++ b/engines/saga2/spellio.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/magic.h"
diff --git a/engines/saga2/spellloc.cpp b/engines/saga2/spellloc.cpp
index df6539f21c..556739db38 100644
--- a/engines/saga2/spellloc.cpp
+++ b/engines/saga2/spellloc.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/spellbuk.h"
#include "saga2/spelvals.h"
diff --git a/engines/saga2/spellsiz.cpp b/engines/saga2/spellsiz.cpp
index 0f339301f2..6263616497 100644
--- a/engines/saga2/spellsiz.cpp
+++ b/engines/saga2/spellsiz.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/spellbuk.h"
diff --git a/engines/saga2/spellspr.cpp b/engines/saga2/spellspr.cpp
index c01428f902..c65b859fdc 100644
--- a/engines/saga2/spellspr.cpp
+++ b/engines/saga2/spellspr.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/spellbuk.h"
diff --git a/engines/saga2/spellsta.cpp b/engines/saga2/spellsta.cpp
index 033d35b027..49fe49274c 100644
--- a/engines/saga2/spellsta.cpp
+++ b/engines/saga2/spellsta.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/spellbuk.h"
#include "saga2/spelvals.h"
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index cc9fa6c0d1..d4554ccd20 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/sprite.h"
#include "saga2/tcoords.h"
diff --git a/engines/saga2/std.h b/engines/saga2/std.h
index c3f65233ec..5e928af5ed 100644
--- a/engines/saga2/std.h
+++ b/engines/saga2/std.h
@@ -27,9 +27,6 @@
#ifndef SAGA2_STD_H
#define SAGA2_STD_H
-// FIXME. Remove this
-#define FORBIDDEN_SYMBOL_ALLOW_ALL
-
#include "common/system.h"
#include "saga2/rmemfta.h"
diff --git a/engines/saga2/target.cpp b/engines/saga2/target.cpp
index eba3bf52e9..f7f51869de 100644
--- a/engines/saga2/target.cpp
+++ b/engines/saga2/target.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/cmisc.h"
#include "saga2/target.h"
diff --git a/engines/saga2/task.cpp b/engines/saga2/task.cpp
index fbe6fb786e..f6d3326fc6 100644
--- a/engines/saga2/task.cpp
+++ b/engines/saga2/task.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/cmisc.h"
#include "saga2/task.h"
diff --git a/engines/saga2/terrain.cpp b/engines/saga2/terrain.cpp
index b9312f879c..7700d90a75 100644
--- a/engines/saga2/terrain.cpp
+++ b/engines/saga2/terrain.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/tcoords.h"
#include "saga2/tile.h"
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index ebed3aaa9d..df817a8138 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/tcoords.h"
#include "saga2/objects.h"
diff --git a/engines/saga2/tileline.cpp b/engines/saga2/tileline.cpp
index 021f3651eb..235056b827 100644
--- a/engines/saga2/tileline.cpp
+++ b/engines/saga2/tileline.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/tileline.h"
#include "saga2/tcoords.h"
diff --git a/engines/saga2/tileload.cpp b/engines/saga2/tileload.cpp
index b6ad067a45..04735ac7a6 100644
--- a/engines/saga2/tileload.cpp
+++ b/engines/saga2/tileload.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/input.h"
#include "saga2/cmisc.h"
diff --git a/engines/saga2/tilemode.cpp b/engines/saga2/tilemode.cpp
index 2fbe9fdc97..60a9bdf7c5 100644
--- a/engines/saga2/tilemode.cpp
+++ b/engines/saga2/tilemode.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/tilemode.h"
#include "saga2/tile.h"
diff --git a/engines/saga2/timer.cpp b/engines/saga2/timer.cpp
index c52ef15dbd..fafc84f396 100644
--- a/engines/saga2/timer.cpp
+++ b/engines/saga2/timer.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/fta.h"
#include "saga2/audio.h"
diff --git a/engines/saga2/timers.cpp b/engines/saga2/timers.cpp
index 67a173e966..676bb35aa2 100644
--- a/engines/saga2/timers.cpp
+++ b/engines/saga2/timers.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/timers.h"
#include "saga2/pool.h"
diff --git a/engines/saga2/tower.cpp b/engines/saga2/tower.cpp
index c7b86b45d0..d3e40593c9 100644
--- a/engines/saga2/tower.cpp
+++ b/engines/saga2/tower.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/tower.h"
#include "saga2/osexcept.h"
diff --git a/engines/saga2/towerfta.cpp b/engines/saga2/towerfta.cpp
index 1151f9137f..d000c3e3bc 100644
--- a/engines/saga2/towerfta.cpp
+++ b/engines/saga2/towerfta.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/towerwin.h"
diff --git a/engines/saga2/transit.cpp b/engines/saga2/transit.cpp
index b254e6abb9..243e6bd099 100644
--- a/engines/saga2/transit.cpp
+++ b/engines/saga2/transit.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/fta.h"
#include "saga2/tile.h"
diff --git a/engines/saga2/tromode.cpp b/engines/saga2/tromode.cpp
index 23670b6fe3..ce25a6f7c8 100644
--- a/engines/saga2/tromode.cpp
+++ b/engines/saga2/tromode.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/cmisc.h"
#include "saga2/input.h"
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index 209532e4c4..60e9268390 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/objects.h"
diff --git a/engines/saga2/vbacksav.cpp b/engines/saga2/vbacksav.cpp
index 29e3620cad..1117b482b1 100644
--- a/engines/saga2/vbacksav.cpp
+++ b/engines/saga2/vbacksav.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/vbacksav.h"
#include "saga2/rmemfta.h"
diff --git a/engines/saga2/verify.cpp b/engines/saga2/verify.cpp
index 03515d7904..1b814fc68f 100644
--- a/engines/saga2/verify.cpp
+++ b/engines/saga2/verify.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/errclass.h"
diff --git a/engines/saga2/video.cpp b/engines/saga2/video.cpp
index 7c4820a959..0ed23f6c1c 100644
--- a/engines/saga2/video.cpp
+++ b/engines/saga2/video.cpp
@@ -26,6 +26,8 @@
// Tiny Smacker player for the Miles Sound System
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/video.h"
diff --git a/engines/saga2/videobox.cpp b/engines/saga2/videobox.cpp
index 84ef96b07a..d4836a64d9 100644
--- a/engines/saga2/videobox.cpp
+++ b/engines/saga2/videobox.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/videobox.h"
diff --git a/engines/saga2/videomem.cpp b/engines/saga2/videomem.cpp
index 51b9c1f714..313efdf301 100644
--- a/engines/saga2/videomem.cpp
+++ b/engines/saga2/videomem.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/videomem.h"
diff --git a/engines/saga2/vidhook.cpp b/engines/saga2/vidhook.cpp
index f495707f25..fd0337147b 100644
--- a/engines/saga2/vidhook.cpp
+++ b/engines/saga2/vidhook.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/video.h"
diff --git a/engines/saga2/vidsmk.cpp b/engines/saga2/vidsmk.cpp
index 90602b6d1c..10a08662bb 100644
--- a/engines/saga2/vidsmk.cpp
+++ b/engines/saga2/vidsmk.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/video.h"
diff --git a/engines/saga2/vpal.cpp b/engines/saga2/vpal.cpp
index d5915cfc5b..d628205f6a 100644
--- a/engines/saga2/vpal.cpp
+++ b/engines/saga2/vpal.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/fta.h"
#include "saga2/iff.h"
diff --git a/engines/saga2/vwdraw.cpp b/engines/saga2/vwdraw.cpp
index b8aa9057f7..899470e34a 100644
--- a/engines/saga2/vwdraw.cpp
+++ b/engines/saga2/vwdraw.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/vwpage.h"
diff --git a/engines/saga2/vwpage.cpp b/engines/saga2/vwpage.cpp
index 21e684a79f..a148899684 100644
--- a/engines/saga2/vwpage.cpp
+++ b/engines/saga2/vwpage.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/vwpage.h"
#include "saga2/display.h"
diff --git a/engines/saga2/weapons.cpp b/engines/saga2/weapons.cpp
index ef311edc08..fc934d513b 100644
--- a/engines/saga2/weapons.cpp
+++ b/engines/saga2/weapons.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/weapons.h"
diff --git a/engines/saga2/winini.cpp b/engines/saga2/winini.cpp
index 046c037b0f..6315122000 100644
--- a/engines/saga2/winini.cpp
+++ b/engines/saga2/winini.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
#include "saga2/std.h"
#include "saga2/winini.h"
Commit: 823bdc404d846e142b40b30afae5c68c67211206
https://github.com/scummvm/scummvm/commit/823bdc404d846e142b40b30afae5c68c67211206
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:46+02:00
Commit Message:
SAGA2: Use Common::File operations for LoadResource
Changed paths:
engines/saga2/hresmgr.cpp
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index 8969e7ec92..94f5fcda04 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -125,12 +125,12 @@ hResEntry *hResContext::findEntry(hResID id, RHANDLE **capture) {
_bytepos = 0;
if (!_valid) return nullptr;
- debugC(kDebugResources, "findEntry: looking for %d (%s)", id, tag2str(id));
+ debugC(kDebugResources, "findEntry: looking for %x (%s)", id, tag2str(id));
for (i = 0, entry = _base; i < _numEntries; i++, entry++) {
- debugC(kDebugResources, "%d: Trying ID: %d (%s)", i, entry->id, tag2str(entry->id));
+ debugC(kDebugResources, "%x: Trying ID: %x (%s)", i, entry->id, tag2str(entry->id));
if (entry->id == id) {
if (capture) *capture = &_data[ i ];
- debugC(kDebugResources, "findEntry: found %d (%s)", entry->id, tag2str(entry->id));
+ debugC(kDebugResources, "findEntry: found %x (%s)", entry->id, tag2str(entry->id));
return entry;
}
}
@@ -221,7 +221,7 @@ void hResContext::rest(void) {
_bytecount = 0;
_bytepos = 0;
if (_valid && _handle && _handle != _res->_handle) {
- HR_CLOSE(_handle);
+ _handle->close();
_handle = nullptr;
}
}
@@ -230,7 +230,7 @@ bool hResContext::read(void *buffer, int32 size) {
if (!_valid) return false;
_bytecount = 0;
_bytepos = 0;
- return (HR_READ(buffer, size, 1, _handle) == 1);
+ return _handle->read(buffer, size);
}
bool hResContext::eor(void) {
@@ -399,7 +399,7 @@ void hResource::readResource(hResEntry &element) {
element.size = _file.readUint32LE();
uint32 id = element.id;
- debugC(kDebugResources, "%s, offset: %d, size: %d", tag2str(id), element.offset, element.size);
+ debugC(kDebugResources, "%s, offset: %x, size: %d", tag2str(id), element.offset, element.size);
}
hResource::hResource(char *resname, char *extname, const char desc[]) {
Commit: ee924d93abf8b24a4d11f80b230b489af6177bc3
https://github.com/scummvm/scummvm/commit/ee924d93abf8b24a4d11f80b230b489af6177bc3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:46+02:00
Commit Message:
SAGA2: Cleanup and fixing warnings
Changed paths:
engines/saga2/errlist.cpp
engines/saga2/errlist.h
engines/saga2/errors.cpp
engines/saga2/objproto.h
diff --git a/engines/saga2/errlist.cpp b/engines/saga2/errlist.cpp
index 923218abaa..ad39a9a1c5 100644
--- a/engines/saga2/errlist.cpp
+++ b/engines/saga2/errlist.cpp
@@ -51,7 +51,7 @@ SequentialErrorList::SequentialErrorList(ErrType et, uint32 ec, char *es[]) :
// ------------------------------------------------------------------
//
-SequentialErrorList::SequentialErrorList(ErrType et, char *es[]) :
+SequentialErrorList::SequentialErrorList(ErrType et, const char *es[]) :
ErrorList(et, stringCount(es)) {
for (int i = 0; i < eLimit(); i++)
setEntry(i, i, es[i]);
@@ -60,7 +60,7 @@ SequentialErrorList::SequentialErrorList(ErrType et, char *es[]) :
// ------------------------------------------------------------------
//
-uint32 SequentialErrorList::stringCount(char *es[]) {
+uint32 SequentialErrorList::stringCount(const char *es[]) {
uint32 rv = 0;
if (es == NULL)
return 0;
diff --git a/engines/saga2/errlist.h b/engines/saga2/errlist.h
index 05317217a3..f0f1f856fb 100644
--- a/engines/saga2/errlist.h
+++ b/engines/saga2/errlist.h
@@ -27,41 +27,27 @@
#ifndef SAGA2_ERRLIST_H
#define SAGA2_ERRLIST_H
-/* ===================================================================== *
- Includes
- * ===================================================================== */
-
#include "saga2/errbase.h"
namespace Saga2 {
-/* ===================================================================== *
- Class definitions
- * ===================================================================== */
-
-// ------------------------------------------------------------------
-//
-
-class SequentialErrorList: public ErrorList {
- static uint32 stringCount(char *es[]);
+class SequentialErrorList : public ErrorList {
+ static uint32 stringCount(const char *es[]);
protected:
virtual uint32 lookupMessage(ErrorID id);
public:
SequentialErrorList(ErrType et, uint32 ec, char *es[]);
- SequentialErrorList(ErrType et, char *es[]);
-
+ SequentialErrorList(ErrType et, const char *es[]);
+ virtual ~SequentialErrorList() {}
};
-// ------------------------------------------------------------------
-//
-
-class SparseErrorList: public ErrorList {
+class SparseErrorList : public ErrorList {
protected:
virtual uint32 lookupMessage(ErrorID id);
public:
SparseErrorList(ErrType et, uint32 ec, ErrorID ei[], const char *es[]);
SparseErrorList(ErrType et, uint32 ec, ErrorRec er[]);
-
+ virtual ~SparseErrorList() {}
};
}
diff --git a/engines/saga2/errors.cpp b/engines/saga2/errors.cpp
index 317528d490..d22b5367d0 100644
--- a/engines/saga2/errors.cpp
+++ b/engines/saga2/errors.cpp
@@ -24,12 +24,6 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-/* ===================================================================== *
- Includes
- * ===================================================================== */
-
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/errlist.h"
#include "saga2/errtype.h"
@@ -39,7 +33,7 @@ namespace Saga2 {
// ------------------------------------------------------------------
// FTA2 error text
-char *FTA2ProgramErrors[] = {
+const char *FTA2ProgramErrors[] = {
"No Error",
"Unknown command line argument",
@@ -101,146 +95,6 @@ char *FTA2ProgramErrors[] = {
""
};
-// ------------------------------------------------------------------
-// FTA2 error list
-
-SequentialErrorList
-programErrors(etiFTA2ErrorList, FTA2ProgramErrors);
-
-#ifdef _WIN32
-
-// ------------------------------------------------------------------
-// WIN32 exceptions
-
-ErrorRec win32Exceptions[] = {
- { EXCEPTION_ACCESS_VIOLATION, "General Access Violation" },
- { EXCEPTION_BREAKPOINT, "A debugger breakpoint" },
- { EXCEPTION_DATATYPE_MISALIGNMENT, "Data Alignment error" },
- { EXCEPTION_SINGLE_STEP, "Debugger single-step" },
- { EXCEPTION_ARRAY_BOUNDS_EXCEEDED, "Array index out of bounds" },
- { EXCEPTION_FLT_DENORMAL_OPERAND, "FP: Denormal operand" },
- { EXCEPTION_FLT_DIVIDE_BY_ZERO, "FP: Division by zero" },
- { EXCEPTION_FLT_INEXACT_RESULT, "FP: inexact result" },
- { EXCEPTION_FLT_INVALID_OPERATION, "FP: invalid operand" },
- { EXCEPTION_FLT_OVERFLOW, "FP: overflow" },
- { EXCEPTION_FLT_STACK_CHECK, "FP: stack overflow" },
- { EXCEPTION_FLT_UNDERFLOW, "FP: underflow" },
- { EXCEPTION_INT_DIVIDE_BY_ZERO, "Int: division by zero" },
- { EXCEPTION_INT_OVERFLOW, "Int: overflow" },
- { EXCEPTION_PRIV_INSTRUCTION, "Priviledged instruction" },
- { EXCEPTION_NONCONTINUABLE_EXCEPTION, "Attempt to continue after last exception was unsucessful" }
-};
-
-// ------------------------------------------------------------------
-// WIN32 exception error list
-
-SparseErrorList
-win32ExceptionList(etiWin32ExceptionList, 16, win32Exceptions);
-
-
-#include "ddraw.h"
-
-#ifndef __WATCOMC__
-#pragma warning(disable : 4245)
-#endif
-
-ErrorRec directDrawErrors[] = {
- { DDERR_ALREADYINITIALIZED, "This object is already initialized " },
- { DDERR_BLTFASTCANTCLIP, "Return if a clipper object is attached to the source surface passed into a BltFast call." },
- { DDERR_CANNOTATTACHSURFACE, "This surface can not be attached to the requested surface." },
- { DDERR_CANNOTDETACHSURFACE, "This surface can not be detached from the requested surface." },
- { DDERR_CANTCREATEDC, "Windows can not create any more DCs" },
- { DDERR_CANTDUPLICATE, "Can't duplicate primary & 3D surfaces, or surfaces that are implicitly created." },
- { DDERR_CLIPPERISUSINGHWND, "An attempt was made to set a cliplist for a clipper object that is already monitoring an hwnd." },
- { DDERR_COLORKEYNOTSET, "No src color key specified for this operation." },
- { DDERR_CURRENTLYNOTAVAIL, "Support is currently not available." },
- { DDERR_DIRECTDRAWALREADYCREATED, "A DirectDraw object representing this driver has already been created for this process." },
- { DDERR_EXCEPTION, "An exception was encountered while performing the requested operation." },
- { DDERR_EXCLUSIVEMODEALREADYSET, "An attempt was made to set the cooperative level when it was already set to exclusive." },
- { DDERR_GENERIC, "Generic failure." },
- { DDERR_HEIGHTALIGN, "Height of rectangle provided is not a multiple of reqd alignment." },
- { DDERR_HWNDALREADYSET, "The CooperativeLevel HWND has already been set. It can not be reset while the process has surfaces or palettes created." },
- { DDERR_HWNDSUBCLASSED, "HWND used by DirectDraw CooperativeLevel has been subclassed, this prevents DirectDraw from restoring state." },
- { DDERR_IMPLICITLYCREATED, "This surface can not be restored because it is an implicitly created surface." },
- { DDERR_INCOMPATIBLEPRIMARY, "Unable to match primary surface creation request with existing primary surface." },
- { DDERR_INVALIDCAPS, "One or more of the caps bits passed to the callback are incorrect." },
- { DDERR_INVALIDCLIPLIST, "DirectDraw does not support the provided cliplist." },
- { DDERR_INVALIDDIRECTDRAWGUID, "The GUID passed to DirectDrawCreate is not a valid DirectDraw driver identifier." },
- { DDERR_INVALIDMODE, "DirectDraw does not support the requested mode." },
- { DDERR_INVALIDOBJECT, "DirectDraw received a pointer that was an invalid DIRECTDRAW object." },
- { DDERR_INVALIDPARAMS, "One or more of the parameters passed to the function are incorrect." },
- { DDERR_INVALIDPIXELFORMAT, "The pixel format was invalid as specified." },
- { DDERR_INVALIDPOSITION, "Returned when the position of the overlay on the destination is no longer legal for that destination." },
- { DDERR_INVALIDRECT, "Rectangle provided was invalid." },
- { DDERR_LOCKEDSURFACES, "Operation could not be carried out because one or more surfaces are locked." },
- { DDERR_NO3D, "There is no 3D present." },
- { DDERR_NOALPHAHW, "Operation could not be carried out because there is no alpha accleration hardware present or available." },
- { DDERR_NOBLTHW, "No blter hardware present." },
- { DDERR_NOCLIPLIST, "No cliplist available." },
- { DDERR_NOCLIPPERATTACHED, "No clipper object attached to surface object." },
- { DDERR_NOCOLORCONVHW, "Operation could not be carried out because there is no color conversion hardware present or available." },
- { DDERR_NOCOLORKEY, "Surface doesn't currently have a color key" },
- { DDERR_NOCOLORKEYHW, "Operation could not be carried out because there is no hardware support of the destination color key." },
- { DDERR_NOCOOPERATIVELEVELSET, "Create function called without DirectDraw object method SetCooperativeLevel being called." },
- { DDERR_NODC, "No DC was ever created for this surface." },
- { DDERR_NODDROPSHW, "No DirectDraw ROP hardware." },
- { DDERR_NODIRECTDRAWHW, "A hardware-only DirectDraw object creation was attempted but the driver did not support any hardware." },
- { DDERR_NOEMULATION, "Software emulation not available." },
- { DDERR_NOEXCLUSIVEMODE, "Operation requires the application to have exclusive mode but the application does not have exclusive mode." },
- { DDERR_NOFLIPHW, "Flipping visible surfaces is not supported." },
- { DDERR_NOGDI, "There is no GDI present." },
- { DDERR_NOHWND, "Clipper notification requires an HWND or no HWND has previously been set as the CooperativeLevel HWND." },
- { DDERR_NOMIRRORHW, "Operation could not be carried out because there is no hardware present or available." },
- { DDERR_NOOVERLAYDEST, "Returned when GetOverlayPosition is called on an overlay that UpdateOverlay has never been called on to establish a destination." },
- { DDERR_NOOVERLAYHW, "Operation could not be carried out because there is no overlay hardware present or available." },
- { DDERR_NOPALETTEATTACHED, "No palette object attached to this surface." },
- { DDERR_NOPALETTEHW, "No hardware support for 16 or 256 color palettes." },
- { DDERR_NORASTEROPHW, "Operation could not be carried out because there is no appropriate raster op hardware present or available." },
- { DDERR_NOROTATIONHW, "Operation could not be carried out because there is no rotation hardware present or available." },
- { DDERR_NOSTRETCHHW, "Operation could not be carried out because there is no hardware support for stretching." },
- { DDERR_NOT4BITCOLOR, "DirectDrawSurface is not in 4 bit color palette and the requested operation requires 4 bit color palette." },
- { DDERR_NOT4BITCOLORINDEX, "DirectDrawSurface is not in 4 bit color index palette and the requested operation requires 4 bit color index palette." },
- { DDERR_NOT8BITCOLOR, "DirectDrawSurface is not in 8 bit color mode and the requested operation requires 8 bit color" },
- { DDERR_NOTAOVERLAYSURFACE, "Returned when an overlay member is called for a non-overlay surface." },
- { DDERR_NOTEXTUREHW, "Operation could not be carried out because there is no texture mapping hardware present or available." },
- { DDERR_NOTFLIPPABLE, "An attempt has been made to flip a surface that is not flippable." },
- { DDERR_NOTFOUND, "Requested item was not found." },
- { DDERR_NOTLOCKED, "Surface was not locked. An attempt to unlock a surface that was not locked at all, or by this process, has been attempted." },
- { DDERR_NOTPALETTIZED, "The surface being used is not a palette-based surface." },
- { DDERR_NOVSYNCHW, "Operation could not be carried out because there is no hardware support for vertical blank synchronized operations." },
- { DDERR_NOZBUFFERHW, "Operation could not be carried out because there is no hardware support for zbuffer blting." },
- { DDERR_NOZOVERLAYHW, "Overlay surfaces could not be z layered based on their BltOrder because the hardware does not support z layering of overlays." },
- { DDERR_OUTOFCAPS, "The hardware needed for the requested operation has already been allocated." },
- { DDERR_OUTOFMEMORY, "DirectDraw does not have enough memory to perform the operation." },
- { DDERR_OUTOFVIDEOMEMORY, "DirectDraw does not have enough memory to perform the operation." },
- { DDERR_OVERLAYCANTCLIP, "The hardware does not support clipped overlays." },
- { DDERR_OVERLAYCOLORKEYONLYONEACTIVE, "Can only have ony color key active at one time for overlays." },
- { DDERR_OVERLAYNOTVISIBLE, "Returned when GetOverlayPosition is called on a hidden overlay." },
- { DDERR_PALETTEBUSY, "Access to this palette is being refused because the palette is already locked by another thread." },
- { DDERR_PRIMARYSURFACEALREADYEXISTS, "This process already has created a primary surface." },
- { DDERR_REGIONTOOSMALL, "Region passed to Clipper::GetClipList is too small." },
- { DDERR_SURFACEALREADYATTACHED, "This surface is already attached to the surface it is being attached to." },
- { DDERR_SURFACEALREADYDEPENDENT, "This surface is already a dependency of the surface it is being made a dependency of." },
- { DDERR_SURFACEBUSY, "Access to this surface is being refused because the surface is already locked by another thread." },
- { DDERR_SURFACEISOBSCURED, "Access to surface refused because the surface is obscured." },
- { DDERR_SURFACELOST, "Access to this surface is being refused because the surface memory is gone. The DirectDrawSurface object representing this surface should have Restore called on it." },
- { DDERR_SURFACENOTATTACHED, "The requested surface is not attached." },
- { DDERR_TOOBIGHEIGHT, "Height requested by DirectDraw is too large." },
- { DDERR_TOOBIGSIZE, "Size requested by DirectDraw is too large -- the individual height and width are OK." },
- { DDERR_TOOBIGWIDTH, "Width requested by DirectDraw is too large." },
- { DDERR_UNSUPPORTED, "Action not supported." },
- { DDERR_UNSUPPORTEDFORMAT, "FOURCC format requested is unsupported by DirectDraw." },
- { DDERR_UNSUPPORTEDMASK, "Bitmask in the pixel format requested is unsupported by DirectDraw." },
- { DDERR_VERTICALBLANKINPROGRESS, "Vertical blank is in progress." },
- { DDERR_WASSTILLDRAWING, "Informs DirectDraw that the previous Blt which is transfering information to or from this Surface is incomplete." },
- { DDERR_WRONGMODE, "This surface can not be restored because it was created in a different mode." },
- { DDERR_XALIGN, "Rectangle provided was not horizontally aligned on required boundary." }
-};
-
-SparseErrorList
-directDrawErrorList(etiDDrawErrorList, 90, directDrawErrors);
-
-
-#endif
+SequentialErrorList programErrors(etiFTA2ErrorList, FTA2ProgramErrors);
}
diff --git a/engines/saga2/objproto.h b/engines/saga2/objproto.h
index bd28a1b489..3b1e4d1451 100644
--- a/engines/saga2/objproto.h
+++ b/engines/saga2/objproto.h
@@ -304,8 +304,8 @@ public:
// A constructor which takes the data loaded from the file
// and loads it into the various fields...
- ProtoObj(ResourceObjectPrototype &proto) :
- ResourceObjectPrototype(proto) {}
+ ProtoObj(ResourceObjectPrototype &proto) : ResourceObjectPrototype(proto) {}
+ virtual ~ProtoObj() {}
// returns the containment type flags for this object
virtual uint16 containmentSet(void);
@@ -343,9 +343,6 @@ public:
ObjectID indirectObj,
int16 value);
- // Create A Container Window
-// virtual ContainerWindow *makeWindow( GameObject *Obj );
-
// generic actions
// Use this object
bool use(ObjectID dObj, ObjectID enactor);
@@ -642,6 +639,7 @@ public:
class InventoryProto : public ProtoObj {
public:
InventoryProto(ResourceObjectPrototype &proto) : ProtoObj(proto) {}
+ virtual ~InventoryProto() {}
virtual uint16 containmentSet(void);
@@ -686,7 +684,6 @@ public:
// Prototype class for physical object container
class PhysicalContainerProto : public InventoryProto {
-
private:
enum {
ViewableRows = 4,
@@ -696,8 +693,8 @@ private:
};
public:
- PhysicalContainerProto(ResourceObjectPrototype &proto) :
- InventoryProto(proto) {}
+ PhysicalContainerProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {}
+ virtual ~PhysicalContainerProto() {}
virtual uint16 containmentSet(void);
@@ -739,9 +736,6 @@ public:
const TilePoint &where,
int16 num = 1);
-// virtual ContainerWindow *makeWindow( GameObject *Obj );
-
-
public:
virtual uint16 getViewableRows(void) {
return ViewableRows;
@@ -774,6 +768,7 @@ public:
class KeyProto : public InventoryProto {
public:
KeyProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {}
+ virtual ~KeyProto() {}
// Set up targeting cursor
virtual bool setUseCursor(ObjectID dObj);
@@ -792,9 +787,10 @@ public:
// hierarchy:
// ProtoObj, InventoryProto, BottleProto
-class BottleProto : public InventoryProto {
+class BottleProto : public InventoryProto {
public:
BottleProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {}
+ virtual ~BottleProto() {}
virtual uint16 containmentSet(void);
@@ -810,9 +806,10 @@ public:
// hierarchy:
// ProtoObj, InventoryProto, FoodProto
-class FoodProto : public InventoryProto {
+class FoodProto : public InventoryProto {
public:
FoodProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {}
+ virtual ~FoodProto() {}
virtual uint16 containmentSet(void);
@@ -828,9 +825,10 @@ public:
// hierarchy:
// ProtoObj, InventoryProto, WearbleProto
-class WearableProto : public InventoryProto {
+class WearableProto : public InventoryProto {
public:
WearableProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {}
+ virtual ~WearableProto() {}
virtual uint16 containmentSet(void);
};
@@ -851,6 +849,7 @@ protected:
public:
WeaponProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {}
+ virtual ~WeaponProto() {}
virtual uint16 containmentSet(void);
@@ -877,8 +876,8 @@ public:
class MeleeWeaponProto : public WeaponProto {
public:
- MeleeWeaponProto(ResourceObjectPrototype &proto) :
- WeaponProto(proto) {}
+ MeleeWeaponProto(ResourceObjectPrototype &proto) : WeaponProto(proto) {}
+ virtual ~MeleeWeaponProto() {}
virtual bool useAction(ObjectID dObj, ObjectID enactor);
virtual bool useOnAction(ObjectID dObj, ObjectID enactor, ObjectID item);
@@ -944,8 +943,8 @@ public:
class BludgeoningWeaponProto : public MeleeWeaponProto {
public:
- BludgeoningWeaponProto(ResourceObjectPrototype &proto) :
- MeleeWeaponProto(proto) {}
+ BludgeoningWeaponProto(ResourceObjectPrototype &proto) : MeleeWeaponProto(proto) {}
+ virtual ~BludgeoningWeaponProto() {}
// Get the value of the wielder's skill which applies to this
// weapon
@@ -965,8 +964,8 @@ public:
class SlashingWeaponProto : public MeleeWeaponProto {
public:
- SlashingWeaponProto(ResourceObjectPrototype &proto) :
- MeleeWeaponProto(proto) {}
+ SlashingWeaponProto(ResourceObjectPrototype &proto) : MeleeWeaponProto(proto) {}
+ virtual ~SlashingWeaponProto() {}
// Get the value of the wielder's skill which applies to this
// weapon
@@ -985,8 +984,8 @@ public:
class BowProto : public WeaponProto {
public:
- BowProto(ResourceObjectPrototype &proto) :
- WeaponProto(proto) {}
+ BowProto(ResourceObjectPrototype &proto) : WeaponProto(proto) {}
+ virtual ~BowProto() {}
virtual bool useAction(ObjectID dObj, ObjectID enactor);
@@ -1022,8 +1021,8 @@ public:
class WeaponWandProto : public WeaponProto {
public:
- WeaponWandProto(ResourceObjectPrototype &proto) :
- WeaponProto(proto) {}
+ WeaponWandProto(ResourceObjectPrototype &proto) : WeaponProto(proto) {}
+ virtual ~WeaponWandProto() {}
virtual bool useAction(ObjectID dObj, ObjectID enactor);
@@ -1211,7 +1210,7 @@ public:
// hierarchy:
// ProtoObj, InventoryProto, DocumentProto
-class DocumentProto : public InventoryProto {
+class DocumentProto : public InventoryProto {
public:
DocumentProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {}
virtual ~DocumentProto() {}
@@ -1234,7 +1233,7 @@ public:
// hierarchy:
// ProtoObj, InventoryProto, DocumentProto, BookProto
-class BookProto : public DocumentProto {
+class BookProto : public DocumentProto {
public:
BookProto(ResourceObjectPrototype &proto) : DocumentProto(proto) {}
virtual ~BookProto() {}
@@ -1250,7 +1249,7 @@ public:
// hierarchy:
// ProtoObj, InventoryProto, DocumentProto, ScrollProto
-class ScrollProto : public DocumentProto {
+class ScrollProto : public DocumentProto {
public:
ScrollProto(ResourceObjectPrototype &proto) : DocumentProto(proto) {}
virtual ~ScrollProto() {}
@@ -1267,7 +1266,7 @@ public:
// hierarchy:
// ProtoObj, InventoryProto, AutoMapProto
-class AutoMapProto : public InventoryProto {
+class AutoMapProto : public InventoryProto {
public:
AutoMapProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {}
virtual ~AutoMapProto() {}
@@ -1326,7 +1325,7 @@ public:
// hierarchy:
// ProtoObj, IntangibleObjProto, IdeaProto
-class IdeaProto : public IntangibleObjProto {
+class IdeaProto : public IntangibleObjProto {
public:
IdeaProto(ResourceObjectPrototype &proto) : IntangibleObjProto(proto) {}
virtual ~IdeaProto() {}
@@ -1343,7 +1342,7 @@ public:
// hierarchy:
// ProtoObj, IntangibleObjProto, MemoryProto
-class MemoryProto : public IntangibleObjProto {
+class MemoryProto : public IntangibleObjProto {
public:
MemoryProto(ResourceObjectPrototype &proto) : IntangibleObjProto(proto) {}
virtual ~MemoryProto() {}
@@ -1360,7 +1359,7 @@ public:
// hierarchy:
// ProtoObj, IntangibleObjProto, PsychProto
-class PsychProto : public IntangibleObjProto {
+class PsychProto : public IntangibleObjProto {
public:
PsychProto(ResourceObjectPrototype &proto) : IntangibleObjProto(proto) {}
virtual ~PsychProto() {}
@@ -1379,7 +1378,7 @@ public:
// hierarchy:
// ProtoObj, IntagibleObjProto, SkillProto
-class SkillProto : public IntangibleObjProto {
+class SkillProto : public IntangibleObjProto {
public:
SkillProto(ResourceObjectPrototype &proto) : IntangibleObjProto(proto) {}
virtual ~SkillProto() {}
Commit: 91c749d2d6fb2e7be74b68772b8624ddfd9f0ddb
https://github.com/scummvm/scummvm/commit/91c749d2d6fb2e7be74b68772b8624ddfd9f0ddb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:47+02:00
Commit Message:
SAGA2: More comment cleanup
Changed paths:
engines/saga2/errlist.cpp
diff --git a/engines/saga2/errlist.cpp b/engines/saga2/errlist.cpp
index ad39a9a1c5..d3f0f42523 100644
--- a/engines/saga2/errlist.cpp
+++ b/engines/saga2/errlist.cpp
@@ -24,42 +24,21 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-/* ===================================================================== *
- Includes
- * ===================================================================== */
-
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/errlist.h"
namespace Saga2 {
-/* ===================================================================== *
- SequentialErrorList implementation
- * ===================================================================== */
-
-// ------------------------------------------------------------------
-//
-
-SequentialErrorList::SequentialErrorList(ErrType et, uint32 ec, char *es[]) :
- ErrorList(et, ec) {
+SequentialErrorList::SequentialErrorList(ErrType et, uint32 ec, char *es[]) : ErrorList(et, ec) {
for (int i = 0; i < eLimit(); i++)
setEntry(i, i, es[i]);
}
-// ------------------------------------------------------------------
-//
-
-SequentialErrorList::SequentialErrorList(ErrType et, const char *es[]) :
- ErrorList(et, stringCount(es)) {
+SequentialErrorList::SequentialErrorList(ErrType et, const char *es[]) : ErrorList(et, stringCount(es)) {
for (int i = 0; i < eLimit(); i++)
setEntry(i, i, es[i]);
}
-// ------------------------------------------------------------------
-//
-
uint32 SequentialErrorList::stringCount(const char *es[]) {
uint32 rv = 0;
if (es == NULL)
@@ -68,9 +47,6 @@ uint32 SequentialErrorList::stringCount(const char *es[]) {
return rv;
}
-// ------------------------------------------------------------------
-//
-
uint32 SequentialErrorList::lookupMessage(ErrorID id) {
if (id >= 0 && id < eLimit()) {
return id;
@@ -78,38 +54,16 @@ uint32 SequentialErrorList::lookupMessage(ErrorID id) {
return unkError;
}
-
-
-/* ===================================================================== *
- SparseErrorList implementation
- * ===================================================================== */
-
-// ------------------------------------------------------------------
-//
-
-SparseErrorList::SparseErrorList(ErrType et,
- uint32 ec,
- ErrorID ei[],
- const char *es[]):
- ErrorList(et, ec) {
+SparseErrorList::SparseErrorList(ErrType et, uint32 ec, ErrorID ei[], const char *es[]) : ErrorList(et, ec) {
for (int i = 0; i < eLimit(); i++)
setEntry(i, ei[i], es[i]);
}
-// ------------------------------------------------------------------
-//
-
-SparseErrorList::SparseErrorList(ErrType et,
- uint32 ec,
- ErrorRec er[]):
- ErrorList(et, ec) {
+SparseErrorList::SparseErrorList(ErrType et, uint32 ec, ErrorRec er[]) : ErrorList(et, ec) {
for (int i = 0; i < eLimit(); i++)
setEntry(i, er[i].ID, er[i].text);
}
-// ------------------------------------------------------------------
-//
-
uint32 SparseErrorList::lookupMessage(ErrorID id) {
for (int i = 0; i < eLimit(); i++) {
if (errList[i].ID == id)
Commit: 10c78758f41356097d6fd192aa0b00e13feed4c1
https://github.com/scummvm/scummvm/commit/10c78758f41356097d6fd192aa0b00e13feed4c1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:47+02:00
Commit Message:
SAGA2: Restored msgbox.*
Changed paths:
A engines/saga2/msgbox.cpp
A engines/saga2/msgbox.h
engines/saga2/module.mk
diff --git a/engines/saga2/module.mk b/engines/saga2/module.mk
index 03d714914a..1c86299ad2 100644
--- a/engines/saga2/module.mk
+++ b/engines/saga2/module.mk
@@ -58,6 +58,7 @@ MODULE_OBJS := \
modal.o \
mono.o \
motion.o \
+ msgbox.o \
noise.o \
mouseimg.o \
nice_err.o \
diff --git a/engines/saga2/msgbox.cpp b/engines/saga2/msgbox.cpp
new file mode 100644
index 0000000000..dc4305d9f5
--- /dev/null
+++ b/engines/saga2/msgbox.cpp
@@ -0,0 +1,441 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * aint32 with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Based on the original sources
+ * Faery Tale II -- The Halls of the Dead
+ * (c) 1993-1996 The Wyrmkeep Entertainment Co.
+ */
+
+#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+
+#include "saga2/std.h"
+#include "saga2/msgbox.h"
+
+namespace Saga2 {
+
+const int8 windowColor = 33 + 9;
+const int8 buttonColor = 36 + 9;
+const int numMessageBtns = 2;
+
+Rect16 mbWindowRect(70, 170, 500, 140);
+
+const Rect16 mbOkBtnRect(100, 100, 100, 25);
+const Rect16 mbCancelBtnRect(300, 100, 100, 25);
+const Rect16 mbOneBtnRect(200, 100, 100, 25);
+const Rect16 mbButtonRects[ numMessageBtns ] = { { mbOkBtnRect },
+ { mbCancelBtnRect }
+};
+static gFont *mbButtonFont = &ThinFix8Font;
+
+/* ===================================================================== *
+ Imports
+ * ===================================================================== */
+
+extern bool gameRunning; // true while game running
+extern BackWindow *mainWindow;
+
+/* ===================================================================== *
+ Prototypes
+ * ===================================================================== */
+
+APPFUNC(cmdDialogQuit);
+int16 MsgBox(char *msg, char *btnMsg1, char *btnMsg2);
+void writePlaqText(gPort &port,
+ const Rect16 &r,
+ gFont *font,
+ int16 textPos,
+ textPallete &pal,
+ bool hiLite,
+ char *msg, ...);
+
+inline Rect16 butBox(int n, int i) {
+ return (n > 1 ? mbButtonRects[i] : mbOneBtnRect);
+}
+
+/* ===================================================================== *
+ Main message box code
+ * ===================================================================== */
+
+bool userDialogAvailable(void);
+int16 userDialog(char *title, char *msg, char *btnMsg1,
+ char *btnMsg2,
+ char *btnMsg3);
+
+// ------------------------------------------------------------------------
+// Wrapper to avoid errors
+
+int16 FTAMessageBox(char *msg,
+ char *btnMsg1,
+ char *btnMsg2)
+
+{
+ int16 rv = -1;
+ if (userDialogAvailable()) {
+ char *b1 = btnMsg1;
+ char *b2 = btnMsg2;
+ //if (b1[0]=='_') b1++;
+ //if (b2[0]=='_') b2++;
+
+ rv = (0 == userDialog(ERROR_HEADING, msg, b1, b2, NULL));
+ } else
+ rv = MsgBox(msg, btnMsg1, btnMsg2);
+ return rv;
+}
+
+// ------------------------------------------------------------------------
+// Very primitive message box
+
+int16 MsgBox(char *msg,
+ char *btnMsg1,
+ char *btnMsg2) {
+ ErrorWindow *win = NEW_MSGR ErrorWindow(msg, btnMsg1, btnMsg2);
+ int16 res = win->getResult();
+ delete win;
+ return res;
+}
+
+char ErrorWindow::mbChs1Text[8];
+char ErrorWindow::mbChs2Text[8];
+uint8 ErrorWindow::numBtns = 0;
+requestInfo ErrorWindow::rInfo;
+
+APPFUNC(ErrorWindow::cmdMessageWindow) {
+ gWindow *win;
+ requestInfo *ri;
+
+ if (ev.panel && ev.eventType == gEventNewValue && ev.value) {
+ win = ev.panel->getWindow(); // get the window pointer
+ ri = win ? (requestInfo *)win->userData : NULL;
+
+ if (ri) {
+ ri->running = 0;
+ ri->result = ev.panel->id;
+ }
+ }
+}
+
+
+ErrorWindow::ErrorWindow(char *msg, char *btnMsg1, char *btnMsg2)
+ : SimpleWindow(mbWindowRect, 0, msg, cmdMessageWindow) {
+ const int maxBtns = 2;
+
+ numBtns = 0;
+
+ if (btnMsg1) numBtns++;
+ if (btnMsg2) numBtns++;
+
+ // requester info struct
+
+ rInfo.result = -1;
+ rInfo.running = TRUE;
+
+ strcpy(mbChs1Text, "\x13");
+ strcpy(mbChs2Text, "\x1B");
+ char *eq;
+ // button one
+ if (btnMsg1) {
+ new SimpleButton(*this, butBox(numBtns, 0), btnMsg1, 0, cmdMessageWindow);
+ if ((eq = strchr(btnMsg1, '_')) != NULL) {
+ eq++;
+ if (eq)
+ mbChs1Text[strlen(mbChs1Text)] = *eq;
+ }
+ }
+
+ // button two
+ if (btnMsg2) {
+ new SimpleButton(*this, butBox(numBtns, 1), btnMsg2, 1, cmdMessageWindow);
+ if ((eq = strchr(btnMsg2, '_')) != NULL) {
+ eq++;
+ if (eq)
+ mbChs2Text[strlen(mbChs2Text)] = *eq;
+ }
+ }
+
+ userData = &rInfo;
+
+}
+
+int16 ErrorWindow::getResult(void) {
+ open();
+ draw();
+ EventLoop(rInfo.running, TRUE);
+ return rInfo.result;
+}
+
+ErrorWindow::~ErrorWindow() {
+ mainWindow->invalidate(mbWindowRect);
+}
+
+
+
+void ErrorWindow::ErrorModeHandleKey(short key, short) {
+ if (strchr(mbChs2Text, tolower(key)) ||
+ strchr(mbChs2Text, toupper(key))) {
+ rInfo.result = 2;
+ rInfo.running = FALSE;
+ return;
+ }
+ if (strchr(mbChs1Text, tolower(key)) ||
+ strchr(mbChs1Text, toupper(key))) {
+ rInfo.result = 1;
+ rInfo.running = FALSE;
+ return;
+ }
+ if (numBtns < 2) {
+ rInfo.result = 1;
+ rInfo.running = FALSE;
+ return;
+ }
+}
+
+GameMode SimpleMode = {
+ NULL, // no previous mode
+ FALSE, // mode is not nestable
+ ErrorWindow::ErrorModeSetup,
+ ErrorWindow::ErrorModeCleanup,
+ ErrorWindow::ErrorModeHandleTask,
+ ErrorWindow::ErrorModeHandleKey,
+};
+
+/* ===================================================================== *
+ SimpleWindow
+ * ===================================================================== */
+
+
+SimpleWindow::SimpleWindow(const Rect16 &r,
+ uint16 ident,
+ char *stitle,
+ AppFunc *cmd)
+ : gWindow(r, ident, "", cmd) {
+ prevModeStackCtr = GameMode::getStack(prevModeStackPtr);
+ GameMode::SetStack(&PlayMode, &TileMode, &SimpleMode, End_List);
+ title = stitle;
+}
+
+SimpleWindow::~SimpleWindow(void) {
+ GameMode::SetStack(prevModeStackPtr, prevModeStackCtr);
+}
+
+bool SimpleWindow::isModal(void) {
+ return TRUE;
+}
+
+void SimpleWindow::update(const Rect16 &) {
+}
+
+void SimpleWindow::draw(void) {
+ pointer.hide(mainPort, extent); // hide mouse pointer
+ drawClipped(mainPort, Point16(0, 0), extent);
+ pointer.show(mainPort, extent); // show mouse pointer
+}
+
+void SimpleWindow::drawClipped(
+ gPort &port,
+ const Point16 &p,
+ const Rect16 &r) {
+ Rect16 box = extent;
+ //gFont *buttonFont=&Onyx10Font;
+ int16 textPos = textPosHigh;
+ //textPallete pal( 33+9, 36+9, 41+9, 34+9, 40+9, 43+9 );
+ textPallete pal(33 + 9, 33 + 9, 41 + 9, 33 + 9, 33 + 9, 41 + 9);
+ bool selected = FALSE;
+
+ box.x += 10;
+ box.y += 10;
+ box.width -= 20;
+ box.height -= 100;
+
+ SAVE_GPORT_STATE(port); // save pen color, etc.
+ pointer.hide(port, extent); // hide mouse pointer
+
+ DrawOutlineFrame(port, extent, windowColor);
+ writeWrappedPlaqText(port, box, mbButtonFont, textPos, pal, selected, title);
+
+ gWindow::drawClipped(port, p, r);
+
+ pointer.show(port, extent); // show mouse pointer
+}
+
+/* ===================================================================== *
+ Display code
+ * ===================================================================== */
+
+
+void SimpleWindow::writeWrappedPlaqText(gPort &port,
+ const Rect16 &r,
+ gFont *font,
+ int16 textPos,
+ textPallete &pal,
+ bool hiLite,
+ char *msg, ...) {
+ char textBuf[ 256 ];
+ char lineBuf[ 128 ];
+ va_list argptr;
+ int16 tPos = 0;
+ Rect16 r2 = r;
+
+ va_start(argptr, msg);
+ int cnt = vsprintf(textBuf, msg, argptr);
+ va_end(argptr);
+
+ char *text = &textBuf[0];
+
+ while (tPos < cnt && strlen(text)) {
+ text = &text[tPos];
+ int i = strlen(text);
+ char *src = strchr(text, '\n');
+ if (src)
+ i = (src - text);
+ tPos += i;
+ memset(lineBuf, '\0', 128);
+ strncpy(lineBuf, text, i);
+ writePlaqText(port, r2, font, textPos, pal, hiLite, lineBuf);
+ r2.y += font->height + 4;
+ r2.height -= font->height + 4;
+ }
+}
+
+// ------------------------------------------------------------------------
+// Very primitive box
+
+void SimpleWindow::DrawOutlineFrame(gPort &port, const Rect16 &r, int16 fillColor) {
+ gPenState saveState;
+
+ port.getState(saveState);
+
+ if (r.width > 3 && r.height > 3) {
+ int16 bottom = r.y + r.height - 2,
+ right = r.x + r.width - 2;
+
+ port.setIndirectColor(whitePen);
+ port.vLine(r.x + 1, r.y + 1, r.height - 3);
+ port.hLine(r.x + 2, r.y + 1, r.width - 3);
+
+ port.setIndirectColor(blackPen);
+ port.frameRect(r, 1);
+
+ port.setIndirectColor(buttonDkPen);
+ port.hLine(r.x + 1, bottom, r.width - 2);
+ port.vLine(right, r.y + 1, r.height - 2);
+
+ port.setIndirectColor(buttonPen);
+ port.setPixel(r.x + 1, bottom);
+ port.setPixel(right, r.y + 1);
+
+ if (fillColor >= 0) {
+ port.setIndirectColor(fillColor);
+ port.fillRect(r.x + 2, r.y + 2, r.width - 4, r.height - 4);
+ }
+ }
+
+ port.setState(saveState);
+}
+
+
+/* ===================================================================== *
+ SimpleButton
+ * ===================================================================== */
+
+SimpleButton::SimpleButton(gWindow &win, const Rect16 &box, char *title, uint16 ident,
+ AppFunc *cmd)
+ : gControl(win, box, title, ident, cmd) {
+ window = &win;
+}
+
+void SimpleButton::deactivate(void) {
+ selected = 0;
+ draw();
+ gPanel::deactivate();
+}
+
+bool SimpleButton::activate(gEventType why) {
+ selected = 1;
+ draw();
+
+ if (why == gEventKeyDown) { // momentarily depress
+ //delay( 200 );
+ deactivate();
+ notify(gEventNewValue, 1); // notify App of successful hit
+ }
+ return FALSE;
+}
+
+bool SimpleButton::pointerHit(gPanelMessage &) {
+ //if (ghosted) return FALSE;
+
+ activate(gEventMouseDown);
+ return TRUE;
+}
+
+void SimpleButton::pointerRelease(gPanelMessage &) {
+ // We have to test selected first because deactivate clears it.
+
+ if (selected) {
+ deactivate(); // give back input focus
+ notify(gEventNewValue, 1); // notify App of successful hit
+ } else deactivate();
+}
+
+void SimpleButton::pointerDrag(gPanelMessage &msg) {
+ if (selected != msg.inPanel) {
+ selected = msg.inPanel;
+ draw();
+ }
+}
+
+void SimpleButton::draw(void) {
+ gDisplayPort &port = window->windowPort;
+ Rect16 rect = window->getExtent();
+
+ SAVE_GPORT_STATE(port); // save pen color, etc.
+ pointer.hide(port, extent); // hide mouse pointer
+ drawClipped(port,
+ Point16(0, 0),
+ Rect16(0, 0, rect.width, rect.height));
+ pointer.show(port, extent); // show mouse pointer
+}
+
+void SimpleButton::drawClipped(
+ gPort &port,
+ const Point16 &,
+ const Rect16 &) {
+ Rect16 base = window->getExtent();
+
+ Rect16 box = Rect16(extent.x + 1,
+ extent.y + 1,
+ extent.width - 2,
+ extent.height - 2);
+ box.x += base.x;
+ box.y += base.y;
+
+ SAVE_GPORT_STATE(port); // save pen color, etc.
+ pointer.hide(port, extent); // hide mouse pointer
+
+ SimpleWindow::DrawOutlineFrame(port, // draw outer frame
+ box,
+ buttonColor);
+
+ drawTitle((enum text_positions)0);
+ pointer.show(port, extent); // show mouse pointer
+}
+
+} // end of namespace Saga2
diff --git a/engines/saga2/msgbox.h b/engines/saga2/msgbox.h
new file mode 100644
index 0000000000..ac96c65ce4
--- /dev/null
+++ b/engines/saga2/msgbox.h
@@ -0,0 +1,142 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * aint32 with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Based on the original sources
+ * Faery Tale II -- The Halls of the Dead
+ * (c) 1993-1996 The Wyrmkeep Entertainment Co.
+ */
+
+#ifndef SAGA2_MSGBOX_H
+#define SAGA2_MSGBOX_H
+
+#include "saga2/fta.h"
+#include "saga2/floating.h"
+#include "saga2/grequest.h"
+#include "saga2/button.h"
+
+namespace Saga2 {
+
+void ModalModeSetup(void);
+void ModalModeCleanup(void);
+void ModalModeHandleTask(void);
+void ModalModeHandleKey(short, short);
+
+//Modal Mode GameMode Object
+
+extern GameMode ModalMode;
+
+/* ===================================================================== *
+ ModalWindow --
+ * ===================================================================== */
+
+class SimpleWindow : public gWindow {
+
+ GameMode *prevModeStackPtr[ Max_Modes ];
+ int prevModeStackCtr;
+
+public:
+
+ SimpleWindow(const Rect16 &r,
+ uint16 ident,
+ char *title,
+ AppFunc *cmd);
+ ~SimpleWindow();
+
+ bool isModal(void);
+ void update(const Rect16 &);
+ void draw(void); // redraw the panel.
+ void drawClipped(gPort &port, const Point16 &offset, const Rect16 &r);
+ static void DrawOutlineFrame(gPort &port, const Rect16 &r, int16 fillColor);
+ static void writeWrappedPlaqText(gPort &port,
+ const Rect16 &r,
+ gFont *font,
+ int16 textPos,
+ textPallete &pal,
+ bool hiLite,
+ char *msg, ...);
+
+};
+
+class SimpleButton : public gControl {
+ gWindow *window;
+public:
+ SimpleButton(gWindow &, const Rect16 &, char *, uint16, AppFunc *cmd = NULL);
+
+ void draw(void); // redraw the panel.
+ void drawClipped(gPort &port, const Point16 &offset, const Rect16 &r);
+
+private:
+ bool activate(gEventType why); // activate the control
+ void deactivate(void);
+ bool pointerHit(gPanelMessage &msg);
+ void pointerDrag(gPanelMessage &msg);
+ void pointerRelease(gPanelMessage &msg);
+};
+
+class ErrorWindow : public SimpleWindow {
+ static char mbChs1Text[8];
+ static char mbChs2Text[8];
+ static uint8 numBtns;
+public:
+
+ static requestInfo rInfo;
+ ErrorWindow(char *msg,
+ char *btnMsg1,
+ char *btnMsg2);
+ ~ErrorWindow();
+ int16 getResult(void);
+ static APPFUNC(cmdMessageWindow);
+ static void ErrorModeSetup(void) {}
+ static void ErrorModeCleanup(void) {}
+ static void ErrorModeHandleTask(void) {}
+ static void ErrorModeHandleKey(short key, short);
+
+};
+
+
+struct MBErr {
+ int16 errNo;
+ MBErr(int16 e) {
+ errNo = e;
+ }
+};
+
+#define assert_alloc(e,p) if (NULL==p) throw MBErr(e)
+
+
+
+int16 FTAMessageBox(char *msg, char *btnMsg1, char *btnMsg2);
+
+#if 0
+class SystemErrorMessager : public Messager {
+protected:
+ int dumpit(char *s, size_t size) ;
+
+public:
+ SystemErrorMessager() {}
+ ~SystemErrorMessager() {}
+ int16 getAnswer(const char *b1, const char *b2, const char fmt[], ...);
+};
+#endif
+
+} // end of namespace Saga2
+
+#endif
Commit: 04ecb9e275db025a4a0b1cc5606710f7503bbb7a
https://github.com/scummvm/scummvm/commit/04ecb9e275db025a4a0b1cc5606710f7503bbb7a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:47+02:00
Commit Message:
SAGA2: Remove custom error handling
Changed paths:
R engines/saga2/audioerr.h
R engines/saga2/errbase.cpp
R engines/saga2/errbase.h
R engines/saga2/errclass.cpp
R engines/saga2/errclass.h
R engines/saga2/errlist.cpp
R engines/saga2/errlist.h
R engines/saga2/errors.cpp
R engines/saga2/errtype.h
R engines/saga2/nice_err.cpp
R engines/saga2/nice_err.h
engines/saga2/assign.h
engines/saga2/audio.h
engines/saga2/audiobuf.cpp
engines/saga2/audiobuf.h
engines/saga2/audiores.cpp
engines/saga2/config.h
engines/saga2/display.cpp
engines/saga2/fta.h
engines/saga2/gpointer.cpp
engines/saga2/hresmgr.cpp
engines/saga2/ioerrors.h
engines/saga2/loadsave.cpp
engines/saga2/magic.cpp
engines/saga2/main.cpp
engines/saga2/mainmap.h
engines/saga2/module.mk
engines/saga2/msgbox.cpp
engines/saga2/noise.cpp
engines/saga2/rmem.cpp
engines/saga2/savefile.cpp
engines/saga2/savefile.h
engines/saga2/spelshow.h
engines/saga2/std.h
engines/saga2/tile.cpp
engines/saga2/tower.cpp
engines/saga2/tower.h
engines/saga2/towerfta.cpp
engines/saga2/tromode.cpp
engines/saga2/verify.cpp
engines/saga2/video.h
engines/saga2/vwpage.cpp
diff --git a/engines/saga2/assign.h b/engines/saga2/assign.h
index cc11a0275d..3d77ef43e2 100644
--- a/engines/saga2/assign.h
+++ b/engines/saga2/assign.h
@@ -271,7 +271,7 @@ public:
uint16 r,
bool trackFlag = FALSE) :
ActorAssignment(indefinitely) {
- ASSERT(isActor(a) && a != getActor());
+ assert(isActor(a) && a != getActor());
initialize(SpecificActorTarget(a), r, trackFlag);
}
@@ -282,7 +282,7 @@ public:
uint16 r,
bool trackFlag = FALSE) :
ActorAssignment(until) {
- ASSERT(isActor(a) && a != getActor());
+ assert(isActor(a) && a != getActor());
initialize(SpecificActorTarget(a), r, trackFlag);
}
@@ -354,7 +354,7 @@ public:
// Construct with no time limit and specific actor
HuntToKillAssignment(Actor *a, bool trackFlag = FALSE) :
ActorAssignment(indefinitely) {
- ASSERT(isActor(a) && a != getActor());
+ assert(isActor(a) && a != getActor());
initialize(SpecificActorTarget(a), trackFlag, TRUE);
}
@@ -364,7 +364,7 @@ public:
Actor *a,
bool trackFlag = FALSE) :
ActorAssignment(until) {
- ASSERT(isActor(a) && a != getActor());
+ assert(isActor(a) && a != getActor());
initialize(SpecificActorTarget(a), trackFlag, TRUE);
}
diff --git a/engines/saga2/audio.h b/engines/saga2/audio.h
index dc40e19515..a7c6d4a985 100644
--- a/engines/saga2/audio.h
+++ b/engines/saga2/audio.h
@@ -73,11 +73,13 @@ int32 AIL_sample_volume(HSAMPLE S);
int32 AIL_sequence_volume(HSEQUENCE S);
void AIL_set_sequence_volume(HSEQUENCE S, int32 volume, int32 milliseconds);
+inline void audioFatal(char *msg) {
+ error("Sound error %s", msg);
+}
+
#include "saga2/rect.h"
-#include "saga2/errclass.h"
#include "saga2/audiotmr.h"
#include "saga2/audiomem.h"
-#include "saga2/audioerr.h"
#include "saga2/queues.h"
#include "saga2/audiobuf.h"
#include "saga2/audiodec.h"
diff --git a/engines/saga2/audiobuf.cpp b/engines/saga2/audiobuf.cpp
index a9988bc5ef..c313826a22 100644
--- a/engines/saga2/audiobuf.cpp
+++ b/engines/saga2/audiobuf.cpp
@@ -28,8 +28,6 @@
#include "saga2/std.h"
#include "saga2/audio.h"
-#include "saga2/audioerr.h"
-#include "saga2/errclass.h"
namespace Saga2 {
diff --git a/engines/saga2/audiobuf.h b/engines/saga2/audiobuf.h
index 7bc44f71d5..7d9c401f0c 100644
--- a/engines/saga2/audiobuf.h
+++ b/engines/saga2/audiobuf.h
@@ -292,7 +292,6 @@ public:
void setVolume(int8 val); // internal : set buffer to fill & play
void setLoopCount(int16 loops) {
- VERIFY(audioSet);
loopCount = loops;
}
int16 getLoopCount(void) {
diff --git a/engines/saga2/audioerr.h b/engines/saga2/audioerr.h
deleted file mode 100644
index 9f7b284c68..0000000000
--- a/engines/saga2/audioerr.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#ifndef SAGA2_AUDIOERR_H
-#define SAGA2_AUDIOERR_H 1
-
-#include "saga2/errors.h"
-#include "saga2/errclass.h"
-
-namespace Saga2 {
-
-const int32 audioErrorOffset = 0xE0;
-
-enum soundErrors {
- serrNoError = audioErrorOffset,
- serrOpenFailed,
- serrReadFailed,
- serrNoFreeBuffers,
- serrBufferSizeTooSmall,
- serrPlayError,
- serrCompUnexpectedEOF,
- serrCompNoMagicNum,
- serrCompBadAlign,
- serrCompBadFloat,
- serrCompBadType,
- serrCompUnkType,
- serrCompUnsupType,
- serrCompOddType,
- serrCompNoType,
- serrCompInternal,
- serrCompWriteFailed,
- serrCompPutFailed,
- serrCompReadFailed,
- serrCompEOFInStream,
- serrVersionMismatch,
- serrFATAL,
- serrMaxErr,
-};
-
-/* ===================================================================== *
- Audio error classes
- * ===================================================================== */
-
-class AudioError : public gError {
-public:
- AudioError(soundErrors errID);
- AudioError(char *msg);
-};
-
-class AudioFatal : public AudioError {
-public:
- AudioFatal();
- AudioFatal(char *msg);
-};
-
-
-/* ===================================================================== *
- Error macros
- * ===================================================================== */
-
-inline void SegFatal(soundErrors errID) {
- error("Sound error %d", errID);
-}
-
-inline void audioFatal(char *msg) {
- error("Sound error %s", msg);
-}
-
-char *IDName(long s);
-
-/* ===================================================================== *
- Logging macro
- * ===================================================================== */
-
-#if DEBUG
-
-#include <io.h>
-#define AUDIO_LOG_FILE "AUDIOERR.LOG"
-#define AUDIO_MAX_LOG_SIZE 16384
-
-inline void audioLog(char *s) {
- FILE *fp = fopen(AUDIO_LOG_FILE, "at");
- if (fp) {
- if (filelength(fileno(fp)) > AUDIO_MAX_LOG_SIZE) {
- fclose(fp);
- remove(AUDIO_LOG_FILE);
- fp = fopen(AUDIO_LOG_FILE, "at");
- fprintf(fp, "LOG CLEARED AT TIME %d\n==========================", gameTime);
- }
- fprintf(fp, "%s\n", s);
- fclose(fp);
- }
-}
-#endif
-
-} // end of namespace Saga2
-
-#endif
diff --git a/engines/saga2/audiores.cpp b/engines/saga2/audiores.cpp
index f8ad3dcc02..52402bc3d1 100644
--- a/engines/saga2/audiores.cpp
+++ b/engines/saga2/audiores.cpp
@@ -85,27 +85,15 @@ bool hResCheckResID(hResContext *hrc, uint32 s[]) {
int16 hResSeek(Buffer &sb, soundSample &ss, hResContext *hrc, bool Cheksize) {
if (hrc->seek(ss.curSeg) == FALSE) {
-#if DEBUG
- char msg[80];
- sprintf(msg, "Audio: %s is an invalid res ID\n", IDName(ss.curSeg));
- audioLog(msg);
- if (debugResource) {
- WriteStatusF(6, msg);
- }
-#endif
- return serrOpenFailed;
+ warning("Audio: %d is an invalid res ID", ss.curSeg);
+ return 1;
}
if (Cheksize && sb.wSize < hrc->bytesleft()) {
int bufferSize = sb.wSize;
int soundSize = hrc->bytesleft();
-#if DEBUG
- if (debugResource) {
- char msg[80];
- sprintf(msg, "Buffer too small %d sample: %d", bufferSize, soundSize);
- audioLog(msg);
- }
-#endif
- return serrBufferSizeTooSmall;
+
+ warning("Buffer too small %d sample: %d", bufferSize, soundSize);
+ return 1;
}
ss.channels = soundSample::channelMono;
ss.speed = soundRate22K;
@@ -162,7 +150,8 @@ int16 hResFlush(Buffer &sb, soundSample &ss, hResContext *hrc) {
int16 bufSeek(Buffer &sb, soundSample &ss) {
if (ss.curSeg >= maxClicks) {
- return serrOpenFailed;
+ warning("bufSeek: open failed");
+ return 1;
}
ss.channels = soundSample::channelMono;
ss.speed = soundRate22K;
diff --git a/engines/saga2/config.h b/engines/saga2/config.h
index 0831c89ec5..050827600a 100644
--- a/engines/saga2/config.h
+++ b/engines/saga2/config.h
@@ -27,7 +27,6 @@
#ifndef SAGA2_CONFIG_H
#define SAGA2_CONFIG_H
-#include "saga2/nice_err.h"
#include "saga2/winini.h"
namespace Saga2 {
@@ -73,4 +72,3 @@ extern configuration globalConfig;
} // end of namespace Saga2
#endif // CONFIG_H
-
diff --git a/engines/saga2/display.cpp b/engines/saga2/display.cpp
index 4765d82c7a..40307eeafe 100644
--- a/engines/saga2/display.cpp
+++ b/engines/saga2/display.cpp
@@ -28,7 +28,6 @@
#include "saga2/std.h"
#include "saga2/display.h"
-#include "saga2/nice_err.h"
#include "saga2/floating.h"
#include "saga2/intrface.h"
#include "saga2/loadmsg.h"
@@ -85,7 +84,6 @@ void resumeProcessResources(void);
#endif
static void switchOn(void);
static void switchOff(void);
-void shutdownSave(void);
/* ===================================================================== *
@@ -141,10 +139,6 @@ void resumeGame(void) {
// end game (normally)
void endGame(void) {
- shutdownSave();
-#ifdef _WIN32
- localCursorOff();
-#endif
blackOut();
displayDisable(GameEnded);
gameRunning = FALSE;
@@ -251,19 +245,11 @@ void mainDisable(void) {
// On/Off hooks
static void switchOn(void) {
- SetFatalMode(fhmGUI);
-#ifdef _WIN32
- resumeDDGraphics();
-#endif
enableUserControls();
}
static void switchOff(void) {
disableUserControls();
-#ifdef _WIN32
- suspendDDGraphics();
-#endif
- SetFatalMode(fhmHold);
}
/* ===================================================================== *
diff --git a/engines/saga2/errbase.cpp b/engines/saga2/errbase.cpp
deleted file mode 100644
index 0108c8ad6e..0000000000
--- a/engines/saga2/errbase.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-/* ===================================================================== *
- Includes
- * ===================================================================== */
-
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
-#include "saga2/std.h"
-#include "saga2/errbase.h"
-
-namespace Saga2 {
-
-/* ===================================================================== *
- Global constants
- * ===================================================================== */
-
-char ErrorList::noErrorString[] = "";
-char ErrorList::unkErrorString[] = "Unknown error";
-const ErrText noErrorText = (const char *) ErrorList::noErrorString;
-const ErrText unkErrorText = (const char *) ErrorList::unkErrorString;
-
-/* ===================================================================== *
- ErrorList implementation
- * ===================================================================== */
-
-// ------------------------------------------------------------------
-//
-
-ErrorList::ErrorList() {
- sourceID = nullErrorList;
- errCount = 0;
- errList = NULL;
-}
-
-// ------------------------------------------------------------------
-//
-
-ErrorList::~ErrorList() {
- errCount = 0;
- if (errList != NULL) delete [] errList;
- errList = NULL;
-}
-
-// ------------------------------------------------------------------
-//
-
-ErrorList::ErrorList(ErrType et, uint32 ec) {
- setErrorType(et);
- setListSize(ec);
-}
-
-// ------------------------------------------------------------------
-//
-
-size_t ErrorList::setListSize(size_t s) {
- if (s)
- errList = new ErrorRec[s];
- else
- errList = NULL;
- if (errList)
- errCount = s;
- else
- errCount = 0;
- return errCount;
-}
-
-
-// ------------------------------------------------------------------
-//
-
-void ErrorList::setEntry(uint32 i, ErrorID id, ErrText text) {
- assert(i >= 0 && i < errCount);
- errList[i].ID = id;
- errList[i].text = text;
-}
-
-// ------------------------------------------------------------------
-//
-
-ErrText ErrorList::errMessage(ErrorID id) {
- uint32 index = lookupMessage(id);
- if (index == unkError)
- return unkErrorText;
- return errList[index].text;
-}
-
-}
diff --git a/engines/saga2/errbase.h b/engines/saga2/errbase.h
deleted file mode 100644
index 5c9beb5580..0000000000
--- a/engines/saga2/errbase.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#ifndef SAGA2_ERRBASE_H
-#define SAGA2_ERRBASE_H
-
-namespace Saga2 {
-
-/* ===================================================================== *
- Base types and constants
- * ===================================================================== */
-
-// ------------------------------------------------------------------
-//
-
-typedef uint32 ErrorID;
-const ErrorID noError = 0;
-const ErrorID unkError = 0xFFFFFFFF;
-
-// ------------------------------------------------------------------
-//
-
-typedef const char *ErrText;
-
-// ------------------------------------------------------------------
-//
-
-typedef uint32 ErrType;
-const ErrType nullErrorList = 0;
-
-
-/* ===================================================================== *
- Structures and classes
- * ===================================================================== */
-
-// ------------------------------------------------------------------
-//
-
-struct ErrorRec {
- ErrorID ID;
- ErrText text;
-};
-
-
-// ------------------------------------------------------------------
-//
-
-class ErrorList {
-public:
- static char noErrorString[];
- static char unkErrorString[];
-private:
- ErrType sourceID;
- size_t errCount;
-protected:
- ErrorRec *errList;
-
-private:
- ErrorList();
-
-protected:
- ErrorList(ErrType et, uint32 ec);
- ~ErrorList();
- void setErrorType(ErrType et) {
- sourceID = et;
- }
- size_t setListSize(size_t s);
- void setEntry(uint32 i, ErrorID id, ErrText text);
- size_t eLimit(void) {
- return errCount;
- }
-
-
- virtual uint32 lookupMessage(ErrorID id) = 0;
-
-public:
- ErrText errMessage(ErrorID id);
-};
-
-extern const ErrText noErrorText;
-extern const ErrText unkErrorText;
-
-#endif
-
-}
diff --git a/engines/saga2/errclass.cpp b/engines/saga2/errclass.cpp
deleted file mode 100644
index ca63770ae6..0000000000
--- a/engines/saga2/errclass.cpp
+++ /dev/null
@@ -1,351 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * aint32 with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
-#include "saga2/std.h"
-#include "saga2/errclass.h"
-
-namespace Saga2 {
-
-void (*gError::dumpHandler)(char *);
-
-char *gError::errBuf = new char[ 128 ];
-int16 gError::errBufSize = 128,
- gError::errBufOffset = 0;
-uint8 gError::saveErrFlag = 0;
-
-/****** errclass.cpp/gError [class] *******************************
-*
-* NAME
-* class gError -- an error-handling exception class
-*
-* FUNCTION
-* gError is (or will be) the basis for error-handling
-* in the DGI libraries. It has the ability to store an
-* ASCII error message text which can be printed to the
-* display.
-*
-* The display of the error messages can be handled
-* automatically by gError, or a custom error-reporting
-* routine can be specified for things like an error
-* window.
-*
-* SEE ALSO
-* gError::gError
-* gError::warn
-* class MemoryError
-* class DOSError
-*
-*******************************************************************/
-
-/****** errclass.cpp/gError::gError *******************************
-*
-* NAME
-* gError::gError -- constructor for gError class
-*
-* SYNOPSIS
-* throw gError( "message", arg );
-*
-* gError::gError( char *msg, ... );
-*
-* FUNCTION
-* The gError constructor is called whenever an exception is
-* thrown. It appends the message (after it is expanded) into
-* the internal error text buffer. If there is no custom error
-* handler currently installed, then the error message is
-* printed to stderr. If a custom error handler is installed,
-* then the error message is left in the buffer until the
-* "dump" member function is called.
-*
-* INPUTS
-* message a text string, which can have printf-like
-* formatting. The additional args are used just
-* like printf.
-* NOTE: A linefeed '\n' should be included
-* at the end of the error message.
-*
-* args printf-like variable arguments.
-*
-* EXAMPLE
-* /c/throw gError( "Attempt to open window failed.\n" );
-*
-* SEE ALSO
-* gError [class]
-* gError::warn
-*
-*******************************************************************/
-
-gError::gError(char *msg, ...) {
- va_list argptr;
-
- va_start(argptr, msg);
- append(msg, argptr);
- va_end(argptr);
-}
-
-gError::gError(void) {}
-
-/****** errclass.cpp/gError::dump *******************************
-*
-* NAME
-* gError::dump -- prints out the error message
-*
-* SYNOPSIS
-* gError::dump();
-*
-* static gError::dump( void );
-*
-* FUNCTION
-* The dump member function can be called by the application
-* to force printing of the error message. This is only needed
-* when a dump-handler has been installed.
-*
-* INPUTS
-* none
-*
-* SEE ALSO
-* gError [class]
-*
-*******************************************************************/
-
-void gError::dump(void) {
- if (errBufOffset > 0) {
- if (dumpHandler) dumpHandler(errBuf);
- else fputs(errBuf, stderr);
-
- errBuf[ 0 ] = 0;
- errBufOffset = 0;
- }
-}
-
-/****** errclass.cpp/gError::warn *******************************
-*
-* NAME
-* gError::warn -- print a non-fatal error
-*
-* SYNOPSIS
-* gError::warn( "message", arg );
-*
-* void gError::warn( char *msg, ... );
-*
-* FUNCTION
-* the 'warn' member function appends an error message to
-* the internal gError message buffer, but does not throw
-* an exception. This can be useful for mixing non-fatal
-* error messages in the same message stream.
-*
-* INPUTS
-* message a text string, which can have printf-like
-* formatting. The additional args are used just
-* like printf.
-* NOTE: A linefeed '\n' should be included
-* at the end of the error message.
-*
-* args printf-like variable arguments.
-*
-* SEE ALSO
-* gError [class]
-* gError::gError [class]
-*
-*******************************************************************/
-
-void gError::warn(char *msg, ...) {
- va_list argptr;
-
- va_start(argptr, msg);
- append(msg, argptr);
- va_end(argptr);
-}
-
-void gError::appendf(char *msg, ...) {
- va_list argptr;
-
- va_start(argptr, msg);
- append(msg, argptr);
- va_end(argptr);
-}
-
-void gError::append(char *msg, va_list args) {
- uint8 tempBuf[ 256 ];
- int16 size = vsprintf((char *) tempBuf, msg, args);
-
- size = MIN<int16>(size, errBufSize - errBufOffset);
- memcpy(errBuf + errBufOffset, tempBuf, size + 1);
- errBufOffset += size;
- if (!saveErrFlag) dump();
-}
-
-/****** errclass.cpp/gError::setErrBufSize *******************************
-*
-* NAME
-* gError::setErrBufSize -- set the size of the internal error buffer
-*
-* SYNOPSIS
-* gError::setErrBufSize( size );
-*
-* void gError::setErrBufSize( int32 );
-*
-* FUNCTION
-* the default internal error buffer is 128 bytes. This is
-* fine for most applications. However, applications which
-* make substantial use of 'warn' to create a log of
-* errors will quickly run out of room. This function can be
-* used to allocate a larger buffer.
-*
-* Note that messages which overflow the error buffer are
-* truncated.
-*
-* INPUTS
-* size the desired size of the error text buffer.
-*
-* SEE ALSO
-* gError [class]
-* gError::gError [class]
-*
-*******************************************************************/
-
-void gError::setErrBufSize(int32 size) {
- if (errBuf) free(errBuf);
- errBuf = new char[ size ];
- errBufOffset = 0;
- errBufSize = (int16) size;
-}
-
-/****** errclass.cpp/gError::setDumpHandler *******************************
-*
-* NAME
-* gError::setDumpHandler -- set a custom error reporting function
-*
-* SYNOPSIS
-* gError::setDumpHandler( handlerFunc );
-*
-* void gError::setDumpHandler( void (*dumpHand)( char * ) );
-*
-* FUNCTION
-* This function can be used to set a custom "dump" handler
-* for gError exceptions. The dump handler is called whenever
-* an error occurs, unless the "saveErrors" flag has been set,
-* in which case the dump handler is called whenever
-* gError::dump() is called by the application.
-*
-* The "dump" function is called with a single argument, which
-* is a character pointer to the error buffer( which is NULL
-* terminated).
-*
-* INPUTS
-* handlerFunc the custom error reporting function.
-*
-* SEE ALSO
-* gError [class]
-* gError::gError [class]
-*
-*******************************************************************/
-
-/****** errclass.cpp/gError::saveErrs *******************************
-*
-* NAME
-* gError::saveErrs -- tell gError to accumulate error messages.
-*
-* SYNOPSIS
-* gError::saveErrs( save );
-*
-* void gError::saveErrs( bool );
-*
-* FUNCTION
-* This member function affects the "saveErrorFlag" which
-* determines if errors are dumped immediately when they
-* occur, or if they are accumulated and dumped when the
-* application calls gError::dump();
-*
-* INPUTS
-* save TRUE - do not dump errors automatically,
-* accumulate them in buffer.
-* FALSE - dump errors immediately and clear buffer.
-*
-* (the gError class defaults to saveErrors=FALSE)
-*
-* SEE ALSO
-* gError [class]
-* gError::gError [class]
-*
-*******************************************************************/
-
-/* ======================================================================= *
- class MemoryError
- * ======================================================================= */
-
-/****** errclass.cpp/MemoryError [class] *******************************
-*
-* NAME
-* class MemoryError -- exception class for memory errors
-*
-* FUNCTION
-* MemoryError is a class designed to be used for
-* out-of-memory errors. It is derived from class gError,
-* and inherits most of it's behavior from that class.
-*
-* It has two forms:
-*
-* /c/
-* /c/throw MemoryError( size );
-* /c/throw MemoryError();
-* /c/
-*
-* -- where 'size' is the amount of memory that the
-* application was attempting to allocate.
-*
-* EXAMPLE
-*
-* the code:
-*
-* /c/
-* /c/throw MemoryError( 1000 );
-* /c/
-*
-* produces the message:
-*
-* /c/
-* /c/"Attempt to allocate object size 1000 failed."
-* /c/
-*
-* SEE ALSO
-* gError::gError
-* gError::warn
-* class gError
-* class DOSError
-*
-*******************************************************************/
-
-MemoryError::MemoryError(int32 size)
- : gError("Attempt to allocate object size %d failed.\n", size)
-{}
-
-MemoryError::MemoryError(void)
- : gError("Memory allocation failed.\n")
-{}
-
-} // end of namespace Saga2
diff --git a/engines/saga2/errclass.h b/engines/saga2/errclass.h
deleted file mode 100644
index 4f88c0fca6..0000000000
--- a/engines/saga2/errclass.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#ifndef SAGA2_ERRCLASS_H
-#define SAGA2_ERRCLASS_H 1
-
-namespace Saga2 {
-
-class gError {
-protected:
-
- static void (*dumpHandler)(char *);
- static char *errBuf;
-
- static int16 errBufSize,
- errBufOffset;
- static uint8 saveErrFlag;
-
- // Special constructor for sub-classes which doesn't do
- // anything.
- gError(void);
-
- // Append to error buffer (subclasses can use)
- static void append(char *msg, va_list args);
- static void appendf(char *msg, ...);
-
-public:
- gError(char *msg, ...);
-
- static void dump(void);
- static void setDumpHandler(void (*dumpHand)(char *)) {
- dumpHandler = dumpHand;
- }
- static void saveErrs(bool flag) {
- saveErrFlag = (uint8) flag;
- }
-
- static void warn(char *msg, ...);
- static void setErrBufSize(int32 size);
-};
-
-class MemoryError : private gError {
-public:
- MemoryError(int32 allocSize);
- MemoryError(void);
-};
-
-class DosError : private gError {
-public:
- DosError(char *msg, ...);
-};
-
-/* ===================================================================== *
- Breakpoint code
- * ===================================================================== */
-
-/* ===================================================================== *
- Assertion macros (VERIFY)
- * ===================================================================== */
-
-#undef verify
-
-#define verify(expr) (expr)
-#define assert2(__ignore,msg) ((void)0)
-
-#define VERIFY assert
-
-#ifndef ASSERT
-#define ASSERT(x) assert(x)
-#define ASSERTMSG assert2
-#endif
-
-// Extensions to set a breakpoint from code
-
-#if DEBUG && defined(__WATCOMC__)
-
-# ifdef __cplusplus
-void debug_breakpoint(const int linenumber, const char filename[]);
-void debug_dumptext(const char text[]);
-# else
-void cebug_breakpoint(const int linenumber, const char filename[]);
-void cebug_dumptext(const char text[]);
-# endif
-
-# ifdef __cplusplus
-# define DEBUG_BREAK debug_breakpoint(__LINE__,__FILE__)
-# else
-# define DEBUG_BREAK cebug_breakpoint(__LINE__,__FILE__)
-# endif
-
-# ifndef NO_BREAK_ON_VERIFAIL
-# ifdef VERIFY
-# undef VERIFY
-# endif
-# define VERIFY(expr) ((expr)?(void)0:(DEBUG_BREAK,__verify(#expr,__FILE__,__LINE__ )))
-# endif // NO_BREAK_ON_VERIFAIL
-
-# ifndef NO_RUNTIME_MESSAGES
-# ifdef __cplusplus
-# define DEBUG_DUMP(s) debug_dumptext(s)
-# else // __cplusplus
-# define DEBUG_DUMP(s) cebug_dumptext(s)
-# endif // __cplusplus
-# else // NO_RUNTIME_MESSAGES
-# define DEBUG_DUMP(s) ((void)0)
-# endif // NO_RUNTIME_MESSAGES
-
-#else // DEBUG && defined(__WATCOMC__)
-
-# define DEBUG_BREAK ((void)0)
-# define DEBUG_DUMP(s) ((void)0)
-
-#endif // DEBUG && defined(__WATCOMC__)
-
-} // end of namespace Saga2
-
-#endif
diff --git a/engines/saga2/errlist.cpp b/engines/saga2/errlist.cpp
deleted file mode 100644
index d3f0f42523..0000000000
--- a/engines/saga2/errlist.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#include "saga2/std.h"
-#include "saga2/errlist.h"
-
-namespace Saga2 {
-
-SequentialErrorList::SequentialErrorList(ErrType et, uint32 ec, char *es[]) : ErrorList(et, ec) {
- for (int i = 0; i < eLimit(); i++)
- setEntry(i, i, es[i]);
-}
-
-SequentialErrorList::SequentialErrorList(ErrType et, const char *es[]) : ErrorList(et, stringCount(es)) {
- for (int i = 0; i < eLimit(); i++)
- setEntry(i, i, es[i]);
-}
-
-uint32 SequentialErrorList::stringCount(const char *es[]) {
- uint32 rv = 0;
- if (es == NULL)
- return 0;
- while (strlen(es[rv])) rv++;
- return rv;
-}
-
-uint32 SequentialErrorList::lookupMessage(ErrorID id) {
- if (id >= 0 && id < eLimit()) {
- return id;
- }
- return unkError;
-}
-
-SparseErrorList::SparseErrorList(ErrType et, uint32 ec, ErrorID ei[], const char *es[]) : ErrorList(et, ec) {
- for (int i = 0; i < eLimit(); i++)
- setEntry(i, ei[i], es[i]);
-}
-
-SparseErrorList::SparseErrorList(ErrType et, uint32 ec, ErrorRec er[]) : ErrorList(et, ec) {
- for (int i = 0; i < eLimit(); i++)
- setEntry(i, er[i].ID, er[i].text);
-}
-
-uint32 SparseErrorList::lookupMessage(ErrorID id) {
- for (int i = 0; i < eLimit(); i++) {
- if (errList[i].ID == id)
- return i;
- }
- return unkError;
-}
-
-}
diff --git a/engines/saga2/errlist.h b/engines/saga2/errlist.h
deleted file mode 100644
index f0f1f856fb..0000000000
--- a/engines/saga2/errlist.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#ifndef SAGA2_ERRLIST_H
-#define SAGA2_ERRLIST_H
-
-#include "saga2/errbase.h"
-
-namespace Saga2 {
-
-class SequentialErrorList : public ErrorList {
- static uint32 stringCount(const char *es[]);
-protected:
- virtual uint32 lookupMessage(ErrorID id);
-public:
- SequentialErrorList(ErrType et, uint32 ec, char *es[]);
- SequentialErrorList(ErrType et, const char *es[]);
- virtual ~SequentialErrorList() {}
-};
-
-class SparseErrorList : public ErrorList {
-protected:
- virtual uint32 lookupMessage(ErrorID id);
-public:
- SparseErrorList(ErrType et, uint32 ec, ErrorID ei[], const char *es[]);
- SparseErrorList(ErrType et, uint32 ec, ErrorRec er[]);
- virtual ~SparseErrorList() {}
-};
-
-}
-
-#endif
diff --git a/engines/saga2/errors.cpp b/engines/saga2/errors.cpp
deleted file mode 100644
index d22b5367d0..0000000000
--- a/engines/saga2/errors.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#include "saga2/std.h"
-#include "saga2/errlist.h"
-#include "saga2/errtype.h"
-
-namespace Saga2 {
-
-// ------------------------------------------------------------------
-// FTA2 error text
-
-const char *FTA2ProgramErrors[] = {
- "No Error",
- "Unknown command line argument",
-
-
- "Minimum CPU not found",
- "Get a real machine",
- "Get a real machine",
- "Not in a DOS Box",
- "This program requires 8 Megabytes of RAM to run properly",
- "You do not have sufficient memory available",
- "This program requires more virtual memory to run properly",
- "You do not have sufficient virtual memory available",
- "No DPMI support", // Minimum memory
-
-
- "You should run SETSOUND before running this program for the first time",
- "You should run SETSOUND and set up a digital sound driver",
- "You should run SETSOUND and set up a music driver",
- "Unaccelerated video card detected",
- "Get a real machine",
- "This game requires a mouse. No mouse driver was detected.",
-
-
- "Unable to allocate fault handler",
- "Direct X does not recognize your display. You may have inappropriate drivers.",
- "Could not initialize the audio",
- "Could not initialize the game clock",
-
-
- "A severe internal error has occurred",
-
-
- "A program file cannot be opened",
- "A necessary file can't be found. You may need to insert the game CD",
- "The game CD is required to play a video.",
- "Sound driver not detected. Continue anyway?",
- "Music driver not detected. Continue anyway?",
-
- "A program file is in use and cannot be opened",
- "A program file may be corrupt or wrong size",
- "A program file could not be read",
- "A program file could not be written",
- "A program file could not be closed",
-
- "A saved game file could not be read",
- "A saved game file could not be written",
-
-
- "The display is in use by another program",
-
-
- "An internal program error has been detected",
-
-
- "Are you sure you want to exit",
- "Direct X does not recognize your display. You may have inappropriate drivers. Emulation will allow you to continue, but perfomance will be severly degraded. Do you want to continue?",
- "Game heap overflowed continue?",
-
- ""
-};
-
-SequentialErrorList programErrors(etiFTA2ErrorList, FTA2ProgramErrors);
-
-}
diff --git a/engines/saga2/errtype.h b/engines/saga2/errtype.h
deleted file mode 100644
index 920d111473..0000000000
--- a/engines/saga2/errtype.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#ifndef SAGA2_ERRTYPE_H
-#define SAGA2_ERRTYPE_H
-
-namespace Saga2 {
-
-/* ===================================================================== *
- IDs for error lists
- * ===================================================================== */
-
-enum DGIErrorTypeIDs {
-
- //system error lists
- etiSystemErrorList = 0x00000001,
-
- //application error lists
- etiApplicationList = 0x10000000,
-
- // Common error types
- etiWin32ExceptionList = 0x10000002,
- etiDDrawErrorList = 0x10000003,
-
- //specific application error lists
- etiFTA2ErrorList = 0x10001001,
-
-
-};
-
-
-
-
-
-#endif //ERRTYPE_H
-
-}
-
diff --git a/engines/saga2/fta.h b/engines/saga2/fta.h
index ba975d9d0b..4903c245ca 100644
--- a/engines/saga2/fta.h
+++ b/engines/saga2/fta.h
@@ -32,12 +32,10 @@
#include "saga2/vpal.h"
#include "saga2/gpointer.h"
#include "saga2/fontlib.h"
-#include "saga2/errclass.h"
#include "saga2/rmem.h"
#include "saga2/hresmgr.h"
#include "saga2/savefile.h"
#include "saga2/config.h"
-#include "saga2/nice_err.h"
namespace Saga2 {
/* ===================================================================== *
@@ -199,25 +197,7 @@ void restoreProgramDir(void); // chdir() to program directory
void *mustAlloc(uint32 size, const char desc[]); // alloc 'size' bytes or fail
RHANDLE mustAllocHandle(uint32 size, const char desc[]); // as above, but relocatable
//void checkAlloc( void *ptr ); // check allocation
-#define checkAlloc(ptr) assertAlloc(ptr)
-
-// Debugging routines
-
-
-// We've replaced the old error-handling routines with an exception class,
-// but not all source has been updated.
-#if 1
-#ifndef WIN32
-#define fatal throw gError
-#else
-void fatal(char *msg, ...);
-#endif
-#else
-#define fatal systemConfigError
-#endif
-#define debugf gError::warn
-
-extern void TBlit(gPixelMap *d, gPixelMap *s, int32 x, int32 y);
+#define checkAlloc(ptr) (ptr)
// Returns Random Number
diff --git a/engines/saga2/gpointer.cpp b/engines/saga2/gpointer.cpp
index 28b585fbbb..cddae37628 100644
--- a/engines/saga2/gpointer.cpp
+++ b/engines/saga2/gpointer.cpp
@@ -30,7 +30,6 @@
#include "saga2/vdraw.h"
#include "saga2/gpointer.h"
#include "saga2/input.h"
-#include "saga2/errclass.h"
namespace Saga2 {
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index 94f5fcda04..bcb80a6c78 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -29,7 +29,6 @@
#include "saga2/std.h"
#include "saga2/saga2.h"
#include "saga2/rmemfta.h"
-#include "saga2/errclass.h"
#include "saga2/hresmgr.h"
#include "saga2/fta.h"
#include "common/debug.h"
@@ -415,7 +414,7 @@ hResource::hResource(char *resname, char *extname, const char desc[]) {
strncpy(_externalPath, extname ? extname : "", EXTERNAL_PATH_SIZE);
debugC(kDebugResources, "Opening resource: %s", resname);
- _file.open(resname);
+ _file.open(resname);
readResource(origin);
if (origin.id != HRES_ID)
diff --git a/engines/saga2/ioerrors.h b/engines/saga2/ioerrors.h
index 353f248f02..f1893a2146 100644
--- a/engines/saga2/ioerrors.h
+++ b/engines/saga2/ioerrors.h
@@ -27,8 +27,6 @@
#ifndef SAGA2_IOERRORS_H
#define SAGA2_IOERRORS_H
-#include "saga2/nice_err.h"
-
namespace Saga2 {
#ifdef _WIN32
diff --git a/engines/saga2/loadsave.cpp b/engines/saga2/loadsave.cpp
index 8669c8c545..08211210c0 100644
--- a/engines/saga2/loadsave.cpp
+++ b/engines/saga2/loadsave.cpp
@@ -48,7 +48,6 @@
#include "saga2/intrface.h"
#include "saga2/palette.h"
#include "saga2/contain.h"
-#include "saga2/nice_err.h"
namespace Saga2 {
diff --git a/engines/saga2/magic.cpp b/engines/saga2/magic.cpp
index c890b6a3ef..1eeb46701d 100644
--- a/engines/saga2/magic.cpp
+++ b/engines/saga2/magic.cpp
@@ -111,7 +111,7 @@ void initializeSkill(SkillProto *oNo, SpellID sNo) {
error("Duplicate prototype for spell %d", sNo);
spellBook[sNo].setProto(oNo);
} else
- gError::warn("Spell prototype has invalid spell ID %d (lockType)", sNo);
+ warning("Spell prototype has invalid spell ID %d (lockType)", sNo);
}
//-----------------------------------------------------------------------
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index bf03915551..404837331e 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -41,6 +41,7 @@
#include "saga2/messager.h"
#include "saga2/intrface.h"
#include "saga2/script.h"
+#include "saga2/localize.h"
#include "saga2/mainmap.h"
#include "saga2/display.h"
#include "saga2/tower.h"
@@ -49,7 +50,7 @@
#include "saga2/ioerrors.h"
#include "saga2/loadsave.h"
#include "saga2/gamerate.h"
-
+#include "saga2/msgbox.h"
namespace Saga2 {
@@ -176,7 +177,6 @@ frameCounter irate(TICKSPERSECOND, gameTime);
* ===================================================================== */
bool readCommandLine(int argc, char *argv[]);
-void errDumper(char *s);
void findProgramDir(char *argv); // save program home directory
APPFUNC(cmdWindowFunc); // main window event handler
@@ -329,16 +329,9 @@ void processEventLoop(bool updateScreen) {
statusshow("starting event loop");
irate.updateFrameCount();
- statusshow("checking for exceptions");
- if (FatalErrorFlag()) {
- //gameRunning=false;
- endGame();
- return;
- }
-
statusshow("checking user abort");
breakEventLoop();
- if (checkExit && verifyUserExit()) { //( SystemError::SystemErrorRetry(cpUserAbort,"")!=0 ) )
+ if (checkExit && verifyUserExit()) {
//gameRunning=false;
endGame();
return;
@@ -470,14 +463,9 @@ char *getExeFromCommandLine(int argc, char *argv[]) {
// Adds error handling to command line parsing
bool readCommandLine(int argc, char *argv[]) {
- SimpleErrorMessager cmdLineFatal;
-
- //SystemError::useHandler(&cmdLineFatal);
parseCommandLine(argc, argv);
return true;
-
- //SystemError::useHandler(NULL);
}
/********************************************************************/
@@ -703,21 +691,20 @@ static bool openResource(
char *basePath, // path to data file
char *defaultPath, // backup path
char *fileName, // file name & extension
- char *description, // description of this resource
- configProblem errID) { // in case something goes wrong
+ char *description) {
if (hr) delete hr;
hr = NULL;
hr = NEW_PRES hResource(fileName, defaultPath, description);
- while ((hr == NULL || !hr->_valid) && retryConfigError(cpResDiskMissing, description)) {
+ while (hr == NULL || !hr->_valid) {
if (hr) delete hr;
hr = NULL;
hr = NEW_PRES hResource(fileName, defaultPath, description);
}
if (hr == NULL || !hr->_valid) {
- error("openResource: %s: %d", fileName, errID);
+ error("openResource: Cannot open resource: %s, %s", fileName, description);
// return false;
}
return true;
@@ -731,25 +718,25 @@ bool openResources(void) {
if (
openResource(resFile, globalConfig.imageResfilePath,
"..\\resfile\\", IMAGE_RESFILE,
- "Imagery resource file", cpResFileMissing) &&
+ "Imagery resource file") &&
openResource(objResFile, globalConfig.mainResfilePath,
"..\\resfile\\", OBJECT_RESFILE,
- "Object resource file", cpResFileMissing) &&
+ "Object resource file") &&
openResource(auxResFile, globalConfig.dataResfilePath,
"..\\resfile\\", AUX_RESFILE,
- "Data resource file", cpResFileMissing) &&
+ "Data resource file") &&
openResource(scriptResFile, globalConfig.scriptResfilePath,
"..\\scripts\\", SCRIPT_RESFILE,
- "Script resource file", cpResFileMissing) &&
+ "Script resource file") &&
openResource(voiceResFile, globalConfig.voiceResfilePath,
"..\\sound\\", VOICE_RESFILE,
- "Voice resource file", cpResFileMissing) &&
+ "Voice resource file") &&
openResource(soundResFile, globalConfig.soundResfilePath,
"..\\sound\\", SOUND_RESFILE,
- "Sound resource file", cpResFileMissing)) {
+ "Sound resource file")) {
return true;
}
return false;
@@ -893,7 +880,7 @@ void loadGlobals(SaveFileReader &saveGame) {
bool verifyUserExit(void) {
if (!gameRunning)
return true;
- if (SystemError::SystemErrorRetry(cpUserAbort, "") != 0)
+ if (FTAMessageBox("Are you sure you want to exit", ERROR_YE_BUTTON, ERROR_NO_BUTTON) != 0)
return true;
return false;
}
@@ -981,17 +968,6 @@ void WriteStatusF(int16, char *, ...) {}
void WriteStatusF2(int16, char *, ...) {}
#endif
-//---------------------------------------------------------
-//
-// Assorted kludgy messaging routines
-//
-//
-
-void errDumper(char *s) {
- SystemError::SystemErrorNotify(s);
-}
-
-
void logStr(bool onOff, bool newLn, char *st);
void memoryWarning(char *msg, ...) {
@@ -1151,7 +1127,7 @@ void cleanupMemPool(void) {
if (heapMemory) {
free(heapMemory);
heapMemory = nullptr;
- }
+ }
}
//-----------------------------------------------------------------------
diff --git a/engines/saga2/mainmap.h b/engines/saga2/mainmap.h
index 5df272b6a3..46d284e7e6 100644
--- a/engines/saga2/mainmap.h
+++ b/engines/saga2/mainmap.h
@@ -110,7 +110,6 @@ void displayEventLoop(void);
// major parts of main that are actually in main.cpp
void cleanupGame(void); // auto-cleanup function
-void errDumper(char *s);
bool setupGame(void);
void cleanupPalettes(void);
diff --git a/engines/saga2/module.mk b/engines/saga2/module.mk
index 1c86299ad2..dc44bdc89d 100644
--- a/engines/saga2/module.mk
+++ b/engines/saga2/module.mk
@@ -23,10 +23,6 @@ MODULE_OBJS := \
document.o \
effects.o \
enchant.o \
- errbase.o \
- errclass.o \
- errlist.o \
- errors.o \
exit.o \
floating.o \
gamemode.o \
@@ -61,7 +57,6 @@ MODULE_OBJS := \
msgbox.o \
noise.o \
mouseimg.o \
- nice_err.o \
objects.o \
objproto.o \
osexcept.o \
diff --git a/engines/saga2/msgbox.cpp b/engines/saga2/msgbox.cpp
index dc4305d9f5..1d51fa1c48 100644
--- a/engines/saga2/msgbox.cpp
+++ b/engines/saga2/msgbox.cpp
@@ -27,6 +27,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
+#include "saga2/localize.h"
#include "saga2/msgbox.h"
namespace Saga2 {
diff --git a/engines/saga2/nice_err.cpp b/engines/saga2/nice_err.cpp
deleted file mode 100644
index 694446d383..0000000000
--- a/engines/saga2/nice_err.cpp
+++ /dev/null
@@ -1,501 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * aint32 with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
-#include "saga2/std.h"
-#include "saga2/rmemfta.h"
-#include "saga2/cmisc.h"
-#include "saga2/fta.h"
-#include "saga2/errors.h"
-#include "saga2/program.h"
-#include "saga2/messager.h"
-#include "saga2/display.h"
-#include "saga2/localize.h"
-
-namespace Saga2 {
-
-pMessager basicFatal = NULL;
-pMessager delayedFatal = NULL;
-pMessager activeFatal = NULL;
-
-bool cleaningUp = FALSE;
-static bool FatalFlag = FALSE;
-static int lasterrno;
-void BackToSysPalette(void);
-
-/* ===================================================================== *
- Functions
- * ===================================================================== */
-
-// ------------------------------------------------------------------
-// niceFatal is a happy joyful way to tell the user his disk is full
-
-void niceFatal(char *msg, ...) {
- char dump[256];
- va_list argptr;
-
- va_start(argptr, msg);
- vsprintf(dump, msg, argptr);
- va_end(argptr);
-
- error("Program ended : %s", dump);
-}
-
-int16 FTAMessageBox(char *msg, char *btnMsg1, char *btnMsg2) {
- warning("STUB: FTAMessageBox()");
- return 0;
-}
-
-// ------------------------------------------------------------------
-// shutdownSave offers a chance to save the game on fatal exits
-
-void shutdownSave(void) {
-#if !DEBUG
- cleaningUp = TRUE;
-#endif
-}
-
-/* ===================================================================== *
- SystemError member functions
- * ===================================================================== */
-
-pMessager SystemError::fatalMessager = NULL;
-
-// ------------------------------------------------------------------
-// Constructors
-
-SystemError::SystemError(const char *nmsg, ...) {
- va_list argptr;
-
- notifyFlag = FALSE;
- cp = cpInternal;
- va_start(argptr, nmsg);
- buildMsg(nmsg, argptr);
- va_end(argptr);
-}
-
-SystemError::SystemError(configProblem errID, const char *nmsg, ...) {
- va_list argptr;
-
- notifyFlag = FALSE;
- cp = errID;
- va_start(argptr, nmsg);
- buildMsg(nmsg, argptr);
- va_end(argptr);
-}
-
-#if DEBUG
-void SystemError::buildMsg(const char *fmt, va_list vl)
-#else
-void SystemError::buildMsg(const char *, va_list)
-#endif
-{
-#if 0
- char dosErr[256];
- if (errno && (cp >= cpResFileLocked && cp <= cpSavFileRead)) { // unable to read save file
- sprintf(dosErr, "(%s)\n", strerror(errno));
- lasterrno = errno;
- errno = 0;
- } else
- dosErr[0] = '\0';
-
-#if DEBUG
- SureLogMessager slm = SureLogMessager("SYSERRS.LOG", (int16) 0, SureLogMessager::logOpenAppend);
- char tmsg[256];
- vsprintf(tmsg, fmt, vl);
- sprintf(msg, "%s\n%s%s\n", sysMessage(cp), dosErr, tmsg);
- slm("FATAL: %s\n", msg);
-#else
- sprintf(msg, "%s\n%s", sysMessage(cp), dosErr);
-#endif
- if (getRetry(cp) != rcIgnore)
- if (!notifyFlag) {
- //#if DEBUG
- // warn(msg);
- //#else
- SystemErrorNotify(msg);
- notifyFlag = TRUE;
- //#endif
- }
-#endif
- warning("STUB: SystemError::buildMsg");
-}
-
-// ------------------------------------------------------------------
-// Code to get the textual version of an error message
-
-#include "saga2/errlist.h"
-
-extern SequentialErrorList programErrors;
-
-const char *SystemError::sysMessage(configProblem prob) {
- ErrText et = programErrors.errMessage(prob);
- return et;
-}
-
-// ------------------------------------------------------------------
-// Code to get the appropriate action for an error
-
-SystemError::RetryClasses SystemError::getRetry(configProblem prob) {
- switch (prob) {
- case cpMinCPU :
- case cpMinCPUSpeed :
- case cpMinDOSVer :
- case cpInDOSBox :
- case cpInsufPhysRAM :
- case cpInsufPhysMemFree :
- case cpInsufVirtRAM :
- case cpInsufVirtMemFree :
- case cpNoDPMISupport :
- case cpNoAudioDrivers :
- case cpNoDIGAudio :
- case cpNoMDIAudio :
- case cpNoMouseDriver :
- case cpLowSVGAThruput :
- case cpLowCDROMThruput :
- case cpDDrawInitFail :
- case cpDSoundInitFail :
- case cpDTimerInitFail :
- case cpProcessorExcept :
- case cpGPHandlerFail :
- case cpInternal :
- case cpResFileLocked :
- case cpResFileSeek :
- case cpResFileRead :
- case cpResFileWrite :
- case cpResFileClose :
- return rcFatal;
-
- case cpResFileMissing :
- case cpResDiskMissing :
- case cpVidDiskMissing :
- case cpDDrawReInitFail :
- return rcRetry;
-
- case cpUserAbort :
- case cpVideoCompat :
- case cpHeapOverflow :
- case cpNoDIGAudioCheck :
- case cpNoMDIAudioCheck :
- return rcYesNo;
-
- case cpExitQuietly :
- return rcIgnore;
-
- default :
- return rcFatal;
- }
-}
-
-// ------------------------------------------------------------------
-// needed for error handling
-
-#ifdef _WIN32
-#include "saga2/ftawin.h"
-extern HWND hWndMain;
-void localCursorOn(void);
-void localCursorOff(void);
-#else
-int textUserDialog(char *, char *msg, char *b1, char *b2, char *b3);
-#endif
-
-// ------------------------------------------------------------------
-// Simple error handling
-
-SimpleErrorMessager::SimpleErrorMessager() {
-}
-
-SimpleErrorMessager::~SimpleErrorMessager() {
-}
-
-int SimpleErrorMessager::dumpit(char *s, size_t size) {
-#ifdef _WIN32
- MessageBox(hWndMain, s, PROGRAM_FULL_NAME, MB_APPLMODAL | MB_ICONSTOP | MB_OK);
-#else
- textUserDialog(PROGRAM_FULL_NAME, s, NULL, NULL, NULL);
-#endif
- return size;
-}
-
-// ------------------------------------------------------------------
-// delayed Simple error handling
-
-int BufferedErrorMessager::dumpit(char *t, size_t s) {
- if (cleaningUp)
- return s;
- return BufferedTextMessager::dumpit(t, s);
-}
-
-BufferedErrorMessager::BufferedErrorMessager(size_t s) :
- BufferedTextMessager(s) {
-}
-
-BufferedErrorMessager::~BufferedErrorMessager() {
- if (dumpText) {
- if (bufPos) {
-#ifdef _WIN32
- MessageBox(hWndMain, dumpText, PROGRAM_FULL_NAME, MB_APPLMODAL | MB_ICONSTOP | MB_OK);
-#else
- textUserDialog(PROGRAM_FULL_NAME, dumpText, NULL, NULL, NULL);
-#endif
- }
- bufPos = 0;
- }
-}
-
-// ------------------------------------------------------------------
-// full screen mode error handling
-
-int GUIErrorMessager::dumpit(char *s, size_t size) {
- FTAMessageBox(s, NULL, "OK");
- return size;
-}
-
-GUIErrorMessager::GUIErrorMessager() {
-}
-
-GUIErrorMessager::~GUIErrorMessager() {
-}
-
-#define errDialog(t,m,b1,b2,b3) FTAMessageBox(m,b1,b2)
-
-#ifdef _WIN32
-extern CFTWindow *pWindow;
-extern char TITLE[];
-#else
-int textUserDialog(char *, char *msg, char *b1, char *b2, char *b3);
-int16 userDialog(char *title, char *msg, char *btnMsg1,
- char *btnMsg2,
- char *btnMsg3);
-
-
-// ------------------------------------------------------------------
-// in DOS, if Graphics haven't been initialized we still need a Retry
-// capability
-
-int textUserDialog(char *, char *msg, char *bt1, char *bt2, char *bt3) {
- int bs = 0;
- char l[5];
- char b1[32];
- char b2[32];
- char b3[32];
- char c = '\0';
- for (int i = 0; i < 5; i++)
- l[i] = '\0';
- if (bt1) strncpy(b1, bt1, 32);
- else b1[0] = '\0';
- if (bt2) strncpy(b2, bt2, 32);
- else b2[0] = '\0';
- if (bt3) strncpy(b3, bt3, 32);
- else b3[0] = '\0';
- if (isalpha(*b1)) l[bs++] = toupper(*b1);
- if (isalpha(*b2)) l[bs++] = toupper(*b2);
- if (isalpha(*b3)) l[bs++] = toupper(*b3);
-
- fprintf(stderr, "%s\n%s %s %s %s", msg, b1, b2, b3, bs > 1 ? "?" : " ");
-
- if (strlen(l) < 2 || c == 27)
- return -1;
-
-#if 0
- c = toupper(getch());
-#else
- c = 27;
-#endif
- warning("STUB: textUserDialog");
-
- fprintf(stderr, "\n");
-
-#if 0
- while (strlen(l) > 1 && c != 27 && NULL == strchr(l, c))
- c = toupper(getch());
-#endif
-
- return abs(strchr(l, c) - l);
-}
-#endif
-
-// ------------------------------------------------------------------
-// Static member functions to pop up a retry box
-
-bool SystemError::SystemErrorRetry(configProblem errID, const char *nmsg, ...) {
-#if 0
- char t[256];
- char t2[256];
- char dosErr[256];
- if (errno && (errID >= cpResFileLocked && errID <= cpSavFileRead)) // unable to read save file
- sprintf(dosErr, "(%s)\n", strerror(errno));
- else
- dosErr[0] = '\0';
- va_list argptr;
-
- va_start(argptr, nmsg);
- vsprintf(t, nmsg, argptr);
- va_end(argptr);
-
-#if DEBUG
- sprintf(t2, "%s\n%s%s\n", sysMessage(errID), dosErr, t);
-#else
- sprintf(t2, "%s\n%s", sysMessage(errID), dosErr);
-#endif
- return SystemError::SystemErrorRetry(t2, getRetry(errID));
-#endif
- warning("STUB: SystemError::SystemErrorRetry()");
- return false;
-}
-
-bool SystemError::SystemErrorRetry(char *nmsg, SystemError::RetryClasses rc) {
-#ifdef _WIN32
- int r = 1;
- if (
-#if DEBUG
- 0 && (
-#endif
- !displayEnabled(WindowInactive) || !pWindow->m_fullScreen || !displayEnabled(GraphicsInit)
-#if DEBUG
- )
-#endif
- ) {
- BackToSysPalette();
- switch (rc) {
- case rcRetry:
- r = (IDCANCEL != MessageBox(hWndMain,
- nmsg,
- PROGRAM_FULL_NAME,
- MB_APPLMODAL | MB_ICONSTOP | MB_RETRYCANCEL));
- break;
- case rcYesNo:
- r = (IDYES == MessageBox(hWndMain,
- nmsg,
- PROGRAM_FULL_NAME,
- MB_APPLMODAL | MB_ICONQUESTION | MB_YESNO));
- break;
- default:
- return FALSE;
- }
- } else {
- switch (rc) {
- case rcRetry:
- r = errDialog(PROGRAM_FULL_NAME, nmsg, ERROR_RE_BUTTON, ERROR_CA_BUTTON, NULL);
- break;
- case rcYesNo:
- r = errDialog(PROGRAM_FULL_NAME, nmsg, ERROR_YE_BUTTON, ERROR_NO_BUTTON, NULL);
- break;
- default:
- return FALSE;
- }
- }
- return (r);
-#else
- int r = 1;
- if (displayEnabled(GraphicsInit)) {
- switch (rc) {
- case rcRetry:
- r = errDialog(PROGRAM_FULL_NAME, nmsg, ERROR_RE_BUTTON, ERROR_CA_BUTTON, NULL);
- break;
- case rcYesNo:
- r = errDialog(PROGRAM_FULL_NAME, nmsg, ERROR_YE_BUTTON, ERROR_NO_BUTTON, NULL);
- break;
- default:
- return FALSE;
- }
- } else {
- switch (rc) {
- case rcRetry:
- r = textUserDialog(PROGRAM_FULL_NAME, nmsg, ERROR_RE_BUTTON, ERROR_CA_BUTTON, NULL);
- break;
- case rcYesNo:
- r = textUserDialog(PROGRAM_FULL_NAME, nmsg, ERROR_YE_BUTTON, ERROR_NO_BUTTON, NULL);
- break;
- default:
- return FALSE;
- }
- }
- return (r == 0);
-#endif
-}
-
-void SystemError::SystemErrorNotify(const char *nmsg, ...) {
-#ifdef _WIN32
- BackToSysPalette();
-#endif
-#if DEBUG
- SureLogMessager slm = SureLogMessager("SYSERRS.LOG", (int16) 0, SureLogMessager::logOpenAppend);
-#endif
- va_list argptr;
- FatalFlag = TRUE;
-#if DEBUG
- va_start(argptr, nmsg);
- slm.va((char *)nmsg, argptr);
- va_end(argptr);
-#endif
- va_start(argptr, nmsg);
- if (fatalMessager) {
- fatalMessager->va((char *)nmsg, argptr);
- }
- va_end(argptr);
-}
-
-// ------------------------------------------------------------------------
-// Fatal error handling
-
-bool FatalErrorFlag(void) {
- return FatalFlag;
-}
-
-bool SetFatalMode(FatalHandlingModes fhm) {
- if (basicFatal) delete basicFatal;
- basicFatal = NULL;
- if (delayedFatal) delete delayedFatal;
- delayedFatal = NULL;
- if (activeFatal) delete activeFatal;
- activeFatal = NULL;
- SystemError::useHandler(NULL);
- switch (fhm) {
- case fhmSimple:
- basicFatal = new SimpleErrorMessager;
- if (basicFatal == NULL)
- return FALSE;
- SystemError::useHandler(basicFatal);
- return TRUE;
- case fhmHold:
- delayedFatal = new BufferedErrorMessager(4096);
- if (delayedFatal == NULL)
- return FALSE;
- SystemError::useHandler(delayedFatal);
- return TRUE;
- case fhmGUI:
- activeFatal = new GUIErrorMessager;
- if (activeFatal == NULL)
- return FALSE;
- SystemError::useHandler(activeFatal);
- return TRUE;
- }
- return TRUE;
-}
-
-} // end of namespace Saga2
diff --git a/engines/saga2/nice_err.h b/engines/saga2/nice_err.h
deleted file mode 100644
index fd53f68f4e..0000000000
--- a/engines/saga2/nice_err.h
+++ /dev/null
@@ -1,297 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#ifndef SAGA2_NICE_ERR_H
-#define SAGA2_NICE_ERR_H
-
-/* ===================================================================== *
- Includes
- * ===================================================================== */
-
-#include "saga2/errclass.h"
-#include "saga2/errors.h"
-#include "saga2/messager.h"
-#include "saga2/errlist.h"
-#include "saga2/localize.h"
-
-/* ===================================================================== *
- Types
- * ===================================================================== */
-
-// ------------------------------------------------------------------
-// error codes used by SystemError
-
-namespace Saga2 {
-
-enum configProblem {
- cpNoError = 0,
- cpBadCLArgs, // Bad command line args
-
- // Hardware minimums
- cpMinCPU, // Minimum CPU type
- cpMinCPUSpeed, // Minimum CPU speed
- cpMinDOSVer, // Minimum DOS version
- cpInDOSBox, // Running in a DOS box
- cpInsufPhysRAM, // Minimum Physical RAM
- cpInsufPhysMemFree, // Minimum Free Physical RAM
- cpInsufVirtRAM, // Minimum memory
- cpInsufVirtMemFree, // Minimum free memory
- cpNoDPMISupport, // Minimum memory
-
- // DOS problems
- cpNoAudioDrivers, // audio drivers missing
- cpNoDIGAudio, // no AIL dig driver
- cpNoMDIAudio, // no AIL midi driver
- cpLowSVGAThruput, // low frame rate
- cpLowCDROMThruput, // low CD throughput
- cpNoMouseDriver, // mouse driver not loaded
-
- // Win problems
- cpGPHandlerFail, // couldn't add GP handler
- cpDDrawInitFail, // direct draw initfailure
- cpDSoundInitFail, // direct sound init failure
- cpDTimerInitFail, // direct sound init failure
-
- // Runtime failures
- cpProcessorExcept, // GPF et al.
-
- // Resource file failures
- cpResFileMissing, // unable to open resource file
- cpResDiskMissing, // unable to open resource file
- cpVidDiskMissing, // unable to open video file
- cpNoDIGAudioCheck, // no AIL dig driver
- cpNoMDIAudioCheck, // no AIL midi driver
-
- cpResFileLocked, // unable to open resource file for read
- cpResFileSeek, // unable to seek in resource file
- cpResFileRead, // unable to read resource file
- cpResFileWrite, // unable to write resource file
- cpResFileClose, // unable to close resource file
-
- cpSavFileWrite, // unable to write save file
- cpSavFileRead, // unable to read save file
-
- // Multitasking errors
- cpDDrawReInitFail, // unable to reinitialize screen
-
- // Internal
- cpInternal, // internal game error
-
- // User cancel
- cpUserAbort, // user hit break
- cpVideoCompat, // video card warning
- cpHeapOverflow, // heap overflow debugging
-
- // Quiet
- cpExitQuietly,
-
- maxConfigProblem, // bounding value
-};
-
-// ------------------------------------------------------------------
-// SystemError class
-// A gError variant aimed at release versions
-
-class SystemError : public gError {
- // ------------------------------------------------------------------
- // internal types
- enum RetryClasses {
- rcFatal,
- rcClose,
- rcRetry,
- rcYesNo,
- rcIgnore,
- };
-
- // ------------------------------------------------------------------
- // member data
- configProblem cp;
- char msg[256];
- BOOL notifyFlag;
-
- static pMessager fatalMessager;
-
- // ------------------------------------------------------------------
- // internal member functions
- static const char *sysMessage(configProblem prob);
- static RetryClasses getRetry(configProblem prob);
-
- static bool SystemErrorRetry(char *msg, RetryClasses rc);
- void buildMsg(const char *fmt, va_list vl);
-
-
-public:
- // ------------------------------------------------------------------
- // external member functions
- static void useHandler(pMessager m) {
- fatalMessager = m;
- }
-
- static void SystemErrorFatal(SystemError &se) {
- error("%s", se.msg);
- }
- static bool SystemErrorRetry(configProblem errID, const char *notes, ...);
- static void SystemErrorNotify(const char *nmsg, ...);
-
- SystemError(const char *msg, ...);
- SystemError(configProblem errID, const char *msg, ...);
-
- void notify(void) {
- if (!notifyFlag) SystemErrorNotify(msg);
- notifyFlag = TRUE;
- }
-
-};
-
-// ------------------------------------------------------------------
-// Messagers for errors
-
-// ------------------------------------------------------------------
-// For use with unititialized screens
-
-class SimpleErrorMessager : public Messager {
-protected:
- int dumpit(char *s, size_t size);
-
-public:
- SimpleErrorMessager();
- ~SimpleErrorMessager();
-
- void *operator new (size_t s) {
- return calloc(1, s);
- }
- void operator delete (void *m) {
- free(m);
- }
-};
-
-// ------------------------------------------------------------------
-// During init/cleanup
-
-class BufferedErrorMessager : public BufferedTextMessager {
-protected:
- int dumpit(char *, size_t);
-
-public:
- BufferedErrorMessager(size_t s);
- ~BufferedErrorMessager();
-
- void *operator new (size_t s) {
- return calloc(1, s);
- }
- void operator delete (void *m) {
- free(m);
- }
-};
-
-// ------------------------------------------------------------------
-// full screen mode error handling
-
-class GUIErrorMessager : public Messager {
-protected:
- int dumpit(char *s, size_t size);
-
-public:
- GUIErrorMessager();
- ~GUIErrorMessager();
-
- void *operator new (size_t s) {
- return calloc(1, s);
- }
- void operator delete (void *m) {
- free(m);
- }
-};
-
-
-
-
-
-extern SequentialErrorList systemErrors;
-extern SequentialErrorList programErrors;
-#ifdef _WIN32
-extern SparseErrorList win32ExceptionList;
-extern SparseErrorList directDrawErrorList;
-#endif
-
-
-/* ===================================================================== *
- Prototypes
- * ===================================================================== */
-
-// ------------------------------------------------------------------
-// Error descriptions for processor faults
-const char *ExceptDescript(unsigned long ExCode); //, LPEXCEPTION_POINTERS );
-
-// ------------------------------------------------------------------
-// Old system error call
-void niceFatal(char *msg, ...);
-
-// ------------------------------------------------------------------
-// dialog using no resources / little memory
-int16 FTAMessageBox(char *msg, char *btnMsg1, char *btnMsg2);
-
-
-/* ===================================================================== *
- Inlines & aliases
- * ===================================================================== */
-
-// ------------------------------------------------------------------
-// alias to build & throw error
-#define systemConfigError throw SystemError
-
-// ------------------------------------------------------------------
-// alias to do a retry box
-#define retryConfigError SystemError::SystemErrorRetry
-
-// ------------------------------------------------------------------
-// alias to do a warning box
-#define systemWarning SystemError::SystemErrorNotify
-
-// ------------------------------------------------------------------
-// ASSERT variation
-#define REQUIRE(requirement,whenfails) if (!requirement) throw SystemError(whenfails,"")
-
-inline void assertAlloc(void *ptr) {
- if (NULL == ptr)
- error(ALLOCATION_ERROR);
-}
-
-enum FatalHandlingModes {
- fhmNone = 0,
- fhmSimple,
- fhmHold,
- fhmGUI,
-};
-
-bool SetFatalMode(FatalHandlingModes fhm);
-
-
-bool FatalErrorFlag(void);
-
-} // end of namespace Saga2
-
-#endif
diff --git a/engines/saga2/noise.cpp b/engines/saga2/noise.cpp
index ac11709794..d53203625f 100644
--- a/engines/saga2/noise.cpp
+++ b/engines/saga2/noise.cpp
@@ -33,7 +33,6 @@
#include "saga2/audiores.h"
#include "saga2/tcoords.h"
#include "saga2/button.h"
-#include "saga2/nice_err.h"
#include "saga2/annoy.h"
#include "saga2/objproto.h"
#include "saga2/player.h"
diff --git a/engines/saga2/rmem.cpp b/engines/saga2/rmem.cpp
index 040fc7c493..fabb11ac8b 100644
--- a/engines/saga2/rmem.cpp
+++ b/engines/saga2/rmem.cpp
@@ -31,7 +31,6 @@
#define NO_LOCAL_MEMORY_OVERRIDES 1
#include "saga2/rmembase.h"
#include "saga2/errors.h"
-#include "saga2/errclass.h"
namespace Saga2 {
diff --git a/engines/saga2/savefile.cpp b/engines/saga2/savefile.cpp
index 8738a0a145..596ebd625c 100644
--- a/engines/saga2/savefile.cpp
+++ b/engines/saga2/savefile.cpp
@@ -44,36 +44,6 @@ void getSaveFileName(int16 saveNo, char *fileName) {
sprintf(fileName, "%s%3.3d.SAV", globalConfig.savedGamePath, saveNo);
}
-/* ===================================================================== *
- SaveFileWriteError member functions
- * ===================================================================== */
-
-//----------------------------------------------------------------------
-// Constructor
-
-SaveFileWriteError::SaveFileWriteError(char *msg, ...) {
- va_list argptr;
-
- va_start(argptr, msg);
- append(msg, argptr);
- va_end(argptr);
-}
-
-/* ===================================================================== *
- SaveFileReadError member functions
- * ===================================================================== */
-
-//----------------------------------------------------------------------
-// Constructor
-
-SaveFileReadError::SaveFileReadError(char *msg, ...) {
- va_list argptr;
-
- va_start(argptr, msg);
- append(msg, argptr);
- va_end(argptr);
-}
-
/* ===================================================================== *
SaveFileConstructor member functions
* ===================================================================== */
diff --git a/engines/saga2/savefile.h b/engines/saga2/savefile.h
index c29b3bc483..b220fefec7 100644
--- a/engines/saga2/savefile.h
+++ b/engines/saga2/savefile.h
@@ -28,7 +28,6 @@
#define SAGA2_SAVEFILE_H
#include "saga2/iff.h"
-#include "saga2/errclass.h"
namespace Saga2 {
@@ -45,29 +44,6 @@ const ChunkID gameID = MKTAG('F', 'T', 'A', '2');
const ChunkID gameID = MKTAG('D', 'I', 'N', 'O');
#endif
-/* ===================================================================== *
- SaveFileWriteError class
- * ===================================================================== */
-
-// This is an exception class for detecting write errors. This will allow
-// a graceful recovery from a failed save attempt.
-
-class SaveFileWriteError : public gError {
-public:
- SaveFileWriteError(char *msg, ...);
-};
-
-/* ===================================================================== *
- SaveFileWriteError class
- * ===================================================================== */
-
-// The is an exception class for detecting read errors.
-
-class SaveFileReadError : public gError {
-public:
- SaveFileReadError(char *msg, ...);
-};
-
/* ===================================================================== *
SaveFileHeader class
* ===================================================================== */
diff --git a/engines/saga2/spelshow.h b/engines/saga2/spelshow.h
index ca420fa6fe..86a64d32bd 100644
--- a/engines/saga2/spelshow.h
+++ b/engines/saga2/spelshow.h
@@ -119,27 +119,21 @@ class EffectDisplayPrototype {
#pragma off (unreferenced) ;
#endif
static SPELLLOCATIONFUNCTION(nullLocation) {
- VERIFY(0);
return TilePoint(0, 0, 0);
}
static SPELLSPRITATIONFUNCTION(nullSpritation) {
- VERIFY(0);
return 0;
}
static SPELLSTATUSFUNCTION(nullStatus) {
- VERIFY(0);
return effectronDead;
}
static SPELLHEIGHTFUNCTION(nullHeight) {
- VERIFY(0);
return 0;
}
static SPELLBREADTHFUNCTION(nullBreadth) {
- VERIFY(0);
return 0;
}
static SPELLINITFUNCTION(nullInit) {
- VERIFY(0);
}
#ifdef __WATCOMC__
#pragma on (unreferenced) ;
diff --git a/engines/saga2/std.h b/engines/saga2/std.h
index 5e928af5ed..f49936fe99 100644
--- a/engines/saga2/std.h
+++ b/engines/saga2/std.h
@@ -31,6 +31,9 @@
#include "saga2/rmemfta.h"
+#define ASSERT assert // FIXME
+#define VERIFY assert // FIXME
+
#define FTA
// #define LEAVE goto exitit // bail out of function
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index df817a8138..8d08a32fb4 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -4713,8 +4713,7 @@ extern int32 gameTime;
}
tclock1 = gameTime;
- debugf( "Time = %d\n",
- tclock1 - tclock0 );
+ debug( "Time = %d", tclock1 - tclock0 );
*/
diff --git a/engines/saga2/tower.cpp b/engines/saga2/tower.cpp
index d3e40593c9..fa4e7f3606 100644
--- a/engines/saga2/tower.cpp
+++ b/engines/saga2/tower.cpp
@@ -119,12 +119,7 @@ INITIALIZER(programInit) {
if (r) {
setInitState(initializationState + 1);
} else {
- SystemError se = SystemError(
- tower[tLevel].onFail,
- "Tower Initialization Step %d Failed (record %d)",
- initializationState,
- tLevel);
- se.notify();
+ error("Tower Initialization Step %d Failed (record %d)", initializationState, tLevel);
return FALSE;
}
}
@@ -160,8 +155,7 @@ TERMINATOR(termTowerBase) {
// This pair should be the first thing in the tower list
INITIALIZER(initErrorManagers) {
- //initErrorHandlers();
- return SetFatalMode(fhmSimple);
+ return true;
}
// defining VERIFY_EXIT will give you a message box when the program has
@@ -173,35 +167,26 @@ INITIALIZER(initErrorManagers) {
#endif
TERMINATOR(termErrorManagers) {
-#ifdef VERIFY_EXIT
- extern HWND hWndMain;
-#endif
- SetFatalMode(fhmNone);
-#ifdef VERIFY_EXIT
- MessageBox(hWndMain, "Cleanup complete", PROGRAM_FULL_NAME, MB_APPLMODAL | MB_OK);
-#endif
}
// ------------------------------------------------------------------------
// This pair should be used before the display is initialized
INITIALIZER(initDelayedErrors) {
- return SetFatalMode(fhmHold);
+ return true;
}
TERMINATOR(termDelayedErrors) {
- SetFatalMode(fhmSimple);
}
// ------------------------------------------------------------------------
// This pair should be used once everything is working
INITIALIZER(initActiveErrors) {
- return SetFatalMode(fhmGUI);
+ return true;
}
TERMINATOR(termActiveErrors) {
- SetFatalMode(fhmHold);
}
diff --git a/engines/saga2/tower.h b/engines/saga2/tower.h
index 40a1ea37a2..4c4c05ebfe 100644
--- a/engines/saga2/tower.h
+++ b/engines/saga2/tower.h
@@ -27,8 +27,6 @@
#ifndef SAGA2_TOWER_H
#define SAGA2_TOWER_H
-#include "saga2/nice_err.h"
-
namespace Saga2 {
/* ===================================================================== *
@@ -59,7 +57,6 @@ struct TowerLayer {
int ord;
pPROGRAM_INITIALIZER init;
pPROGRAM_TERMINATOR term;
- configProblem onFail;
};
/* ===================================================================== *
diff --git a/engines/saga2/towerfta.cpp b/engines/saga2/towerfta.cpp
index d000c3e3bc..9bdbd9b492 100644
--- a/engines/saga2/towerfta.cpp
+++ b/engines/saga2/towerfta.cpp
@@ -59,43 +59,43 @@ namespace Saga2 {
int maxInitState = fullyInitialized;
TowerLayer tower[fullyInitialized] = {
- { nothingInitialized, &initTowerBase, &termTowerBase, cpInternal },
- { errHandlersInitialized, &initErrorManagers, &termErrorManagers, cpInternal },
- { delayedErrInitialized, &initDelayedErrors, &termDelayedErrors, cpInternal },
- { activeErrInitialized, &initActiveErrors, &termActiveErrors, cpInternal },
- { messagersInitialized, &initSysMessagers, &termSysMessagers, cpInternal },
- { errLoggersInitialized, &initErrorLoggers, &termErrorLoggers, cpInternal },
- { breakHandlerInitialized, &initCtlBreakTrap, &termCtlBreakTrap, cpInternal },
- { configTestInitialized, &initSystemConfig, &termTowerBase, cpInternal },
- { memoryInitialized, &initMemPool, &termMemPool, cpInsufVirtMemFree },
- { graphicsSystemInitialized, &initGraphicsSystem, &termGraphicsSystem, cpDDrawInitFail },
- { videoInitialized, &initVideoPlayer, &termVideoPlayer, cpInternal },
- { introInitialized, &initPlayIntro, &termPlayOutro, cpInternal },
- { timerInitialized, &initSystemTimer, &termSystemTimer, cpDTimerInitFail },
- { resourcesInitialized, &initResourceFiles, &termResourceFiles, cpResFileMissing },
- { serversInitialized, &initResourceServers, &termResourceServers, cpInternal },
- { pathFinderInitialized, &initPathFinders, &termPathFinders, cpInternal },
- { scriptsInitialized, &initSAGAInterpreter, &termSAGAInterpreter, cpInternal },
- { audStartInitialized, &initAudioChannels, &termAudioChannels, cpInternal },
- { tileResInitialized, &initResourceHandles, &termResourceHandles, cpInternal },
- { palettesInitialized, &initPalettes, &termPalettes, cpInternal },
- { mainWindowInitialized, &initDisplayPort, &termDisplayPort, cpInternal },
- { panelsInitialized, &initPanelSystem, &termPanelSystem, cpInternal },
- { mainWindowOpenInitialized, &initMainWindow, &termMainWindow, cpInternal },
- { guiMessInitialized, &initGUIMessagers, &termGUIMessagers, cpInternal },
- { mouseImageInitialized, &initMousePointer, &termMousePointer, cpNoMouseDriver },
- { displayInitialized, &initDisplay, &termDisplay, cpInternal },
- { mapsInitialized, &initGameMaps, &termGameMaps, cpInternal },
- { patrolsInitialized, &initRouteData, &termRouteData, cpInternal },
- { spritesInitialized, &initActorSprites, &termActorSprites, cpInternal },
- { weaponsInitialized, &initWeaponData, &termWeaponData, cpInternal },
- { magicInitialized, &initSpellData, &termSpellData, cpInternal },
- { objectSoundFXInitialized, &initObjectSoundFX, &termObjectSoundFX, cpInternal },
- { prototypesInitialized, &initObjectPrototypes, &termObjectPrototypes, cpInternal },
- { gameStateInitialized, &initDynamicGameData, &termDynamicGameData, cpInternal },
- { gameModeInitialized, &initGameMode, &termGameMode, cpInternal },
- { gameDisplayEnabled, &initTop, &termTop, cpInternal },
- { procResEnabled, &initProcessResources, &termProcessResources, cpInternal },
+ { nothingInitialized, &initTowerBase, &termTowerBase },
+ { errHandlersInitialized, &initErrorManagers, &termErrorManagers },
+ { delayedErrInitialized, &initDelayedErrors, &termDelayedErrors },
+ { activeErrInitialized, &initActiveErrors, &termActiveErrors },
+ { messagersInitialized, &initSysMessagers, &termSysMessagers },
+ { errLoggersInitialized, &initErrorLoggers, &termErrorLoggers },
+ { breakHandlerInitialized, &initCtlBreakTrap, &termCtlBreakTrap },
+ { configTestInitialized, &initSystemConfig, &termTowerBase },
+ { memoryInitialized, &initMemPool, &termMemPool },
+ { graphicsSystemInitialized, &initGraphicsSystem, &termGraphicsSystem },
+ { videoInitialized, &initVideoPlayer, &termVideoPlayer },
+ { introInitialized, &initPlayIntro, &termPlayOutro },
+ { timerInitialized, &initSystemTimer, &termSystemTimer },
+ { resourcesInitialized, &initResourceFiles, &termResourceFiles },
+ { serversInitialized, &initResourceServers, &termResourceServers },
+ { pathFinderInitialized, &initPathFinders, &termPathFinders },
+ { scriptsInitialized, &initSAGAInterpreter, &termSAGAInterpreter },
+ { audStartInitialized, &initAudioChannels, &termAudioChannels },
+ { tileResInitialized, &initResourceHandles, &termResourceHandles },
+ { palettesInitialized, &initPalettes, &termPalettes },
+ { mainWindowInitialized, &initDisplayPort, &termDisplayPort },
+ { panelsInitialized, &initPanelSystem, &termPanelSystem },
+ { mainWindowOpenInitialized, &initMainWindow, &termMainWindow },
+ { guiMessInitialized, &initGUIMessagers, &termGUIMessagers },
+ { mouseImageInitialized, &initMousePointer, &termMousePointer },
+ { displayInitialized, &initDisplay, &termDisplay },
+ { mapsInitialized, &initGameMaps, &termGameMaps },
+ { patrolsInitialized, &initRouteData, &termRouteData },
+ { spritesInitialized, &initActorSprites, &termActorSprites },
+ { weaponsInitialized, &initWeaponData, &termWeaponData },
+ { magicInitialized, &initSpellData, &termSpellData },
+ { objectSoundFXInitialized, &initObjectSoundFX, &termObjectSoundFX },
+ { prototypesInitialized, &initObjectPrototypes, &termObjectPrototypes },
+ { gameStateInitialized, &initDynamicGameData, &termDynamicGameData },
+ { gameModeInitialized, &initGameMode, &termGameMode },
+ { gameDisplayEnabled, &initTop, &termTop },
+ { procResEnabled, &initProcessResources, &termProcessResources }
};
/* ===================================================================== *
diff --git a/engines/saga2/tromode.cpp b/engines/saga2/tromode.cpp
index ce25a6f7c8..0a36cbb998 100644
--- a/engines/saga2/tromode.cpp
+++ b/engines/saga2/tromode.cpp
@@ -34,7 +34,6 @@
#include "saga2/videos.h"
#include "saga2/player.h"
#include "saga2/tromode.h"
-#include "saga2/nice_err.h"
#include "saga2/messager.h"
#include "saga2/config.h"
#include "saga2/display.h"
@@ -249,10 +248,6 @@ void waitForVideoFile(char *fileName) { // file name & extension
fe = fileExists(filespec);
- while (!fe && retryConfigError(cpVidDiskMissing, "Trying to open a video")) {
- fe = fileExists(filespec);
- }
-
if (!fe) {
abortFlag = TRUE;
return;
diff --git a/engines/saga2/verify.cpp b/engines/saga2/verify.cpp
index 1b814fc68f..a3bdff821f 100644
--- a/engines/saga2/verify.cpp
+++ b/engines/saga2/verify.cpp
@@ -27,7 +27,6 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
-#include "saga2/errclass.h"
namespace Saga2 {
diff --git a/engines/saga2/video.h b/engines/saga2/video.h
index 0e23628c37..9ed6cfe5f6 100644
--- a/engines/saga2/video.h
+++ b/engines/saga2/video.h
@@ -37,8 +37,6 @@
#define USE_MOV 0
-#include "saga2/errclass.h"
-
namespace Saga2 {
typedef int HDIGDRIVER;
diff --git a/engines/saga2/vwpage.cpp b/engines/saga2/vwpage.cpp
index a148899684..db8533065b 100644
--- a/engines/saga2/vwpage.cpp
+++ b/engines/saga2/vwpage.cpp
@@ -29,7 +29,6 @@
#include "saga2/std.h"
#include "saga2/vwpage.h"
#include "saga2/display.h"
-#include "saga2/errclass.h"
namespace Saga2 {
Commit: a9da39baed071e77362ff0cd67deb99c5f14e97a
https://github.com/scummvm/scummvm/commit/a9da39baed071e77362ff0cd67deb99c5f14e97a
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:47+02:00
Commit Message:
SAGA2: Change debug message in unpackImage
Changed paths:
engines/saga2/blitters.cpp
diff --git a/engines/saga2/blitters.cpp b/engines/saga2/blitters.cpp
index fb3512298c..214e5f2594 100644
--- a/engines/saga2/blitters.cpp
+++ b/engines/saga2/blitters.cpp
@@ -470,9 +470,9 @@ void unpackImage(gPixelMap *map, int32 width, int32 rowCount, int8 *srcData) {
compressedBuffer[i] = srcData[i];
if (!decodeBGImage(compressedBuffer, outputBuffer, w, h, false)) {
- error("Could not unpack sprite");
+ error("Could not unpack image");
}
- debugC(kDebugResources, "hello");
+ debugC(kDebugResources, "Successfully unpacked image: w:%d, h:%d", *w, *h);
map->data = outputBuffer.getBuffer();
}
Commit: e9e3313adad3923aa1356a0993cc9dcb56d5c84c
https://github.com/scummvm/scummvm/commit/e9e3313adad3923aa1356a0993cc9dcb56d5c84c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:47+02:00
Commit Message:
SAGA2: Cleanup and removing unused files
Changed paths:
R engines/saga2/audiotmr.cpp
R engines/saga2/audiotmr.h
engines/saga2/arrowptr.cpp
engines/saga2/audio.cpp
engines/saga2/audio.h
engines/saga2/audiobuf.cpp
engines/saga2/audiobuf.h
engines/saga2/module.mk
diff --git a/engines/saga2/arrowptr.cpp b/engines/saga2/arrowptr.cpp
index 0794c7f97d..6d3cf64a03 100644
--- a/engines/saga2/arrowptr.cpp
+++ b/engines/saga2/arrowptr.cpp
@@ -30,8 +30,6 @@
Converted by iff2c.
* ===================================================================== */
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/gdraw.h"
diff --git a/engines/saga2/audio.cpp b/engines/saga2/audio.cpp
index 5482d935fd..e836f8386a 100644
--- a/engines/saga2/audio.cpp
+++ b/engines/saga2/audio.cpp
@@ -24,8 +24,6 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/audio.h"
diff --git a/engines/saga2/audio.h b/engines/saga2/audio.h
index a7c6d4a985..82aaa0b6cc 100644
--- a/engines/saga2/audio.h
+++ b/engines/saga2/audio.h
@@ -78,7 +78,6 @@ inline void audioFatal(char *msg) {
}
#include "saga2/rect.h"
-#include "saga2/audiotmr.h"
#include "saga2/audiomem.h"
#include "saga2/queues.h"
#include "saga2/audiobuf.h"
diff --git a/engines/saga2/audiobuf.cpp b/engines/saga2/audiobuf.cpp
index c313826a22..fbdb1b6b5a 100644
--- a/engines/saga2/audiobuf.cpp
+++ b/engines/saga2/audiobuf.cpp
@@ -602,13 +602,13 @@ void cacheBuffer::fill(void) {
/* */
/* When a buffer is no longer needed this call resets it. */
-void Buffer::abort(void) {
+void Buffer::abortsound(void) {
}
void Buffer::release(void) {
}
-void workBuffer::abort(void) {
+void workBuffer::abortsound(void) {
if (rSize)
took(rSize);
release();
@@ -617,7 +617,7 @@ void workBuffer::abort(void) {
void workBuffer::release(void) {
}
-void doubleBuffer::abort(void) {
+void doubleBuffer::abortsound(void) {
if (rSize)
took(rSize);
release();
@@ -642,7 +642,7 @@ void doubleBuffer::release(void) {
VERIFY(AILLOCated == -1);
}
-void singleBuffer::abort(void) {
+void singleBuffer::abortsound(void) {
AIL_end_sample(ailSampleHandle);
if (rSize)
took(rSize);
@@ -657,7 +657,7 @@ void singleBuffer::release(void) {
VERIFY(AILLOCated == -1);
}
-void musicBuffer::abort(void) {
+void musicBuffer::abortsound(void) {
if (rSize)
took(rSize);
release();
@@ -670,7 +670,7 @@ void musicBuffer::release(void) {
audioSet = 0;
}
-void cacheBuffer::abort(void) {
+void cacheBuffer::abortsound(void) {
}
void cacheBuffer::release(void) {
diff --git a/engines/saga2/audiobuf.h b/engines/saga2/audiobuf.h
index 7d9c401f0c..2c531abeef 100644
--- a/engines/saga2/audiobuf.h
+++ b/engines/saga2/audiobuf.h
@@ -100,7 +100,7 @@ public:
virtual void gave(size_t dSize); // notify amount written
virtual void took(size_t dSize); // notify amount read
virtual void fill(void); // convince buffer it is full
- virtual void abort(void); // kill sound & return buffer to its heap
+ virtual void abortsound(void); // kill sound & return buffer to its heap
virtual void release(void); // return buffer to its heap
virtual void setVolume(int8 val); // internal : set buffer to fill & play
@@ -140,7 +140,7 @@ public:
void gave(size_t dSize); // notify amount written
void took(size_t dSize); // notify amount read
void fill(void); // convince buffer it is full
- void abort(void); // kill sound & return buffer to its heap
+ void abortsound(void); // kill sound & return buffer to its heap
void release(void); // return buffer to its heap
void setVolume(int8 val); // internal : set buffer to fill & play
@@ -169,7 +169,7 @@ public:
int16 ID(void) {
return bufID; // for buffer Manager
}
- void abort(void); // abort playback
+ void abortsound(void); // abort playback
doubleBuffer(size_t newSize, audioInterface *sd, int16 newID);
~doubleBuffer(void);
@@ -235,7 +235,7 @@ public:
void took(size_t dSize); // notify amount read
void fill(void); // convince buffer it is full
void replay(void); // kill sound & return buffer to its heap
- void abort(void); // kill sound & return buffer to its heap
+ void abortsound(void); // kill sound & return buffer to its heap
void release(void); // return buffer to its heap
void setVolume(int8 val); // internal : set buffer to fill & play
@@ -287,7 +287,7 @@ public:
void gave(size_t dSize); // notify amount written
void took(size_t dSize); // notify amount read
void fill(void); // convince buffer it is full
- void abort(void); // kill sound & return buffer to its heap
+ void abortsound(void); // kill sound & return buffer to its heap
void release(void); // return buffer to its heap
void setVolume(int8 val); // internal : set buffer to fill & play
@@ -336,7 +336,7 @@ public:
void gave(size_t dSize); // notify amount written
void took(size_t dSize); // notify amount read
void fill(void); // convince buffer it is full
- void abort(void); // kill sound & return buffer to its heap
+ void abortsound(void); // kill sound & return buffer to its heap
void release(void); // return buffer to its heap
void setVolume(int8 val); // internal : set buffer to fill & play
diff --git a/engines/saga2/audiotmr.cpp b/engines/saga2/audiotmr.cpp
deleted file mode 100644
index 4ffcec8e76..0000000000
--- a/engines/saga2/audiotmr.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
-#include "saga2/std.h"
-#include "saga2/audio.h"
-
-namespace Saga2 {
-
-volatile int32 bufferState;
-
-#ifdef __WATCOMC__
-#pragma off ( check_stack )
-#endif
-
-#if !defined(_WIN32) || defined(USE_REAL_WAIL)
-TIMERFUNCTION(timerHookFunc) {
-// if ( suspendCalls==0 )
- gameTime++;
-}
-
-
-TIMERFUNCTION(EOB_callback) {
- bufferState++;
-}
-
-#endif
-
-} // end of namespace Saga2
diff --git a/engines/saga2/audiotmr.h b/engines/saga2/audiotmr.h
deleted file mode 100644
index 6c20620288..0000000000
--- a/engines/saga2/audiotmr.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#ifndef SAGA2_AUDIOTMR_H
-#define SAGA2_AUDIOTMR_H
-
-namespace Saga2 {
-
-#define TICKSPERSECOND ( 728L/10L )
-
-#define TIMERFUNCTION(name) void name( uint32 user )
-
-/* ===================================================================== *
- Global game time
- * ===================================================================== */
-
-extern volatile int32 gameTime;
-
-TIMERFUNCTION(timerHookFunc);
-
-} // end of namespace Saga2
-
-#endif
diff --git a/engines/saga2/module.mk b/engines/saga2/module.mk
index dc44bdc89d..74c2215423 100644
--- a/engines/saga2/module.mk
+++ b/engines/saga2/module.mk
@@ -7,7 +7,6 @@ MODULE_OBJS := \
audio.o \
audiobuf.o \
audiores.o \
- audiotmr.o \
automap.o \
band.o \
beegee.o \
Commit: 863adf7918e5b026f81f8ae793642c494e741c8c
https://github.com/scummvm/scummvm/commit/863adf7918e5b026f81f8ae793642c494e741c8c
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:47+02:00
Commit Message:
SAGA2: Replace image unpack routines with original
Changed paths:
engines/saga2/blitters.cpp
engines/saga2/blitters.h
diff --git a/engines/saga2/blitters.cpp b/engines/saga2/blitters.cpp
index 214e5f2594..9f8f044637 100644
--- a/engines/saga2/blitters.cpp
+++ b/engines/saga2/blitters.cpp
@@ -28,420 +28,10 @@
#include "saga2/std.h"
#include "saga2/saga2.h"
-#include "common/memstream.h"
#include "common/debug.h"
namespace Saga2 {
-class ByteArray : public Common::Array<byte> {
-public:
- /**
- * Return a pointer to the start of the buffer underlying this byte array,
- * or NULL if the buffer is empty.
- */
- byte *getBuffer() {
- return empty() ? NULL : &front();
- }
-
- const byte *getBuffer() const {
- return empty() ? NULL : &front();
- }
-
- void assign(const ByteArray &src) {
- resize(src.size());
- if (!empty()) {
- memcpy(&front(), &src.front(), size());
- }
- }
-};
-
-typedef struct {
- int width;
- int height;
-} ImgHeader;
-
-static int granulate(int value, int granularity) {
- int remainder;
-
- if (value == 0)
- return 0;
-
- if (granularity == 0)
- return 0;
-
- remainder = value % granularity;
-
- if (remainder == 0) {
- return value;
- } else {
- return (granularity - remainder + value);
- }
-}
-
-bool decodeBGImage(ByteArray imageData, ByteArray outputBuffer, int *w, int *h, bool flip);
-bool decodeBGImageRLE(const byte *inbuf, size_t inbuf_len, ByteArray &outbuf);
-void flipImage(byte *imageBuffer, int columns, int scanlines);
-void unbankBGImage(byte *dst_buf, const byte *src_buf, int columns, int scanlines);
-
-bool decodeBGImage(ByteArray imageData, ByteArray outputBuffer, int *w, int *h, bool flip) {
- ImgHeader hdr;
- int modex_height;
- const byte *RLE_data_ptr;
- size_t RLE_data_len;
- ByteArray decodeBuffer;
-
- const int32 SAGA_IMAGE_DATA_OFFSET = 776;
-
- if (imageData.size() <= SAGA_IMAGE_DATA_OFFSET) {
- error("decodeBGImage() Image size is way too small (%d)", (int)imageData.size());
- }
-
- Common::MemoryReadStream readS(imageData.getBuffer(), imageData.size());
-
- hdr.width = readS.readUint16LE();
- hdr.height = readS.readUint16LE();
- // The next four bytes of the image header aren't used.
- readS.readUint16LE();
- readS.readUint16LE();
-
- RLE_data_ptr = &imageData.front() + SAGA_IMAGE_DATA_OFFSET;
- RLE_data_len = imageData.size() - SAGA_IMAGE_DATA_OFFSET;
-
- modex_height = granulate(hdr.height, 4);
-
- decodeBuffer.resize(hdr.width * modex_height);
-
- outputBuffer.resize(hdr.width * hdr.height);
-
- if (!decodeBGImageRLE(RLE_data_ptr, RLE_data_len, decodeBuffer)) {
- return false;
- }
-
- unbankBGImage(outputBuffer.getBuffer(), decodeBuffer.getBuffer(), hdr.width, hdr.height);
-
- *w = hdr.width;
- *h = hdr.height;
-
- return true;
-}
-
-bool decodeBGImageRLE(const byte *inbuf, size_t inbuf_len, ByteArray &outbuf) {
- const byte *inbuf_ptr;
- byte *outbuf_ptr;
- byte *outbuf_start;
- uint32 inbuf_remain;
-
- const byte *inbuf_end;
- byte *outbuf_end;
- uint32 outbuf_remain;
-
- byte mark_byte;
- int test_byte;
-
- uint32 runcount;
-
- byte bitfield;
- byte bitfield_byte1;
- byte bitfield_byte2;
-
- byte *backtrack_ptr;
- int backtrack_amount;
-
- uint16 c, b;
-
- int decode_err = 0;
-
- inbuf_ptr = inbuf;
- inbuf_remain = inbuf_len;
-
- outbuf_start = outbuf_ptr = outbuf.getBuffer();
- outbuf_remain = outbuf.size();
- outbuf_end = (outbuf_start + outbuf_remain) - 1;
- memset(outbuf_start, 0, outbuf_remain);
-
- inbuf_end = (inbuf + inbuf_len) - 1;
-
-
- while ((inbuf_remain > 1) && (outbuf_remain > 0) && !decode_err) {
-
- if ((inbuf_ptr > inbuf_end) || (outbuf_ptr > outbuf_end)) {
- return false;
- }
-
- mark_byte = *inbuf_ptr++;
- inbuf_remain--;
-
- test_byte = mark_byte & 0xC0; // Mask all but two high order bits
-
- switch (test_byte) {
- case 0xC0: // 1100 0000
- // Uncompressed run follows: Max runlength 63
- runcount = mark_byte & 0x3f;
- if ((inbuf_remain < runcount) || (outbuf_remain < runcount)) {
- return false;
- }
-
- for (c = 0; c < runcount; c++) {
- *outbuf_ptr++ = *inbuf_ptr++;
- }
-
- inbuf_remain -= runcount;
- outbuf_remain -= runcount;
- continue;
- break;
- case 0x80: // 1000 0000
- // Compressed run follows: Max runlength 63
- runcount = (mark_byte & 0x3f) + 3;
- if (!inbuf_remain || (outbuf_remain < runcount)) {
- return false;
- }
-
- for (c = 0; c < runcount; c++) {
- *outbuf_ptr++ = *inbuf_ptr;
- }
-
- inbuf_ptr++;
- inbuf_remain--;
- outbuf_remain -= runcount;
- continue;
-
- break;
-
- case 0x40: // 0100 0000
- // Repeat decoded sequence from output stream:
- // Max runlength 10
-
- runcount = ((mark_byte >> 3) & 0x07U) + 3;
- backtrack_amount = *inbuf_ptr;
-
- if (!inbuf_remain || (backtrack_amount > (outbuf_ptr - outbuf_start)) || (runcount > outbuf_remain)) {
- return false;
- }
-
- inbuf_ptr++;
- inbuf_remain--;
-
- backtrack_ptr = outbuf_ptr - backtrack_amount;
-
- for (c = 0; c < runcount; c++) {
- *outbuf_ptr++ = *backtrack_ptr++;
- }
-
- outbuf_remain -= runcount;
- continue;
- break;
- default: // 0000 0000
- break;
- }
-
- // Mask all but the third and fourth highest order bits
- test_byte = mark_byte & 0x30;
-
- switch (test_byte) {
-
- case 0x30: // 0011 0000
- // Bitfield compression
- runcount = (mark_byte & 0x0F) + 1;
-
- if ((inbuf_remain < (runcount + 2)) || (outbuf_remain < (runcount * 8))) {
- return false;
- }
-
- bitfield_byte1 = *inbuf_ptr++;
- bitfield_byte2 = *inbuf_ptr++;
-
- for (c = 0; c < runcount; c++) {
- bitfield = *inbuf_ptr;
- for (b = 0; b < 8; b++) {
- if (bitfield & 0x80) {
- *outbuf_ptr = bitfield_byte2;
- } else {
- *outbuf_ptr = bitfield_byte1;
- }
- bitfield <<= 1;
- outbuf_ptr++;
- }
- inbuf_ptr++;
- }
-
- inbuf_remain -= (runcount + 2);
- outbuf_remain -= (runcount * 8);
- continue;
- break;
- case 0x20: // 0010 0000
- // Uncompressed run follows
- runcount = ((mark_byte & 0x0F) << 8) + *inbuf_ptr;
- if ((inbuf_remain < (runcount + 1)) || (outbuf_remain < runcount)) {
- return false;
- }
-
- inbuf_ptr++;
-
- for (c = 0; c < runcount; c++) {
- *outbuf_ptr++ = *inbuf_ptr++;
- }
-
- inbuf_remain -= (runcount + 1);
- outbuf_remain -= runcount;
- continue;
-
- break;
-
- case 0x10: // 0001 0000
- // Repeat decoded sequence from output stream
- backtrack_amount = ((mark_byte & 0x0F) << 8) + *inbuf_ptr;
- if (inbuf_remain < 2) {
- return false;
- }
-
- inbuf_ptr++;
- runcount = *inbuf_ptr++;
-
- if ((backtrack_amount > (outbuf_ptr - outbuf_start)) || (outbuf_remain < runcount)) {
- return false;
- }
-
- backtrack_ptr = outbuf_ptr - backtrack_amount;
-
- for (c = 0; c < runcount; c++) {
- *outbuf_ptr++ = *backtrack_ptr++;
- }
-
- inbuf_remain -= 2;
- outbuf_remain -= runcount;
- continue;
- break;
- default:
- return false;
- }
- }
-
- return true;
-}
-
-void flipImage(byte *imageBuffer, int columns, int scanlines) {
- int line;
- ByteArray tmp_scan;
-
- byte *flip_p1;
- byte *flip_p2;
- byte *flip_tmp;
-
- int flipcount = scanlines / 2;
-
- tmp_scan.resize(columns);
- flip_tmp = tmp_scan.getBuffer();
- if (flip_tmp == NULL) {
- return;
- }
-
- flip_p1 = imageBuffer;
- flip_p2 = imageBuffer + (columns * (scanlines - 1));
-
- for (line = 0; line < flipcount; line++) {
- memcpy(flip_tmp, flip_p1, columns);
- memcpy(flip_p1, flip_p2, columns);
- memcpy(flip_p2, flip_tmp, columns);
- flip_p1 += columns;
- flip_p2 -= columns;
- }
-}
-
-void unbankBGImage(byte *dst_buf, const byte *src_buf, int columns, int scanlines) {
- int x, y;
- int temp;
- int quadruple_rows;
- int remain_rows;
- int rowjump_src;
- int rowjump_dest;
- const byte *src_p;
- const byte *srcptr1, *srcptr2, *srcptr3, *srcptr4;
- byte *dstptr1, *dstptr2, *dstptr3, *dstptr4;
-
- quadruple_rows = scanlines - (scanlines % 4);
- remain_rows = scanlines - quadruple_rows;
-
- assert(scanlines > 0);
-
- src_p = src_buf;
-
- srcptr1 = src_p;
- srcptr2 = src_p + 1;
- srcptr3 = src_p + 2;
- srcptr4 = src_p + 3;
-
- dstptr1 = dst_buf;
- dstptr2 = dst_buf + columns;
- dstptr3 = dst_buf + columns * 2;
- dstptr4 = dst_buf + columns * 3;
-
- rowjump_src = columns * 4;
- rowjump_dest = columns * 4;
-
- // Unbank groups of 4 first
- for (y = 0; y < quadruple_rows; y += 4) {
- for (x = 0; x < columns; x++) {
- temp = x * 4;
- dstptr1[x] = srcptr1[temp];
- dstptr2[x] = srcptr2[temp];
- dstptr3[x] = srcptr3[temp];
- dstptr4[x] = srcptr4[temp];
- }
-
- // This is to avoid generating invalid pointers -
- // usually innocuous, but undefined
- if (y < quadruple_rows - 4) {
- dstptr1 += rowjump_dest;
- dstptr2 += rowjump_dest;
- dstptr3 += rowjump_dest;
- dstptr4 += rowjump_dest;
- srcptr1 += rowjump_src;
- srcptr2 += rowjump_src;
- srcptr3 += rowjump_src;
- srcptr4 += rowjump_src;
- }
- }
-
- // Unbank rows remaining
- switch (remain_rows) {
- case 1:
- dstptr1 += rowjump_dest;
- srcptr1 += rowjump_src;
- for (x = 0; x < columns; x++) {
- temp = x * 4;
- dstptr1[x] = srcptr1[temp];
- }
- break;
- case 2:
- dstptr1 += rowjump_dest;
- dstptr2 += rowjump_dest;
- srcptr1 += rowjump_src;
- srcptr2 += rowjump_src;
- for (x = 0; x < columns; x++) {
- temp = x * 4;
- dstptr1[x] = srcptr1[temp];
- dstptr2[x] = srcptr2[temp];
- }
- break;
- case 3:
- dstptr1 += rowjump_dest;
- dstptr2 += rowjump_dest;
- dstptr3 += rowjump_dest;
- srcptr1 += rowjump_src;
- srcptr2 += rowjump_src;
- srcptr3 += rowjump_src;
- for (x = 0; x < columns; x++) {
- temp = x * 4;
- dstptr1[x] = srcptr1[temp];
- dstptr2[x] = srcptr2[temp];
- dstptr3[x] = srcptr3[temp];
- }
- break;
- default:
- break;
- }
-}
-
void _BltPixels(uint8 *srcPtr, uint32 srcMod, uint8 *dstPtr, uint32 dstMod, uint32 width, uint32 height) {
warning("STUB: _BltPixels()");
}
@@ -458,22 +48,40 @@ void _HLine(uint8 *dstPtr, uint32 width, uint32 color) {
warning("STUB: _HLine()");
}
-void unpackImage(gPixelMap *map, int32 width, int32 rowCount, int8 *srcData) {
- warning("STUB: unpackImage()");
- ByteArray compressedBuffer;
- ByteArray outputBuffer;
- int *w = nullptr;
- int *h = nullptr;
+void unpackImage(gPixelMap &map, int16 width, int16 rowCount, int8 *srcData) {
+ int8 *dest = (int8 *)map.data;
+ int16 bytecount = (width + 1) & ~1;
+ int16 rowMod = map.size.x - bytecount;
+
+ while (rowCount--)
+ {
+ for (int16 k = 0; k < bytecount;)
+ {
+ int16 p = *srcData++;
- compressedBuffer.resize(map->bytes());
- for (int i = 0; i < map->bytes(); ++i)
- compressedBuffer[i] = srcData[i];
+ if (p == -128) ;
+ else if (p >= 0)
+ {
+ p++;
+ k += p;
+ while (p--) *dest++ = *srcData++;
+ }
+ else
+ {
+ p = 1 - p;
+ k += p;
+ while (p--) *dest++ = *srcData;
+ srcData++;
+ }
+ }
- if (!decodeBGImage(compressedBuffer, outputBuffer, w, h, false)) {
- error("Could not unpack image");
+ if (bytecount & 1) srcData++;
+ dest += rowMod;
}
- debugC(kDebugResources, "Successfully unpacked image: w:%d, h:%d", *w, *h);
- map->data = outputBuffer.getBuffer();
+}
+
+void unpackImage(gPixelMap *map, int32 width, int32 rowCount, int8 *srcData) {
+ unpackImage(*map, (int16)width, (int16)rowCount, srcData);
}
void unpackSprite(gPixelMap *map, uint8 *sprData) {
diff --git a/engines/saga2/blitters.h b/engines/saga2/blitters.h
index b9eba6d278..72e6370ecf 100644
--- a/engines/saga2/blitters.h
+++ b/engines/saga2/blitters.h
@@ -66,6 +66,10 @@ void unpackImage(gPixelMap *map,
int32 rowCount,
int8 *srcData);
+void unpackImage(gPixelMap &map,
+ int16 width,
+ int16 rowCount,
+ int8 *srcData);
/* ===================================================================== *
SPRDRAW.ASM
* ===================================================================== */
Commit: b8ab6203e455184c53bca3ad93ae8da9574d43e6
https://github.com/scummvm/scummvm/commit/b8ab6203e455184c53bca3ad93ae8da9574d43e6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:47+02:00
Commit Message:
SAGA2: Rename abort() methods
Changed paths:
engines/saga2/actor.cpp
engines/saga2/actor.h
engines/saga2/assign.cpp
engines/saga2/gdraw.cpp
engines/saga2/gdraw.h
engines/saga2/player.cpp
engines/saga2/task.cpp
engines/saga2/task.h
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index e4512cf3ef..03454df76e 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -1368,7 +1368,7 @@ void Actor::deleteActor(void) {
// Kill task
if (curTask != NULL) {
- curTask->abort();
+ curTask->abortTask();
delete curTask;
curTask = NULL;
}
@@ -1432,7 +1432,7 @@ void Actor::die(void) {
// Kill task
if (curTask != NULL) {
- curTask->abort();
+ curTask->abortTask();
delete curTask;
curTask = NULL;
}
@@ -1533,7 +1533,7 @@ void Actor::deactivateActor(void) {
#endif
// Kill task
if (curTask != NULL) {
- curTask->abort();
+ curTask->abortTask();
delete curTask;
curTask = NULL;
}
@@ -1588,7 +1588,7 @@ void Actor::lobotomize(void) {
// Kill task
if (curTask != NULL) {
- curTask->abort();
+ curTask->abortTask();
delete curTask;
curTask = NULL;
}
@@ -2275,7 +2275,7 @@ bool Actor::SetAvailableAction(int16 flags, ...) {
void Actor::setGoal(uint8 newGoal) {
if (currentGoal != newGoal) {
if (curTask != NULL) {
- curTask->abort();
+ curTask->abortTask();
delete curTask;
curTask = NULL;
}
diff --git a/engines/saga2/actor.h b/engines/saga2/actor.h
index 3201d56c15..d260d06b86 100644
--- a/engines/saga2/actor.h
+++ b/engines/saga2/actor.h
@@ -33,14 +33,6 @@
namespace Saga2 {
-#ifdef _WIN32 // Set structure alignment packing value to 1 byte
-#pragma pack( push, 1 )
-#endif
-
-/* ===================================================================== *
- Constants
- * ===================================================================== */
-
class ActorAssignment;
class Band;
class MotionTask;
@@ -138,15 +130,15 @@ struct ActorAttributes {
};
- uint8 allSkills[ numSkills ]; // number of skills
+ uint8 allSkills[numSkills]; // number of skills
};
// Pad byte for alignment
- int8 pad;
+ int8 pad;
// Hit-points
- int16 vitality;
+ int16 vitality;
// Magic energy
union {
@@ -159,14 +151,14 @@ struct ActorAttributes {
violetMana;
};
- int16 allManas[ numManas ];
+ int16 allManas[numManas];
};
uint8 &skill(int16 id) {
- return allSkills[ id ];
+ return allSkills[id];
}
int16 &mana(int16 id) {
- return allManas[ id ];
+ return allManas[id];
}
uint8 getSkillLevel(int16 id) {
@@ -175,8 +167,8 @@ struct ActorAttributes {
}; // 28 bytes
-const int baseCarryingCapacity = 100;
-const int carryingCapacityBonusPerBrawn = 200 / ActorAttributes::skillLevels;
+const int baseCarryingCapacity = 100;
+const int carryingCapacityBonusPerBrawn = 200 / ActorAttributes::skillLevels;
/* ===================================================================== *
ResourceActorProtoExtension structure
@@ -512,13 +504,13 @@ struct ResourceActor : public ResourceGameObject {
rightHandObject; // object held in right hand.
// Knowledge packets
- uint16 knowledge[ 16 ];
+ uint16 knowledge[16];
// Schedule script ID
uint16 schedule;
// Pad bytes
- uint8 reserved[ 18 ];
+ uint8 reserved[18];
};
@@ -561,14 +553,14 @@ public:
rightHandObject; // object held in right hand.
// Knowledge packets
- uint16 knowledge[ 16 ];
+ uint16 knowledge[16];
// Schedule script ID
uint16 schedule;
// Run-time fields
- uint8 conversationMemory[ 4 ];// last things talked about
+ uint8 conversationMemory[4];// last things talked about
// Sprite animation variables
uint8 currentAnimation, // current action sequence
@@ -613,7 +605,7 @@ public:
uint8 deactivationCounter;
// Assignment
- uint8 assignmentBuf[ 24 ]; // memory reserved for actor
+ uint8 assignmentBuf[24]; // memory reserved for actor
// assignments
// Current effective stats
@@ -636,11 +628,11 @@ public:
Actor *leader; // This actor's leader
Band *followers; // This actor's band of followers
- ObjectID armorObjects[ ARMOR_COUNT ]; // armor objects being worn
+ ObjectID armorObjects[ARMOR_COUNT]; // armor objects being worn
GameObject *currentTarget;
- int16 scriptVar[ actorScriptVars ]; // scratch variables for scripter use
+ int16 scriptVar[actorScriptVars]; // scratch variables for scripter use
// Member functions
@@ -1078,58 +1070,6 @@ void loadFactionTallies(SaveFileReader &saveGame);
// Cleanup the faction tally table
inline void cleanupFactionTallies(void) { /* Nothing to do */ }
-/* ============================================================================ *
- Magic: Actor Enchantment bits
- * ============================================================================ */
-
-// These are are all the enchantment effects that can be represented
-// as a single bit.
-
-
-
-// THESE ARE NO LONGER VALID SEE EFFECTS.H
-
-#if 0
-enum enchantmentEffects {
- actorFlamingAura = (1 << 0), // surrounded by damaging aura
- actorImmunePhysical = (1 << 1), // immune to physical weapons
- actorImmuneProjectile = (1 << 2), // immune to projectiles
- actorImmuneHandToHand = (1 << 3), // immune to non-projectiles
- actorImmuneMagicMissile = (1 << 4), // immune to magical projectiles
- actorImmuneFire = (1 << 5), // immune to fire
- actorImmuneFireMagic = (1 << 6), // immune to magical fire
- actorImmuneLava = (1 << 7), // immune to hot terrain
- actorImmuneCold = (1 << 8), // immune to cold
- actorImmuneMental = (1 << 9), // immune to mental attack
- actorImmuneDirectMagic = (1 << 10), // immune to direct magic
- actorImmuneLifeDrain = (1 << 11), // immune to Life Drain
- actorLandWalking = (1 << 12), // can walk on land
- actorDesolidified = (1 << 13), // can walk through walls
- actorFloating = (1 << 14), // actor is floating
- actorFallSlowly = (1 << 15), // protected against falling
- actorLevitating = (1 << 16), // actor is levitating
- actorWaterWalking = (1 << 17), // can walk on water
- actorFlying = (1 << 18), // flying spell
- actorBlind = (1 << 19), // actor is blind
- actorPanic = (1 << 20), // actor runs away from danger
- actorParalyzed = (1 << 21), // actor can not move
- actorMoveFast = (1 << 22), // move faster than normal
- actorMoveSlow = (1 << 23), // move slower than normal
- actorAttackFast = (1 << 24), // attack faster than normal
- actorAttackSlow = (1 << 25), // attack slower than normal
- actorAsleep = (1 << 26), // actor goes to sleep
- actorSoulSight = (1 << 27), // can see invisible
- actorClairvoyant = (1 << 28), // player can scroll view
- actorDetectPoison = (1 << 29), // poison objects highlighted
- actorInvisible = (1 << 30), // no-one can see this actor
- actorHasNoSmell = (1 << 31), // can't be tracked
-};
-#endif
-
-#ifdef _WIN32 // Reset old structure alignment
-#pragma pack( pop )
-#endif
-
} // end of namespace Saga2
#endif
diff --git a/engines/saga2/assign.cpp b/engines/saga2/assign.cpp
index 777060bb5d..20b27af7f6 100644
--- a/engines/saga2/assign.cpp
+++ b/engines/saga2/assign.cpp
@@ -62,7 +62,7 @@ ActorAssignment::~ActorAssignment(void) {
if (a->currentGoal == actorGoalFollowAssignment
&& a->curTask != NULL) {
// If so, abort it
- a->curTask->abort();
+ a->curTask->abortTask();
delete a->curTask;
a->curTask = NULL;
}
diff --git a/engines/saga2/gdraw.cpp b/engines/saga2/gdraw.cpp
index 603ac8cecf..f176ca14d1 100644
--- a/engines/saga2/gdraw.cpp
+++ b/engines/saga2/gdraw.cpp
@@ -24,8 +24,6 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/gdraw.h"
#include "saga2/gblitter.h"
@@ -36,10 +34,6 @@ namespace Saga2 {
#define TempFree free
-/* ===================================================================== *
- Member functions for gPort
- * ===================================================================== */
-
void gPort::setMap(gPixelMap *newmap, bool inverted) {
map = newmap;
clip = Rect16(0, 0, map->size.x, map->size.y);
diff --git a/engines/saga2/gdraw.h b/engines/saga2/gdraw.h
index f5e513539d..90cfa72569 100644
--- a/engines/saga2/gdraw.h
+++ b/engines/saga2/gdraw.h
@@ -189,8 +189,7 @@ public:
// Constructor
gPort(void) {
- memset(&map, 0,
- offsetof(gPort, textStyles) - offsetof(gPort, map) + sizeof(textStyles));
+ memset(&map, 0, sizeof(gPort));
}
virtual ~gPort() {}
@@ -216,8 +215,8 @@ public:
// Indirect colors
- void setPenMap(gPen *map) {
- penMap = map;
+ void setPenMap(gPen *pmap) {
+ penMap = pmap;
}
void setIndirectColor(uint8 color) {
fgPen = penMap[ color ];
diff --git a/engines/saga2/player.cpp b/engines/saga2/player.cpp
index 6adfa1db6c..7944e49143 100644
--- a/engines/saga2/player.cpp
+++ b/engines/saga2/player.cpp
@@ -580,7 +580,7 @@ void setCenterActor(PlayerActorID newCenter) {
setEnchantmentDisplay();
if (a->curTask != NULL) {
- a->curTask->abort();
+ a->curTask->abortTask();
delete a->curTask;
a->curTask = NULL;
}
diff --git a/engines/saga2/task.cpp b/engines/saga2/task.cpp
index f6d3326fc6..0cb4d5f6ab 100644
--- a/engines/saga2/task.cpp
+++ b/engines/saga2/task.cpp
@@ -1261,7 +1261,7 @@ int16 WanderTask::getType(void) const {
//----------------------------------------------------------------------
-void WanderTask::abort(void) {
+void WanderTask::abortTask(void) {
// if the actor has a wander motion, abort it
MotionTask *actorMotion = stack->getActor()->moveTask;
@@ -1316,7 +1316,7 @@ TaskResult WanderTask::handleWander(void) {
void WanderTask::pause(void) {
// Call abort to stop the wandering motion
- abort();
+ abortTask();
paused = TRUE;
counter = (rand() % 64 + rand() % 64) / 2;
@@ -1424,9 +1424,9 @@ int16 TetheredWanderTask::getType(void) const {
//----------------------------------------------------------------------
-void TetheredWanderTask::abort(void) {
+void TetheredWanderTask::abortTask(void) {
if (gotoTether != NULL) {
- gotoTether->abort();
+ gotoTether->abortTask();
delete gotoTether;
gotoTether = NULL;
} else {
@@ -1467,7 +1467,7 @@ TaskResult TetheredWanderTask::handleWander(void) {
}
} else {
if (gotoTether != NULL) {
- gotoTether->abort();
+ gotoTether->abortTask();
delete gotoTether;
gotoTether = NULL;
}
@@ -1590,10 +1590,10 @@ void GotoTask::mark(void) {
//----------------------------------------------------------------------
-void GotoTask::abort(void) {
+void GotoTask::abortTask(void) {
// If there is a wander subtask, delete it.
if (wander) {
- wander->abort();
+ wander->abortTask();
delete wander;
wander = NULL;
} else {
@@ -1608,7 +1608,7 @@ void GotoTask::abort(void) {
TaskResult GotoTask::evaluate(void) {
// Determine if we have reach the target.
if (stack->getActor()->getLocation() == destination()) {
- abort();
+ abortTask();
return taskSucceeded;
}
@@ -2274,9 +2274,9 @@ void GoAwayFromTask::mark(void) {
//----------------------------------------------------------------------
// Abort this task
-void GoAwayFromTask::abort(void) {
+void GoAwayFromTask::abortTask(void) {
if (goTask != NULL) {
- goTask->abort();
+ goTask->abortTask();
delete goTask;
goTask = NULL;
}
@@ -2597,14 +2597,14 @@ void HuntTask::mark(void) {
//----------------------------------------------------------------------
-void HuntTask::abort(void) {
+void HuntTask::abortTask(void) {
if (huntFlags & (huntWander | huntGoto)) {
- subTask->abort();
+ subTask->abortTask();
delete subTask;
}
- // If we've reached the target call the atTargetAbort() function
- if (atTarget()) atTargetAbort();
+ // If we've reached the target call the atTargetabortTask() function
+ if (atTarget()) atTargetabortTask();
}
//----------------------------------------------------------------------
@@ -2680,7 +2680,7 @@ TaskResult HuntTask::update(void) {
//----------------------------------------------------------------------
void HuntTask::removeWanderTask(void) {
- subTask->abort();
+ subTask->abortTask();
delete subTask;
huntFlags &= ~huntWander;
}
@@ -2688,7 +2688,7 @@ void HuntTask::removeWanderTask(void) {
//----------------------------------------------------------------------
void HuntTask::removeGotoTask(void) {
- subTask->abort();
+ subTask->abortTask();
delete subTask;
huntFlags &= ~huntGoto;
}
@@ -2866,7 +2866,7 @@ bool HuntToBeNearLocationTask::atTarget(void) {
//----------------------------------------------------------------------
-void HuntToBeNearLocationTask::atTargetAbort(void) {}
+void HuntToBeNearLocationTask::atTargetabortTask(void) {}
//----------------------------------------------------------------------
@@ -3099,7 +3099,7 @@ bool HuntToBeNearObjectTask::atTarget(void) {
//----------------------------------------------------------------------
-void HuntToBeNearObjectTask::atTargetAbort(void) {}
+void HuntToBeNearObjectTask::atTargetabortTask(void) {}
//----------------------------------------------------------------------
@@ -3238,7 +3238,7 @@ bool HuntToPossessTask::atTarget(void) {
//----------------------------------------------------------------------
-void HuntToPossessTask::atTargetAbort(void) {}
+void HuntToPossessTask::atTargetabortTask(void) {}
//----------------------------------------------------------------------
@@ -3512,7 +3512,7 @@ void HuntToBeNearActorTask::evaluateTarget(void) {
maxSenseRange,
actorArray[ i ])) {
if (currentTarget != actorArray[ i ]) {
- if (atTarget()) atTargetAbort();
+ if (atTarget()) atTargetabortTask();
currentTarget = actorArray[ i ];
}
@@ -3539,7 +3539,7 @@ bool HuntToBeNearActorTask::atTarget(void) {
return TRUE;
else {
if (goAway != NULL) {
- goAway->abort();
+ goAway->abortTask();
delete goAway;
goAway = NULL;
}
@@ -3550,9 +3550,9 @@ bool HuntToBeNearActorTask::atTarget(void) {
//----------------------------------------------------------------------
-void HuntToBeNearActorTask::atTargetAbort(void) {
+void HuntToBeNearActorTask::atTargetabortTask(void) {
if (goAway != NULL) {
- goAway->abort();
+ goAway->abortTask();
delete goAway;
goAway = NULL;
}
@@ -3568,7 +3568,7 @@ TaskResult HuntToBeNearActorTask::atTargetEvaluate(void) {
return taskNotDone;
if (goAway != NULL) {
- goAway->abort();
+ goAway->abortTask();
delete goAway;
goAway = NULL;
}
@@ -3596,7 +3596,7 @@ TaskResult HuntToBeNearActorTask::atTargetUpdate(void) {
// Delete the go away task if it exists
if (goAway != NULL) {
- goAway->abort();
+ goAway->abortTask();
delete goAway;
goAway = NULL;
}
@@ -3689,8 +3689,8 @@ bool HuntToKillTask::operator == (const Task &t) const {
//----------------------------------------------------------------------
-void HuntToKillTask::abort(void) {
- HuntActorTask::abort();
+void HuntToKillTask::abortTask(void) {
+ HuntActorTask::abortTask();
Actor *a = stack->getActor();
@@ -3858,7 +3858,7 @@ void HuntToKillTask::evaluateTarget(void) {
if (bestTarget != currentTarget) {
// If the current target has changed, abort any
// action currently taking place
- if (atTarget()) atTargetAbort();
+ if (atTarget()) atTargetabortTask();
currentTarget = bestTarget;
a->currentTarget = currentTarget;
}
@@ -3883,7 +3883,7 @@ bool HuntToKillTask::atTarget(void) {
//----------------------------------------------------------------------
-void HuntToKillTask::atTargetAbort(void) {
+void HuntToKillTask::atTargetabortTask(void) {
// If the task is aborted while at the target actor, abort any
// attack currently taking place
stack->getActor()->stopAttack(currentTarget);
@@ -4070,7 +4070,7 @@ bool HuntToGiveTask::atTarget(void) {
//----------------------------------------------------------------------
-void HuntToGiveTask::atTargetAbort(void) {}
+void HuntToGiveTask::atTargetabortTask(void) {}
//----------------------------------------------------------------------
@@ -4355,7 +4355,7 @@ bool BandTask::atTarget(void) {
if ((actorLoc - currentTarget).quickHDistance() > 6
|| abs(actorLoc.z - currentTarget.z) > maxStepHeight) {
if (attend != NULL) {
- attend->abort();
+ attend->abortTask();
delete attend;
attend = NULL;
}
@@ -4368,9 +4368,9 @@ bool BandTask::atTarget(void) {
//----------------------------------------------------------------------
-void BandTask::atTargetAbort(void) {
+void BandTask::atTargetabortTask(void) {
if (attend != NULL) {
- attend->abort();
+ attend->abortTask();
delete attend;
attend = NULL;
}
@@ -4641,10 +4641,10 @@ int16 FollowPatrolRouteTask::getType(void) const {
//----------------------------------------------------------------------
-void FollowPatrolRouteTask::abort(void) {
+void FollowPatrolRouteTask::abortTask(void) {
// If there is a subtask, get rid of it
if (gotoWayPoint) {
- gotoWayPoint->abort();
+ gotoWayPoint->abortTask();
delete gotoWayPoint;
gotoWayPoint = NULL;
}
@@ -4693,7 +4693,7 @@ TaskResult FollowPatrolRouteTask::handleFollowPatrolRoute(void) {
&& abs(actorLoc.z - currentWayPoint.z) <= maxStepHeight) {
// Delete the gotoWayPoint task
if (gotoWayPoint != NULL) {
- gotoWayPoint->abort();
+ gotoWayPoint->abortTask();
delete gotoWayPoint;
gotoWayPoint = NULL;
}
@@ -4808,7 +4808,7 @@ int16 AttendTask::getType(void) const {
//----------------------------------------------------------------------
-void AttendTask::abort(void) {
+void AttendTask::abortTask(void) {
MotionTask *actorMotion = stack->getActor()->moveTask;
// Determine if we need to abort the actor motion
@@ -4939,10 +4939,10 @@ int16 DefendTask::getType(void) const {
//----------------------------------------------------------------------
-void DefendTask::abort(void) {
+void DefendTask::abortTask(void) {
// If we have a sub-task, kill it
if (subTask != NULL) {
- subTask->abort();
+ subTask->abortTask();
delete subTask;
subTask = NULL;
}
@@ -5101,7 +5101,7 @@ int16 ParryTask::getType(void) const {
//----------------------------------------------------------------------
-void ParryTask::abort(void) {
+void ParryTask::abortTask(void) {
MotionTask *actorMotion = stack->getActor()->moveTask;
// Kill the defense motion, if there is one
@@ -5261,11 +5261,11 @@ void TaskStack::setTask(Task *t) {
//----------------------------------------------------------------------
// Abort all tasks in stack
-void TaskStack::abort(void) {
+void TaskStack::abortTask(void) {
if (stackBottomID != NoTask) {
Task *stackBottom = getTaskAddress(stackBottomID);
- stackBottom->abort();
+ stackBottom->abortTask();
delete stackBottom;
}
}
diff --git a/engines/saga2/task.h b/engines/saga2/task.h
index 74f71b1d0e..e4eb2c3aec 100644
--- a/engines/saga2/task.h
+++ b/engines/saga2/task.h
@@ -204,7 +204,7 @@ public:
// Return an integer representing the type of this task
virtual int16 getType(void) const = 0;
- virtual void abort(void) = 0;
+ virtual void abortTask(void) = 0;
virtual TaskResult evaluate(void) = 0;
virtual TaskResult update(void) = 0;
@@ -244,7 +244,7 @@ public:
// Return an integer representing the type of this task
int16 getType(void) const;
- void abort();
+ void abortTask();
TaskResult evaluate(void);
TaskResult update(void);
@@ -323,7 +323,7 @@ public:
// Return an integer representing the type of this task
int16 getType(void) const;
- void abort(void);
+ void abortTask(void);
// Determine if the specified task is equivalent to this task
bool operator == (const Task &t) const;
@@ -367,7 +367,7 @@ public:
void mark(void);
#endif
- void abort(void);
+ void abortTask(void);
TaskResult evaluate(void);
TaskResult update(void);
@@ -664,7 +664,7 @@ public:
void mark(void);
#endif
- void abort(void);
+ void abortTask(void);
TaskResult evaluate(void);
TaskResult update(void);
@@ -788,7 +788,7 @@ public:
void mark(void);
#endif
- void abort(void);
+ void abortTask(void);
TaskResult evaluate(void);
TaskResult update(void);
@@ -804,7 +804,7 @@ protected:
virtual TilePoint currentTargetLoc(void) = 0;
virtual bool atTarget(void) = 0;
- virtual void atTargetAbort(void) = 0;
+ virtual void atTargetabortTask(void) = 0;
virtual TaskResult atTargetEvaluate(void) = 0;
virtual TaskResult atTargetUpdate(void) = 0;
};
@@ -887,7 +887,7 @@ protected:
bool atTarget(void);
- void atTargetAbort(void);
+ void atTargetabortTask(void);
TaskResult atTargetEvaluate(void);
TaskResult atTargetUpdate(void);
@@ -978,7 +978,7 @@ protected:
bool atTarget(void);
- void atTargetAbort(void);
+ void atTargetabortTask(void);
TaskResult atTargetEvaluate(void);
TaskResult atTargetUpdate(void);
@@ -1031,7 +1031,7 @@ protected:
void evaluateTarget(void);
bool atTarget(void);
- void atTargetAbort(void);
+ void atTargetabortTask(void);
TaskResult atTargetEvaluate(void);
TaskResult atTargetUpdate(void);
};
@@ -1147,7 +1147,7 @@ protected:
bool atTarget(void);
- void atTargetAbort(void);
+ void atTargetabortTask(void);
TaskResult atTargetEvaluate(void);
TaskResult atTargetUpdate(void);
@@ -1204,14 +1204,14 @@ public:
// Determine if the specified task is equivalent to this task
bool operator == (const Task &t) const;
- void abort(void);
+ void abortTask(void);
TaskResult update(void);
protected:
void evaluateTarget(void);
bool atTarget(void);
- void atTargetAbort(void);
+ void atTargetabortTask(void);
TaskResult atTargetEvaluate(void);
TaskResult atTargetUpdate(void);
@@ -1264,7 +1264,7 @@ protected:
void evaluateTarget(void);
bool atTarget(void);
- void atTargetAbort(void);
+ void atTargetabortTask(void);
TaskResult atTargetEvaluate(void);
TaskResult atTargetUpdate(void);
};
@@ -1399,7 +1399,7 @@ protected:
bool atTarget(void);
- void atTargetAbort(void);
+ void atTargetabortTask(void);
TaskResult atTargetEvaluate(void);
TaskResult atTargetUpdate(void);
@@ -1514,7 +1514,7 @@ public:
// Return an integer representing the type of this task
int16 getType(void) const;
- void abort(void);
+ void abortTask(void);
TaskResult evaluate(void);
TaskResult update(void);
@@ -1560,7 +1560,7 @@ public:
// Return an integer representing the type of this task
int16 getType(void) const;
- void abort(void);
+ void abortTask(void);
TaskResult evaluate(void);
TaskResult update(void);
@@ -1605,7 +1605,7 @@ public:
// Return an integer representing the type of this task
int16 getType(void) const;
- void abort(void);
+ void abortTask(void);
TaskResult evaluate(void);
TaskResult update(void);
@@ -1650,7 +1650,7 @@ public:
// Return an integer representing the type of this task
int16 getType(void) const;
- void abort(void);
+ void abortTask(void);
TaskResult evaluate(void);
TaskResult update(void);
@@ -1732,7 +1732,7 @@ public:
}
// Abort all tasks in stack
- void abort(void);
+ void abortTask(void);
// Re-evaluate tasks in stack
TaskResult evaluate(void);
// Update the state of the tasks in stack
Commit: a531df5354b32cbe85a89b67bf9a4be399f20b3f
https://github.com/scummvm/scummvm/commit/a531df5354b32cbe85a89b67bf9a4be399f20b3f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:47+02:00
Commit Message:
SAGA2: Exposed random source
Changed paths:
engines/saga2/dice.h
engines/saga2/hresmgr.cpp
engines/saga2/saga2.cpp
engines/saga2/saga2.h
engines/saga2/std.h
engines/saga2/task.cpp
diff --git a/engines/saga2/dice.h b/engines/saga2/dice.h
index a3c2aeeaf5..ef02222465 100644
--- a/engines/saga2/dice.h
+++ b/engines/saga2/dice.h
@@ -30,7 +30,7 @@
namespace Saga2 {
inline int32 RANDOM(int32 minV, int32 maxV) {
- return (maxV - minV + 1) ? (rand() % abs(maxV - minV + 1)) + minV : 0;
+ return (maxV - minV + 1) ? g_vm->_rnd->getRandomNumber(abs(maxV - minV)) + minV : 0;
}
inline int32 diceRoll(int dice, int sides, int perDieMod, int base) {
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index bcb80a6c78..1c0e7b1c83 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -124,16 +124,16 @@ hResEntry *hResContext::findEntry(hResID id, RHANDLE **capture) {
_bytepos = 0;
if (!_valid) return nullptr;
- debugC(kDebugResources, "findEntry: looking for %x (%s)", id, tag2str(id));
+ debugC(2, kDebugResources, "findEntry: looking for %x (%s)", id, tag2str(id));
for (i = 0, entry = _base; i < _numEntries; i++, entry++) {
debugC(kDebugResources, "%x: Trying ID: %x (%s)", i, entry->id, tag2str(entry->id));
if (entry->id == id) {
if (capture) *capture = &_data[ i ];
- debugC(kDebugResources, "findEntry: found %x (%s)", entry->id, tag2str(entry->id));
+ debugC(2, kDebugResources, "findEntry: found %x (%s)", entry->id, tag2str(entry->id));
return entry;
}
}
- debugC(kDebugResources, "findEntry: No entry found");
+ debugC(2, kDebugResources, "findEntry: No entry found");
return nullptr;
}
@@ -398,7 +398,7 @@ void hResource::readResource(hResEntry &element) {
element.size = _file.readUint32LE();
uint32 id = element.id;
- debugC(kDebugResources, "%s, offset: %x, size: %d", tag2str(id), element.offset, element.size);
+ debugC(3, kDebugResources, "%s, offset: %x, size: %d", tag2str(id), element.offset, element.size);
}
hResource::hResource(char *resname, char *extname, const char desc[]) {
@@ -413,7 +413,7 @@ hResource::hResource(char *resname, char *extname, const char desc[]) {
strncpy(_externalPath, extname ? extname : "", EXTERNAL_PATH_SIZE);
- debugC(kDebugResources, "Opening resource: %s", resname);
+ debugC(1, kDebugResources, "Opening resource: %s", resname);
_file.open(resname);
readResource(origin);
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index a8ba326b4f..d13eed7bb2 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -45,6 +45,8 @@ void openImageTest();
bool openResources();
void main_saga2();
+Saga2Engine *g_vm;
+
Saga2Engine::Saga2Engine(OSystem *syst)
: Engine(syst) {
const Common::FSNode gameDataDir(ConfMan.get("path"));
@@ -52,6 +54,8 @@ Saga2Engine::Saga2Engine(OSystem *syst)
// Don't forget to register your random source
_rnd = new Common::RandomSource("saga2");
+ g_vm = this;
+
SearchMan.addSubDirectoryMatching(gameDataDir, "res");
debug("Saga2Engine::Saga2Engine");
@@ -73,7 +77,7 @@ Common::Error Saga2Engine::run() {
// Additional setup.
debug("Saga2Engine::init");
- if (openResources()) {
+ if (openResources()) {
openImageTest();
}
diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h
index 9f46d2ff32..7a79fea40b 100644
--- a/engines/saga2/saga2.h
+++ b/engines/saga2/saga2.h
@@ -39,9 +39,6 @@ enum {
};
class Saga2Engine : public Engine {
-private:
- // We need random numbers
- Common::RandomSource *_rnd;
public:
Saga2Engine(OSystem *syst);
~Saga2Engine();
@@ -56,8 +53,14 @@ public:
void loadExeResources();
void freeExeResources();
+
+public:
+ // We need random numbers
+ Common::RandomSource *_rnd;
};
+extern Saga2Engine *g_vm;
+
} // End of namespace Saga2
#endif
diff --git a/engines/saga2/std.h b/engines/saga2/std.h
index f49936fe99..413179d67a 100644
--- a/engines/saga2/std.h
+++ b/engines/saga2/std.h
@@ -30,6 +30,7 @@
#include "common/system.h"
#include "saga2/rmemfta.h"
+#include "saga2/saga2.h"
#define ASSERT assert // FIXME
#define VERIFY assert // FIXME
diff --git a/engines/saga2/task.cpp b/engines/saga2/task.cpp
index 0cb4d5f6ab..d5b000659b 100644
--- a/engines/saga2/task.cpp
+++ b/engines/saga2/task.cpp
@@ -1319,7 +1319,7 @@ void WanderTask::pause(void) {
abortTask();
paused = TRUE;
- counter = (rand() % 64 + rand() % 64) / 2;
+ counter = (g_vm->_rnd->getRandomNumber(63) + g_vm->_rnd->getRandomNumber(63)) / 2;
}
//----------------------------------------------------------------------
@@ -1327,7 +1327,7 @@ void WanderTask::pause(void) {
void WanderTask::wander(void) {
paused = FALSE;
- counter = (rand() % 256 + rand() % 256) / 2;
+ counter = (g_vm->_rnd->getRandomNumber(255) + g_vm->_rnd->getRandomNumber(255)) / 2;
}
/* ===================================================================== *
@@ -3904,7 +3904,7 @@ TaskResult HuntToKillTask::atTargetUpdate(void) {
Actor *a = stack->getActor();
// If we're ready to attack, attack
- if (a->isInterruptable() && (rand() & 0x7) == 0) {
+ if (a->isInterruptable() && g_vm->_rnd->getRandomNumber(6) == 0) {
a->attack(currentTarget);
flags |= evalWeapon;
}
@@ -4711,7 +4711,7 @@ TaskResult FollowPatrolRouteTask::handleFollowPatrolRoute(void) {
// We are at a way point so randomly determine if we should
// pause for a while.
- if (rand() % 4 == 0) {
+ if (g_vm->_rnd->getRandomNumber(3) == 0) {
pause();
return taskNotDone;
}
@@ -4750,7 +4750,7 @@ TaskResult FollowPatrolRouteTask::handlePaused(void) {
void FollowPatrolRouteTask::pause(void) {
paused = TRUE;
- counter = (rand() % 64 + rand() % 64) / 2;
+ counter = (g_vm->_rnd->getRandomNumber(63) + g_vm->_rnd->getRandomNumber(63)) / 2;
}
/* ===================================================================== *
Commit: edceb1d82465fb94e117d9dbfef694ecacb0ac1f
https://github.com/scummvm/scummvm/commit/edceb1d82465fb94e117d9dbfef694ecacb0ac1f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:47+02:00
Commit Message:
SAGA2: Remove unneeded messagers and replace them with debugC()
Changed paths:
engines/saga2/actor.cpp
engines/saga2/detection.cpp
engines/saga2/interp.cpp
engines/saga2/main.cpp
engines/saga2/messager.cpp
engines/saga2/messager.h
engines/saga2/rmem.cpp
engines/saga2/saga2.h
engines/saga2/sagafunc.cpp
engines/saga2/script.h
engines/saga2/tower.cpp
engines/saga2/towerfta.cpp
engines/saga2/towerfta.h
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 03454df76e..6f02444b72 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -26,6 +26,8 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+#include "common/debug.h"
+
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/dispnode.h"
@@ -1294,9 +1296,6 @@ void *Actor::archive(void *buf) {
return buf;
}
-#if 0
-MonoMessager amm;
-#endif
//-----------------------------------------------------------------------
// Return a newly created actor
@@ -1345,9 +1344,7 @@ Actor *Actor::newActor(
if (a->flags & temporary) {
incTempActorCount(protoNum);
-#if 0
- amm("Created temp actor %d new count:%d", a->thisID() - 32768, getTempActorCount(protoNum));
-#endif
+ debugC(1, kDebugActors, "Actors: Created temp actor %d new count:%d", a->thisID() - 32768, getTempActorCount(protoNum));
}
return a;
@@ -1361,9 +1358,7 @@ void Actor::deleteActor(void) {
uint16 protoNum = (ActorProto *)prototype - actorProtos;
decTempActorCount(protoNum);
-#if 0
- amm("Deleting temp actor %d new count:%d", thisID() - 32768, getTempActorCount(protoNum));
-#endif
+ debugC(1, kDebugActors, "Actors: Deleting temp actor %d new count:%d", thisID() - 32768, getTempActorCount(protoNum));
}
// Kill task
@@ -1516,10 +1511,8 @@ void Actor::vitalityUpdate(void) {
// Perform actor specific activation tasks
void Actor::activateActor(void) {
-#if 0
if (thisID() > 32768)
- amm("Activated %d ", thisID() - 32768);
-#endif
+ debugC(1, kDebugActors, "Actors: Activated %d ", thisID() - 32768);
evaluateNeeds();
}
@@ -1527,10 +1520,9 @@ void Actor::activateActor(void) {
// Perfrom actor specific deactivation tasks
void Actor::deactivateActor(void) {
-#if 0
if (thisID() > 32768)
- amm("De-activated %d ", thisID() - 32768);
-#endif
+ debugC(1, kDebugActors, "Actors: De-activated %d ", thisID() - 32768);
+
// Kill task
if (curTask != NULL) {
curTask->abortTask();
diff --git a/engines/saga2/detection.cpp b/engines/saga2/detection.cpp
index 490837df42..6bc6382ff4 100644
--- a/engines/saga2/detection.cpp
+++ b/engines/saga2/detection.cpp
@@ -26,7 +26,11 @@
#include "engines/advancedDetector.h"
static const DebugChannelDef debugFlagList[] = {
- {Saga2::kDebugResources, "Resources", "Debug the resources"},
+ {Saga2::kDebugResources, "resources", "Debug the resources"},
+ {Saga2::kDebugActors, "actors", "Debug the actors"},
+ {Saga2::kDebugScripts, "scripts", "Debug the scripts"},
+ {Saga2::kDebugEventLoop, "eventloop", "Debug the event loop"},
+ {Saga2::kDebugInit, "init", "Debug the initialization process"},
DEBUG_CHANNEL_END
};
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index c1f615d65a..26afa533ee 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -26,6 +26,8 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+#include "common/debug.h"
+
#include "saga2/std.h"
#include "saga2/fta.h"
#include "saga2/script.h"
@@ -84,9 +86,7 @@ long exportCount; // number of exported syms
// An extended script is running -- suspend all background processing.
int16 extendedThreadLevel;
-#if DEBUG
int16 lastExport;
-#endif
/* ============================================================================ *
Externals
@@ -97,19 +97,6 @@ int16 lastExport;
extern hResource *scriptResFile; // script resources
hResContext *scriptRes; // script resource handle
-#if DEBUG
-//extern bool cliScriptDebug; // script debugging flag
-#define cliScriptDebug 1
-
-#include "messager.h"
-
-MonoMessager scriptDebugOut("Scripts");
-
-//extern pMessager Status[10];
-//#define scriptDebugOut (*Status[ 1 ])
-
-#endif
-
/* ============================================================================ *
Functions
* ============================================================================ */
@@ -137,7 +124,7 @@ uint8 *builtinObjectAddress(int16 segment, uint16 index) {
ASSERT(index > 0);
if (lookupExport(index, segNum, segOff) == FALSE)
error("SAGA: Cannot take address of abtract class");
-//debugf( "index = %d, segNum = %d, segOff = %d\n", index, segNum, segOff );
+
return segmentAddress(segNum, segOff);
case builtinTypeMission:
@@ -173,38 +160,35 @@ uint16 *builtinVTableAddress(int16 btype, uint8 *addr, CallTable **callTab) {
obj = (GameObject *)addr;
script = obj->scriptClass();
*callTab = &actorCFuncs;
-#if DEBUG
+
if (script <= 0)
error("SAGA failure: GameObject %d (%s) has no script.\n", obj->thisID(), obj->proto() ? obj->objName() : "Unknown");
-#endif
+
break;
case builtinTypeTAG:
aItem = (ActiveItem *)addr;
script = aItem->scriptClassID;
*callTab = &tagCFuncs;
-#if DEBUG
- if (script <= 0) error("SAGA failure: TAG has no script.\n");
-#endif
+
+ if (script <= 0)
+ error("SAGA failure: TAG has no script.\n");
+
break;
case builtinTypeMission:
aMission = (ActiveMission *)addr;
script = aMission->getScript();
*callTab = &missionCFuncs;
-#if DEBUG
- if (script <= 0) error("SAGA failure: Mission Object has no script.\n");
-#endif
+
+ if (script <= 0)
+ error("SAGA failure: Mission Object has no script.\n");
+
break;
case builtinAbstract:
*callTab = NULL;
-//{
-//uint16 *p;
-//
-//p = (uint16 *)addr;
-//debugf( "p[-1]=%d, p[0]=%d, p[1]=%d, p[2]=%d, p[3]=%d\n", p[-1], p[0], p[1], p[2], p[3] );
-//}
+
return (uint16 *)addr;
default:
@@ -522,26 +506,26 @@ int16 RRandom(int16 c, int16 s, int16 id) {
Main interpreter
* ============================================================================ */
-#if DEBUG
void print_script_name(uint8 *codePtr, char *descr = NULL) {
- if (cliScriptDebug) {
- char scriptName[ 32 ];
- uint8 *sym = codePtr - 1;
- uint8 length = min(*sym, sizeof scriptName - 1);
+ char scriptName[ 32 ];
+ uint8 *sym = codePtr - 1;
+ uint8 length = MIN<uint>(*sym, sizeof scriptName - 1);
- memcpy(scriptName, sym - *sym, length);
- scriptName[ length ] = '\0';
+ memcpy(scriptName, sym - *sym, length);
+ scriptName[ length ] = '\0';
- if (descr) scriptDebugOut("op_enter: [%s].%s ", descr, scriptName);
- else scriptDebugOut("op_enter: ::%s ", scriptName);
- }
+ if (descr)
+ debugC(1, kDebugScripts, "Scripts: op_enter: [%s].%s ", descr, scriptName);
+ else
+ debugC(1, kDebugScripts, "Scripts: op_enter: ::%s ", scriptName);
}
char *objectName(int16 segNum, uint16 segOff) {
//static nameBuf[ 64 ];
uint8 *objAddr;
- if (segNum >= 0) return "SagaObject";
+ if (segNum >= 0)
+ return "SagaObject";
objAddr = builtinObjectAddress(segNum, segOff);
@@ -560,7 +544,6 @@ char *objectName(int16 segNum, uint16 segOff) {
}
return "???";
}
-#endif
bool Thread::interpret(void) {
uint8 *pc,
@@ -684,9 +667,7 @@ bool Thread::interpret(void) {
returnVal = *stack++;
case op_return_v: // return with void
-#if DEBUG
- if (cliScriptDebug) scriptDebugOut("op_return");
-#endif
+ debugC(1, kDebugScripts, "Scripts: op_return");
// REM: When we implement dynamic strings we'll want to clean up first.
@@ -732,9 +713,7 @@ bool Thread::interpret(void) {
pc = *codeSeg + w; // calculate PC address
-#if DEBUG
print_script_name(pc);
-#endif
break;
case op_call_far: // call function in other seg
@@ -756,9 +735,7 @@ bool Thread::interpret(void) {
programCounter.offset = w; // store into pc
pc = *codeSeg + w; // calculate PC address
-#if DEBUG
print_script_name(pc);
-#endif
break;
case op_ccall: // call C function
@@ -809,7 +786,6 @@ bool Thread::interpret(void) {
// Handle the case of a builtin object which computes the
// vtable address in a different way.
-//debugf( "seg = %d, offset = %d\n", seg, offset );
if ((int16)seg < 0) {
vtable = builtinVTableAddress((int16)seg, addr, &callTab);
} else {
@@ -819,8 +795,6 @@ bool Thread::interpret(void) {
vtableEntry = vtable + (w * 2);
-//debugf( "vtable=%x, entry[ 0 ]=%d, entry[ 1 ]=%d\n", vtable, vtableEntry[ 0 ], vtableEntry[ 1 ] );
-
if (vtable == NULL) {
// Do nothing...
} else if (vtableEntry[ 0 ] != 0xffff) { // It's a SAGA func
@@ -849,9 +823,7 @@ bool Thread::interpret(void) {
// calculate PC address
pc = (*codeSeg) + programCounter.offset;
-#if DEBUG
print_script_name(pc, objectName(seg, offset));
-#endif
break;
} else if (vtableEntry[ 1 ] != 0xffff) { // It's a C func
// Save the ID of the invoked object
@@ -1528,10 +1500,8 @@ Thread::Thread(uint16 segNum, uint16 segOff, scriptCallFrame &args) {
((uint16 *)stackPtr)[ 2 ] = 0; // dummy return address
framePtr = stackSize;
-#if DEBUG
if ((*codeSeg)[ programCounter.offset ] != op_enter)
error("SAGA failure: Invalid script entry point (export=%d) [segment=%d:%d]\n", lastExport, segNum, segOff);
-#endif
// VERIFY ((*codeSeg)[ programCounter.offset ] == op_enter);
}
@@ -1634,7 +1604,6 @@ void Thread::dispatch(void) {
Thread *th,
*nextThread;
-#if DEBUG
int numThreads = 0,
numExecute = 0,
numWaitDelay = 0,
@@ -1642,9 +1611,8 @@ void Thread::dispatch(void) {
numWaitSemi = 0,
numWaitOther = 0;
- for (th = threadList.first();
- th;
- th = threadList.next(th)) {
+#if DEBUG
+ for (th = threadList.first(); th; th = threadList.next(th)) {
if (th->flags & waiting) {
switch (th->waitType) {
@@ -1668,9 +1636,7 @@ void Thread::dispatch(void) {
WriteStatusF(17, "Threads:%d X:%d D:%d F:%d T:%d O:%d", numThreads, numExecute, numWaitDelay, numWaitFrames, numWaitSemi, numWaitOther);
#endif
- for (th = threadList.first();
- th;
- th = nextThread) {
+ for (th = threadList.first(); th; th = nextThread) {
nextThread = threadList.next(th);
if (th->flags & (finished | aborted)) {
@@ -1845,11 +1811,10 @@ static bool lookupExport(
segOff = segRef >> 16,
segNum = segRef & 0x0000ffff;
-#if DEBUG
lastExport = entry;
if (segNum > 1000)
- error("SAGA failure: Bad data in export table entry #%d (see scripts.r)\n", entry);
-#endif
+ error("SAGA failure: Bad data in export table entry #%d (see scripts.r)", entry);
+
return TRUE;
}
@@ -1864,21 +1829,16 @@ scriptResult runScript(uint16 exportEntryNum, scriptCallFrame &args) {
Thread *saveThread = thisThread;
// Lookup function entry point in export table
-#if DEBUG
if (exportEntryNum < 0)
- error("SAGA failure: Attempt to run script with invalid export ID %d.\n", exportEntryNum);
-#endif
+ error("SAGA failure: Attempt to run script with invalid export ID %d.", exportEntryNum);
+
ASSERT(exportEntryNum > 0);
lookupExport(exportEntryNum, segNum, segOff);
// Create a new thread
th = new Thread(segNum, segOff, args);
thisThread = th;
-#if DEBUG
- print_script_name(
- (*th->codeSeg) + th->programCounter.offset,
- objectName(segNum, segOff));
-#endif
+ print_script_name((*th->codeSeg) + th->programCounter.offset, objectName(segNum, segOff));
// Run the thread to completion
result = th->run();
@@ -1913,11 +1873,9 @@ scriptResult runMethod(
if (bType == builtinAbstract) index = scriptClassID;
// Lookup class function table in export table
-#if DEBUG
if (scriptClassID < 0)
error("SAGA failure: Attempt to run object script with invalid export ID %d.\n", scriptClassID);
-#endif
-// ASSERT( scriptClassID > 0 );
+
lookupExport(scriptClassID, segNum, segOff);
// Get address of class function table
@@ -1951,9 +1909,7 @@ scriptResult runMethod(
// Create a new thread
th = new Thread(segNum, segOff, args);
thisThread = th;
-#if DEBUG
print_script_name((*th->codeSeg) + th->programCounter.offset, objectName(bType, index));
-#endif
// Put the object segment and ID onto the dummy stack frame
((uint16 *)th->stackPtr)[ 3 ] = bType;
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 404837331e..2c889fa82f 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -26,6 +26,8 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+#include "common/debug.h"
+
#include "saga2/std.h"
#include "saga2/rmemfta.h"
@@ -150,14 +152,6 @@ static uint32 lastGameTime = 0;
// message handlers
static pMessager Status[10];
static pMessager Status2[10];
-static pMessager Dump;
-
-#if DEBUG_LOOP
-MonoMessager elmm = MonoMessager("EventLoop");
-#define statusshow(s) elmm(s)
-#else
-#define statusshow(s) ((void)0)
-#endif
pMessager ratemess[3];
@@ -326,10 +320,10 @@ void processEventLoop(bool updateScreen) {
int key, qual;
- statusshow("starting event loop");
+ debugC(1, kDebugEventLoop, "EventLoop: starting event loop");
irate.updateFrameCount();
- statusshow("checking user abort");
+ debugC(1, kDebugEventLoop, "EventLoop: checking user abort");
breakEventLoop();
if (checkExit && verifyUserExit()) {
//gameRunning=false;
@@ -337,38 +331,38 @@ void processEventLoop(bool updateScreen) {
return;
}
- statusshow("handle win messages");
+ debugC(1, kDebugEventLoop, "EventLoop: handle win messages");
if (handlingMessages())
return;
- statusshow("check for game suspend");
+ debugC(1, kDebugEventLoop, "EventLoop: check for game suspend");
if (gameSuspended())
return;
- statusshow("audio event loop");
+ debugC(1, kDebugEventLoop, "EventLoop: audio event loop");
audioEventLoop();
- statusshow("game mode update");
+ debugC(1, kDebugEventLoop, "EventLoop: game mode update");
if (GameMode::newmodeFlag)
GameMode::update();
- statusshow("mouse update");
+ debugC(1, kDebugEventLoop, "EventLoop: mouse update");
updateMouse();
- statusshow("keyboard update");
+ debugC(1, kDebugEventLoop, "EventLoop: keyboard update");
if (ReadKeyboard(key, qual)) {
G_BASE.handleKeyStroke(key, qual);
}
//if(!running) return; // This Is No Tasks Are Done After Saving Game
- statusshow("timer update");
+ debugC(1, kDebugEventLoop, "EventLoop: timer update");
// Handle the timer events
// REM: Causing code corruption in windows for some reason...
G_BASE.handleTimerTick(gameTime >> 2);
// Handle updating of the display.
- statusshow("display update");
+ debugC(1, kDebugEventLoop, "EventLoop: display update");
if (!checkVideo()) {
displayUpdate();
}
@@ -381,9 +375,9 @@ void processEventLoop(bool updateScreen) {
void displayUpdate(void) {
if (displayEnabled()) { //updateScreen)
- //statusshow("daytime transition update loop");
+ //debugC(1, kDebugEventLoop, "EventLoop: daytime transition update loop");
dayNightUpdate();
- //statusshow("Game mode handle task");
+ //debugC(1, kDebugEventLoop, "EventLoop: Game mode handle task");
GameMode::modeStackPtr[GameMode::modeStackCtr - 1]->handleTask();
lrate.updateFrameCount();
loops++;
@@ -391,25 +385,25 @@ void displayUpdate(void) {
lastGameTime = gameTime;
- statusshow("Interface indicator updates");
+ debugC(1, kDebugEventLoop, "EventLoop: Interface indicator updates");
updateIndicators();
- statusshow("OS specific display routines");
+ debugC(1, kDebugEventLoop, "EventLoop: OS specific display routines");
displayEventLoop();
if (delayReDraw)
reDrawScreen();
// Call asynchronous resource loader
- statusshow("resource update");
+ debugC(1, kDebugEventLoop, "EventLoop: resource update");
loadAsyncResources();
audioEventLoop();
// Call the asynchronous path finder
- statusshow("pathfinder update");
+ debugC(1, kDebugEventLoop, "EventLoop: pathfinder update");
runPathFinder();
// Hows the game running?
- statusshow("updating stats");
+ debugC(1, kDebugEventLoop, "EventLoop: updating stats");
updatePerfStats();
}
@@ -885,14 +879,6 @@ bool verifyUserExit(void) {
return false;
}
-//-----------------------------------------------------------------------
-// Allocate text messagers
-
-bool initMessagers(void) {
- Dump = new BufferedTextMessager(8000);
- return (Dump != NULL);
-}
-
//-----------------------------------------------------------------------
// Allocate visual messagers
@@ -912,14 +898,6 @@ bool initGUIMessagers(void) {
return true;
}
-//-----------------------------------------------------------------------
-// cleanup text messagers
-
-void cleanupMessagers(void) {
- if (Dump) delete Dump;
- Dump = NULL;
-}
-
//-----------------------------------------------------------------------
// cleanup visual messagers
@@ -968,41 +946,6 @@ void WriteStatusF(int16, char *, ...) {}
void WriteStatusF2(int16, char *, ...) {}
#endif
-void logStr(bool onOff, bool newLn, char *st);
-
-void memoryWarning(char *msg, ...) {
- va_list argptr;
- SureLogMessager *slm = NEW_MSGR SureLogMessager("ERRORS.LOG", (int16) 0, SureLogMessager::logOpenAppend);
- DebuggerMessager *wdm = NEW_MSGR DebuggerMessager() ;
- TeeMessager t = TeeMessager(Dump, slm, wdm);
-
- va_start(argptr, msg);
- t.va(msg, argptr);
- va_end(argptr);
-
- if (slm) delete slm;
- if (wdm) delete wdm;
-}
-
-void memoryFatal(char *msg, ...) {
- va_list argptr;
- SureLogMessager *slm = NEW_MSGR SureLogMessager("ERRORS.LOG", (int16) 0, SureLogMessager::logOpenAppend);
- DebuggerMessager *wdm = NEW_MSGR DebuggerMessager() ;
- DialogMessager *mm = NEW_MSGR DialogMessager("FATAL ERROR");
- TeeMessager t = TeeMessager(Dump, slm, wdm, mm);
-
- va_start(argptr, msg);
- t.va(msg, argptr);
- va_end(argptr);
-
- if (slm) delete slm;
- if (wdm) delete wdm;
- if (mm) delete mm;
- RShowMem();
- //gameRunning=false;
- endGame();
-}
-
//---------------------------------------------------------
// Game performance can be used as a gauge of how much
// CPU time is available. We'd like to keep the retu
diff --git a/engines/saga2/messager.cpp b/engines/saga2/messager.cpp
index 094da7eb4b..d2c8d31b4e 100644
--- a/engines/saga2/messager.cpp
+++ b/engines/saga2/messager.cpp
@@ -24,8 +24,6 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/messager.h"
@@ -36,10 +34,6 @@ int16 userDialog(char *title, char *msg, char *btnMsg1,
char *btnMsg3);
-#ifndef TALLOC
-#define TALLOC(s,m) malloc(s)
-#endif
-
size_t Messager::va(char *format, va_list argptr) {
if (enabled) {
char tempBuf[ 256 ];
@@ -71,146 +65,6 @@ size_t Messager::operator()(char *format, ...) {
return 0;
}
-int FastLogMessager::dumpit(char *s, size_t size) {
-#if 0
- char timeBuf[32];
- if (logFile) {
- if (maxSize > 0 &&
- (size_t) filelength(fileno(logFile)) > maxSize) {
- fclose(logFile);
- remove(logFileName);
- logFile = fopen(logFileName, "at+");
- fprintf(logFile, "LOG CLEARED \n==========================");
- }
- if (flags & logTimeStamp) {
- _strtime(timeBuf);
- fprintf(logFile, "[%s] ", timeBuf);
- }
- return fwrite(s, 1, size, logFile);
- }
-#endif
- warning("STUB: dumpit");
- return 0;
-}
-
-FastLogMessager::FastLogMessager(char *entry, char *filename, size_t sizeLimit, logOpenFlags flg)
- : Messager(entry) {
- flags = flg;
- maxSize = sizeLimit;
- if (flg == logOpenAppend)
- logFile = fopen(filename, "at+");
- else
- logFile = fopen(filename, "wt+");
- enabled = (logFile != NULL);
-}
-
-FastLogMessager::FastLogMessager(char *filename, size_t sizeLimit, logOpenFlags flg) {
- flags = flg;
- maxSize = sizeLimit;
- if (flg == logOpenAppend)
- logFile = fopen(filename, "at+");
- else
- logFile = fopen(filename, "wt+");
- enabled = (logFile != NULL);
-}
-
-FastLogMessager::~FastLogMessager() {
- if (logFile) {
- fclose(logFile);
- }
-}
-
-int SureLogMessager::dumpit(char *s, size_t) {
- warning("STUB: dumpit");
-#if 0
-
- char timeBuf[32];
- FILE *logFile = fopen(logFileName, "at+");
- if (logFile) {
- if (maxSize > 0 &&
- (size_t) filelength(fileno(logFile)) > maxSize) {
- fclose(logFile);
- remove(logFileName);
- logFile = fopen(logFileName, "at+");
- fprintf(logFile, "LOG CLEARED \n==========================");
- }
- if (flags & logTimeStamp) {
- _strtime(timeBuf);
- fprintf(logFile, "[%s] ", timeBuf);
- }
- size_t l = fprintf(logFile, s);
- fclose(logFile);
- return l;
- }
-#endif
- return 0;
-}
-
-SureLogMessager::SureLogMessager(char *entry, char *filename, size_t sizeLimit, logOpenFlags flg)
- : Messager(entry) {
- flags = flg;
- strncpy(logFileName, filename, MAX_LOG_NAME_LENGTH);
- maxSize = sizeLimit;
- if (flg & logOpenAppend == 0) {
- FILE *logFile = fopen(filename, "wt+");
- if (logFile) {
- fprintf(logFile, "Log %s opened\n", filename);
- fclose(logFile);
- }
- }
-}
-
-SureLogMessager::SureLogMessager(char *filename, size_t sizeLimit, logOpenFlags flg) {
- flags = flg;
- strncpy(logFileName, filename, MAX_LOG_NAME_LENGTH);
- maxSize = sizeLimit;
- if (flg & logOpenAppend == 0) {
- FILE *logFile = fopen(filename, "wt+");
- if (logFile) {
- fprintf(logFile, "Log %s opened\n", filename);
- fclose(logFile);
- }
- }
-}
-
-SureLogMessager::~SureLogMessager() {
-}
-
-
-
-int BufferedTextMessager::dumpit(char *s, size_t l) {
- if (bufPos < bufSiz - 1) {
- size_t copy = MIN(bufSiz - bufPos, l);
- strncpy(dumpText + bufPos, s, copy);
- bufPos += copy;
- dumpText[bufPos] = '\0';
- return copy;
- }
- return 0;
-}
-
-BufferedTextMessager::BufferedTextMessager(char *entry, size_t s)
- : Messager(entry) {
- dumpText = (char *) TALLOC(s, memMessagers);
- bufSiz = s;
- bufPos = 0;
-}
-
-BufferedTextMessager::BufferedTextMessager(size_t s) {
- dumpText = (char *) TALLOC(s, memMessagers);
- bufSiz = s;
- bufPos = 0;
-}
-
-BufferedTextMessager::~BufferedTextMessager() {
- if (dumpText) {
- if (bufPos)
- fprintf(stderr, dumpText);
- if (dumpText) delete dumpText;
- dumpText = NULL;
- }
-}
-
uint16 defaultStatusFX = 468;
uint16 defaultStatusFY = 354;
@@ -260,98 +114,4 @@ StatusLineMessager::~StatusLineMessager() {
operator()("");
}
-int DialogMessager::dummy_va_arg_dump(char *s, ...) {
- va_list argptr;
- va_start(argptr, s);
-#ifdef GBASE_H
- GRequest(header, s, "_OK", argptr, 0, NULL, 0);
-#endif
- va_end(argptr);
- return 0;
-}
-
-int DialogMessager::dumpit(char *s, size_t size) {
-#ifdef _WIN32
- MessageBox(NULL, s, header, MB_OK);
-#else
-#if GBASE_H
- dummy_va_arg_dump(s);
-#else
- userDialog(header, s, "OK", NULL, NULL);
-#endif
-#endif
- return size;
-}
-
-DialogMessager::DialogMessager(char *entry, char *head)
- : Messager(entry) {
- strncpy(header, head, 31);
- header[31] = '\0';
-}
-
-DialogMessager::DialogMessager(char *head) {
- strncpy(header, head, 31);
- header[31] = '\0';
-}
-
-DialogMessager::~DialogMessager() {
-}
-
-
-int MonoMessager::dumpit(char *s, size_t t) {
- char t2[82];
- strncpy(t2, s, MIN<size_t>(t, 79));
- t2[MIN<size_t>(t, 79)] = '\0';
- monoprint(t2);
- return t;
-}
-
-MonoMessager::MonoMessager(char *entry)
- : Messager(entry) {
-}
-
-MonoMessager::MonoMessager(void) {
-}
-
-MonoMessager::~MonoMessager() {
-}
-
-
-
-
-int TeeMessager::dumpit(char *s, size_t t) {
- for (int i = 0; i < numSplit; i++) {
- if (mSub[i])
- (*mSub[i])(s);
- }
- return t;
-}
-
-TeeMessager::TeeMessager(pMessager m1, pMessager m2) {
- for (int i = 0; i < MAX_MESSAGER_TEES; i++)
- mSub[i] = NULL;
- numSplit = 2;
- mSub[0] = m1;
- mSub[1] = m2;
-}
-
-TeeMessager::TeeMessager(pMessager m1, pMessager m2, pMessager m3) {
- for (int i = 0; i < MAX_MESSAGER_TEES; i++)
- mSub[i] = NULL;
- numSplit = 3;
- mSub[0] = m1;
- mSub[1] = m2;
- mSub[2] = m3;
-}
-
-TeeMessager::TeeMessager(pMessager m1, pMessager m2, pMessager m3, pMessager m4) {
- for (int i = 0; i < MAX_MESSAGER_TEES; i++)
- mSub[i] = NULL;
- numSplit = 4;
- mSub[0] = m1;
- mSub[1] = m2;
- mSub[2] = m3;
- mSub[3] = m4;
-}
-
} // end of namespace Saga2
diff --git a/engines/saga2/messager.h b/engines/saga2/messager.h
index 6e97d4a79b..2adbc77a68 100644
--- a/engines/saga2/messager.h
+++ b/engines/saga2/messager.h
@@ -94,117 +94,6 @@ public:
typedef Messager *pMessager;
-//-------------------------------------------------------------------
-// Tee Messager
-
-#define MAX_MESSAGER_TEES 4
-
-class TeeMessager : public Messager {
-private:
- int16 numSplit;
- pMessager mSub[MAX_MESSAGER_TEES];
-
-protected:
- int dumpit(char *, size_t);
-
-public:
- TeeMessager(pMessager, pMessager);
- TeeMessager(pMessager, pMessager, pMessager);
- TeeMessager(pMessager, pMessager, pMessager, pMessager);
- ~TeeMessager() {}
-};
-
-
-//-------------------------------------------------------------------
-// Messager that ignores text
-
-class NullMessager : public Messager {
-protected:
- int dumpit(char *, size_t) {
- return 0;
- }
-
-public:
- NullMessager() {
- enabled = FALSE;
- }
- ~NullMessager() {}
-
-};
-
-//-------------------------------------------------------------------
-// Messager to write text to a log file. Has several options:
-// A maximum size for the log file can be given
-// Normally any existing log is deleted. This can be overridden
-
-class FastLogMessager : public Messager {
-private:
- char logFileName[MAX_LOG_NAME_LENGTH];
- FILE *logFile;
- size_t maxSize;
- uint32 flags;
-
-protected:
- int dumpit(char *s, size_t size) ;
-
-public:
- enum logOpenFlags {
- logOpenNormal = 0,
- logOpenAppend = 1 << 0,
- logTimeStamp = 1 << 1,
- };
-
- FastLogMessager(char *filename, size_t sizeLimit = 0, logOpenFlags flgs = logOpenNormal);
- FastLogMessager(char *entry, char *filename, size_t sizeLimit = 0, logOpenFlags flgs = logOpenNormal);
- ~FastLogMessager();
-};
-
-//-------------------------------------------------------------------
-// Similar to the FastLogMessager, but the file is kept closed most of
-// the time. While this is noteicably slower, the log will actually
-// be there after a crash.
-
-class SureLogMessager : public Messager {
-private:
- char logFileName[MAX_LOG_NAME_LENGTH];
- size_t maxSize;
- uint32 flags;
-
-protected:
- int dumpit(char *s, size_t size) ;
-
-public:
- enum logOpenFlags {
- logOpenNormal = 0,
- logOpenAppend = 1 << 0,
- logTimeStamp = 1 << 1,
- };
-
- SureLogMessager(char *filename, size_t sizeLimit = 0, logOpenFlags flgs = logOpenNormal);
- SureLogMessager(char *entry, char *filename, size_t sizeLimit = 0, logOpenFlags flgs = logOpenNormal);
- ~SureLogMessager();
-};
-
-//-------------------------------------------------------------------
-// This Messager acts like the gError::warn() routine. Text is appended
-// to an internal buffer till the Messager is destroyed. At that
-// point the entire buffer is written to stderr. The buffer is
-// internally allocated, but you need to specify how big to make it
-// in the constructor.
-
-class BufferedTextMessager : public Messager {
-protected:
- char *dumpText;
- size_t bufSiz, bufPos;
-
- int dumpit(char *, size_t);
-
-public:
- BufferedTextMessager(size_t s);
- BufferedTextMessager(char *entry, size_t s);
- ~BufferedTextMessager();
-};
-
//-------------------------------------------------------------------
// This messager writes text on a gDisplayPort (usually mainPort).
// If you have seen the debugging lines in FTA2, this class acts
@@ -229,75 +118,6 @@ public:
~StatusLineMessager();
};
-//-------------------------------------------------------------------
-// This Messager should pop up a modal dialog with the text on it.
-// While this is easily done in Windows, or with gTools, FTA2 for
-// DOS doesn't have that capability yet, so its not fully functional
-
-class DialogMessager : public Messager {
-private:
- char header[32];
- int dummy_va_arg_dump(char *s, ...);
-
-protected:
- int dumpit(char *s, size_t size);
-
-public:
- DialogMessager(char *head);
- DialogMessager(char *entry, char *head);
- ~DialogMessager();
-};
-
-
-//-------------------------------------------------------------------
-// If you have DEBRK.LIB set up this class will dump text to the
-// Log window of the Watcom Debugger. If you don't or if you're
-// using Windows, this is effectively a NullMessager
-
-class DebuggerMessager : public Messager {
-protected:
-#if defined(__WATCOMC__)
-#if DEBUG
- int dumpit(char *s, size_t l) {
- DEBUG_DUMP(s);
- return l;
- }
-#else
- int dumpit(char *, size_t l) {
- return l;
- }
-#endif
-#else
-#if DEBUG
- int dumpit(char *s, size_t l) {
- OutputDebugString(s);
- return l;
- }
-#else
- int dumpit(char *, size_t l) {
- return l;
- }
-#endif
-#endif
-
-public:
- DebuggerMessager() {}
- DebuggerMessager(char *entry) : Messager(entry) {}
- ~DebuggerMessager() {}
-};
-
-//-------------------------------------------------------------------
-// These use Robert McNally's Mono code to dump to the mono screen
-
-class MonoMessager : public Messager {
-protected:
- int dumpit(char *s, size_t size);
-
-public:
- MonoMessager(void);
- MonoMessager(char *entry);
- ~MonoMessager();
-};
} // end of namespace Saga2
diff --git a/engines/saga2/rmem.cpp b/engines/saga2/rmem.cpp
index fabb11ac8b..57a0a38fa8 100644
--- a/engines/saga2/rmem.cpp
+++ b/engines/saga2/rmem.cpp
@@ -46,11 +46,8 @@ namespace Saga2 {
/* DGI Library calls */
/* STD.H */
/* Others */
-/* logBreak(); */
/* VMM_Lock() or LocalLock() (DOS/WIN) */
/* VMM_Unlock() or LocalUnlock() (DOS/WIN) */
-/* memoryWarning(char*,...) */
-/* memoryFatal(char*,...) */
/* initRMemLogging() (in RMEMLOG.CPP) */
/* */
/* ===================================================================== */
@@ -58,13 +55,6 @@ namespace Saga2 {
#define SysAlloc malloc
#define SysFree( m,s ) free( m )
-// Breakpoint call
-void logBreak(void);
-// Warning message
-void memoryWarning(char *msg, ...);
-// fatal error
-void memoryFatal(char *msg, ...);
-
/* ===================================================================== *
Debugging variables which control the heap integrity checking
NOTE: If you want to change these settings you should do so
@@ -220,7 +210,7 @@ void VMM_Lock_Mem(void *ptr, size_t size) {
warning("STUB: VMM_Lock_Mem()");
#if 0
if (!VMM_lock(ptr, size))
- memoryFatal("VMM Locking failed");
+ error("VMM Locking failed");
#endif
}
@@ -228,7 +218,7 @@ void VMM_Unlock_Mem(void *ptr, size_t size) {
warning("STUB: VMM_Unlock_mem");
#if 0
if (!VMM_unlock(ptr, size))
- memoryFatal("VMM Locking failed");
+ error("VMM Locking failed");
#endif
}
@@ -247,7 +237,7 @@ RHeapPtr _RNewHeap(uint8 *memory, int32 size) {
heap = (RHeapPtr) SysAlloc(sizeof * heap);
if (heap == NULL)
- memoryFatal("Memory allocation (%ld bytes) failed\n", sizeof * heap);
+ error("Memory allocation (%ld bytes) failed", sizeof * heap);
heap->next = heapList;
heapList = heap;
@@ -442,10 +432,10 @@ static void DisposePtrHeap(void *ptr, RHeapPtr heap) {
uint8 *cptr;
#endif
if (whichHeap(ptr) == NULL) {
- memoryFatal("Cannot dispose pointers in global heap");
+ error("Cannot dispose pointers in global heap");
}
if (heap != whichHeap(ptr)) {
- memoryFatal("bad heap specified on dispose");
+ error("bad heap specified on dispose");
}
#endif
if (ptr) { // if pointer is non-null
@@ -456,14 +446,14 @@ static void DisposePtrHeap(void *ptr, RHeapPtr heap) {
if (pr->size < sizeof * pr + wallSize * 2 ||
pr->magic != RMEM_MAGIC_ID) {
if (pr->magic == RMEM_FREED_ID)
- memoryFatal("Double deletion detected");
+ error("Double deletion detected");
else if (pr->magic == RMEM_LEAK_ID) {
char tDesc[20];
strncpy(tDesc, pr->description, 16);
tDesc[16] = '\0';
- memoryWarning("Block '%s' deleted after heap cleanup.\n", tDesc);
+ warning("Block '%s' deleted after heap cleanup.", tDesc);
} else
- memoryFatal("Invalid Memory Prefix");
+ error("Invalid Memory Prefix");
} else {
pr->magic = RMEM_FREED_ID;
strncpy(pr->description, "freed", 16);
@@ -485,13 +475,13 @@ void _RCheckPtr(void *ptr) {
// get memory prefix address
RMemPrefix *pr;
if (whichHeap(ptr) == NULL) {
- memoryFatal("Cannot check pointers in global heap");
+ error("Cannot check pointers in global heap");
}
pr = PrefixBaseAddr(ptr);
// debugging check
if (pr->size < sizeof * pr + wallSize * 2 ||
pr->magic != RMEM_MAGIC_ID) {
- memoryFatal("Invalid Memory Prefix");
+ error("Invalid Memory Prefix");
}
//checkWalls( (uint8 *)(pr + 1), pr->size - sizeof *pr );
}
@@ -566,9 +556,6 @@ static void *RAllocBlockHeap(RHeapPtr heap, int32 size, bool high, const char de
} else {
strncpy(pr->description, desc, 16);
}
- if (strlen(desc) == 0) {
- logBreak();
- }
#if WIPE_ALLOC
ptr = (uint8 *)pr + prefixOffset;
memset(ptr, RMEM_ALLOC_WIPE_ID, size - (sizeof * pr + wallSize * 2)); // clear prefix to zero
@@ -719,7 +706,7 @@ static void CompactHeap(RHeapPtr heap, uint32 needed) {
// Check to see if size field is too large or too small
if (pr->size > next_free - alloc
|| alloc < sizeof * pr + wallSize * 2) {
- memoryFatal("Invalid Memory prefix");
+ error("Invalid Memory prefix");
}
// Check memory wall integrity
@@ -1242,7 +1229,7 @@ void _RUnlockHandle(RHANDLE handle) {
if (handle && hb->data) {
if (whichHeap(hb->data) == NULL)
- memoryFatal("Handle has invalid data pointer");
+ error("Handle has invalid data pointer");
pr = PrefixBaseAddr(hb->data);
pr->lockNestCount--;
@@ -1324,7 +1311,7 @@ bool _RHandleLoading(RHANDLE handle) {
// This function is called whenever a wall corruption is detected.
// Probably should be set as a breakpoint in the debugger.
void wallHit(void) {
- memoryFatal("Wall Hit");
+ error("Wall Hit");
}
// Checks to see if the memory cookie is still in place around each allocation.
@@ -1335,16 +1322,13 @@ void checkWalls(uint8 *begin, uint32 length) {
RHeapPtr heap = whichHeap(begin); // pointer to new heap
if (heap == NULL) {
- logBreak();
- memoryFatal("invalid wall size");
+ error("invalid wall size");
}
if (length > heap->size) {
- logBreak();
- memoryFatal("invalid wall size");
+ error("invalid wall size");
}
if (whichHeap(end - 1) != heap) {
- logBreak();
- memoryFatal("invalid wall size");
+ error("invalid wall size");
}
for (i = 0; i < wallSize; i++) {
--end;
@@ -1364,8 +1348,7 @@ void setWalls(uint8 *begin, uint32 length) {
int i;
if (heap == NULL || length > heap->size || whichHeap(end - 1) != heap) {
- logBreak();
- memoryFatal("invalid wallocation");
+ error("invalid wallocation");
}
for (i = 0; i < wallSize; i++) {
*begin++ = RMEM_WALL_ID;
@@ -1378,7 +1361,7 @@ void setWalls(uint8 *begin, uint32 length) {
void heapCheck(void) {
if (heapList->firstFree
&& (uint8 *)heapList->firstFree < (uint8 *)heapList->memory) {
- memoryFatal("HeapFailed: %d %d\n", heapList->size, heapList->free);
+ error("HeapFailed: %d %d\n", heapList->size, heapList->free);
}
}
@@ -1418,7 +1401,7 @@ bool _RMemIntegrity(void) {
if (pr->size > bytesToNext
|| pr->size < sizeof * pr + wallSize * 2) {
- memoryFatal("Bad prefix size %d : %s\n", pr->size,
+ error("Bad prefix size %d : %s", pr->size,
#if DEBUG
pr->description
#else
diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h
index 7a79fea40b..3ea9abc221 100644
--- a/engines/saga2/saga2.h
+++ b/engines/saga2/saga2.h
@@ -36,6 +36,10 @@ class Console;
enum {
kDebugResources = 1 << 0,
+ kDebugActors = 1 << 1,
+ kDebugScripts = 1 << 2,
+ kDebugEventLoop = 1 << 3,
+ kDebugInit = 1 << 4
};
class Saga2Engine : public Engine {
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index 4078af8da8..195a1097eb 100644
--- a/engines/saga2/sagafunc.cpp
+++ b/engines/saga2/sagafunc.cpp
@@ -26,6 +26,8 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+#include "common/debug.h"
+
#include "saga2/std.h"
#include "saga2/fta.h"
#include "saga2/script.h"
@@ -59,24 +61,8 @@ void drawMainDisplay(void);
#pragma off (unreferenced);
#endif
-#if DEBUG
-//extern bool cliScriptDebug; // script debugging flag
-#define cliScriptDebug 1
-
-#include "saga2/messager.h"
-
-//MonoMessager scriptDebugOut( "Scripts" );
-
-//extern pMessager Status[10];
-//#define scriptDebugOut (*Status[ 1 ])
-extern MonoMessager scriptDebugOut;
-
-#define MONOLOG( s ) {if (cliScriptDebug) scriptDebugOut( "cfunc: " #s );}
-#define OBJLOG( s ) {if (cliScriptDebug) scriptDebugOut( "cfunc: [%s]." #s , ((GameObject *)thisThread->thisObject)->objName() );}
-#else
-#define MONOLOG( s )
-#define OBJLOG(s)
-#endif
+#define MONOLOG(s) {debugC(2, kDebugScripts, "cfunc: " #s );}
+#define OBJLOG(s) {debugC(2, kDebugScripts, "cfunc: [%s]." #s , ((GameObject *)thisThread->thisObject)->objName() );}
namespace Saga2 {
diff --git a/engines/saga2/script.h b/engines/saga2/script.h
index 9e2f740afa..fbd7d0bfb6 100644
--- a/engines/saga2/script.h
+++ b/engines/saga2/script.h
@@ -195,9 +195,8 @@ class Thread {
friend void wakeUpThread(ThreadID, int16);
- SegmentRef programCounter; // current PC location
-
public:
+ SegmentRef programCounter; // current PC location
uint8 *stackPtr; // current stack location
UByteHandle codeSeg; // base of current data segment
diff --git a/engines/saga2/tower.cpp b/engines/saga2/tower.cpp
index fa4e7f3606..71d4d19346 100644
--- a/engines/saga2/tower.cpp
+++ b/engines/saga2/tower.cpp
@@ -26,6 +26,8 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+#include "common/debug.h"
+
#include "saga2/std.h"
#include "saga2/tower.h"
#include "saga2/osexcept.h"
@@ -198,22 +200,11 @@ int initState(void) {
}
void setInitState(int i) {
-#if DEBUG_INIT
- MonoMessager mm = MonoMessager("GameInit");
-#else
- NullMessager mm;
-#endif
-
initializationState = i;
-#if DEBUG_INIT
- WriteStatusF(12, "Init State %d", i);
- mm("Init state %d", i);
- if (i == maxInitState) {
- WriteStatusF(13, "INITIALIZATION COMPLETE");
- mm("INITIALIZATION COMPLETE");
- }
-#endif
+ debugC(1, kDebugInit, "Init state %d", i);
+ if (i == maxInitState)
+ debugC(1, kDebugInit, "INITIALIZATION COMPLETE");
}
} // end of namespace Saga2
diff --git a/engines/saga2/towerfta.cpp b/engines/saga2/towerfta.cpp
index 9bdbd9b492..ac1e745fbe 100644
--- a/engines/saga2/towerfta.cpp
+++ b/engines/saga2/towerfta.cpp
@@ -63,7 +63,6 @@ TowerLayer tower[fullyInitialized] = {
{ errHandlersInitialized, &initErrorManagers, &termErrorManagers },
{ delayedErrInitialized, &initDelayedErrors, &termDelayedErrors },
{ activeErrInitialized, &initActiveErrors, &termActiveErrors },
- { messagersInitialized, &initSysMessagers, &termSysMessagers },
{ errLoggersInitialized, &initErrorLoggers, &termErrorLoggers },
{ breakHandlerInitialized, &initCtlBreakTrap, &termCtlBreakTrap },
{ configTestInitialized, &initSystemConfig, &termTowerBase },
@@ -103,7 +102,6 @@ TowerLayer tower[fullyInitialized] = {
* ===================================================================== */
//#include "saga2/loadmsg.h"
-bool initMessagers(void);
bool initGUIMessagers(void);
void cleanupMessagers(void);
void cleanupGUIMessagers(void);
@@ -149,18 +147,6 @@ TERMINATOR(termErrorLoggers) {
}
-// ------------------------------------------------------------------------
-
-INITIALIZER(initSysMessagers) {
- initMessagers();
- return TRUE;
-}
-
-TERMINATOR(termSysMessagers) {
- cleanupMessagers();
-}
-
-
// ------------------------------------------------------------------------
INITIALIZER(initCtlBreakTrap) {
diff --git a/engines/saga2/towerfta.h b/engines/saga2/towerfta.h
index 876230bb98..c0994a4af4 100644
--- a/engines/saga2/towerfta.h
+++ b/engines/saga2/towerfta.h
@@ -34,9 +34,6 @@ namespace Saga2 {
INITIALIZER(initErrorLoggers);
TERMINATOR(termErrorLoggers);
-INITIALIZER(initSysMessagers);
-TERMINATOR(termSysMessagers);
-
INITIALIZER(initCtlBreakTrap);
TERMINATOR(termCtlBreakTrap);
Commit: 1f1947c39a7c39d40a7c83c6a921d4dab31cb464
https://github.com/scummvm/scummvm/commit/1f1947c39a7c39d40a7c83c6a921d4dab31cb464
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:48+02:00
Commit Message:
SAGA2: Remove winini.*
Changed paths:
R engines/saga2/winini.cpp
R engines/saga2/winini.h
engines/saga2/config.cpp
engines/saga2/config.h
engines/saga2/main.cpp
engines/saga2/messager.h
engines/saga2/module.mk
engines/saga2/noise.cpp
engines/saga2/tromode.cpp
engines/saga2/uidialog.cpp
diff --git a/engines/saga2/config.cpp b/engines/saga2/config.cpp
index 799e5c20f3..e4c38cb871 100644
--- a/engines/saga2/config.cpp
+++ b/engines/saga2/config.cpp
@@ -29,7 +29,6 @@
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/config.h"
-#include "saga2/winini.h"
#include "saga2/program.h"
namespace Saga2 {
@@ -88,6 +87,7 @@ static void defaultConfig(configuration &config) {
// saves settings to INI file
void writeConfig(void) {
+#if 0
WritePrivateProfileInt("Sound", "MusicVolume", globalConfig.musicVolume, iniFile);
WritePrivateProfileInt("Sound", "SoundVolume", globalConfig.soundVolume, iniFile);
WritePrivateProfileInt("Sound", "VoiceVolume", globalConfig.voiceVolume, iniFile);
@@ -95,6 +95,8 @@ void writeConfig(void) {
WritePrivateProfileInt("Options", "AutoWeapon", globalConfig.autoWeapon, iniFile);
WritePrivateProfileInt("Options", "SpeechText", globalConfig.speechText, iniFile);
WritePrivateProfileInt("Options", "Night", globalConfig.showNight, iniFile);
+#endif
+ warning("STUB: writeConfig()");
}
/* ===================================================================== *
diff --git a/engines/saga2/config.h b/engines/saga2/config.h
index 050827600a..ce729e2d34 100644
--- a/engines/saga2/config.h
+++ b/engines/saga2/config.h
@@ -27,8 +27,6 @@
#ifndef SAGA2_CONFIG_H
#define SAGA2_CONFIG_H
-#include "saga2/winini.h"
-
namespace Saga2 {
// under WIN95 paths can get BIG
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 2c889fa82f..0594284ab8 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -39,7 +39,6 @@
#include "saga2/calender.h"
#include "saga2/itevideo.h"
#include "saga2/tile.h"
-#include "saga2/winini.h"
#include "saga2/messager.h"
#include "saga2/intrface.h"
#include "saga2/script.h"
diff --git a/engines/saga2/messager.h b/engines/saga2/messager.h
index 2adbc77a68..a7492ff345 100644
--- a/engines/saga2/messager.h
+++ b/engines/saga2/messager.h
@@ -29,7 +29,6 @@
#include "saga2/vdraw.h"
#include "saga2/grequest.h"
-#include "saga2/winini.h"
#include "saga2/mono.h"
namespace Saga2 {
@@ -74,7 +73,7 @@ public:
enabled = TRUE;
}
Messager(char *entry) {
- enabled = GetPrivateProfileInt("Debug", entry, FALSE, iniFile);
+ enabled = TRUE;
}
virtual ~Messager() {}
diff --git a/engines/saga2/module.mk b/engines/saga2/module.mk
index 74c2215423..da78e5cb68 100644
--- a/engines/saga2/module.mk
+++ b/engines/saga2/module.mk
@@ -109,8 +109,7 @@ MODULE_OBJS := \
vpal.o \
vwdraw.o \
vwpage.o \
- weapons.o \
- winini.o
+ weapons.o
MODULE_DIRS += \
engines/saga2
diff --git a/engines/saga2/noise.cpp b/engines/saga2/noise.cpp
index d53203625f..e8d85c27fe 100644
--- a/engines/saga2/noise.cpp
+++ b/engines/saga2/noise.cpp
@@ -233,11 +233,13 @@ void startAudio(void) {
(uint32) 400000 // sound buffer size
);
+#if 0
disMusic = !GetPrivateProfileInt("Sound", "Music", 1, iniFile);
disVoice = !GetPrivateProfileInt("Sound", "Voice", 1, iniFile);
disLoops = !GetPrivateProfileInt("Sound", "Loops", 1, iniFile);
disSound = !GetPrivateProfileInt("Sound", "Sound", 1, iniFile);
-
+#endif
+ warning("STUB: startAudio, sync sound settings");
assert(audio);
if (audio->active()) {
@@ -316,10 +318,13 @@ void startAudio(void) {
clickData[2] = (uint8 *) LoadResource(soundRes, MKTAG('C', 'L', 'K', 2), "Click 2");
}
+#if 0
disMusic = !GetPrivateProfileInt("Sound", "Music", 1, iniFile);
disVoice = !GetPrivateProfileInt("Sound", "Voice", 1, iniFile);
disLoops = !GetPrivateProfileInt("Sound", "Loops", 1, iniFile);
disSound = !GetPrivateProfileInt("Sound", "Sound", 1, iniFile);
+#endif
+ warning("STUB: startAudio, sync sound settings");
#if DEBUG
if (debugStatuses) {
diff --git a/engines/saga2/tromode.cpp b/engines/saga2/tromode.cpp
index 0a36cbb998..e17268572d 100644
--- a/engines/saga2/tromode.cpp
+++ b/engines/saga2/tromode.cpp
@@ -26,6 +26,8 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+#include "common/config-manager.h"
+
#include "saga2/std.h"
#include "saga2/cmisc.h"
#include "saga2/input.h"
@@ -235,7 +237,7 @@ void waitForVideoFile(char *fileName) { // file name & extension
abortFlag = FALSE;
- if (!GetPrivateProfileInt("Options", "Videos", 1, iniFile)) {
+ if (ConfMan.getBool("disable_videos")) {
abortFlag = TRUE;
return;
}
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index 60e9268390..9a8f111afb 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -637,7 +637,6 @@ int16 FileDialog(int16 fileProcess) {
void **arrowUpIm = NULL,
**arrowDnIm = NULL,
**pushBtnIm = NULL;
- int16 lastGame;
AppFunc *fileCommands[ 2 ] = { { cmdFileSave }, { cmdFileLoad } };
@@ -749,8 +748,6 @@ int16 FileDialog(int16 fileProcess) {
elementsof(saveWindowDecorations),
decRes, 'S', 'L', 'D');
- lastGame = GetPrivateProfileInt("Options", "LastGame", 0, iniFile);
-
win->userData = &rInfo;
win->open();
@@ -758,7 +755,6 @@ int16 FileDialog(int16 fileProcess) {
GameMode::update();
win->invalidate();
- textBox->choose(lastGame);
//win->draw();
//G_BASE.setActive(textBox);
@@ -973,7 +969,6 @@ int16 OptionsDialog(bool disableSaveResume) {
loadRestartGame();
else {
loadSavedGameState(deferredLoadID);
- WritePrivateProfileInt("Options", "LastGame", deferredLoadID, iniFile);
}
if (GameMode::newmodeFlag)
GameMode::update();
@@ -990,7 +985,6 @@ int16 OptionsDialog(bool disableSaveResume) {
if (deferredSaveFlag) {
#ifdef IMMEDIATE_SAVE
saveGameState(deferredLoadID, deferredSaveName);
- WritePrivateProfileInt("Options", "LastGame", deferredLoadID, iniFile);
#endif
}
mainWindow->invalidate(optionsWindowRect);
@@ -1685,7 +1679,6 @@ APPFUNC(cmdFileSave) {
#ifndef IMMEDIATE_SAVE
// save game
saveGameState(saveIndex, textBox->getLine(saveIndex));
- WritePrivateProfileInt("Options", "LastGame", saveIndex, iniFile);
#else
deferredLoadID = saveIndex;
deferredSaveFlag = TRUE;
diff --git a/engines/saga2/winini.cpp b/engines/saga2/winini.cpp
deleted file mode 100644
index 6315122000..0000000000
--- a/engines/saga2/winini.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * aint32 with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
-#include "saga2/std.h"
-#include "saga2/winini.h"
-
-namespace Saga2 {
-
-int GetPrivateProfileString(LPCSTR, LPCSTR, LPCSTR, LPSTR, int, LPCSTR) {
- warning("STUB: GetPrivateProfileString()");
- return 0;
-}
-
-bool WritePrivateProfileInt(char *s, char *k, int val, char *ini) {
- warning("STUB: WritePrivateProfileString()");
- return false;
-}
-
-uint16 GetPrivateProfileInt(LPCSTR, LPCSTR, int, LPCSTR) {
- warning("STUB: GetPrivateProfileInt()");
- return 0;
-}
-
-} // end of namespace Saga2
diff --git a/engines/saga2/winini.h b/engines/saga2/winini.h
deleted file mode 100644
index 6af39d76aa..0000000000
--- a/engines/saga2/winini.h
+++ /dev/null
@@ -1,61 +0,0 @@
-
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * aint32 with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#ifndef SAGA2_WININI_H
-#define SAGA2_WININI_H
-
-namespace Saga2 {
-
-#ifndef _WIN32
-
-typedef char *LPCSTR;
-typedef char *LPSTR;
-
-int GetPrivateProfileString(LPCSTR, LPCSTR, LPCSTR, LPSTR, int, LPCSTR);
-bool WritePrivateProfileString(LPCSTR, LPCSTR, LPCSTR, LPCSTR);
-
-uint16 GetPrivateProfileInt(LPCSTR, LPCSTR, int, LPCSTR);
-bool WritePrivateProfileInt(char *s, char *k, int val, char *ini);
-
-int GetProfileString(LPCSTR, LPCSTR, LPCSTR, LPSTR, int);
-bool WriteProfileString(LPCSTR, LPCSTR, LPCSTR);
-
-uint16 GetProfileInt(LPCSTR, LPCSTR, int);
-#else
-//uint16 GetPrivateProfileInt(LPCSTR, LPCSTR, int, LPCSTR);
-inline bool WritePrivateProfileInt(char *s, char *k, int val, char *ini) {
- char temp[20];
- return WritePrivateProfileString(s, k, itoa(val, temp, 10), ini);
-}
-
-#endif
-
-extern char iniFile[];
-
-} // end of namespace Saga2
-
-#endif
Commit: a41d378fedb61498cbbb0d83ca3046c379d64480
https://github.com/scummvm/scummvm/commit/a41d378fedb61498cbbb0d83ca3046c379d64480
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:48+02:00
Commit Message:
SAGA2: Remove mono.*
Changed paths:
R engines/saga2/mono.cpp
R engines/saga2/mono.h
engines/saga2/messager.h
engines/saga2/module.mk
diff --git a/engines/saga2/messager.h b/engines/saga2/messager.h
index a7492ff345..e5be7c5a61 100644
--- a/engines/saga2/messager.h
+++ b/engines/saga2/messager.h
@@ -29,7 +29,6 @@
#include "saga2/vdraw.h"
#include "saga2/grequest.h"
-#include "saga2/mono.h"
namespace Saga2 {
diff --git a/engines/saga2/module.mk b/engines/saga2/module.mk
index da78e5cb68..aa9736860a 100644
--- a/engines/saga2/module.mk
+++ b/engines/saga2/module.mk
@@ -51,7 +51,6 @@ MODULE_OBJS := \
metaengine.o \
mission.o \
modal.o \
- mono.o \
motion.o \
msgbox.o \
noise.o \
diff --git a/engines/saga2/mono.cpp b/engines/saga2/mono.cpp
deleted file mode 100644
index b79edeeb6d..0000000000
--- a/engines/saga2/mono.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * aint32 with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
-#include "saga2/std.h"
-#include "saga2/mono.h"
-
-namespace Saga2 {
-
-bool debugOn = FALSE;
-
-void debugf(char *format, ...) {
- if (debugOn) {
- char scratchBuffer[512];
-
- va_list val;
-
- va_start(val, format);
- vsprintf(scratchBuffer, format, val);
- va_end(val);
-
- monoprint(scratchBuffer);
- }
-}
-
-void monoscroll(int lines) {
- unsigned int col;
- short *pd;
- short *ps;
-
- for (col = lines, pd = (short *)0xB0000, ps = (short *)(160 * lines + 0xB0000);
- col < 24;
- col++) {
- int row;
-
- for (row = 0; row < 80; row++) {
- *(pd++) = *(ps++);
- }
- }
-}
-
-void monocopy(int lines, char *p, int length) {
- int column = 24 - lines;
- if (column < 0) column = 0;
- if (length > 80 * 24) length = 80 * 24;
-
- int length2 = (80 - length) % 80;
-
- char *pDest = column * 160 + (char *)0xB0000;
-
- while (length > 0) {
- *(pDest++) = *(p++);
- *(pDest++) = 0x40;
- length--;
- }
- while (length2 > 0) {
- *(pDest++) = ' ';
- *(pDest++) = 0x40;
- length2--;
- }
-}
-
-void monoprint(char *p) {
- char *p2;
- while (*p != 0) {
- p2 = p;
- while (*p2 != 0 && *p2 != '\n') {
- p2++;
- }
- bool foundCR = *p2 == '\n';
- if (foundCR) *p2 = 0;
-
- int length = strlen(p);
-
- int lines = 1 + length / 80;
-
- monoscroll(lines);
-
- monocopy(lines, p, length);
-
- if (foundCR) {
- *p2 = '\n';
- p = p2 + 1;
- } else {
- p = p2;
- }
- }
-}
-
-
-#if 0
-
-#ifndef __MYASSERT
-#define __MYASSERT
-
-
-
-/*
- * myassert.h
- *
- * Copyright by The Dreamers Guild, Inc. 1995. All rights reserved.
- *
- */
-#ifdef __cplusplus
-extern "C" {
-#endif
-#undef assert
-
-
-
-#ifdef NDEBUG
-#define assert(__ignore) ((void)0)
-#else
-extern void __assert(int, char *, char *, int);
-extern void __myassert(long, char *, char *, int);
-#define assert(expr) __myassert((long)(expr),#expr,__FILE__,__LINE__);
-#endif
-#ifdef __cplusplus
-};
-#endif
-
-#endif
-
-
-
-
-void __myassert(long expr, char *pError, char *pFile, int line) {
- static bool inAssert = FALSE;
-
- if (inAssert) return;
-
- inAssert = TRUE;
-
- if (!expr) {
- debug("Assert failed: %s, file = %s, line = %d", pError, pFile, line);
- if (connection != connectionNone) {
- error("Assert failed: %s, file = %s, line = %d",
- pError, pFile, line);
- } else {
-#undef __assert
- __assert(expr, pError, pFile, line);
- }
- }
-
- inAssert = FALSE;
-}
-
-
-#endif
-
-#if 0 // __WATCOMC__
-
-void debugf(char *, ...) {
-}
-
-void monoprint(char *) {
-}
-
-#endif
-
-} // end if namespace Saga2
diff --git a/engines/saga2/mono.h b/engines/saga2/mono.h
deleted file mode 100644
index 98a108a278..0000000000
--- a/engines/saga2/mono.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * aint32 with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#ifndef SAGA2_MONO_H
-#define SAGA2_MONO_H
-
-namespace Saga2 {
-
-extern bool debugOn;
-
-void debugf(char *format, ...);
-void monoprint(char *string);
-
-} // end of namespace Saga2
-
-#endif
Commit: b76a1121d63bff7c1fe68017712819f813aa5559
https://github.com/scummvm/scummvm/commit/b76a1121d63bff7c1fe68017712819f813aa5559
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:48+02:00
Commit Message:
SAGA2: Const'ness
Changed paths:
engines/saga2/button.h
engines/saga2/floating.cpp
engines/saga2/gdraw.h
engines/saga2/gtext.cpp
engines/saga2/intrface.cpp
engines/saga2/intrface.h
engines/saga2/messager.cpp
engines/saga2/msgbox.cpp
engines/saga2/msgbox.h
engines/saga2/panel.cpp
engines/saga2/panel.h
engines/saga2/uidialog.cpp
engines/saga2/uidialog.h
diff --git a/engines/saga2/button.h b/engines/saga2/button.h
index 1d090ff155..ea4b6ca163 100644
--- a/engines/saga2/button.h
+++ b/engines/saga2/button.h
@@ -404,7 +404,7 @@ void writePlaqText(gPort &port,
int16 textPos,
textPallete &pal,
bool hiLite,
- char *msg, ...);
+ const char *msg, ...);
void writePlaqTextPos(gPort &port,
@@ -413,7 +413,7 @@ void writePlaqTextPos(gPort &port,
int16 textPos,
textPallete &pal,
bool hiLite,
- char *msg, ...);
+ const char *msg, ...);
} // end of namespace Saga2
diff --git a/engines/saga2/floating.cpp b/engines/saga2/floating.cpp
index d3f548c1bb..053472ea96 100644
--- a/engines/saga2/floating.cpp
+++ b/engines/saga2/floating.cpp
@@ -403,7 +403,7 @@ LabeledButton::LabeledButton(gPanelList &list,
buttonLabel,
ident,
cmd) {
- char *underscore;
+ const char *underscore;
if ((underscore = strchr(title, '_')) != NULL)
accelKey = toupper(underscore[ 1 ]);
diff --git a/engines/saga2/gdraw.h b/engines/saga2/gdraw.h
index 90cfa72569..75dfe8bb84 100644
--- a/engines/saga2/gdraw.h
+++ b/engines/saga2/gdraw.h
@@ -116,7 +116,7 @@ struct gFont {
gFont *LoadFont(char *fontname);
void DisposeFont(gFont *font);
-int16 TextWidth(gFont *font, char *s, int16 length, int16 styles);
+int16 TextWidth(gFont *font, const char *s, int16 length, int16 styles);
int16 WhichChar(gFont *font, uint8 *s, int16 length, int16 maxLen);
int16 WhichIChar(gFont *font, uint8 *s, int16 length, int16 maxLen);
int32 GTextWrap(gFont *font, char *mark, uint16 &count, uint16 width, int16 styles);
@@ -383,16 +383,16 @@ public:
private:
// Unclipped text rendering
- void drawStringChars(char *, int16, gPixelMap &, int, int);
+ void drawStringChars(const char *, int16, gPixelMap &, int, int);
// Clipped but still low-level
- int16 drawClippedString(char *str, int16 len, int xpos, int ypos);
+ int16 drawClippedString(const char *str, int16 len, int xpos, int ypos);
public:
// Draw a text string with the current settings at the
// current pen position. If the length is < 0, then use the
// natural string length.
- void drawText(char *str, int16 length = -1);
- void drawTextInBox(char *str, int16 length,
+ void drawText(const char *str, int16 length = -1);
+ void drawTextInBox(const char *str, int16 length,
const Rect16 &r, int16 pos,
Point16 borders);
};
diff --git a/engines/saga2/gtext.cpp b/engines/saga2/gtext.cpp
index 4a1525a438..5335c86c31 100644
--- a/engines/saga2/gtext.cpp
+++ b/engines/saga2/gtext.cpp
@@ -604,7 +604,7 @@ endall:
*/
void gPort::drawStringChars(
- char *str, // string to draw
+ const char *str, // string to draw
int16 len, // length of string
gPixelMap &dest,
int xpos, // x position to draw it
@@ -720,7 +720,7 @@ void gPort::drawStringChars(
// we would probably do this differently...
int16 gPort::drawClippedString(
- char *s, // string to draw
+ const char *s, // string to draw
int16 len, // length of string
int xpos, // x position to draw it
int ypos) { // y position to draw it
@@ -934,7 +934,7 @@ int16 gPort::drawClippedString(
**********************************************************************
*/
void gPort::drawText(
- char *str, /* string to draw */
+ const char *str, /* string to draw */
int16 length) {
if (length < 0) length = strlen(str);
@@ -994,7 +994,7 @@ void gPort::drawText(
**********************************************************************
*/
void gPort::drawTextInBox(
- char *str,
+ const char *str,
int16 length,
const Rect16 &r,
int16 pos,
@@ -1071,7 +1071,7 @@ void gPort::drawTextInBox(
*
**********************************************************************
*/
-int16 TextWidth(gFont *font, char *s, int16 length, int16 styles) {
+int16 TextWidth(gFont *font, const char *s, int16 length, int16 styles) {
int16 count = 0;
if (length < 0) length = strlen(s);
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index d127ad0fd3..85612518f1 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -441,7 +441,7 @@ void playMemSound(uint32 s); // play click # s
CPlaqText::CPlaqText(gPanelList &list,
const Rect16 &box,
- char *msg,
+ const char *msg,
gFont *font,
int16 textPos,
textPallete &pal,
@@ -1470,7 +1470,7 @@ void writePlaqText(gPort &port,
int16 textPos,
textPallete &pal,
bool hiLite,
- char *msg, ...) {
+ const char *msg, ...) {
char lineBuf[ 128 ];
va_list argptr;
int16 cnt;
@@ -1522,7 +1522,7 @@ void writePlaqTextPos(gPort &port,
int16 /*textPos*/,
textPallete &pal,
bool hiLite,
- char *msg, ...) {
+ const char *msg, ...) {
char lineBuf[ 128 ];
va_list argptr;
int16 cnt;
diff --git a/engines/saga2/intrface.h b/engines/saga2/intrface.h
index 2626a6bcbe..2d50a0e425 100644
--- a/engines/saga2/intrface.h
+++ b/engines/saga2/intrface.h
@@ -203,7 +203,7 @@ protected:
public:
- CPlaqText(gPanelList &, const Rect16 &, char *, gFont *,
+ CPlaqText(gPanelList &, const Rect16 &, const char *, gFont *,
int16, textPallete &, int16, AppFunc *cmd = NULL);
void enable(bool);
diff --git a/engines/saga2/messager.cpp b/engines/saga2/messager.cpp
index d2c8d31b4e..6db67db791 100644
--- a/engines/saga2/messager.cpp
+++ b/engines/saga2/messager.cpp
@@ -29,11 +29,6 @@
namespace Saga2 {
-int16 userDialog(char *title, char *msg, char *btnMsg1,
- char *btnMsg2,
- char *btnMsg3);
-
-
size_t Messager::va(char *format, va_list argptr) {
if (enabled) {
char tempBuf[ 256 ];
diff --git a/engines/saga2/msgbox.cpp b/engines/saga2/msgbox.cpp
index 1d51fa1c48..9931332262 100644
--- a/engines/saga2/msgbox.cpp
+++ b/engines/saga2/msgbox.cpp
@@ -65,7 +65,7 @@ void writePlaqText(gPort &port,
int16 textPos,
textPallete &pal,
bool hiLite,
- char *msg, ...);
+ const char *msg, ...);
inline Rect16 butBox(int n, int i) {
return (n > 1 ? mbButtonRects[i] : mbOneBtnRect);
@@ -76,7 +76,7 @@ inline Rect16 butBox(int n, int i) {
* ===================================================================== */
bool userDialogAvailable(void);
-int16 userDialog(char *title, char *msg, char *btnMsg1,
+int16 userDialog(const char *title, char *msg, char *btnMsg1,
char *btnMsg2,
char *btnMsg3);
@@ -287,7 +287,7 @@ void SimpleWindow::writeWrappedPlaqText(gPort &port,
int16 textPos,
textPallete &pal,
bool hiLite,
- char *msg, ...) {
+ const char *msg, ...) {
char textBuf[ 256 ];
char lineBuf[ 128 ];
va_list argptr;
diff --git a/engines/saga2/msgbox.h b/engines/saga2/msgbox.h
index ac96c65ce4..9b2602051d 100644
--- a/engines/saga2/msgbox.h
+++ b/engines/saga2/msgbox.h
@@ -71,7 +71,7 @@ public:
int16 textPos,
textPallete &pal,
bool hiLite,
- char *msg, ...);
+ const char *msg, ...);
};
diff --git a/engines/saga2/panel.cpp b/engines/saga2/panel.cpp
index 9f6d3eaa26..b4a38b19b8 100644
--- a/engines/saga2/panel.cpp
+++ b/engines/saga2/panel.cpp
@@ -68,7 +68,7 @@ gPanel::gPanel(gWindow &win, const Rect16 &box, AppFunc *cmd)
}
gPanel::gPanel(gPanelList &list, const Rect16 &box,
- char *newTitle, uint16 ident, AppFunc *cmd)
+ const char *newTitle, uint16 ident, AppFunc *cmd)
: window(list.window) {
title = newTitle;
extent = box;
@@ -608,7 +608,7 @@ void gWindow::setPointer( gPixelMap &map, int x, int y )
gControl class: The basis for buttons and other controls.
* ===================================================================== */
-gControl::gControl(gPanelList &list, const Rect16 &box, char *title, uint16 ident,
+gControl::gControl(gPanelList &list, const Rect16 &box, const char *title, uint16 ident,
AppFunc *cmd) : gPanel(list, box, title, ident, cmd) {
accelKey = 0;
diff --git a/engines/saga2/panel.h b/engines/saga2/panel.h
index 43bc45131b..f0ebf93b9b 100644
--- a/engines/saga2/panel.h
+++ b/engines/saga2/panel.h
@@ -131,7 +131,7 @@ class gPanel : public DNode {
protected:
gWindow &window; // window this belongs to
Rect16 extent; // rectangular bounds of the control
- char *title; // title of the panel
+ const char *title; // title of the panel
int enabled : 1, // allows disabling the panel
selected : 1, // some panels have a selected state
imageLabel : 1, // button label is image, not text
@@ -146,7 +146,7 @@ public:
void *userData; // data for this panel
// constructor
- gPanel(gPanelList &, const Rect16 &, char *, uint16, AppFunc *cmd = NULL);
+ gPanel(gPanelList &, const Rect16 &, const char *, uint16, AppFunc *cmd = NULL);
gPanel(gPanelList &, const Rect16 &, gPixelMap &, uint16, AppFunc *cmd = NULL);
virtual ~gPanel(); // destructor
@@ -398,7 +398,7 @@ class gControl : public gPanel {
public:
uint8 accelKey;
- gControl(gPanelList &, const Rect16 &, char *, uint16, AppFunc *cmd = NULL);
+ gControl(gPanelList &, const Rect16 &, const char *, uint16, AppFunc *cmd = NULL);
gControl(gPanelList &, const Rect16 &, gPixelMap &, uint16, AppFunc *cmd = NULL);
~gControl(); // destructor
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index 9a8f111afb..bcfd3929aa 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -1074,7 +1074,7 @@ void cleanupUserDialog(void) {
}
-int16 userDialog(char *title, char *msg, char *bMsg1,
+int16 userDialog(const char *title, char *msg, char *bMsg1,
char *bMsg2,
char *bMsg3) {
const maxBtns = 3;
@@ -1167,7 +1167,7 @@ bool userDialogAvailable(void) {
}
void cleanupUserDialog(void) {}
-int16 userDialog(char *title, char *msg, char *bMsg1,
+int16 userDialog(const char *title, char *msg, char *bMsg1,
char *bMsg2,
char *bMsg3) {
const int maxBtns = 3;
diff --git a/engines/saga2/uidialog.h b/engines/saga2/uidialog.h
index 827e859a66..69f85f7ee5 100644
--- a/engines/saga2/uidialog.h
+++ b/engines/saga2/uidialog.h
@@ -57,7 +57,7 @@ int16 OptionsDialog(bool disableSaveResume = FALSE);
void initFileFields(char **fieldStrings);
char **destroyFileFields(void);
bool getSaveName(int8 saveNo, SaveFileHeader &header);
-int16 userDialog(char *title, char *msg, char *btnMsg1,
+int16 userDialog(const char *title, char *msg, char *btnMsg1,
char *btnMsg2,
char *btnMsg3);
Commit: b036dddc9da6640b2cd0a0512ef44f49b0f31d7f
https://github.com/scummvm/scummvm/commit/b036dddc9da6640b2cd0a0512ef44f49b0f31d7f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:48+02:00
Commit Message:
SAGA2: Fix warnings
Changed paths:
engines/saga2/floating.h
engines/saga2/fta.h
engines/saga2/main.cpp
engines/saga2/messager.cpp
engines/saga2/messager.h
engines/saga2/panel.h
diff --git a/engines/saga2/floating.h b/engines/saga2/floating.h
index 5aff3a996c..f683d786ad 100644
--- a/engines/saga2/floating.h
+++ b/engines/saga2/floating.h
@@ -128,7 +128,7 @@ public:
// Fakes out the gButton into thinking there's no image.
gPhantomButton(gPanelList &list,
const Rect16 &box, uint16 ident, AppFunc *cmd = NULL) :
- gButton(list, box, *((gPixelMap *)NULL), ident, cmd) {};
+ gButton(list, box, NULL, ident, cmd) {};
virtual void draw(void) {}; // Overrides draw() member of parent, since
// in this case there's nothing to draw.
@@ -144,32 +144,13 @@ protected:
*deselImage;
public:
- gImageButton(gPanelList &list,
- const Rect16 &box,
- gPixelMap &img1,
- gPixelMap &img2,
- uint16 ident,
- AppFunc *cmd = NULL) :
- gButton(list,
- box,
- *((gPixelMap *)NULL),
- ident,
- cmd) {
+ gImageButton(gPanelList &list, const Rect16 &box, gPixelMap &img1, gPixelMap &img2, uint16 ident, AppFunc *cmd = NULL) :
+ gButton(list, box, NULL, ident, cmd) {
selImage = &img1;
deselImage = &img2;
}
- gImageButton(gPanelList &list,
- const Rect16 &box,
- gPixelMap &img1,
- gPixelMap &img2,
- char *title,
- uint16 ident,
- AppFunc *cmd = NULL) :
- gButton(list,
- box,
- title,
- ident,
- cmd) {
+ gImageButton(gPanelList &list, const Rect16 &box, gPixelMap &img1, gPixelMap &img2, char *title, uint16 ident, AppFunc *cmd = NULL) :
+ gButton(list, box, title, ident, cmd) {
selImage = &img1;
deselImage = &img2;
}
@@ -183,18 +164,8 @@ public:
class gToggleButton : public gImageButton {
public:
- gToggleButton(gPanelList &list,
- const Rect16 &box,
- gPixelMap &img1,
- gPixelMap &img2,
- uint16 ident,
- AppFunc *cmd) :
- gImageButton(list,
- box,
- img1,
- img2,
- ident,
- cmd) {}
+ gToggleButton(gPanelList &list, const Rect16 &box, gPixelMap &img1, gPixelMap &img2, uint16 ident, AppFunc *cmd) :
+ gImageButton(list, box, img1, img2, ident, cmd) {}
private:
bool activate(gEventType why); // activate the control
diff --git a/engines/saga2/fta.h b/engines/saga2/fta.h
index 4903c245ca..e043dca48e 100644
--- a/engines/saga2/fta.h
+++ b/engines/saga2/fta.h
@@ -156,7 +156,7 @@ public:
// Debugging status
-void WriteStatusF(int16 lin, char *msg, ...);
+void WriteStatusF(int16 lin, const char *msg, ...);
// Mouse polling
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 0594284ab8..ba1181e292 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -197,7 +197,7 @@ void RShowMem(void);
void parseCommandLine(int argc, char *argv[]);
char *getExeFromCommandLine(int argc, char *argv[]);
void updateMouse(void);
-void WriteStatusF2(int16 line, char *msg, ...);
+void WriteStatusF2(int16 line, const char *msg, ...);
bool initUserDialog(void);
void cleanupUserDialog(void);
int16 OptionsDialog(bool disableSaveResume = false);
@@ -914,7 +914,7 @@ void cleanupGUIMessagers(void) {
// Debugging status functions
#ifdef WriteStatus
-void WriteStatusF(int16 line, char *msg, ...) {
+void WriteStatusF(int16 line, const char *msg, ...) {
va_list argptr;
int cnt;
if (displayEnabled()) {
@@ -930,7 +930,7 @@ void WriteStatusF(int16 line, char *msg, ...) {
}
}
-void WriteStatusF2(int16 line, char *msg, ...) {
+void WriteStatusF2(int16 line, const char *msg, ...) {
va_list argptr;
int cnt;
if (displayEnabled()) {
@@ -941,8 +941,8 @@ void WriteStatusF2(int16 line, char *msg, ...) {
}
}
#else
-void WriteStatusF(int16, char *, ...) {}
-void WriteStatusF2(int16, char *, ...) {}
+void WriteStatusF(int16, const char *, ...) {}
+void WriteStatusF2(int16, const char *, ...) {}
#endif
//---------------------------------------------------------
diff --git a/engines/saga2/messager.cpp b/engines/saga2/messager.cpp
index 6db67db791..367c3069c6 100644
--- a/engines/saga2/messager.cpp
+++ b/engines/saga2/messager.cpp
@@ -29,7 +29,7 @@
namespace Saga2 {
-size_t Messager::va(char *format, va_list argptr) {
+size_t Messager::va(const char *format, va_list argptr) {
if (enabled) {
char tempBuf[ 256 ];
size_t size;
diff --git a/engines/saga2/messager.h b/engines/saga2/messager.h
index e5be7c5a61..9433b56b0d 100644
--- a/engines/saga2/messager.h
+++ b/engines/saga2/messager.h
@@ -77,7 +77,7 @@ public:
virtual ~Messager() {}
size_t operator()(char *format, ...);
- size_t va(char *format, va_list argptr);
+ size_t va(const char *format, va_list argptr);
void enable() {
enabled = TRUE;
diff --git a/engines/saga2/panel.h b/engines/saga2/panel.h
index f0ebf93b9b..34081e23e0 100644
--- a/engines/saga2/panel.h
+++ b/engines/saga2/panel.h
@@ -480,20 +480,21 @@ public:
bool mouseHintSet; // true if mouse hint is up.
private:
- void setMsgQ(gPanelMessage &msg, gPanel *panel) {
- if (panel == &panel->window) msg.pickPos = pickPos;
+ void setMsgQ(gPanelMessage &msg_, gPanel *panel) {
+ if (panel == &panel->window)
+ msg_.pickPos = pickPos;
else {
- msg.pickPos.x = (int16)(pickPos.x - panel->extent.x);
- msg.pickPos.y = (int16)(pickPos.y - panel->extent.y);
+ msg.pickPos.x = (int16)(pickPos.x - panel->extent.x);
+ msg.pickPos.y = (int16)(pickPos.y - panel->extent.y);
}
}
- void setMsg(gPanelMessage &msg, gPanel *panel) {
- setMsgQ(msg, panel);
- msg.inPanel = (msg.pickPos.x >= 0
- && msg.pickPos.y >= 0
- && msg.pickPos.x < panel->extent.width
- && msg.pickPos.y < panel->extent.height);
+ void setMsg(gPanelMessage &msg_, gPanel *panel) {
+ setMsgQ(msg_, panel);
+ msg.inPanel = (msg_.pickPos.x >= 0
+ && msg_.pickPos.y >= 0
+ && msg_.pickPos.x < panel->extent.width
+ && msg_.pickPos.y < panel->extent.height);
// panel->extent.ptInside( pickPos );
}
Commit: 97fa02d7b817cf917ed652792ce0ad1cf4d3dd86
https://github.com/scummvm/scummvm/commit/97fa02d7b817cf917ed652792ce0ad1cf4d3dd86
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:48+02:00
Commit Message:
SAGA2: Fix duplicated enums
Changed paths:
engines/saga2/actor.cpp
engines/saga2/contain.cpp
engines/saga2/effects.h
engines/saga2/enchant.cpp
engines/saga2/motion.cpp
engines/saga2/objects.cpp
engines/saga2/objects.h
engines/saga2/objproto.cpp
engines/saga2/sagafunc.cpp
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 6f02444b72..46c6aca8fa 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -194,7 +194,7 @@ bool ActorProto::openAction(ObjectID dObj, ObjectID) {
cn = CreateContainerNode(dObj, FALSE, openMindType);
cn->markForShow(); // Deferred open
- dObjPtr->objectFlags |= GameObject::objectOpen; // Set open bit;
+ dObjPtr->objectFlags |= objectOpen; // Set open bit;
return TRUE;
}
@@ -214,7 +214,7 @@ bool ActorProto::closeAction(ObjectID dObj, ObjectID) {
cn->markForDelete();
// Clear open bit
- dObjPtr->objectFlags &= ~GameObject::objectOpen;
+ dObjPtr->objectFlags &= ~objectOpen;
return TRUE;
}
diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index d6a268eb53..b303e96db0 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -1645,7 +1645,7 @@ void ContainerList::doDeferredActions(void) {
if (obj->world() != world
|| (obj->getWorldLocation() - tp).quickHDistance() > maxOpenDistance) {
// Close object image and window (silently)
- obj->setFlags(0, GameObject::objectOpen);
+ obj->setFlags(0, objectOpen);
delete n;
continue;
}
diff --git a/engines/saga2/effects.h b/engines/saga2/effects.h
index 0cb02397ed..08d125c080 100644
--- a/engines/saga2/effects.h
+++ b/engines/saga2/effects.h
@@ -252,16 +252,6 @@ enum effectDrainsTypes {
};
-//
-// Object Effects - effects that apply only to non-actor objects
-//
-
-enum effectObjectTypes {
- objectLocked = 1 << 1,
- objectInvisible = 1 << 4,
-};
-
-
//
// TAG Effects - effects that apply when a TAG is the target
//
@@ -280,6 +270,24 @@ enum effectLocationTypes {
locateDummy = 1,
};
+enum objectFlags {
+ objectOpen = (1 << 0), // object is in the "open" state
+ objectLocked = (1 << 1), // object cannot be opened
+ objectImportant = (1 << 2), // object must be recycled when trashed
+ objectGhosted = (1 << 3), // object drawn translucent
+ objectInvisible = (1 << 4), // object cannot be seen
+ objectObscured = (1 << 5), // object obscured by terrain
+ objectMoving = (1 << 6), // object has attached motion task
+ objectScavengable = (1 << 7), // object can be deleted
+ objectFloating = (1 << 8), // object not affected by Gravity
+ objectNoRecycle = (1 << 9), // object is referred to by script, don't delete
+ objectActivated = (1 << 10), // object is activated
+ objectAlias = (1 << 11), // object is not real, just a copy of another object
+ objectTriggeringTAG = (1 << 12), // object has triggerred TAG upon which it rests
+ objectOnScreen = (1 << 13), // object is on display list
+ objectSightedByCenter = (1 << 14), // there is a line of sight to center actor
+};
+
//
// Special Effects - these are spells that need to be handled manually
@@ -333,7 +341,7 @@ inline uint16 makeEnchantmentID(effectOthersTypes othtyp, bool damamt) {
return (effectOthers << 13) | (othtyp << 8) + (damamt + 128);
}
-inline uint16 makeEnchantmentID(effectObjectTypes othtyp, bool damamt) {
+inline uint16 makeEnchantmentID(objectFlags othtyp, bool damamt) {
return (effectNonActor << 13) | (othtyp << 8) + (damamt + 128);
}
diff --git a/engines/saga2/enchant.cpp b/engines/saga2/enchant.cpp
index 092a760513..5fa9ce757b 100644
--- a/engines/saga2/enchant.cpp
+++ b/engines/saga2/enchant.cpp
@@ -241,11 +241,11 @@ void evalObjectEnchantments(GameObject *obj) {
// have to do this a bit differently...
if (FindObjectEnchantment(obj->thisID(), makeEnchantmentID(effectNonActor, objectInvisible, TRUE)))
- obj->setFlags((uint8) - 1, GameObject::objectInvisible);
+ obj->setFlags((uint8) - 1, objectInvisible);
else
- obj->setFlags(0, GameObject::objectInvisible);
+ obj->setFlags(0, objectInvisible);
if (FindObjectEnchantment(obj->thisID(), makeEnchantmentID(effectNonActor, objectLocked, FALSE)))
- obj->setFlags((uint8) - 1, GameObject::objectLocked);
+ obj->setFlags((uint8) - 1, objectLocked);
}
//-------------------------------------------------------------------
diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp
index 576d336645..bee4a79cbb 100644
--- a/engines/saga2/motion.cpp
+++ b/engines/saga2/motion.cpp
@@ -510,7 +510,7 @@ MotionTask *MotionTaskList::newTask(GameObject *obj) {
if (isActor(obj))((Actor *)obj)->moveTask = mt;
}
}
- obj->objectFlags |= GameObject::objectMoving;
+ obj->objectFlags |= objectMoving;
return mt;
}
@@ -1213,11 +1213,11 @@ void MotionTask::remove(int16 returnVal) {
if (nextMT == this)
nextMT = (MotionTask *)next();
- object->objectFlags &= ~GameObject::objectMoving;
+ object->objectFlags &= ~objectMoving;
if (objObscured(object))
- object->objectFlags |= GameObject::objectObscured;
+ object->objectFlags |= objectObscured;
else
- object->objectFlags &= ~GameObject::objectObscured;
+ object->objectFlags &= ~objectObscured;
if (isActor(object)) {
Actor *a = (Actor *)object;
@@ -4709,7 +4709,7 @@ bool MotionTask::freeFall(TilePoint &newPos, StandingTileInfo &sti) {
tHeight = tileSlopeHeight(newPos, object, &sti);
- if (object->objectFlags & GameObject::objectFloating) return FALSE;
+ if (object->objectFlags & objectFloating) return FALSE;
velocity.u = (newPos.u - object->location.u) * 2 / 3;
velocity.v = (newPos.v - object->location.v) * 2 / 3;
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index e0eee83a1b..f75bb1f6af 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -2212,11 +2212,11 @@ void GameObject::evalEnchantments(void) {
}
}
-#define noMergeFlags (GameObject::objectImportant|\
- GameObject::objectGhosted|\
- GameObject::objectInvisible|\
- GameObject::objectFloating|\
- GameObject::objectNoRecycle)
+#define noMergeFlags (objectImportant|\
+ objectGhosted|\
+ objectInvisible|\
+ objectFloating|\
+ objectNoRecycle)
int32 GameObject::canStackOrMerge(GameObject *dropObj, GameObject *target) {
int32 cSet = dropObj->proto()->containmentSet();
diff --git a/engines/saga2/objects.h b/engines/saga2/objects.h
index 5c20bbe73c..4e1d253424 100644
--- a/engines/saga2/objects.h
+++ b/engines/saga2/objects.h
@@ -96,7 +96,6 @@ void initActors(void);
void saveActors(SaveFileConstructor &);
void loadActors(SaveFileReader &);
void cleanupActors(void);
-
class GameObject {
friend void initWorlds(void);
@@ -180,30 +179,6 @@ public:
uint8 reserved[ 2 ];
- // 32 bytes
- // If we had to add anything, it would be:
- // thisID <-- id of this object
- // prevSiblingID <-- id of previous sibling
-
-
- enum objectFlags {
- objectOpen = (1 << 0), // object is in the "open" state
- objectLocked = (1 << 1), // object cannot be opened
- objectImportant = (1 << 2), // object must be recycled when trashed
- objectGhosted = (1 << 3), // object drawn translucent
- objectInvisible = (1 << 4), // object cannot be seen
- objectObscured = (1 << 5), // object obscured by terrain
- objectMoving = (1 << 6), // object has attached motion task
- objectScavengable = (1 << 7), // object can be deleted
- objectFloating = (1 << 8), // object not affected by Gravity
- objectNoRecycle = (1 << 9), // object is referred to by script, don't delete
- objectActivated = (1 << 10), // object is activated
- objectAlias = (1 << 11), // object is not real, just a copy of another object
- objectTriggeringTAG = (1 << 12), // object has triggerred TAG upon which it rests
- objectOnScreen = (1 << 13), // object is on display list
- objectSightedByCenter = (1 << 14), // there is a line of sight to center actor
- };
-
// Default constructor
GameObject(void);
diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp
index cc1fee6efd..6f12b2ddb6 100644
--- a/engines/saga2/objproto.cpp
+++ b/engines/saga2/objproto.cpp
@@ -1238,7 +1238,7 @@ bool PhysicalContainerProto::useAction(ObjectID dObj, ObjectID enactor) {
bool result;
GameObject *dObjPtr = GameObject::objectAddress(dObj);
- if (dObjPtr->objectFlags & GameObject::objectOpen)
+ if (dObjPtr->objectFlags & objectOpen)
result = close(dObj, enactor);
else
result = open(dObj, enactor);
@@ -1263,7 +1263,7 @@ bool PhysicalContainerProto::openAction(ObjectID dObj, ObjectID) {
cn = CreateContainerNode(dObj, FALSE);
cn->markForShow(); // Deferred open
- dObjPtr->objectFlags |= GameObject::objectOpen; // Set open bit;
+ dObjPtr->objectFlags |= objectOpen; // Set open bit;
globalContainerList.setUpdate(dObjPtr->IDParent());
return TRUE;
}
@@ -1279,7 +1279,7 @@ bool PhysicalContainerProto::closeAction(ObjectID dObj, ObjectID) {
cn->markForDelete();
// Clear open bit
- dObjPtr->objectFlags &= ~GameObject::objectOpen;
+ dObjPtr->objectFlags &= ~objectOpen;
globalContainerList.setUpdate(dObjPtr->IDParent());
return TRUE;
}
@@ -1301,7 +1301,7 @@ bool PhysicalContainerProto::acceptLockToggleAction(
GameObject *dObjPtr = GameObject::objectAddress(dObj);
// Toggle locked bit
- dObjPtr->objectFlags ^= GameObject::objectLocked;
+ dObjPtr->objectFlags ^= objectLocked;
return TRUE;
}
@@ -1319,7 +1319,7 @@ bool PhysicalContainerProto::acceptInsertionAction(
GameObject *itemPtr = GameObject::objectAddress(item);
// Place the object in the container (if possible)
- if ((dObjPtr->objectFlags & GameObject::objectLocked)
+ if ((dObjPtr->objectFlags & objectLocked)
|| !dObjPtr->placeObject(enactor, item, TRUE, num)) {
if (isWorld(dObjPtr->IDParent()))
dObjPtr->dropInventoryObject(itemPtr, num);
@@ -2986,7 +2986,7 @@ bool IntangibleContainerProto::useAction(ObjectID dObj, ObjectID enactor) {
bool result;
GameObject *dObjPtr = GameObject::objectAddress(dObj);
- if (dObjPtr->objectFlags & GameObject::objectOpen)
+ if (dObjPtr->objectFlags & objectOpen)
result = close(dObj, enactor);
else
result = open(dObj, enactor);
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index 195a1097eb..00b6ea2ebf 100644
--- a/engines/saga2/sagafunc.cpp
+++ b/engines/saga2/sagafunc.cpp
@@ -645,7 +645,7 @@ int16 scriptActorSetImportant(int16 *args) {
OBJLOG(SetImportant);
((GameObject *)thisThread->thisObject)->setFlags(
args[0 ] ? (int16) 0xffff : (int16) 0,
- GameObject::objectImportant);
+ objectImportant);
return 0;
}
@@ -653,7 +653,7 @@ int16 scriptActorSetScavengable(int16 *args) {
OBJLOG(SetScavengable);
((GameObject *)thisThread->thisObject)->setFlags(
args[0 ] ? (int16) 0xffff : (int16) 0,
- GameObject::objectScavengable);
+ objectScavengable);
return 0;
}
Commit: 4319fd55f554d0d5324ca3fb1fe241e13ffbe7a4
https://github.com/scummvm/scummvm/commit/4319fd55f554d0d5324ca3fb1fe241e13ffbe7a4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:48+02:00
Commit Message:
SAGA2: Fix more warnings
Changed paths:
engines/saga2/button.cpp
engines/saga2/button.h
engines/saga2/msgbox.cpp
engines/saga2/property.h
engines/saga2/uidialog.cpp
engines/saga2/uidialog.h
diff --git a/engines/saga2/button.cpp b/engines/saga2/button.cpp
index bc3c1976af..daf59f8c19 100644
--- a/engines/saga2/button.cpp
+++ b/engines/saga2/button.cpp
@@ -101,7 +101,7 @@ gCompImage::gCompImage(gPanelList &list,
resContext = NULL;
}
-gCompImage::gCompImage(gPanelList &list, const Rect16 &box, void *image, char *text, textPallete &pal, uint16 ident,
+gCompImage::gCompImage(gPanelList &list, const Rect16 &box, void *image, const char *text, textPallete &pal, uint16 ident,
AppFunc *cmd) : gControl(list, box, text, ident, cmd) {
// setup a single image configuration
init();
@@ -150,7 +150,7 @@ gCompImage::gCompImage(gPanelList &list, const Rect16 &box, void **images,
}
gCompImage::gCompImage(gPanelList &list, const Rect16 &box, void **images,
- int16 numRes, int16 initial, char *text, textPallete &pal,
+ int16 numRes, int16 initial, const char *text, textPallete &pal,
uint16 ident, AppFunc *cmd) : gControl(list, box, text, ident, cmd) {
init();
@@ -423,7 +423,7 @@ gCompButton::gCompButton(gPanelList &list, const Rect16 &box, void **images, int
extent = box;
}
-gCompButton::gCompButton(gPanelList &list, const Rect16 &box, void **images, int16 numRes, char *text, textPallete &pal, uint16 ident,
+gCompButton::gCompButton(gPanelList &list, const Rect16 &box, void **images, int16 numRes, const char *text, textPallete &pal, uint16 ident,
AppFunc *cmd) : gCompImage(list, box, NULL, 0, 0, text, pal, ident, cmd) {
if (images[ 0 ] && images[ 1 ] && numRes == 2) {
forImage = images[ 0 ];
diff --git a/engines/saga2/button.h b/engines/saga2/button.h
index ea4b6ca163..d8b8fd63b3 100644
--- a/engines/saga2/button.h
+++ b/engines/saga2/button.h
@@ -102,14 +102,14 @@ public:
gCompImage(gPanelList &, const Rect16 &, void *, uint16, AppFunc *cmd = NULL);
- gCompImage(gPanelList &, const Rect16 &, void *, char *,
+ gCompImage(gPanelList &, const Rect16 &, void *, const char *,
textPallete &, uint16, AppFunc *cmd = NULL);
gCompImage(gPanelList &, const Rect16 &, void **, int16, int16,
uint16, AppFunc *cmd = NULL);
gCompImage(gPanelList &, const Rect16 &, void **, int16, int16,
- char *, textPallete &, uint16, AppFunc *cmd = NULL);
+ const char *, textPallete &, uint16, AppFunc *cmd = NULL);
gCompImage(gPanelList &list,
const Rect16 &box,
@@ -209,7 +209,7 @@ public:
uint16, AppFunc *cmd = NULL);
gCompButton(gPanelList &, const Rect16 &, void **, int16,
- char *, textPallete &, uint16, AppFunc *cmd = NULL);
+ const char *, textPallete &, uint16, AppFunc *cmd = NULL);
gCompButton(gPanelList &, const Rect16 &, void **, int16, void *, bool,
uint16, AppFunc *cmd = NULL);
diff --git a/engines/saga2/msgbox.cpp b/engines/saga2/msgbox.cpp
index 9931332262..85c40d967c 100644
--- a/engines/saga2/msgbox.cpp
+++ b/engines/saga2/msgbox.cpp
@@ -76,9 +76,7 @@ inline Rect16 butBox(int n, int i) {
* ===================================================================== */
bool userDialogAvailable(void);
-int16 userDialog(const char *title, char *msg, char *btnMsg1,
- char *btnMsg2,
- char *btnMsg3);
+int16 userDialog(const char *title, const char *msg, const char *btnMsg1, const char *btnMsg2, const char *btnMsg3);
// ------------------------------------------------------------------------
// Wrapper to avoid errors
diff --git a/engines/saga2/property.h b/engines/saga2/property.h
index fbcb9b47c8..1dcdc5c981 100644
--- a/engines/saga2/property.h
+++ b/engines/saga2/property.h
@@ -309,6 +309,7 @@ struct MetaTile;
class MetaTileProperty {
public:
+ virtual ~MetaTileProperty() {}
virtual bool operator()(
MetaTile *mt,
int16 mapNum,
@@ -329,6 +330,8 @@ public:
propertyFunc(func) {
}
+ virtual ~SimpleMetaTileProperty() {}
+
bool operator()(
MetaTile *mt,
int16 mapNum,
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index bcfd3929aa..afdeb783fd 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -803,7 +803,7 @@ void updateAllUserControls(void);
int16 OptionsDialog(bool disableSaveResume) {
// text for dialog
- char *btnStrings[ numOptionsBtns ] = { { OPTN_DIALOG_BUTTON1 },
+ const char *btnStrings[ numOptionsBtns ] = { { OPTN_DIALOG_BUTTON1 },
{ OPTN_DIALOG_BUTTON2 },
{ OPTN_DIALOG_BUTTON3 },
{ OPTN_DIALOG_BUTTON4 },
@@ -811,7 +811,7 @@ int16 OptionsDialog(bool disableSaveResume) {
};
- char *textStrings[ numOptionsTexts ] = { { OPTN_DIALOG_NAME },
+ const char *textStrings[ numOptionsTexts ] = { { OPTN_DIALOG_NAME },
{ OPTN_DIALOG_SLIDE1 },
{ OPTN_DIALOG_SLIDE2 },
{ OPTN_DIALOG_SLIDE3 },
@@ -998,7 +998,7 @@ int16 OptionsDialog(bool disableSaveResume) {
message dialog box
* ===================================================================== */
-char stripAccel(char *t, char *s) {
+char stripAccel(char *t, const char *s) {
char accel = '\0';
char *underscore;
@@ -1074,9 +1074,9 @@ void cleanupUserDialog(void) {
}
-int16 userDialog(const char *title, char *msg, char *bMsg1,
- char *bMsg2,
- char *bMsg3) {
+int16 userDialog(const char *title, const char *msg, const char *bMsg1,
+ const char *bMsg2,
+ const char *bMsg3) {
const maxBtns = 3;
uint8 numBtns = 0;
@@ -1167,9 +1167,9 @@ bool userDialogAvailable(void) {
}
void cleanupUserDialog(void) {}
-int16 userDialog(const char *title, char *msg, char *bMsg1,
- char *bMsg2,
- char *bMsg3) {
+int16 userDialog(const char *title, const char *msg, const char *bMsg1,
+ const char *bMsg2,
+ const char *bMsg3) {
const int maxBtns = 3;
uint8 numBtns = 0;
@@ -1411,7 +1411,7 @@ void CPlacardWindow::drawClipped(
}
}
-CPlacardPanel::CPlacardPanel(gPanelList &gpl, const Rect16 &r, char *t, gFont *f,
+CPlacardPanel::CPlacardPanel(gPanelList &gpl, const Rect16 &r, const char *t, gFont *f,
int16 i, textPallete &p, int16 i2, AppFunc *cmd) :
CPlaqText(gpl, r, t, f, i, p, i2, cmd) {
@@ -1420,9 +1420,7 @@ CPlacardPanel::CPlacardPanel(gPanelList &gpl, const Rect16 &r, char *t, gFont *f
-void CPlacardPanel::positionText(
- char *windowText,
- const Rect16 &textArea) {
+void CPlacardPanel::positionText(const char *windowText, const Rect16 &textArea) {
if (windowText) {
int16 i,
yPos,
diff --git a/engines/saga2/uidialog.h b/engines/saga2/uidialog.h
index 69f85f7ee5..cb29aa3acd 100644
--- a/engines/saga2/uidialog.h
+++ b/engines/saga2/uidialog.h
@@ -57,9 +57,9 @@ int16 OptionsDialog(bool disableSaveResume = FALSE);
void initFileFields(char **fieldStrings);
char **destroyFileFields(void);
bool getSaveName(int8 saveNo, SaveFileHeader &header);
-int16 userDialog(const char *title, char *msg, char *btnMsg1,
- char *btnMsg2,
- char *btnMsg3);
+int16 userDialog(const char *title, const char *msg, const char *btnMsg1,
+ const char *btnMsg2,
+ const char *btnMsg3);
void placardWindow(int8 type, char *text);
@@ -126,9 +126,7 @@ class CPlacardPanel : public CPlaqText {
char *titleStrings[ maxLines ];
char titleBuf[ maxText ];
- void positionText(
- char *windowText,
- const Rect16 &textArea);
+ void positionText(const char *windowText, const Rect16 &textArea);
int16 SplitString(
char *text,
@@ -136,7 +134,7 @@ class CPlacardPanel : public CPlaqText {
int16 maxStrings,
char delimiter);
public:
- CPlacardPanel(gPanelList &, const Rect16 &, char *, gFont *,
+ CPlacardPanel(gPanelList &, const Rect16 &, const char *, gFont *,
int16, textPallete &, int16, AppFunc *cmd = NULL);
void drawClipped(gPort &,
Commit: 8d5c31359e136e9172a5faf7e8a87fb7846a5652
https://github.com/scummvm/scummvm/commit/8d5c31359e136e9172a5faf7e8a87fb7846a5652
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:48+02:00
Commit Message:
SAGA2: Blit test image to screen
Changed paths:
engines/saga2/playmode.cpp
engines/saga2/saga2.cpp
diff --git a/engines/saga2/playmode.cpp b/engines/saga2/playmode.cpp
index 0e24d1191d..4954235d56 100644
--- a/engines/saga2/playmode.cpp
+++ b/engines/saga2/playmode.cpp
@@ -44,6 +44,7 @@
#include "saga2/testmap.h"
#include "saga2/cmisc.h"
#include "saga2/button.h"
+#include "graphics/surface.h"
namespace Saga2 {
@@ -338,6 +339,12 @@ void drawCompressedImage(gPort &port, const Point16 pos, void *image) {
map.data = (uint8 *)malloc(map.bytes());
if (map.data == NULL) return;
unpackImage(&map, map.size.x, map.size.y, hdr->data);
+
+ Graphics::Surface sur;
+ sur.create(map.size.x, map.size.y, Graphics::PixelFormat::createFormatCLUT8());
+ sur.setPixels(map.data);
+ sur.debugPrint();
+ g_system->copyRectToScreen(sur.getPixels(), sur.pitch, 0, 0, sur.w, sur.h);
} else map.data = (uint8 *)hdr->data;
port.setMode(drawModeMatte);
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index d13eed7bb2..9fb2fc2788 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -77,10 +77,6 @@ Common::Error Saga2Engine::run() {
// Additional setup.
debug("Saga2Engine::init");
- if (openResources()) {
- openImageTest();
- }
-
// Your main even loop should be (invoked from) here.
debug("Saga2Engine::go: Hello, World!");
@@ -88,6 +84,10 @@ Common::Error Saga2Engine::run() {
loadingScreen();
+ if (openResources()) {
+ openImageTest();
+ }
+
// Simple main event loop
Common::Event evt;
while (!shouldQuit()) {
Commit: 0ad7e918d912e7a7cc91d2146bb1378abad308bd
https://github.com/scummvm/scummvm/commit/0ad7e918d912e7a7cc91d2146bb1378abad308bd
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:48+02:00
Commit Message:
SAGA2: Fix gPort initialization
Changed paths:
engines/saga2/gdraw.h
diff --git a/engines/saga2/gdraw.h b/engines/saga2/gdraw.h
index 75dfe8bb84..f6bdacb310 100644
--- a/engines/saga2/gdraw.h
+++ b/engines/saga2/gdraw.h
@@ -189,7 +189,15 @@ public:
// Constructor
gPort(void) {
- memset(&map, 0, sizeof(gPort));
+ map = nullptr;
+ baseRow = nullptr;
+
+ rowMod = 0;
+ penMap = nullptr;
+ drawMode = drawModeMatte;
+ font = nullptr;
+ textSpacing = 0;
+ textStyles = 0;
}
virtual ~gPort() {}
Commit: ac551e3c2423f5e74c56abf2d399033cf3de4c45
https://github.com/scummvm/scummvm/commit/ac551e3c2423f5e74c56abf2d399033cf3de4c45
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:49+02:00
Commit Message:
SAGA2: Fix formatting for unpackImage()
Changed paths:
engines/saga2/blitters.cpp
engines/saga2/saga2.cpp
diff --git a/engines/saga2/blitters.cpp b/engines/saga2/blitters.cpp
index 9f8f044637..40b45d3185 100644
--- a/engines/saga2/blitters.cpp
+++ b/engines/saga2/blitters.cpp
@@ -49,33 +49,33 @@ void _HLine(uint8 *dstPtr, uint32 width, uint32 color) {
}
void unpackImage(gPixelMap &map, int16 width, int16 rowCount, int8 *srcData) {
- int8 *dest = (int8 *)map.data;
- int16 bytecount = (width + 1) & ~1;
- int16 rowMod = map.size.x - bytecount;
-
- while (rowCount--)
- {
- for (int16 k = 0; k < bytecount;)
- {
- int16 p = *srcData++;
-
- if (p == -128) ;
- else if (p >= 0)
- {
+ int8 *dest = (int8 *)map.data;
+ int16 bytecount = (width + 1) & ~1;
+ int16 rowMod = map.size.x - bytecount;
+
+ while (rowCount--) {
+ for (int16 k = 0; k < bytecount;) {
+ int16 p = *srcData++;
+
+ if (p == -128)
+ continue;
+ else if (p >= 0) {
p++;
k += p;
- while (p--) *dest++ = *srcData++;
+ while (p--)
+ *dest++ = *srcData++;
}
- else
- {
+ else {
p = 1 - p;
k += p;
- while (p--) *dest++ = *srcData;
+ while (p--)
+ *dest++ = *srcData;
srcData++;
}
}
- if (bytecount & 1) srcData++;
+ if (bytecount & 1)
+ srcData++;
dest += rowMod;
}
}
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index 9fb2fc2788..f34eed8809 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -84,9 +84,8 @@ Common::Error Saga2Engine::run() {
loadingScreen();
- if (openResources()) {
+ if (openResources())
openImageTest();
- }
// Simple main event loop
Common::Event evt;
Commit: 5eadf11a37418a8005a0ec1f982c3f402d425ac3
https://github.com/scummvm/scummvm/commit/5eadf11a37418a8005a0ec1f982c3f402d425ac3
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:49+02:00
Commit Message:
SAGA2: Fix more formatting
Changed paths:
engines/saga2/blitters.cpp
engines/saga2/playmode.cpp
diff --git a/engines/saga2/blitters.cpp b/engines/saga2/blitters.cpp
index 40b45d3185..afd65d230d 100644
--- a/engines/saga2/blitters.cpp
+++ b/engines/saga2/blitters.cpp
@@ -64,8 +64,7 @@ void unpackImage(gPixelMap &map, int16 width, int16 rowCount, int8 *srcData) {
k += p;
while (p--)
*dest++ = *srcData++;
- }
- else {
+ } else {
p = 1 - p;
k += p;
while (p--)
diff --git a/engines/saga2/playmode.cpp b/engines/saga2/playmode.cpp
index 4954235d56..b166bec3b1 100644
--- a/engines/saga2/playmode.cpp
+++ b/engines/saga2/playmode.cpp
@@ -337,7 +337,9 @@ void drawCompressedImage(gPort &port, const Point16 pos, void *image) {
if (hdr->compress) {
map.data = (uint8 *)malloc(map.bytes());
- if (map.data == NULL) return;
+ if (map.data == NULL)
+ return;
+
unpackImage(&map, map.size.x, map.size.y, hdr->data);
Graphics::Surface sur;
@@ -345,14 +347,16 @@ void drawCompressedImage(gPort &port, const Point16 pos, void *image) {
sur.setPixels(map.data);
sur.debugPrint();
g_system->copyRectToScreen(sur.getPixels(), sur.pitch, 0, 0, sur.w, sur.h);
- } else map.data = (uint8 *)hdr->data;
+ } else
+ map.data = (uint8 *)hdr->data;
port.setMode(drawModeMatte);
port.bltPixels(map, 0, 0,
pos.x, pos.y,
map.size.x, map.size.y);
- if (hdr->compress) free(map.data);
+ if (hdr->compress)
+ free(map.data);
}
void drawCompressedImageGhosted(gPort &port, const Point16 pos, void *image) {
Commit: f8024e73ccfd1dbd5e6232dd0c30a7ddd4a64a4e
https://github.com/scummvm/scummvm/commit/f8024e73ccfd1dbd5e6232dd0c30a7ddd4a64a4e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:49+02:00
Commit Message:
SAGA2: More warning fixes
Changed paths:
engines/saga2/grabinfo.cpp
engines/saga2/grabinfo.h
engines/saga2/tilemode.cpp
diff --git a/engines/saga2/grabinfo.cpp b/engines/saga2/grabinfo.cpp
index 10cc5361fb..d1396bdebe 100644
--- a/engines/saga2/grabinfo.cpp
+++ b/engines/saga2/grabinfo.cpp
@@ -325,7 +325,7 @@ void GrabInfo::replaceObject(void) {
// This function is called to request a new mouse text string. If there
// is currently no grabbed object the text will be displayed, else the
// text pointer will simply be saved.
-void GrabInfo::setText(char *txt) {
+void GrabInfo::setText(const char *txt) {
if ((txt != NULL) && strlen(txt)) {
strncpy(textBuf, txt, bufSize);
textBuf[ bufSize - 1 ] = '\0';
diff --git a/engines/saga2/grabinfo.h b/engines/saga2/grabinfo.h
index ab9e50ff8d..9bf46551e5 100644
--- a/engines/saga2/grabinfo.h
+++ b/engines/saga2/grabinfo.h
@@ -141,7 +141,7 @@ public:
void replaceObject(void);
// request a change to the mouse cursor text
- void setText(char *txt);
+ void setText(const char *txt);
// request a change to the mouse gauge
void setGauge(int16 numerator, int16 denominator);
diff --git a/engines/saga2/tilemode.cpp b/engines/saga2/tilemode.cpp
index 60a9bdf7c5..5ad23eba4f 100644
--- a/engines/saga2/tilemode.cpp
+++ b/engines/saga2/tilemode.cpp
@@ -547,7 +547,7 @@ static void evalMouseState(void) {
// intention to walk to the actor, else
// set the intention to pick up the object
if (isActor(pickedObject)) {
- Actor *a = (Actor *)obj;
+ a = (Actor *)obj;
mouseInfo.setIntent(
!a->isDead()
@@ -580,7 +580,7 @@ static void evalMouseState(void) {
if (mousePressed
&& !clickActionDone
&& mouseInfo.getObject() == NULL) {
- Actor *a = getCenterActor();
+ a = getCenterActor();
// Since the mouse is being dragged, initiate
// the effects of the mouse drag
@@ -670,24 +670,15 @@ void loadTileModeState(SaveFileReader &saveGame) {
// Initialize the Tile mode
void TileModeSetup(void) {
-
- GameObject *viewActor;
-
// Load in decorative panels for the main window (for this mode)
- mainWindow->setDecorations(mainWindowDecorations,
- elementsof(mainWindowDecorations),
- imageRes);
+ mainWindow->setDecorations(mainWindowDecorations, elementsof(mainWindowDecorations), imageRes);
// Test to draw borders.
// REM: We should actually have a routine to refresh the window...
mainWindow->draw();
// Create a control covering the map area.
- tileMapControl = new gStickyDragControl(*playControls,
- tileRect,
- 0,
- cmdClickTileMap);
- checkAlloc(tileMapControl);
+ tileMapControl = new gStickyDragControl(*playControls, tileRect, 0, cmdClickTileMap);
//Enable Tile Mode Specific Controls
tileControls->enable(TRUE);
@@ -886,12 +877,8 @@ void TileModeHandleTask(void) {
mouseInfo.setText(cursorText);
if (isActor(pickedObject)) {
- Actor *a;
-
a = (Actor *)GameObject::objectAddress(pickedObject);
- mouseInfo.setGauge(
- a->getStats()->vitality,
- a->getBaseStats()->vitality);
+ mouseInfo.setGauge(a->getStats()->vitality, a->getBaseStats()->vitality);
} else {
mouseInfo.clearGauge();
}
@@ -953,7 +940,7 @@ void TileModeHandleKey(int16 key, int16 qual) {
Actor *a = getCenterActor();
Location l(a->getLocation(), a->IDParent());
- GameObject *object = (GameObject *)getCenterActor();
+ //GameObject *object = (GameObject *)getCenterActor();
lastUnusedKey = '\0';
//This is for moving center actor in cardinal directions
@@ -1269,7 +1256,7 @@ static APPFUNC(cmdClickTileMap) {
}
}
} else if (pickedObject != Nothing) {
- GameObject *obj = GameObject::objectAddress(pickedObject);
+ //GameObject *obj = GameObject::objectAddress(pickedObject);
if (mouseInfo.getDoable()) {
PlayerActorID pID;
@@ -1403,13 +1390,16 @@ static APPFUNC(cmdClickTileMap) {
mousePressed = TRUE;
}
break;
+
+ default:
+ break;
}
}
//-----------------------------------------------------------------------
// Sets up a motion task for the main character.
-void navigateDirect(TilePoint pick, bool runFlag) {
+void navigateDirect(TilePoint pick, bool runFlag_) {
Actor *a = getCenterActor(); // addr of actor we control
if (a) {
@@ -1417,7 +1407,7 @@ void navigateDirect(TilePoint pick, bool runFlag) {
// REM: Do running here...
- MotionTask::walkToDirect(*a, pick, runFlag, FALSE);
+ MotionTask::walkToDirect(*a, pick, runFlag_, FALSE);
}
}
Commit: cda89805f18cc0f40cbc4095c35ba3706a68b0d6
https://github.com/scummvm/scummvm/commit/cda89805f18cc0f40cbc4095c35ba3706a68b0d6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:49+02:00
Commit Message:
SAGA2: Fix more warnings
Changed paths:
engines/saga2/uidialog.cpp
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index afdeb783fd..d620a97cf1 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -634,25 +634,19 @@ int16 FileDialog(int16 fileProcess) {
char **fieldStrings;
uint16 stringIndex;
bool displayOnly;
- void **arrowUpIm = NULL,
- **arrowDnIm = NULL,
- **pushBtnIm = NULL;
+ void **arrowUpIm = NULL, **arrowDnIm = NULL, **pushBtnIm = NULL;
AppFunc *fileCommands[ 2 ] = { { cmdFileSave }, { cmdFileLoad } };
// text for dialog
- char *saveTextStrings[ numSaveLoadTexts ] = { { SAVE_DIALOG_NAME } };
- char *saveBtnStrings[ numSaveLoadBtns ] = { { SAVE_DIALOG_BUTTON1 },
- { SAVE_DIALOG_BUTTON2 }
- };
+ const char *saveTextStrings[numSaveLoadTexts] = { SAVE_DIALOG_NAME };
+ const char *saveBtnStrings[numSaveLoadBtns] = { SAVE_DIALOG_BUTTON1, SAVE_DIALOG_BUTTON2 };
- char *loadTextStrings[ numSaveLoadTexts ] = { { LOAD_DIALOG_NAME } };
- char *loadBtnStrings[ numSaveLoadBtns ] = { { LOAD_DIALOG_BUTTON1 },
- { LOAD_DIALOG_BUTTON2 }
- };
+ const char *loadTextStrings[numSaveLoadTexts] = { LOAD_DIALOG_NAME };
+ const char *loadBtnStrings[numSaveLoadBtns] = { LOAD_DIALOG_BUTTON1, LOAD_DIALOG_BUTTON2 };
- char **textStrings[] = { saveTextStrings, loadTextStrings };
- char **btnStrings[] = { saveBtnStrings, loadBtnStrings };
+ const char **textStrings[] = { saveTextStrings, loadTextStrings };
+ const char **btnStrings[] = { saveBtnStrings, loadBtnStrings };
// make the text coloring object
@@ -803,26 +797,28 @@ void updateAllUserControls(void);
int16 OptionsDialog(bool disableSaveResume) {
// text for dialog
- const char *btnStrings[ numOptionsBtns ] = { { OPTN_DIALOG_BUTTON1 },
- { OPTN_DIALOG_BUTTON2 },
- { OPTN_DIALOG_BUTTON3 },
- { OPTN_DIALOG_BUTTON4 },
- { OPTN_DIALOG_BUTTON5 }
+ const char *btnStrings[numOptionsBtns] = {
+ OPTN_DIALOG_BUTTON1,
+ OPTN_DIALOG_BUTTON2,
+ OPTN_DIALOG_BUTTON3,
+ OPTN_DIALOG_BUTTON4,
+ OPTN_DIALOG_BUTTON5
};
- const char *textStrings[ numOptionsTexts ] = { { OPTN_DIALOG_NAME },
- { OPTN_DIALOG_SLIDE1 },
- { OPTN_DIALOG_SLIDE2 },
- { OPTN_DIALOG_SLIDE3 },
- { OPTN_DIALOG_CHECK1 },
- { OPTN_DIALOG_CHECK2 },
- { OPTN_DIALOG_CHECK3 },
- { OPTN_DIALOG_CHECK4 }
+ const char *textStrings[numOptionsTexts] = {
+ OPTN_DIALOG_NAME,
+ OPTN_DIALOG_SLIDE1,
+ OPTN_DIALOG_SLIDE2,
+ OPTN_DIALOG_SLIDE3,
+ OPTN_DIALOG_CHECK1,
+ OPTN_DIALOG_CHECK2,
+ OPTN_DIALOG_CHECK3,
+ OPTN_DIALOG_CHECK4
};
// make the text coloring object
- textPallete pal(33 + 9, 36 + 9, 41 + 9, 34 + 9, 40 + 9, 43 + 9);
+ textPallete pal(33 + 9, 36 + 9, 41 + 9, 34 + 9, 40 + 9, 43 + 9);
// requester info struct
requestInfo rInfo;
@@ -1597,7 +1593,7 @@ void placardWindow(int8 type, char *text) {
break;
default:
- // no code
+ error("Unhandled placard type %d", type);
break;
}
Commit: a2a6c82bc22f798d8005db5f469ae573ecc956aa
https://github.com/scummvm/scummvm/commit/a2a6c82bc22f798d8005db5f469ae573ecc956aa
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:49+02:00
Commit Message:
SAGA2: Fix more warnings
Changed paths:
engines/saga2/audio.cpp
engines/saga2/audiomem.h
engines/saga2/gtextbox.cpp
engines/saga2/gtextbox.h
engines/saga2/uidialog.cpp
diff --git a/engines/saga2/audio.cpp b/engines/saga2/audio.cpp
index e836f8386a..64d48b2928 100644
--- a/engines/saga2/audio.cpp
+++ b/engines/saga2/audio.cpp
@@ -37,11 +37,9 @@ void cleanupAudio() {
warning("STUB: cleanupAudio()");
}
-void *audioAlloc(size_t s, char desc[])
-{
+void *audioAlloc(size_t s, const char desc[]) {
warning("STUB: audioAlloc()");
- return nullptr;
- //return malloc(s);
+ return malloc(s);
}
void audioFree(void *mem)
diff --git a/engines/saga2/audiomem.h b/engines/saga2/audiomem.h
index 9a04834dd5..1961c5d471 100644
--- a/engines/saga2/audiomem.h
+++ b/engines/saga2/audiomem.h
@@ -34,7 +34,7 @@ namespace Saga2{
Memory alloc/free
* ===================================================================== */
-void *audioAlloc(size_t s, char []);
+void *audioAlloc(size_t s, const char[]);
void audioFree(void *mem);
#define audionew( s ) (( s* )audioAlloc( sizeof( s )))
diff --git a/engines/saga2/gtextbox.cpp b/engines/saga2/gtextbox.cpp
index 06d035e6d7..0da11b839e 100644
--- a/engines/saga2/gtextbox.cpp
+++ b/engines/saga2/gtextbox.cpp
@@ -161,8 +161,8 @@ gTextBox::gTextBox(
int8 HLColor,
int8 BGHLColor,
int8 CRColor,
- char *title,
- char *buffer,
+ const char *title,
+ const char *buffer,
char **stringBufs,
uint16 length,
uint16 flg,
diff --git a/engines/saga2/gtextbox.h b/engines/saga2/gtextbox.h
index b9faea0946..1159fab1f7 100644
--- a/engines/saga2/gtextbox.h
+++ b/engines/saga2/gtextbox.h
@@ -159,7 +159,7 @@ protected:
public:
- gTextBox(gPanelList &list, // window
+ gTextBox(gPanelList &list, // window
const Rect16 &box, // rectangle
gFont *font, // font specified for this box
int8 height, // height of the font
@@ -168,8 +168,8 @@ public:
int8 HLColor, // hilite color of font
int8 BGHLColor, // back ground hilite color
int8 CRColor, // cusor color
- char *title, // title bar
- char *buffer, // buffer to edit
+ const char *title, // title bar
+ const char *buffer, // buffer to edit
char **stringBufs,
uint16 length, // length of buffer
uint16 flg, // various flags
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index d620a97cf1..1f7648336f 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -283,7 +283,7 @@ const int pushButtonWidth = 121;
const int pushButtonHeight = 30;
const int sliderWidth = 168;
-const int sliderHeight = 15;
+//const int sliderHeight = 15;
const int imageHeight = 17;
const int textPixelLen = 175;
@@ -630,13 +630,13 @@ bool getSaveName(int8 saveNo, SaveFileHeader &header) {
* ===================================================================== */
int16 FileDialog(int16 fileProcess) {
- const int strLen = editLen;
+ //const int strLen = editLen;
char **fieldStrings;
uint16 stringIndex;
bool displayOnly;
void **arrowUpIm = NULL, **arrowDnIm = NULL, **pushBtnIm = NULL;
- AppFunc *fileCommands[ 2 ] = { { cmdFileSave }, { cmdFileLoad } };
+ AppFunc *fileCommands[2] = { cmdFileSave, cmdFileLoad };
// text for dialog
const char *saveTextStrings[numSaveLoadTexts] = { SAVE_DIALOG_NAME };
@@ -1166,7 +1166,7 @@ void cleanupUserDialog(void) {}
int16 userDialog(const char *title, const char *msg, const char *bMsg1,
const char *bMsg2,
const char *bMsg3) {
- const int maxBtns = 3;
+ //const int maxBtns = 3;
uint8 numBtns = 0;
char k1, k2, k3;
@@ -1314,7 +1314,7 @@ void CPlacardWindow::positionText(
int16 fontHeight = textFont->height;
// make a copy of the window text string
- sprintf(titleBuf, windowText);
+ sprintf(titleBuf, "%s", windowText);
// break up the title text string
titleCount = SplitString(titleBuf, titleStrings, maxLines, '\n');
@@ -1425,7 +1425,7 @@ void CPlacardPanel::positionText(const char *windowText, const Rect16 &textArea)
int16 fontHeight = buttonFont->height;
// make a copy of the window text string
- sprintf(titleBuf, windowText);
+ sprintf(titleBuf, "%s", windowText);
// break up the title text string
titleCount = SplitString(titleBuf, titleStrings, maxLines, '\n');
Commit: 36ead351f1716133a13eccff85f4061ed8f63867
https://github.com/scummvm/scummvm/commit/36ead351f1716133a13eccff85f4061ed8f63867
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:49+02:00
Commit Message:
SAGA2: Fix incorrect change
Changed paths:
engines/saga2/calender.cpp
diff --git a/engines/saga2/calender.cpp b/engines/saga2/calender.cpp
index 9ef9ecc08a..c581c61595 100644
--- a/engines/saga2/calender.cpp
+++ b/engines/saga2/calender.cpp
@@ -127,7 +127,7 @@ int CalenderTime::lightLevel(int maxLevel) {
// to framesAtNoon*2/3. Then we clip off the part of the
// curve below zero, and above 1/3, giving 1/3 night,
// 1/6 morning, 1/3 day, and 1/6 evening.
- solarLevel = CLIP(globalConfig.showNight ? /* 0 */ (dayBias * 5 / 4) : (framesAtNoon / 3),
+ solarLevel = clamp(globalConfig.showNight ? /* 0 */ (dayBias * 5 / 4) : (framesAtNoon / 3),
solarAngle * 2 + season - framesAtNoon / 3 + dayBias * 2,
framesAtNoon / 3);
Commit: 177aa929005618d9bf32975811d264827d5e6a22
https://github.com/scummvm/scummvm/commit/177aa929005618d9bf32975811d264827d5e6a22
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:49+02:00
Commit Message:
SAGA2: Replace custom assert macros
Changed paths:
R engines/saga2/verify.cpp
engines/saga2/actor.cpp
engines/saga2/actor.h
engines/saga2/assign.cpp
engines/saga2/audiobuf.cpp
engines/saga2/audiores.cpp
engines/saga2/automap.cpp
engines/saga2/band.cpp
engines/saga2/band.h
engines/saga2/calender.cpp
engines/saga2/contain.cpp
engines/saga2/dispnode.cpp
engines/saga2/effects.cpp
engines/saga2/effects.h
engines/saga2/enchant.cpp
engines/saga2/floating.cpp
engines/saga2/gamerate.h
engines/saga2/gpointer.cpp
engines/saga2/grabinfo.cpp
engines/saga2/interp.cpp
engines/saga2/intrface.cpp
engines/saga2/itevideo.cpp
engines/saga2/magic.cpp
engines/saga2/mission.cpp
engines/saga2/module.mk
engines/saga2/motion.cpp
engines/saga2/mouseimg.cpp
engines/saga2/noise.cpp
engines/saga2/objects.cpp
engines/saga2/objects.h
engines/saga2/objproto.cpp
engines/saga2/oncall.h
engines/saga2/panel.cpp
engines/saga2/path.cpp
engines/saga2/patrol.cpp
engines/saga2/player.cpp
engines/saga2/player.h
engines/saga2/playmode.cpp
engines/saga2/property.cpp
engines/saga2/property.h
engines/saga2/sagafunc.cpp
engines/saga2/savefile.cpp
engines/saga2/sensor.cpp
engines/saga2/speech.cpp
engines/saga2/spelcast.cpp
engines/saga2/speldata.cpp
engines/saga2/speldefs.h
engines/saga2/speldraw.cpp
engines/saga2/spellio.cpp
engines/saga2/sprite.cpp
engines/saga2/std.h
engines/saga2/target.h
engines/saga2/task.cpp
engines/saga2/terrain.cpp
engines/saga2/tile.cpp
engines/saga2/tile.h
engines/saga2/tilemode.cpp
engines/saga2/tilevect.h
engines/saga2/timers.cpp
engines/saga2/tower.cpp
engines/saga2/video.cpp
engines/saga2/videobox.cpp
engines/saga2/vidsmk.cpp
engines/saga2/vpal.cpp
engines/saga2/weapons.cpp
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 46c6aca8fa..8bbd17b996 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -3230,7 +3230,7 @@ bool Actor::takeMana(ActorManaID i, int8 dMana) {
if (!isPlayerActor(this))
return TRUE;
#endif
- VERIFY(i >= manaIDRed && i <= manaIDViolet);
+ assert(i >= manaIDRed && i <= manaIDViolet);
if ((&effectiveStats.redMana)[i] < dMana)
return FALSE;
(&effectiveStats.redMana)[i] -= dMana;
@@ -3243,7 +3243,7 @@ bool Actor::hasMana(ActorManaID i, int8 dMana) {
if (!isPlayerActor(this))
return TRUE;
#endif
- VERIFY(i >= manaIDRed && i <= manaIDViolet);
+ assert(i >= manaIDRed && i <= manaIDViolet);
if ((&effectiveStats.redMana)[i] < dMana)
return FALSE;
return TRUE;
diff --git a/engines/saga2/actor.h b/engines/saga2/actor.h
index d260d06b86..c587a29e55 100644
--- a/engines/saga2/actor.h
+++ b/engines/saga2/actor.h
@@ -718,7 +718,7 @@ public:
// Allocate the assignment buffer for a new assignment
void *allocAssignment(size_t sz) {
- ASSERT(sz <= sizeof(assignmentBuf));
+ assert(sz <= sizeof(assignmentBuf));
if (!(flags & hasAssignment)) {
flags |= hasAssignment;
return &assignmentBuf;
@@ -915,7 +915,7 @@ public:
void disband(void);
bool inBandingRange(void) {
- ASSERT(leader != NULL);
+ assert(leader != NULL);
return leader->IDParent() == IDParent()
&& (leader->getLocation() - getLocation()).quickHDistance()
diff --git a/engines/saga2/assign.cpp b/engines/saga2/assign.cpp
index 20b27af7f6..8081627556 100644
--- a/engines/saga2/assign.cpp
+++ b/engines/saga2/assign.cpp
@@ -331,7 +331,7 @@ Task *PatrolRouteAssignment::getTask(TaskStack *ts) {
void HuntToBeNearLocationAssignment::initialize(
const Target &targ,
uint16 r) {
- ASSERT(targ.size() <= sizeof(targetMem));
+ assert(targ.size() <= sizeof(targetMem));
// Make a copy of the target
targ.clone(targetMem);
@@ -418,7 +418,7 @@ void HuntToBeNearActorAssignment::initialize(
const ActorTarget &at,
uint16 r,
bool trackFlag) {
- ASSERT(at.size() <= sizeof(targetMem));
+ assert(at.size() <= sizeof(targetMem));
// Copy the target
at.clone(targetMem);
@@ -524,7 +524,7 @@ void HuntToKillAssignment::initialize(
const ActorTarget &at,
bool trackFlag,
bool specificActorFlag) {
- ASSERT(at.size() <= sizeof(targetMem));
+ assert(at.size() <= sizeof(targetMem));
// Copy the target
at.clone(targetMem);
diff --git a/engines/saga2/audiobuf.cpp b/engines/saga2/audiobuf.cpp
index fbdb1b6b5a..2d62ca5848 100644
--- a/engines/saga2/audiobuf.cpp
+++ b/engines/saga2/audiobuf.cpp
@@ -61,7 +61,7 @@ extern audioInterface *audio;
/*******************************************************************/
Buffer::Buffer(size_t newSize) {
- VERIFY(newSize > 0);
+ assert(newSize > 0);
internallyAllocated = TRUE;
size = newSize;
@@ -77,7 +77,7 @@ Buffer::Buffer(size_t newSize) {
Buffer::~Buffer(void) {
if (internallyAllocated) {
- VERIFY(data[0]);
+ assert(data[0]);
audio_unlock(data[0], size);
audioFree(data[0]); //delete [] data[0];
data[0] = NULL;
@@ -113,8 +113,8 @@ cacheBuffer::~cacheBuffer(void) {
doubleBuffer::doubleBuffer(size_t newSize, audioInterface *sd, int16 newID)
: Buffer(newSize) {
if (sd && sd->enabled(volVoice)) {
- VERIFY(sd);
- //VERIFY( sd->dig );
+ assert(sd);
+ //assert( sd->dig );
bufID = newID;
fillBuffer = 0;
@@ -134,7 +134,7 @@ doubleBuffer::doubleBuffer(size_t newSize, audioInterface *sd, int16 newID)
}
doubleBuffer::~doubleBuffer(void) {
- VERIFY(ailSampleHandle);
+ assert(ailSampleHandle);
if (data[1]) {
audio_unlock(data[1], size);
audioFree(data[1]); //delete [] data[1];
@@ -152,8 +152,8 @@ doubleBuffer::~doubleBuffer(void) {
singleBuffer::singleBuffer(size_t newSize, audioInterface *sd, int16 newID)
: Buffer(newSize) {
if (sd && sd->enabled(volSound)) {
- VERIFY(sd);
- VERIFY(sd->dig);
+ assert(sd);
+ assert(sd->dig);
bufID = newID;
fillBuffer = 0;
@@ -170,7 +170,7 @@ singleBuffer::singleBuffer(size_t newSize, audioInterface *sd, int16 newID)
}
singleBuffer::~singleBuffer(void) {
- VERIFY(ailSampleHandle);
+ assert(ailSampleHandle);
if (ailSampleHandle) {
AIL_release_sample_handle(ailSampleHandle);
}
@@ -183,8 +183,8 @@ singleBuffer::~singleBuffer(void) {
musicBuffer::musicBuffer(size_t newSize, audioInterface *sd, int16 newID)
: Buffer(newSize) {
if (sd && sd->enabled(volMusic)) {
- VERIFY(sd);
- VERIFY(sd->mid);
+ assert(sd);
+ assert(sd->mid);
bufID = newID;
fillBuffer = 0;
@@ -198,7 +198,7 @@ musicBuffer::musicBuffer(size_t newSize, audioInterface *sd, int16 newID)
}
musicBuffer::~musicBuffer(void) {
- VERIFY(ailSampleHandle);
+ assert(ailSampleHandle);
if (ailSampleHandle) {
AIL_release_sequence_handle(ailSampleHandle);
}
@@ -213,14 +213,14 @@ musicBuffer::~musicBuffer(void) {
void workBuffer::shiftdown(int16 bufNo) {
long dif = size - (wSize + rSize);
- VERIFY(bufNo == 0);
- VERIFY(dif >= 0);
- VERIFY(dif <= (size - (rSize + wSize)));
- VERIFY(((char *)(data[bufNo]) + rSize) < ((char *) rData));
- VERIFY(dif > rSize);
- VERIFY(dif > wSize);
- VERIFY(data[bufNo]);
- VERIFY(rData);
+ assert(bufNo == 0);
+ assert(dif >= 0);
+ assert(dif <= (size - (rSize + wSize)));
+ assert(((char *)(data[bufNo]) + rSize) < ((char *) rData));
+ assert(dif > rSize);
+ assert(dif > wSize);
+ assert(data[bufNo]);
+ assert(rData);
if (dif > 0 && rSize > 0) {
char *tbuf = (char *) audioAlloc(rSize, "audio work buffer"); //new char[rSize];
@@ -258,7 +258,7 @@ void cacheBuffer::format(soundSample *) {
void doubleBuffer::format(soundSample *ss) {
if (audioSet == 0) {
- VERIFY(ailSampleHandle);
+ assert(ailSampleHandle);
AIL_init_sample(ailSampleHandle);
AIL_set_sample_type(ailSampleHandle, ss->format(), ss->flags());
AIL_set_sample_playback_rate(ailSampleHandle, ss->speed);
@@ -270,7 +270,7 @@ void doubleBuffer::format(soundSample *ss) {
}
void singleBuffer::format(soundSample *ss) {
- VERIFY(ailSampleHandle);
+ assert(ailSampleHandle);
AIL_init_sample(ailSampleHandle);
AIL_set_sample_type(ailSampleHandle, ss->format(), ss->flags());
AIL_set_sample_playback_rate(ailSampleHandle, ss->speed);
@@ -304,7 +304,7 @@ bool workBuffer::laden(void) {
// sound buffers need to find out from AIL whether a buffer is free
bool doubleBuffer::laden(void) {
- VERIFY(ailSampleHandle);
+ assert(ailSampleHandle);
if (-1 == washed())
return TRUE;
else if (targetSated)
@@ -313,7 +313,7 @@ bool doubleBuffer::laden(void) {
}
bool singleBuffer::laden(void) {
- VERIFY(ailSampleHandle);
+ assert(ailSampleHandle);
if (targetSated)
activate(0);
return (FALSE);
@@ -347,7 +347,7 @@ uint32 workBuffer::sample_status(void) {
uint32 doubleBuffer::sample_status(void) {
- VERIFY(ailSampleHandle);
+ assert(ailSampleHandle);
#if 0
int32 newPos = AIL_sample_position(ailSampleHandle);
if (targetPos == 0 || newPos >= targetPos) { //( newPos==lastPos && lastPos==distPos)
@@ -360,7 +360,7 @@ uint32 doubleBuffer::sample_status(void) {
}
uint32 singleBuffer::sample_status(void) {
- VERIFY(ailSampleHandle);
+ assert(ailSampleHandle);
return (AIL_sample_status(ailSampleHandle));
}
@@ -402,7 +402,7 @@ int16 workBuffer::washed(void) {
}
int16 doubleBuffer::washed(void) {
- VERIFY(ailSampleHandle);
+ assert(ailSampleHandle);
if (AILLOCated > -1) return AILLOCated;
AILLOCated = AIL_sample_buffer_ready(ailSampleHandle);
return AILLOCated;
@@ -428,7 +428,7 @@ int16 cacheBuffer::washed(void) {
/* */
void Buffer::gave(size_t dSize) {
- VERIFY(dSize <= wSize);
+ assert(dSize <= wSize);
wSize -= dSize;
rSize += dSize;
if (wSize)
@@ -437,7 +437,7 @@ void Buffer::gave(size_t dSize) {
}
void workBuffer::gave(size_t dSize) {
- VERIFY(dSize <= wSize);
+ assert(dSize <= wSize);
wSize -= dSize;
rSize += dSize;
if (wSize) {
@@ -449,22 +449,22 @@ void workBuffer::gave(size_t dSize) {
// when sound buffers get full they automatically trigger AIL
void doubleBuffer::gave(size_t dSize) {
- VERIFY(ailSampleHandle);
- VERIFY(dSize <= wSize);
+ assert(ailSampleHandle);
+ assert(dSize <= wSize);
wSize -= dSize;
rSize += dSize;
if (wSize) {
wData = (void *)(((char *) data[fillBuffer]) + (size - wSize));
} else {
- VERIFY(AILLOCated >= 0);
+ assert(AILLOCated >= 0);
play(AILLOCated);
activate(1 - fillBuffer);
}
}
void singleBuffer::gave(size_t dSize) {
- VERIFY(ailSampleHandle);
- VERIFY(dSize <= wSize);
+ assert(ailSampleHandle);
+ assert(dSize <= wSize);
lastRSize = rSize;
wSize -= dSize;
rSize += dSize;
@@ -476,8 +476,8 @@ void singleBuffer::gave(size_t dSize) {
}
void musicBuffer::gave(size_t dSize) {
- VERIFY(ailSampleHandle);
- VERIFY(dSize <= wSize);
+ assert(ailSampleHandle);
+ assert(dSize <= wSize);
wSize -= dSize;
rSize += dSize;
if (wSize) {
@@ -489,7 +489,7 @@ void musicBuffer::gave(size_t dSize) {
}
void cacheBuffer::gave(size_t dSize) {
- VERIFY(dSize <= wSize);
+ assert(dSize <= wSize);
wSize -= dSize;
rSize += dSize;
if (wSize) {
@@ -501,7 +501,7 @@ void cacheBuffer::gave(size_t dSize) {
// when work buffers get fully drained they reset themselves
void Buffer::took(size_t dSize) {
- VERIFY(dSize <= rSize);
+ assert(dSize <= rSize);
rSize -= dSize;
if (rSize > 0)
rData = (void *)(((char *) rData) + dSize);
@@ -510,7 +510,7 @@ void Buffer::took(size_t dSize) {
}
void workBuffer::took(size_t dSize) {
- VERIFY(dSize <= rSize);
+ assert(dSize <= rSize);
rSize -= dSize;
if (rSize > 0) {
rData = (void *)(((char *) rData) + dSize);
@@ -521,14 +521,14 @@ void workBuffer::took(size_t dSize) {
}
void doubleBuffer::took(size_t dSize) {
- VERIFY(dSize <= rSize);
+ assert(dSize <= rSize);
rSize -= dSize;
if (rSize > 0)
rData = (void *)(((char *) rData) + dSize);
}
void singleBuffer::took(size_t dSize) {
- VERIFY(dSize <= rSize);
+ assert(dSize <= rSize);
lastRSize = rSize;
rSize -= dSize;
if (rSize > 0)
@@ -536,14 +536,14 @@ void singleBuffer::took(size_t dSize) {
}
void musicBuffer::took(size_t dSize) {
- VERIFY(dSize <= rSize);
+ assert(dSize <= rSize);
rSize -= dSize;
if (rSize > 0)
rData = (void *)(((char *) rData) + dSize);
}
void cacheBuffer::took(size_t dSize) {
- VERIFY(dSize <= rSize);
+ assert(dSize <= rSize);
}
/*******************************************************************/
@@ -570,8 +570,8 @@ void workBuffer::fill(void) {
// sound buffers pass what they have to AIL
void doubleBuffer::fill(void) {
- VERIFY(ailSampleHandle);
- VERIFY(AILLOCated >= 0);
+ assert(ailSampleHandle);
+ assert(AILLOCated >= 0);
if (rSize) {
play(AILLOCated);
activate(1 - fillBuffer);
@@ -581,14 +581,14 @@ void doubleBuffer::fill(void) {
}
void singleBuffer::fill(void) {
- VERIFY(ailSampleHandle);
+ assert(ailSampleHandle);
if (rSize) {
play(0);
}
}
void musicBuffer::fill(void) {
- VERIFY(ailSampleHandle);
+ assert(ailSampleHandle);
play(0);
}
@@ -625,8 +625,8 @@ void doubleBuffer::abortsound(void) {
}
void doubleBuffer::release(void) {
- VERIFY(ailSampleHandle);
- VERIFY(rSize == 0);
+ assert(ailSampleHandle);
+ assert(rSize == 0);
if (washed() <= -1) {
if (sample_status() != SMP_STOPPED)
@@ -639,7 +639,7 @@ void doubleBuffer::release(void) {
AIL_end_sample(ailSampleHandle);
audioSet = 0;
audio->resetState((audioInterface::BufferRequest) ID());
- VERIFY(AILLOCated == -1);
+ assert(AILLOCated == -1);
}
void singleBuffer::abortsound(void) {
@@ -650,11 +650,11 @@ void singleBuffer::abortsound(void) {
}
void singleBuffer::release(void) {
- VERIFY(ailSampleHandle);
- VERIFY(rSize == 0);
+ assert(ailSampleHandle);
+ assert(rSize == 0);
// AIL_end_sample( ailSampleHandle );
audioSet = 0;
- VERIFY(AILLOCated == -1);
+ assert(AILLOCated == -1);
}
void musicBuffer::abortsound(void) {
@@ -664,7 +664,7 @@ void musicBuffer::abortsound(void) {
}
void musicBuffer::release(void) {
- VERIFY(ailSampleHandle);
+ assert(ailSampleHandle);
// new
AIL_end_sequence(ailSampleHandle);
audioSet = 0;
@@ -686,13 +686,13 @@ void Buffer::play(int16) {
}
void workBuffer::play(int16 bufNo) {
- VERIFY(bufNo == 0);
+ assert(bufNo == 0);
took(rSize);
}
void doubleBuffer::play(int16 bufNo) {
- VERIFY(bufNo >= 0 && bufNo <= 1);
- VERIFY(ailSampleHandle);
+ assert(bufNo >= 0 && bufNo <= 1);
+ assert(ailSampleHandle);
targetPos = (int32)((char *) rData - (char *)data[AILLOCated]) + rSize;
AIL_load_sample_buffer(ailSampleHandle, AILLOCated, rData, rSize);
took(rSize);
@@ -700,8 +700,8 @@ void doubleBuffer::play(int16 bufNo) {
}
void singleBuffer::play(int16 bufNo) {
- VERIFY(bufNo == 0);
- VERIFY(ailSampleHandle);
+ assert(bufNo == 0);
+ assert(ailSampleHandle);
AIL_set_sample_address(ailSampleHandle, rData, rSize);
AIL_set_sample_loop_count(ailSampleHandle, loopCount);
AIL_start_sample(ailSampleHandle);
@@ -709,18 +709,18 @@ void singleBuffer::play(int16 bufNo) {
}
void singleBuffer::replay(void) {
- VERIFY(ailSampleHandle);
+ assert(ailSampleHandle);
rSize = lastRSize; //((uint8 *)rData)-((uint8 *)data[0]) ;
rData = data[0];
- VERIFY(rSize);
+ assert(rSize);
AIL_set_sample_address(ailSampleHandle, rData, rSize);
AIL_set_sample_loop_count(ailSampleHandle, loopCount);
AIL_start_sample(ailSampleHandle);
}
void musicBuffer::play(int16 bufNo) {
- VERIFY(bufNo == 0);
- VERIFY(ailSampleHandle);
+ assert(bufNo == 0);
+ assert(ailSampleHandle);
if (AIL_init_sequence(ailSampleHandle, rData, 0) <= 0) {
error("musicBuffer::play");
}
@@ -748,8 +748,8 @@ void Buffer::activate(int16) {
}
void workBuffer::activate(int16 bufNo) {
- VERIFY(bufNo == 0);
- VERIFY(rSize == 0);
+ assert(bufNo == 0);
+ assert(rSize == 0);
if (washed() > -1) {
fillBuffer = 0;
wSize = size;
@@ -761,7 +761,7 @@ void workBuffer::activate(int16 bufNo) {
void doubleBuffer::activate(int16 bufNo) {
int32 n;
- VERIFY(ailSampleHandle);
+ assert(ailSampleHandle);
n = bufNo;
if (washed() > -1) {
targetSated = FALSE;
@@ -782,7 +782,7 @@ void doubleBuffer::activate(int16 bufNo) {
void singleBuffer::activate(int16 bufNo) {
int32 n;
- VERIFY(ailSampleHandle);
+ assert(ailSampleHandle);
n = bufNo;
targetSated = FALSE;
fillBuffer = 0;
@@ -794,7 +794,7 @@ void singleBuffer::activate(int16 bufNo) {
void musicBuffer::activate(int16 bufNo) {
int32 n;
- VERIFY(ailSampleHandle);
+ assert(ailSampleHandle);
n = bufNo;
audioSet = 0;
if (washed() > -1) {
@@ -815,7 +815,7 @@ void musicBuffer::activate(int16 bufNo) {
}
void cacheBuffer::activate(int16 bufNo) {
- VERIFY(bufNo == 0);
+ assert(bufNo == 0);
}
/*******************************************************************/
@@ -830,19 +830,19 @@ void Buffer::reset(void) {
void workBuffer::reset(void) {
if (rSize) took(rSize);
- VERIFY(rSize == 0);
+ assert(rSize == 0);
activate(0);
}
void doubleBuffer::reset(void) {
- VERIFY(AILLOCated == -1);
+ assert(AILLOCated == -1);
AIL_init_sample(ailSampleHandle);
audioSet = 0;
targetPos = 0;
}
void singleBuffer::reset(void) {
-// VERIFY( AILLOCated==-1 );
+// assert( AILLOCated==-1 );
AIL_init_sample(ailSampleHandle);
audioSet = 0;
}
@@ -854,7 +854,7 @@ void musicBuffer::reset(void) {
}
void cacheBuffer::reset(void) {
- VERIFY(rSize == 0);
+ assert(rSize == 0);
activate(0);
}
diff --git a/engines/saga2/audiores.cpp b/engines/saga2/audiores.cpp
index 52402bc3d1..91cc4ad2e1 100644
--- a/engines/saga2/audiores.cpp
+++ b/engines/saga2/audiores.cpp
@@ -121,7 +121,7 @@ int16 hResRead(Buffer &sb, soundSample &ss, hResContext *hrc) {
bread = hrc->readbytes(sb.wData, count);
sb.gave(bread);
- VERIFY(bread <= count);
+ assert(bread <= count);
#if ASYNCH_AUDIO
if (partial)
@@ -171,7 +171,7 @@ int16 bufRead(Buffer &sb, soundSample &ss) {
memcpy(sb.wData, clickData[ss.curSeg], count);
sb.gave(bread);
- VERIFY(bread <= count);
+ assert(bread <= count);
if (bread == count)
rVal |= msgBufferFull;
diff --git a/engines/saga2/automap.cpp b/engines/saga2/automap.cpp
index 77ee152577..f930f9ba99 100644
--- a/engines/saga2/automap.cpp
+++ b/engines/saga2/automap.cpp
@@ -197,10 +197,10 @@ void CAutoMap::locateRegion(void) {
int i;
areaRes = auxResFile->newContext(MKTAG('A', 'M', 'A', 'P'), "AreaList");
- VERIFY(areaRes != NULL);
+ assert(areaRes != NULL);
trRes = (uint16 *)LoadResource(areaRes, MKTAG('Z', 'O', 'N', currentWorld->mapNum), "AreaList");
- VERIFY(trRes != NULL);
+ assert(trRes != NULL);
regionCount = *trRes;
centerCoords = trackPos >> (tileUVShift + platShift);
diff --git a/engines/saga2/band.cpp b/engines/saga2/band.cpp
index 204f5c29ce..f242330e4a 100644
--- a/engines/saga2/band.cpp
+++ b/engines/saga2/band.cpp
@@ -91,7 +91,7 @@ public:
// Return a pointer to a Band given a BandID
Band *getBandAddress(BandID id) {
- ASSERT(id >= 0 && id < numBands);
+ assert(id >= 0 && id < numBands);
return array[ id ].getBand();
}
};
@@ -220,7 +220,7 @@ void *BandList::newBand(void) {
// Place a specific Band into the active list and return its address
void *BandList::newBand(BandID id) {
- ASSERT(id >= 0 && id < elementsof(array));
+ assert(id >= 0 && id < elementsof(array));
BandPlaceHolder *bp;
@@ -388,18 +388,18 @@ Band::Band(void **buf) {
int16 i;
// Restore the leader pointer
- ASSERT(isActor(*((ObjectID *)bufferPtr)));
+ assert(isActor(*((ObjectID *)bufferPtr)));
leader = (Actor *)GameObject::objectAddress(*((ObjectID *)bufferPtr));
bufferPtr = (ObjectID *)bufferPtr + 1;
// Restore the member count
- ASSERT(*((int16 *)bufferPtr) < elementsof(members));
+ assert(*((int16 *)bufferPtr) < elementsof(members));
memberCount = *((int16 *)bufferPtr);
bufferPtr = (int16 *)bufferPtr + 1;
// Restore the member pointers
for (i = 0; i < memberCount; i++) {
- ASSERT(isActor(*((ObjectID *)bufferPtr)));
+ assert(isActor(*((ObjectID *)bufferPtr)));
members[ i ] = (Actor *)GameObject::objectAddress(
*((ObjectID *)bufferPtr));
bufferPtr = (ObjectID *)bufferPtr + 1;
diff --git a/engines/saga2/band.h b/engines/saga2/band.h
index 1430547cd5..b480a0670b 100644
--- a/engines/saga2/band.h
+++ b/engines/saga2/band.h
@@ -122,7 +122,7 @@ public:
}
void remove(int index) {
- ASSERT(index < memberCount);
+ assert(index < memberCount);
int i;
diff --git a/engines/saga2/calender.cpp b/engines/saga2/calender.cpp
index c581c61595..c31a3787d0 100644
--- a/engines/saga2/calender.cpp
+++ b/engines/saga2/calender.cpp
@@ -55,7 +55,7 @@ const uint16 GAME_START_HOUR = 5;
* ===================================================================== */
void CalenderTime::update(void) {
- char *text = NULL;
+ const char *text = NULL;
if (++frameInHour >= framesPerHour) {
frameInHour = 0;
@@ -97,7 +97,8 @@ void CalenderTime::update(void) {
break;
}
- if (text) StatusMsg(CALENDAR_STATUS, text, dayInWeek + 1, weeks + 1);
+ if (text)
+ StatusMsg(CALENDAR_STATUS, text, dayInWeek + 1, weeks + 1);
}
}
@@ -239,8 +240,7 @@ void saveCalender(SaveFileConstructor &saveGame) {
// the correct chunk.
void loadCalender(SaveFileReader &saveGame) {
- ASSERT(saveGame.getChunkSize()
- == sizeof(calenderPaused) + sizeof(calender));
+ assert(saveGame.getChunkSize() == sizeof(calenderPaused) + sizeof(calender));
saveGame.read(&calenderPaused, sizeof(calenderPaused));
saveGame.read(&calender, sizeof(calender));
diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index b303e96db0..1d01c0e9ab 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -808,8 +808,8 @@ void ContainerView::dropPhysical(
GameObject *mObj,
GameObject *cObj,
int16 num) {
- ASSERT(mouseInfo.getObject() == mObj);
- ASSERT(mObj->containmentSet() & ProtoObj::isTangible);
+ assert(mouseInfo.getObject() == mObj);
+ assert(mObj->containmentSet() & ProtoObj::isTangible);
// Place object back where it came from, temporarily
mouseInfo.replaceObject();
@@ -839,8 +839,8 @@ void ContainerView::usePhysical(
gPanelMessage &msg,
GameObject *mObj,
GameObject *cObj) {
- ASSERT(mouseInfo.getObject() == mObj);
- ASSERT(mObj->containmentSet() & ProtoObj::isTangible);
+ assert(mouseInfo.getObject() == mObj);
+ assert(mObj->containmentSet() & ProtoObj::isTangible);
if (cObj == NULL) {
dropPhysical(msg, mObj, cObj);
@@ -856,8 +856,8 @@ void ContainerView::useConcept(
gPanelMessage &msg,
GameObject *mObj,
GameObject *cObj) {
- ASSERT(mouseInfo.getObject() == mObj);
- ASSERT(mObj->containmentSet() & ProtoObj::isIntangible);
+ assert(mouseInfo.getObject() == mObj);
+ assert(mObj->containmentSet() & ProtoObj::isIntangible);
mouseInfo.replaceObject();
@@ -939,7 +939,7 @@ void ContainerView::updateMouseText(Point16 &pickPos) {
// Functions do not appear to be called
void ContainerView::setCursorText(GameObject *obj) {
- ASSERT(obj);
+ assert(obj);
const bufSize = 40;
char cursorText[ bufSize ];
@@ -1219,8 +1219,8 @@ ScrollableContainerWindow::ScrollableContainerWindow(
0,
cmdScrollFunc); // mind app func
- ASSERT(view != NULL);
- ASSERT(scrollCompButton != NULL);
+ assert(view != NULL);
+ assert(scrollCompButton != NULL);
}
/* ===================================================================== *
@@ -1231,8 +1231,8 @@ TangibleContainerWindow::TangibleContainerWindow(
ContainerNode &nd, ContainerAppearanceDef &app)
: ScrollableContainerWindow(nd, app, "ObjectWindow") {
#if DEBUG
- ASSERT(view->containerObject);
- ASSERT(view->containerObject->proto());
+ assert(view->containerObject);
+ assert(view->containerObject->proto());
#endif
const int weightIndicatorType = 2;
@@ -1255,7 +1255,7 @@ TangibleContainerWindow::TangibleContainerWindow(
};
uint16 bgndType = view->containerObject->proto()->appearanceType;
- ASSERT(bgndType < 4);
+ assert(bgndType < 4);
setContainerSprite(); // show at the top of the box
@@ -1342,7 +1342,7 @@ IntangibleContainerWindow::IntangibleContainerWindow(
0,
cmdMindContainerFunc); // mind app func
- ASSERT(mindSelectorCompButton != NULL);
+ assert(mindSelectorCompButton != NULL);
mindSelectorCompButton->setResponse(FALSE);
@@ -1373,8 +1373,8 @@ EnchantmentContainerWindow::EnchantmentContainerWindow(
0,
cmdScrollFunc); // mind app func
- ASSERT(view != NULL);
- ASSERT(scrollCompButton != NULL);
+ assert(view != NULL);
+ assert(scrollCompButton != NULL);
}
/* ===================================================================== *
@@ -1499,7 +1499,7 @@ void ContainerNode::hide(void) {
void ContainerNode::show(void) {
ProtoObj *proto = GameObject::protoAddress(object);
- ASSERT(proto);
+ assert(proto);
// open the window; Object should already be "open"
if (window == NULL) {
@@ -1796,7 +1796,7 @@ void initContainerNodes(void) {
}
}
- ASSERT(onlyReady);
+ assert(onlyReady);
#endif
}
@@ -1896,7 +1896,7 @@ void loadContainerNodes(SaveFileReader &saveGame) {
globalContainerList.add(*node);
}
- ASSERT(tempList.empty());
+ assert(tempList.empty());
// Free the archive buffer
RDisposePtr(archiveBuffer);
@@ -1934,8 +1934,8 @@ void setMindContainer(int index, IntangibleContainerWindow &cw) {
GameObject *newContainer = NULL;
ObjectID id;
- ASSERT(index >= 0);
- ASSERT(index < elementsof(classTable));
+ assert(index >= 0);
+ assert(index < elementsof(classTable));
int containerClass = classTable[ index ];
diff --git a/engines/saga2/dispnode.cpp b/engines/saga2/dispnode.cpp
index 3dde17e709..a9d2c512a9 100644
--- a/engines/saga2/dispnode.cpp
+++ b/engines/saga2/dispnode.cpp
@@ -581,22 +581,22 @@ void DisplayNode::drawObject(void) {
a->currentFacing,
a->currentPose);
- ASSERT(anim->start[ 0 ] >= 0);
- ASSERT(anim->start[ 0 ] < 10000);
- ASSERT(anim->start[ 1 ] >= 0);
- ASSERT(anim->start[ 1 ] < 10000);
- ASSERT(anim->start[ 2 ] >= 0);
- ASSERT(anim->start[ 2 ] < 10000);
-
- ASSERT(pose->rightObjectOffset.x < 1000);
- ASSERT(pose->rightObjectOffset.x > -1000);
- ASSERT(pose->rightObjectOffset.y < 1000);
- ASSERT(pose->rightObjectOffset.y > -1000);
-
- ASSERT(pose->leftObjectOffset.x < 1000);
- ASSERT(pose->leftObjectOffset.x > -1000);
- ASSERT(pose->leftObjectOffset.y < 1000);
- ASSERT(pose->leftObjectOffset.y > -1000);
+ assert(anim->start[ 0 ] >= 0);
+ assert(anim->start[ 0 ] < 10000);
+ assert(anim->start[ 1 ] >= 0);
+ assert(anim->start[ 1 ] < 10000);
+ assert(anim->start[ 2 ] >= 0);
+ assert(anim->start[ 2 ] < 10000);
+
+ assert(pose->rightObjectOffset.x < 1000);
+ assert(pose->rightObjectOffset.x > -1000);
+ assert(pose->rightObjectOffset.y < 1000);
+ assert(pose->rightObjectOffset.y > -1000);
+
+ assert(pose->leftObjectOffset.x < 1000);
+ assert(pose->leftObjectOffset.x > -1000);
+ assert(pose->leftObjectOffset.y < 1000);
+ assert(pose->leftObjectOffset.y > -1000);
// washHandle( aa->spriteBanks[ pose->actorFrameBank ] );
@@ -699,7 +699,7 @@ void DisplayNode::drawObject(void) {
// Fill in the SpriteComponent structure for body
sc = &scList[ bodyIndex ];
- ASSERT(a->poseInfo.actorFrameIndex < ss->count);
+ assert(a->poseInfo.actorFrameIndex < ss->count);
sc->sp = ss->sprite(a->poseInfo.actorFrameIndex);
sc->offset.x = sc->offset.y = 0;
// Color remapping info
@@ -707,11 +707,11 @@ void DisplayNode::drawObject(void) {
// sc->colorTable = aa->schemeList ? mainColors : identityColors;
sc->flipped = (poseFlags & ActorPose::actorFlipped);
- ASSERT(sc->sp != NULL);
- ASSERT(sc->sp->size.x > 0);
- ASSERT(sc->sp->size.y > 0);
- ASSERT(sc->sp->size.x < 255);
- ASSERT(sc->sp->size.y < 255);
+ assert(sc->sp != NULL);
+ assert(sc->sp->size.x > 0);
+ assert(sc->sp->size.y > 0);
+ assert(sc->sp->size.x < 255);
+ assert(sc->sp->size.y < 255);
// If we were carrying something in the left hand,
// then fill in the component structure for it.
@@ -728,12 +728,12 @@ void DisplayNode::drawObject(void) {
sc->sp = proto->getOrientedSprite(
obj,
a->poseInfo.leftObjectIndex);
- ASSERT(sc->sp != NULL);
+ assert(sc->sp != NULL);
sc->offset = a->poseInfo.leftObjectOffset;
- ASSERT(sc->offset.x < 1000);
- ASSERT(sc->offset.x > -1000);
- ASSERT(sc->offset.y < 1000);
- ASSERT(sc->offset.y > -1000);
+ assert(sc->offset.x < 1000);
+ assert(sc->offset.x > -1000);
+ assert(sc->offset.y < 1000);
+ assert(sc->offset.y > -1000);
sc->colorTable = leftColors;
sc->flipped = (poseFlags & ActorPose::leftObjectFlipped);
}
@@ -753,16 +753,16 @@ void DisplayNode::drawObject(void) {
sc->sp = proto->getOrientedSprite(
obj,
a->poseInfo.rightObjectIndex);
- ASSERT(sc->sp != NULL);
- ASSERT(sc->sp->size.x > 0);
- ASSERT(sc->sp->size.y > 0);
- ASSERT(sc->sp->size.x < 255);
- ASSERT(sc->sp->size.y < 255);
+ assert(sc->sp != NULL);
+ assert(sc->sp->size.x > 0);
+ assert(sc->sp->size.y > 0);
+ assert(sc->sp->size.x < 255);
+ assert(sc->sp->size.y < 255);
sc->offset = a->poseInfo.rightObjectOffset;
- ASSERT(sc->offset.x < 1000);
- ASSERT(sc->offset.x > -1000);
- ASSERT(sc->offset.y < 1000);
- ASSERT(sc->offset.y > -1000);
+ assert(sc->offset.x < 1000);
+ assert(sc->offset.x > -1000);
+ assert(sc->offset.y < 1000);
+ assert(sc->offset.y > -1000);
sc->colorTable = rightColors;
sc->flipped = (poseFlags & ActorPose::rightObjectFlipped);
}
diff --git a/engines/saga2/effects.cpp b/engines/saga2/effects.cpp
index 080dd073af..8d7e79e008 100644
--- a/engines/saga2/effects.cpp
+++ b/engines/saga2/effects.cpp
@@ -93,7 +93,7 @@ void ProtoDamage::implement(GameObject *cst, SpellTarget *trg, int8 deltaDamage)
ObjectID pID = cst->possessor();
if (pID != Nothing) {
Actor *p = (Actor *) GameObject::objectAddress(pID);
- VERIFY(isActor(p));
+ assert(isActor(p));
if (totalDice > 0 && trg->getObject() && isActor(trg->getObject()))
offensiveNotification(p, (Actor *) trg->getObject());
}
@@ -101,7 +101,7 @@ void ProtoDamage::implement(GameObject *cst, SpellTarget *trg, int8 deltaDamage)
totalBase -= deltaDamage;
- VERIFY(trg->getType() == SpellTarget::spellTargetObject);
+ assert(trg->getType() == SpellTarget::spellTargetObject);
if (self)
cst->acceptDamage(cst->thisID(), totalBase, type, totalDice, sides);
else
@@ -174,7 +174,7 @@ void ProtoDrainage::implement(GameObject *cst, SpellTarget *trg, int8) {
ObjectID pID = cst->possessor();
if (pID != Nothing) {
Actor *p = (Actor *) GameObject::objectAddress(pID);
- VERIFY(isActor(p));
+ assert(isActor(p));
if (totalDice > 0 && trg->getObject() && isActor(trg->getObject()))
offensiveNotification(p, (Actor *) trg->getObject());
}
@@ -222,7 +222,7 @@ void ProtoEnchantment::implement(GameObject *cst, SpellTarget *trg, int8) {
ObjectID pID = cst->possessor();
if (pID != Nothing) {
Actor *p = (Actor *) GameObject::objectAddress(pID);
- VERIFY(isActor(p));
+ assert(isActor(p));
offensiveNotification(p, (Actor *) trg->getObject());
}
}
@@ -246,7 +246,7 @@ void ProtoEnchantment::implement(GameObject *cst, SpellTarget *trg, int8) {
void ProtoTAGEffect::implement(GameObject *cst, SpellTarget *trg, int8) {
ActiveItem *tag = trg->getTAG();
- VERIFY(tag);
+ assert(tag);
if (affectBit == settagLocked) {
//if ( tag->builtInBehavior()==ActiveItem::builtInDoor )
if (tag->isLocked() != onOff)
@@ -261,7 +261,7 @@ void ProtoTAGEffect::implement(GameObject *cst, SpellTarget *trg, int8) {
void ProtoObjectEffect::implement(GameObject *, SpellTarget *trg, int8) {
GameObject *go = trg->getObject();
- VERIFY(go);
+ assert(go);
if (!isActor(go))
EnchantObject(go->thisID(), affectBit, dice.roll());
}
@@ -278,7 +278,7 @@ void ProtoLocationEffect::implement(GameObject *, SpellTarget *, int8) {
// use a special spell on something
void ProtoSpecialEffect::implement(GameObject *cst, SpellTarget *trg, int8) {
- VERIFY(handler);
+ assert(handler);
(*handler)(cst, trg);
}
@@ -322,8 +322,8 @@ bool ProtoObjectEffect::applicable(SpellTarget &trg) {
#endif
void createSpellCallFrame(GameObject *go, SpellTarget *trg, scriptCallFrame &scf) {
- VERIFY(go);
- VERIFY(trg);
+ assert(go);
+ assert(trg);
scf.invokedObject = Nothing;
scf.enactor = go->thisID();
scf.directObject = Nothing;
@@ -426,7 +426,7 @@ SPECIALSPELL(DeathSpell) {
ObjectID pID = cst->possessor();
if (pID != Nothing) {
Actor *p = (Actor *) GameObject::objectAddress(pID);
- VERIFY(isActor(p));
+ assert(isActor(p));
offensiveNotification(p, (Actor *) trg->getObject());
}
}
@@ -475,7 +475,7 @@ SPECIALSPELL(DispellProtections) {
ObjectID pID = cst->possessor();
if (pID != Nothing) {
Actor *p = (Actor *) GameObject::objectAddress(pID);
- VERIFY(isActor(p));
+ assert(isActor(p));
offensiveNotification(p, (Actor *) trg->getObject());
}
}
diff --git a/engines/saga2/effects.h b/engines/saga2/effects.h
index 08d125c080..1718db6d72 100644
--- a/engines/saga2/effects.h
+++ b/engines/saga2/effects.h
@@ -318,9 +318,9 @@ enum effectSpecialTypes {
//
inline uint16 makeEnchantmentID(uint16 type, uint16 damtyp, int16 damamt) {
- VERIFY(type < 8);
- VERIFY(damtyp < 32);
- VERIFY(damamt < 128 && damamt > -128);
+ assert(type < 8);
+ assert(damtyp < 32);
+ assert(damamt < 128 && damamt > -128);
return (type << 13) | (damtyp << 8) + (damamt + 128);
}
diff --git a/engines/saga2/enchant.cpp b/engines/saga2/enchant.cpp
index 5fa9ce757b..a97be7a2d9 100644
--- a/engines/saga2/enchant.cpp
+++ b/engines/saga2/enchant.cpp
@@ -58,8 +58,8 @@ ObjectID EnchantObject(
ProtoObj *enchProto;
TilePoint slot;
- VERIFY(enchantmentProto >= 0);
- VERIFY(enchantmentProto < objectProtoCount);
+ assert(enchantmentProto >= 0);
+ assert(enchantmentProto < objectProtoCount);
enchProto = &objectProtos[ enchantmentProto ];
@@ -86,8 +86,8 @@ ObjectID EnchantObject(
// Now, change the object base on enchantments
obj->evalEnchantments();
- VERIFY(enchProto->containmentSet() & ProtoObj::isEnchantment);
- VERIFY((ench->protoAddress(ench->thisID()))->containmentSet() & ProtoObj::isEnchantment);
+ assert(enchProto->containmentSet() & ProtoObj::isEnchantment);
+ assert((ench->protoAddress(ench->thisID()))->containmentSet() & ProtoObj::isEnchantment);
return ench->thisID();
}
diff --git a/engines/saga2/floating.cpp b/engines/saga2/floating.cpp
index 053472ea96..a892c3363c 100644
--- a/engines/saga2/floating.cpp
+++ b/engines/saga2/floating.cpp
@@ -448,7 +448,7 @@ void LabeledButton::drawClipped(
FloatingWindow::FloatingWindow(const Rect16 &r, uint16 ident, const char saveas[], AppFunc *cmd)
: DecoratedWindow(r, ident, saveas, cmd) {
- VERIFY(db = NEW_UI DragBar(*this, Rect16(0, 0, r.width, r.height)));
+ assert(db = NEW_UI DragBar(*this, Rect16(0, 0, r.width, r.height)));
origPos.x = r.x;
origPos.y = r.y;
diff --git a/engines/saga2/gamerate.h b/engines/saga2/gamerate.h
index 16809bff50..c84acde115 100644
--- a/engines/saga2/gamerate.h
+++ b/engines/saga2/gamerate.h
@@ -221,7 +221,7 @@ public:
frameSmoother::frameSmoother(int32 fps, uint32 perSec, uint32 now)
: frameCounter(perSec, now) {
- ASSERT(fps);
+ assert(fps);
desiredFPS = fps;
historySize = fps * 5;
frameHistory = new float[historySize];
diff --git a/engines/saga2/gpointer.cpp b/engines/saga2/gpointer.cpp
index cddae37628..a9417702cf 100644
--- a/engines/saga2/gpointer.cpp
+++ b/engines/saga2/gpointer.cpp
@@ -232,7 +232,7 @@ void gMousePointer::restore(void) {
**********************************************************************
*/
void gMousePointer::show(void) {
- ASSERT(hideCount > 0);
+ assert(hideCount > 0);
if (--hideCount == 0) {
#if defined( USEWINDOWS )
diff --git a/engines/saga2/grabinfo.cpp b/engines/saga2/grabinfo.cpp
index d1396bdebe..76b5db4889 100644
--- a/engines/saga2/grabinfo.cpp
+++ b/engines/saga2/grabinfo.cpp
@@ -88,7 +88,7 @@ void GrabInfo::grabObject(ObjectID objid, Intent in, int16 count) {
void GrabInfo::grabObject(GameObject *obj, Intent in, int16 count) {
char objText[ bufSize ];
- ASSERT(!obj->isMoving());
+ assert(!obj->isMoving());
// set the number of items
setMoveCount(count);
@@ -177,12 +177,12 @@ uint8 GrabInfo::setIntent(uint8 in) {
// Make the object given into the mouse pointer
void GrabInfo::setIcon(void) {
- ASSERT(
+ assert(
pointerMap.size.x == 0
&& pointerMap.size.y == 0
&& pointerMap.data == NULL);
- ASSERT(grabObj != NULL && isObject(grabObj));
+ assert(grabObj != NULL && isObject(grabObj));
Sprite *spr;
ProtoObj *proto;
@@ -219,7 +219,7 @@ void GrabInfo::setIcon(void) {
}
void GrabInfo::clearIcon(void) {
- ASSERT(grabObj == NULL);
+ assert(grabObj == NULL);
if (pointerMap.data != NULL) {
RDisposePtr(pointerMap.data);
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 26afa533ee..2d42467f3b 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -121,7 +121,7 @@ uint8 *builtinObjectAddress(int16 segment, uint16 index) {
return (uint8 *)ActiveItem::activeItemAddress(index);
case builtinAbstract:
- ASSERT(index > 0);
+ assert(index > 0);
if (lookupExport(index, segNum, segOff) == FALSE)
error("SAGA: Cannot take address of abtract class");
@@ -195,7 +195,7 @@ uint16 *builtinVTableAddress(int16 btype, uint8 *addr, CallTable **callTab) {
error("SAGA Failure: Attempt to call member function of invalid builtin type.\n");
}
-// ASSERT( script > 0 );
+// assert( script > 0 );
// Look up the vtable in the export table.
if (script != 0 && lookupExport(script, vtSeg, vtOffset)) {
@@ -455,9 +455,9 @@ uint8 *Thread::strAddress(int strNum) {
uint16 *codeBase = (uint16 *)*codeSeg;
uint8 *strSeg = segmentAddress(codeBase[ 1 ], codeBase[ 2 ]);
- ASSERT(strNum >= 0);
- ASSERT(codeBase);
- ASSERT(strSeg);
+ assert(strNum >= 0);
+ assert(codeBase);
+ assert(strSeg);
return strSeg + ((uint16 *)strSeg)[ strNum ];
}
@@ -1161,7 +1161,7 @@ public:
// Return a pointer to a thread, given an ID
Thread *getThreadAddress(ThreadID id) {
- ASSERT(id >= 0 && id < elementsof(array));
+ assert(id >= 0 && id < elementsof(array));
return array[ id ].getThread();
}
@@ -1296,7 +1296,7 @@ void *ThreadList::newThread(void) {
// Place a new thread into the active list and return its pointer
void *ThreadList::newThread(ThreadID id) {
- ASSERT(id >= 0 && id < elementsof(array));
+ assert(id >= 0 && id < elementsof(array));
ThreadPlaceHolder *tp;
@@ -1427,7 +1427,7 @@ void loadSAGAThreads(SaveFileReader &saveGame) {
new (&threadList) ThreadList;
bufferPtr = threadList.restore(bufferPtr);
- ASSERT((char *)bufferPtr == (char *)archiveBuffer
+ assert((char *)bufferPtr == (char *)archiveBuffer
+ saveGame.getChunkSize());
RDisposePtr(archiveBuffer);
@@ -1502,7 +1502,7 @@ Thread::Thread(uint16 segNum, uint16 segOff, scriptCallFrame &args) {
if ((*codeSeg)[ programCounter.offset ] != op_enter)
error("SAGA failure: Invalid script entry point (export=%d) [segment=%d:%d]\n", lastExport, segNum, segOff);
-// VERIFY ((*codeSeg)[ programCounter.offset ] == op_enter);
+// assert ((*codeSeg)[ programCounter.offset ] == op_enter);
}
//-----------------------------------------------------------------------
@@ -1754,7 +1754,7 @@ void initScripts(void) {
dataSegSize = RPtrSize(*dataSegment);
exportSegment = (UByteHandle)scriptRes->load(exportSegID, "saga export segmant");
- ASSERT(exportSegment != NULL);
+ assert(exportSegment != NULL);
exportCount = (scriptRes->size(exportSegID) / sizeof(uint32)) + 1;
}
@@ -1804,8 +1804,8 @@ static bool lookupExport(
uint32 segRef,
*exportBase = (uint32 *)(*exportSegment - 2);
- ASSERT(entry > 0);
- ASSERT(entry <= exportCount);
+ assert(entry > 0);
+ assert(entry <= exportCount);
segRef = exportBase[ entry ];
segOff = segRef >> 16,
@@ -1832,7 +1832,7 @@ scriptResult runScript(uint16 exportEntryNum, scriptCallFrame &args) {
if (exportEntryNum < 0)
error("SAGA failure: Attempt to run script with invalid export ID %d.", exportEntryNum);
- ASSERT(exportEntryNum > 0);
+ assert(exportEntryNum > 0);
lookupExport(exportEntryNum, segNum, segOff);
// Create a new thread
@@ -1894,8 +1894,8 @@ scriptResult runMethod(
C_Call *cfunc;
// Make sure the C function number is OK
- ASSERT(funcNum >= 0);
- ASSERT(funcNum < globalCFuncs.numEntries);
+ assert(funcNum >= 0);
+ assert(funcNum < globalCFuncs.numEntries);
cfunc = globalCFuncs.table[ funcNum ];
// Build a temporary dummy thread
@@ -1935,7 +1935,7 @@ scriptResult runObjectMethod(
scriptCallFrame &args) {
GameObject *obj;
- VERIFY(obj = GameObject::objectAddress(id));
+ assert(obj = GameObject::objectAddress(id));
return runMethod(obj->scriptClass(),
builtinTypeObject,
@@ -1953,7 +1953,7 @@ scriptResult runTagMethod(
scriptCallFrame &args) {
ActiveItemPtr aItem;
- VERIFY(aItem = ActiveItem::activeItemAddress(index));
+ assert(aItem = ActiveItem::activeItemAddress(index));
if (!aItem->scriptClassID)
return scriptResultNoScript;
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index 85612518f1..0c203b6172 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -513,11 +513,11 @@ CPortrait::CPortrait(gMultCompButton **portraits,
const uint16 numPorts,
uint16 numBrothers) { // numBrothers = post 1
// do some checking
- ASSERT(portraits);
- ASSERT(indivPort);
+ assert(portraits);
+ assert(indivPort);
for (uint16 i = 0; i < numBrothers; i++) {
- ASSERT(portraits[ i ]);
+ assert(portraits[ i ]);
};
buttons = portraits; // set the pointer for class
@@ -532,7 +532,7 @@ CPortrait::CPortrait(gMultCompButton **portraits,
}
void CPortrait::setPortrait(uint16 brotherID) {
- ASSERT(brotherID < _numViews + 1);
+ assert(brotherID < _numViews + 1);
// tell button to select and display new image
if (brotherID == uiIndiv) {
@@ -553,7 +553,7 @@ void CPortrait::set(uint16 brotherID, PortraitType type) {
}
void CPortrait::ORset(uint16 brotherID, PortraitType type) { // brotherID = post 0
- ASSERT(brotherID < _numViews + 1);
+ assert(brotherID < _numViews + 1);
if (type == currentState[ brotherID ]) {
currentState[ brotherID ] = normal;
@@ -723,7 +723,7 @@ CStatusLine::CStatusLine(gPanelList &list,
CStatusLine::~CStatusLine(void) {
while (queueTail != queueHead) {
- ASSERT(lineQueue[ queueTail ].text != NULL);
+ assert(lineQueue[ queueTail ].text != NULL);
RDisposePtr(lineQueue[ queueTail ].text);
queueTail = bump(queueTail);
@@ -950,7 +950,7 @@ CManaIndicator::CManaIndicator(gPanelList &list) : gCompImage(list,
NULL,
0,
cmdManaInd) {
- ASSERT(resFile);
+ assert(resFile);
// init the resource handle with the mana resource group
resContext = resFile->newContext(MKTAG('M', 'A', 'N', 'A'),
@@ -1218,7 +1218,7 @@ void CManaIndicator::drawClipped(gPort &port,
}
bool CManaIndicator::needUpdate(PlayerActor *player) {
- ASSERT(player);
+ assert(player);
// get the ability scores for this character
ActorAttributes *stats = player->getEffStats();
@@ -1245,7 +1245,7 @@ bool CManaIndicator::needUpdate(PlayerActor *player) {
bool CManaIndicator::update(PlayerActor *player) {
- ASSERT(player);
+ assert(player);
// get the ability scores for this character
ActorAttributes *stats = player->getEffStats();
@@ -1422,7 +1422,7 @@ CHealthIndicator::~CHealthIndicator(void) {
// Recalculate and update the health star for a particular brother
void CHealthIndicator::updateStar(gCompImage *starCtl, int32 bro, int32 baseVitality, int32 curVitality) {
- ASSERT(baseVitality >= 0);
+ assert(baseVitality >= 0);
int16 maxStar, imageIndex;
@@ -1909,7 +1909,7 @@ inline T GetRatio(T curUnits, T maxUnits, T ratio) {
}
uint16 getWeightRatio(GameObject *obj, uint16 &maxRatio, bool bReturnMaxRatio = TRUE) {
- ASSERT(isObject(obj) || isActor(obj));
+ assert(isObject(obj) || isActor(obj));
uint16 weight;
uint16 maxWeight;
@@ -1933,7 +1933,7 @@ uint16 getWeightRatio(GameObject *obj, uint16 &maxRatio, bool bReturnMaxRatio =
uint16 getBulkRatio(GameObject *obj, uint16 &maxRatio, bool bReturnMaxRatio = TRUE) {
- ASSERT(isObject(obj) || isActor(obj));
+ assert(isObject(obj) || isActor(obj));
uint16 maxBulk;
uint16 bulk;
diff --git a/engines/saga2/itevideo.cpp b/engines/saga2/itevideo.cpp
index 07282c0143..2db3e0488e 100644
--- a/engines/saga2/itevideo.cpp
+++ b/engines/saga2/itevideo.cpp
@@ -350,7 +350,7 @@ inline bool file_exists(const char f[]) {
void nameHook(char *targ, const char *bpath, const char *, const char *fname) {
char filename[260] = "";
- VERIFY(targ);
+ assert(targ);
if (strcmp(bpath, ".\\")) { //if env var set
strcpy(filename, bpath);
diff --git a/engines/saga2/magic.cpp b/engines/saga2/magic.cpp
index 1eeb46701d..af6ca39419 100644
--- a/engines/saga2/magic.cpp
+++ b/engines/saga2/magic.cpp
@@ -131,8 +131,8 @@ bool nonUsable(SkillProto *spell) {
//-----------------------------------------------------------------------
// test a target for viability in a given spell
bool validTarget(GameObject *enactor, GameObject *target, ActiveItem *tag, SkillProto *skill) {
- VERIFY(enactor != NULL);
- VERIFY(skill != NULL);
+ assert(enactor != NULL);
+ assert(skill != NULL);
SpellStuff &sp = spellBook[skill->getSpellID()];
int32 range = sp.getRange();
if (target != NULL && target->thisID() != Nothing) {
@@ -196,7 +196,7 @@ bool canCast(GameObject *enactor, SkillProto *spell) {
#if NPC_MANA_CHECK
if (isActor(enactor)) {
Actor *a = (Actor *) enactor;
- VERIFY(ami >= manaIDRed && ami <= manaIDViolet);
+ assert(ami >= manaIDRed && ami <= manaIDViolet);
if ((&a->effectiveStats.redMana)[ami] < amt)
return FALSE;
return TRUE;
@@ -279,7 +279,7 @@ bool implementSpell(GameObject *enactor, Location &target, SkillProto *spell)
SpellID s = spell->getSpellID();
SpellStuff &sProto = spellBook[s];
- VERIFY(sProto.shouldTarget(spellApplyLocation));
+ assert(sProto.shouldTarget(spellApplyLocation));
ActorManaID ami = (ActorManaID)(sProto.getManaType());
@@ -318,8 +318,8 @@ bool implementSpell(GameObject *enactor, ActiveItem *target, SkillProto *spell)
if (sProto.shouldTarget(spellApplyLocation)) {
return implementSpell(enactor, l, spell);
}
- VERIFY(sProto.shouldTarget(spellApplyTAG));
- VERIFY(target->itemType == activeTypeInstance);
+ assert(sProto.shouldTarget(spellApplyTAG));
+ assert(target->itemType == activeTypeInstance);
ActorManaID ami = (ActorManaID)(sProto.getManaType());
@@ -357,7 +357,7 @@ bool implementSpell(GameObject *enactor, GameObject *target, SkillProto *spell)
Location l = Location(target->getWorldLocation(), enactor->world()->thisID());
if (sProto.shouldTarget(spellApplyLocation))
return implementSpell(enactor, l, spell);
- VERIFY(sProto.shouldTarget(spellApplyObject));
+ assert(sProto.shouldTarget(spellApplyObject));
ActorManaID ami = (ActorManaID)(sProto.getManaType());
diff --git a/engines/saga2/mission.cpp b/engines/saga2/mission.cpp
index fa1cb96869..f2cac4015e 100644
--- a/engines/saga2/mission.cpp
+++ b/engines/saga2/mission.cpp
@@ -80,8 +80,8 @@ int ActiveMission::findMission(ObjectID genID) {
}
ActiveMission *ActiveMission::missionAddress(int index) {
- ASSERT(index >= 0);
- ASSERT(index < elementsof(activeMissions));
+ assert(index >= 0);
+ assert(index < elementsof(activeMissions));
return &activeMissions[ index ];
}
diff --git a/engines/saga2/module.mk b/engines/saga2/module.mk
index aa9736860a..568c96162c 100644
--- a/engines/saga2/module.mk
+++ b/engines/saga2/module.mk
@@ -99,7 +99,6 @@ MODULE_OBJS := \
tromode.o \
uidialog.o \
vbacksav.o \
- verify.o \
video.o \
videobox.o \
videomem.o \
diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp
index bee4a79cbb..bb3d9b7195 100644
--- a/engines/saga2/motion.cpp
+++ b/engines/saga2/motion.cpp
@@ -232,7 +232,7 @@ inline int16 spinRight(int16 dir, int16 amt = 1) {
// happens due to the point-sampled nature of the environment.
bool unstickObject(GameObject *obj) {
- ASSERT(isObject(obj) || isActor(obj));
+ assert(isObject(obj) || isActor(obj));
TilePoint pos;
int height,
@@ -402,7 +402,7 @@ MotionTaskList::MotionTaskList(void **buf) {
// active list
mt = (MotionTask *)free.remHead();
#if DEBUG
- VERIFY(mt != NULL);
+ assert(mt != NULL);
#endif
list.addTail(*mt);
@@ -1296,7 +1296,7 @@ void MotionTask::calcVelocity(const TilePoint &vector, int16 turns) {
// This initiates a motion task for turning an actor
void MotionTask::turn(Actor &obj, Direction dir) {
- ASSERT(dir >= 0 && dir < 8);
+ assert(dir >= 0 && dir < 8);
MotionTask *mt;
@@ -1879,7 +1879,7 @@ void MotionTask::castSpell(Actor &a, SkillProto &spell, ActiveItem &target) {
if ((mt = mTaskList.newTask(&a)) != NULL) {
if (mt->motionType != type) {
Location loc;
- VERIFY(target.itemType == activeTypeInstance);
+ assert(target.itemType == activeTypeInstance);
mt->motionType = type;
mt->spellObj = &spell;
mt->targetTAG = ⌖
@@ -2543,7 +2543,7 @@ void MotionTask::walkAction(void) {
moveTaskDone = FALSE;
WalkType walkType = walkNormal;
- ASSERT(isActor(object));
+ assert(isActor(object));
a = (Actor *)object;
aa = a->appearance;
@@ -3558,7 +3558,7 @@ GameObject *MotionTask::blockingObject(Actor *thisAttacker) {
void MotionTask::fireBowAction(void) {
Actor *a = (Actor *)object;
- ASSERT(a->leftHandObject != Nothing);
+ assert(a->leftHandObject != Nothing);
// Initialize the bow firing motion
if (flags & reset) {
@@ -3695,7 +3695,7 @@ void MotionTask::castSpellAction(void) {
if (actionCounter == 0) {
if (spellObj) {
if (flags & TAGTarg) {
- VERIFY(targetTAG->itemType == activeTypeInstance);
+ assert(targetTAG->itemType == activeTypeInstance);
spellObj->implementAction(spellObj->getSpellID(), a->thisID(), targetTAG->thisID());
} else if (flags & LocTarg) {
spellObj->implementAction(spellObj->getSpellID(), a->thisID(), targetLoc);
@@ -4113,7 +4113,7 @@ void MotionTask::useMagicWeaponAction(void) {
spell = GameObject::objectAddress(magicWeapon->IDChild());
spellProto = (SkillProto *)spell->proto();
- ASSERT(spellProto->containmentSet() & ProtoObj::isSkill);
+ assert(spellProto->containmentSet() & ProtoObj::isSkill);
// use the spell
spellProto->implementAction(
diff --git a/engines/saga2/mouseimg.cpp b/engines/saga2/mouseimg.cpp
index 1d61669bea..0408094166 100644
--- a/engines/saga2/mouseimg.cpp
+++ b/engines/saga2/mouseimg.cpp
@@ -131,8 +131,8 @@ void createStackedImage(
gPixelMap **imageArray,
int *imageCenterArray,
int images) {
- ASSERT(images != 0);
- ASSERT(newImage->data == NULL);
+ assert(images != 0);
+ assert(newImage->data == NULL);
int i;
int newImageBytes,
@@ -184,7 +184,7 @@ void createStackedImage(
// Dispose of an image created with createStackedImage
inline void disposeStackedImage(gPixelMap *image) {
- ASSERT(image->data != NULL);
+ assert(image->data != NULL);
delete [] image->data;
image->data = NULL;
@@ -363,8 +363,8 @@ void setMouseTextF(char *format, ...) {
// gauge on if necessary ).
void setMouseGauge(int numerator, int denominator) {
- ASSERT(denominator != 0);
- ASSERT(numerator <= denominator);
+ assert(denominator != 0);
+ assert(numerator <= denominator);
if (showGauge
&& numerator == gaugeNumerator
diff --git a/engines/saga2/noise.cpp b/engines/saga2/noise.cpp
index e8d85c27fe..a0181c861f 100644
--- a/engines/saga2/noise.cpp
+++ b/engines/saga2/noise.cpp
@@ -410,7 +410,7 @@ void toggleMusic(void) {
// hook used by videos
HDIGDRIVER &digitalAudioDriver(void) {
- VERIFY(audio);
+ assert(audio);
return audio->dig;
}
@@ -691,7 +691,7 @@ uint32 parse_res_id(char IDstr[]) {
uint32 a[5] = {0, 0, 0, 0, 0};
uint32 a2, res = 0;
uint32 i, j;
- VERIFY(IDstr != NULL);
+ assert(IDstr != NULL);
if (strlen(IDstr)) {
for (i = 0, j = 0; i < strlen(IDstr); i++) {
if (IDstr[i] == ':') {
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index f75bb1f6af..4b37124028 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -528,7 +528,7 @@ void GameObject::objCursorText(char nameBuf[], const int8 size, int16 count) {
nameBuf[ size - 1 ] = NULL;
- ASSERT(strlen(objName()) < size - addTextSize);
+ assert(strlen(objName()) < size - addTextSize);
// check to see if this item is a physical object
// if so, then give the count of the item ( if stacked )
@@ -600,7 +600,7 @@ void GameObject::objCursorText(char nameBuf[], const int8 size, int16 count) {
if (actorIDToPlayerID(aID, pID)) {
PlayerActor *player = getPlayerActorAddress(pID);
- ASSERT(player);
+ assert(player);
int16 manaAmount;
int16 baseManaAmount;
@@ -834,7 +834,7 @@ void GameObject::move(const Location &location, int16 num) {
int16 GameObject::getChargeType(void) {
- ASSERT(prototype);
+ assert(prototype);
return prototype->getChargeType();
}
@@ -846,7 +846,7 @@ void GameObject::recharge(void) {
// it's charges to maximum
if (getChargeType()) {
ProtoObj *po = GameObject::protoAddress(thisID());
- VERIFY(po);
+ assert(po);
bParam = po->maxCharges;
}
}
@@ -854,7 +854,7 @@ void GameObject::recharge(void) {
// take a charge
bool GameObject::deductCharge(ActorManaID manaID, uint16 manaCost) {
ProtoObj *po = GameObject::protoAddress(thisID());
- VERIFY(po);
+ assert(po);
// if this is not a chargeable item, then return FALSE
if (!getChargeType()) {
@@ -887,7 +887,7 @@ bool GameObject::deductCharge(ActorManaID manaID, uint16 manaCost) {
bool GameObject::hasCharge(ActorManaID manaID, uint16 manaCost) {
ProtoObj *po = GameObject::protoAddress(thisID());
- VERIFY(po);
+ assert(po);
// if this is not a chargeable item, then return FALSE
if (!getChargeType()) {
@@ -1016,7 +1016,7 @@ ObjectID GameObject::extractMerged(const Location &loc, int16 num) {
}
// massCount should never go negitive
- ASSERT(massCount >= 0);
+ assert(massCount >= 0);
} else
return Nothing;
} else {
@@ -1049,7 +1049,7 @@ GameObject *GameObject::extractMerged(int16 num) {
}
// massCount should never go negitive
- ASSERT(massCount >= 0);
+ assert(massCount >= 0);
} else
return NULL;
} else {
@@ -1277,7 +1277,7 @@ void GameObject::deleteObjectRecursive(void) {
// If this is an important object let's not delete it but try to drop
// it on the ground instead.
if (isImportant()) {
- ASSERT((prototype->containmentSet() & ProtoObj::isTangible) != 0);
+ assert((prototype->containmentSet() & ProtoObj::isTangible) != 0);
// If the object is already in a world there's nothing to do.
if (isWorld(parentID))
@@ -1539,9 +1539,9 @@ bool GameObject::getAvailableSlot(
TilePoint *tp,
bool canMerge,
GameObject **mergeObj) {
- ASSERT(isObject(obj));
- ASSERT(tp != NULL);
- ASSERT(!canMerge || mergeObj != NULL);
+ assert(isObject(obj));
+ assert(tp != NULL);
+ assert(!canMerge || mergeObj != NULL);
if (prototype == NULL) return FALSE;
@@ -1553,7 +1553,7 @@ bool GameObject::getAvailableSlot(
if ((objProto->containmentSet()
& (ProtoObj::isContainer | ProtoObj::isIntangible))
== (ProtoObj::isContainer | ProtoObj::isIntangible)) {
-// ASSERT( isActor( obj ) );
+// assert( isActor( obj ) );
// Set intangible container locations to -1, -1.
tp->u = -1;
@@ -1601,8 +1601,8 @@ bool GameObject::placeObject(
ObjectID objID,
bool canMerge,
int16 num) {
- ASSERT(isActor(enactor));
- ASSERT(isObject(objID));
+ assert(isActor(enactor));
+ assert(isObject(objID));
TilePoint slot;
GameObject *obj = GameObject::objectAddress(objID),
@@ -1622,7 +1622,7 @@ bool GameObject::placeObject(
// Drop the specified object on the ground in a semi-random location
void GameObject::dropInventoryObject(GameObject *obj, int16 count) {
- ASSERT(isWorld(parentID));
+ assert(isWorld(parentID));
int16 dist;
int16 mapNum = getMapNum();
@@ -1802,14 +1802,14 @@ bool GameObject::addTimer(TimerID id, int16 frameInterval) {
return FALSE;
}
- ASSERT(timerList->getObject() == this);
+ assert(timerList->getObject() == this);
// Search the list to see if there is already a timer with same
// ID as the new timer. If so, remove it and delete it.
for (timerInList = (Timer *)timerList->first();
timerInList != NULL;
timerInList = (Timer *)timerInList->next()) {
- ASSERT(timerInList->getObject() == this);
+ assert(timerInList->getObject() == this);
if (newTimer->thisID() == timerInList->thisID()) {
timerInList->remove();
@@ -1896,14 +1896,14 @@ bool GameObject::addSensor(Sensor *newSensor) {
&& (sensorList = new SensorList(this)) == NULL)
return FALSE;
- ASSERT(sensorList->getObject() == this);
+ assert(sensorList->getObject() == this);
// Search the list to see if there is already a sensor with same
// ID as the new sensor. If so, remove it and delete it.
for (sensorInList = (Sensor *)sensorList->first();
sensorInList != NULL;
sensorInList = (Sensor *)sensorInList->next()) {
- ASSERT(sensorInList->getObject() == this);
+ assert(sensorInList->getObject() == this);
if (newSensor->thisID() == sensorInList->thisID()) {
sensorInList->remove();
@@ -3156,7 +3156,7 @@ void Sector::activate(void) {
// actors in sector if activation count has reached zero.
void Sector::deactivate(void) {
- ASSERT(activationCount != 0);
+ assert(activationCount != 0);
activationCount--;
}
@@ -3331,8 +3331,8 @@ void loadActiveRegions(SaveFileReader &saveGame) {
SectorRegionObjectIterator::SectorRegionObjectIterator(GameWorld *world) :
searchWorld(world) {
- ASSERT(searchWorld != NULL);
- ASSERT(isWorld(searchWorld));
+ assert(searchWorld != NULL);
+ assert(isWorld(searchWorld));
minSector = TilePoint(0, 0, 0);
maxSector = searchWorld->sectorSize();
@@ -3372,10 +3372,10 @@ ObjectID SectorRegionObjectIterator::first(GameObject **obj) {
// Return the next object found
ObjectID SectorRegionObjectIterator::next(GameObject **obj) {
- ASSERT(sectorCoords.u >= minSector.u);
- ASSERT(sectorCoords.v >= minSector.v);
- ASSERT(sectorCoords.u < maxSector.u);
- ASSERT(sectorCoords.v < maxSector.v);
+ assert(sectorCoords.u >= minSector.u);
+ assert(sectorCoords.v >= minSector.v);
+ assert(sectorCoords.u < maxSector.u);
+ assert(sectorCoords.v < maxSector.v);
ObjectID currentObjectID;
@@ -3818,7 +3818,7 @@ bool ActiveRegionObjectIterator::nextActiveRegion(void) {
if (!(sectorBitMask & sectorBit)) {
currentRegionSectors--;
- ASSERT(currentRegionSectors >= 0);
+ assert(currentRegionSectors >= 0);
// Set the bit in the bit mask indicating that this
// sector overlaps with a previouse active region
@@ -3904,7 +3904,7 @@ ObjectID ActiveRegionObjectIterator::first(GameObject **obj) {
sectorCoords.u,
sectorCoords.v);
- ASSERT(currentSector != NULL);
+ assert(currentSector != NULL);
currentObjectID = currentSector->childID;
currentObject = currentObjectID != Nothing
@@ -3918,7 +3918,7 @@ ObjectID ActiveRegionObjectIterator::first(GameObject **obj) {
sectorCoords.u,
sectorCoords.v);
- ASSERT(currentSector != NULL);
+ assert(currentSector != NULL);
currentObjectID = currentSector->childID;
currentObject = currentObjectID != Nothing
@@ -3935,8 +3935,8 @@ ObjectID ActiveRegionObjectIterator::first(GameObject **obj) {
// Return the next object within the specified region
ObjectID ActiveRegionObjectIterator::next(GameObject **obj) {
- ASSERT(activeRegionIndex >= 0);
- ASSERT(activeRegionIndex < elementsof(activeRegionList));
+ assert(activeRegionIndex >= 0);
+ assert(activeRegionIndex < elementsof(activeRegionList));
ObjectID currentObjectID;
@@ -3954,7 +3954,7 @@ ObjectID ActiveRegionObjectIterator::next(GameObject **obj) {
sectorCoords.u,
sectorCoords.v);
- ASSERT(currentSector != NULL);
+ assert(currentSector != NULL);
currentObjectID = currentSector->childID;
currentObject = currentObjectID != Nothing
@@ -4032,7 +4032,7 @@ ObjectID RecursiveContainerIterator::next(GameObject **obj) {
if (currentObj->IDChild()) {
subIter = NEW_ITER RecursiveContainerIterator(currentObj);
- VERIFY(subIter);
+ assert(subIter);
return subIter->first(obj);
}
}
@@ -4299,7 +4299,7 @@ int16 openMindType;
APPFUNC(cmdBrain) {
int16 part = clamp(0, ev.mouse.x * 3 / ev.panel->getExtent().width, 2);
- //ASSERT( indivControls->getEnabled() );
+ //assert( indivControls->getEnabled() );
if (!indivControls->getEnabled())
return;
@@ -4312,7 +4312,7 @@ APPFUNC(cmdBrain) {
openMindType = part;
- ASSERT(container == indivCviewBot->containerObject);
+ assert(container == indivCviewBot->containerObject);
// Get the actor's mind container
while (iter.next(&item) != Nothing) {
@@ -4498,21 +4498,21 @@ void doBackgroundSimulation(void) {
childID != Nothing;
childID = GameObject::objectAddress(childID)->IDNext())
count++;
- VERIFY(objectLimboCount == count);
+ assert(objectLimboCount == count);
count = 0;
for (childID = GameObject::objectAddress(ActorLimbo)->IDChild();
childID != Nothing;
childID = GameObject::objectAddress(childID)->IDNext())
count++;
- VERIFY(actorLimboCount == count);
+ assert(actorLimboCount == count);
count = 0;
for (childID = GameObject::objectAddress(ImportantLimbo)->IDChild();
childID != Nothing;
childID = GameObject::objectAddress(childID)->IDNext())
count++;
- VERIFY(importantLimboCount == count);
+ assert(importantLimboCount == count);
#endif
int32 objectUpdateCount,
@@ -4535,7 +4535,7 @@ void doBackgroundSimulation(void) {
// If object is not deleted, then tell that object to do
// a background update
if (obj->IDParent() > ImportantLimbo) {
- ASSERT(obj->proto());
+ assert(obj->proto());
// If an object has been abandoned by the player,
// and is not sitting inside a container,
@@ -4566,7 +4566,7 @@ void doBackgroundSimulation(void) {
// If actor is not deleted, then tell that actor to do
// a background update
if (a->IDParent() > ImportantLimbo) {
- ASSERT(a->proto());
+ assert(a->proto());
a->proto()->doBackgroundUpdate(a);
}
diff --git a/engines/saga2/objects.h b/engines/saga2/objects.h
index 4e1d253424..e5eb335f9a 100644
--- a/engines/saga2/objects.h
+++ b/engines/saga2/objects.h
@@ -793,7 +793,7 @@ public:
}
static uint32 IDtoMapNum(ObjectID id) {
- VERIFY(isWorld(id));
+ assert(isWorld(id));
return ((GameWorld *)GameObject::objectAddress(id))->mapNum;
}
};
@@ -918,8 +918,8 @@ public:
searchWorld(world),
minSector(sectorRegion.min),
maxSector(sectorRegion.max) {
- ASSERT(searchWorld != NULL);
- ASSERT(isWorld(searchWorld));
+ assert(searchWorld != NULL);
+ assert(isWorld(searchWorld));
}
protected:
diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp
index 6f12b2ddb6..8ac68b9f0d 100644
--- a/engines/saga2/objproto.cpp
+++ b/engines/saga2/objproto.cpp
@@ -103,7 +103,7 @@ bool ProtoObj::isMissile(void) {
// Simple use command
bool ProtoObj::use(ObjectID dObj, ObjectID enactor) {
- ASSERT(dObj != Nothing);
+ assert(dObj != Nothing);
int16 scriptResult;
@@ -132,8 +132,8 @@ bool ProtoObj::useAction(ObjectID dObj, ObjectID enactor) {
// UseOn object command
bool ProtoObj::useOn(ObjectID dObj, ObjectID enactor, ObjectID item) {
- ASSERT(dObj != Nothing);
- ASSERT(item != Nothing);
+ assert(dObj != Nothing);
+ assert(item != Nothing);
int16 scriptResult;
@@ -156,8 +156,8 @@ bool ProtoObj::useOnAction(ObjectID dObj, ObjectID enactor, ObjectID item) {
// UseOn active item command
bool ProtoObj::useOn(ObjectID dObj, ObjectID enactor, ActiveItem *item) {
- ASSERT(dObj != Nothing);
- ASSERT(item != NULL);
+ assert(dObj != Nothing);
+ assert(item != NULL);
int16 scrResult;
@@ -193,8 +193,8 @@ bool ProtoObj::useOnAction(ObjectID dObj, ObjectID enactor, ActiveItem *item) {
// UseOn location command
bool ProtoObj::useOn(ObjectID dObj, ObjectID enactor, const Location &loc) {
- ASSERT(dObj != Nothing);
- ASSERT(loc != Nowhere && loc.context != Nothing);
+ assert(dObj != Nothing);
+ assert(loc != Nowhere && loc.context != Nothing);
/* int16 scrResult;
@@ -256,7 +256,7 @@ bool ProtoObj::useSlotAvailable(GameObject *, Actor *) {
// Open this object
bool ProtoObj::open(ObjectID dObj, ObjectID enactor) {
- ASSERT(dObj != Nothing);
+ assert(dObj != Nothing);
int16 scriptResult;
@@ -284,7 +284,7 @@ bool ProtoObj::openAction(ObjectID, ObjectID) {
// Close this object
bool ProtoObj::close(ObjectID dObj, ObjectID enactor) {
- ASSERT(dObj != Nothing);
+ assert(dObj != Nothing);
int16 scriptResult;
GameObject *dObjPtr = GameObject::objectAddress(dObj);
@@ -308,8 +308,8 @@ bool ProtoObj::closeAction(ObjectID, ObjectID) {
// Take this object
bool ProtoObj::take(ObjectID dObj, ObjectID enactor, int16 num) {
- ASSERT(dObj != Nothing);
- ASSERT(mouseInfo.getObjectId() == Nothing);
+ assert(dObj != Nothing);
+ assert(mouseInfo.getObjectId() == Nothing);
// >>> this needs to be dynamic!
if (mass > 200 || bulk > 200) return FALSE;
@@ -339,7 +339,7 @@ bool ProtoObj::takeAction(ObjectID, ObjectID, int16 num) {
// Drop this object at the specified location
bool ProtoObj::drop(ObjectID dObj, ObjectID enactor, const Location &loc, int16 num) {
- ASSERT(dObj != Nothing);
+ assert(dObj != Nothing);
if (!canDropAt(dObj, enactor, loc)) return FALSE;
@@ -379,7 +379,7 @@ bool ProtoObj::dropAction(ObjectID, ObjectID, const Location &, int16) {
// drop an object onto another object and handle the result.
bool ProtoObj::dropOn(ObjectID dObj, ObjectID enactor, ObjectID target, int16 count) {
- ASSERT(dObj != Nothing);
+ assert(dObj != Nothing);
// this prevents objects from being dropped on themselves
if (target == dObj) return TRUE;
@@ -416,9 +416,9 @@ bool ProtoObj::dropOn(
ActiveItem *target,
const Location &loc,
int16 num) {
- ASSERT(dObj != Nothing);
- ASSERT(target != NULL);
- ASSERT(isWorld(loc.context));
+ assert(dObj != Nothing);
+ assert(target != NULL);
+ assert(isWorld(loc.context));
int16 scriptResult;
/*
@@ -444,8 +444,8 @@ bool ProtoObj::dropOnAction(
// Strike another object with this object
bool ProtoObj::strike(ObjectID dObj, ObjectID enactor, ObjectID item) {
- ASSERT(isObject(dObj) || isActor(dObj));
- ASSERT(isObject(item) || isActor(item));
+ assert(isObject(dObj) || isActor(dObj));
+ assert(isObject(item) || isActor(item));
int16 scriptResult;
@@ -466,8 +466,8 @@ bool ProtoObj::strikeAction(ObjectID, ObjectID, ObjectID) {
// Damage another object with this object
bool ProtoObj::damage(ObjectID dObj, ObjectID enactor, ObjectID target) {
- ASSERT(isObject(dObj) || isActor(dObj));
- ASSERT(isObject(target) || isActor(target));
+ assert(isObject(dObj) || isActor(dObj));
+ assert(isObject(target) || isActor(target));
int16 scriptResult;
@@ -487,7 +487,7 @@ bool ProtoObj::damageAction(ObjectID, ObjectID, ObjectID) {
// Eat this object
bool ProtoObj::eat(ObjectID dObj, ObjectID enactor) {
- ASSERT(dObj != Nothing);
+ assert(dObj != Nothing);
int16 scriptResult;
@@ -508,8 +508,8 @@ bool ProtoObj::eatAction(ObjectID, ObjectID) {
// Insert this object into another object
bool ProtoObj::insert(ObjectID dObj, ObjectID enactor, ObjectID item) {
- ASSERT(dObj != Nothing);
- ASSERT(item != Nothing);
+ assert(dObj != Nothing);
+ assert(item != Nothing);
int16 scriptResult;
@@ -530,7 +530,7 @@ bool ProtoObj::insertAction(ObjectID, ObjectID, ObjectID) {
// Remove this object from the object it is in
bool ProtoObj::remove(ObjectID dObj, ObjectID enactor) {
- ASSERT(dObj != Nothing);
+ assert(dObj != Nothing);
int16 scriptResult;
@@ -555,8 +555,8 @@ bool ProtoObj::acceptDrop(
ObjectID enactor,
ObjectID droppedObj,
int count) {
- ASSERT(dObj != Nothing);
- ASSERT(droppedObj != Nothing);
+ assert(dObj != Nothing);
+ assert(droppedObj != Nothing);
int16 scriptResult;
@@ -626,7 +626,7 @@ bool ProtoObj::acceptHealing(
int8 pdm = perDieMod;
int16 damage = 0;
int16 scriptResult;
- ASSERT(dObj != Nothing);
+ assert(dObj != Nothing);
damage = absDamage;
if (dice)
for (int d = 0; d < abs(dice); d++)
@@ -654,8 +654,8 @@ bool ProtoObj::acceptStrike(
ObjectID enactor,
ObjectID strikingObj,
uint8 skillIndex) {
- ASSERT(dObj != Nothing);
- ASSERT(strikingObj != Nothing);
+ assert(dObj != Nothing);
+ assert(strikingObj != Nothing);
int16 scriptResult;
@@ -687,7 +687,7 @@ bool ProtoObj::acceptLockToggle(
ObjectID dObj,
ObjectID enactor,
uint8 keyCode) {
- ASSERT(dObj != Nothing);
+ assert(dObj != Nothing);
int16 scriptResult;
@@ -715,8 +715,8 @@ bool ProtoObj::acceptLockToggleAction(ObjectID, ObjectID, uint8) {
// Mix this object with another.
bool ProtoObj::acceptMix(ObjectID dObj, ObjectID enactor, ObjectID mixObj) {
- ASSERT(dObj != Nothing);
- ASSERT(mixObj != Nothing);
+ assert(dObj != Nothing);
+ assert(mixObj != Nothing);
int16 scriptResult;
@@ -741,8 +741,8 @@ bool ProtoObj::acceptInsertion(
ObjectID enactor,
ObjectID item,
int16 count) {
- ASSERT(dObj != Nothing);
- ASSERT(item != Nothing);
+ assert(dObj != Nothing);
+ assert(item != Nothing);
if (!canContain(dObj, item)) return FALSE;
@@ -770,8 +770,8 @@ bool ProtoObj::acceptInsertionAt(
ObjectID item,
const TilePoint &where,
int16 num) {
- ASSERT(dObj != Nothing);
- ASSERT(item != Nothing);
+ assert(dObj != Nothing);
+ assert(item != Nothing);
if (!canContainAt(dObj, item, where)) return FALSE;
@@ -1022,7 +1022,7 @@ bool InventoryProto::canDropAt(
ObjectID,
ObjectID enactor,
const Location &loc) {
- ASSERT(enactor != Nothing);
+ assert(enactor != Nothing);
// If we're not dropping it onto a world, we're okay
if (!isWorld(loc.context)) return TRUE;
@@ -1045,9 +1045,9 @@ bool InventoryProto::dropAction(
ObjectID enactor,
const Location &loc,
int16 num) {
- ASSERT(loc.context != Nothing);
- ASSERT(dObj != Nothing);
- ASSERT(enactor != Nothing);
+ assert(loc.context != Nothing);
+ assert(dObj != Nothing);
+ assert(enactor != Nothing);
GameObject *dObjPtr = GameObject::objectAddress(dObj);
Actor *enactorPtr = (Actor *)GameObject::objectAddress(enactor);
@@ -1147,9 +1147,9 @@ bool InventoryProto::dropOnAction(
ActiveItem *target,
const Location &loc,
int16 num) {
- ASSERT(dObj != Nothing);
- ASSERT(target != NULL);
- ASSERT(isWorld(loc.context));
+ assert(dObj != Nothing);
+ assert(target != NULL);
+ assert(isWorld(loc.context));
if (drop(dObj, enactor, loc, num)) {
GameObject *dObjPtr = GameObject::objectAddress(dObj);
@@ -1188,9 +1188,9 @@ bool InventoryProto::acceptStrikeAction(
ObjectID enactor,
ObjectID strikingObj,
uint8) {
- ASSERT(isObject(dObj) || isActor(dObj));
- ASSERT(isActor(enactor));
- ASSERT(isObject(strikingObj) || isActor(strikingObj));
+ assert(isObject(dObj) || isActor(dObj));
+ assert(isActor(enactor));
+ assert(isObject(strikingObj) || isActor(strikingObj));
GameObject *weapon = GameObject::objectAddress(strikingObj);
@@ -1259,7 +1259,7 @@ bool PhysicalContainerProto::openAction(ObjectID dObj, ObjectID) {
GameObject *dObjPtr = GameObject::objectAddress(dObj);
- ASSERT(!dObjPtr->isOpen() && !dObjPtr->isLocked());
+ assert(!dObjPtr->isOpen() && !dObjPtr->isLocked());
cn = CreateContainerNode(dObj, FALSE);
cn->markForShow(); // Deferred open
@@ -1272,8 +1272,8 @@ bool PhysicalContainerProto::closeAction(ObjectID dObj, ObjectID) {
GameObject *dObjPtr = GameObject::objectAddress(dObj);
ContainerNode *cn = globalContainerList.find(dObj, ContainerNode::physicalType);
- ASSERT(dObjPtr->isOpen());
- ASSERT(cn);
+ assert(dObjPtr->isOpen());
+ assert(cn);
// Delete the container (lazy delete)
cn->markForDelete();
@@ -1312,8 +1312,8 @@ bool PhysicalContainerProto::acceptInsertionAction(
ObjectID enactor,
ObjectID item,
int16 num) {
- ASSERT(isObject(dObj));
- ASSERT(isObject(item));
+ assert(isObject(dObj));
+ assert(isObject(item));
GameObject *dObjPtr = GameObject::objectAddress(dObj);
GameObject *itemPtr = GameObject::objectAddress(item);
@@ -1346,8 +1346,8 @@ bool PhysicalContainerProto::acceptInsertionAtAction(
ObjectID item,
const TilePoint &where,
int16 num) {
- ASSERT(isObject(dObj));
- ASSERT(isObject(item));
+ assert(isObject(dObj));
+ assert(isObject(item));
GameObject *dObjPtr = GameObject::objectAddress(dObj);
GameObject *itemPtr = GameObject::objectAddress(item);
@@ -1442,7 +1442,7 @@ uint16 PhysicalContainerProto::bulkCapacity(GameObject *) {
// Put key into mouse with intention to use
bool KeyProto::setUseCursor(ObjectID dObj) {
- ASSERT(mouseInfo.getObjectId() == Nothing);
+ assert(mouseInfo.getObjectId() == Nothing);
mouseInfo.copyObject(GameObject::objectAddress(dObj), GrabInfo::Use);
return TRUE;
}
@@ -1549,8 +1549,8 @@ bool WeaponProto::isObjectBeingUsed(GameObject *obj) {
// Place weapon into right hand
bool MeleeWeaponProto::useAction(ObjectID dObj, ObjectID enactor) {
- ASSERT(isObject(dObj));
- ASSERT(isActor(enactor));
+ assert(isObject(dObj));
+ assert(isActor(enactor));
GameObject *dObjPtr = GameObject::objectAddress(dObj);
Actor *a = (Actor *)GameObject::objectAddress(enactor);
@@ -1593,9 +1593,9 @@ bool MeleeWeaponProto::strikeAction(
ObjectID dObj,
ObjectID enactor,
ObjectID item) {
- ASSERT(isObject(dObj));
- ASSERT(isActor(enactor));
- ASSERT(isObject(item) || isActor(item));
+ assert(isObject(dObj));
+ assert(isActor(enactor));
+ assert(isObject(item) || isActor(item));
GameObject *itemPtr = GameObject::objectAddress(item);
ObjectSoundFXs *soundFXs;
@@ -1615,9 +1615,9 @@ bool MeleeWeaponProto::damageAction(
ObjectID dObj,
ObjectID enactor,
ObjectID target) {
- ASSERT(isObject(dObj));
- ASSERT(isActor(enactor));
- ASSERT(isObject(target) || isActor(target));
+ assert(isObject(dObj));
+ assert(isActor(enactor));
+ assert(isObject(target) || isActor(target));
Actor *a = (Actor *)GameObject::objectAddress(enactor);
ActorAttributes *effStats = a->getStats();
@@ -1655,7 +1655,7 @@ bool MeleeWeaponProto::acceptDamageAction(
// Determine if this type of weapon must be wielded with two hands
// for the specified actor
bool MeleeWeaponProto::isTwoHanded(ObjectID attackerID) {
- ASSERT(isActor(attackerID));
+ assert(isActor(attackerID));
Actor *attackerPtr = (Actor *)GameObject::objectAddress(attackerID);
ActorProto *attackerProto = (ActorProto *)attackerPtr->proto();
@@ -1669,8 +1669,8 @@ bool MeleeWeaponProto::isTwoHanded(ObjectID attackerID) {
// Initiate a melee weapon attack motion
void MeleeWeaponProto::initiateAttack(ObjectID attacker, ObjectID target) {
- ASSERT(isActor(attacker));
- ASSERT(isObject(target) || isActor(target));
+ assert(isActor(attacker));
+ assert(isObject(target) || isActor(target));
Actor *attackerPtr = (Actor *)GameObject::objectAddress(attacker);
GameObject *targetPtr = GameObject::objectAddress(target);
@@ -1687,9 +1687,9 @@ void MeleeWeaponProto::initiateDefense(
ObjectID defensiveObj,
ObjectID defender,
ObjectID attacker) {
- ASSERT(isObject(defensiveObj));
- ASSERT(isActor(defender));
- ASSERT(isActor(attacker));
+ assert(isObject(defensiveObj));
+ assert(isActor(defender));
+ assert(isActor(attacker));
GameObject *weapon = GameObject::objectAddress(defensiveObj);
Actor *defenderPtr = (Actor *)GameObject::objectAddress(defender),
@@ -1719,8 +1719,8 @@ uint8 MeleeWeaponProto::weaponRating(
ObjectID weaponID,
ObjectID wielderID,
ObjectID targetID) {
- ASSERT(isActor(wielderID));
- ASSERT(isObject(targetID) || isActor(targetID));
+ assert(isActor(wielderID));
+ assert(isObject(targetID) || isActor(targetID));
Actor *wielder = (Actor *)GameObject::objectAddress(wielderID);
@@ -1761,12 +1761,12 @@ uint8 MeleeWeaponProto::getDamageSound(const ObjectSoundFXs &soundFXs) {
// specified actor
bool MeleeWeaponProto::useSlotAvailable(GameObject *obj, Actor *a) {
- ASSERT(isObject(obj) && obj->proto() == this);
- ASSERT(isActor(a));
+ assert(isObject(obj) && obj->proto() == this);
+ assert(isActor(a));
if (a->rightHandObject == Nothing) {
if (a->leftHandObject != Nothing) {
- ASSERT(isObject(a->leftHandObject));
+ assert(isObject(a->leftHandObject));
GameObject *leftHandObjectPtr;
@@ -1776,7 +1776,7 @@ bool MeleeWeaponProto::useSlotAvailable(GameObject *obj, Actor *a) {
}
return TRUE;
}
- ASSERT(isObject(a->rightHandObject));
+ assert(isObject(a->rightHandObject));
return FALSE;
}
@@ -1789,7 +1789,7 @@ bool MeleeWeaponProto::useSlotAvailable(GameObject *obj, Actor *a) {
// Get the value of the wielder's skill which applies to this weapon
uint8 BludgeoningWeaponProto::getSkillValue(ObjectID enactor) {
- ASSERT(isActor(enactor));
+ assert(isActor(enactor));
Actor *a;
ActorAttributes *effStats;
@@ -1804,7 +1804,7 @@ uint8 BludgeoningWeaponProto::getSkillValue(ObjectID enactor) {
// Cause the user's associated skill to grow
void BludgeoningWeaponProto::applySkillGrowth(ObjectID enactor, uint8 points) {
- ASSERT(isActor(enactor));
+ assert(isActor(enactor));
PlayerActorID playerID;
@@ -1826,7 +1826,7 @@ void BludgeoningWeaponProto::applySkillGrowth(ObjectID enactor, uint8 points) {
// Get the value of the wielder's skill which applies to this weapon
uint8 SlashingWeaponProto::getSkillValue(ObjectID enactor) {
- ASSERT(isActor(enactor));
+ assert(isActor(enactor));
Actor *a;
ActorAttributes *effStats;
@@ -1841,7 +1841,7 @@ uint8 SlashingWeaponProto::getSkillValue(ObjectID enactor) {
// Cause the user's associated skill to grow
void SlashingWeaponProto::applySkillGrowth(ObjectID enactor, uint8 points) {
- ASSERT(isActor(enactor));
+ assert(isActor(enactor));
PlayerActorID playerID;
@@ -1860,8 +1860,8 @@ void SlashingWeaponProto::applySkillGrowth(ObjectID enactor, uint8 points) {
* ==================================================================== */
bool BowProto::useAction(ObjectID dObj, ObjectID enactor) {
- ASSERT(isObject(dObj));
- ASSERT(isActor(enactor));
+ assert(isObject(dObj));
+ assert(isActor(enactor));
GameObject *dObjPtr = GameObject::objectAddress(dObj);
Actor *a = (Actor *)GameObject::objectAddress(enactor);
@@ -1887,8 +1887,8 @@ bool BowProto::isTwoHanded(ObjectID) {
// Initiate the bow firing motion
void BowProto::initiateAttack(ObjectID attacker, ObjectID target) {
- ASSERT(isActor(attacker));
- ASSERT(isObject(target) || isActor(target));
+ assert(isActor(attacker));
+ assert(isObject(target) || isActor(target));
Actor *attackerPtr = (Actor *)GameObject::objectAddress(attacker);
GameObject *targetPtr = GameObject::objectAddress(target);
@@ -1898,8 +1898,8 @@ void BowProto::initiateAttack(ObjectID attacker, ObjectID target) {
// Grab an arrow from the actor's inventory
GameObject *BowProto::getProjectile(ObjectID weapon, ObjectID enactor) {
- ASSERT(isObject(weapon));
- ASSERT(isActor(enactor));
+ assert(isObject(weapon));
+ assert(isActor(enactor));
GameObject *obj,
*arrow = NULL;
@@ -1929,8 +1929,8 @@ GameObject *BowProto::getProjectile(ObjectID weapon, ObjectID enactor) {
// specified actor
bool BowProto::useSlotAvailable(GameObject *obj, Actor *a) {
- ASSERT(isObject(obj) && obj->proto() == this);
- ASSERT(isActor(a));
+ assert(isObject(obj) && obj->proto() == this);
+ assert(isActor(a));
return a->leftHandObject == Nothing && a->rightHandObject == Nothing;
}
@@ -1942,8 +1942,8 @@ uint8 BowProto::weaponRating(
ObjectID weaponID,
ObjectID wielderID,
ObjectID targetID) {
- ASSERT(isActor(wielderID));
- ASSERT(isObject(targetID) || isActor(targetID));
+ assert(isActor(wielderID));
+ assert(isObject(targetID) || isActor(targetID));
if (getProjectile(weaponID, wielderID) == NULL) return 0;
@@ -1978,8 +1978,8 @@ int16 BowProto::fightStanceAction(ObjectID actor) {
* ==================================================================== */
bool WeaponWandProto::useAction(ObjectID dObj, ObjectID enactor) {
- ASSERT(isObject(dObj));
- ASSERT(isActor(enactor));
+ assert(isObject(dObj));
+ assert(isActor(enactor));
GameObject *dObjPtr = GameObject::objectAddress(dObj);
Actor *a = (Actor *)GameObject::objectAddress(enactor);
@@ -2005,8 +2005,8 @@ bool WeaponWandProto::isTwoHanded(ObjectID) {
// Initiate the use wand motion
void WeaponWandProto::initiateAttack(ObjectID attacker, ObjectID target) {
- ASSERT(isActor(attacker));
- ASSERT(isObject(target) || isActor(target));
+ assert(isActor(attacker));
+ assert(isObject(target) || isActor(target));
Actor *attackerPtr = (Actor *)GameObject::objectAddress(attacker);
GameObject *targetPtr = GameObject::objectAddress(target);
@@ -2019,8 +2019,8 @@ void WeaponWandProto::initiateAttack(ObjectID attacker, ObjectID target) {
// specified actor
bool WeaponWandProto::useSlotAvailable(GameObject *obj, Actor *a) {
- ASSERT(isObject(obj) && obj->proto() == this);
- ASSERT(isActor(a));
+ assert(isObject(obj) && obj->proto() == this);
+ assert(isActor(a));
return a->leftHandObject == Nothing && a->rightHandObject == Nothing;
}
@@ -2032,9 +2032,9 @@ uint8 WeaponWandProto::weaponRating(
ObjectID weaponID,
ObjectID wielderID,
ObjectID targetID) {
- ASSERT(isObject(weaponID) || isActor(weaponID));
- ASSERT(isActor(wielderID));
- ASSERT(isObject(targetID) || isActor(targetID));
+ assert(isObject(weaponID) || isActor(weaponID));
+ assert(isActor(wielderID));
+ assert(isObject(targetID) || isActor(targetID));
Actor *wielder = (Actor *)GameObject::objectAddress(wielderID);
@@ -2121,9 +2121,9 @@ bool ArrowProto::strikeAction(
ObjectID dObj,
ObjectID enactor,
ObjectID item) {
- ASSERT(isObject(dObj));
- ASSERT(isActor(enactor));
- ASSERT(isObject(item) || isActor(item));
+ assert(isObject(dObj));
+ assert(isActor(enactor));
+ assert(isObject(item) || isActor(item));
Actor *a = (Actor *)GameObject::objectAddress(enactor);
GameObject *itemPtr = GameObject::objectAddress(item);
@@ -2138,9 +2138,9 @@ bool ArrowProto::damageAction(
ObjectID dObj,
ObjectID enactor,
ObjectID target) {
- ASSERT(isObject(dObj));
- ASSERT(isActor(enactor));
- ASSERT(isObject(target) || isActor(target));
+ assert(isObject(dObj));
+ assert(isActor(enactor));
+ assert(isObject(target) || isActor(target));
Actor *a = (Actor *)GameObject::objectAddress(enactor);
ActorAttributes *effStats = a->getStats();
@@ -2168,7 +2168,7 @@ bool ArrowProto::damageAction(
// Cause the user's associated skill to grow
void ArrowProto::applySkillGrowth(ObjectID enactor, uint8 points) {
- ASSERT(isActor(enactor));
+ assert(isActor(enactor));
PlayerActorID playerID;
@@ -2226,8 +2226,8 @@ bool ArmorProto::isObjectBeingUsed(GameObject *obj) {
// specified actor
bool ArmorProto::useSlotAvailable(GameObject *obj, Actor *a) {
- ASSERT(isObject(obj) || obj->proto() == this);
- ASSERT(isActor(a));
+ assert(isObject(obj) || obj->proto() == this);
+ assert(isActor(a));
return a->armorObjects[ whereWearable ] == Nothing;
}
@@ -2236,14 +2236,14 @@ bool ArmorProto::useSlotAvailable(GameObject *obj, Actor *a) {
// "Wear" a piece of armor.
bool ArmorProto::useAction(ObjectID dObj, ObjectID enactor) {
- ASSERT(isObject(dObj));
- ASSERT(isActor(enactor));
+ assert(isObject(dObj));
+ assert(isActor(enactor));
PlayerActorID pID;
Actor *a = (Actor *)GameObject::objectAddress(enactor);
GameObject *obj = GameObject::objectAddress(dObj);
- ASSERT(obj->proto() == this);
+ assert(obj->proto() == this);
if (enactor != obj->IDParent()) return FALSE;
@@ -2269,8 +2269,8 @@ uint16 ShieldProto::containmentSet(void) {
// Place shield into left hand
bool ShieldProto::useAction(ObjectID dObj, ObjectID enactor) {
- ASSERT(isObject(dObj));
- ASSERT(isActor(enactor));
+ assert(isObject(dObj));
+ assert(isActor(enactor));
GameObject *dObjPtr = GameObject::objectAddress(dObj);
Actor *a = (Actor *)GameObject::objectAddress(enactor);
@@ -2278,7 +2278,7 @@ bool ShieldProto::useAction(ObjectID dObj, ObjectID enactor) {
if (enactor != dObjPtr->IDParent()) return FALSE;
if (a->rightHandObject != Nothing) {
- ASSERT(isObject(a->rightHandObject));
+ assert(isObject(a->rightHandObject));
GameObject *rightHandObjectPtr =
GameObject::objectAddress(a->rightHandObject);
@@ -2311,9 +2311,9 @@ void ShieldProto::initiateDefense(
ObjectID defensiveObj,
ObjectID defender,
ObjectID attacker) {
- ASSERT(isObject(defensiveObj));
- ASSERT(isActor(defender));
- ASSERT(isActor(attacker));
+ assert(isObject(defensiveObj));
+ assert(isActor(defender));
+ assert(isActor(attacker));
GameObject *shield = GameObject::objectAddress(defensiveObj);
Actor *defenderPtr = (Actor *)GameObject::objectAddress(defender),
@@ -2355,12 +2355,12 @@ bool ShieldProto::isObjectBeingUsed(GameObject *obj) {
// specified actor
bool ShieldProto::useSlotAvailable(GameObject *obj, Actor *a) {
- ASSERT(isObject(obj) || obj->proto() == this);
- ASSERT(isActor(a));
+ assert(isObject(obj) || obj->proto() == this);
+ assert(isActor(a));
if (a->leftHandObject == Nothing) {
if (a->rightHandObject != Nothing) {
- ASSERT(isObject(a->rightHandObject));
+ assert(isObject(a->rightHandObject));
GameObject *rightHandObjectPtr;
@@ -2378,7 +2378,7 @@ bool ShieldProto::useSlotAvailable(GameObject *obj, Actor *a) {
// Get the value of the user's skill which applies to this object
uint8 ShieldProto::getSkillValue(ObjectID enactor) {
- ASSERT(isActor(enactor));
+ assert(isActor(enactor));
Actor *a;
ActorAttributes *effStats;
@@ -2393,7 +2393,7 @@ uint8 ShieldProto::getSkillValue(ObjectID enactor) {
// Cause the user's associated skill to grow
void ShieldProto::applySkillGrowth(ObjectID enactor, uint8 points) {
- ASSERT(isActor(enactor));
+ assert(isActor(enactor));
PlayerActorID playerID;
@@ -2421,7 +2421,7 @@ uint8 ShieldProto::getDamageSound(const ObjectSoundFXs &soundFXs) {
// Put tool into mouse with intention to use
bool ToolProto::setUseCursor(ObjectID dObj) {
- ASSERT(mouseInfo.getObjectId() == Nothing);
+ assert(mouseInfo.getObjectId() == Nothing);
mouseInfo.copyObject(GameObject::objectAddress(dObj), GrabInfo::Use);
return TRUE;
}
@@ -2490,7 +2490,7 @@ uint16 IntangibleObjProto::containmentSet(void) {
}
bool IntangibleObjProto::useAction(ObjectID dObj, ObjectID enactor) {
- ASSERT(isObject(dObj));
+ assert(isObject(dObj));
/* GameObject *obj = GameObject::objectAddress(dObj);
@@ -2501,8 +2501,8 @@ bool IntangibleObjProto::useAction(ObjectID dObj, ObjectID enactor) {
}
bool IntangibleObjProto::takeAction(ObjectID dObj, ObjectID enactor, int16) {
- ASSERT(isObject(dObj));
- ASSERT(mouseInfo.getObjectId() == Nothing);
+ assert(isObject(dObj));
+ assert(mouseInfo.getObjectId() == Nothing);
GameObject *dObjPtr = GameObject::objectAddress(dObj);
@@ -2527,9 +2527,9 @@ bool IntangibleObjProto::dropAction(
ObjectID enactor,
const Location &loc,
int16) {
- ASSERT(isObject(dObj));
- ASSERT(loc.context != Nothing);
- ASSERT(!isWorld(loc.context));
+ assert(isObject(dObj));
+ assert(loc.context != Nothing);
+ assert(!isWorld(loc.context));
GameObject *container = GameObject::objectAddress(loc.context);
@@ -2553,7 +2553,7 @@ bool IntangibleObjProto::acceptDropAction(
ObjectID enactor,
ObjectID droppedObj,
int) {
- ASSERT(isObject(dObj));
+ assert(isObject(dObj));
GameObject *dObjPtr = GameObject::objectAddress(dObj);
@@ -2685,7 +2685,7 @@ bool SkillProto::canDropAt(ObjectID, ObjectID, const Location &) {
}
bool SkillProto::dropAction(ObjectID dObj, ObjectID enactor, const Location &loc, int16 num) {
- ASSERT(isActor(enactor));
+ assert(isActor(enactor));
if (isWorld(loc.context)) {
Actor *enactorPtr = (Actor *)GameObject::objectAddress(enactor);
@@ -2700,8 +2700,8 @@ bool SkillProto::dropAction(ObjectID dObj, ObjectID enactor, const Location &lo
}
bool SkillProto::dropOnAction(ObjectID dObj, ObjectID enactor, ObjectID target, int count) {
- ASSERT(isActor(enactor));
- ASSERT(isObject(target) || isActor(target));
+ assert(isActor(enactor));
+ assert(isObject(target) || isActor(target));
GameObject *targetPtr = GameObject::objectAddress(target);
@@ -2721,7 +2721,7 @@ bool SkillProto::dropOnAction(
ActiveItem *target,
const Location &loc,
int16 num) {
- ASSERT(isActor(enactor));
+ assert(isActor(enactor));
if (target != NULL) {
Actor *enactorPtr = (Actor *)GameObject::objectAddress(enactor);
@@ -2768,7 +2768,7 @@ void EnchantmentProto::doBackgroundUpdate(GameObject *obj) {
int16 hitPoints = obj->getHitPoints(); // get hitpoints of enchant
GameObject *parentObj = obj->parent(); // get parent of enchantment
- ASSERT(parentObj);
+ assert(parentObj);
// if this is a poison enchantment
// then hurt the victim
@@ -2975,7 +2975,7 @@ void MissionGeneratorProto::doBackgroundUpdate(GameObject *obj) {
* ==================================================================== */
bool IntangibleContainerProto::canContain(ObjectID dObj, ObjectID item) {
- ASSERT(isObject(item));
+ assert(isObject(item));
GameObject *itemPtr = GameObject::objectAddress(item);
@@ -3019,7 +3019,7 @@ bool IntangibleContainerProto::closeAction(ObjectID dObj, ObjectID) {
GameObject *dObjPtr = GameObject::objectAddress(dObj);
ContainerNode *cn = globalContainerList.find(dObj, ContainerNode::mentalType);
- ASSERT(cn);
+ assert(cn);
// Mark container for lazy deletion
cn->markForDelete();
diff --git a/engines/saga2/oncall.h b/engines/saga2/oncall.h
index cc07a26b26..9d6370d94c 100644
--- a/engines/saga2/oncall.h
+++ b/engines/saga2/oncall.h
@@ -69,7 +69,7 @@ public:
}
RESTYPE operator[](uint32 ind) {
-// ASSERT (ind<handles);
+// assert (ind<handles);
if (!locked[ind]) handle[ind] = rLoad(ind, FALSE);
return handle[ind];
}
diff --git a/engines/saga2/panel.cpp b/engines/saga2/panel.cpp
index b4a38b19b8..0019c16a01 100644
--- a/engines/saga2/panel.cpp
+++ b/engines/saga2/panel.cpp
@@ -1103,7 +1103,7 @@ void LockUI(bool state) {
lockUINest++;
} else {
lockUINest--;
- ASSERT(lockUINest >= 0);
+ assert(lockUINest >= 0);
if (lockUINest <= 0) {
enableUIKeys(TRUE);
pointer.show();
diff --git a/engines/saga2/path.cpp b/engines/saga2/path.cpp
index 89f117431d..cb68e8f4b4 100644
--- a/engines/saga2/path.cpp
+++ b/engines/saga2/path.cpp
@@ -178,8 +178,8 @@ public:
void fetchTileSection(const TilePoint &org, const TilePoint &a);
PathTilePosInfo *tilePos(const TilePoint &pos) {
- ASSERT(pos.u >= origin.u && (pos.u - origin.u) < area.u);
- ASSERT(pos.v >= origin.v && (pos.v - origin.v) < area.v);
+ assert(pos.u >= origin.u && (pos.u - origin.u) < area.u);
+ assert(pos.v >= origin.v && (pos.v - origin.v) < area.v);
return &array[(pos.u - origin.u) * area.v + pos.v - origin.v ];
}
};
@@ -331,8 +331,8 @@ void PathTileRegion::fetchSubMeta(const TilePoint &subMeta) {
tileReg.min.v = (tileReg.min.v + origin.v) & platMask;
tileReg.max.v = tileReg.min.v + offset.v;
- ASSERT(tileReg.max.u <= platformWidth);
- ASSERT(tileReg.max.v <= platformWidth);
+ assert(tileReg.max.u <= platformWidth);
+ assert(tileReg.max.v <= platformWidth);
// Compute the offset of base tile in metatile to origin
offset.u = ((subMeta.u >> 1) << platShift) - origin.u;
@@ -353,14 +353,14 @@ void PathTileRegion::fetchSubMeta(const TilePoint &subMeta) {
for (u = tileReg.min.u; u < tileReg.max.u; u++) {
PathTilePosInfo *arrRow = &array[(u + offset.u) * area.v ];
- ASSERT(u >= 0);
- ASSERT(u < platformWidth);
+ assert(u >= 0);
+ assert(u < platformWidth);
for (v = tileReg.min.v; v < tileReg.max.v; v++) {
int16 flagIndex = ((u & subMetaMask) << subMetaShift) | (v & subMetaMask);
- ASSERT(v >= 0);
- ASSERT(v < platformWidth);
+ assert(v >= 0);
+ assert(v < platformWidth);
if (!(tpFlags & (1 << flagIndex))) {
tpFlags |= (1 << flagIndex);
@@ -378,7 +378,7 @@ void PathTileRegion::fetchSubMeta(const TilePoint &subMeta) {
TileRegion subMetaTag;
TileRef *stateData;
- ASSERT((uint16)tr->tile <= activeItemIndexNullID);
+ assert((uint16)tr->tile <= activeItemIndexNullID);
groupItem = ActiveItem::activeItemAddress(
ActiveItemID(mapNum, tr->tile));
@@ -537,10 +537,10 @@ PathArray::~PathArray(void) {
// be TRUE. If it fails to allocate a new cell it will throw
// a CellAllocationFailure.
PathCell *PathArray::makeCell(int plat, int uCoord, int vCoord, bool *newCell) {
- ASSERT(plat >= 0 && plat < maxPlatforms);
- ASSERT(uCoord >= 0 && uCoord < searchDiameter);
- ASSERT(vCoord >= 0 && vCoord < searchDiameter);
- ASSERT(newCell != NULL);
+ assert(plat >= 0 && plat < maxPlatforms);
+ assert(uCoord >= 0 && uCoord < searchDiameter);
+ assert(vCoord >= 0 && vCoord < searchDiameter);
+ assert(newCell != NULL);
// Compute the chunk coords
int chunkUCoord = uCoord >> 2,
@@ -585,9 +585,9 @@ PathCell *PathArray::makeCell(int plat, int uCoord, int vCoord, bool *newCell) {
// Get a pointer to an existing cell. If the specified cell has
// not been created, it will return NULL.
PathCell *PathArray::getCell(int plat, int uCoord, int vCoord) {
- ASSERT(plat >= 0 && plat < maxPlatforms);
- ASSERT(uCoord >= 0 && uCoord < searchDiameter);
- ASSERT(vCoord >= 0 && vCoord < searchDiameter);
+ assert(plat >= 0 && plat < maxPlatforms);
+ assert(uCoord >= 0 && uCoord < searchDiameter);
+ assert(vCoord >= 0 && vCoord < searchDiameter);
// Compute the chunk coords
int chunkUCoord = uCoord >> 2,
@@ -612,9 +612,9 @@ PathCell *PathArray::getCell(int plat, int uCoord, int vCoord) {
}
void PathArray::deleteCell(int plat, int uCoord, int vCoord) {
- ASSERT(plat >= 0 && plat < maxPlatforms);
- ASSERT(uCoord >= 0 && uCoord < searchDiameter);
- ASSERT(vCoord >= 0 && vCoord < searchDiameter);
+ assert(plat >= 0 && plat < maxPlatforms);
+ assert(uCoord >= 0 && uCoord < searchDiameter);
+ assert(vCoord >= 0 && vCoord < searchDiameter);
// Compute the chunk coords
int chunkUCoord = uCoord >> 2,
@@ -1354,7 +1354,7 @@ static void push(
int cost,
int direction,
int8 platformDelta) {
- ASSERT(cellArray != NULL);
+ assert(cellArray != NULL);
PathCell *cellPtr;
bool newCell;
@@ -1367,7 +1367,7 @@ static void push(
cellPtr = cellArray->makeCell(platform, tp.u, tp.v, &newCell);
- ASSERT(cellPtr != NULL);
+ assert(cellPtr != NULL);
// If the cell is already visited, only
// update it if it was less cost to get here.
@@ -1542,12 +1542,12 @@ void PathRequest::initialize(void) {
for (curTileRegU = minTileRegU;
curTileRegU < maxTileRegU;
curTileRegU++) {
- ASSERT(curTileRegU >= 0 && curTileRegU < searchDiameter);
+ assert(curTileRegU >= 0 && curTileRegU < searchDiameter);
for (curTileRegV = minTileRegV;
curTileRegV < maxTileRegV;
curTileRegV++) {
- ASSERT(curTileRegV >= 0 && curTileRegV < searchDiameter);
+ assert(curTileRegV >= 0 && curTileRegV < searchDiameter);
VolumeLookupNode *node;
VolumeLookupNode **tablePtrPtr;
@@ -1641,7 +1641,7 @@ void PathRequest::finish(void) {
if (bestLoc != Nowhere) {
cell = cellArray->getCell(bestPlatform, bestLoc.u, bestLoc.v);
- ASSERT(cell != NULL);
+ assert(cell != NULL);
if (cell->direction != dirInvalid) {
res = &tempResult[ elementsof(tempResult) ];
@@ -1652,7 +1652,7 @@ void PathRequest::finish(void) {
int16 reverseDir;
cell = cellArray->getCell(bestPlatform, bestLoc.u, bestLoc.v);
- ASSERT(cell != NULL);
+ assert(cell != NULL);
if (cell->direction != dirInvalid) {
if (cell->direction != prevDir
@@ -1676,10 +1676,10 @@ void PathRequest::finish(void) {
reverseDir = (cell->direction + 4) & 0x07;
bestLoc += tDirTable2[ reverseDir ];
- ASSERT(bestLoc.u >= 0 && bestLoc.u < searchDiameter);
- ASSERT(bestLoc.v >= 0 && bestLoc.v < searchDiameter);
+ assert(bestLoc.u >= 0 && bestLoc.u < searchDiameter);
+ assert(bestLoc.v >= 0 && bestLoc.v < searchDiameter);
bestPlatform -= cell->platformDelta;
- ASSERT(bestPlatform >= 0 && bestPlatform < maxPlatforms);
+ assert(bestPlatform >= 0 && bestPlatform < maxPlatforms);
} else
break;
}
@@ -1717,7 +1717,7 @@ void PathRequest::abort(void) {
static uint32 severePathFinderOverruns = 0;
PathResult PathRequest::findPath(void) {
- ASSERT(cellArray != NULL);
+ assert(cellArray != NULL);
static const uint8 costTable[] =
{ 4, 10, 12, 16, 12, 10, 4, 0, 4, 10, 12, 16, 12, 10, 4, 0 };
@@ -1732,9 +1732,9 @@ PathResult PathRequest::findPath(void) {
lastTick = gameTime;
while (queue.remove(qi)) {
- ASSERT(cellArray->getCell(qi.platform, qi.u, qi.v) != NULL);
- ASSERT(qi.u >= 1 && qi.u < searchDiameter - 1);
- ASSERT(qi.v >= 1 && qi.v < searchDiameter - 1);
+ assert(cellArray->getCell(qi.platform, qi.u, qi.v) != NULL);
+ assert(qi.u >= 1 && qi.u < searchDiameter - 1);
+ assert(qi.v >= 1 && qi.v < searchDiameter - 1);
TilePoint centerTileCoords;
TilePoint *tDir;
@@ -2049,7 +2049,7 @@ PathResult PathRequest::findPath(void) {
cost,
dir,
testPlatform - centerPlatform);
- ASSERT(cellArray->getCell(centerPlatform, qi.u, qi.v) != NULL);
+ assert(cellArray->getCell(centerPlatform, qi.u, qi.v) != NULL);
big_continue:
;
@@ -2493,7 +2493,7 @@ TilePoint selectNearbySite(
int32 minDist,
int32 maxDist,
bool offScreenOnly) { // TRUE if we want it off-screen
- ASSERT(isWorld(worldID));
+ assert(isWorld(worldID));
TilePoint baseCoords,
baseTileCoords,
diff --git a/engines/saga2/patrol.cpp b/engines/saga2/patrol.cpp
index c1984e6f2a..b47ba1d36c 100644
--- a/engines/saga2/patrol.cpp
+++ b/engines/saga2/patrol.cpp
@@ -93,7 +93,7 @@ void PatrolRouteList::setRouteData(PatrolRouteData *data) {
currentRoute =
(PatrolRoute *) & (*currentRoute)[ currentRoute->vertices() ]) {
#if DEBUG
- VERIFY(currentRoute->vertices() > 1);
+ assert(currentRoute->vertices() > 1);
#endif
warning("STUB: PatrolRouteList::setRouteData: unsafe arithmetics");
offsetArray[ i ] = 0; // FIXME: It was "currentRoute - routeData";
diff --git a/engines/saga2/player.cpp b/engines/saga2/player.cpp
index 7944e49143..9c13adadb2 100644
--- a/engines/saga2/player.cpp
+++ b/engines/saga2/player.cpp
@@ -366,7 +366,7 @@ void PlayerActor::vitalityAdvance(uint8 points) {
}
}
- ASSERT(baseStats.vitality < ActorAttributes::vitalityLimit);
+ assert(baseStats.vitality < ActorAttributes::vitalityLimit);
}
// this function will return a value of 0 - 4 to indicate
@@ -492,7 +492,7 @@ ActorAttributes *PlayerActor::getEffStats(void) {
ActorAttributes *effStats = &actor->effectiveStats;
// valid?
- ASSERT(effStats);
+ assert(effStats);
// return current stats for this player actor
return effStats;
@@ -516,7 +516,7 @@ void PlayerActor::handleAttacked(void) {
// Return a pointer to a PlayerActor given it's ID
PlayerActor *getPlayerActorAddress(PlayerActorID id) {
- ASSERT(id >= 0 && id < elementsof(playerList));
+ assert(id >= 0 && id < elementsof(playerList));
return &playerList[ id ];
}
@@ -555,7 +555,7 @@ PlayerActorID getCenterActorPlayerID(void) {
void setCenterActor(PlayerActorID newCenter) {
extern void setEnchantmentDisplay(void);
- ASSERT(newCenter < playerActors);
+ assert(newCenter < playerActors);
Actor *a = playerList[ newCenter ].getActor();
PlayerActorIterator iter;
@@ -601,7 +601,7 @@ void setCenterActor(PlayerActorID newCenter) {
// Set a new center actor based upon an Actor address
void setCenterActor(Actor *newCenter) {
- ASSERT(newCenter->disposition >= dispositionPlayer);
+ assert(newCenter->disposition >= dispositionPlayer);
setCenterActor(newCenter->disposition - dispositionPlayer);
}
@@ -609,7 +609,7 @@ void setCenterActor(Actor *newCenter) {
// Set a new center actor based upon a PlayerActor address
void setCenterActor(PlayerActor *newCenter) {
- ASSERT(newCenter >= playerList && newCenter < &playerList[ playerActors ]);
+ assert(newCenter >= playerList && newCenter < &playerList[ playerActors ]);
setCenterActor(newCenter - playerList);
}
@@ -628,7 +628,7 @@ TilePoint centerActorCoords(void) {
// Set or clear a player's aggressive state
void setAggression(PlayerActorID player, bool aggression) {
- ASSERT(player >= 0 && player < playerActors);
+ assert(player >= 0 && player < playerActors);
Actor *a = playerList[ player ].getActor();
@@ -651,7 +651,7 @@ void setAggression(PlayerActorID player, bool aggression) {
// Determine if player actor is in an aggressive state
bool isAggressive(PlayerActorID player) {
- ASSERT(player >= 0 && player < playerActors);
+ assert(player >= 0 && player < playerActors);
return playerList[ player ].isAggressive();
}
@@ -703,7 +703,7 @@ void autoAdjustAggression(void) {
// Set a player actor's banding
void setBanded(PlayerActorID player, bool banded) {
- ASSERT(player >= 0 && player < playerActors);
+ assert(player >= 0 && player < playerActors);
if (playerList[ player ].getActor()->isDead()) return;
@@ -721,7 +721,7 @@ void setBanded(PlayerActorID player, bool banded) {
// Determine if a player actor is banded
bool isBanded(PlayerActorID player) {
- ASSERT(player >= 0 && player < playerActors);
+ assert(player >= 0 && player < playerActors);
return playerList[ player ].isBanded();
}
@@ -791,7 +791,7 @@ bool actorIDToPlayerID(ObjectID id, PlayerActorID &result) {
}
void handlePlayerActorDeath(PlayerActorID id) {
- ASSERT(id >= 0 && id < playerActors);
+ assert(id >= 0 && id < playerActors);
if (getCenterActor()->isDead()) {
PlayerActor *newCenter;
@@ -818,7 +818,7 @@ void handlePlayerActorDeath(PlayerActorID id) {
// to the center actor
void transportCenterBand(const Location &loc) {
- ASSERT(isWorld(loc.context));
+ assert(isWorld(loc.context));
fadeDown();
diff --git a/engines/saga2/player.h b/engines/saga2/player.h
index 761f177b55..d46f016c38 100644
--- a/engines/saga2/player.h
+++ b/engines/saga2/player.h
@@ -111,7 +111,7 @@ public:
vitalityMemory(0) {
int i;
- ASSERT(ActorAttributes::skillFracPointsPerLevel > 0); // this is used in a divide
+ assert(ActorAttributes::skillFracPointsPerLevel > 0); // this is used in a divide
memset(&baseStats, 0, sizeof(baseStats));
diff --git a/engines/saga2/playmode.cpp b/engines/saga2/playmode.cpp
index b166bec3b1..51b2abb49f 100644
--- a/engines/saga2/playmode.cpp
+++ b/engines/saga2/playmode.cpp
@@ -205,7 +205,7 @@ void PlayModeSetup(void) {
// for tile mode.
// NOTE: Make sure these are allocated first, so that they
// can over-ride other controls.
- VERIFY(speakButtonControls = NEW_UI gPanelList(*mainWindow));
+ assert(speakButtonControls = NEW_UI gPanelList(*mainWindow));
// Create a control covering the map area.
speakButtonPanel = NEW_UI gGenericControl(*speakButtonControls,
@@ -216,11 +216,11 @@ void PlayModeSetup(void) {
// Create a panelList to contain all controls created
// for play mode.
- VERIFY(playControls = NEW_UI gPanelList(*mainWindow));
+ assert(playControls = NEW_UI gPanelList(*mainWindow));
// Create a panelList to contain all controls created
// for tile mode.
- VERIFY(tileControls = NEW_UI gPanelList(*mainWindow));
+ assert(tileControls = NEW_UI gPanelList(*mainWindow));
// Create a panelList to contain all controls created
// for stage mode.
diff --git a/engines/saga2/property.cpp b/engines/saga2/property.cpp
index c10a839e9f..22e3aaec86 100644
--- a/engines/saga2/property.cpp
+++ b/engines/saga2/property.cpp
@@ -181,7 +181,7 @@ CompoundMetaTileProperty::CompoundMetaTileProperty(
// Allocate memory for a copy of the array
propertyArray = (MetaTileProperty **)malloc(arrayBytes);
#if DEBUG
- VERIFY(propertyArray);
+ assert(propertyArray);
#endif
// Copy the array
memcpy(propertyArray, array, arrayBytes);
diff --git a/engines/saga2/property.h b/engines/saga2/property.h
index 1dcdc5c981..36371cea67 100644
--- a/engines/saga2/property.h
+++ b/engines/saga2/property.h
@@ -120,7 +120,7 @@ CompoundProperty< T >::CompoundProperty(
// Allocate memory to copy the array.
propertyArray = (Property< T > **)TALLOC(arrayBytes, memPropList);
#if DEBUG
- VERIFY(propertyArray);
+ assert(propertyArray);
#endif
// Copy the array
memcpy(propertyArray, array, arrayBytes);
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index 00b6ea2ebf..b6f7115881 100644
--- a/engines/saga2/sagafunc.cpp
+++ b/engines/saga2/sagafunc.cpp
@@ -728,7 +728,7 @@ int16 scriptGameObjectAddProtaganistSensor(int16 *args) {
int16 scriptGameObjectAddSpecificActorSensor(int16 *args) {
OBJLOG(AddSpecificActorSensor);
- ASSERT(isActor(args[ 2 ]));
+ assert(isActor(args[ 2 ]));
GameObject *obj = (GameObject *)thisThread->thisObject;
@@ -748,7 +748,7 @@ int16 scriptGameObjectAddSpecificActorSensor(int16 *args) {
int16 scriptGameObjectAddSpecificObjectSensor(int16 *args) {
OBJLOG(AddSpecificObjectSensor);
- ASSERT(isObject(args[ 2 ]) || isActor(args[ 2 ]));
+ assert(isObject(args[ 2 ]) || isActor(args[ 2 ]));
GameObject *obj = (GameObject *)thisThread->thisObject;
@@ -854,7 +854,7 @@ int16 scriptGameObjectCanSenseProtaganist(int16 *args) {
int16 scriptGameObjectCanSenseSpecificActor(int16 *args) {
OBJLOG(CanSenseSpecificActor);
- ASSERT(isActor(args[ 1 ]));
+ assert(isActor(args[ 1 ]));
GameObject *obj = (GameObject *)thisThread->thisObject;
SenseInfo info;
@@ -881,7 +881,7 @@ int16 scriptGameObjectCanSenseSpecificActor(int16 *args) {
int16 scriptGameObjectCanSenseSpecificObject(int16 *args) {
OBJLOG(CanSenseSpecificObject);
- ASSERT(isObject(args[ 1 ]) || isActor(args[ 1 ]));
+ assert(isObject(args[ 1 ]) || isActor(args[ 1 ]));
GameObject *obj = (GameObject *)thisThread->thisObject;
SenseInfo info;
@@ -988,8 +988,8 @@ int16 scriptGameObjectSetMass(int16 *args) {
OBJLOG(SetMass);
GameObject *obj = (GameObject *)thisThread->thisObject;
-// ASSERT( args[ 0 ] > 0 );
- ASSERT(args[ 0 ] < maxuint16);
+// assert( args[ 0 ] > 0 );
+ assert(args[ 0 ] < maxuint16);
if (obj->proto()->flags & ResourceObjectPrototype::objPropMergeable) {
obj->setExtra(args[ 0 ]);
@@ -1565,7 +1565,7 @@ int16 scriptActorFaceTowards(int16 *args) {
int16 oldFacing = 0;
if (isActor((GameObject *)thisThread->thisObject)) {
- ASSERT(isObject(args[ 0 ]) || isActor(args[ 0 ]));
+ assert(isObject(args[ 0 ]) || isActor(args[ 0 ]));
Actor *a = (Actor *)thisThread->thisObject;
@@ -1611,7 +1611,7 @@ int16 scriptActorTurn(int16 *args) {
int16 scriptActorTurnTowards(int16 *args) {
OBJLOG(TurnTowards);
if (isActor((GameObject *)thisThread->thisObject)) {
- ASSERT(isObject(args[ 0 ]) || isActor(args[ 0 ]));
+ assert(isObject(args[ 0 ]) || isActor(args[ 0 ]));
Actor *a = (Actor *)thisThread->thisObject;
@@ -1766,7 +1766,7 @@ int16 scriptActorAssignBeNearLocation(int16 *args) {
int16 scriptActorAssignBeNearActor(int16 *args) {
OBJLOG(AssignBeNearActor);
if (isActor((GameObject *)thisThread->thisObject)) {
- ASSERT(isActor(args[ 1 ]));
+ assert(isActor(args[ 1 ]));
Actor *a = (Actor *)thisThread->thisObject,
*targetActor;
@@ -1795,7 +1795,7 @@ int16 scriptActorAssignBeNearActor(int16 *args) {
int16 scriptActorAssignKillActor(int16 *args) {
OBJLOG(AssignKillActor);
if (isActor((GameObject *)thisThread->thisObject)) {
- ASSERT(isActor(args[ 1 ]));
+ assert(isActor(args[ 1 ]));
Actor *a = (Actor *)thisThread->thisObject,
*targetActor;
@@ -1913,7 +1913,7 @@ int16 scriptActorBandWith(int16 *args) {
if (isActor((GameObject *)thisThread->thisObject)) {
Actor *a = (Actor *)thisThread->thisObject;
- ASSERT(isActor(args[ 0 ]));
+ assert(isActor(args[ 0 ]));
a->bandWith((Actor *)GameObject::objectAddress(args[ 0 ]));
}
@@ -1975,8 +1975,8 @@ int16 scriptActorGetFollower(int16 *args) {
if (isActor((GameObject *)thisThread->thisObject)) {
Actor *a = (Actor *)thisThread->thisObject;
- ASSERT(a->followers != NULL);
- ASSERT(args[ 0 ] < a->followers->size());
+ assert(a->followers != NULL);
+ assert(args[ 0 ] < a->followers->size());
return (*a->followers)[ args[ 0 ] ]->thisID();
}
@@ -2406,10 +2406,10 @@ int16 scriptTagAssoc(int16 *args) {
ActiveItem *ai = (ActiveItem *)thisThread->thisObject;
int mapNum = ai->getMapNum();
- ASSERT(args[ 0 ] >= 0);
- ASSERT(args[ 0 ] < ai->numAssociations);
- ASSERT(mapNum >= 0);
- ASSERT(mapNum < 8);
+ assert(args[ 0 ] >= 0);
+ assert(args[ 0 ] < ai->numAssociations);
+ assert(mapNum >= 0);
+ assert(mapNum < 8);
return (*mapList[ mapNum ].assocList)[ ai->associationOffset + args[ 0 ] ];
}
@@ -2527,8 +2527,8 @@ int16 scriptTagSetAnimation(int16 *args) {
tagLoc.z = ai->instance.h * 8 - a->getLocation().z;
#endif
// Assert that the state is valid
- ASSERT(args[ 1 ] >= 0);
- ASSERT(args[ 1 ] < ai->getGroup()->group.numStates);
+ assert(args[ 1 ] >= 0);
+ assert(args[ 1 ] < ai->getGroup()->group.numStates);
// If soundID is not NULL, then play the sound
if (soundID) playSoundAt(soundID, ail);
@@ -2999,7 +2999,7 @@ int16 scriptDeleteObject(int16 *args) {
GameObject *obj = GameObject::objectAddress(args[ 0 ]);
ObjectID oldParentID;
- VERIFY(obj);
+ assert(obj);
oldParentID = obj->IDParent();
obj->deleteObjectRecursive();
globalContainerList.setUpdate(oldParentID);
@@ -3020,7 +3020,7 @@ int16 scriptMakeActor(int16 *args) {
int32 actorAppearanceNum;
Actor *a;
- VERIFY(actorAppearanceName);
+ assert(actorAppearanceName);
memcpy(&actorAppearanceNum, actorAppearanceName, 4);
a = Actor::newActor(
@@ -3095,7 +3095,7 @@ int16 scriptPlaySoundFrom(int16 *args) {
int32 soundID;
soundID = parse_res_id(sID);
GameObject *go = GameObject::objectAddress(args[1]);
- ASSERT(go != NULL);
+ assert(go != NULL);
if (soundID) playSoundAt(soundID, go->notGetWorldLocation());
return 0;
@@ -3198,10 +3198,10 @@ int16 scriptResID(int16 *args) {
int16 scriptWorldNum2Object(int16 *args) {
MONOLOG(WorldNum2Object);
- ASSERT(args[ 0 ] >= 0);
+ assert(args[ 0 ] >= 0);
// REM: I can't seem to find a symbolic constant for the
// maximum number of worlds. I know that it's currently 8.
- ASSERT(args[ 0 ] < 8);
+ assert(args[ 0 ] < 8);
return args[ 0 ] + WorldBaseID;
}
@@ -3280,8 +3280,8 @@ int16 scriptAssertEvent(int16 *args) {
MONOLOG(AssertEvent);
GameEvent ev;
- ASSERT(isObject(args[ 1 ]) || isActor(args[ 1 ]));
- ASSERT(args[ 2 ] == Nothing
+ assert(isObject(args[ 1 ]) || isActor(args[ 1 ]));
+ assert(args[ 2 ] == Nothing
|| isObject(args[ 2 ])
|| isActor(args[ 2 ]));
@@ -3332,8 +3332,8 @@ int16 scriptCanCast(int16 *args) {
MONOLOG(CanCast);
GameObject *caster = GameObject::objectAddress(*args++);
SkillProto *spell = skillProtoFromID(*args++);
- VERIFY(caster);
- VERIFY(spell);
+ assert(caster);
+ assert(spell);
return canCast(caster, spell);
}
@@ -3342,9 +3342,9 @@ int16 scriptCastSpellAtObject(int16 *args) {
GameObject *caster = GameObject::objectAddress(*args++);
SkillProto *spell = skillProtoFromID(*args++);
GameObject *target = GameObject::objectAddress(*args++);
- VERIFY(caster);
- VERIFY(spell);
- VERIFY(target);
+ assert(caster);
+ assert(spell);
+ assert(target);
castSpell(caster, target, spell);
return 0;
}
@@ -3354,9 +3354,9 @@ int16 scriptCastSpellAtActor(int16 *args) {
GameObject *caster = GameObject::objectAddress(*args++);
SkillProto *spell = skillProtoFromID(*args++);
GameObject *target = GameObject::objectAddress(*args++);
- VERIFY(caster);
- VERIFY(spell);
- VERIFY(target);
+ assert(caster);
+ assert(spell);
+ assert(target);
castSpell(caster, target, spell);
return 0;
}
@@ -3365,8 +3365,8 @@ int16 scriptCastSpellAtWorld(int16 *args) {
MONOLOG(CastSpellAtWorld);
GameObject *caster = GameObject::objectAddress(*args++);
SkillProto *spell = skillProtoFromID(*args++);
- VERIFY(caster);
- VERIFY(spell);
+ assert(caster);
+ assert(spell);
castUntargetedSpell(caster, spell);
return 0;
}
@@ -3376,9 +3376,9 @@ int16 scriptCastSpellAtTAG(int16 *args) {
GameObject *caster = GameObject::objectAddress(*args++);
SkillProto *spell = skillProtoFromID(*args++);
ActiveItem *ai = ActiveItem::activeItemAddress(*args++);
- VERIFY(caster);
- VERIFY(spell);
- VERIFY(ai);
+ assert(caster);
+ assert(spell);
+ assert(ai);
castSpell(caster, ai, spell);
return 0;
}
@@ -3391,8 +3391,8 @@ int16 scriptCastSpellAtTile(int16 *args) {
int16 v = *args++; // << tileUVShift;
int16 h = *args++;
Location l = Location(TilePoint(u, v, h), Nothing);
- VERIFY(caster);
- VERIFY(spell);
+ assert(caster);
+ assert(spell);
castSpell(caster, l, spell);
return 0;
}
@@ -3529,9 +3529,9 @@ int16 scriptSearchRegion(int16 *args) {
maxP;
// Get a pointer to the world
- ASSERT(isWorld(args[ 0 ]));
+ assert(isWorld(args[ 0 ]));
worldPtr = (GameWorld *)GameObject::objectAddress(args[ 0 ]);
- ASSERT(worldPtr != NULL);
+ assert(worldPtr != NULL);
minP.u = MIN(args[ 1 ], args[ 3 ]);
minP.v = MIN(args[ 2 ], args[ 4 ]);
@@ -3625,14 +3625,14 @@ int16 scriptSwapRegions(int16 *args) {
TileRegion region1,
region2;
- ASSERT(isWorld(worldID1));
- ASSERT(isWorld(worldID2));
+ assert(isWorld(worldID1));
+ assert(isWorld(worldID2));
worldPtr1 = (GameWorld *)GameObject::objectAddress(worldID1);
worldPtr2 = (GameWorld *)GameObject::objectAddress(worldID2);
- ASSERT(worldPtr1 != NULL);
- ASSERT(worldPtr2 != NULL);
+ assert(worldPtr1 != NULL);
+ assert(worldPtr2 != NULL);
region1.min.u = args[ 1 ];
region1.min.v = args[ 2 ];
@@ -3654,9 +3654,9 @@ int16 scriptSwapRegions(int16 *args) {
// Allocate an array to hold object ID's for each region
objArray1 = new ObjectID[ objCount1 ];
- ASSERT(objArray1);
+ assert(objArray1);
objArray2 = new ObjectID[ objCount2 ];
- ASSERT(objArray2);
+ assert(objArray2);
// Get a list of the objects in each region
listObjectsInRegion(worldPtr1, region1, objArray1);
@@ -3744,8 +3744,8 @@ extern int16 objectProtoCount;
int16 scriptNumTempActors(int16 *args) {
MONOLOG(NumTempActors);
- ASSERT(args[ 0 ] >= 0);
- ASSERT(args[ 0 ] < actorProtoCount);
+ assert(args[ 0 ] >= 0);
+ assert(args[ 0 ] < actorProtoCount);
return getTempActorCount(args[ 0 ]);
}
@@ -3758,8 +3758,8 @@ int16 scriptGetObjectBasePrice(int16 *args) {
MONOLOG(GetBaseObjectPrice);
extern ProtoObj *objectProtos;
- ASSERT(args[ 0 ] >= 0);
- ASSERT(args[ 0 ] < objectProtoCount);
+ assert(args[ 0 ] >= 0);
+ assert(args[ 0 ] < objectProtoCount);
return objectProtos[ args[ 0 ] ].price;
}
@@ -3807,7 +3807,7 @@ int16 scriptPlayVideo(int16 *args) {
int16 scriptDistanceBetween(int16 *args) {
MONOLOG(distanceBetween);
- ASSERT((isObject(args[ 0 ]) || isActor(args[ 0 ]))
+ assert((isObject(args[ 0 ]) || isActor(args[ 0 ]))
&& (isObject(args[ 1 ]) || isActor(args[ 1 ])));
GameObject *obj1 = GameObject::objectAddress(args[ 0 ]),
@@ -3824,7 +3824,7 @@ int16 scriptDistanceBetween(int16 *args) {
int16 scriptTransportCenterBand(int16 *args) {
MONOLOG(transportCenterBand);
- ASSERT(isWorld(args[ 0 ]));
+ assert(isWorld(args[ 0 ]));
transportCenterBand(Location(args[ 1 ], args[ 2 ], args[ 3 ], args[ 0 ]));
diff --git a/engines/saga2/savefile.cpp b/engines/saga2/savefile.cpp
index 596ebd625c..5b0066a6d0 100644
--- a/engines/saga2/savefile.cpp
+++ b/engines/saga2/savefile.cpp
@@ -92,7 +92,7 @@ bool SaveFileConstructor::newChunk(ChunkID id, int32 size) {
// Determine if file position is at end of previous chunk
if (posInChunk < chunkSize) return FALSE;
- ASSERT(posInChunk == chunkSize);
+ assert(posInChunk == chunkSize);
SaveFileChunkInfo chunkHeader;
@@ -137,7 +137,7 @@ bool SaveFileConstructor::writeChunk(ChunkID id, void *buf, int32 size) {
// Determine if file position is at end of previous chunk
if (posInChunk < chunkSize) return FALSE;
- ASSERT(posInChunk == chunkSize);
+ assert(posInChunk == chunkSize);
SaveFileChunkInfo chunkHeader;
@@ -224,7 +224,7 @@ bool SaveFileReader::firstChunk(ChunkID &chunk, int32 &size) {
// Make the next chunk the current chunk
bool SaveFileReader::nextChunk(ChunkID &chunk, int32 &size) {
- ASSERT(posInChunk <= chunkSize);
+ assert(posInChunk <= chunkSize);
// If not already at the beginning of the next chunk header, seek
// the next chunk
diff --git a/engines/saga2/sensor.cpp b/engines/saga2/sensor.cpp
index da852eecca..c25cf0254f 100644
--- a/engines/saga2/sensor.cpp
+++ b/engines/saga2/sensor.cpp
@@ -191,12 +191,12 @@ void *constructSensor(int16 ctr, void *buf) {
break;
}
- ASSERT(sensor != NULL);
+ assert(sensor != NULL);
// Get the sensor list
sensorList = fetchSensorList(sensor->getObject());
- ASSERT(sensorList != NULL);
+ assert(sensorList != NULL);
// Append this Sensor to the sensor list
sensorList->addTail(*sensor);
@@ -209,7 +209,7 @@ void *constructSensor(int16 ctr, void *buf) {
// an archive buffer
int32 sensorArchiveSize(Sensor *sensor) {
- ASSERT(sensor != NULL);
+ assert(sensor != NULL);
return sizeof(int16) // Type
+ sensor->archiveSize();
@@ -219,7 +219,7 @@ int32 sensorArchiveSize(Sensor *sensor) {
// Archive the specified Sensor in an archive buffer
void *archiveSensor(Sensor *sensor, void *buf) {
- ASSERT(sensor != NULL);
+ assert(sensor != NULL);
// Store the sensor type
*((int16 *)buf) = sensor->getType();
@@ -243,7 +243,7 @@ void checkSensors(void) {
nextSensorHolder = (SensorHolder *)sensorHolder->next();
if (--sensorHolder->checkCtr <= 0) {
- ASSERT(sensorHolder->checkCtr == 0);
+ assert(sensorHolder->checkCtr == 0);
Sensor *sensor = sensorHolder->getSensor();
SenseInfo info;
@@ -256,8 +256,8 @@ void checkSensors(void) {
if (sensor->check(info, sFlags)) {
- ASSERT(info.sensedObject != NULL);
- ASSERT(isObject(info.sensedObject)
+ assert(info.sensedObject != NULL);
+ assert(isObject(info.sensedObject)
|| isActor(info.sensedObject));
sensor->getObject()->senseObject(
@@ -273,8 +273,8 @@ void checkSensors(void) {
//----------------------------------------------------------------------
void assertEvent(const GameEvent &ev) {
- ASSERT(ev.directObject != NULL);
- ASSERT(isObject(ev.directObject) || isActor(ev.directObject));
+ assert(ev.directObject != NULL);
+ assert(isObject(ev.directObject) || isActor(ev.directObject));
SensorHolder *sensorHolder,
*nextSensorHolder;
@@ -303,12 +303,12 @@ void assertEvent(const GameEvent &ev) {
void initSensors(void) {
// Nothing to do
- ASSERT(sizeof(ProtaganistSensor) <= maxSensorSize);
- ASSERT(sizeof(SpecificObjectSensor) <= maxSensorSize);
- ASSERT(sizeof(ObjectPropertySensor) <= maxSensorSize);
- ASSERT(sizeof(SpecificActorSensor) <= maxSensorSize);
- ASSERT(sizeof(ActorPropertySensor) <= maxSensorSize);
- ASSERT(sizeof(EventSensor) <= maxSensorSize);
+ assert(sizeof(ProtaganistSensor) <= maxSensorSize);
+ assert(sizeof(SpecificObjectSensor) <= maxSensorSize);
+ assert(sizeof(ObjectPropertySensor) <= maxSensorSize);
+ assert(sizeof(SpecificActorSensor) <= maxSensorSize);
+ assert(sizeof(ActorPropertySensor) <= maxSensorSize);
+ assert(sizeof(EventSensor) <= maxSensorSize);
}
//----------------------------------------------------------------------
@@ -374,7 +374,7 @@ void saveSensors(SaveFileConstructor &saveGame) {
bufferPtr = archiveSensor(sensorHolder->getSensor(), bufferPtr);
}
- ASSERT(bufferPtr == &((uint8 *)archiveBuffer)[ archiveBufSize ]);
+ assert(bufferPtr == &((uint8 *)archiveBuffer)[ archiveBufSize ]);
// Write the data to the save file
saveGame.writeChunk(
@@ -425,7 +425,7 @@ void loadSensors(SaveFileReader &saveGame) {
bufferPtr = constructSensor(ctr, bufferPtr);
}
- ASSERT(bufferPtr == &((uint8 *)archiveBuffer)[ saveGame.getChunkSize() ]);
+ assert(bufferPtr == &((uint8 *)archiveBuffer)[ saveGame.getChunkSize() ]);
RDisposePtr(archiveBuffer);
}
@@ -484,7 +484,7 @@ SensorList *fetchSensorList(GameObject *obj) {
SensorList::SensorList(void **buf) {
ObjectID *bufferPtr = (ObjectID *)*buf;
- ASSERT(isObject(*bufferPtr) || isActor(*bufferPtr));
+ assert(isObject(*bufferPtr) || isActor(*bufferPtr));
obj = GameObject::objectAddress(*bufferPtr);
@@ -511,7 +511,7 @@ void *SensorList::archive(void *buf) {
Sensor::Sensor(void **buf) {
void *bufferPtr = *buf;
- ASSERT(isObject(*((ObjectID *)bufferPtr))
+ assert(isObject(*((ObjectID *)bufferPtr))
|| isActor(*((ObjectID *)bufferPtr)));
// Restore the object pointer
@@ -559,13 +559,13 @@ void *Sensor::archive(void *buf) {
#if DEBUG
void *Sensor::operator new (size_t sz) {
- ASSERT(sz <= maxSensorSize);
+ assert(sz <= maxSensorSize);
return newSensor();
}
void *Sensor::operator new (size_t sz, int16 ctr) {
- ASSERT(sz <= maxSensorSize);
+ assert(sz <= maxSensorSize);
return newSensor(ctr);
}
@@ -599,7 +599,7 @@ bool ProtaganistSensor::check(SenseInfo &info, uint32 senseFlags) {
Actor *protag =
getPlayerActorAddress(playerActorIDs[ i ])->getActor();
- ASSERT(isActor(protag));
+ assert(isActor(protag));
// Skip this protaganist if they're dead
if (protag->isDead())
@@ -755,8 +755,8 @@ int16 SpecificObjectSensor::getType(void) {
// Determine if the object can sense what it's looking for
bool SpecificObjectSensor::check(SenseInfo &info, uint32 senseFlags) {
- ASSERT(soughtObjID != Nothing);
- ASSERT(isObject(soughtObjID) || isActor(soughtObjID));
+ assert(soughtObjID != Nothing);
+ assert(isObject(soughtObjID) || isActor(soughtObjID));
GameObject *soughtObject = GameObject::objectAddress(soughtObjID);
bool objIsActor = isActor(getObject());
@@ -793,9 +793,9 @@ bool SpecificObjectSensor::check(SenseInfo &info, uint32 senseFlags) {
// Determine if an object meets the search criteria
bool SpecificObjectSensor::isObjectSought(GameObject *obj) {
- ASSERT(isObject(obj) || isActor(obj));
- ASSERT(soughtObjID != Nothing);
- ASSERT(isObject(soughtObjID) || isActor(soughtObjID));
+ assert(isObject(obj) || isActor(obj));
+ assert(soughtObjID != Nothing);
+ assert(isObject(soughtObjID) || isActor(soughtObjID));
return obj == GameObject::objectAddress(soughtObjID);
}
@@ -849,7 +849,7 @@ int16 ObjectPropertySensor::getType(void) {
// Determine if an object meets the search criteria
bool ObjectPropertySensor::isObjectSought(GameObject *obj) {
- ASSERT(isObject(obj) || isActor(obj));
+ assert(isObject(obj) || isActor(obj));
return obj->hasProperty(*getObjProp(objectProperty));
}
@@ -862,7 +862,7 @@ bool ObjectPropertySensor::isObjectSought(GameObject *obj) {
// Determine if an object meets the search criteria
bool ActorSensor::isObjectSought(GameObject *obj) {
- ASSERT(isObject(obj) || isActor(obj));
+ assert(isObject(obj) || isActor(obj));
// Only actors need apply
return isActor(obj) && isActorSought((Actor *)obj);
@@ -878,7 +878,7 @@ bool ActorSensor::isObjectSought(GameObject *obj) {
SpecificActorSensor::SpecificActorSensor(void **buf) : ActorSensor(buf) {
ObjectID *bufferPtr = (ObjectID *)*buf;
- ASSERT(isActor(*bufferPtr));
+ assert(isActor(*bufferPtr));
// Restore the sought actor pointer
soughtActor = (Actor *)GameObject::objectAddress(*bufferPtr++);
@@ -918,7 +918,7 @@ int16 SpecificActorSensor::getType(void) {
// Determine if the object can sense what it's looking for
bool SpecificActorSensor::check(SenseInfo &info, uint32 senseFlags) {
- ASSERT(isActor(soughtActor));
+ assert(isActor(soughtActor));
bool objIsActor = isActor(getObject());
if (senseFlags & (1 << actorBlind))
diff --git a/engines/saga2/speech.cpp b/engines/saga2/speech.cpp
index 7c9d02dbcf..4068d390d3 100644
--- a/engines/saga2/speech.cpp
+++ b/engines/saga2/speech.cpp
@@ -1049,7 +1049,7 @@ SpeechTaskList::SpeechTaskList(void **buf) {
// Restore the speeches
for (i = 0; i < count; i++) {
Speech *sp = (Speech *)free.remHead();
- ASSERT(sp != NULL);
+ assert(sp != NULL);
nonActiveList.addTail(*sp);
bufferPtr = sp->restore(bufferPtr);
diff --git a/engines/saga2/spelcast.cpp b/engines/saga2/spelcast.cpp
index 506315c19e..5b347d9c22 100644
--- a/engines/saga2/spelcast.cpp
+++ b/engines/saga2/spelcast.cpp
@@ -147,7 +147,7 @@ void SpellStuff::killEffects(void) {
// implement a spell - general target type
void SpellStuff::implement(GameObject *enactor, SpellTarget *target) {
- VERIFY(target);
+ assert(target);
switch (target->getType()) {
case SpellTarget::spellTargetPoint:
implement(enactor, Location(target->getPoint(), Nothing));
@@ -581,8 +581,8 @@ void SpellStuff::show(GameObject *, SpellTarget &) {}
// ctor
SpellInstance::SpellInstance(SpellCaster *newCaster, SpellTarget *newTarget, SpellID spellNo) {
- VERIFY(newCaster);
- VERIFY(newTarget);
+ assert(newCaster);
+ assert(newTarget);
caster = newCaster;
target = NEW_SPEL SpellTarget(*newTarget);
world = newCaster->world();
@@ -594,7 +594,7 @@ SpellInstance::SpellInstance(SpellCaster *newCaster, SpellTarget *newTarget, Spe
// ctor
SpellInstance::SpellInstance(SpellCaster *newCaster, GameObject &newTarget, SpellID spellNo) {
- VERIFY(newCaster);
+ assert(newCaster);
target = NEW_SPEL SpellTarget(newTarget);
caster = newCaster;
world = newCaster->world();
@@ -606,8 +606,8 @@ SpellInstance::SpellInstance(SpellCaster *newCaster, GameObject &newTarget, Spel
// ctor
SpellInstance::SpellInstance(SpellCaster *newCaster, GameObject *newTarget, SpellID spellNo) {
- VERIFY(newCaster);
- VERIFY(newTarget);
+ assert(newCaster);
+ assert(newTarget);
target = NEW_SPEL SpellTarget(newTarget);
caster = newCaster;
world = newCaster->world();
@@ -619,7 +619,7 @@ SpellInstance::SpellInstance(SpellCaster *newCaster, GameObject *newTarget, Spel
// ctor
SpellInstance::SpellInstance(SpellCaster *newCaster, TilePoint &newTarget, SpellID spellNo) {
- VERIFY(newCaster);
+ assert(newCaster);
target = NEW_SPEL SpellTarget(newTarget);
caster = newCaster;
world = newCaster->world();
@@ -655,7 +655,7 @@ void SpellInstance::init(void) {
age = 0;
implementAge = 0;
effSeq = 0;
- VERIFY(dProto);
+ assert(dProto);
if (!dProto) return;
effect = EffectDisplayPrototypeList::edpList[dProto->effect];
implementAge = dProto->implementAge;
diff --git a/engines/saga2/speldata.cpp b/engines/saga2/speldata.cpp
index ac6954dce4..acc59c8234 100644
--- a/engines/saga2/speldata.cpp
+++ b/engines/saga2/speldata.cpp
@@ -130,9 +130,9 @@ void initMagic(void) {
loadMagicData();
spellSprites = (SpriteSet **) spriteRes->load(spellSpriteID, "spell sprites");
- VERIFY(spellSprites);
+ assert(spellSprites);
spellSchemes = (ColorScheme **)schemeRes->load(spellSpriteID, "scheme list");
- VERIFY(spellSchemes);
+ assert(spellSchemes);
loadedColorMaps = schemeRes->size(spellSpriteID) / sizeof(ColorScheme);
}
@@ -222,7 +222,7 @@ static void loadMagicData(void) {
RDisposePtr(rsi);
i++;
}
- VERIFY(i > 1);
+ assert(i > 1);
// get spell effects
i = 0;
@@ -243,7 +243,7 @@ static void loadMagicData(void) {
RDisposePtr(rse);
i++;
}
- VERIFY(i > 1);
+ assert(i > 1);
// get spell color maps
diff --git a/engines/saga2/speldefs.h b/engines/saga2/speldefs.h
index d65d4f49ea..9b3fec21cd 100644
--- a/engines/saga2/speldefs.h
+++ b/engines/saga2/speldefs.h
@@ -109,7 +109,7 @@ typedef GameObject SpellCaster;
inline TilePoint TAGPos(ActiveItem *ai) {
if (ai == NULL) return Nowhere;
- VERIFY(ai->itemType == activeTypeInstance);
+ assert(ai->itemType == activeTypeInstance);
return TilePoint(
ai->instance.u << tileUVShift,
ai->instance.v << tileUVShift,
@@ -230,12 +230,12 @@ public:
}
GameObject *getObject(void) {
- VERIFY(type == spellTargetObject);
+ assert(type == spellTargetObject);
return obj;
}
ActiveItem *getTAG(void) {
- VERIFY(type == spellTargetTAG);
+ assert(type == spellTargetTAG);
return tag;
}
diff --git a/engines/saga2/speldraw.cpp b/engines/saga2/speldraw.cpp
index 3eb9428bf4..71f504ad7a 100644
--- a/engines/saga2/speldraw.cpp
+++ b/engines/saga2/speldraw.cpp
@@ -83,7 +83,7 @@ EffectDisplayPrototypeList::EffectDisplayPrototypeList(int32 c) {
effects = (pEffectDisplayPrototype *) TALLOC(sizeof(pEffectDisplayPrototype) * c, memSpells);
for (int i = 0; i < c; i++)
effects[i] = NULL;
- VERIFY(effects);
+ assert(effects);
if (effects) maxCount = c;
}
@@ -101,7 +101,7 @@ EffectDisplayPrototypeList::~EffectDisplayPrototypeList() {
}
int32 EffectDisplayPrototypeList::add(EffectDisplayPrototype *edp) {
- VERIFY(count < maxCount);
+ assert(count < maxCount);
edp->setID(count);
effects[count++] = edp;
return count - 1;
@@ -118,14 +118,14 @@ void EffectDisplayPrototypeList::cleanup(void) {
}
void EffectDisplayPrototypeList::append(EffectDisplayPrototype *nedp, int32 acount) {
- VERIFY(acount < maxCount);
+ assert(acount < maxCount);
EffectDisplayPrototype *edp = effects[acount];
while (edp->next) edp = edp->next;
edp->next = nedp;
}
EffectDisplayPrototype *EffectDisplayPrototypeList::operator[](EffectID e) {
- VERIFY(e >= 0 && e < maxCount);
+ assert(e >= 0 && e < maxCount);
return effects[e];
}
@@ -155,7 +155,7 @@ SpellDisplayPrototype::SpellDisplayPrototype(
}
SpellDisplayPrototype *SpellDisplayPrototypeList::operator[](SpellID s) {
- VERIFY(s >= 0 && s < count);
+ assert(s >= 0 && s < count);
return spells[s];
}
@@ -195,7 +195,7 @@ SpellDisplayPrototypeList::SpellDisplayPrototypeList(uint16 s) {
spells = (pSpellDisplayPrototype *) TALLOC(sizeof(pSpellDisplayPrototype) * s, memSpells);
for (int i = 0; i < s; i++)
spells[i] = NULL;
- VERIFY(spells);
+ assert(spells);
if (spells) maxCount = s;
}
@@ -212,7 +212,7 @@ SpellDisplayPrototypeList::~SpellDisplayPrototypeList() {
}
int32 SpellDisplayPrototypeList::add(SpellDisplayPrototype *sdp) {
- VERIFY(count < maxCount);
+ assert(count < maxCount);
sdp->setID((SpellID) count);
spells[count++] = sdp;
return count;
@@ -253,7 +253,7 @@ void SpellDisplayList::cleanup(void) {
}
void SpellDisplayList::add(SpellInstance *newSpell) {
- VERIFY(newSpell);
+ assert(newSpell);
if (count < maxCount)
spells[count++] = newSpell;
}
@@ -273,7 +273,7 @@ void SpellDisplayList::updateStates(int32 deltaTime) {
}
void SpellDisplayList::tidyKill(uint16 spellNo) {
- VERIFY(count);
+ assert(count);
if (spells[spellNo]) {
delete spells[spellNo];
spells[spellNo] = NULL;
diff --git a/engines/saga2/spellio.cpp b/engines/saga2/spellio.cpp
index af2d6b620b..0d8138371b 100644
--- a/engines/saga2/spellio.cpp
+++ b/engines/saga2/spellio.cpp
@@ -96,7 +96,7 @@ void SpellStuff::setupFromResource(ResourceSpellItem *rsi) {
void SpellStuff::addEffect(ResourceSpellEffect *rse) {
ProtoEffect *pe;
- VERIFY(rse && rse->spell == master);
+ assert(rse && rse->spell == master);
switch (rse->effectGroup) {
case effectNone :
return;
@@ -305,7 +305,7 @@ SpellInstance::SpellInstance(StorageSpellInstance &ssi) {
caster = GameObject::objectAddress(ssi.caster);
target = NEW_SPEL SpellTarget(ssi.target);
GameObject *go = GameObject::objectAddress(ssi.world);
- VERIFY(isWorld(go));
+ assert(isWorld(go));
world = (GameWorld *) go;
age = ssi.age;
spell = ssi.spell;
@@ -353,7 +353,7 @@ void SpellDisplayList::load(SaveFileReader &saveGame) {
uint16 tCount;
saveGame.read(&tCount, sizeof(tCount));
- VERIFY(tCount < maxCount);
+ assert(tCount < maxCount);
if (tCount) {
for (int i = 0; i < tCount; i++) {
SpellInstance *si;
@@ -364,7 +364,7 @@ void SpellDisplayList::load(SaveFileReader &saveGame) {
si->loadEffect(saveGame, ssi.eListSize);
}
}
- VERIFY(tCount == count);
+ assert(tCount == count);
}
void SpellDisplayList::wipe(void) {
@@ -375,7 +375,7 @@ void SpellDisplayList::wipe(void) {
count--;
}
- ASSERT(count == 0);
+ assert(count == 0);
}
size_t SpellInstance::saveSize(void) {
@@ -397,7 +397,7 @@ void SpellInstance::saveEffect(SaveFileConstructor &saveGame) {
}
void SpellInstance::loadEffect(SaveFileReader &saveGame, uint16 eListSize) {
- VERIFY(eListSize == effect->nodeCount);
+ assert(eListSize == effect->nodeCount);
eList.count = effect->nodeCount; //sdp->effCount;
if (eList.count)
for (int32 i = 0; i < eList.count; i++) {
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index d4554ccd20..d1297f716a 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -744,21 +744,21 @@ void initSprites(void) {
error("Error accessing sprite resource group.");
frameRes = resFile->newContext(frameGroupID, "frame resources");
- VERIFY(frameRes && frameRes->_valid);
+ assert(frameRes && frameRes->_valid);
poseRes = resFile->newContext(poseGroupID, "pose resources");
- VERIFY(poseRes && poseRes->_valid);
+ assert(poseRes && poseRes->_valid);
schemeRes = resFile->newContext(schemeGroupID, "scheme resources");
- VERIFY(schemeRes && schemeRes->_valid);
+ assert(schemeRes && schemeRes->_valid);
// object sprites
objectSprites = (SpriteSet **)spriteRes->load(objectSpriteID, "object sprites");
- VERIFY(objectSprites);
+ assert(objectSprites);
// intagible object sprites
mentalSprites = (SpriteSet **)spriteRes->load(mentalSpriteID, "mental sprites");
- VERIFY(mentalSprites);
+ assert(mentalSprites);
for (i = 0; i < maxWeaponSpriteSets; i++) {
hResID weaponSpriteID;
diff --git a/engines/saga2/std.h b/engines/saga2/std.h
index 413179d67a..40fb4965d2 100644
--- a/engines/saga2/std.h
+++ b/engines/saga2/std.h
@@ -32,9 +32,6 @@
#include "saga2/rmemfta.h"
#include "saga2/saga2.h"
-#define ASSERT assert // FIXME
-#define VERIFY assert // FIXME
-
#define FTA
// #define LEAVE goto exitit // bail out of function
diff --git a/engines/saga2/target.h b/engines/saga2/target.h
index 5b335bd6ef..6ab98bdae3 100644
--- a/engines/saga2/target.h
+++ b/engines/saga2/target.h
@@ -459,10 +459,10 @@ public:
// Constructors -- initial construction
SpecificObjectTarget(ObjectID id) :
obj(id) {
- ASSERT(isObject(obj));
+ assert(isObject(obj));
}
SpecificObjectTarget(GameObject *ptr) :
- obj((ASSERT(isObject(ptr)), ptr->thisID())) {
+ obj((assert(isObject(ptr)), ptr->thisID())) {
}
// Constructor -- reconstruct from archive buffer
diff --git a/engines/saga2/task.cpp b/engines/saga2/task.cpp
index d5b000659b..3b57bce301 100644
--- a/engines/saga2/task.cpp
+++ b/engines/saga2/task.cpp
@@ -164,7 +164,7 @@ public:
// Return a pointer to a TaskStack given a TaskStackID
TaskStack *getTaskStackAddress(TaskStackID id) {
- ASSERT(id >= 0 && id < numTaskStacks);
+ assert(id >= 0 && id < numTaskStacks);
return array[ id ].getTaskStack();
}
@@ -193,7 +193,7 @@ TaskStackList::TaskStackList(void) {
// TaskStackList destructor
TaskStackList::~TaskStackList(void) {
- ASSERT(!lazyDelete);
+ assert(!lazyDelete);
TaskStackPlaceHolder *tsp;
TaskStackPlaceHolder *nextTsp;
@@ -308,7 +308,7 @@ void *TaskStackList::newTaskStack(void) {
// Place a specific TaskStack into the active list and return its address
void *TaskStackList::newTaskStack(TaskStackID id) {
- ASSERT(id >= 0 && id < elementsof(array));
+ assert(id >= 0 && id < elementsof(array));
TaskStackPlaceHolder *tsp;
@@ -371,7 +371,7 @@ void TaskStackList::updateTaskStacks(void) {
// Update the task stack and delete it if it is done
if ((result = ts->update()) != taskNotDone) {
Actor *a = ts->getActor();
- ASSERT(a != NULL);
+ assert(a != NULL);
a->handleTaskCompletion(result);
}
@@ -526,7 +526,7 @@ void loadTaskStacks(SaveFileReader &saveGame) {
new (&stackList) TaskStackList;
bufferPtr = stackList.restore(bufferPtr);
- ASSERT(bufferPtr == &((char *)archiveBuffer)[ archiveBufSize ]);
+ assert(bufferPtr == &((char *)archiveBuffer)[ archiveBufSize ]);
RDisposePtr(archiveBuffer);
}
@@ -611,7 +611,7 @@ public:
// Return a pointer to a Task given a TaskID
Task *getTaskAddress(TaskID id) {
- ASSERT(id >= 0 && id < numTasks);
+ assert(id >= 0 && id < numTasks);
return array[ id ].getTask();
}
@@ -666,7 +666,7 @@ TaskList::~TaskList(void) {
// Reconstruct from an archive buffer
void *TaskList::restore(void *buf) {
- ASSERT(list.first() == NULL);
+ assert(list.first() == NULL);
int16 i,
taskCount;
@@ -782,7 +782,7 @@ void *TaskList::newTask(char *file, int line, TaskID id)
void *TaskList::newTask(TaskID id)
#endif
{
- ASSERT(id >= 0 && id < elementsof(array));
+ assert(id >= 0 && id < elementsof(array));
TaskPlaceHolder *tp;
@@ -944,7 +944,7 @@ void saveTasks(SaveFileConstructor &saveGame) {
bufferPtr = taskList.archive(bufferPtr);
- ASSERT((uint8 *)bufferPtr - (uint8 *)archiveBuffer == archiveBufSize);
+ assert((uint8 *)bufferPtr - (uint8 *)archiveBuffer == archiveBufSize);
saveGame.writeChunk(
MakeID('T', 'A', 'S', 'K'),
@@ -982,7 +982,7 @@ void loadTasks(SaveFileReader &saveGame) {
new (&taskList) TaskList;
bufferPtr = taskList.restore(bufferPtr);
- ASSERT(bufferPtr == &((char *)archiveBuffer)[ archiveBufSize ]);
+ assert(bufferPtr == &((char *)archiveBuffer)[ archiveBufSize ]);
RDisposePtr(archiveBuffer);
}
@@ -1183,12 +1183,12 @@ void *Task::archive(void *buf) const {
#if DEBUG
void *Task::operator new (size_t sz, char *file, int line) {
- ASSERT(sz <= maxTaskSize);
+ assert(sz <= maxTaskSize);
return newTask(file, line);
}
void *Task::operator new (size_t sz, char *file, int line, TaskID id) {
- ASSERT(sz <= maxTaskSize);
+ assert(sz <= maxTaskSize);
return newTask(file, line, id);
}
#endif
@@ -2431,7 +2431,7 @@ GoAwayFromActorTask::GoAwayFromActorTask(
const ActorTarget &at,
bool runFlag) :
GoAwayFromTask(ts, runFlag) {
- ASSERT(at.size() <= sizeof(targetMem));
+ assert(at.size() <= sizeof(targetMem));
// Copy the target to the target buffer
at.clone(targetMem);
}
@@ -2703,7 +2703,7 @@ void HuntTask::removeGotoTask(void) {
HuntLocationTask::HuntLocationTask(TaskStack *ts, const Target &t) :
HuntTask(ts),
currentTarget(Nowhere) {
- ASSERT(t.size() <= sizeof(targetMem));
+ assert(t.size() <= sizeof(targetMem));
// Copy the target to the target buffer
t.clone(targetMem);
}
@@ -2892,7 +2892,7 @@ TaskResult HuntToBeNearLocationTask::atTargetUpdate(void) {
HuntObjectTask::HuntObjectTask(TaskStack *ts, const ObjectTarget &ot) :
HuntTask(ts),
currentTarget(NULL) {
- ASSERT(ot.size() <= sizeof(targetMem));
+ assert(ot.size() <= sizeof(targetMem));
// Copy the target to the target buffer
ot.clone(targetMem);
}
@@ -3270,7 +3270,7 @@ HuntActorTask::HuntActorTask(
HuntTask(ts),
flags(trackFlag ? track : 0),
currentTarget(NULL) {
- ASSERT(at.size() <= sizeof(targetMem));
+ assert(at.size() <= sizeof(targetMem));
// Copy the target to the target buffer
at.clone(targetMem);
}
@@ -3899,7 +3899,7 @@ TaskResult HuntToKillTask::atTargetEvaluate(void) {
//----------------------------------------------------------------------
TaskResult HuntToKillTask::atTargetUpdate(void) {
- ASSERT(isActor(currentTarget));
+ assert(isActor(currentTarget));
Actor *a = stack->getActor();
@@ -4093,7 +4093,7 @@ TaskResult HuntToGiveTask::atTargetUpdate(void) {
bool BandTask::BandingRepulsorIterator::first(
TilePoint &repulsorVector,
int16 &repulsorStrength) {
- ASSERT(a->leader != NULL && a->leader->followers != NULL);
+ assert(a->leader != NULL && a->leader->followers != NULL);
band = a->leader->followers;
bandIndex = 0;
@@ -4119,9 +4119,9 @@ bool BandTask::BandingRepulsorIterator::first(
bool BandTask::BandingRepulsorIterator::next(
TilePoint &repulsorVector,
int16 &repulsorStrength) {
- ASSERT(a->leader != NULL && a->leader->followers != NULL);
- ASSERT(band == a->leader->followers);
- ASSERT(bandIndex < band->size());
+ assert(a->leader != NULL && a->leader->followers != NULL);
+ assert(band == a->leader->followers);
+ assert(bandIndex < band->size());
bandIndex++;
while (bandIndex < band->size()) {
@@ -4420,7 +4420,7 @@ BandTask::RepulsorIterator *BandTask::getNewRepulsorIterator(void) {
bool BandTask::BandAndAvoidEnemiesRepulsorIterator::firstEnemyRepulsor(
TilePoint &repulsorVector,
int16 &repulsorStrength) {
- ASSERT(iteratingThruEnemies);
+ assert(iteratingThruEnemies);
int16 actorDistArray[ elementsof(actorArray) ];
TargetActorArray taa(elementsof(actorArray), actorArray, actorDistArray);
@@ -4428,7 +4428,7 @@ bool BandTask::BandAndAvoidEnemiesRepulsorIterator::firstEnemyRepulsor(
numActors = target.actor(a->world(), a->getLocation(), taa);
- ASSERT(numActors == taa.actors);
+ assert(numActors == taa.actors);
actorIndex = 0;
@@ -4449,7 +4449,7 @@ bool BandTask::BandAndAvoidEnemiesRepulsorIterator::firstEnemyRepulsor(
bool BandTask::BandAndAvoidEnemiesRepulsorIterator::nextEnemyRepulsor(
TilePoint &repulsorVector,
int16 &repulsorStrength) {
- ASSERT(iteratingThruEnemies);
+ assert(iteratingThruEnemies);
actorIndex++;
@@ -5154,7 +5154,7 @@ TaskResult ParryTask::update(void) {
return taskNotDone;
}
- ASSERT(defenderMotion != NULL);
+ assert(defenderMotion != NULL);
// If the blow is about to strike, start the actual block
if (!(flags & blockStarted)
@@ -5249,7 +5249,7 @@ void TaskStack::mark(void) {
// Set the bottom task of this task stack
void TaskStack::setTask(Task *t) {
- ASSERT(stackBottomID == NoTask);
+ assert(stackBottomID == NoTask);
if (t->stack == this) {
TaskID id = getTaskID(t);
diff --git a/engines/saga2/terrain.cpp b/engines/saga2/terrain.cpp
index 7700d90a75..35ccf5e428 100644
--- a/engines/saga2/terrain.cpp
+++ b/engines/saga2/terrain.cpp
@@ -729,8 +729,8 @@ int16 tileSlopeHeight(
GameObject *obj,
StandingTileInfo *stiResult,
uint8 *platformResult) {
- VERIFY(obj);
- VERIFY(obj->proto());
+ assert(obj);
+ assert(obj->proto());
return tileSlopeHeight(
pt,
obj->getMapNum(),
@@ -746,8 +746,8 @@ int16 tileSlopeHeight(
GameObject *obj,
StandingTileInfo *stiResult,
uint8 *platformResult) {
- VERIFY(obj);
- VERIFY(obj->proto());
+ assert(obj);
+ assert(obj->proto());
return tileSlopeHeight(
pt,
mapNum,
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 8d08a32fb4..d53cde1a81 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -241,18 +241,18 @@ BankBits LoadedBanks; // what banks are loaded?
#if DEBUG
ActiveItemID::ActiveItemID(int16 m, int16 i) :
val((m << activeItemMapShift) | (i & activeItemIndexMask)) {
- VERIFY(m < 0x8);
- VERIFY((uint16)i <= activeItemIndexNullID);
+ assert(m < 0x8);
+ assert((uint16)i <= activeItemIndexNullID);
}
void ActiveItemID::setMapNum(int16 m) {
- VERIFY(m < 0x8);
+ assert(m < 0x8);
val &= ~activeItemMapMask;
val |= (m << activeItemMapShift);
}
void ActiveItemID::setIndexNum(int16 i) {
- VERIFY((uint16)i <= activeItemIndexNullID);
+ assert((uint16)i <= activeItemIndexNullID);
val &= ~activeItemIndexMask;
val |= i & activeItemIndexMask;
}
@@ -359,7 +359,7 @@ int16 ActiveItem::getMapNum(void) {
ObjectID ActiveItem::getInstanceContext(void) {
int16 mn = getMapNum();
- ASSERT(mn >= 0 && mn < 3);
+ assert(mn >= 0 && mn < 3);
if (mn < 0 || mn > 2)
return Nothing;
WorldMapData &map = mapList[mn]; // master map data array
@@ -543,7 +543,7 @@ bool ActiveItem::use(ActiveItem *ins, ObjectID enactor) {
// trigger() function for ActiveItem group
bool ActiveItem::trigger(ActiveItem *ins, ObjectID enactor, ObjectID objID) {
- ASSERT(objID != Nothing);
+ assert(objID != Nothing);
GameObject *obj = GameObject::objectAddress(objID);
GameWorld *world = (GameWorld *)GameObject::objectAddress(
@@ -655,7 +655,7 @@ bool ActiveItem::trigger(ActiveItem *ins, ObjectID enactor, ObjectID objID) {
// release() function for ActiveItem group
bool ActiveItem::release(ActiveItem *ins, ObjectID enactor, ObjectID objID) {
- ASSERT(objID != Nothing);
+ assert(objID != Nothing);
GameObject *obj = GameObject::objectAddress(objID);
GameWorld *world = (GameWorld *)GameObject::objectAddress(
@@ -771,7 +771,7 @@ bool ActiveItem::acceptLockToggle(ActiveItem *ins, ObjectID enactor, uint8 keyCo
//-----------------------------------------------------------------------
TilePoint getClosestPointOnTAI(ActiveItem *TAI, GameObject *obj) {
- ASSERT(TAI->itemType == activeTypeInstance);
+ assert(TAI->itemType == activeTypeInstance);
TilePoint objLoc = obj->getLocation(),
TAILoc;
@@ -1738,7 +1738,7 @@ void loadAutoMap(SaveFileReader &saveGame) {
mapData = map->mapData;
for (mapIndex = 0; mapIndex < mapSize; mapIndex++) {
- ASSERT((totalMapIndex >> 3) < archiveBufSize);
+ assert((totalMapIndex >> 3) < archiveBufSize);
// If the bit is set in the archive buffer, set the visited
// bit in the map data
@@ -2213,8 +2213,8 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
uint16 plIndex = stack[ layer ];
PlatformCacheEntry *pce;
- ASSERT(layer >= 0);
- ASSERT(this >= *mapList[ mapNum ].metaList
+ assert(layer >= 0);
+ assert(this >= *mapList[ mapNum ].metaList
&& this < & (*mapList[ mapNum ].metaList)[
mapList[ mapNum ].metaCount ]);
@@ -2225,14 +2225,14 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
else if (plIndex & cacheFlag) {
plIndex &= ~cacheFlag;
- ASSERT(plIndex < platformCacheSize);
+ assert(plIndex < platformCacheSize);
// Get the address of the pce from the cache
pce = &platformCache[ plIndex ];
- ASSERT(pce->platformNum >= 0);
- ASSERT(pce->metaID != NoMetaTile);
- ASSERT(pce->metaID == thisID(mapNum));
+ assert(pce->platformNum >= 0);
+ assert(pce->metaID != NoMetaTile);
+ assert(pce->metaID == thisID(mapNum));
// Move to the end of the LRU
pce->remove();
@@ -2254,8 +2254,8 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
// Compute the layer of this entry in the cache
cacheIndex = pce - platformCache;
- ASSERT(cacheIndex < platformCacheSize);
- ASSERT(cacheIndex >= 0);
+ assert(cacheIndex < platformCacheSize);
+ assert(cacheIndex >= 0);
// Now, flush the old mt from the cache.
// This assumes that all metatiles from all worlds are loaded.
@@ -2263,8 +2263,8 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
if (pce->metaID != NoMetaTile) {
MetaTile *oldMeta = metaTileAddress(pce->metaID);
- ASSERT(pce->layerNum < maxPlatforms);
- ASSERT(oldMeta->stack[ pce->layerNum ] == (cacheFlag | cacheIndex));
+ assert(pce->layerNum < maxPlatforms);
+ assert(oldMeta->stack[ pce->layerNum ] == (cacheFlag | cacheIndex));
oldMeta->stack[ pce->layerNum ] = pce->platformNum;
}
@@ -2274,8 +2274,8 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
pce->metaID = thisID(mapNum);
stack[ layer ] = (cacheFlag | cacheIndex);
- ASSERT(plIndex >= 0);
- ASSERT(plIndex * sizeof(Platform) < tileRes->size(platformID + RES_ID(0, 0, 0, mapNum)));
+ assert(plIndex >= 0);
+ assert(plIndex * sizeof(Platform) < tileRes->size(platformID + RES_ID(0, 0, 0, mapNum)));
// Now, load the actual metatile data...
if (tileRes->seek(platformID + RES_ID(0, 0, 0, mapNum))) {
@@ -2379,8 +2379,8 @@ MetaTilePtr WorldMapData::lookupMeta(TilePoint coords) {
#endif
- ASSERT(mtile < metaCount);
- ASSERT(mtile >= 0);
+ assert(mtile < metaCount);
+ assert(mtile >= 0);
return &(*metaList)[ mtile ];
}
@@ -3929,7 +3929,7 @@ bool pointOnHiddenSurface(
const TilePoint &tileCoords,
const TilePoint &pickCoords,
SurfaceType surfaceType) {
- ASSERT(surfaceType == surfaceVertU || surfaceType == surfaceVertV);
+ assert(surfaceType == surfaceVertU || surfaceType == surfaceVertV);
WorldMapData *curMap = &mapList[ currentMapNum ];
@@ -3956,11 +3956,11 @@ bool pointOnHiddenSurface(
// Determine the tile coordinates of adjacent tile and the mask
// of the subtile to test on that tile.
if (surfaceType == surfaceVertV) {
- ASSERT(testCoords.u == 0);
+ assert(testCoords.u == 0);
adjTCoords.u--;
adjSubMask = 0x1000 << (testCoords.v >> subTileShift);
} else {
- ASSERT(testCoords.v == 0);
+ assert(testCoords.v == 0);
adjTCoords.v--;
adjSubMask = 0x0008 << (testCoords.u & ~subTileMask);
}
@@ -4356,7 +4356,7 @@ void loadTileCyclingStates(SaveFileReader &saveGame) {
initTileCyclingStates();
- ASSERT(saveGame.getChunkSize() == sizeof(TileCycleArchive) * cycleCount);
+ assert(saveGame.getChunkSize() == sizeof(TileCycleArchive) * cycleCount);
archiveBuffer = (TileCycleArchive *)RNewPtr(
sizeof(TileCycleArchive) * cycleCount,
@@ -4527,13 +4527,13 @@ void updateMainDisplay(void) {
int32 deltaTime = gameTime - lastUpdateTime;
- ASSERT(isActor(viewCenterObject));
+ assert(isActor(viewCenterObject));
Actor *viewActor = (Actor *)GameObject::objectAddress(
viewCenterObject);
TilePoint viewDiff;
- ASSERT(isWorld(viewActor->IDParent()));
+ assert(isWorld(viewActor->IDParent()));
GameWorld *viewWorld = (GameWorld *)viewActor->parent();
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index 0c6572762d..72f22c49a0 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -456,7 +456,7 @@ public:
// Return a pointer to this TAI's group
ActiveItem *getGroup(void) {
- ASSERT(itemType == activeTypeInstance);
+ assert(itemType == activeTypeInstance);
return activeItemAddress(
ActiveItemID(getMapNum(), instance.groupID));
}
diff --git a/engines/saga2/tilemode.cpp b/engines/saga2/tilemode.cpp
index 5ad23eba4f..106632a140 100644
--- a/engines/saga2/tilemode.cpp
+++ b/engines/saga2/tilemode.cpp
@@ -449,7 +449,7 @@ static void evalMouseState(void) {
// and if so, wether the other object is within the
// use range of the center actor
if (mouseInfo.getIntent() == GrabInfo::Use) {
- ASSERT(obj != NULL);
+ assert(obj != NULL);
if (mObj->containmentSet() & (ProtoObj::isSkill | ProtoObj::isSpell)) {
GameObject *tob = pickedObject != Nothing ? obj : NULL;
@@ -610,7 +610,7 @@ static void evalMouseState(void) {
// Initialize the tile mode state
void initTileModeState(void) {
- ASSERT(uiKeysEnabled);
+ assert(uiKeysEnabled);
aggressiveActFlag = FALSE;
inCombat = FALSE;
@@ -623,7 +623,7 @@ void initTileModeState(void) {
void saveTileModeState(SaveFileConstructor &saveGame) {
int32 size = 0;
- ASSERT(uiKeysEnabled);
+ assert(uiKeysEnabled);
// Compute the number of bytes needed
size += sizeof(aggressiveActFlag)
@@ -648,7 +648,7 @@ void saveTileModeState(SaveFileConstructor &saveGame) {
// Load the tile mode state from a save file
void loadTileModeState(SaveFileReader &saveGame) {
- ASSERT(uiKeysEnabled);
+ assert(uiKeysEnabled);
// Simply read in the data
saveGame.read(&aggressiveActFlag, sizeof(aggressiveActFlag));
diff --git a/engines/saga2/tilevect.h b/engines/saga2/tilevect.h
index 3af9bef678..754621fb11 100644
--- a/engines/saga2/tilevect.h
+++ b/engines/saga2/tilevect.h
@@ -54,7 +54,7 @@ inline TilePoint rightVector(TilePoint tp, bool which = 0) {
inline void setMagnitude(TilePoint &tp, int32 newMag) {
#if DEBUG
- VERIFY(tp.magnitude());
+ assert(tp.magnitude());
#else
if (tp.magnitude() == 0)
tp = TilePoint(1, 1, 0);
diff --git a/engines/saga2/timers.cpp b/engines/saga2/timers.cpp
index 676bb35aa2..2d6329eecf 100644
--- a/engines/saga2/timers.cpp
+++ b/engines/saga2/timers.cpp
@@ -238,7 +238,7 @@ void saveTimers(SaveFileConstructor &saveGame) {
timerHolder = (TimerHolder *)timerHolder->next())
bufferPtr = timerHolder->getTimer()->archive(bufferPtr);
- ASSERT(bufferPtr == &((uint8 *)archiveBuffer)[ archiveBufSize ]);
+ assert(bufferPtr == &((uint8 *)archiveBuffer)[ archiveBufSize ]);
// Write the data to the save file
saveGame.writeChunk(
@@ -286,18 +286,18 @@ void loadTimers(SaveFileReader &saveGame) {
timer = new Timer(&bufferPtr);
- ASSERT(timer != NULL);
+ assert(timer != NULL);
// Get the objects's timer list
timerList = fetchTimerList(timer->getObject());
- ASSERT(timerList != NULL);
+ assert(timerList != NULL);
// Append this timer to the objects's timer list
timerList->addTail(*timer);
}
- ASSERT(bufferPtr == &((uint8 *)archiveBuffer)[ saveGame.getChunkSize() ]);
+ assert(bufferPtr == &((uint8 *)archiveBuffer)[ saveGame.getChunkSize() ]);
RDisposePtr(archiveBuffer);
}
@@ -340,7 +340,7 @@ void cleanupTimers(void) {
TimerList::TimerList(void **buf) {
ObjectID *bufferPtr = (ObjectID *)*buf;
- ASSERT(isObject(*bufferPtr) || isActor(*bufferPtr));
+ assert(isObject(*bufferPtr) || isActor(*bufferPtr));
// Restore the object pointer
obj = GameObject::objectAddress(*bufferPtr++);
@@ -369,7 +369,7 @@ void *TimerList::archive(void *buf) {
Timer::Timer(void **buf) {
void *bufferPtr = *buf;
- ASSERT(isObject(*((ObjectID *)bufferPtr))
+ assert(isObject(*((ObjectID *)bufferPtr))
|| isActor(*((ObjectID *)bufferPtr)));
// Restore the object pointer
diff --git a/engines/saga2/tower.cpp b/engines/saga2/tower.cpp
index 71d4d19346..569e895cda 100644
--- a/engines/saga2/tower.cpp
+++ b/engines/saga2/tower.cpp
@@ -160,14 +160,6 @@ INITIALIZER(initErrorManagers) {
return true;
}
-// defining VERIFY_EXIT will give you a message box when the program has
-// been sucessfully cleaned up
-
-
-#ifdef VERIFY_EXIT
-#include "saga2/program.h"
-#endif
-
TERMINATOR(termErrorManagers) {
}
diff --git a/engines/saga2/verify.cpp b/engines/saga2/verify.cpp
deleted file mode 100644
index a3bdff821f..0000000000
--- a/engines/saga2/verify.cpp
+++ /dev/null
@@ -1,134 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * aint32 with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
-#include "saga2/std.h"
-
-namespace Saga2 {
-
-/****** errclass.cpp/VERIFY *******************************
-*
-* NAME
-* VERIFY -- GTools-compatible assertion macro
-*
-* SYNOPSIS
-* VERIFY( condition );
-* verify( condition );
-*
-* FUNCTION
-* Throws a gError exception if condition not met. It prints
-* a message indicating the condition that was not met and
-* the source file name and line number of the macro.
-*
-* SEE ALSO
-* gError::gError
-* gError::warn
-* class gError
-*
-*******************************************************************/
-
-void __verify(char *expr, char *file, long line, char *msg) {
- if (msg) {
- error("Error in %s, line %d: %s\n",
- file,
- line,
- msg);
- } else {
- error("VERIFY failed in %s, line %d: (%s)\n",
- file,
- line,
- expr);
- }
-}
-
-//
-// This value is set if the program is in the debugger & the extensions
-// have initialized properly
-//
-
-volatile signed short int DebugExtensionsEnabled = 0;
-
-//
-// When DebugBreakNow is set to 1 a breakpoint is triggered
-//
-
-volatile signed short int DebugBreakNow = 0;
-
-//
-// Override these calls in an OBJ file to disable /enable stuff
-//
-
-void PauseTimers(void) { }
-void ResumeTimers(void) { }
-
-//
-// Force a breakpoint
-//
-
-void debug_breakpoint(const int, const char []) {
- PauseTimers();
- DebugBreakNow = 1;
-}
-
-//
-// When DebugDumpNow is set, anything in DebugDumpText will get
-// dumped to the debugger LOG screen
-//
-
-volatile signed short int DebugDumpNow = 0;
-char DebugDumpText[80] = "Run Time Messages Enabled\0";
-
-//
-// Set up & trigger a run-time error message
-//
-
-void debug_dumptext(const char text[]) {
- int l;
- l = strlen(text);
- if (l > 78)
- l = 78;
- strncpy(DebugDumpText, text, l);
- DebugDumpText[l] = '\0';
- PauseTimers();
- DebugDumpNow = 1;
- ResumeTimers();
-}
-
-
-extern "C" {
-
- void cebug_breakpoint(const int linenumber, const char filename[]) {
- debug_breakpoint(linenumber, filename);
- }
-
- void cebug_dumptext(const char text[]) {
- debug_dumptext(text);
- }
-
-};
-
-} // end of namespace Saga2
diff --git a/engines/saga2/video.cpp b/engines/saga2/video.cpp
index 0ed23f6c1c..f4f60a8f50 100644
--- a/engines/saga2/video.cpp
+++ b/engines/saga2/video.cpp
@@ -211,7 +211,7 @@ bool VideoPlayer::StartPlay(char *filespec,
res = FALSE;
break;
default:
- ASSERT(0);
+ assert(0);
res = FALSE;
}
mouseHook(TRUE);
@@ -251,7 +251,7 @@ bool VideoPlayer::CheckPlay(void) {
case VideoNone:
break;
default:
- ASSERT(0);
+ assert(0);
}
autoEnd = FALSE;
mouseHook(TRUE);
@@ -282,7 +282,7 @@ void VideoPlayer::EndPlay(void) {
break;
#endif
default:
- ASSERT(0);
+ assert(0);
}
mouseHook(TRUE);
setType(VideoNone);
diff --git a/engines/saga2/videobox.cpp b/engines/saga2/videobox.cpp
index d4836a64d9..f9f0de930a 100644
--- a/engines/saga2/videobox.cpp
+++ b/engines/saga2/videobox.cpp
@@ -127,7 +127,7 @@ void CVideoBox::draw(void) { // redraw the window
void CVideoBox::init(void) {
- ASSERT(resFile);
+ assert(resFile);
// set the result info to nominal startup values
rInfo.result = -1;
diff --git a/engines/saga2/vidsmk.cpp b/engines/saga2/vidsmk.cpp
index 10a08662bb..52518c1501 100644
--- a/engines/saga2/vidsmk.cpp
+++ b/engines/saga2/vidsmk.cpp
@@ -187,7 +187,7 @@ bool VideoPlayer::StartSMK(char *filespec,
bool VideoPlayer::CheckSMK(void) {
#if 0
- VERIFY(smk);
+ assert(smk);
if (abort)
i = smk->Frames + 1;
if (i > smk->Frames) {
diff --git a/engines/saga2/vpal.cpp b/engines/saga2/vpal.cpp
index d628205f6a..fb1e3dfd8b 100644
--- a/engines/saga2/vpal.cpp
+++ b/engines/saga2/vpal.cpp
@@ -244,7 +244,7 @@ void createPalette(
gPalettePtr dstP,
int32 elapsedTime,
int32 totalTime) {
- ASSERT(totalTime != 0);
+ assert(totalTime != 0);
int i;
uint32 fadeProgress = (elapsedTime << 8) / totalTime;
diff --git a/engines/saga2/weapons.cpp b/engines/saga2/weapons.cpp
index fc934d513b..9336b12a01 100644
--- a/engines/saga2/weapons.cpp
+++ b/engines/saga2/weapons.cpp
@@ -170,7 +170,7 @@ WeaponStuff &getWeapon(weaponID i) {
//-----------------------------------------------------------------------
GameObject *getShieldItem(GameObject *defender) {
- VERIFY(isActor(defender));
+ assert(isActor(defender));
Actor *a = (Actor *) defender;
GameObject *obj;
@@ -206,9 +206,9 @@ void WeaponStrikeEffect::implement(
GameObject *target,
GameObject *strikingObj,
uint8 strength) {
- ASSERT(isActor(enactor));
- ASSERT(isObject(target) || isActor(target));
- ASSERT(isObject(strikingObj) || isActor(strikingObj));
+ assert(isActor(enactor));
+ assert(isObject(target) || isActor(target));
+ assert(isObject(strikingObj) || isActor(strikingObj));
int8 totalDice,
totalBase;
@@ -270,8 +270,8 @@ void WeaponStuff::addEffect(WeaponEffect *we) {
void WeaponStuff::addEffect(ResourceItemEffect *rie) {
WeaponEffect *we;
- VERIFY(rie);
- VERIFY(rie && rie->item == master);
+ assert(rie);
+ assert(rie && rie->item == master);
if (rie->effectGroup == effectStrike) {
we = NEW_EFCT WeaponStrikeEffect(
@@ -344,7 +344,7 @@ static void loadWeaponData(void) {
i++;
}
loadedWeapons = i;
- VERIFY(i > 1);
+ assert(i > 1);
auxResFile->disposeContext(spellRes);
}
Commit: 44455e469e6fec8fab03931be0590b9001cbce46
https://github.com/scummvm/scummvm/commit/44455e469e6fec8fab03931be0590b9001cbce46
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:49+02:00
Commit Message:
SAGA2: Fix resource loading and add initScripts() prototype
Changed paths:
engines/saga2/hresmgr.cpp
engines/saga2/hresmgr.h
engines/saga2/saga2.cpp
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index 1c0e7b1c83..d80cef6df9 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -75,6 +75,7 @@ hResContext::hResContext() {
hResContext::hResContext(hResContext *sire, hResID id, const char desc[]) {
hResEntry *entry;
+ const uint32 resourceSize = 12;
_valid = false;
_res = sire->_res;
@@ -91,12 +92,11 @@ hResContext::hResContext(hResContext *sire, hResID id, const char desc[]) {
if ((entry = _parent->findEntry(id)) == nullptr)
return;
- _numEntries = entry->resSize() / sizeof * entry;
+ _numEntries = entry->size / resourceSize;
- _base = (hResEntry *)((uint8 *)_res->_groups +
- (entry->offset - _res->_firstGroupOffset));
+ _base = &_res->_table[entry->offset - _res->_firstGroupOffset];
- _data = (RHANDLE *)malloc(_numEntries * sizeof(RHANDLE));
+ _data = new RHANDLE[_numEntries]();
if (_data == nullptr)
return;
@@ -105,13 +105,7 @@ hResContext::hResContext(hResContext *sire, hResID id, const char desc[]) {
hResContext::~hResContext() {
if (_data) {
- if (_valid) {
- for (int i = 0; i < _numEntries; i++) {
- free(_data[ i ]);
- _data[i] = nullptr;
- }
- }
- free(_data);
+ delete[] _data;
_data = nullptr;
}
}
@@ -126,7 +120,7 @@ hResEntry *hResContext::findEntry(hResID id, RHANDLE **capture) {
debugC(2, kDebugResources, "findEntry: looking for %x (%s)", id, tag2str(id));
for (i = 0, entry = _base; i < _numEntries; i++, entry++) {
- debugC(kDebugResources, "%x: Trying ID: %x (%s)", i, entry->id, tag2str(entry->id));
+ debugC(2, kDebugResources, "%d: Trying ID: %x (%s)", i, entry->id, tag2str(entry->id));
if (entry->id == id) {
if (capture) *capture = &_data[ i ];
debugC(2, kDebugResources, "findEntry: found %x (%s)", entry->id, tag2str(entry->id));
@@ -147,7 +141,7 @@ uint32 hResContext::size(hResID id) {
if ((entry = findEntry(id)) == nullptr)
return 0;
- return entry->resSize();
+ return entry->size;
}
uint32 hResContext::count(void) {
@@ -199,7 +193,7 @@ bool hResContext::seek(hResID id) {
if ((entry = findEntry(id)) == nullptr) return false;
- _bytecount = entry->resSize();
+ _bytecount = entry->size;
_bytepos = entry->resOffset();
_res->_handle->seek(_bytepos, SEEK_SET);
@@ -225,11 +219,12 @@ void hResContext::rest(void) {
}
}
-bool hResContext::read(void *buffer, int32 size) {
+bool hResContext::read(void *buffer, uint32 size) {
+ assert(_handle);
if (!_valid) return false;
_bytecount = 0;
_bytepos = 0;
- return _handle->read(buffer, size);
+ return (_handle->read(buffer, size) != 0);
}
bool hResContext::eor(void) {
@@ -240,24 +235,23 @@ uint32 hResContext::readbytes(void *buffer, uint32 size) {
int32 bytesRead;
if (!_valid || _bytecount < 1) return 0;
- if (HR_SEEK(_res->_handle, _bytepos, SEEK_SET) != 0)
- error("Error seeking resource file:");
- bytesRead = HR_READ(buffer, 1, MIN(size, _bytecount), _handle);
+ _res->_handle->seek(_bytepos, SEEK_SET);
+ bytesRead = _handle->read(buffer, MIN(size, _bytecount));
_bytecount -= bytesRead;
_bytepos += bytesRead;
return bytesRead;
}
-bool hResContext::skip(int32 amount) {
+bool hResContext::skip(uint32 amount) {
if (!_valid) return false;
- HR_SEEK(_res->_handle, amount, SEEK_CUR);
+ _res->_handle->seek(amount, SEEK_CUR);
_bytecount -= amount;
_bytepos -= amount;
return true;
}
-bool hResContext::get(hResID id, void *buffer, int32 size) {
+bool hResContext::get(hResID id, void *buffer, uint32 size) {
bool result = false;
if (!_valid) return false;
@@ -269,7 +263,7 @@ bool hResContext::get(hResID id, void *buffer, int32 size) {
if ((entry = findEntry(id)) == nullptr) return false;
- size = entry->resSize();
+ size = entry->size;
}
if (seek(id)) {
@@ -297,7 +291,7 @@ RHANDLE hResContext::load(hResID id, const char desc[], bool async, bool cacheab
entry->use();
} else {
if (*capture == nullptr)
- *capture = (RHANDLE)malloc(entry->resSize());
+ *capture = (RHANDLE)malloc(entry->size);
if (*capture == nullptr) return nullptr;
@@ -307,7 +301,7 @@ RHANDLE hResContext::load(hResID id, const char desc[], bool async, bool cacheab
async = false;
#endif
if (entry->isExternal() || async == false) {
- if (seek(id) && read(**capture, entry->resSize())) {
+ if (seek(id) && read(**capture, entry->size)) {
entry->use();
} else {
free(*capture);
@@ -317,10 +311,9 @@ RHANDLE hResContext::load(hResID id, const char desc[], bool async, bool cacheab
rest();
} else {
#ifndef WINKLUDGE
- RequestResource(
- *capture,
- entry->resOffset(),
- entry->resSize());
+ RequestResource(*capture,
+ entry->offset,
+ entry->size);
#endif
entry->use();
}
@@ -345,13 +338,13 @@ RHANDLE hResContext::loadIndex(int16 index, const char desc[], bool cacheable) {
entry->use();
} else {
if (*capture == nullptr)
- *capture = (RHANDLE)malloc(entry->resSize());
+ *capture = (RHANDLE)malloc(entry->size);
if (*capture == nullptr) return nullptr;
_res->_handle->seek(entry->resOffset(), SEEK_SET);
- if (read(**capture, entry->resSize()) == false) {
+ if (read(**capture, entry->size) == false) {
free(*capture);
*capture = nullptr;
}
@@ -403,7 +396,8 @@ void hResource::readResource(hResEntry &element) {
hResource::hResource(char *resname, char *extname, const char desc[]) {
hResEntry origin;
- uint32 size;
+ int32 tableSize;
+ const int32 resourceSize = 4 + 4 + 4; // id, offset, size
_valid = false;
_base = nullptr;
@@ -425,30 +419,33 @@ hResource::hResource(char *resname, char *extname, const char desc[]) {
// allocate buffers for root, groups and data
- _base = (hResEntry *)malloc(origin.resSize());
- size = origin.offset - _firstGroupOffset - sizeof(uint32);
- _groups = (hResEntry *)malloc(size);
+ _numEntries = origin.size;
- if (_base == nullptr || _groups == nullptr) return;
+ _base = new hResEntry[_numEntries]();
+ tableSize = origin.offset - _firstGroupOffset - sizeof(uint32);
+ _table = new hResEntry[tableSize / resourceSize]();
- readResource(*_base);
- _numEntries = origin.resSize() / sizeof origin;
+
+ if (_base == nullptr || _table == nullptr) return;
debugC(kDebugResources, "Reading %d categories:", _numEntries);
+ for (int i = 0; i < _numEntries; ++i)
+ readResource(_base[i]);
+
+ debugC(kDebugResources, "Reading %d groups:", tableSize / resourceSize);
_file.seek(_firstGroupOffset, SEEK_SET);
- for (int i = 0; i < _numEntries; ++i) {
- readResource(_groups[i]);
+ for (int i = 0; i < tableSize / resourceSize; ++i) {
+ readResource(_table[i]);
}
_res = this;
- _numEntries = origin.resSize() / sizeof origin;
_valid = true;
}
hResource::~hResource() {
- if (_base) free(_base);
- if (_groups) free(_groups);
- if (_handle) free(_handle);
+ if (_base) delete[] _base;
+ if (_table) delete[] _table;
+ //if (_handle) free(_handle);
}
hResContext *hResource::newContext(hResID id, const char desc[]) {
diff --git a/engines/saga2/hresmgr.h b/engines/saga2/hresmgr.h
index 46880a4489..586c889c70 100644
--- a/engines/saga2/hresmgr.h
+++ b/engines/saga2/hresmgr.h
@@ -156,11 +156,11 @@ public:
inline size_t bytesleft(void) {
return _bytecount;
}
- bool read(void *buffer, int32 size);
- bool skip(int32 amount);
- bool get(hResID id, void *buffer, int32 size);
- RHANDLE load(hResID id, const char [], bool async = FALSE, bool cacheable = TRUE);
- RHANDLE loadIndex(int16 index, const char[], bool cacheable = TRUE);
+ bool read(void *buffer, uint32 size);
+ bool skip(uint32 amount);
+ bool get(hResID id, void *buffer, uint32 size);
+ RHANDLE load(hResID id, const char [], bool async = false, bool cacheable = true);
+ RHANDLE loadIndex(int16 index, const char[], bool cacheable = true);
void release(RHANDLE p);
Common::File *resFileHandle(void) {
return _handle;
@@ -181,7 +181,7 @@ class hResource : public hResContext {
uint32 _firstGroupOffset;
char _externalPath[EXTERNAL_PATH_SIZE];
- hResEntry *_groups;
+ hResEntry *_table;
public:
hResource(char *resname, char *extname, const char []);
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index f34eed8809..b99002e2da 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -41,6 +41,7 @@
namespace Saga2 {
+void initScripts();
void openImageTest();
bool openResources();
void main_saga2();
@@ -84,8 +85,10 @@ Common::Error Saga2Engine::run() {
loadingScreen();
- if (openResources())
+ if (openResources()) {
openImageTest();
+ //initScripts(); // crashes currently
+ }
// Simple main event loop
Common::Event evt;
Commit: df220014769b8e1db843b1daf3de54be4373a81d
https://github.com/scummvm/scummvm/commit/df220014769b8e1db843b1daf3de54be4373a81d
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:49+02:00
Commit Message:
SAGA2: Fix if statements to agree with conventions
Changed paths:
engines/saga2/hresmgr.cpp
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index d80cef6df9..2415594723 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -425,8 +425,9 @@ hResource::hResource(char *resname, char *extname, const char desc[]) {
tableSize = origin.offset - _firstGroupOffset - sizeof(uint32);
_table = new hResEntry[tableSize / resourceSize]();
+ if (_base == nullptr || _table == nullptr)
+ return;
- if (_base == nullptr || _table == nullptr) return;
debugC(kDebugResources, "Reading %d categories:", _numEntries);
for (int i = 0; i < _numEntries; ++i)
@@ -443,8 +444,10 @@ hResource::hResource(char *resname, char *extname, const char desc[]) {
}
hResource::~hResource() {
- if (_base) delete[] _base;
- if (_table) delete[] _table;
+ if (_base)
+ delete[] _base;
+ if (_table)
+ delete[] _table;
//if (_handle) free(_handle);
}
Commit: bb044850a3b7d8bee93d0e5f37a85da0ebd92f60
https://github.com/scummvm/scummvm/commit/bb044850a3b7d8bee93d0e5f37a85da0ebd92f60
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:50+02:00
Commit Message:
SAGA2: Add functions to get resource pointer and size by id
Changed paths:
engines/saga2/hresmgr.cpp
engines/saga2/hresmgr.h
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index 2415594723..771e6c26b1 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -274,6 +274,25 @@ bool hResContext::get(hResID id, void *buffer, uint32 size) {
return result;
}
+uint32 hResContext::getSize(hResID id) {
+ hResEntry *entry;
+ if ((entry = findEntry(id)) == nullptr)
+ return 0;
+
+ return entry->size;
+}
+
+byte *hResContext::loadResource(hResID id, const char desc[]) {
+ hResEntry *entry;
+ if ((entry = findEntry(id)) == nullptr)
+ return nullptr;
+
+ byte *res = (byte*)malloc(entry->size);
+ _file.seek(entry->offset, SEEK_SET);
+ _file.read(res, entry->size);
+
+ return res;
+}
RHANDLE hResContext::load(hResID id, const char desc[], bool async, bool cacheable) {
hResEntry *entry;
diff --git a/engines/saga2/hresmgr.h b/engines/saga2/hresmgr.h
index 586c889c70..7e8f38af8f 100644
--- a/engines/saga2/hresmgr.h
+++ b/engines/saga2/hresmgr.h
@@ -133,6 +133,7 @@ protected:
uint32 _bytepos;
hResEntry *findEntry(hResID id, RHANDLE **capture = NULL);
+ hResEntry *findResEntry(hResID id);
Common::File *openExternal(Common::File *fh);
public:
@@ -159,7 +160,9 @@ public:
bool read(void *buffer, uint32 size);
bool skip(uint32 amount);
bool get(hResID id, void *buffer, uint32 size);
+ uint32 getSize(hResID id);
RHANDLE load(hResID id, const char [], bool async = false, bool cacheable = true);
+ byte *loadResource(hResID id, const char desc[]);
RHANDLE loadIndex(int16 index, const char[], bool cacheable = true);
void release(RHANDLE p);
Common::File *resFileHandle(void) {
Commit: 389de83222fda0d041bd15da88d4043bca56a64a
https://github.com/scummvm/scummvm/commit/389de83222fda0d041bd15da88d4043bca56a64a
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:50+02:00
Commit Message:
SAGA2: Add warnings when ID is not found
Changed paths:
engines/saga2/hresmgr.cpp
engines/saga2/hresmgr.h
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index 771e6c26b1..25690f3136 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -274,18 +274,22 @@ bool hResContext::get(hResID id, void *buffer, uint32 size) {
return result;
}
-uint32 hResContext::getSize(hResID id) {
+uint32 hResContext::getSize(hResID id, const char desc[]) {
hResEntry *entry;
- if ((entry = findEntry(id)) == nullptr)
+ if ((entry = findEntry(id)) == nullptr) {
+ warning("Resource %d, %s not found", id, desc);
return 0;
+ }
return entry->size;
}
byte *hResContext::loadResource(hResID id, const char desc[]) {
hResEntry *entry;
- if ((entry = findEntry(id)) == nullptr)
+ if ((entry = findEntry(id)) == nullptr) {
+ warning("Resource %d, %s not found", id, desc);
return nullptr;
+ }
byte *res = (byte*)malloc(entry->size);
_file.seek(entry->offset, SEEK_SET);
diff --git a/engines/saga2/hresmgr.h b/engines/saga2/hresmgr.h
index 7e8f38af8f..cd721e1613 100644
--- a/engines/saga2/hresmgr.h
+++ b/engines/saga2/hresmgr.h
@@ -122,18 +122,17 @@ public:
class hResContext {
protected:
- uint16 _numEntries;
- hResource *_res;
- hResContext *_parent;
- hResEntry *_base;
- RHANDLE *_data; // allocated array of handles
- Common::File _file;
- Common::File *_handle;
- uint32 _bytecount;
- uint32 _bytepos;
+ uint16 _numEntries;
+ hResource *_res;
+ hResContext *_parent;
+ hResEntry *_base;
+ RHANDLE *_data; // allocated array of handles
+ Common::File _file;
+ Common::File *_handle;
+ uint32 _bytecount;
+ uint32 _bytepos;
hResEntry *findEntry(hResID id, RHANDLE **capture = NULL);
- hResEntry *findResEntry(hResID id);
Common::File *openExternal(Common::File *fh);
public:
@@ -160,7 +159,7 @@ public:
bool read(void *buffer, uint32 size);
bool skip(uint32 amount);
bool get(hResID id, void *buffer, uint32 size);
- uint32 getSize(hResID id);
+ uint32 getSize(hResID id, const char desc[]);
RHANDLE load(hResID id, const char [], bool async = false, bool cacheable = true);
byte *loadResource(hResID id, const char desc[]);
RHANDLE loadIndex(int16 index, const char[], bool cacheable = true);
Commit: 6d218247bbe0796215bbac1cfb08d5ee90618791
https://github.com/scummvm/scummvm/commit/6d218247bbe0796215bbac1cfb08d5ee90618791
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:50+02:00
Commit Message:
SAGA2: Fix initScripts()
Changed paths:
engines/saga2/hresmgr.cpp
engines/saga2/hresmgr.h
engines/saga2/interp.cpp
engines/saga2/saga2.cpp
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index 25690f3136..6157d4000c 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -284,14 +284,19 @@ uint32 hResContext::getSize(hResID id, const char desc[]) {
return entry->size;
}
-byte *hResContext::loadResource(hResID id, const char desc[]) {
+byte *hResContext::loadResource(hResID id, Common::String filename, const char desc[]) {
hResEntry *entry;
+
if ((entry = findEntry(id)) == nullptr) {
warning("Resource %d, %s not found", id, desc);
return nullptr;
}
byte *res = (byte*)malloc(entry->size);
+
+ if (!_file.isOpen())
+ _file.open(filename);
+
_file.seek(entry->offset, SEEK_SET);
_file.read(res, entry->size);
@@ -427,11 +432,13 @@ hResource::hResource(char *resname, char *extname, const char desc[]) {
_parent = nullptr;
_data = nullptr;
_numEntries = 0;
+ _filename = resname;
strncpy(_externalPath, extname ? extname : "", EXTERNAL_PATH_SIZE);
debugC(1, kDebugResources, "Opening resource: %s", resname);
- _file.open(resname);
+ if (!_file.open(resname))
+ warning("Unable to open file %s", resname);
readResource(origin);
if (origin.id != HRES_ID)
diff --git a/engines/saga2/hresmgr.h b/engines/saga2/hresmgr.h
index cd721e1613..8ead0a5d9c 100644
--- a/engines/saga2/hresmgr.h
+++ b/engines/saga2/hresmgr.h
@@ -122,21 +122,22 @@ public:
class hResContext {
protected:
- uint16 _numEntries;
- hResource *_res;
- hResContext *_parent;
- hResEntry *_base;
- RHANDLE *_data; // allocated array of handles
- Common::File _file;
- Common::File *_handle;
- uint32 _bytecount;
- uint32 _bytepos;
-
- hResEntry *findEntry(hResID id, RHANDLE **capture = NULL);
- Common::File *openExternal(Common::File *fh);
+ uint16 _numEntries;
+ hResource *_res;
+ hResContext *_parent;
+ hResEntry *_base;
+ RHANDLE *_data; // allocated array of handles
+ Common::File _file;
+ Common::File *_handle;
+ uint32 _bytecount;
+ uint32 _bytepos;
+
+ hResEntry *findEntry(hResID id, RHANDLE **capture = NULL);
+ Common::File *openExternal(Common::File *fh);
public:
- bool _valid;
+ bool _valid;
+ Common::String _filename;
hResContext();
hResContext(hResContext *sire, hResID id, const char []);
@@ -161,7 +162,7 @@ public:
bool get(hResID id, void *buffer, uint32 size);
uint32 getSize(hResID id, const char desc[]);
RHANDLE load(hResID id, const char [], bool async = false, bool cacheable = true);
- byte *loadResource(hResID id, const char desc[]);
+ byte *loadResource(hResID id, Common::String filename, const char desc[]);
RHANDLE loadIndex(int16 index, const char[], bool cacheable = true);
void release(RHANDLE p);
Common::File *resFileHandle(void) {
@@ -181,9 +182,9 @@ class hResource : public hResContext {
friend class hResContext;
- uint32 _firstGroupOffset;
- char _externalPath[EXTERNAL_PATH_SIZE];
- hResEntry *_table;
+ uint32 _firstGroupOffset;
+ char _externalPath[EXTERNAL_PATH_SIZE];
+ hResEntry *_table;
public:
hResource(char *resname, char *extname, const char []);
@@ -191,7 +192,7 @@ public:
hResContext *newContext(hResID id, const char []);
void disposeContext(hResContext *con);
- void readResource(hResEntry &element);
+ void readResource(hResEntry &element);
};
/* ===================================================================== *
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 2d42467f3b..cc202a95fe 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -1744,27 +1744,28 @@ void initScripts(void) {
error("Unable to open script resource file!\n");
// Load the data segment
- dataSegment = (UByteHandle)scriptRes->load(
- dataSegID,
- "saga data segment");
+ dataSegment = (UByteHandle)scriptRes->loadResource(dataSegID, scriptResFile->_filename, "saga data segment");
if (dataSegment == NULL)
error("Unable to load the SAGA data segment");
- dataSegSize = RPtrSize(*dataSegment);
+ dataSegSize = scriptRes->getSize(dataSegID, "saga data segment");
- exportSegment = (UByteHandle)scriptRes->load(exportSegID, "saga export segmant");
+ exportSegment = (UByteHandle)scriptRes->loadResource(exportSegID, scriptResFile->_filename, "saga export segment");
assert(exportSegment != NULL);
- exportCount = (scriptRes->size(exportSegID) / sizeof(uint32)) + 1;
+ exportCount = (scriptRes->getSize(exportSegID, "saga export segment") / sizeof(uint32)) + 1;
}
void cleanupScripts(void) {
- if (exportSegment) scriptRes->release((RHANDLE)exportSegment);
+ if (exportSegment)
+ free(exportSegment);
- if (dataSegment) scriptRes->release((RHANDLE)dataSegment);
+ if (dataSegment)
+ free(dataSegment);
- if (scriptRes) scriptResFile->disposeContext(scriptRes);
+ if (scriptRes)
+ scriptResFile->disposeContext(scriptRes);
scriptRes = NULL;
}
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index b99002e2da..db2f0b1c69 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -87,7 +87,7 @@ Common::Error Saga2Engine::run() {
if (openResources()) {
openImageTest();
- //initScripts(); // crashes currently
+ initScripts();
}
// Simple main event loop
Commit: e5e85e2ff80da1e194efc59c2da3319fa132abd3
https://github.com/scummvm/scummvm/commit/e5e85e2ff80da1e194efc59c2da3319fa132abd3
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:50+02:00
Commit Message:
SAGA2: Get rid of some pointer arithmetic
Changed paths:
engines/saga2/interp.cpp
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index cc202a95fe..5cb50a1363 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -76,8 +76,8 @@ int16 moduleBaseResource,
moduleCount;
uint16 dataSegIndex; // saved index of data seg
-UByteHandle dataSegment, // loaded in data
- exportSegment; // export table from SAGA
+byte *dataSegment, // loaded in data
+ *exportSegment; // export table from SAGA
int32 dataSegSize; // bytes in data segment
@@ -248,7 +248,7 @@ uint8 *byteAddress(Thread *th, uint8 **pcPtr) {
case addr_data:
IMMED_WORD(offset);
*pcPtr = pc;
- return *dataSegment + offset;
+ return &dataSegment[offset];
case addr_near:
IMMED_WORD(offset);
@@ -283,7 +283,8 @@ uint8 *byteAddress(Thread *th, uint8 **pcPtr) {
IMMED_WORD(offset);
arg = (uint16 *)(th->stackBase + th->framePtr + 8);
*pcPtr = pc;
- if (arg[ 0 ] == dataSegIndex) return *dataSegment + arg[ 1 ] + offset;
+ if (arg[ 0 ] == dataSegIndex)
+ return &dataSegment[arg[ 1 ] + offset];
return segmentArrayAddress(arg[ 0 ],
arg[ 1 ]) + offset;
@@ -331,7 +332,7 @@ uint8 *objectAddress(
case addr_data:
IMMED_WORD(index);
seg = dataSegIndex;
- addr = *dataSegment + index;
+ addr = &dataSegment[index];
break;
case addr_far:
@@ -352,7 +353,8 @@ uint8 *objectAddress(
arg = (uint16 *)(th->stackBase + th->framePtr + 8);
seg = arg[ 0 ];
index = arg[ 1 ];
- if (seg == dataSegIndex) return *dataSegment + index + offset;
+ if (seg == dataSegIndex)
+ return &dataSegment[index + offset];
addr = segmentArrayAddress(seg, index) + offset;
break;
@@ -398,7 +400,7 @@ uint8 *bitAddress(Thread *th, uint8 **pcPtr, int16 *mask) {
IMMED_WORD(offset);
*pcPtr = pc;
*mask = (1 << (offset & 7));
- return *dataSegment + (offset >> 3);
+ return &dataSegment[(offset >> 3)];
case addr_near:
IMMED_WORD(offset);
@@ -1744,16 +1746,20 @@ void initScripts(void) {
error("Unable to open script resource file!\n");
// Load the data segment
- dataSegment = (UByteHandle)scriptRes->loadResource(dataSegID, scriptResFile->_filename, "saga data segment");
+ dataSegment = scriptRes->loadResource(dataSegID, scriptResFile->_filename, "saga data segment");
if (dataSegment == NULL)
error("Unable to load the SAGA data segment");
dataSegSize = scriptRes->getSize(dataSegID, "saga data segment");
- exportSegment = (UByteHandle)scriptRes->loadResource(exportSegID, scriptResFile->_filename, "saga export segment");
+// Common::hexdump(dataSegment, dataSegSize);
+
+ exportSegment = scriptRes->loadResource(exportSegID, scriptResFile->_filename, "saga export segment");
assert(exportSegment != NULL);
+// Common::hexdump(exportSegment, scriptRes->getSize(exportSegID, "saga export segment"));
+
exportCount = (scriptRes->getSize(exportSegID, "saga export segment") / sizeof(uint32)) + 1;
}
@@ -1775,7 +1781,7 @@ void cleanupScripts(void) {
void initSAGADataSeg(void) {
// Load the data segment
scriptRes->seek(dataSegID);
- scriptRes->read(*dataSegment, dataSegSize);
+ scriptRes->read(dataSegment, dataSegSize);
}
//-----------------------------------------------------------------------
@@ -1784,7 +1790,7 @@ void initSAGADataSeg(void) {
void saveSAGADataSeg(SaveFileConstructor &saveGame) {
saveGame.writeChunk(
MakeID('S', 'D', 'T', 'A'),
- *dataSegment,
+ dataSegment,
dataSegSize);
}
@@ -1792,7 +1798,7 @@ void saveSAGADataSeg(SaveFileConstructor &saveGame) {
// Load the SAGA data segment from a save file
void loadSAGADataSeg(SaveFileReader &saveGame) {
- saveGame.read(*dataSegment, dataSegSize);
+ saveGame.read(dataSegment, dataSegSize);
}
//-----------------------------------------------------------------------
Commit: 676fd24e9cd9aa3b4c6e88df2038276923b7db5b
https://github.com/scummvm/scummvm/commit/676fd24e9cd9aa3b4c6e88df2038276923b7db5b
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:50+02:00
Commit Message:
SAGA2: Initialize Thread in Saga2::run()
Changed paths:
engines/saga2/hresmgr.cpp
engines/saga2/hresmgr.h
engines/saga2/interp.cpp
engines/saga2/main.cpp
engines/saga2/saga2.cpp
engines/saga2/script.h
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index 6157d4000c..a7474ec4b6 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -350,6 +350,24 @@ RHANDLE hResContext::load(hResID id, const char desc[], bool async, bool cacheab
return (*capture);
}
+byte *hResContext::loadIndexResource(int16 index, const char desc[], Common::String filename) {
+ hResEntry *entry;
+ entry = &_base[index];
+
+ if (!_valid || entry == nullptr)
+ return nullptr;
+
+ byte *res = (byte*)malloc(entry->size);
+
+ if (!_file.isOpen())
+ _file.open(filename);
+
+ _file.seek(entry->offset, SEEK_SET);
+ _file.read(res, entry->size);
+
+ return res;
+}
+
RHANDLE hResContext::loadIndex(int16 index, const char desc[], bool cacheable) {
hResEntry *entry;
RHANDLE *capture; //, _handle;
diff --git a/engines/saga2/hresmgr.h b/engines/saga2/hresmgr.h
index 8ead0a5d9c..44c00ed6a0 100644
--- a/engines/saga2/hresmgr.h
+++ b/engines/saga2/hresmgr.h
@@ -162,7 +162,8 @@ public:
bool get(hResID id, void *buffer, uint32 size);
uint32 getSize(hResID id, const char desc[]);
RHANDLE load(hResID id, const char [], bool async = false, bool cacheable = true);
- byte *loadResource(hResID id, Common::String filename, const char desc[]);
+ byte *loadResource(hResID id, Common::String filename, const char desc[]);
+ byte *loadIndexResource(int16 index, const char desc[], Common::String filename);
RHANDLE loadIndex(int16 index, const char[], bool cacheable = true);
void release(RHANDLE p);
Common::File *resFileHandle(void) {
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 5cb50a1363..2a2f829d11 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -43,7 +43,7 @@ namespace Saga2 {
* ============================================================================ */
#define IMMED_WORD(w) ((w = *pc++),(w |= (*pc++)<<8))
-#define BRANCH(w) pc = *codeSeg + (w)
+#define BRANCH(w) pc = codeSeg + (w)
const uint32 sagaID = MKTAG('S', 'A', 'G', 'A'),
dataSegID = MKTAG('_', '_', 'D', 'A'),
@@ -253,7 +253,7 @@ uint8 *byteAddress(Thread *th, uint8 **pcPtr) {
case addr_near:
IMMED_WORD(offset);
*pcPtr = pc;
- return *th->codeSeg + offset;
+ return th->codeSeg + offset;
case addr_far:
IMMED_WORD(seg);
@@ -406,7 +406,7 @@ uint8 *bitAddress(Thread *th, uint8 **pcPtr, int16 *mask) {
IMMED_WORD(offset);
*pcPtr = pc;
*mask = (1 << (offset & 7));
- return *th->codeSeg + (offset >> 3);
+ return th->codeSeg + (offset >> 3);
case addr_far:
IMMED_WORD(seg);
@@ -454,7 +454,7 @@ uint8 *bitAddress(Thread *th, uint8 **pcPtr, int16 *mask) {
// Returns the address of a string
uint8 *Thread::strAddress(int strNum) {
- uint16 *codeBase = (uint16 *)*codeSeg;
+ uint16 *codeBase = (uint16 *)codeSeg;
uint8 *strSeg = segmentAddress(codeBase[ 1 ], codeBase[ 2 ]);
assert(strNum >= 0);
@@ -557,7 +557,7 @@ bool Thread::interpret(void) {
n;
C_Call *cfunc;
- pc = (*codeSeg) + programCounter.offset;
+ pc = (codeSeg) + programCounter.offset;
thisThread = this; // set current thread address
@@ -567,7 +567,7 @@ bool Thread::interpret(void) {
switch (op = *pc++) {
// case op_nextblock:
-// n = (pc-1-(*codeSeg)) / 1024; // calculate address of this block
+// n = (pc-1-(codeSeg)) / 1024; // calculate address of this block
// BRANCH((n + 1) * 1024); // jump to next block
// break;
@@ -678,7 +678,7 @@ bool Thread::interpret(void) {
if (stack >= (int16 *)(stackBase + stackSize - initialStackFrameSize)) {
// Halt the thread here, wait for death
- programCounter.offset = (pc - (*codeSeg));
+ programCounter.offset = (pc - (codeSeg));
stackPtr = (uint8 *)stack;
flags |= finished;
return TRUE;
@@ -687,9 +687,10 @@ bool Thread::interpret(void) {
programCounter.offset = *stack++;
RUnlockHandle((RHANDLE)codeSeg);
- codeSeg = (UByteHandle)
- scriptRes->loadIndex(programCounter.segment, "saga code segment");
- pc = (*codeSeg) + programCounter.offset;
+ codeSeg = scriptRes->loadIndexResource(programCounter.segment,
+ "saga code segment",
+ scriptRes->_filename);
+ pc = (codeSeg) + programCounter.offset;
n = *stack++; // get argument count from call
stack += n; // pop that many args
@@ -703,7 +704,7 @@ bool Thread::interpret(void) {
n = *pc++; // get argument count
- programCounter.offset = (pc + 2 - *codeSeg);
+ programCounter.offset = (pc + 2 - codeSeg);
*--stack = n; // push number of args (16 bits)
// push the program counter
@@ -713,7 +714,7 @@ bool Thread::interpret(void) {
IMMED_WORD(w); // pick up segment offset
programCounter.offset = w; // store into pc
- pc = *codeSeg + w; // calculate PC address
+ pc = codeSeg + w; // calculate PC address
print_script_name(pc);
break;
@@ -722,7 +723,7 @@ bool Thread::interpret(void) {
n = *pc++; // get argument count
- programCounter.offset = (pc + 4 - *codeSeg);
+ programCounter.offset = (pc + 4 - codeSeg);
*--stack = n; // push number of args (16 bits)
// push the program counter
@@ -732,11 +733,11 @@ bool Thread::interpret(void) {
IMMED_WORD(w); // pick up segment number
programCounter.segment = w; // set current segment
RUnlockHandle((RHANDLE)codeSeg);
- codeSeg = (UByteHandle)scriptRes->loadIndex(w, "saga code segment");
+ codeSeg = scriptRes->loadIndexResource(w, "saga code segment", scriptRes->_filename);
IMMED_WORD(w); // pick up segment offset
programCounter.offset = w; // store into pc
- pc = *codeSeg + w; // calculate PC address
+ pc = codeSeg + w; // calculate PC address
print_script_name(pc);
break;
@@ -800,7 +801,7 @@ bool Thread::interpret(void) {
if (vtable == NULL) {
// Do nothing...
} else if (vtableEntry[ 0 ] != 0xffff) { // It's a SAGA func
- programCounter.offset = (pc - *codeSeg);
+ programCounter.offset = (pc - codeSeg);
// Push the address of the object
*--stack = offset;
@@ -818,13 +819,13 @@ bool Thread::interpret(void) {
w = vtableEntry[ 0 ];
programCounter.segment = w;
RUnlockHandle((RHANDLE)codeSeg);
- codeSeg = (UByteHandle)scriptRes->loadIndex(w, "saga code segment");
+ codeSeg = scriptRes->loadIndexResource(w, "saga code segment", scriptRes->_filename);
// store pc-offset into pc
programCounter.offset = vtableEntry[ 1 ];
// calculate PC address
- pc = (*codeSeg) + programCounter.offset;
+ pc = (codeSeg) + programCounter.offset;
print_script_name(pc, objectName(seg, offset));
break;
} else if (vtableEntry[ 1 ] != 0xffff) { // It's a C func
@@ -1101,7 +1102,7 @@ bool Thread::interpret(void) {
}
}
- programCounter.offset = (pc - (*codeSeg));
+ programCounter.offset = (pc - (codeSeg));
stackPtr = (uint8 *)stack;
return FALSE;
@@ -1389,7 +1390,7 @@ void saveSAGAThreads(SaveFileConstructor &saveGame) {
archiveBufSize = threadList.archiveSize();
- archiveBuffer = RNewPtr(archiveBufSize, NULL, "archive buffer");
+ archiveBuffer = malloc(archiveBufSize);
if (archiveBuffer == NULL)
error("Unable to allocate SAGA thread archive buffer");
@@ -1400,7 +1401,7 @@ void saveSAGAThreads(SaveFileConstructor &saveGame) {
archiveBuffer,
archiveBufSize);
- RDisposePtr(archiveBuffer);
+ free(archiveBuffer);
}
//-------------------------------------------------------------------
@@ -1416,8 +1417,8 @@ void loadSAGAThreads(SaveFileReader &saveGame) {
void *archiveBuffer;
void *bufferPtr;
- archiveBuffer = RNewPtr(saveGame.getChunkSize(), NULL, "archive buffer");
- if (archiveBuffer == NULL)
+ archiveBuffer = malloc(saveGame.getChunkSize());
+ if (archiveBuffer == nullptr)
error("Unable to allocate SAGA thread archive buffer");
// Read the archived thread data
@@ -1432,7 +1433,7 @@ void loadSAGAThreads(SaveFileReader &saveGame) {
assert((char *)bufferPtr == (char *)archiveBuffer
+ saveGame.getChunkSize());
- RDisposePtr(archiveBuffer);
+ free(archiveBuffer);
}
//-------------------------------------------------------------------
@@ -1486,7 +1487,7 @@ Thread *getThreadAddress(ThreadID id) {
// Thread constructor
Thread::Thread(uint16 segNum, uint16 segOff, scriptCallFrame &args) {
- codeSeg = (UByteHandle)scriptRes->loadIndex(segNum, "saga code segment");
+ codeSeg = scriptRes->loadIndexResource(segNum, "saga code segment", scriptRes->_filename);
// initialize the thread
stackSize = kStackSize;
@@ -1495,16 +1496,16 @@ Thread::Thread(uint16 segNum, uint16 segOff, scriptCallFrame &args) {
programCounter.segment = segNum;
programCounter.offset = segOff;
threadArgs = args;
- stackBase = (UBytePtr)RNewPtr(stackSize, NULL, "saga stack");
+ stackBase = (UBytePtr)malloc(stackSize);
stackPtr = stackBase + stackSize - initialStackFrameSize;
((uint16 *)stackPtr)[ 0 ] = 0; // 0 args
((uint16 *)stackPtr)[ 1 ] = 0; // dummy return address
((uint16 *)stackPtr)[ 2 ] = 0; // dummy return address
framePtr = stackSize;
- if ((*codeSeg)[ programCounter.offset ] != op_enter)
+ if ((codeSeg)[ programCounter.offset ] != op_enter)
error("SAGA failure: Invalid script entry point (export=%d) [segment=%d:%d]\n", lastExport, segNum, segOff);
-// assert ((*codeSeg)[ programCounter.offset ] == op_enter);
+// assert ((codeSeg)[ programCounter.offset ] == op_enter);
}
//-----------------------------------------------------------------------
@@ -1530,10 +1531,11 @@ Thread::Thread(void **buf) {
stackOffset = *((int16 *)bufferPtr);
bufferPtr = (int16 *)bufferPtr + 1;
- codeSeg = (UByteHandle)scriptRes->loadIndex(
- programCounter.segment, "saga code segment");
+ codeSeg = scriptRes->loadIndexResource(programCounter.segment,
+ "saga code segment",
+ scriptRes->_filename);
- stackBase = (UBytePtr)RNewPtr(stackSize, NULL, "saga stack");
+ stackBase = (UBytePtr)malloc(stackSize);
stackPtr = stackBase + stackSize - stackOffset;
memcpy(stackPtr, bufferPtr, stackOffset);
@@ -1553,7 +1555,7 @@ Thread::~Thread() {
RUnlockHandle((RHANDLE)codeSeg);
// Deallocate the thread stack
- RDisposePtr(stackBase);
+ free(stackBase);
}
//-----------------------------------------------------------------------
@@ -1845,7 +1847,7 @@ scriptResult runScript(uint16 exportEntryNum, scriptCallFrame &args) {
// Create a new thread
th = new Thread(segNum, segOff, args);
thisThread = th;
- print_script_name((*th->codeSeg) + th->programCounter.offset, objectName(segNum, segOff));
+ print_script_name((th->codeSeg) + th->programCounter.offset, objectName(segNum, segOff));
// Run the thread to completion
result = th->run();
@@ -1916,7 +1918,7 @@ scriptResult runMethod(
// Create a new thread
th = new Thread(segNum, segOff, args);
thisThread = th;
- print_script_name((*th->codeSeg) + th->programCounter.offset, objectName(bType, index));
+ print_script_name((th->codeSeg) + th->programCounter.offset, objectName(bType, index));
// Put the object segment and ID onto the dummy stack frame
((uint16 *)th->stackPtr)[ 3 ] = bType;
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index ba1181e292..893c88e6cb 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -52,6 +52,7 @@
#include "saga2/loadsave.h"
#include "saga2/gamerate.h"
#include "saga2/msgbox.h"
+#include "saga2/script.h"
namespace Saga2 {
@@ -751,6 +752,12 @@ void openImageTest() {
drawCompressedImage(mainPort, pos, dec->image);
}
+void testScripts() {
+ scriptCallFrame scf;
+ Thread th(0,0,scf);
+ th.interpret();
+}
+
//-----------------------------------------------------------------------
// Routine to cleanup all the resource files
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index db2f0b1c69..338152c908 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -41,6 +41,7 @@
namespace Saga2 {
+void testScripts();
void initScripts();
void openImageTest();
bool openResources();
@@ -88,6 +89,7 @@ Common::Error Saga2Engine::run() {
if (openResources()) {
openImageTest();
initScripts();
+ testScripts();
}
// Simple main event loop
diff --git a/engines/saga2/script.h b/engines/saga2/script.h
index fbd7d0bfb6..a193c2d816 100644
--- a/engines/saga2/script.h
+++ b/engines/saga2/script.h
@@ -199,7 +199,7 @@ public:
SegmentRef programCounter; // current PC location
uint8 *stackPtr; // current stack location
- UByteHandle codeSeg; // base of current data segment
+ byte *codeSeg; // base of current data segment
// *stringBase; // base of string resource
uint8 *stackBase; // base of module stack
@@ -297,10 +297,10 @@ public:
void setExtended(void);
void clearExtended(void);
+ bool interpret(void);
private:
uint8 *strAddress(int strNum);
- bool interpret(void);
};
const int maxTimeSlice = 16, // max instructions per call
Commit: 0eefd3b65715aed5b4d530cbc9b983afd5ab526d
https://github.com/scummvm/scummvm/commit/0eefd3b65715aed5b4d530cbc9b983afd5ab526d
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:50+02:00
Commit Message:
SAGA2: Make test script runnable
Changed paths:
engines/saga2/dlist.cpp
engines/saga2/interp.cpp
engines/saga2/main.cpp
engines/saga2/script.h
diff --git a/engines/saga2/dlist.cpp b/engines/saga2/dlist.cpp
index f4afb5dfe6..b1aa8ab370 100644
--- a/engines/saga2/dlist.cpp
+++ b/engines/saga2/dlist.cpp
@@ -55,6 +55,8 @@ void DList::addTail(DNode &d) {
DNode *DList::remHead(void) {
DNode *n = head;
+ if (n == nullptr)
+ return nullptr;
if (n->succ) {
head = n->succ;
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 2a2f829d11..d5c8a73e8f 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -214,7 +214,7 @@ uint8 *segmentAddress(uint16 segment, uint16 offset) {
segHandle = scriptRes->dataHandle(segment);
if (segHandle == NULL || *segHandle == NULL) {
segHandle = scriptRes->loadIndex(segment, "object segment");
- RUnlockHandle(segHandle);
+ //RUnlockHandle(segHandle);
}
return ((uint8 *)(*segHandle) + offset);
}
@@ -227,7 +227,7 @@ uint8 *segmentArrayAddress(uint16 segment, uint16 index) {
segHandle = scriptRes->dataHandle(segment);
if (segHandle == NULL || *segHandle == NULL) {
segHandle = scriptRes->loadIndex(segment, "object array segment");
- RUnlockHandle(segHandle);
+ //RUnlockHandle(segHandle);
}
return (uint8 *)(*segHandle) + sizeof(uint16)
@@ -686,7 +686,7 @@ bool Thread::interpret(void) {
programCounter.segment = *stack++;
programCounter.offset = *stack++;
- RUnlockHandle((RHANDLE)codeSeg);
+ //RUnlockHandle((RHANDLE)codeSeg);
codeSeg = scriptRes->loadIndexResource(programCounter.segment,
"saga code segment",
scriptRes->_filename);
@@ -732,7 +732,7 @@ bool Thread::interpret(void) {
IMMED_WORD(w); // pick up segment number
programCounter.segment = w; // set current segment
- RUnlockHandle((RHANDLE)codeSeg);
+ //RUnlockHandle((RHANDLE)codeSeg);
codeSeg = scriptRes->loadIndexResource(w, "saga code segment", scriptRes->_filename);
IMMED_WORD(w); // pick up segment offset
programCounter.offset = w; // store into pc
@@ -818,7 +818,7 @@ bool Thread::interpret(void) {
// into thread).
w = vtableEntry[ 0 ];
programCounter.segment = w;
- RUnlockHandle((RHANDLE)codeSeg);
+ //RUnlockHandle((RHANDLE)codeSeg);
codeSeg = scriptRes->loadIndexResource(w, "saga code segment", scriptRes->_filename);
// store pc-offset into pc
@@ -1204,7 +1204,7 @@ void *ThreadList::restore(void *buf) {
id = *((ThreadID *)buf);
buf = (ThreadID *)buf + 1;
- new (id) Thread(&buf);
+ new Thread(&buf);
}
return buf;
@@ -1378,7 +1378,7 @@ static ThreadList &threadList = *((ThreadList *)threadListBuffer);
void initSAGAThreads(void) {
// Simply call the Thread List default constructor
- new (&threadList) ThreadList;
+ new ThreadList;
}
//-------------------------------------------------------------------
@@ -1410,7 +1410,7 @@ void saveSAGAThreads(SaveFileConstructor &saveGame) {
void loadSAGAThreads(SaveFileReader &saveGame) {
// If there is no saved data, simply call the default constructor
if (saveGame.getChunkSize() == 0) {
- new (&threadList) ThreadList;
+ new ThreadList;
return;
}
@@ -1427,7 +1427,7 @@ void loadSAGAThreads(SaveFileReader &saveGame) {
bufferPtr = archiveBuffer;
// Reconstruct stackList from archived data
- new (&threadList) ThreadList;
+ new ThreadList;
bufferPtr = threadList.restore(bufferPtr);
assert((char *)bufferPtr == (char *)archiveBuffer
@@ -1552,7 +1552,7 @@ Thread::~Thread() {
clearExtended();
// Free the thread's code segment
- RUnlockHandle((RHANDLE)codeSeg);
+ //RUnlockHandle((RHANDLE)codeSeg);
// Deallocate the thread stack
free(stackBase);
@@ -1811,7 +1811,7 @@ static bool lookupExport(
uint16 &segNum,
uint16 &segOff) {
uint32 segRef,
- *exportBase = (uint32 *)(*exportSegment - 2);
+ *exportBase = (uint32 *)(exportSegment - 2);
assert(entry > 0);
assert(entry <= exportCount);
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 893c88e6cb..54ac7424e6 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -754,8 +754,7 @@ void openImageTest() {
void testScripts() {
scriptCallFrame scf;
- Thread th(0,0,scf);
- th.interpret();
+ runScript(1, scf);
}
//-----------------------------------------------------------------------
diff --git a/engines/saga2/script.h b/engines/saga2/script.h
index a193c2d816..94ac242635 100644
--- a/engines/saga2/script.h
+++ b/engines/saga2/script.h
@@ -267,19 +267,6 @@ public:
// Create an archive of this thread in an archive buffer
void *archive(void *buf);
- // Overloaded new operator functions
- void *operator new (size_t) {
- return newThread();
- }
- void *operator new (size_t, ThreadID id) {
- return newThread(id);
- }
-
- // Overloaded delete operator function
- void operator delete (void *p) {
- deleteThread(p);
- }
-
// Dispatch all asynchronous threads
static void dispatch(void);
Commit: af8adadc73610cbc7e92be95ad9a8e9dfe294d01
https://github.com/scummvm/scummvm/commit/af8adadc73610cbc7e92be95ad9a8e9dfe294d01
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:50+02:00
Commit Message:
SAGA2: Fix endianness in reading in lookupExport
Changed paths:
engines/saga2/interp.cpp
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index d5c8a73e8f..8d98ef1227 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -1810,13 +1810,12 @@ static bool lookupExport(
uint16 entry,
uint16 &segNum,
uint16 &segOff) {
- uint32 segRef,
- *exportBase = (uint32 *)(exportSegment - 2);
+ uint32 segRef;
assert(entry > 0);
assert(entry <= exportCount);
- segRef = exportBase[ entry ];
+ segRef = READ_LE_INT32(exportSegment + 4 * entry - 2);
segOff = segRef >> 16,
segNum = segRef & 0x0000ffff;
Commit: 3ee9ab99304f73ecf5ffcfb4969f4d1260066ebf
https://github.com/scummvm/scummvm/commit/3ee9ab99304f73ecf5ffcfb4969f4d1260066ebf
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:50+02:00
Commit Message:
SAGA2: Replace rand()
Changed paths:
engines/saga2/interp.cpp
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 8d98ef1227..1eb61b5cc6 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -28,6 +28,8 @@
#include "common/debug.h"
+#include "saga2/saga2.h"
+
#include "saga2/std.h"
#include "saga2/fta.h"
#include "saga2/script.h"
@@ -500,8 +502,8 @@ int16 RRandom(int16 c, int16 s, int16 id) {
// with a non-deterministic portion generated by the standard
// library rand() function and a deterministic potion based upon
// the "id" argument
- RandomGenerator random((rand() % s) + (id * s));
- return random() % c;
+ RandomGenerator rnd(g_vm->_rnd->getRandomNumber(s - 1) + (id * s));
+ return rnd() % c;
}
/* ============================================================================ *
@@ -934,7 +936,7 @@ bool Thread::interpret(void) {
if (op == op_jmp_random) {
IMMED_WORD(n); // n = number of cases
IMMED_WORD(n); // total probability
- n = (uint16)rand() % n; // random number between 0 and n-1
+ n = (uint16)(g_vm->_rnd->getRandomNumber(n - 1)); // random number between 0 and n-1
} else {
int16 seed,
r;
Commit: cd6261fca397de1cb57f5b37bf17230c10abfc48
https://github.com/scummvm/scummvm/commit/cd6261fca397de1cb57f5b37bf17230c10abfc48
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:51+02:00
Commit Message:
SAGA2: Remove iff.*
Changed paths:
R engines/saga2/iff.cpp
R engines/saga2/iff.h
engines/saga2/enchant.cpp
engines/saga2/gamemode.cpp
engines/saga2/module.mk
engines/saga2/objects.cpp
engines/saga2/savefile.h
engines/saga2/std.h
engines/saga2/vpal.cpp
diff --git a/engines/saga2/enchant.cpp b/engines/saga2/enchant.cpp
index a97be7a2d9..3dda57b7ae 100644
--- a/engines/saga2/enchant.cpp
+++ b/engines/saga2/enchant.cpp
@@ -32,7 +32,6 @@
#include "saga2/cmisc.h"
#include "saga2/contain.h"
#include "saga2/script.h"
-#include "saga2/iff.h"
#include "saga2/player.h"
#include "saga2/target.h"
#include "saga2/enchant.h"
diff --git a/engines/saga2/gamemode.cpp b/engines/saga2/gamemode.cpp
index dcbbca9ec3..5fa08e6ed2 100644
--- a/engines/saga2/gamemode.cpp
+++ b/engines/saga2/gamemode.cpp
@@ -36,7 +36,6 @@
#include "saga2/images.h"
#include "saga2/setup.h"
#include "saga2/palette.h"
-#include "saga2/iff.h"
#include "saga2/transit.h"
#include "saga2/mouseimg.h"
#include "saga2/player.h"
diff --git a/engines/saga2/iff.cpp b/engines/saga2/iff.cpp
deleted file mode 100644
index f438de126e..0000000000
--- a/engines/saga2/iff.cpp
+++ /dev/null
@@ -1,357 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * aint32 with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
-#include "saga2/std.h"
-#include "saga2/errors.h"
-#include "saga2/iff.h"
-
-namespace Saga2 {
-
-/* ======================================================================= *
- General IFF routines (not completely general, but will do for now...)
- * ======================================================================= */
-
-iffHandle::iffHandle(void) {
- fileHandle = NULL;
- flags = iffStreamIO;
-
- form.id = 0;
- form.size = 0;
- form.pos = 0;
- form.patch = 0;
-
- chunk.id = 0;
- chunk.size = 0;
- chunk.pos = 0;
- chunk.patch = 0;
-
- lastErr = errOK;
-}
-
-void iffHandle::swapLong(int32 &l) {
-#if defined(MSDOS) || defined(__MSDOS__)
- l = ((l >> 24) & 0x000000ffL) |
- ((l >> 8) & 0x0000ff00L) |
- ((l << 8) & 0x00ff0000L) |
- ((l << 24) & 0xff000000L);
-#endif
-}
-
-bool iffReadHandle::readChunk(void) {
- int32 hdr[ 2 ];
-
- if (fread(&hdr, 4, 2, fileHandle) != 2) {
- lastErr = dosErrCode();
- return FALSE;
- }
-
- swapLong(hdr[ 1 ]);
-
- chunk.id = hdr[ 0 ];
- chunk.size = hdr[ 1 ];
- chunk.pos = 0;
- chunk.patch = 0;
-
- form.pos += 8;
-
- if (form.size > 0 &&
- (chunk.size < 0 || chunk.size > form.size - form.pos)) {
- lastErr = errMangledForm;
- return FALSE;
- }
-
- return TRUE;
-}
-
-bool iffReadHandle::skipChunk(void) {
- if (lastErr != errOK) return FALSE;
-
- // skip over old chunk
-
- if (chunk.size & 1) chunk.size++; // pad to even size
- if (chunk.pos < chunk.size) {
- if (fseek(fileHandle, chunk.size - chunk.pos, SEEK_CUR) != 0) {
- lastErr = dosErrCode();
- return FALSE;
- }
- form.pos += chunk.size - chunk.pos;
- }
-
- return TRUE;
-}
-
-iffReadHandle::iffReadHandle(char *filename, ChunkID &formName) {
- name = filename;
-
- fileHandle = fopen(filename, "rb");
- if (fileHandle == NULL) {
- lastErr = dosErrCode();
- } else if (readChunk()) {
- form = chunk;
- chunk.pos = chunk.size = 0;
-
- if (form.id != ID_FORM) {
- lastErr = errNotIFF;
- } else if (fread(&form.id, 4, 1, fileHandle) != 1) {
- lastErr = dosErrCode();
- } else {
- formName = form.id;
- form.pos += 4;
- }
- }
-}
-
-iffReadHandle::~iffReadHandle() {
- if (fileHandle) fclose(fileHandle);
-}
-
-bool iffReadHandle::nextChunk(ChunkID &id) {
- if (skipChunk() == FALSE) return FALSE;
-
- if (form.pos >= form.size) {
- id = 0; // ID of zero means EOF
- return TRUE;
- }
-
- // Read chunk header
-
- if (readChunk() == FALSE) return FALSE;
- id = chunk.id; // return ID of read chunk
- return TRUE;
-}
-
-#if 0
-bool iffReadHandle::seekChunk(ChunkID id) {
- ChunkID cid;
-
- // keep reading chunks until we find one we want
-
- do {
- nextChunk(cid);
- if (lastErr) break;
-
- } while (cid != id && cid != 0);
-
- return (cid != id);
-}
-#endif
-
-int32 iffReadHandle::read(void *buffer, int32 length) {
- if (lastErr != errOK) return -1;
-
- if (length <= 0) return 0;
- else if (length > chunk.size - chunk.pos)
- length = chunk.size - chunk.pos;
-
- // REM: If using borland, break this up using jburks method
-
- if (fread(buffer, length, 1, fileHandle) != 1) {
- lastErr = dosErrCode();
- return -1;
- }
- chunk.pos += length;
- form.pos += length;
- return length;
-}
-
-#if 0
-void iffReadHandle::stopChunks(ChunkID *stopList) {
-}
-#endif
-
-iffWriteHandle::iffWriteHandle(char *filename, ChunkID formName) {
- name = filename;
-
- fileHandle = fopen(filename, "wb");
- if (fileHandle == NULL) {
- lastErr = dosErrCode();
- } else {
- uint32 hdr[ 3 ];
-
- // Set up the form handle
-
- form.id = formName;
- form.size = -1;
- form.pos = 4;
- form.patch = 4;
-
- // write the form handle
-
- hdr[ 0 ] = ID_FORM;
- hdr[ 1 ] = 0;
- hdr[ 2 ] = formName;
-
- if (fwrite(hdr, sizeof hdr, 1, fileHandle) != 1) {
- lastErr = dosErrCode();
- }
- }
-}
-
-iffWriteHandle::~iffWriteHandle() {
- if (fileHandle) {
- if (lastErr == errOK) {
- swapLong(form.pos);
-
- if (fseek(fileHandle, form.patch, SEEK_SET) != 0
- || fwrite(&form.pos, 4, 1, fileHandle) != 1
- || fseek(fileHandle, form.pos, SEEK_SET) != 0) {
- lastErr = dosErrCode();
- }
-
- swapLong(form.pos);
- }
- fclose(fileHandle);
- }
-}
-
-bool iffWriteHandle::pushChunk(ChunkID id, int32 length) {
- int32 hdr[ 2 ];
-
- if (lastErr != errOK) return FALSE;
-
- chunk.id = id;
- chunk.pos = 0;
- if (length >= 0) {
- chunk.size = length;
- chunk.patch = 0;
- } else {
- chunk.size = -1;
- chunk.patch = form.pos + 8 + 4;
- }
-
- hdr[ 0 ] = id;
- hdr[ 1 ] = chunk.size;
- swapLong(hdr[ 1 ]);
-
- if (fwrite(hdr, sizeof hdr, 1, fileHandle) != 1) {
- lastErr = dosErrCode();
- }
-
- form.pos += 8;
-
- return TRUE;
-}
-
-bool iffWriteHandle::popChunk(void) {
- int32 length;
-
- if (lastErr != errOK) return FALSE;
-
- // Figure out length of chunk...
-
- if (chunk.size == -1)
- length = chunk.pos;
- else length = chunk.size;
-
- // Add NULL pad bytes to fill to end of chunk
-
- while (chunk.pos < length) {
- if (fputc(0, fileHandle) == EOF) {
- lastErr = dosErrCode();
- return FALSE;
- }
- chunk.pos++;
- form.pos++;
- }
-
- // extend chunk length to include pad byte
-
- if (length & 1) {
- if (fputc(0, fileHandle) == EOF) {
- lastErr = dosErrCode();
- return FALSE;
- }
- chunk.pos++;
- form.pos++;
- }
-
- // Now, patch the chunk length if needed
-
- if (chunk.patch > 0) {
- swapLong(length);
-
- if (fseek(fileHandle, chunk.patch, SEEK_SET) != 0) {
- lastErr = dosErrCode();
- return FALSE;
- }
-
- if (fwrite(&length, 4, 1, fileHandle) != 1) {
- lastErr = dosErrCode();
- return FALSE;
- }
-
- if (fseek(fileHandle, form.pos + 8, SEEK_SET) != 0) {
- lastErr = dosErrCode();
- return FALSE;
- }
- }
- return TRUE;
-}
-
-int32 iffWriteHandle::write(void *buffer, int32 length) {
- if (lastErr != errOK) return FALSE;
-
- if (length <= 0) return 0;
- else if (chunk.size > 0 && length > chunk.size - chunk.pos)
- length = chunk.size - chunk.pos;
-
- // REM: If using borland, break this up using jburks method
-
- if (fwrite(buffer, length, 1, fileHandle) != 1) {
- lastErr = dosErrCode();
- return FALSE;
- }
-
- chunk.pos += length;
- form.pos += length;
-
- return length;
-}
-
-int32 iffWriteHandle::writeChunk(ChunkID id, void *buffer, int32 length) {
- return (pushChunk(id, length)
- && write(buffer, length)
- && popChunk());
-}
-
-void swapLong(int32 &l) {
-#if defined(MSDOS) || defined(__MSDOS__)
- l = ((l >> 24) & 0x000000ffL) |
- ((l >> 8) & 0x0000ff00L) |
- ((l << 8) & 0x00ff0000L) |
- ((l << 24) & 0xff000000L);
-#endif
-}
-
-void swapWord(int16 &w) {
-#if defined(MSDOS) || defined(__MSDOS__)
- w = ((w >> 8) & 0x00ff) | ((w << 8) & 0xff00);
-#endif
-}
-
-} // end of namespace Saga2
diff --git a/engines/saga2/iff.h b/engines/saga2/iff.h
deleted file mode 100644
index 8a0b47bd85..0000000000
--- a/engines/saga2/iff.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#ifndef SAGA2_IFF_H
-#define SAGA2_IFF_H
-
-#include "saga2/errors.h"
-
-namespace Saga2 {
-
-enum iffErrCodes {
- errNotIFF = 0x100, // not an iff form
- errMangledForm, // data in form is mangled
- errEndOfFile, // unexpected EOF reached
-};
-
-// Right now I don't care about clipboard or memory reading...
-
-typedef uint32 ChunkID;
-
-#define MakeID(a,b,c,d) (((ChunkID)d<<24L)|((ChunkID)c<<16L)|(b<<8L)|a)
-
-const ChunkID ID_FORM = MakeID('F', 'O', 'R', 'M'),
- ID_NAME = MakeID('N', 'A', 'M', 'E'),
- ID_AUTH = MakeID('A', 'U', 'T', 'H'),
- ID_COPYRIGHT = MakeID('(', 'C', ')', ' ');
-
-struct chunkInfo {
- ChunkID id; // id of this chunk
- int32 size, // size of chunk
- pos; // filepos within chunk
- int32 patch; // file position to patch
-};
-
-// Base class for both reading and writing handles
-
-class iffHandle {
-protected:
- char *name; // name of file
- FILE *fileHandle; // handle to raw file
- uint16 flags;
- errorCode lastErr;
-
- chunkInfo form, // info on current FORM
- chunk; // info on current chunk
-
- iffHandle(void);
-
- void swapLong(int32 &l); // put bytes in moto order
-
-public:
- errorCode lastError(void) { // returns last error code
- return lastErr;
- }
-
- void setError(errorCode e) { // sets error code
- lastErr = e;
- }
-
- int32 chunkLength(void) { // length of this chunk
- return chunk.size;
- }
-
- int32 chunkPos(void) { // position of chunk
- return chunk.pos;
- }
-
- int32 formLength(void) { // length of this form
- return form.size;
- }
-
- int32 formPos(void) { // position of form
- return form.pos;
- }
-
- char *getFileName(void) {
- return name;
- }
-};
-
-enum iffFlags {
- iffStreamIO = (1 << 0),
-};
-
-// IFF reading handle
-
-class iffReadHandle : public iffHandle {
-// ChunkID *stopList;
-
- bool readChunk(void);
- bool skipChunk(void);
-public:
- iffReadHandle(char *filename, ChunkID &formName);
- virtual ~iffReadHandle(void);
-
- bool nextChunk(ChunkID &id);
- int32 read(void *buffer, int32 length);
-
-// bool seekChunk( ChunkID );
-// void stopChunks( ChunkID *stopList );
-};
-
-// IFF writing handle
-
-class iffWriteHandle : public iffHandle {
-public:
- iffWriteHandle(char *filename, ChunkID formName);
- virtual ~iffWriteHandle(void);
-
- bool pushChunk(ChunkID id, int32 length = -1);
- bool popChunk(void);
-
- // Write bytes
- int32 write(void *buffer, int32 length);
-
- // Write a whole chunk
- int32 writeChunk(ChunkID id, void *buffer, int32 length);
-};
-
-void swapLong(int32 &l);
-void swapWord(int16 &w);
-
-} // end of namespace Saga2
-
-#endif
diff --git a/engines/saga2/module.mk b/engines/saga2/module.mk
index 568c96162c..dfcb686b13 100644
--- a/engines/saga2/module.mk
+++ b/engines/saga2/module.mk
@@ -32,7 +32,6 @@ MODULE_OBJS := \
gtext.o \
gtextbox.o \
hresmgr.o \
- iff.o \
imagcach.o \
images.o \
input.o \
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 4b37124028..4861376c71 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -37,7 +37,6 @@
#include "saga2/contain.h"
#include "saga2/setup.h"
#include "saga2/script.h"
-#include "saga2/iff.h"
#include "saga2/player.h"
#include "saga2/target.h"
#include "saga2/uimetrcs.h"
diff --git a/engines/saga2/savefile.h b/engines/saga2/savefile.h
index b220fefec7..970192c651 100644
--- a/engines/saga2/savefile.h
+++ b/engines/saga2/savefile.h
@@ -27,8 +27,6 @@
#ifndef SAGA2_SAVEFILE_H
#define SAGA2_SAVEFILE_H
-#include "saga2/iff.h"
-
namespace Saga2 {
/* ===================================================================== *
diff --git a/engines/saga2/std.h b/engines/saga2/std.h
index 40fb4965d2..dc9cb17176 100644
--- a/engines/saga2/std.h
+++ b/engines/saga2/std.h
@@ -29,6 +29,9 @@
#include "common/system.h"
+typedef uint32 ChunkID;
+#define MakeID(a,b,c,d) ((d<<24L)|(c<<16L)|(b<<8L)|a)
+
#include "saga2/rmemfta.h"
#include "saga2/saga2.h"
@@ -66,7 +69,6 @@ typedef bool BOOL;
#define maxuint32 0xffffffffu
#define minuint32 0u
-
#include "saga2/blitters.h"
#endif //SAGA2_STD_H
diff --git a/engines/saga2/vpal.cpp b/engines/saga2/vpal.cpp
index fb1e3dfd8b..75dd6d0b63 100644
--- a/engines/saga2/vpal.cpp
+++ b/engines/saga2/vpal.cpp
@@ -28,7 +28,6 @@
#include "saga2/std.h"
#include "saga2/fta.h"
-#include "saga2/iff.h"
#include "saga2/palette.h"
#include "saga2/transit.h"
#include "saga2/cmisc.h"
Commit: 426e750347c6424acbdb16cd0169e047df3d9eef
https://github.com/scummvm/scummvm/commit/426e750347c6424acbdb16cd0169e047df3d9eef
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:51+02:00
Commit Message:
SAGA2: Code formatting
Changed paths:
engines/saga2/intrface.cpp
engines/saga2/speldraw.cpp
engines/saga2/sprite.cpp
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index 0c203b6172..00e27b3068 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -59,7 +59,6 @@ extern const uint32 imageGroupID;
extern gPanelList *tileControls;
extern BackWindow *mainWindow;
extern uint8 fixedColors[ 16 ];
-extern uint8 ColorMapRanges[][ 8 ];
/* ===================================================================== *
diff --git a/engines/saga2/speldraw.cpp b/engines/saga2/speldraw.cpp
index 71f504ad7a..f0094860f6 100644
--- a/engines/saga2/speldraw.cpp
+++ b/engines/saga2/speldraw.cpp
@@ -45,7 +45,6 @@ namespace Saga2 {
Imports
* ===================================================================== */
-extern uint8 ColorMapRanges[][ 8 ];
extern ColorScheme **spellSchemes;
extern ColorTable spellColorMaps[];
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index d1297f716a..5610e22608 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -80,7 +80,7 @@ extern gPixelMap tileDrawMap;
extern Point16 fineScroll; // current scroll pos
// Color map ranges
-extern uint8 ColorMapRanges[][ 8 ];
+extern uint8 ColorMapRanges[][8];
extern gPort backPort;
@@ -101,7 +101,7 @@ extern uint8 fixedColors[] = {
SpriteSet **objectSprites, // object sprites
* *mentalSprites, // intangible object sprites
- * *weaponSprites[ maxWeaponSpriteSets ], // weapon sprites
+ * *weaponSprites[maxWeaponSpriteSets], // weapon sprites
* *missileSprites; // missile sprites
hResContext *spriteRes, // sprite resource handle
@@ -110,7 +110,7 @@ hResContext *spriteRes, // sprite resource handle
*schemeRes; // schemelist resource handle
// An array of 32 actor appearances
-static ActorAppearance appearanceTable[ 32 ];
+static ActorAppearance appearanceTable[32];
// A least-recently-used list of actor appearances
static DList appearanceLRU;
@@ -297,7 +297,7 @@ void DrawCompositeMaskedSprite(
visiblePixels = 0;
for (i = 0; i < compMapBytes; i++) {
- if (compMap.data[ i ] != 0) {
+ if (compMap.data[i] != 0) {
visiblePixels++;
if (visiblePixels > 10) break;
}
@@ -320,9 +320,9 @@ void DrawCompositeMaskedSprite(
uint8 *submergedArea = &compMap.data[(-loc.z < compMap.size.y ?
(compMap.size.y + loc.z)
* compMap.size.x :
- 0) ];
+ 0)];
- uint16 submergedSize = &compMap.data[ compMap.bytes() ] -
+ uint16 submergedSize = &compMap.data[compMap.bytes()] -
submergedArea;
memset(submergedArea, 0, submergedSize);
@@ -461,10 +461,10 @@ uint8 GetSpritePixel(
// Map the coords to the bitmap and return the pixel
if (flipped) {
- result = sprMap.data[ testPoint.y * sprMap.size.x
- + sprMap.size.x - testPoint.x ];
+ result = sprMap.data[testPoint.y * sprMap.size.x
+ + sprMap.size.x - testPoint.x];
} else {
- result = sprMap.data[ testPoint.y * sprMap.size.x + testPoint.x ];
+ result = sprMap.data[testPoint.y * sprMap.size.x + testPoint.x];
}
freeQuickMem(sprMap.data);
@@ -543,7 +543,7 @@ uint16 visiblePixelsInSprite(
// count the visible pixels in the composite map
for (i = 0, visiblePixels = 0; i < compBytes; i++)
- if (compMap.data[ i ]) visiblePixels++;
+ if (compMap.data[i]) visiblePixels++;
#if DEBUG*0
WriteStatusF(8, "Visible pixels = %u", visiblePixels);
@@ -571,7 +571,7 @@ void buildColorTable(
dst = (uint32 *)(colorTable + sizeof fixedColors);
while (numOptions--) {
- src = (uint32 *)ColorMapRanges[ *colorOptions++ ];
+ src = (uint32 *)ColorMapRanges[*colorOptions++];
*dst++ = *src++;
*dst++ = *src++;
}
@@ -583,17 +583,17 @@ void buildColorTable(
#if DEBUG
char *idname(long s) {
- static char t[ 8 ];
+ static char t[8];
char *p = (char *)&s;
- t[ 0 ] = *p++;
- t[ 1 ] = *p++;
- t[ 2 ] = *p++;
+ t[0] = *p++;
+ t[1] = *p++;
+ t[2] = *p++;
if (*p > ' ') {
- t[ 3 ] = *p;
- t[ 4 ] = 0;
+ t[3] = *p;
+ t[4] = 0;
} else {
- sprintf(&t[ 3 ], ":%d", *p);
+ sprintf(&t[3], ":%d", *p);
}
return t;
}
@@ -612,30 +612,14 @@ void ActorAppearance::loadSpriteBanks(int16 banksNeeded) {
for (bank = 0; bank < elementsof(spriteBanks); bank++) {
// Wash the sprite banks...i.e. clear out dead handles
// which have been purged.
- washHandle((RHANDLE &)(spriteBanks[ bank ]));
+ washHandle((RHANDLE &)(spriteBanks[bank]));
// Load the sprite handle...
- if (spriteBanks[ bank ] == NULL
- && (banksNeeded & (1 << bank))) {
- spriteBanks[ bank ] =
- (SpriteSet **)spriteRes->load(id + RES_ID(0, 0, 0, bank), "sprite bank",
-
-
-//
-// THIS WAS TRUE BUT THE SPRITE CORRUPTION GOES AWAY IF IT ISNT
-//
-//
-
-
- FALSE);
-
-
-
-
-
+ if (spriteBanks[bank] == NULL && (banksNeeded & (1 << bank))) {
+ spriteBanks[bank] = (SpriteSet **)spriteRes->load(id + RES_ID(0, 0, 0, bank), "sprite bank", FALSE);
#if DEBUG
- if (spriteBanks[ bank ] == NULL)
+ if (spriteBanks[bank] == NULL)
fatal("Sprite '%s' bank %d failed to load!\n",
idname(id),
bank);
@@ -643,7 +627,7 @@ void ActorAppearance::loadSpriteBanks(int16 banksNeeded) {
// Since the sprites are so big, we'll keep them unlocked
// so that they can be purged as needed.
- RUnlockHandle((RHANDLE) spriteBanks[ bank ]);
+ RUnlockHandle((RHANDLE) spriteBanks[bank]);
}
}
}
@@ -689,9 +673,9 @@ ActorAppearance *LoadActorAppearance(uint32 id, int16 banksNeeded) {
// Dump the sprites being stored
for (bank = 0; bank < elementsof(aa->spriteBanks); bank++) {
- if (aa->spriteBanks[ bank ])
- spriteRes->release((RHANDLE) aa->spriteBanks[ bank ]);
- aa->spriteBanks[ bank ] = NULL;
+ if (aa->spriteBanks[bank])
+ spriteRes->release((RHANDLE) aa->spriteBanks[bank]);
+ aa->spriteBanks[bank] = NULL;
}
if (aa->poseList) poseRes->release((RHANDLE) aa->poseList);
@@ -766,11 +750,11 @@ void initSprites(void) {
weaponSpriteID = weaponSpriteBaseID + RES_ID(0, 0, 0, i);
if (spriteRes->size(weaponSpriteID) == 0) {
- weaponSprites[ i ] = NULL;
+ weaponSprites[i] = NULL;
continue;
}
- weaponSprites[ i ] = (SpriteSet **)spriteRes->load(
+ weaponSprites[i] = (SpriteSet **)spriteRes->load(
weaponSpriteID,
"weapon sprite set");
}
@@ -781,7 +765,7 @@ void initSprites(void) {
// Initialize actor appearance table
for (i = 0; i < elementsof(appearanceTable); i++) {
- ActorAppearance *aa = &appearanceTable[ i ];
+ ActorAppearance *aa = &appearanceTable[i];
aa->useCount = 0;
appearanceLRU.addHead(*aa);
@@ -800,9 +784,9 @@ void cleanupSprites(void) {
mentalSprites = NULL;
for (i = 0; i < maxWeaponSpriteSets; i++) {
- if (weaponSprites[ i ]) {
- spriteRes->release((RHANDLE) weaponSprites[ i ]);
- weaponSprites[ i ] = NULL;
+ if (weaponSprites[i]) {
+ spriteRes->release((RHANDLE) weaponSprites[i]);
+ weaponSprites[i] = NULL;
}
}
Commit: 44d293f6fc69937a3528d69148cdba1877aa1d8f
https://github.com/scummvm/scummvm/commit/44d293f6fc69937a3528d69148cdba1877aa1d8f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:51+02:00
Commit Message:
SAGA2: Load ColorMapRanges from the .exe, kill maprange.cpp
Changed paths:
R engines/saga2/maprange.cpp
engines/saga2/module.mk
engines/saga2/saga2.cpp
engines/saga2/sprite.cpp
diff --git a/engines/saga2/maprange.cpp b/engines/saga2/maprange.cpp
deleted file mode 100644
index 282b830bc5..0000000000
--- a/engines/saga2/maprange.cpp
+++ /dev/null
@@ -1,248 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * aint32 with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-/* ===================================================================== *
- maprange.c -- Created from maprange.bbm
- Image Size: 8 Wide by 168 High.
- Converted by iff2c.
- * ===================================================================== */
-
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
-#include "saga2/std.h"
-
-namespace Saga2 {
-
-//uint8 fixedColors[] = {
-// 0, 1, 3, 5, 7, 9, 12, 15,
-// 92,95,121,123,188,190,219,221
-//};
-
-uint8 ColorMapRanges[][ 8 ] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Transparent row
- 0x0A, 0x0A, 0x0C, 0x0E, 0x10, 0x12, 0x14, 0x16, // Row 0
- 0x0A, 0x0C, 0x0E, 0x10, 0x12, 0x14, 0x16, 0x18, // Row 1
- 0x0C, 0x0E, 0x10, 0x12, 0x14, 0x16, 0x18, 0x18, // Row 2
- 0x0E, 0x10, 0x12, 0x14, 0x16, 0x18, 0x18, 0x18, // Row 3
- 0x0A, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, // Row 4
- 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, // Row 5
- 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, // Row 6
- 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, // Row 7
- 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, // Row 8
- 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, // Row 9
- 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, // Row 10
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, // Row 11
- 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, // Row 12
- 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x18, // Row 13
- 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x18, 0x18, // Row 14
- 0x15, 0x16, 0x17, 0x18, 0x18, 0x18, 0x18, 0x18, // Row 15
- 0xA1, 0xA1, 0xA2, 0xA3, 0xA4, 0x12, 0x13, 0x14, // Row 16
- 0xA1, 0xA2, 0xA3, 0xA4, 0x12, 0x13, 0x14, 0x15, // Row 17
- 0xA2, 0xA3, 0xA4, 0x12, 0x13, 0x14, 0x15, 0x16, // Row 18
- 0xA3, 0xA4, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, // Row 19
- 0x19, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, // Row 20
- 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, // Row 21
- 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x14, 0x15, // Row 22
- 0x0A, 0x0A, 0x0B, 0x21, 0x22, 0x23, 0x24, 0x25, // Row 23
- 0x0A, 0x0B, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, // Row 24
- 0x0B, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, // Row 25
- 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, // Row 26
- 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x28, // Row 27
- 0x29, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, // Row 28
- 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, // Row 29
- 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, // Row 30
- 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, // Row 31
- 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, // Row 32
- 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, // Row 33
- 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x18, // Row 34
- 0xD9, 0xD9, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, // Row 35
- 0xD9, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, // Row 36
- 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, // Row 37
- 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x33, // Row 38
- 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x33, 0x34, // Row 39
- 0x54, 0x55, 0x56, 0x57, 0x58, 0x33, 0x34, 0x18, // Row 40
- 0xA5, 0xA5, 0xA6, 0xA7, 0xA8, 0x38, 0x58, 0x33, // Row 41
- 0x21, 0x21, 0x22, 0x23, 0x35, 0x36, 0x37, 0x38, // Row 42
- 0x21, 0x22, 0x23, 0x35, 0x36, 0x37, 0x38, 0x58, // Row 43
- 0x22, 0x23, 0x35, 0x36, 0x37, 0x38, 0x58, 0x33, // Row 44
-// 0x39,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F, // Row 45
- 0xE9, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, // Row 45 (replaced)
- 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, // Row 46
- 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, // Row 47
- 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, // Row 48
- 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, // Row 49
- 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, // Row 50
- 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x18, // Row 51
- 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x18, 0x18, // Row 52
- 0x49, 0x49, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, // Row 53
- 0x49, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, // Row 54
- 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, // Row 55
- 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x5F, // Row 56
- 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x5F, 0x60, // Row 57
- 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x5F, 0x60, 0x61, // Row 58
- 0x4D, 0x4E, 0x4F, 0x50, 0x5F, 0x60, 0x61, 0x62, // Row 59
- 0x4E, 0x4F, 0x50, 0x5F, 0x60, 0x61, 0x62, 0x63, // Row 60
- 0x0A, 0x49, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, // Row 61
- 0x49, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, // Row 62
- 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, // Row 63
- 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, // Row 64
- 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, // Row 65
- 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, // Row 66
- 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, // Row 67
- 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x18, // Row 68
- 0x49, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, // Row 69
- 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x80, // Row 70
- 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x80, 0x72, // Row 71
- 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x80, 0x72, 0x73, // Row 72
- 0x7C, 0x7D, 0x7E, 0x7F, 0x80, 0x72, 0x73, 0x74, // Row 73
- 0x81, 0x81, 0x82, 0x83, 0x84, 0x80, 0x72, 0x73, // Row 74
- 0x81, 0x82, 0x83, 0x84, 0x80, 0x72, 0x73, 0x74, // Row 75
- 0x82, 0x83, 0x84, 0x80, 0x72, 0x73, 0x74, 0x74, // Row 76
- 0x69, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, // Row 77
- 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, // Row 78
- 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, // Row 79
- 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, // Row 80
- 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, // Row 81
- 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, // Row 82
- 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x18, // Row 83
- 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x18, 0x18, // Row 84
- 0x3A, 0x69, 0x6B, 0x75, 0x76, 0x77, 0x78, 0x73, // Row 85
- 0x69, 0x6B, 0x75, 0x76, 0x77, 0x78, 0x73, 0x74, // Row 86
- 0x6B, 0x75, 0x76, 0x77, 0x78, 0x73, 0x74, 0x18, // Row 87
- 0x75, 0x76, 0x77, 0x78, 0x73, 0x74, 0x18, 0x18, // Row 88
- 0x85, 0x85, 0x86, 0x87, 0x88, 0x74, 0x18, 0x18, // Row 89
- 0x85, 0x86, 0x87, 0x88, 0x74, 0x18, 0x18, 0x18, // Row 90
- 0x86, 0x87, 0x88, 0x74, 0x18, 0x18, 0x18, 0x18, // Row 91
- 0x89, 0x89, 0x89, 0x8A, 0x8B, 0x8C, 0x88, 0x74, // Row 92
- 0x89, 0x89, 0x8A, 0x8B, 0x8C, 0x88, 0x74, 0x18, // Row 93
- 0x89, 0x8A, 0x8B, 0x8C, 0x88, 0x74, 0x18, 0x18, // Row 94
- 0x45, 0x45, 0x8D, 0x8E, 0x8F, 0x90, 0x42, 0x43, // Row 95
- 0x91, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, // Row 96
- 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, // Row 97
- 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x16, // Row 98
- 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x16, 0x17, // Row 99
- 0x94, 0x95, 0x96, 0x97, 0x98, 0x16, 0x17, 0x18, // Row 100
- 0x95, 0x96, 0x97, 0x98, 0x16, 0x17, 0x18, 0x18, // Row 101
- 0x96, 0x97, 0x98, 0x16, 0x17, 0x18, 0x18, 0x18, // Row 102
- 0x99, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, // Row 103
- 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0xA0, // Row 104
- 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0xA0, 0x16, // Row 105
- 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0xA0, 0x16, 0x17, // Row 106
- 0x9C, 0x9D, 0x9E, 0x9F, 0xA0, 0x16, 0x17, 0x18, // Row 107
- 0x9D, 0x9E, 0x9F, 0xA0, 0x16, 0x17, 0x18, 0x18, // Row 108
- 0xAB, 0xAC, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, // Row 109
- 0xAC, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0x15, // Row 110
- 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0x15, 0x16, // Row 111
- 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0x15, 0x16, 0x17, // Row 112
- 0xC5, 0xC6, 0xC7, 0xC8, 0x15, 0x16, 0x17, 0x18, // Row 113
- 0xC6, 0xC7, 0xC8, 0x15, 0x16, 0x17, 0x18, 0x18, // Row 114
- 0xA9, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, // Row 115
- 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, // Row 116
- 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, // Row 117
- 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, // Row 118
- 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0x9E, // Row 119
- 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0x9E, 0x9F, // Row 120
- 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0x9E, 0x9F, 0xA0, // Row 121
- 0xAF, 0xB0, 0xB1, 0xB2, 0x9E, 0x9F, 0xA0, 0x16, // Row 122
- 0xB0, 0xB1, 0xB2, 0x9E, 0x9F, 0xA0, 0x16, 0x17, // Row 123
- 0xB1, 0xB2, 0x9E, 0x9F, 0xA0, 0x16, 0x17, 0x18, // Row 124
- 0xB2, 0x9E, 0x9F, 0xA0, 0x16, 0x17, 0x18, 0x18, // Row 125
- 0xB9, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, // Row 126
- 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xC0, // Row 127
- 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xC0, 0xC1, // Row 128
- 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xC0, 0xC1, 0xC2, // Row 129
- 0xBC, 0xBD, 0xBE, 0xBF, 0xC0, 0xC1, 0xC2, 0xD7, // Row 130
- 0xBD, 0xBE, 0xBF, 0xC0, 0xC1, 0xC2, 0xD7, 0xD8, // Row 131
- 0xBE, 0xBF, 0xC0, 0xC1, 0xC2, 0xD7, 0xD8, 0x18, // Row 132
- 0xBF, 0xC0, 0xC1, 0xC2, 0xD7, 0xD8, 0x18, 0x18, // Row 133
- 0xB3, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x9E, // Row 134
- 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x9E, 0x9F, // Row 135
- 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0x9E, 0x9F, 0xA0, // Row 136
- 0xB5, 0xB6, 0xB7, 0xB8, 0x9E, 0x9F, 0xA0, 0x16, // Row 137
- 0xB6, 0xB7, 0xB8, 0x9E, 0x9F, 0xA0, 0x16, 0x17, // Row 138
- 0xB7, 0xB8, 0x9E, 0x9F, 0xA0, 0x16, 0x17, 0x18, // Row 139
- 0xB8, 0x9E, 0x9F, 0xA0, 0x16, 0x17, 0x18, 0x18, // Row 140
- 0xDE, 0xDE, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, // Row 141
- 0xDE, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, // Row 142
- 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, // Row 143
- 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, // Row 144
- 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, // Row 145
- 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0x18, // Row 146
- 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0x18, 0x18, // Row 147
- 0x0A, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, // Row 148
- 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, // Row 149
- 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xE6, // Row 150
- 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xE6, 0xE7, // Row 151
- 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xE6, 0xE7, 0xE8, // Row 152
- 0xCD, 0xCE, 0xCF, 0xD0, 0xE6, 0xE7, 0xE8, 0x18, // Row 153
- 0xCE, 0xCF, 0xD0, 0xE6, 0xE7, 0xE8, 0x18, 0x18, // Row 154
- 0xD1, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, // Row 155
- 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, // Row 156
- 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0x18, // Row 157
- 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0x18, 0x18, // Row 158
- 0xD9, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xCE, 0xCF, // Row 159
- 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xCE, 0xCF, 0xD0, // Row 160
- 0xDA, 0xDB, 0xDC, 0xDD, 0xCE, 0xCF, 0xD0, 0xE6, // Row 161
- 0xDB, 0xDC, 0xDD, 0xCE, 0xCF, 0xD0, 0xE6, 0xE7, // Row 162
- 0xDC, 0xDD, 0xCE, 0xCF, 0xD0, 0xE6, 0xE7, 0xE8, // Row 163
- 0xDD, 0xCE, 0xCF, 0xD0, 0xE6, 0xE7, 0xE8, 0x18, // Row 164
- 0xDA, 0xDA, 0xDB, 0xDC, 0x65, 0x66, 0x67, 0x68, // Row 165
- 0xDA, 0xDB, 0xDC, 0x65, 0x66, 0x67, 0x68, 0x68, // Row 166
- 0xDB, 0xDC, 0x65, 0x66, 0x67, 0x68, 0x68, 0x68, // Row 167
-
- // Extra colors added later
- 0x0A, 0x0F, 0x12, 0x14, 0x16, 0x17, 0x18, 0x18, // Row 0
- 0x0C, 0x10, 0x13, 0x15, 0x16, 0x17, 0x18, 0x18, // Row 1
- 0x0F, 0x12, 0x14, 0x16, 0x17, 0x18, 0x18, 0x18, // Row 2
- 0x11, 0x14, 0x16, 0x17, 0x18, 0x18, 0x18, 0x18, // Row 3
- 0x0A, 0x2C, 0x2F, 0x31, 0x32, 0x33, 0x34, 0x18, // Row 4
- 0x2C, 0x2F, 0x31, 0x33, 0x34, 0x18, 0x18, 0x18, // Row 5
- 0x30, 0x32, 0x33, 0x34, 0x18, 0x18, 0x18, 0x18, // Row 6
- 0x31, 0x34, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // Row 7
- 0xD9, 0x52, 0x55, 0x57, 0x58, 0x33, 0x34, 0x18, // Row 8
- 0x52, 0x54, 0x57, 0x58, 0x33, 0x34, 0x18, 0x18, // Row 9
- 0x55, 0x57, 0x33, 0x18, 0x18, 0x18, 0x18, 0x18, // Row 10
- 0x39, 0x3C, 0x3F, 0x42, 0x43, 0x44, 0x18, 0x18, // Row 11
- 0x3B, 0x3E, 0x40, 0x42, 0x43, 0x44, 0x18, 0x18, // Row 12
- 0x3E, 0x40, 0x43, 0x44, 0x18, 0x18, 0x18, 0x18, // Row 13
- 0x0A, 0x5A, 0x5D, 0x60, 0x62, 0x63, 0x64, 0x18, // Row 14
- 0x59, 0x5B, 0x5E, 0x61, 0x62, 0x63, 0x64, 0x18, // Row 15
- 0x5B, 0x5D, 0x5F, 0x62, 0x63, 0x64, 0x18, 0x18, // Row 16
- 0x5C, 0x5F, 0x62, 0x63, 0x64, 0x18, 0x18, 0x18, // Row 17
- 0xDE, 0xE1, 0xE3, 0xE5, 0xE7, 0xE8, 0x18, 0x18, // Row 18
- 0xE0, 0xE2, 0xE4, 0xE6, 0xE8, 0x18, 0x18, 0x18, // Row 19
- 0xE2, 0xE4, 0xE6, 0xE8, 0x18, 0x18, 0x18, 0x18, // Row 20
- 0xE4, 0xE6, 0xE8, 0x18, 0x18, 0x18, 0x18, 0x18, // Row 21
- 0xA9, 0xAC, 0xAF, 0xB1, 0xB2, 0x9E, 0x9F, 0xA0, // Row 22
- 0xA9, 0xAD, 0xB1, 0x9E, 0xA0, 0x16, 0x17, 0x18, // Row 23
- 0xB3, 0xB6, 0xB8, 0x9E, 0xA0, 0x16, 0x18, 0x18, // Row 24
- 0x0A, 0x0A, 0xEA, 0xE9, 0x39, 0x3A, 0x3B, 0x3C, // Row 25
- 0x0A, 0xEA, 0xE9, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, // Row 26
- 0xEA, 0xE9, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, // Row 27
- 0xBC, 0xBB, 0xBA, 0xB9, 0x2F, 0x2E, 0x2D, 0x2C, // Row 28
-};
-
-} // end of namespace Saga2
diff --git a/engines/saga2/module.mk b/engines/saga2/module.mk
index dfcb686b13..cfabd2e648 100644
--- a/engines/saga2/module.mk
+++ b/engines/saga2/module.mk
@@ -45,7 +45,6 @@ MODULE_OBJS := \
main.o \
mainmap.o \
mapfeatr.o \
- maprange.o \
messager.o \
metaengine.o \
mission.o \
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index 338152c908..59cc713692 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -150,6 +150,8 @@ uint32 loadingWindowHeight = 480;
uint8 *loadingWindowPalette;
uint8 *loadingWindowData;
+uint8 *ColorMapRanges;
+
static void loadFont(Common::File &file, gFont *font, uint32 offset) {
file.seek(offset);
@@ -196,6 +198,10 @@ void Saga2Engine::loadExeResources() {
exe.seek(0x004A2A00 - offset);
exe.read(loadingWindowData, 307200);
+ ColorMapRanges = (uint8 *)malloc(1584);
+ exe.seek(0x004EDC20 - offset);
+ exe.read(ColorMapRanges, 1584);
+
exe.close();
}
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index 5610e22608..366c5743ee 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -80,7 +80,7 @@ extern gPixelMap tileDrawMap;
extern Point16 fineScroll; // current scroll pos
// Color map ranges
-extern uint8 ColorMapRanges[][8];
+extern uint8 *ColorMapRanges;
extern gPort backPort;
@@ -571,7 +571,8 @@ void buildColorTable(
dst = (uint32 *)(colorTable + sizeof fixedColors);
while (numOptions--) {
- src = (uint32 *)ColorMapRanges[*colorOptions++];
+ src = (uint32 *)ColorMapRanges[*colorOptions * 8];
+ colorOptions++;
*dst++ = *src++;
*dst++ = *src++;
}
Commit: 7271d3b52a96bd40491f57147ecb33ff59462780
https://github.com/scummvm/scummvm/commit/7271d3b52a96bd40491f57147ecb33ff59462780
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:51+02:00
Commit Message:
SAGA2: More removal of forbidden symbols
Changed paths:
engines/saga2/pt2angle.cpp
engines/saga2/rect.cpp
engines/saga2/rmem.cpp
diff --git a/engines/saga2/pt2angle.cpp b/engines/saga2/pt2angle.cpp
index e71a90c66c..11f12b9d20 100644
--- a/engines/saga2/pt2angle.cpp
+++ b/engines/saga2/pt2angle.cpp
@@ -24,8 +24,6 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
namespace Saga2 {
diff --git a/engines/saga2/rect.cpp b/engines/saga2/rect.cpp
index 1b3c305a0a..a3b676b34d 100644
--- a/engines/saga2/rect.cpp
+++ b/engines/saga2/rect.cpp
@@ -24,8 +24,6 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/rect.h"
diff --git a/engines/saga2/rmem.cpp b/engines/saga2/rmem.cpp
index 57a0a38fa8..a9d6042908 100644
--- a/engines/saga2/rmem.cpp
+++ b/engines/saga2/rmem.cpp
@@ -24,8 +24,6 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#define NO_LOCAL_MEMORY_OVERRIDES 1
Commit: 53d520e2cfad26aa1afaed1eb29532f7725760b0
https://github.com/scummvm/scummvm/commit/53d520e2cfad26aa1afaed1eb29532f7725760b0
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:51+02:00
Commit Message:
SAGA2: Remove osexcept.*
Changed paths:
R engines/saga2/osexcept.cpp
R engines/saga2/osexcept.h
engines/saga2/main.cpp
engines/saga2/mainmap.h
engines/saga2/module.mk
engines/saga2/tower.cpp
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 54ac7424e6..40a3ae6b2c 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -231,13 +231,7 @@ MAIN_RETURN_TYPE main_saga2() {
cleanExit = gameInitialized;
if (gameInitialized) {
- OSExceptBlk {
- mainLoop(cleanExit, 0, NULL);
- }
- OSExcepTrap {
- cleanExit = false;
- OSExceptHnd;
- }
+ mainLoop(cleanExit, 0, NULL);
}
shutdownGame();
diff --git a/engines/saga2/mainmap.h b/engines/saga2/mainmap.h
index 46d284e7e6..b71935eaad 100644
--- a/engines/saga2/mainmap.h
+++ b/engines/saga2/mainmap.h
@@ -27,8 +27,6 @@
#ifndef SAGA2_MAINMAP_H
#define SAGA2_MAINMAP_H 1
-#include "saga2/osexcept.h"
-
namespace Saga2 {
void main_saga2();
diff --git a/engines/saga2/module.mk b/engines/saga2/module.mk
index cfabd2e648..30bb6cd1c8 100644
--- a/engines/saga2/module.mk
+++ b/engines/saga2/module.mk
@@ -55,7 +55,6 @@ MODULE_OBJS := \
mouseimg.o \
objects.o \
objproto.o \
- osexcept.o \
panel.o \
path.o \
patrol.o \
diff --git a/engines/saga2/osexcept.cpp b/engines/saga2/osexcept.cpp
deleted file mode 100644
index f09a8afdb4..0000000000
--- a/engines/saga2/osexcept.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
-#include "saga2/std.h"
-#include "saga2/osexcept.h"
-
-namespace Saga2 {
-
-void DosExceptHandler() {
- warning("STUB: DosExceptHandler()");
-}
-
-} // end of namespace Saga2
diff --git a/engines/saga2/osexcept.h b/engines/saga2/osexcept.h
deleted file mode 100644
index 41a7ffbbc7..0000000000
--- a/engines/saga2/osexcept.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * aint32 with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#ifndef SAGA2_OSEXCEPT_H
-#define SAGA2_OSEXCEPT_H
-
-namespace Saga2 {
-
-// OS specific exception handling block defs
-
-#ifndef _WIN32
-
-void initFaultHandler(void);
-void DosExceptHandler(void);
-#if 1
-extern int gameKiller;
-#define OSExceptBlk
-#define OSExcepTrap if (gameKiller)
-#define OSExceptHnd DosExceptHandler();
-#else
-#define OSExceptBlk try
-#define OSExcepTrap catch (__WATCOM_exception)
-#define OSExceptHnd DosExceptHandler();
-#endif
-
-#else // _WIN32
-
-DWORD WinExceptFilter(DWORD ExCode, LPEXCEPTION_POINTERS ExPtr);
-void WinExceptHandler(void);
-#define OSExceptBlk __try
-#define OSExcepTrap __except ( \
- WinExceptFilter( \
- GetExceptionCode(), \
- GetExceptionInformation()) )
-#define OSExceptHnd WinExceptHandler()
-
-#endif // _WIN32
-
-} // end of namespace Saga2
-
-#endif
diff --git a/engines/saga2/tower.cpp b/engines/saga2/tower.cpp
index 569e895cda..7713cb355b 100644
--- a/engines/saga2/tower.cpp
+++ b/engines/saga2/tower.cpp
@@ -30,7 +30,6 @@
#include "saga2/std.h"
#include "saga2/tower.h"
-#include "saga2/osexcept.h"
#include "saga2/messager.h"
namespace Saga2 {
@@ -69,41 +68,15 @@ static int32 getTowerLayer(int is) {
static bool initTowerLayer(int is) {
bool r;
-#if !DEBUG
- OSExceptBlk {
-#endif
-
- r = tower[is].init();
-
-#if !DEBUG
- }
- OSExcepTrap {
- r = FALSE;
- OSExceptHnd;
- }
-#endif
-
+ r = tower[is].init();
return r;
-
}
static bool cleanupErr = FALSE;
static void termTowerLayer(int is) {
-#if !DEBUG
- OSExceptBlk {
-#endif
-
- tower[is].term();
-
-#if !DEBUG
- }
- OSExcepTrap {
- cleanupErr = TRUE;
- OSExceptHnd;
- }
-#endif
+ tower[is].term();
}
Commit: 3cb251421bbca7bfecb62d78412ba9635c5f06b8
https://github.com/scummvm/scummvm/commit/3cb251421bbca7bfecb62d78412ba9635c5f06b8
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:51+02:00
Commit Message:
SAGA2: Fix _numEntries
Changed paths:
engines/saga2/hresmgr.cpp
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index a7474ec4b6..d5df95467e 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -467,7 +467,7 @@ hResource::hResource(char *resname, char *extname, const char desc[]) {
// allocate buffers for root, groups and data
- _numEntries = origin.size;
+ _numEntries = origin.size / resourceSize;
_base = new hResEntry[_numEntries]();
tableSize = origin.offset - _firstGroupOffset - sizeof(uint32);
Commit: 58ad6895eb5c46498495dc34986f6fc5c5518f2b
https://github.com/scummvm/scummvm/commit/58ad6895eb5c46498495dc34986f6fc5c5518f2b
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:51+02:00
Commit Message:
SAGA2: Organize hresmgr functions
Changed paths:
engines/saga2/hresmgr.cpp
engines/saga2/hresmgr.h
engines/saga2/interp.cpp
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index d5df95467e..d14f105000 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -276,17 +276,20 @@ bool hResContext::get(hResID id, void *buffer, uint32 size) {
uint32 hResContext::getSize(hResID id, const char desc[]) {
hResEntry *entry;
+
if ((entry = findEntry(id)) == nullptr) {
warning("Resource %d, %s not found", id, desc);
return 0;
}
+ debugC(3, kDebugResources, "Size for %x (%s): %d", id, desc, entry->size);
return entry->size;
}
-byte *hResContext::loadResource(hResID id, Common::String filename, const char desc[]) {
+byte *hResContext::loadResource(hResID id, const char desc[], Common::String filename) {
hResEntry *entry;
+ debugC(3, kDebugResources, "Loading resource %x (%s)", id, desc);
if ((entry = findEntry(id)) == nullptr) {
warning("Resource %d, %s not found", id, desc);
return nullptr;
@@ -294,6 +297,9 @@ byte *hResContext::loadResource(hResID id, Common::String filename, const char d
byte *res = (byte*)malloc(entry->size);
+ if (filename.equalsIgnoreCase(""))
+ filename = _filename;
+
if (!_file.isOpen())
_file.open(filename);
@@ -359,6 +365,9 @@ byte *hResContext::loadIndexResource(int16 index, const char desc[], Common::Str
byte *res = (byte*)malloc(entry->size);
+ if (filename.equalsIgnoreCase(""))
+ filename = _filename;
+
if (!_file.isOpen())
_file.open(filename);
diff --git a/engines/saga2/hresmgr.h b/engines/saga2/hresmgr.h
index 44c00ed6a0..8b3b7cc4ce 100644
--- a/engines/saga2/hresmgr.h
+++ b/engines/saga2/hresmgr.h
@@ -162,8 +162,8 @@ public:
bool get(hResID id, void *buffer, uint32 size);
uint32 getSize(hResID id, const char desc[]);
RHANDLE load(hResID id, const char [], bool async = false, bool cacheable = true);
- byte *loadResource(hResID id, Common::String filename, const char desc[]);
- byte *loadIndexResource(int16 index, const char desc[], Common::String filename);
+ byte *loadResource(hResID id, const char desc[], Common::String filename);
+ byte *loadIndexResource(int16 index, const char desc[], Common::String filename = "");
RHANDLE loadIndex(int16 index, const char[], bool cacheable = true);
void release(RHANDLE p);
Common::File *resFileHandle(void) {
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 1eb61b5cc6..74b8f1ee81 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -690,8 +690,7 @@ bool Thread::interpret(void) {
//RUnlockHandle((RHANDLE)codeSeg);
codeSeg = scriptRes->loadIndexResource(programCounter.segment,
- "saga code segment",
- scriptRes->_filename);
+ "saga code segment");
pc = (codeSeg) + programCounter.offset;
n = *stack++; // get argument count from call
@@ -735,7 +734,7 @@ bool Thread::interpret(void) {
IMMED_WORD(w); // pick up segment number
programCounter.segment = w; // set current segment
//RUnlockHandle((RHANDLE)codeSeg);
- codeSeg = scriptRes->loadIndexResource(w, "saga code segment", scriptRes->_filename);
+ codeSeg = scriptRes->loadIndexResource(w, "saga code segment");
IMMED_WORD(w); // pick up segment offset
programCounter.offset = w; // store into pc
@@ -821,7 +820,7 @@ bool Thread::interpret(void) {
w = vtableEntry[ 0 ];
programCounter.segment = w;
//RUnlockHandle((RHANDLE)codeSeg);
- codeSeg = scriptRes->loadIndexResource(w, "saga code segment", scriptRes->_filename);
+ codeSeg = scriptRes->loadIndexResource(w, "saga code segment");
// store pc-offset into pc
programCounter.offset = vtableEntry[ 1 ];
@@ -1489,7 +1488,7 @@ Thread *getThreadAddress(ThreadID id) {
// Thread constructor
Thread::Thread(uint16 segNum, uint16 segOff, scriptCallFrame &args) {
- codeSeg = scriptRes->loadIndexResource(segNum, "saga code segment", scriptRes->_filename);
+ codeSeg = scriptRes->loadIndexResource(segNum, "saga code segment");
// initialize the thread
stackSize = kStackSize;
@@ -1534,8 +1533,7 @@ Thread::Thread(void **buf) {
bufferPtr = (int16 *)bufferPtr + 1;
codeSeg = scriptRes->loadIndexResource(programCounter.segment,
- "saga code segment",
- scriptRes->_filename);
+ "saga code segment");
stackBase = (UBytePtr)malloc(stackSize);
stackPtr = stackBase + stackSize - stackOffset;
@@ -1750,21 +1748,24 @@ void initScripts(void) {
error("Unable to open script resource file!\n");
// Load the data segment
- dataSegment = scriptRes->loadResource(dataSegID, scriptResFile->_filename, "saga data segment");
+ dataSegment = scriptRes->loadResource(dataSegID, "saga data segment", scriptResFile->_filename);
if (dataSegment == NULL)
error("Unable to load the SAGA data segment");
dataSegSize = scriptRes->getSize(dataSegID, "saga data segment");
+ debugC(2, kDebugScripts, "dataSegment loaded at 0x%08x: size: %d", dataSegment, dataSegSize);
// Common::hexdump(dataSegment, dataSegSize);
- exportSegment = scriptRes->loadResource(exportSegID, scriptResFile->_filename, "saga export segment");
+ exportSegment = scriptRes->loadResource(exportSegID, "saga export segment", scriptResFile->_filename);
assert(exportSegment != NULL);
// Common::hexdump(exportSegment, scriptRes->getSize(exportSegID, "saga export segment"));
exportCount = (scriptRes->getSize(exportSegID, "saga export segment") / sizeof(uint32)) + 1;
+ debugC(2, kDebugScripts, "exportSegment loaded at 0x%08x: size: %d, exportCount: %d",
+ exportSegment, scriptRes->getSize(exportSegID, "saga export segment"), exportCount);
}
void cleanupScripts(void) {
Commit: d4e1abcac7780a9abe9da7430ae12660a69510c2
https://github.com/scummvm/scummvm/commit/d4e1abcac7780a9abe9da7430ae12660a69510c2
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:51+02:00
Commit Message:
SAGA2: Store (index, pointer) pairs into a HashMap
Changed paths:
engines/saga2/hresmgr.cpp
engines/saga2/hresmgr.h
engines/saga2/interp.cpp
engines/saga2/main.cpp
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index d14f105000..394a67f4c0 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -68,7 +68,6 @@ hResContext::hResContext() {
_valid = false;
_base = nullptr;
_parent = nullptr;
- _data = nullptr;
_numEntries = 0;
_handle = &_file;
}
@@ -96,18 +95,11 @@ hResContext::hResContext(hResContext *sire, hResID id, const char desc[]) {
_base = &_res->_table[entry->offset - _res->_firstGroupOffset];
- _data = new RHANDLE[_numEntries]();
- if (_data == nullptr)
- return;
-
_valid = true;
}
hResContext::~hResContext() {
- if (_data) {
- delete[] _data;
- _data = nullptr;
- }
+ releaseIndexData();
}
hResEntry *hResContext::findEntry(hResID id, RHANDLE **capture) {
@@ -122,7 +114,6 @@ hResEntry *hResContext::findEntry(hResID id, RHANDLE **capture) {
for (i = 0, entry = _base; i < _numEntries; i++, entry++) {
debugC(2, kDebugResources, "%d: Trying ID: %x (%s)", i, entry->id, tag2str(entry->id));
if (entry->id == id) {
- if (capture) *capture = &_data[ i ];
debugC(2, kDebugResources, "findEntry: found %x (%s)", entry->id, tag2str(entry->id));
return entry;
}
@@ -363,8 +354,16 @@ byte *hResContext::loadIndexResource(int16 index, const char desc[], Common::Str
if (!_valid || entry == nullptr)
return nullptr;
+ if (_indexData.contains(index))
+ return _indexData.getVal(index);
+
byte *res = (byte*)malloc(entry->size);
+ if (res) {
+ debugC(4, kDebugResources, "_indexData: pushing (%d, %p)", index, (void*)res);
+ _indexData.setVal(index, res);
+ }
+
if (filename.equalsIgnoreCase(""))
filename = _filename;
@@ -387,7 +386,6 @@ RHANDLE hResContext::loadIndex(int16 index, const char desc[], bool cacheable) {
_bytepos = 0;
entry = &_base[ index ];
- capture = &_data[ index ];
if (*capture != nullptr && **capture != nullptr) {
entry->use();
@@ -418,7 +416,6 @@ void hResContext::release(RHANDLE p) {
if (_valid && p != nullptr) {
entry = _base;
- d = _data;
while (entry->id != BAD_ID) {
if ((RHANDLE)p == *d) {
@@ -436,6 +433,18 @@ void hResContext::release(RHANDLE p) {
}
}
+void hResContext::releaseIndexData() {
+ debugC(4, kDebugResources, "releaseIndexData():");
+ for (DataMap::iterator i = _indexData.begin(); i != _indexData.end(); ++i) {
+ debugC(4, kDebugResources, "... %d, %p", i->_key, (void*)i->_value);
+ if (i->_value) {
+ free(i->_value);
+ i->_value = nullptr;
+ _indexData.erase(i);
+ }
+ }
+}
+
/* ===================================================================== *
Resource file
* ===================================================================== */
@@ -457,7 +466,6 @@ hResource::hResource(char *resname, char *extname, const char desc[]) {
_valid = false;
_base = nullptr;
_parent = nullptr;
- _data = nullptr;
_numEntries = 0;
_filename = resname;
diff --git a/engines/saga2/hresmgr.h b/engines/saga2/hresmgr.h
index 8b3b7cc4ce..2dbfbee21a 100644
--- a/engines/saga2/hresmgr.h
+++ b/engines/saga2/hresmgr.h
@@ -61,6 +61,7 @@ namespace Saga2 {
* ===================================================================== */
typedef uint32 hResID;
+typedef Common::HashMap<int16, byte*> DataMap;
#define BAD_ID ((hResID)0xFFFFFFFFL)
#define NATURAL_SIZE ((hResID)0xFFFFFFFFL)
@@ -126,7 +127,7 @@ protected:
hResource *_res;
hResContext *_parent;
hResEntry *_base;
- RHANDLE *_data; // allocated array of handles
+ DataMap _indexData; // allocated array of handles
Common::File _file;
Common::File *_handle;
uint32 _bytecount;
@@ -166,13 +167,10 @@ public:
byte *loadIndexResource(int16 index, const char desc[], Common::String filename = "");
RHANDLE loadIndex(int16 index, const char[], bool cacheable = true);
void release(RHANDLE p);
+ void releaseIndexData();
Common::File *resFileHandle(void) {
return _handle;
}
-
- RHANDLE dataHandle(int16 index) {
- return _data[ index ];
- }
};
/* ===================================================================== *
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 74b8f1ee81..46a97f054c 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -207,33 +207,30 @@ uint16 *builtinVTableAddress(int16 btype, uint8 *addr, CallTable **callTab) {
}
uint8 *segmentAddress(uint16 segment, uint16 offset) {
- RHANDLE segHandle;
+ byte *segHandle = nullptr;
// A segment number of less than zero means that this is
// a "builtin" object, in other words the game engine itself
if ((int16)segment < 0) return builtinObjectAddress(segment, offset);
- segHandle = scriptRes->dataHandle(segment);
- if (segHandle == NULL || *segHandle == NULL) {
- segHandle = scriptRes->loadIndex(segment, "object segment");
- //RUnlockHandle(segHandle);
- }
- return ((uint8 *)(*segHandle) + offset);
+ segHandle = scriptRes->loadIndexResource(segment, "object segment");
+ if (segHandle == nullptr)
+ return nullptr;
+
+ return segHandle + offset;
}
uint8 *segmentArrayAddress(uint16 segment, uint16 index) {
- RHANDLE segHandle;
+ byte *segHandle = nullptr;
if ((int16)segment < 0) return builtinObjectAddress(segment, index);
- segHandle = scriptRes->dataHandle(segment);
- if (segHandle == NULL || *segHandle == NULL) {
- segHandle = scriptRes->loadIndex(segment, "object array segment");
- //RUnlockHandle(segHandle);
- }
+ segHandle = scriptRes->loadIndexResource(segment, "object array segment");
+ if (segHandle == nullptr)
+ return nullptr;
- return (uint8 *)(*segHandle) + sizeof(uint16)
- + (index * *(uint16 *)(*segHandle));
+ return segHandle + sizeof(uint16)
+ + (index * READ_LE_INT16(segHandle));
}
// Returns the address of a byte given an addressing mode
@@ -1754,7 +1751,7 @@ void initScripts(void) {
error("Unable to load the SAGA data segment");
dataSegSize = scriptRes->getSize(dataSegID, "saga data segment");
- debugC(2, kDebugScripts, "dataSegment loaded at 0x%08x: size: %d", dataSegment, dataSegSize);
+ debugC(2, kDebugScripts, "dataSegment loaded at %p: size: %d", (void*)dataSegment, dataSegSize);
// Common::hexdump(dataSegment, dataSegSize);
@@ -1764,8 +1761,8 @@ void initScripts(void) {
// Common::hexdump(exportSegment, scriptRes->getSize(exportSegID, "saga export segment"));
exportCount = (scriptRes->getSize(exportSegID, "saga export segment") / sizeof(uint32)) + 1;
- debugC(2, kDebugScripts, "exportSegment loaded at 0x%08x: size: %d, exportCount: %d",
- exportSegment, scriptRes->getSize(exportSegID, "saga export segment"), exportCount);
+ debugC(2, kDebugScripts, "exportSegment loaded at %p: size: %d, exportCount: %ld",
+ (void*)exportSegment, scriptRes->getSize(exportSegID, "saga export segment"), exportCount);
}
void cleanupScripts(void) {
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 40a3ae6b2c..236df86e93 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -748,7 +748,7 @@ void openImageTest() {
void testScripts() {
scriptCallFrame scf;
- runScript(1, scf);
+ runScript(3, scf);
}
//-----------------------------------------------------------------------
Commit: 238380fd5b865856f9b54762a3f1cd00b1f24ee8
https://github.com/scummvm/scummvm/commit/238380fd5b865856f9b54762a3f1cd00b1f24ee8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:51+02:00
Commit Message:
SAGA2: Cleanup gpointer.cpp
Changed paths:
engines/saga2/gpointer.cpp
diff --git a/engines/saga2/gpointer.cpp b/engines/saga2/gpointer.cpp
index a9417702cf..9a0f27bbde 100644
--- a/engines/saga2/gpointer.cpp
+++ b/engines/saga2/gpointer.cpp
@@ -24,8 +24,6 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/vdraw.h"
#include "saga2/gpointer.h"
@@ -33,26 +31,6 @@
namespace Saga2 {
-/* ======================================================================= *
- gMousePointer class
- * ======================================================================= */
-
-// The mouse pointer constructor
-
-/********* gpointer.cpp/gMousePointer::gMousePointer *****************
-*
-* NAME gMousePointer::gMousePointer
-*
-* SYNOPSIS
-*
-* FUNCTION
-*
-* INPUTS
-*
-* RESULT
-*
-**********************************************************************
-*/
gMousePointer::gMousePointer(gDisplayPort &port) {
hideCount = 0; // pointer not hidden
@@ -74,67 +52,17 @@ gMousePointer::gMousePointer(gDisplayPort &port) {
pointerImage = NULL;
}
-// The destructor
-
-/********* gpointer.cpp/gMousePointer::~gMousePointer ****************
-*
-* NAME gMousePointer::~gMousePointer
-*
-* SYNOPSIS
-*
-* FUNCTION
-*
-* INPUTS
-*
-* RESULT
-*
-**********************************************************************
-*/
gMousePointer::~gMousePointer(void) {
- // Free memory we got earlier
-
- if (saveMap.data) free(saveMap.data);
+ if (saveMap.data)
+ free(saveMap.data);
}
// Init & status check
-
-/********* gpointer.cpp/gMousePointer::~gMousePointer ****************
-*
-* NAME gMousePointer::~gMousePointer
-*
-* SYNOPSIS
-*
-* FUNCTION
-*
-* INPUTS
-*
-* RESULT
-*
-**********************************************************************
-*/
bool gMousePointer::init(Point16 pointerLimits) {
-#ifndef _WIN32
- return (errNoMouse != InitMouse(pointerLimits.x, pointerLimits.y));
-#else
return TRUE;
-#endif
}
-// Private routine to draw the mouse pointer image
-/********* gpointer.cpp/gMousePointer::draw **************************
-*
-* NAME gMousePointer::draw
-*
-* SYNOPSIS
-*
-* FUNCTION
-*
-* INPUTS
-*
-* RESULT
-*
-**********************************************************************
-*/
+// Private routine to draw the mouse pointer image
void gMousePointer::draw(void) {
#if defined( USEWINDOWS )
if (useWinCursor)
@@ -179,21 +107,6 @@ void gMousePointer::draw(void) {
}
// Private routine to restore the mouse pointer image
-
-/********* gpointer.cpp/gMousePointer::restore ***********************
-*
-* NAME gMousePointer::restore
-*
-* SYNOPSIS
-*
-* FUNCTION
-*
-* INPUTS
-*
-* RESULT
-*
-**********************************************************************
-*/
void gMousePointer::restore(void) {
#if defined( USEWINDOWS )
if (useWinCursor)
@@ -216,21 +129,6 @@ void gMousePointer::restore(void) {
}
// Makes the mouse pointer visible
-
-/********* gpointer.cpp/gMousePointer::show **************************
-*
-* NAME gMousePointer::show
-*
-* SYNOPSIS
-*
-* FUNCTION
-*
-* INPUTS
-*
-* RESULT
-*
-**********************************************************************
-*/
void gMousePointer::show(void) {
assert(hideCount > 0);
@@ -244,21 +142,6 @@ void gMousePointer::show(void) {
}
// Makes the mouse pointer invisible
-
-/********* gpointer.cpp/gMousePointer::hide **************************
-*
-* NAME gMousePointer::hide
-*
-* SYNOPSIS
-*
-* FUNCTION
-*
-* INPUTS
-*
-* RESULT
-*
-**********************************************************************
-*/
void gMousePointer::hide(void) {
if (hideCount++ == 0) {
#if defined( USEWINDOWS )
@@ -269,21 +152,6 @@ void gMousePointer::hide(void) {
}
// Makes the mouse pointer visible
-
-/********* gpointer.cpp/gMousePointer::show **************************
-*
-* NAME gMousePointer::show
-*
-* SYNOPSIS
-*
-* FUNCTION
-*
-* INPUTS
-*
-* RESULT
-*
-**********************************************************************
-*/
void gMousePointer::show(gPort &port, Rect16 r) {
Point16 org = port.getOrigin();
@@ -302,22 +170,8 @@ void gMousePointer::show(gPort &port, Rect16 r) {
if (--hideCount == 0) draw();
}
}
-// Makes the mouse pointer visible
-/********* gpointer.cpp/gMousePointer::manditoryShow **************************
-*
-* NAME gMousePointer::manditoryShow
-*
-* SYNOPSIS Forces display of mouse pointer (for error handlers & such)
-*
-* FUNCTION
-*
-* INPUTS
-*
-* RESULT
-*
-**********************************************************************
-*/
+// Makes the mouse pointer visible
int gMousePointer::manditoryShow(void) {
int rv = 0;
while (hideCount > 0) {
@@ -334,21 +188,6 @@ int gMousePointer::manditoryShow(void) {
// Makes the mouse pointer invisible
-
-/********* gpointer.cpp/gMousePointer::hide **************************
-*
-* NAME gMousePointer::hide
-*
-* SYNOPSIS
-*
-* FUNCTION
-*
-* INPUTS
-*
-* RESULT
-*
-**********************************************************************
-*/
void gMousePointer::hide(gPort &port, Rect16 r) {
Point16 org = port.getOrigin();
@@ -369,21 +208,6 @@ void gMousePointer::hide(gPort &port, Rect16 r) {
}
// Moves the mouse pointer to a new position
-
-/********* gpointer.cpp/gMousePointer::move **************************
-*
-* NAME gMousePointer::move
-*
-* SYNOPSIS
-*
-* FUNCTION
-*
-* INPUTS
-*
-* RESULT
-*
-**********************************************************************
-*/
void gMousePointer::move(Point16 pos) {
Point16 offsetPos = pos + offsetPosition;
@@ -395,21 +219,6 @@ void gMousePointer::move(Point16 pos) {
}
// Sets the mouse pointer imagery
-
-/********* gpointer.cpp/gMousePointer::setImage **********************
-*
-* NAME gMousePointer::setImage
-*
-* SYNOPSIS
-*
-* FUNCTION
-*
-* INPUTS
-*
-* RESULT
-*
-**********************************************************************
-*/
void gMousePointer::setImage(
gPixelMap &img,
int x,
Commit: 7a053bf1e3e10f36551ea72235e94e91f2630b51
https://github.com/scummvm/scummvm/commit/7a053bf1e3e10f36551ea72235e94e91f2630b51
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:52+02:00
Commit Message:
SAGA2: Remove graphics initializer
Changed paths:
engines/saga2/mainmap.cpp
engines/saga2/mainmap.h
engines/saga2/towerfta.cpp
diff --git a/engines/saga2/mainmap.cpp b/engines/saga2/mainmap.cpp
index 3639604f52..e4da371bc8 100644
--- a/engines/saga2/mainmap.cpp
+++ b/engines/saga2/mainmap.cpp
@@ -63,18 +63,6 @@ void shutdownGame() {
warning("STUB: shutdownGame");
}
-bool initGraphicsSystem() {
- warning("STUB: initGraphicsSystem()");
- return false;
-}
-void cleanupGraphicsSystem() {
- warning("STUB: cleanupGraphicsSystem()");
-}
-
-void cleanupGraphics() {
- warning("STUB: cleanupGraphics()");
-}
-
bool initSystemTimer() {
warning("STUB: initSystemTimer()");
return false;
diff --git a/engines/saga2/mainmap.h b/engines/saga2/mainmap.h
index b71935eaad..6d717f5358 100644
--- a/engines/saga2/mainmap.h
+++ b/engines/saga2/mainmap.h
@@ -90,11 +90,6 @@ void cleanupErrorHandlers(void);
bool initializeGame(void);
void shutdownGame(void);
-bool initGraphicsSystem(void);
-void cleanupGraphicsSystem(void);
-
-void cleanupGraphics(void);
-
bool initSystemTimer(void);
void cleanupSystemTimer(void);
diff --git a/engines/saga2/towerfta.cpp b/engines/saga2/towerfta.cpp
index ac1e745fbe..0d131a0181 100644
--- a/engines/saga2/towerfta.cpp
+++ b/engines/saga2/towerfta.cpp
@@ -67,7 +67,6 @@ TowerLayer tower[fullyInitialized] = {
{ breakHandlerInitialized, &initCtlBreakTrap, &termCtlBreakTrap },
{ configTestInitialized, &initSystemConfig, &termTowerBase },
{ memoryInitialized, &initMemPool, &termMemPool },
- { graphicsSystemInitialized, &initGraphicsSystem, &termGraphicsSystem },
{ videoInitialized, &initVideoPlayer, &termVideoPlayer },
{ introInitialized, &initPlayIntro, &termPlayOutro },
{ timerInitialized, &initSystemTimer, &termSystemTimer },
@@ -176,15 +175,6 @@ TERMINATOR(termMemPool) {
}
-// ------------------------------------------------------------------------
-
-extern INITIALIZER(initGraphicsSystem);
-
-TERMINATOR(termGraphicsSystem) {
- cleanupGraphicsSystem();
-}
-
-
// ------------------------------------------------------------------------
INITIALIZER(initVideoPlayer) {
Commit: a02aaadc732e42eb5b5e52c0280757df0b1334ca
https://github.com/scummvm/scummvm/commit/a02aaadc732e42eb5b5e52c0280757df0b1334ca
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:52+02:00
Commit Message:
SAGA2: Started cleanup for the video classes
Changed paths:
engines/saga2/itevideo.cpp
engines/saga2/itevideo.h
diff --git a/engines/saga2/itevideo.cpp b/engines/saga2/itevideo.cpp
index 2db3e0488e..4439b4e3a4 100644
--- a/engines/saga2/itevideo.cpp
+++ b/engines/saga2/itevideo.cpp
@@ -41,8 +41,6 @@
namespace Saga2 {
-uint32 performanceBufferSize = 512 * 1024;
-
#define VIDEO_EXT ".SMK"
/* ===================================================================== *
@@ -98,11 +96,7 @@ void startVideo(char *fileName, int x, int y, bool erase, int16, int16) {
strncpy(file, fileName, 260);
nameCheck(file, VIDEO_EXT);
- vp->StartPlay(file, x, y,
-#if USE_SMK
- performanceBufferSize, TRUE,
-#endif
- VideoSMK, erase);
+ vp->StartPlay(file, x, y,VideoSMK, erase);
}
//-----------------------------------------------------------------------
@@ -396,25 +390,4 @@ void setPaletteHook(
#endif
}
-
-bool InVideo(void) {
-#if USE_SMK && defined(_WIN32)
- if (NULL != vp->getSmack())
- return TRUE;
-#endif
- return FALSE;
-}
-
-#ifdef _WIN32
-
-LRESULT VideoOnPaletteChanged(HWND win_handle, WORD wparam, LONG lparam) {
- return vp->OnPaletteChanged(win_handle, wparam, lparam);
-}
-
-LRESULT VideoOnQueryNewPalette(HWND win_handle, WORD wparam, LONG lparam) {
- return vp->OnQueryNewPalette(win_handle, wparam, lparam);
-}
-
-#endif
-
} // end of namespace Saga2
diff --git a/engines/saga2/itevideo.h b/engines/saga2/itevideo.h
index 1364979386..e2e1723d82 100644
--- a/engines/saga2/itevideo.h
+++ b/engines/saga2/itevideo.h
@@ -42,14 +42,6 @@ void startVideo(char *fileName, int x, int y, bool erase = TRUE, int16 from = 0,
bool checkVideo(void);
void endVideo(void);
-//-----------------------------------------------------------------------
-// Windows hooks for smacker
-
-#ifdef _WIN32
-LRESULT VideoOnPaletteChanged(HWND win_handle, WORD wparam, LONG lparam);
-LRESULT VideoOnQueryNewPalette(HWND win_handle, WORD wparam, LONG lparam);
-#endif
-
//-----------------------------------------------------------------------
// Player configuration & other obsolete calls
@@ -59,8 +51,6 @@ void drawVideoMousePointer(Rect16 showZone, char *buffer, int bufferWidth);
void playVideo(char *fileName, int x, int y); //, int16 from=0, int16 to=0 );
bool abortVideo(void);
-bool InVideo(void);
-
} // end of namespace Saga2
#endif
Commit: a6f50cc6e00722b080e0310c910d7b3602259af9
https://github.com/scummvm/scummvm/commit/a6f50cc6e00722b080e0310c910d7b3602259af9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:52+02:00
Commit Message:
SAGA2: Skip videoplayer initialization
Changed paths:
engines/saga2/towerfta.cpp
engines/saga2/towerfta.h
diff --git a/engines/saga2/towerfta.cpp b/engines/saga2/towerfta.cpp
index 0d131a0181..60b01b5d1b 100644
--- a/engines/saga2/towerfta.cpp
+++ b/engines/saga2/towerfta.cpp
@@ -33,7 +33,6 @@
#include "saga2/fta.h"
#include "saga2/mainmap.h"
#include "saga2/config.h"
-#include "saga2/itevideo.h"
#include "saga2/tromode.h"
#include "saga2/audio.h"
#include "saga2/annoy.h"
@@ -67,7 +66,6 @@ TowerLayer tower[fullyInitialized] = {
{ breakHandlerInitialized, &initCtlBreakTrap, &termCtlBreakTrap },
{ configTestInitialized, &initSystemConfig, &termTowerBase },
{ memoryInitialized, &initMemPool, &termMemPool },
- { videoInitialized, &initVideoPlayer, &termVideoPlayer },
{ introInitialized, &initPlayIntro, &termPlayOutro },
{ timerInitialized, &initSystemTimer, &termSystemTimer },
{ resourcesInitialized, &initResourceFiles, &termResourceFiles },
@@ -175,18 +173,6 @@ TERMINATOR(termMemPool) {
}
-// ------------------------------------------------------------------------
-
-INITIALIZER(initVideoPlayer) {
- initVideo();
- return TRUE;
-}
-
-TERMINATOR(termVideoPlayer) {
- cleanupVideo();
-}
-
-
// ------------------------------------------------------------------------
INITIALIZER(initPlayIntro) {
diff --git a/engines/saga2/towerfta.h b/engines/saga2/towerfta.h
index c0994a4af4..0d25d9b4ab 100644
--- a/engines/saga2/towerfta.h
+++ b/engines/saga2/towerfta.h
@@ -46,9 +46,6 @@ TERMINATOR(termMemPool);
INITIALIZER(initGraphicsSystem);
TERMINATOR(termGraphicsSystem);
-INITIALIZER(initVideoPlayer);
-TERMINATOR(termVideoPlayer);
-
INITIALIZER(initPlayIntro);
TERMINATOR(termPlayOutro);
Commit: ccc04196bc9f915a6e5f7e64009339dd7b931929
https://github.com/scummvm/scummvm/commit/ccc04196bc9f915a6e5f7e64009339dd7b931929
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:52+02:00
Commit Message:
SAGA2: Allow looping through the scripts
Changed paths:
engines/saga2/hresmgr.cpp
engines/saga2/interp.cpp
engines/saga2/main.cpp
engines/saga2/script.h
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index 394a67f4c0..bcb557fd54 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -351,6 +351,8 @@ byte *hResContext::loadIndexResource(int16 index, const char desc[], Common::Str
hResEntry *entry;
entry = &_base[index];
+ debugC(5, kDebugResources, "Loading indexed resource: %d (%s)", index, desc);
+
if (!_valid || entry == nullptr)
return nullptr;
@@ -359,11 +361,14 @@ byte *hResContext::loadIndexResource(int16 index, const char desc[], Common::Str
byte *res = (byte*)malloc(entry->size);
- if (res) {
- debugC(4, kDebugResources, "_indexData: pushing (%d, %p)", index, (void*)res);
- _indexData.setVal(index, res);
+ if (res == nullptr) {
+ debugC(5, kDebugResources, "Could not allocate resources");
+ return nullptr;
}
+ debugC(5, kDebugResources, "_indexData: pushing (%d, %p)", index, (void*)res);
+ _indexData.setVal(index, res);
+
if (filename.equalsIgnoreCase(""))
filename = _filename;
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 46a97f054c..2244dbe79f 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -453,14 +453,15 @@ uint8 *bitAddress(Thread *th, uint8 **pcPtr, int16 *mask) {
// Returns the address of a string
uint8 *Thread::strAddress(int strNum) {
- uint16 *codeBase = (uint16 *)codeSeg;
- uint8 *strSeg = segmentAddress(codeBase[ 1 ], codeBase[ 2 ]);
+ uint16 seg = READ_LE_INT16(codeSeg + 2);
+ uint16 offset = READ_LE_INT16(codeSeg + 4);
+ uint8 *strSeg = segmentAddress(seg, offset);
assert(strNum >= 0);
- assert(codeBase);
+ assert(codeSeg);
assert(strSeg);
- return strSeg + ((uint16 *)strSeg)[ strNum ];
+ return strSeg + READ_LE_INT16(strSeg + 2 * strNum);
}
//-----------------------------------------------------------------------
@@ -516,9 +517,9 @@ void print_script_name(uint8 *codePtr, char *descr = NULL) {
scriptName[ length ] = '\0';
if (descr)
- debugC(1, kDebugScripts, "Scripts: op_enter: [%s].%s ", descr, scriptName);
+ debugC(1, kDebugScripts, "Scripts: %d op_enter: [%s].%s ", lastExport, descr, scriptName);
else
- debugC(1, kDebugScripts, "Scripts: op_enter: ::%s ", scriptName);
+ debugC(1, kDebugScripts, "Scripts: %d op_enter: ::%s ", lastExport, scriptName);
}
char *objectName(int16 segNum, uint16 segOff) {
@@ -1500,9 +1501,12 @@ Thread::Thread(uint16 segNum, uint16 segOff, scriptCallFrame &args) {
((uint16 *)stackPtr)[ 1 ] = 0; // dummy return address
((uint16 *)stackPtr)[ 2 ] = 0; // dummy return address
framePtr = stackSize;
+ _valid = true;
- if ((codeSeg)[ programCounter.offset ] != op_enter)
- error("SAGA failure: Invalid script entry point (export=%d) [segment=%d:%d]\n", lastExport, segNum, segOff);
+ if ((codeSeg)[ programCounter.offset ] != op_enter) {
+ //warning("SAGA failure: Invalid script entry point (export=%d) [segment=%d:%d]\n", lastExport, segNum, segOff);
+ _valid = false;
+ }
// assert ((codeSeg)[ programCounter.offset ] == op_enter);
}
@@ -1846,6 +1850,14 @@ scriptResult runScript(uint16 exportEntryNum, scriptCallFrame &args) {
// Create a new thread
th = new Thread(segNum, segOff, args);
thisThread = th;
+ // FIXME: We should probably just use an error(), but this will work for mass debugging
+ if (th == nullptr) {
+ debugC(4, kDebugScripts, "Couldn't allocate memory for Thread(%d, %d)", segNum, segOff);
+ return scriptResultNoScript;
+ } else if (!th->_valid) {
+ debugC(4, kDebugScripts, "Scripts: %d is not valid", lastExport);
+ return scriptResultNoScript;
+ }
print_script_name((th->codeSeg) + th->programCounter.offset, objectName(segNum, segOff));
// Run the thread to completion
@@ -1909,6 +1921,10 @@ scriptResult runMethod(
// Build a temporary dummy thread
th = new Thread(0, 0, args);
thisThread = th;
+ if (th == nullptr)
+ return scriptResultNoScript;
+ else if (!th->_valid)
+ return scriptResultNoScript;
result = (scriptResult)cfunc(stack); // call the function
delete th;
@@ -1917,6 +1933,13 @@ scriptResult runMethod(
// Create a new thread
th = new Thread(segNum, segOff, args);
thisThread = th;
+ if (th == nullptr) {
+ debugC(4, kDebugScripts, "Couldn't allocate memory for Thread(%d, %d)", segNum, segOff);
+ return scriptResultNoScript;
+ } else if (!th->_valid) {
+ debugC(4, kDebugScripts, "Scripts: %d is not valid", lastExport);
+ return scriptResultNoScript;
+ }
print_script_name((th->codeSeg) + th->programCounter.offset, objectName(bType, index));
// Put the object segment and ID onto the dummy stack frame
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 236df86e93..b4ae6209f2 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -748,7 +748,8 @@ void openImageTest() {
void testScripts() {
scriptCallFrame scf;
- runScript(3, scf);
+ for (int i = 1; i < 500; ++i)
+ runScript(i, scf);
}
//-----------------------------------------------------------------------
diff --git a/engines/saga2/script.h b/engines/saga2/script.h
index 94ac242635..6224e53fc4 100644
--- a/engines/saga2/script.h
+++ b/engines/saga2/script.h
@@ -222,6 +222,8 @@ public:
framePtr, // pointer to call frame
returnVal; // return value from ccalls
+ bool _valid;
+
// Various signals that a script can wait upon
enum WaitTypes {
waitNone = 0, // waiting for nothing
Commit: 2b9663ded4dcc18fb4f3add5806ee1bf5d0c85e7
https://github.com/scummvm/scummvm/commit/2b9663ded4dcc18fb4f3add5806ee1bf5d0c85e7
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:52+02:00
Commit Message:
SAGA2: Organize debug messages
Changed paths:
engines/saga2/hresmgr.cpp
engines/saga2/hresmgr.h
engines/saga2/main.cpp
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index bcb557fd54..2b564b4076 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -110,15 +110,15 @@ hResEntry *hResContext::findEntry(hResID id, RHANDLE **capture) {
_bytepos = 0;
if (!_valid) return nullptr;
- debugC(2, kDebugResources, "findEntry: looking for %x (%s)", id, tag2str(id));
+ debugC(3, kDebugResources, "findEntry: looking for %x (%s)", id, tag2str(id));
for (i = 0, entry = _base; i < _numEntries; i++, entry++) {
- debugC(2, kDebugResources, "%d: Trying ID: %x (%s)", i, entry->id, tag2str(entry->id));
+ debugC(3, kDebugResources, "%d: Trying ID: %x (%s)", i, entry->id, tag2str(entry->id));
if (entry->id == id) {
- debugC(2, kDebugResources, "findEntry: found %x (%s)", entry->id, tag2str(entry->id));
+ debugC(3, kDebugResources, "findEntry: found %x (%s)", entry->id, tag2str(entry->id));
return entry;
}
}
- debugC(2, kDebugResources, "findEntry: No entry found");
+ debugC(3, kDebugResources, "findEntry: No entry found");
return nullptr;
}
@@ -454,6 +454,15 @@ void hResContext::releaseIndexData() {
Resource file
* ===================================================================== */
+void hResource::readEntry(hResEntry &element) {
+ element.id = _file.readUint32BE();
+ element.offset = _file.readUint32LE();
+ element.size = _file.readUint32LE();
+ uint32 id = element.id;
+
+ debugC(2, kDebugResources, "%s, offset: %x, size: %d", tag2str(id), element.offset, element.size);
+}
+
void hResource::readResource(hResEntry &element) {
element.id = _file.readUint32BE();
element.offset = _file.readUint32LE();
@@ -499,11 +508,11 @@ hResource::hResource(char *resname, char *extname, const char desc[]) {
return;
- debugC(kDebugResources, "Reading %d categories:", _numEntries);
+ debugC(1, kDebugResources, "Reading %d entries:", _numEntries);
for (int i = 0; i < _numEntries; ++i)
- readResource(_base[i]);
+ readEntry(_base[i]);
- debugC(kDebugResources, "Reading %d groups:", tableSize / resourceSize);
+ debugC(1, kDebugResources, "Reading %d groups:", tableSize / resourceSize);
_file.seek(_firstGroupOffset, SEEK_SET);
for (int i = 0; i < tableSize / resourceSize; ++i) {
readResource(_table[i]);
diff --git a/engines/saga2/hresmgr.h b/engines/saga2/hresmgr.h
index 2dbfbee21a..4f6d6f19a7 100644
--- a/engines/saga2/hresmgr.h
+++ b/engines/saga2/hresmgr.h
@@ -191,6 +191,7 @@ public:
hResContext *newContext(hResID id, const char []);
void disposeContext(hResContext *con);
+ void readEntry(hResEntry &element);
void readResource(hResEntry &element);
};
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index b4ae6209f2..e8e5541321 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -748,8 +748,9 @@ void openImageTest() {
void testScripts() {
scriptCallFrame scf;
- for (int i = 1; i < 500; ++i)
- runScript(i, scf);
+ //for (int i = 1; i < 100; ++i)
+ // runScript(i, scf);
+ runScript(1, scf);
}
//-----------------------------------------------------------------------
Commit: 08b6aca44ba1a2796e37f3f75fac3ecbc2517bf0
https://github.com/scummvm/scummvm/commit/08b6aca44ba1a2796e37f3f75fac3ecbc2517bf0
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:52+02:00
Commit Message:
SAGA2: Fix tile initialization
Changed paths:
engines/saga2/tile.cpp
engines/saga2/tileload.cpp
engines/saga2/tilemode.cpp
engines/saga2/towerfta.cpp
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index d53cde1a81..3056f2c999 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -55,16 +55,16 @@ extern void writeLog(char *str);
Constants
* ===================================================================== */
-const uint32 tileTerrainID = RES_ID('T', 'E', 'R', 0),
- tileImageID = RES_ID('T', 'I', 'L', 0),
- platformID = RES_ID('P', 'L', 'T', 0),
- metaID = RES_ID('M', 'E', 'T', 0),
- mapID = RES_ID('M', 'A', 'P', 0),
- tagID = RES_ID('T', 'A', 'G', 0),
- tagDataID = RES_ID('T', 'G', 'D', 0),
- tagStateID = RES_ID('T', 'S', 'T', 0),
- assocID = RES_ID('A', 'S', 'C', 0),
- cycleID = RES_ID('C', 'Y', 'C', 'L');
+const uint32 tileTerrainID = MKTAG('T', 'E', 'R', 0),
+ tileImageID = MKTAG('T', 'I', 'L', 0),
+ platformID = MKTAG('P', 'L', 'T', 0),
+ metaID = MKTAG('M', 'E', 'T', 0),
+ mapID = MKTAG('M', 'A', 'P', 0),
+ tagID = MKTAG('T', 'A', 'G', 0),
+ tagDataID = MKTAG('T', 'G', 'D', 0),
+ tagStateID = MKTAG('T', 'S', 'T', 0),
+ assocID = MKTAG('A', 'S', 'C', 0),
+ cycleID = MKTAG('C', 'Y', 'C', 'L');
// Scrolling Speed constants
@@ -99,7 +99,7 @@ void setAreaSound(const TilePoint &baseCoords);
* ===================================================================== */
TileBankPtr tileBanks[ maxBanks ];
-extern LoadOnCall<UByteHandle> tileImageBanks;
+extern byte* tileImageBanks[];
void tileFault(int bank, int num);
void updateHandleRefs(const TilePoint &pt); //, StandingTileInfo *stiResult )
@@ -320,7 +320,7 @@ TileInfo *TileInfo::tileAddress(TileID id, uint8 **imageData) {
}
if (ti != NULL) {
- if ((tibh = tileImageBanks[ tileBank ]) != NULL)
+ if ((tibh = tileImageBanks[tileBank]) != NULL)
* imageData = &(*tibh)[ ti->offset ];
else
*imageData = NULL;
@@ -476,7 +476,7 @@ bool ActiveItem::inRange(const TilePoint &loc, int16 range) {
// TAG noise player
void ActiveItem::playTAGNoise(ActiveItem *ai, int16 tagNoiseID) {
- playSoundAt(RES_ID('T', 'A', 'G', tagNoiseID), ai->getInstanceLocation());
+ playSoundAt(MKTAG('T', 'A', 'G', tagNoiseID), ai->getInstanceLocation());
}
//-----------------------------------------------------------------------
@@ -816,7 +816,7 @@ void initActiveItemStates(void) {
for (i = 0; i < worldCount; i++) {
stateArray[ i ] = (UByteHandle)LoadResourceToHandle(
tileRes,
- tagStateID + RES_ID(0, 0, 0, uint8(i)),
+ tagStateID + MKTAG(0, 0, 0, uint8(i)),
"active item state array");
if (stateArray[ i ] == NULL)
@@ -1426,11 +1426,11 @@ void initMaps(void) {
// Load all of the tile terrain banks
for (i = 0; i < maxBanks; i++) {
- if (tileRes->seek(tileTerrainID + RES_ID(0, 0, 0, (uint8)i))) {
+ if (tileRes->seek(tileTerrainID + MKTAG(0, 0, 0, (uint8)i))) {
tileBanks[ i ] =
(TileBankPtr)LoadResource(
tileRes,
- tileTerrainID + RES_ID(0, 0, 0, (uint8)i),
+ tileTerrainID + MKTAG(0, 0, 0, (uint8)i),
"tile terrain bank");
} else
tileBanks[ i ] = NULL;
@@ -1438,7 +1438,7 @@ void initMaps(void) {
// Count the worlds by seeking the map data
for (worldCount = 0;
- tileRes->seek(mapID + RES_ID(0, 0, 0, (uint8)worldCount));
+ tileRes->seek(mapID + MKTAG(0, 0, 0, (uint8)worldCount));
worldCount++) ;
// Allocate the map data array
@@ -1460,7 +1460,7 @@ void initMaps(void) {
// Load the map
mapData->map = (MapHandle)LoadResourceToHandle(
tileRes,
- mapID + RES_ID(0, 0, 0, (uint8)i),
+ mapID + MKTAG(0, 0, 0, (uint8)i),
"world map");
if (mapData->map == NULL)
error("Unable to load map");
@@ -1468,17 +1468,17 @@ void initMaps(void) {
// Load the meta tile list
mapData->metaList = (MetaTileHandle)LoadResourceToHandle(
tileRes,
- metaID + RES_ID(0, 0, 0, (uint8)i),
+ metaID + MKTAG(0, 0, 0, (uint8)i),
"meta tile list");
if (mapData->metaList == NULL)
error("Unable to load meta tile list");
// If there is tag data, load it
- if (tileRes->size(tagDataID + RES_ID(0, 0, 0, (uint8)i)) > 0) {
+ if (tileRes->size(tagDataID + MKTAG(0, 0, 0, (uint8)i)) > 0) {
mapData->activeItemData =
(TileRefHandle)LoadResourceToHandle(
tileRes,
- tagDataID + RES_ID(0, 0, 0, (uint8)i),
+ tagDataID + MKTAG(0, 0, 0, (uint8)i),
"active item data");
if (mapData->activeItemData == NULL)
error("Unable to load active item data");
@@ -1486,11 +1486,11 @@ void initMaps(void) {
mapData->activeItemData = NULL;
// If there is an association list, load it
- if (tileRes->size(assocID + RES_ID(0, 0, 0, (uint8)i)) > 0) {
+ if (tileRes->size(assocID + MKTAG(0, 0, 0, (uint8)i)) > 0) {
mapData->assocList =
(UWordHandle)LoadResourceToHandle(
tileRes,
- assocID + RES_ID(0, 0, 0, (uint8)i),
+ assocID + MKTAG(0, 0, 0, (uint8)i),
"association list");
if (mapData->assocList == NULL)
error("Unable to load association list");
@@ -1498,11 +1498,11 @@ void initMaps(void) {
mapData->assocList = NULL;
// If there is an active item list, load it
- if (tileRes->size(tagID + RES_ID(0, 0, 0, (uint8)i)) > 0) {
+ if (tileRes->size(tagID + MKTAG(0, 0, 0, (uint8)i)) > 0) {
mapData->activeItemList =
(ActiveItemPtr)LoadResource(
tileRes,
- tagID + RES_ID(0, 0, 0, (uint8)i),
+ tagID + MKTAG(0, 0, 0, (uint8)i),
"active item list");
if (mapData->activeItemList == NULL)
error("Unable to load active item list");
@@ -2275,10 +2275,10 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
stack[ layer ] = (cacheFlag | cacheIndex);
assert(plIndex >= 0);
- assert(plIndex * sizeof(Platform) < tileRes->size(platformID + RES_ID(0, 0, 0, mapNum)));
+ assert(plIndex * sizeof(Platform) < tileRes->size(platformID + MKTAG(0, 0, 0, mapNum)));
// Now, load the actual metatile data...
- if (tileRes->seek(platformID + RES_ID(0, 0, 0, mapNum))) {
+ if (tileRes->seek(platformID + MKTAG(0, 0, 0, mapNum))) {
if (tileRes->skip(plIndex * sizeof(Platform))) {
if (tileRes->read(&pce->pl, sizeof(Platform)));
{
diff --git a/engines/saga2/tileload.cpp b/engines/saga2/tileload.cpp
index 04735ac7a6..3f7871591f 100644
--- a/engines/saga2/tileload.cpp
+++ b/engines/saga2/tileload.cpp
@@ -39,7 +39,7 @@ namespace Saga2 {
const uint16 tileBankCount = 25;
-const uint32 tileImageID = RES_ID('T', 'I', 'L', 0);
+const uint32 tileImageID = MKTAG('T', 'I', 'L', 0);
/* ===================================================================== *
Prototypes
@@ -60,6 +60,8 @@ extern gPixelMap tileDrawMap;
extern int16 currentMapNum;
+extern hResource *objResFile;
+
/* ===================================================================== *
Tile structure management
* ===================================================================== */
@@ -77,11 +79,11 @@ void sprintBA(char buf[], BitArray *x);
* ===================================================================== */
-static RHANDLE tileResLoad(hResID i, bool asynch = FALSE) {
+static void *tileResLoad(hResID i, bool asynch = FALSE) {
if (tileRes)
- return tileRes->load(i, "tile image bank", asynch);
+ return tileRes->loadResource(i, "tile image bank", objResFile->_filename);
else
- return NULL;;
+ return nullptr;
}
diff --git a/engines/saga2/tilemode.cpp b/engines/saga2/tilemode.cpp
index 106632a140..4b3ea1da6c 100644
--- a/engines/saga2/tilemode.cpp
+++ b/engines/saga2/tilemode.cpp
@@ -96,9 +96,9 @@ private:
extern int16 speechButtonCount; // count of speech buttons
extern void abortSpeech(void);
-const uint32 tileGroupID = RES_ID('T', 'I', 'L', 'E');
+const uint32 tileGroupID = MKTAG('T', 'I', 'L', 'E');
-extern const uint32 imageGroupID = RES_ID('I', 'M', 'A', 'G');
+extern const uint32 imageGroupID = MKTAG('I', 'M', 'A', 'G');
extern hResContext *tileRes; // tile resource handle
extern CycleHandle cycleList; // list of tile cycling info
diff --git a/engines/saga2/towerfta.cpp b/engines/saga2/towerfta.cpp
index 60b01b5d1b..e1ac4cbdbc 100644
--- a/engines/saga2/towerfta.cpp
+++ b/engines/saga2/towerfta.cpp
@@ -255,27 +255,27 @@ TERMINATOR(termAudioChannels) {
// ------------------------------------------------------------------------
INITIALIZER(initResourceHandles) {
- tileRes = resFile->newContext(RES_ID('T', 'I', 'L', 'E'), "tile resources");
+ tileRes = resFile->newContext(MKTAG('T', 'I', 'L', 'E'), "tile resources");
if (!tileRes->_valid)
- return FALSE;
- listRes = objResFile->newContext(RES_ID('L', 'I', 'S', 'T'), "list resources");
+ return false;
+ listRes = objResFile->newContext(MKTAG('L', 'I', 'S', 'T'), "list resources");
if (!listRes->_valid)
- return FALSE;
- resImports = (ResImportTable *)LoadResource(listRes, RES_ID('I', 'M', 'P', 'O'), "res imports");
+ return false;
+ resImports = (ResImportTable *)LoadResource(listRes, MKTAG('I', 'M', 'P', 'O'), "res imports");
if (!resImports)
- return FALSE;
- return TRUE;
+ return false;
+ return true;
}
TERMINATOR(termResourceHandles) {
if (resImports) {
- RDisposePtr(resImports);
- resImports = NULL;
+ free(resImports);
+ resImports = nullptr;
}
if (listRes) objResFile->disposeContext(listRes);
- listRes = NULL;
+ listRes = nullptr;
if (tileRes) resFile->disposeContext(tileRes);
- tileRes = NULL;
+ tileRes = nullptr;
}
Commit: e64f3079bb279fa145d44ba8f523536c479ca225
https://github.com/scummvm/scummvm/commit/e64f3079bb279fa145d44ba8f523536c479ca225
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:52+02:00
Commit Message:
SAGA2: Fix compilation
Changed paths:
engines/saga2/oncall.h
engines/saga2/tile.cpp
engines/saga2/tileload.cpp
diff --git a/engines/saga2/oncall.h b/engines/saga2/oncall.h
index 9d6370d94c..9feddcecd3 100644
--- a/engines/saga2/oncall.h
+++ b/engines/saga2/oncall.h
@@ -35,6 +35,34 @@ namespace Saga2 {
#define isValidPtr(p) ((p!=NULL)&&(p!=(void *)0xCDCDCDCD))
+class HandleArray {
+private:
+ Common::Array<byte*> _handles;
+ uint32 _tileID;
+ byte*(*_loader)(hResID, bool);
+public:
+ HandleArray(uint16 size, byte*(*loadfunction)(hResID, bool), uint32 newID) {
+ _handles.resize(size);
+ _loader = loadfunction;
+ _tileID = newID;
+ }
+
+ void flush() {
+ for (int i = 0; i < _handles.size(); ++i) {
+ if (_handles[i]) {
+ free(_handles[i]);
+ _handles[i] = nullptr;
+ }
+ }
+ }
+
+ byte *operator[](uint32 ind) {
+ if (_handles[ind])
+ return _handles[ind];
+
+ return _handles[ind] = _loader(_tileID + MKTAG(0, 0, 0, ind), false);
+ }
+};
template <class RESTYPE> class LoadOnCall {
BitArray wanted;
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 3056f2c999..c55e1d93e9 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -298,7 +298,7 @@ TileInfo *TileInfo::tileAddress(TileID id) {
TileInfo *TileInfo::tileAddress(TileID id, uint8 **imageData) {
TileInfo *ti;
TileBankPtr tbh;
- UByteHandle tibh;
+ byte *tibh;
int16 tileBank,
tileNum;
@@ -311,17 +311,17 @@ TileInfo *TileInfo::tileAddress(TileID id, uint8 **imageData) {
if (ti->attrs.cycleRange > 0) {
TileCycleData &tcd = (*cycleList)[ ti->attrs.cycleRange - 1 ];
- TileID2Bank(tcd.cycleList[ tcd.currentState ],
+ TileID2Bank(tcd.cycleList[tcd.currentState],
tileBank,
tileNum);
- if ((tbh = tileBanks[ tileBank ]) == NULL) return NULL;
+ if ((tbh = tileBanks[tileBank]) == NULL) return NULL;
ti = tbh->tile(tileNum);
}
if (ti != NULL) {
if ((tibh = tileImageBanks[tileBank]) != NULL)
- * imageData = &(*tibh)[ ti->offset ];
+ *imageData = &tibh[ti->offset];
else
*imageData = NULL;
} else
diff --git a/engines/saga2/tileload.cpp b/engines/saga2/tileload.cpp
index 3f7871591f..a104ed1b09 100644
--- a/engines/saga2/tileload.cpp
+++ b/engines/saga2/tileload.cpp
@@ -79,7 +79,7 @@ void sprintBA(char buf[], BitArray *x);
* ===================================================================== */
-static void *tileResLoad(hResID i, bool asynch = FALSE) {
+static byte *tileResLoad(hResID i, bool asynch = FALSE) {
if (tileRes)
return tileRes->loadResource(i, "tile image bank", objResFile->_filename);
else
@@ -87,7 +87,8 @@ static void *tileResLoad(hResID i, bool asynch = FALSE) {
}
-LoadOnCall<UByteHandle> tileImageBanks(64, tileResLoad, tileImageID);
+//LoadOnCall<UByteHandle> tileImageBanks(64, tileResLoad, tileImageID);
+HandleArray tileImageBanks(64, tileResLoad, tileImageID);
/* ===================================================================== *
Debugging displays
@@ -116,7 +117,7 @@ void sprintBA(char buf[], BitArray *x) {
* ===================================================================== */
void initTileBank(int16 bankNum) {
- UByteHandle th;
+ byte *th;
th = tileImageBanks[bankNum];
}
Commit: 4d2202da090d7cf03eb22178428af07026731d8a
https://github.com/scummvm/scummvm/commit/4d2202da090d7cf03eb22178428af07026731d8a
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:52+02:00
Commit Message:
SAGA2: Fix filename in resource functions
Changed paths:
engines/saga2/hresmgr.cpp
engines/saga2/hresmgr.h
engines/saga2/interp.cpp
engines/saga2/main.cpp
engines/saga2/saga2.cpp
engines/saga2/tileload.cpp
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index 2b564b4076..f1f65d4948 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -537,6 +537,7 @@ hResContext *hResource::newContext(hResID id, const char desc[]) {
if (result == nullptr || !result->_valid) {
error("Error accessing resource group.");
}
+ result->_filename = _filename;
return result;
}
diff --git a/engines/saga2/hresmgr.h b/engines/saga2/hresmgr.h
index 4f6d6f19a7..91041b1785 100644
--- a/engines/saga2/hresmgr.h
+++ b/engines/saga2/hresmgr.h
@@ -163,7 +163,7 @@ public:
bool get(hResID id, void *buffer, uint32 size);
uint32 getSize(hResID id, const char desc[]);
RHANDLE load(hResID id, const char [], bool async = false, bool cacheable = true);
- byte *loadResource(hResID id, const char desc[], Common::String filename);
+ byte *loadResource(hResID id, const char desc[], Common::String filename = "");
byte *loadIndexResource(int16 index, const char desc[], Common::String filename = "");
RHANDLE loadIndex(int16 index, const char[], bool cacheable = true);
void release(RHANDLE p);
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 2244dbe79f..bc082e2f7c 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -1749,7 +1749,7 @@ void initScripts(void) {
error("Unable to open script resource file!\n");
// Load the data segment
- dataSegment = scriptRes->loadResource(dataSegID, "saga data segment", scriptResFile->_filename);
+ dataSegment = scriptRes->loadResource(dataSegID, "saga data segment");
if (dataSegment == NULL)
error("Unable to load the SAGA data segment");
@@ -1759,7 +1759,7 @@ void initScripts(void) {
// Common::hexdump(dataSegment, dataSegSize);
- exportSegment = scriptRes->loadResource(exportSegID, "saga export segment", scriptResFile->_filename);
+ exportSegment = scriptRes->loadResource(exportSegID, "saga export segment");
assert(exportSegment != NULL);
// Common::hexdump(exportSegment, scriptRes->getSize(exportSegID, "saga export segment"));
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index e8e5541321..ee67a11fc1 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -731,7 +731,7 @@ bool openResources(void) {
}
-void openImageTest() {
+void testOpenImage() {
hResContext *decRes;
decRes = resFile->newContext(MKTAG('A', 'M', 'A', 'P'), "Automap Resources");
@@ -753,6 +753,10 @@ void testScripts() {
runScript(1, scf);
}
+void testTileRendering() {
+
+}
+
//-----------------------------------------------------------------------
// Routine to cleanup all the resource files
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index 59cc713692..215dd52dd7 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -41,9 +41,10 @@
namespace Saga2 {
+void testTileRendering();
void testScripts();
void initScripts();
-void openImageTest();
+void testOpenImage();
bool openResources();
void main_saga2();
@@ -87,9 +88,10 @@ Common::Error Saga2Engine::run() {
loadingScreen();
if (openResources()) {
- openImageTest();
+ testOpenImage();
initScripts();
testScripts();
+ testTileRendering();
}
// Simple main event loop
diff --git a/engines/saga2/tileload.cpp b/engines/saga2/tileload.cpp
index a104ed1b09..b38f704447 100644
--- a/engines/saga2/tileload.cpp
+++ b/engines/saga2/tileload.cpp
@@ -81,7 +81,7 @@ void sprintBA(char buf[], BitArray *x);
static byte *tileResLoad(hResID i, bool asynch = FALSE) {
if (tileRes)
- return tileRes->loadResource(i, "tile image bank", objResFile->_filename);
+ return tileRes->loadResource(i, "tile image bank");
else
return nullptr;
}
Commit: 5d8c85234fc65f68c0fd8971294d557f4bca6f3b
https://github.com/scummvm/scummvm/commit/5d8c85234fc65f68c0fd8971294d557f4bca6f3b
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:53+02:00
Commit Message:
SAGA2: Cleanup some of initMaps()
Changed paths:
engines/saga2/automap.cpp
engines/saga2/mapfeatr.cpp
engines/saga2/tile.cpp
engines/saga2/tile.h
diff --git a/engines/saga2/automap.cpp b/engines/saga2/automap.cpp
index f930f9ba99..c3c26c7d6d 100644
--- a/engines/saga2/automap.cpp
+++ b/engines/saga2/automap.cpp
@@ -426,7 +426,7 @@ void CAutoMap::createSmallMap(void) {
gPort &port = window.windowPort;
WorldMapData *wMap = &mapList[ currentWorld->mapNum ];
- uint16 *mapData = (*wMap->map)->mapData;
+ uint16 *mapData = wMap->map->mapData;
uint16 *mapRow;
// Info about region being drawn
diff --git a/engines/saga2/mapfeatr.cpp b/engines/saga2/mapfeatr.cpp
index f8b88b7bbe..1e53c11d63 100644
--- a/engines/saga2/mapfeatr.cpp
+++ b/engines/saga2/mapfeatr.cpp
@@ -251,7 +251,7 @@ void updateMapFeatures(int16 cWorld) {
extern GameWorld *currentWorld;
WorldMapData *wMap = &mapList[ currentWorld->mapNum ];
- uint16 *mapData = (*wMap->map)->mapData;
+ uint16 *mapData = wMap->map->mapData;
for (int i = 0; i < mapFeatureCount; i++) {
if (mapFeatures[i]->getWorld() == cWorld) {
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index c55e1d93e9..0031fddbf0 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -1427,13 +1427,11 @@ void initMaps(void) {
// Load all of the tile terrain banks
for (i = 0; i < maxBanks; i++) {
if (tileRes->seek(tileTerrainID + MKTAG(0, 0, 0, (uint8)i))) {
- tileBanks[ i ] =
- (TileBankPtr)LoadResource(
- tileRes,
- tileTerrainID + MKTAG(0, 0, 0, (uint8)i),
- "tile terrain bank");
+ tileBanks[i] = (TileBankPtr)LoadResource(tileRes,
+ tileTerrainID + MKTAG(0, 0, 0, (uint8)i),
+ "tile terrain bank");
} else
- tileBanks[ i ] = NULL;
+ tileBanks[i] = nullptr;
}
// Count the worlds by seeking the map data
@@ -1442,11 +1440,8 @@ void initMaps(void) {
worldCount++) ;
// Allocate the map data array
- mapList = (WorldMapData *)RNewPtr(
- sizeof(WorldMapData) * worldCount,
- NULL,
- "map data array");
- if (mapList == NULL)
+ mapList = new WorldMapData[worldCount];
+ if (mapList == nullptr)
error("Unable to allocate map data array");
// Iterate through the map data list initializing each element
@@ -1458,56 +1453,49 @@ void initMaps(void) {
mapData->worldID = WorldBaseID + i;
// Load the map
- mapData->map = (MapHandle)LoadResourceToHandle(
- tileRes,
- mapID + MKTAG(0, 0, 0, (uint8)i),
- "world map");
- if (mapData->map == NULL)
+ mapData->map = (MapPtr)LoadResource(tileRes,
+ mapID + MKTAG(0, 0, 0, (uint8)i), "world map");
+ if (mapData->map == nullptr)
error("Unable to load map");
// Load the meta tile list
- mapData->metaList = (MetaTileHandle)LoadResourceToHandle(
- tileRes,
- metaID + MKTAG(0, 0, 0, (uint8)i),
- "meta tile list");
- if (mapData->metaList == NULL)
+ mapData->metaList = (MetaTileHandle)LoadResourceToHandle(tileRes,
+ metaID + MKTAG(0, 0, 0, (uint8)i),
+ "meta tile list");
+ if (mapData->metaList == nullptr)
error("Unable to load meta tile list");
// If there is tag data, load it
if (tileRes->size(tagDataID + MKTAG(0, 0, 0, (uint8)i)) > 0) {
- mapData->activeItemData =
- (TileRefHandle)LoadResourceToHandle(
- tileRes,
- tagDataID + MKTAG(0, 0, 0, (uint8)i),
- "active item data");
- if (mapData->activeItemData == NULL)
+ mapData->activeItemData = (TileRefHandle)LoadResourceToHandle(tileRes,
+ tagDataID + MKTAG(0, 0, 0, (uint8)i),
+ "active item data");
+ if (mapData->activeItemData == nullptr)
error("Unable to load active item data");
} else
- mapData->activeItemData = NULL;
+ mapData->activeItemData = nullptr;
// If there is an association list, load it
if (tileRes->size(assocID + MKTAG(0, 0, 0, (uint8)i)) > 0) {
mapData->assocList =
- (UWordHandle)LoadResourceToHandle(
- tileRes,
+ (UWordHandle)LoadResourceToHandle(tileRes,
assocID + MKTAG(0, 0, 0, (uint8)i),
"association list");
- if (mapData->assocList == NULL)
+ if (mapData->assocList == nullptr)
error("Unable to load association list");
} else
- mapData->assocList = NULL;
+ mapData->assocList = nullptr;
// If there is an active item list, load it
if (tileRes->size(tagID + MKTAG(0, 0, 0, (uint8)i)) > 0) {
mapData->activeItemList =
- (ActiveItemPtr)LoadResource(
- tileRes,
+ (ActiveItemPtr)LoadResource(tileRes,
tagID + MKTAG(0, 0, 0, (uint8)i),
"active item list");
- if (mapData->activeItemList == NULL)
+ if (mapData->activeItemList == nullptr)
error("Unable to load active item list");
} else
- mapData->activeItemList = NULL;
+ mapData->activeItemList = nullptr;
// Compute the number of meta tiles in list
mapData->metaCount = RPtrSize(*mapData->metaList)
@@ -1532,11 +1520,8 @@ void initMaps(void) {
*/
// Allocate an object ripping table ID list
mapData->ripTableIDList =
- (RipTableIDHandle)RNewHandle(
- sizeof(RipTableID) * mapData->metaCount,
- NULL,
- "rip table ID list");
- if (mapData->ripTableIDList == NULL)
+ (RipTableIDHandle)malloc(sizeof(RipTableID) * mapData->metaCount);
+ if (mapData->ripTableIDList == nullptr)
error("Unable to allocate rip table ID list");
// Initialize the object ripping ID list
@@ -1544,7 +1529,7 @@ void initMaps(void) {
(*mapData->ripTableIDList)[ j ] = -1;
// Get the size of the map in meta tiles
- mapData->mapSize = (*mapData->map)->size;
+ mapData->mapSize = mapData->map->size;
// Compute the height of the map in pixels
mapData->mapHeight = mapData->mapSize * metaTileHeight;
@@ -1570,34 +1555,35 @@ void cleanupMaps(void) {
WorldMapData *mapData = &mapList[ i ];
// Dump the map
- RDisposeHandle((RHANDLE)mapData->map);
+ free(mapData->map);
// Dump the meta tile list
RDisposeHandle((RHANDLE)mapData->metaList);
// If there is active item data, dump it
- if (mapData->activeItemData != NULL)
+ if (mapData->activeItemData != nullptr)
RDisposeHandle((RHANDLE)mapData->activeItemData);
// If there is an association list, dump it
- if (mapData->assocList != NULL)
+ if (mapData->assocList != nullptr)
RDisposeHandle((RHANDLE)mapData->assocList);
// If there is an active item list, dump it
- if (mapData->activeItemList != NULL)
+ if (mapData->activeItemList != nullptr)
RDisposePtr(mapData->activeItemList);
// Dump the object ripping table ID list
- RDisposeHandle((RHANDLE)mapData->ripTableIDList);
+ free(mapData->ripTableIDList);
}
// Dump the map data list
- RDisposePtr(mapList);
+ //RDisposePtr(mapList);
+ delete[] mapList;
// Dump all of the tile terrain banks
for (i = 0; i < maxBanks; i++) {
- if (tileBanks[ i ] != NULL)
- RDisposePtr(tileBanks[ i ]);
+ if (tileBanks[ i ] != nullptr)
+ free(tileBanks[ i ]);
}
}
@@ -1633,7 +1619,7 @@ void initAutoMap(void) {
mapIndex;
uint16 *mapData;
- map = *mapList[ i ].map;
+ map = mapList[i].map;
mapSize = map->size;
mapSize *= mapSize;
mapData = map->mapData;
@@ -1659,7 +1645,7 @@ void saveAutoMap(SaveFileConstructor &saveGame) {
MapHeader *map;
int32 mapSize;
- map = *mapList[ i ].map;
+ map = mapList[i].map;
mapSize = map->size;
mapSize *= mapSize;
@@ -1680,7 +1666,7 @@ void saveAutoMap(SaveFileConstructor &saveGame) {
mapIndex;
uint16 *mapData;
- map = *mapList[ i ].map;
+ map = mapList[i].map;
mapSize = map->size;
mapSize *= mapSize;
mapData = map->mapData;
@@ -1732,7 +1718,7 @@ void loadAutoMap(SaveFileReader &saveGame) {
mapIndex;
uint16 *mapData;
- map = *mapList[ i ].map;
+ map = mapList[i].map;
mapSize = map->size;
mapSize *= mapSize;
mapData = map->mapData;
@@ -2323,7 +2309,7 @@ RipTableID &MetaTile::ripTableID(int16 mapNum) {
// Return a pointer to the specified meta tile on this map
MetaTilePtr WorldMapData::lookupMeta(TilePoint coords) {
- uint16 *mapData = (*map)->mapData;
+ uint16 *mapData = map->mapData;
int16 mtile;
#if 0
@@ -2598,8 +2584,8 @@ inline void drawMetaRow(TilePoint coords, Point16 pos) {
**put = drawList;
int16 mapSizeMask = curMap->mapSize - 1,
- mapEdgeType = (*curMap->map)->edgeType;
- uint16 *mapData = (*curMap->map)->mapData;
+ mapEdgeType = curMap->map->edgeType;
+ uint16 *mapData = curMap->map->mapData;
MetaTilePtr metaArray = *curMap->metaList;
@@ -3234,8 +3220,8 @@ void maskMetaRow(
**put = drawList;
int16 mapSizeMask = curMap->mapSize - 1,
- mapEdgeType = (*curMap->map)->edgeType;
- uint16 *mapData = (*curMap->map)->mapData;
+ mapEdgeType = curMap->map->edgeType;
+ uint16 *mapData = curMap->map->mapData;
MetaTilePtr metaArray = *curMap->metaList;
@@ -4763,7 +4749,7 @@ void markMetaAsVisited(const TilePoint &pt) {
// If (they have cartography)
{
WorldMapData *curMap = &mapList[ currentMapNum ];
- uint16 *mapData = (*curMap->map)->mapData;
+ uint16 *mapData = curMap->map->mapData;
TilePoint metaCoords = pt >> (tileUVShift + platShift);
int32 minU = MAX(metaCoords.u - mappingRadius, 0),
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index 72f22c49a0..b9331a1521 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -872,7 +872,7 @@ const uint16 metaTileVisited = (1 << 15);
struct WorldMapData {
ObjectID worldID; // The number of this map
- MapHandle map; // Map data
+ MapPtr map; // Map data
MetaTileHandle metaList; // MetaTile list
TileRefHandle activeItemData; // ActiveItem tileRefs
ActiveItemPtr activeItemList; // ActiveItem list
Commit: dfaf98b2a77841977fb7c65cdf71cb8f64a1f49a
https://github.com/scummvm/scummvm/commit/dfaf98b2a77841977fb7c65cdf71cb8f64a1f49a
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:53+02:00
Commit Message:
SAGA2: Cleanup initMaps() more
Changed paths:
engines/saga2/main.cpp
engines/saga2/path.cpp
engines/saga2/sagafunc.cpp
engines/saga2/tile.cpp
engines/saga2/tile.h
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index ee67a11fc1..829a2e0724 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -79,8 +79,8 @@ extern configuration globalConfig;
extern char *gameTimeStr;
extern bool underground;
extern char commandLineHelp[];
-//extern hResContext *tileRes; // tile resource handle
-//extern hResContext *listRes;
+extern hResContext *tileRes; // tile resource handle
+extern hResContext *listRes;
/* ===================================================================== *
Globals
@@ -754,7 +754,21 @@ void testScripts() {
}
void testTileRendering() {
-
+ tileRes = resFile->newContext(MKTAG('T', 'I', 'L', 'E'), "tile resources");
+ listRes = objResFile->newContext(MKTAG('L', 'I', 'S', 'T'), "list resources");
+ resImports = (ResImportTable *)LoadResource(listRes, MKTAG('I', 'M', 'P', 'O'), "res imports");
+
+ initMaps();
+
+ //uint8 *img = nullptr;
+ //TileInfo *ti;
+ //for (int i = 0; i < 65535; ++i) {
+ // ti = TileInfo::tileAddress(i, &img);
+ // if (ti) {
+ // debug("height: %d", ti->attrs.height);
+ // Common::hexdump(img, ti->attrs.height);
+ // }
+ //}
}
//-----------------------------------------------------------------------
diff --git a/engines/saga2/path.cpp b/engines/saga2/path.cpp
index cb68e8f4b4..39ec43b386 100644
--- a/engines/saga2/path.cpp
+++ b/engines/saga2/path.cpp
@@ -410,7 +410,7 @@ void PathTileRegion::fetchSubMeta(const TilePoint &subMeta) {
instanceItem = map->findHashedInstance(absPos, tr->tile);
if (instanceItem) state = instanceItem->getInstanceState(mapNum);
- stateData = &(*map->activeItemData)[
+ stateData = &(map->activeItemData)[
groupItem->group.grDataOffset
+ state * groupItem->group.animArea ];
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index b6f7115881..07a8fee83e 100644
--- a/engines/saga2/sagafunc.cpp
+++ b/engines/saga2/sagafunc.cpp
@@ -2411,7 +2411,7 @@ int16 scriptTagAssoc(int16 *args) {
assert(mapNum >= 0);
assert(mapNum < 8);
- return (*mapList[ mapNum ].assocList)[ ai->associationOffset + args[ 0 ] ];
+ return (mapList[mapNum].assocList)[ai->associationOffset + args[0]];
}
//-----------------------------------------------------------------------
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 0031fddbf0..e094895642 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -1459,7 +1459,7 @@ void initMaps(void) {
error("Unable to load map");
// Load the meta tile list
- mapData->metaList = (MetaTileHandle)LoadResourceToHandle(tileRes,
+ mapData->metaList = (MetaTilePtr)LoadResource(tileRes,
metaID + MKTAG(0, 0, 0, (uint8)i),
"meta tile list");
if (mapData->metaList == nullptr)
@@ -1467,7 +1467,7 @@ void initMaps(void) {
// If there is tag data, load it
if (tileRes->size(tagDataID + MKTAG(0, 0, 0, (uint8)i)) > 0) {
- mapData->activeItemData = (TileRefHandle)LoadResourceToHandle(tileRes,
+ mapData->activeItemData = (TileRefPtr)LoadResource(tileRes,
tagDataID + MKTAG(0, 0, 0, (uint8)i),
"active item data");
if (mapData->activeItemData == nullptr)
@@ -1478,7 +1478,7 @@ void initMaps(void) {
// If there is an association list, load it
if (tileRes->size(assocID + MKTAG(0, 0, 0, (uint8)i)) > 0) {
mapData->assocList =
- (UWordHandle)LoadResourceToHandle(tileRes,
+ (UWordPtr)LoadResource(tileRes,
assocID + MKTAG(0, 0, 0, (uint8)i),
"association list");
if (mapData->assocList == nullptr)
@@ -1498,12 +1498,12 @@ void initMaps(void) {
mapData->activeItemList = nullptr;
// Compute the number of meta tiles in list
- mapData->metaCount = RPtrSize(*mapData->metaList)
- / sizeof(MetaTile);
+ mapData->metaCount = tileRes->size(metaID + MKTAG(0, 0, 0, (uint8)i))
+ / sizeof(MetaTile); // 2 + 8 + 2 + 4 = 16
// Compute the number of active items in list
- mapData->activeCount = RPtrSize(mapData->activeItemList)
- / sizeof(ActiveItem);
+ mapData->activeCount = tileRes->size(tagID + MKTAG(0, 0, 0, (uint8)i))
+ / sizeof(ActiveItem); // Not portable?
/* // Initialize the state index for the each active item
// instance. NOTE: This code will need to be removed when
@@ -1519,14 +1519,13 @@ void initMaps(void) {
}
*/
// Allocate an object ripping table ID list
- mapData->ripTableIDList =
- (RipTableIDHandle)malloc(sizeof(RipTableID) * mapData->metaCount);
+ mapData->ripTableIDList = new RipTableID[mapData->metaCount];
if (mapData->ripTableIDList == nullptr)
error("Unable to allocate rip table ID list");
// Initialize the object ripping ID list
for (j = 0; j < mapData->metaCount; j++)
- (*mapData->ripTableIDList)[ j ] = -1;
+ (mapData->ripTableIDList)[j] = -1;
// Get the size of the map in meta tiles
mapData->mapSize = mapData->map->size;
@@ -1558,22 +1557,22 @@ void cleanupMaps(void) {
free(mapData->map);
// Dump the meta tile list
- RDisposeHandle((RHANDLE)mapData->metaList);
+ free(mapData->metaList);
// If there is active item data, dump it
if (mapData->activeItemData != nullptr)
- RDisposeHandle((RHANDLE)mapData->activeItemData);
+ free(mapData->activeItemData);
// If there is an association list, dump it
if (mapData->assocList != nullptr)
- RDisposeHandle((RHANDLE)mapData->assocList);
+ free(mapData->assocList);
// If there is an active item list, dump it
if (mapData->activeItemList != nullptr)
- RDisposePtr(mapData->activeItemList);
+ free(mapData->activeItemList);
// Dump the object ripping table ID list
- free(mapData->ripTableIDList);
+ delete mapData->ripTableIDList;
}
// Dump the map data list
@@ -1582,8 +1581,8 @@ void cleanupMaps(void) {
// Dump all of the tile terrain banks
for (i = 0; i < maxBanks; i++) {
- if (tileBanks[ i ] != nullptr)
- free(tileBanks[ i ]);
+ if (tileBanks[i] != nullptr)
+ free(tileBanks[i]);
}
}
@@ -1878,7 +1877,7 @@ TileInfo *Platform::fetchTile(
state = instanceItem->getInstanceState(mapNum);
// Get the tile to be drawn from the tile group
- tr = &(*mapList[ mapNum ].activeItemData)[
+ tr = &(mapList[mapNum].activeItemData)[
groupItem->group.grDataOffset
+ state * groupItem->group.animArea
+ relPos.u * groupItem->group.vSize
@@ -1960,7 +1959,7 @@ TileInfo *Platform::fetchTAGInstance(
sti.surfaceTAG = instanceItem;
// Get the tile to be drawn from the tile group
- tr = &(*mapList[ mapNum ].activeItemData)[
+ tr = &(mapList[mapNum].activeItemData)[
groupItem->group.grDataOffset
+ state * groupItem->group.animArea
+ relPos.u * groupItem->group.vSize
@@ -2035,7 +2034,7 @@ TileInfo *Platform::fetchTile(
state = instanceItem->getInstanceState(mapNum);
// Get the tile to be drawn from the tile group
- tr = &(*mapList[ mapNum ].activeItemData)[
+ tr = &(mapList[mapNum].activeItemData)[
groupItem->group.grDataOffset
+ state * groupItem->group.animArea
+ relPos.u * groupItem->group.vSize
@@ -2118,7 +2117,7 @@ TileInfo *Platform::fetchTAGInstance(
sti.surfaceTAG = instanceItem;
// Get the tile to be drawn from the tile group
- tr = &(*mapList[ mapNum ].activeItemData)[
+ tr = &(mapList[mapNum].activeItemData)[
groupItem->group.grDataOffset
+ state * groupItem->group.animArea
+ relPos.u * groupItem->group.vSize
@@ -2172,15 +2171,15 @@ RipTableID RipTable::thisID(void) {
MetaTile *MetaTile::metaTileAddress(MetaTileID id) {
return id.map != nullID && id.index != nullID
- ? &(*mapList[ id.map ].metaList)[ id.index ]
- : NULL;
+ ? &(mapList[id.map].metaList)[ id.index ]
+ : nullptr;
}
//-----------------------------------------------------------------------
// Return this meta tile's ID
MetaTileID MetaTile::thisID(int16 mapNum) {
- return MetaTileID(mapNum, this - *mapList[ mapNum ].metaList);
+ return MetaTileID(mapNum, this - mapList[mapNum].metaList);
}
//-----------------------------------------------------------------------
@@ -2200,8 +2199,8 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
PlatformCacheEntry *pce;
assert(layer >= 0);
- assert(this >= *mapList[ mapNum ].metaList
- && this < & (*mapList[ mapNum ].metaList)[
+ assert(this >= mapList[mapNum].metaList
+ && this < & (mapList[ mapNum ].metaList)[
mapList[ mapNum ].metaCount ]);
if (plIndex == nullID) {
@@ -2287,9 +2286,9 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
RipTable *MetaTile::ripTable(int16 mapNum) {
WorldMapData *mapData = &mapList[ mapNum ];
- return RipTable::ripTableAddress((*mapData->ripTableIDList)[
+ return RipTable::ripTableAddress((mapData->ripTableIDList)[
this
- - *mapData->metaList ]);
+ - mapData->metaList ]);
}
//-----------------------------------------------------------------------
@@ -2298,7 +2297,7 @@ RipTable *MetaTile::ripTable(int16 mapNum) {
RipTableID &MetaTile::ripTableID(int16 mapNum) {
WorldMapData *mapData = &mapList[ mapNum ];
- return (*mapData->ripTableIDList)[ this - *mapData->metaList ];
+ return (mapData->ripTableIDList)[ this - mapData->metaList ];
}
/* ====================================================================== *
@@ -2368,7 +2367,8 @@ MetaTilePtr WorldMapData::lookupMeta(TilePoint coords) {
assert(mtile < metaCount);
assert(mtile >= 0);
- return &(*metaList)[ mtile ];
+ return &metaList[mtile];
+
}
//-----------------------------------------------------------------------
@@ -2587,7 +2587,7 @@ inline void drawMetaRow(TilePoint coords, Point16 pos) {
mapEdgeType = curMap->map->edgeType;
uint16 *mapData = curMap->map->mapData;
- MetaTilePtr metaArray = *curMap->metaList;
+ MetaTilePtr metaArray = curMap->metaList;
int16 layerLimit;
@@ -3223,7 +3223,7 @@ void maskMetaRow(
mapEdgeType = curMap->map->edgeType;
uint16 *mapData = curMap->map->mapData;
- MetaTilePtr metaArray = *curMap->metaList;
+ MetaTilePtr metaArray = curMap->metaList;
int16 layerLimit;
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index b9331a1521..2aa05946bc 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -797,7 +797,8 @@ struct RipTable {
};
typedef RipTable *RipTablePtr;
-typedef RipTableID **RipTableIDHandle;
+typedef RipTableID *RipTableIDPtr,
+ **RipTableIDHandle;
typedef uint16 metaTileNoise;
@@ -873,11 +874,11 @@ struct WorldMapData {
ObjectID worldID; // The number of this map
MapPtr map; // Map data
- MetaTileHandle metaList; // MetaTile list
- TileRefHandle activeItemData; // ActiveItem tileRefs
+ MetaTilePtr metaList; // MetaTile list
+ TileRefPtr activeItemData; // ActiveItem tileRefs
ActiveItemPtr activeItemList; // ActiveItem list
- UWordHandle assocList; // Associations
- RipTableIDHandle ripTableIDList; // MetaTile object ripping
+ UWordPtr assocList; // Associations
+ RipTableIDPtr ripTableIDList; // MetaTile object ripping
ActiveItem *instHash[ 513 ]; // ActiveItem hash table
Commit: 308c258b4bbde559c1d8fb39238e34b0e6b7eeda
https://github.com/scummvm/scummvm/commit/308c258b4bbde559c1d8fb39238e34b0e6b7eeda
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:53+02:00
Commit Message:
SAGA2: Fix resource loading in hResContext constructor
Changed paths:
engines/saga2/hresmgr.cpp
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index f1f65d4948..d325644b31 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -88,12 +88,17 @@ hResContext::hResContext(hResContext *sire, hResID id, const char desc[]) {
_parent = sire;
- if ((entry = _parent->findEntry(id)) == nullptr)
+ debugC(3, kDebugResources, "Creating context %x (%s)", id, tag2str(id));
+ if ((entry = _parent->findEntry(id)) == nullptr) {
+ debugC(3, kDebugResources, "Could not create context");
return;
+ }
_numEntries = entry->size / resourceSize;
- _base = &_res->_table[entry->offset - _res->_firstGroupOffset];
+ _base = (hResEntry *)((uint8*)_res->_table + entry->offset - _res->_firstGroupOffset);
+ debugC(3, kDebugResources, "- _numEntries = %d, _base = %p, entry->offset = %d",
+ _numEntries, _base, entry->offset);
_valid = true;
}
Commit: a51985c8fbe903d7c4aed40e01fe42f9cec0ce66
https://github.com/scummvm/scummvm/commit/a51985c8fbe903d7c4aed40e01fe42f9cec0ce66
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:53+02:00
Commit Message:
SAGA2: Cleanup tile.cpp a bit
Changed paths:
engines/saga2/main.cpp
engines/saga2/mapfeatr.cpp
engines/saga2/tile.cpp
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 829a2e0724..c3cde675f1 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -627,6 +627,7 @@ void *LoadResource(hResContext *con, uint32 id, const char desc[]) {
idString[ 0 ] = id;
idString[ 1 ] = 0;
+ debugC(3, kDebugResources, "Loading resource %d (%s, %s)", id, tag2str(id), desc);
size = con->size(id);
if (size <= 0 || !con->seek(id)) {
@@ -769,6 +770,8 @@ void testTileRendering() {
// Common::hexdump(img, ti->attrs.height);
// }
//}
+
+ cleanupMaps();
}
//-----------------------------------------------------------------------
diff --git a/engines/saga2/mapfeatr.cpp b/engines/saga2/mapfeatr.cpp
index 1e53c11d63..8af94545f6 100644
--- a/engines/saga2/mapfeatr.cpp
+++ b/engines/saga2/mapfeatr.cpp
@@ -300,8 +300,9 @@ char *getMapFeaturesText(TileRegion viewRegion,
void termMapFeatures(void) {
for (int i = 0; i < MAX_MAP_FEATURES; i++) {
- if (mapFeatures[i]) delete mapFeatures[i];
- mapFeatures[i] = NULL;
+ if (mapFeatures[i])
+ delete mapFeatures[i];
+ mapFeatures[i] = nullptr;
}
}
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index e094895642..f0be279538 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -98,7 +98,7 @@ void setAreaSound(const TilePoint &baseCoords);
Bank switching interface
* ===================================================================== */
-TileBankPtr tileBanks[ maxBanks ];
+TileBankPtr tileBanks[maxBanks];
extern byte* tileImageBanks[];
void tileFault(int bank, int num);
@@ -186,7 +186,7 @@ uint16 rippedRoofID;
TilePoint ripTableCoords = Nowhere;
-static RipTable ripTableList[ 25 ];
+static RipTable ripTableList[25];
WorldMapData *mapList; // master map data array
@@ -199,7 +199,7 @@ CycleHandle cycleList; // list of tile cycling info
const int platformCacheSize = 256;
DList platformLRU; // least recently used
-PlatformCacheEntry platformCache[ platformCacheSize ];
+PlatformCacheEntry platformCache[platformCacheSize];
/* ===================================================================== *
View state
@@ -271,20 +271,20 @@ TileInfo *TileInfo::tileAddress(TileID id) {
int16 tileBank,
tileNum;
- if (id == 0) return NULL;
+ if (id == 0) return nullptr;
TileID2Bank(id, tileBank, tileNum);
- if ((tbh = tileBanks[ tileBank ]) == NULL) return NULL;
+ if ((tbh = tileBanks[tileBank]) == nullptr) return nullptr;
ti = tbh->tile(tileNum);
if (ti->attrs.cycleRange > 0) {
- TileCycleData &tcd = (*cycleList)[ ti->attrs.cycleRange - 1 ];
+ TileCycleData &tcd = (*cycleList)[ti->attrs.cycleRange - 1];
- TileID2Bank(tcd.cycleList[ tcd.currentState ],
+ TileID2Bank(tcd.cycleList[tcd.currentState],
tileBank,
tileNum);
- if ((tbh = tileBanks[ tileBank ]) == NULL) return NULL;
+ if ((tbh = tileBanks[tileBank]) == nullptr) return nullptr;
ti = tbh->tile(tileNum);
}
@@ -302,30 +302,30 @@ TileInfo *TileInfo::tileAddress(TileID id, uint8 **imageData) {
int16 tileBank,
tileNum;
- if (id == 0) return NULL;
+ if (id == 0) return nullptr;
TileID2Bank(id, tileBank, tileNum);
- if ((tbh = tileBanks[ tileBank ]) == NULL) return NULL;
+ if ((tbh = tileBanks[tileBank]) == nullptr) return nullptr;
ti = tbh->tile(tileNum);
if (ti->attrs.cycleRange > 0) {
- TileCycleData &tcd = (*cycleList)[ ti->attrs.cycleRange - 1 ];
+ TileCycleData &tcd = (*cycleList)[ti->attrs.cycleRange - 1];
TileID2Bank(tcd.cycleList[tcd.currentState],
tileBank,
tileNum);
- if ((tbh = tileBanks[tileBank]) == NULL) return NULL;
+ if ((tbh = tileBanks[tileBank]) == nullptr) return nullptr;
ti = tbh->tile(tileNum);
}
- if (ti != NULL) {
- if ((tibh = tileImageBanks[tileBank]) != NULL)
+ if (ti != nullptr) {
+ if ((tibh = tileImageBanks[tileBank]) != nullptr)
*imageData = &tibh[ti->offset];
else
- *imageData = NULL;
+ *imageData = nullptr;
} else
- *imageData = NULL;
+ *imageData = nullptr;
return ti;
}
@@ -343,11 +343,11 @@ int16 ActiveItem::getMapNum(void) {
// Use a brute force search of all of the maps' active item lists
// to determine which map this active item is on.
for (mapNum = 0; mapNum < worldCount; mapNum++) {
- WorldMapData *mapData = &mapList[ mapNum ];
+ WorldMapData *mapData = &mapList[mapNum];
// Determine if the active item in on this map's list
if (this >= mapData->activeItemList
- && this < &mapData->activeItemList[ mapData->activeCount ])
+ && this < &mapData->activeItemList[mapData->activeCount])
break;
}
@@ -382,8 +382,8 @@ Location ActiveItem::getInstanceLocation(void) {
ActiveItem *ActiveItem::activeItemAddress(ActiveItemID id) {
return id.getIndexNum() != activeItemIndexNullID
- ? &mapList[ id.getMapNum() ].activeItemList[ id.getIndexNum() ]
- : NULL;
+ ? &mapList[id.getMapNum()].activeItemList[id.getIndexNum()]
+ : nullptr;
}
//-----------------------------------------------------------------------
@@ -394,14 +394,14 @@ ActiveItemID ActiveItem::thisID(void) {
return ActiveItemID(
mapNum,
- this - mapList[ mapNum ].activeItemList);
+ this - mapList[mapNum].activeItemList);
}
//-----------------------------------------------------------------------
// Return this active item's ID
ActiveItemID ActiveItem::thisID(int16 mapNum) {
- return ActiveItemID(mapNum, this - mapList[ mapNum ].activeItemList);
+ return ActiveItemID(mapNum, this - mapList[mapNum].activeItemList);
}
//-----------------------------------------------------------------------
@@ -526,7 +526,7 @@ bool ActiveItem::use(ActiveItem *ins, ObjectID enactor) {
playTAGNoise(ins, DEFAULT_OPEN);
} else {
playTAGNoise(ins, DOOR_LOCKED_NO_KEY);
- return FALSE;
+ return false;
}
} else {
TileActivityTask::closeDoor(*ins);
@@ -536,7 +536,7 @@ bool ActiveItem::use(ActiveItem *ins, ObjectID enactor) {
}
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -547,7 +547,7 @@ bool ActiveItem::trigger(ActiveItem *ins, ObjectID enactor, ObjectID objID) {
GameObject *obj = GameObject::objectAddress(objID);
GameWorld *world = (GameWorld *)GameObject::objectAddress(
- mapList[ getMapNum() ].worldID);
+ mapList[getMapNum()].worldID);
ProtoObj *proto = obj->proto();
TileRegion instanceRegion;
ActiveItemID instanceID = ins->thisID();
@@ -556,7 +556,7 @@ bool ActiveItem::trigger(ActiveItem *ins, ObjectID enactor, ObjectID objID) {
// Trap transporters to only react to the center actor
if (ins->builtInBehavior() == builtInTransporter
&& (!isActor(obj) || (Actor *)obj != getCenterActor()))
- return TRUE;
+ return true;
if (ins->scriptClassID != 0) {
// Set up the arguments we want to pass to the script
@@ -571,12 +571,12 @@ bool ActiveItem::trigger(ActiveItem *ins, ObjectID enactor, ObjectID objID) {
Method_TileActivityInstance_onCanTrigger,
scf)
== scriptResultFinished) {
- if (!scf.returnVal) return TRUE;
+ if (!scf.returnVal) return true;
}
}
// Mark the object as triggering this TAG
- obj->setTriggeringTAG(TRUE);
+ obj->setTriggeringTAG(true);
instanceRegion.min.u = ins->instance.u << tileUVShift;
instanceRegion.min.v = ins->instance.v << tileUVShift;
@@ -592,15 +592,15 @@ bool ActiveItem::trigger(ActiveItem *ins, ObjectID enactor, ObjectID objID) {
GameObject *testObject;
for (iter.first(&testObject);
- testObject != NULL;
+ testObject != nullptr;
iter.next(&testObject)) {
if (testObject != obj
&& testObject->currentTAG == instanceID
&& testObject->isTriggeringTAG())
- return TRUE;
+ return true;
}
-// if ( proto->mass < group.triggerWeight ) return FALSE;
+// if ( proto->mass < group.triggerWeight ) return false;
if (ins->scriptClassID != 0) {
// Set up the arguments we want to pass to the script
@@ -648,7 +648,7 @@ bool ActiveItem::trigger(ActiveItem *ins, ObjectID enactor, ObjectID objID) {
}
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -659,12 +659,12 @@ bool ActiveItem::release(ActiveItem *ins, ObjectID enactor, ObjectID objID) {
GameObject *obj = GameObject::objectAddress(objID);
GameWorld *world = (GameWorld *)GameObject::objectAddress(
- mapList[ getMapNum() ].worldID);
+ mapList[getMapNum()].worldID);
TileRegion instanceRegion;
ActiveItemID instanceID = ins->thisID();
scriptCallFrame scf;
- if (obj->isTriggeringTAG()) obj->setTriggeringTAG(FALSE);
+ if (obj->isTriggeringTAG()) obj->setTriggeringTAG(false);
instanceRegion.min.u = ins->instance.u << tileUVShift;
instanceRegion.min.v = ins->instance.v << tileUVShift;
@@ -680,12 +680,12 @@ bool ActiveItem::release(ActiveItem *ins, ObjectID enactor, ObjectID objID) {
GameObject *testObject;
for (iter.first(&testObject);
- testObject != NULL;
+ testObject != nullptr;
iter.next(&testObject)) {
if (testObject != obj
&& testObject->currentTAG == instanceID
&& testObject->isTriggeringTAG())
- return TRUE;
+ return true;
}
if (ins->scriptClassID != 0) {
@@ -712,7 +712,7 @@ bool ActiveItem::release(ActiveItem *ins, ObjectID enactor, ObjectID objID) {
}
}
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -751,21 +751,21 @@ bool ActiveItem::acceptLockToggle(ActiveItem *ins, ObjectID enactor, uint8 keyCo
if (keyCode == ins->lockType()) {
playTAGNoise(ins, UNLOCK_RIGHT_KEY);
if (ins->isLocked())
- ins->setLocked(FALSE);
+ ins->setLocked(false);
else {
if (ins->getInstanceState(getMapNum()) == 0)
- ins->setLocked(TRUE);
+ ins->setLocked(true);
else
- return FALSE;
+ return false;
}
} else {
playTAGNoise(ins, UNLOCK_WRONG_KEY);
- return FALSE;
+ return false;
}
break;
}
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -807,19 +807,19 @@ void initActiveItemStates(void) {
stateArray = (UByteHandle *)RNewPtr(
worldCount * sizeof(UByteHandle),
- NULL,
+ nullptr,
"active item state array array");
- if (stateArray == NULL)
+ if (stateArray == nullptr)
error("Unable to allocate the active item state array array");
for (i = 0; i < worldCount; i++) {
- stateArray[ i ] = (UByteHandle)LoadResourceToHandle(
+ stateArray[i] = (UByteHandle)LoadResourceToHandle(
tileRes,
tagStateID + MKTAG(0, 0, 0, uint8(i)),
"active item state array");
- if (stateArray[ i ] == NULL)
+ if (stateArray[i] == nullptr)
error("Unable to load active item state array");
}
}
@@ -836,23 +836,23 @@ void saveActiveItemStates(SaveFileConstructor &saveGame) {
for (i = 0; i < worldCount; i++) {
archiveBufSize += sizeof(int16);
- if (stateArray[ i ] != NULL)
- archiveBufSize += RPtrSize(*stateArray[ i ]);
+ if (stateArray[i] != nullptr)
+ archiveBufSize += RPtrSize(*stateArray[i]);
}
- archiveBuffer = RNewPtr(archiveBufSize, NULL, "archive buffer");
- if (archiveBuffer == NULL)
+ archiveBuffer = RNewPtr(archiveBufSize, nullptr, "archive buffer");
+ if (archiveBuffer == nullptr)
error("Unable to allocate a state array archive buffer");
bufferPtr = archiveBuffer;
for (i = 0; i < worldCount; i++) {
- if (stateArray[ i ] != NULL) {
- WorldMapData *mapData = &mapList[ i ];
+ if (stateArray[i] != nullptr) {
+ WorldMapData *mapData = &mapList[i];
ActiveItemPtr activeItemList = mapData->activeItemList;
int16 activeItemCount = mapData->activeCount,
j;
- int32 arraySize = RPtrSize(*stateArray[ i ]);
+ int32 arraySize = RPtrSize(*stateArray[i]);
uint8 *bufferedStateArray;
// Save the size of the state array
@@ -860,13 +860,13 @@ void saveActiveItemStates(SaveFileConstructor &saveGame) {
bufferPtr = (int16 *)bufferPtr + 1;
// Copy the state data to the archive buffer
- memcpy(bufferPtr, *stateArray[ i ], arraySize);
+ memcpy(bufferPtr, *stateArray[i], arraySize);
// Save a pointer to the buffered data
bufferedStateArray = (uint8 *)bufferPtr;
bufferPtr = (uint8 *)bufferPtr + arraySize;
for (j = 0; j < activeItemCount; j++) {
- ActiveItem *activeItem = &activeItemList[ j ];
+ ActiveItem *activeItem = &activeItemList[j];
uint8 *statePtr;
if (activeItem->itemType != activeTypeInstance)
@@ -875,7 +875,7 @@ void saveActiveItemStates(SaveFileConstructor &saveGame) {
// Get a pointer to the current active item's state
// data in the archive buffer
statePtr =
- &bufferedStateArray[ activeItem->instance.stateIndex ];
+ &bufferedStateArray[activeItem->instance.stateIndex];
// Set the high bit of the state value based upon the
// active item's locked state
@@ -909,18 +909,18 @@ void loadActiveItemStates(SaveFileReader &saveGame) {
stateArray = (UByteHandle *)RNewPtr(
worldCount * sizeof(UByteHandle),
- NULL,
+ nullptr,
"active item state array array");
- if (stateArray == NULL)
+ if (stateArray == nullptr)
error("Unable to allocate the active item state array array");
archiveBuffer = RNewPtr(
saveGame.getChunkSize(),
- NULL,
+ nullptr,
"archive buffer");
- if (archiveBuffer == NULL)
+ if (archiveBuffer == nullptr)
error("Unable to allocate state array archive buffer");
saveGame.read(archiveBuffer, saveGame.getChunkSize());
@@ -934,14 +934,14 @@ void loadActiveItemStates(SaveFileReader &saveGame) {
bufferPtr = (int16 *)bufferPtr + 1;
if (arraySize > 0) {
- WorldMapData *mapData = &mapList[ i ];
+ WorldMapData *mapData = &mapList[i];
ActiveItemPtr activeItemList = mapData->activeItemList;
int16 activeItemCount = mapData->activeCount,
j;
uint8 *bufferedStateArray = (uint8 *)bufferPtr;
for (j = 0; j < activeItemCount; j++) {
- ActiveItem *activeItem = &activeItemList[ j ];
+ ActiveItem *activeItem = &activeItemList[j];
uint8 *statePtr;
if (activeItem->itemType != activeTypeInstance)
@@ -950,7 +950,7 @@ void loadActiveItemStates(SaveFileReader &saveGame) {
// Get a pointer to the current active item's state
// data in the archive buffer
statePtr =
- &bufferedStateArray[ activeItem->instance.stateIndex ];
+ &bufferedStateArray[activeItem->instance.stateIndex];
// Reset the locked state of the active item based
// upon the high bit of the buffered state value
@@ -960,17 +960,17 @@ void loadActiveItemStates(SaveFileReader &saveGame) {
*statePtr &= ~(1 << 7);
}
- stateArray[ i ] = (UByteHandle)RNewHandle(
+ stateArray[i] = (UByteHandle)RNewHandle(
arraySize,
- NULL,
+ nullptr,
"active item state array");
- if (stateArray[ i ] == NULL)
+ if (stateArray[i] == nullptr)
error("Unable to allocate active item state array");
- memcpy(*stateArray[ i ], bufferPtr, arraySize);
+ memcpy(*stateArray[i], bufferPtr, arraySize);
bufferPtr = (uint8 *)bufferPtr + arraySize;
} else
- stateArray[ i ] = NULL;
+ stateArray[i] = nullptr;
}
RDisposePtr(archiveBuffer);
@@ -983,8 +983,8 @@ void cleanupActiveItemStates(void) {
int16 i;
for (i = 0; i < worldCount; i++) {
- if (stateArray[ i ] != NULL)
- RDisposeHandle((RHANDLE)stateArray[ i ]);
+ if (stateArray[i] != nullptr)
+ RDisposeHandle((RHANDLE)stateArray[i]);
}
RDisposePtr(stateArray);
@@ -997,7 +997,7 @@ void cleanupActiveItemStates(void) {
//-----------------------------------------------------------------------
// The list of active tile activity tasks
-static uint8 aTaskListBuffer[ sizeof(TileActivityTaskList) ];
+static uint8 aTaskListBuffer[sizeof(TileActivityTaskList)];
static TileActivityTaskList &aTaskList =
*((TileActivityTaskList *)aTaskListBuffer);
@@ -1007,7 +1007,7 @@ static TileActivityTaskList &aTaskList =
TileActivityTaskList::TileActivityTaskList(void) {
for (int i = 0; i < elementsof(array); i++) {
- free.addTail(array[ i ]);
+ free.addTail(array[i]);
}
}
@@ -1021,7 +1021,7 @@ TileActivityTaskList::TileActivityTaskList(void **buf) {
taskCount;
for (i = 0; i < elementsof(array); i++) {
- free.addTail(array[ i ]);
+ free.addTail(array[i]);
}
// Retreive the task count
@@ -1038,11 +1038,11 @@ TileActivityTaskList::TileActivityTaskList(void **buf) {
activityType = *((uint8 *)bufferPtr);
bufferPtr = (uint8 *)bufferPtr + 1;
- if (tai != NULL) {
+ if (tai != nullptr) {
TileActivityTask *tat;
tat = newTask(tai);
- if (tat != NULL)
+ if (tat != nullptr)
tat->activityType = activityType;
}
}
@@ -1059,7 +1059,7 @@ int32 TileActivityTaskList::archiveSize(void) {
TileActivityTask *tat;
for (tat = (TileActivityTask *)list.first();
- tat != NULL;
+ tat != nullptr;
tat = (TileActivityTask *)tat->next())
size += sizeof(ActiveItemID) + sizeof(uint8);
@@ -1075,7 +1075,7 @@ void *TileActivityTaskList::archive(void *buf) {
TileActivityTask *tat;
for (tat = (TileActivityTask *)list.first(), taskCount = 0;
- tat != NULL;
+ tat != nullptr;
tat = (TileActivityTask *)tat->next())
taskCount++;
@@ -1084,7 +1084,7 @@ void *TileActivityTaskList::archive(void *buf) {
buf = (int16 *)buf + 1;
for (tat = (TileActivityTask *)list.first();
- tat != NULL;
+ tat != nullptr;
tat = (TileActivityTask *)tat->next()) {
ActiveItem *ai = tat->tai;
@@ -1108,7 +1108,7 @@ void TileActivityTaskList::cleanup(void) {
TileActivityTask *nextTat;
for (tat = (TileActivityTask *)list.first();
- tat != NULL;
+ tat != nullptr;
tat = nextTat) {
nextTat = (TileActivityTask *)tat->next();
tat->remove();
@@ -1134,7 +1134,7 @@ TileActivityTask *TileActivityTaskList::newTask(ActiveItem *activeInstance) {
if (tat) writeLog("Found old TAT\n");
#endif
- if (tat == NULL) {
+ if (tat == nullptr) {
tat = (TileActivityTask *)free.remHead();
#if TATLOG
@@ -1186,7 +1186,7 @@ void TileActivityTask::openDoor(ActiveItem &activeInstance) {
#if TATLOG
writeLog("TAT Open Door\n");
#endif
- if ((tat = aTaskList.newTask(&activeInstance)) != NULL)
+ if ((tat = aTaskList.newTask(&activeInstance)) != nullptr)
tat->activityType = activityTypeOpen;
}
@@ -1199,7 +1199,7 @@ void TileActivityTask::closeDoor(ActiveItem &activeInstance) {
#if TATLOG
writeLog("TAT Close Door\n");
#endif
- if ((tat = aTaskList.newTask(&activeInstance)) != NULL)
+ if ((tat = aTaskList.newTask(&activeInstance)) != nullptr)
tat->activityType = activityTypeClose;
}
@@ -1212,7 +1212,7 @@ void TileActivityTask::doScript(ActiveItem &activeInstance, uint8 finalState, Th
#if TATLOG
writeLog("TAT Do Script\n");
#endif
- if ((tat = aTaskList.newTask(&activeInstance)) != NULL) {
+ if ((tat = aTaskList.newTask(&activeInstance)) != nullptr) {
#if TATLOG
if (scr) writeLog("TAT Assign Script!\n");
#endif
@@ -1240,7 +1240,7 @@ void TileActivityTask::updateActiveItems(void) {
for (tat = (TileActivityTask *)aTaskList.list.first(); tat; tat = nextTat) {
ActiveItem *activityInstance = tat->tai;
- bool activityTaskDone = FALSE;
+ bool activityTaskDone = false;
int16 mapNum = activityInstance->getMapNum();
uint16 state = activityInstance->getInstanceState(mapNum);
@@ -1257,14 +1257,14 @@ void TileActivityTask::updateActiveItems(void) {
if (state < 3)
activityInstance->setInstanceState(mapNum, state + 1);
else
- activityTaskDone = TRUE;
+ activityTaskDone = true;
break;
case activityTypeClose:
if (state > 0)
activityInstance->setInstanceState(mapNum, state - 1);
else
- activityTaskDone = TRUE;
+ activityTaskDone = true;
break;
case activityTypeScript:
@@ -1273,11 +1273,11 @@ void TileActivityTask::updateActiveItems(void) {
else if (state < tat->targetState)
activityInstance->setInstanceState(mapNum, state + 1);
else
- activityTaskDone = TRUE;
+ activityTaskDone = true;
break;
default:
- activityTaskDone = TRUE;
+ activityTaskDone = true;
break;
}
@@ -1306,7 +1306,7 @@ TileActivityTask *TileActivityTask::find(ActiveItem *tai) {
if (tai == tat->tai) return tat;
}
- return NULL;
+ return nullptr;
}
//-----------------------------------------------------------------------
@@ -1326,12 +1326,12 @@ bool TileActivityTask::setWait(ActiveItem *tai, ThreadID script) {
#endif
if (tat->script != NoThread) wakeUpThread(tat->script);
tat->script = script;
- return TRUE;
+ return true;
}
#if TATLOG
writeLog("SetWait failed\n");
#endif
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -1360,8 +1360,8 @@ void saveTileTasks(SaveFileConstructor &saveGame) {
archiveBufSize = aTaskList.archiveSize();
- archiveBuffer = RNewPtr(archiveBufSize, NULL, "archive buffer");
- if (archiveBuffer == NULL)
+ archiveBuffer = RNewPtr(archiveBufSize, nullptr, "archive buffer");
+ if (archiveBuffer == nullptr)
error("Unable to allocate tile activity task archive buffer");
aTaskList.archive(archiveBuffer);
@@ -1389,9 +1389,9 @@ void loadTileTasks(SaveFileReader &saveGame) {
archiveBuffer = RNewPtr(
saveGame.getChunkSize(),
- NULL,
+ nullptr,
"archive buffer");
- if (archiveBuffer == NULL)
+ if (archiveBuffer == nullptr)
error("Unable to allocate tile activity task archive buffer");
// Read the archived tile activity task data
@@ -1446,7 +1446,7 @@ void initMaps(void) {
// Iterate through the map data list initializing each element
for (i = 0; i < worldCount; i++) {
- WorldMapData *mapData = &mapList[ i ];
+ WorldMapData *mapData = &mapList[i];
int16 j;
// Initialize the world ID
@@ -1505,19 +1505,6 @@ void initMaps(void) {
mapData->activeCount = tileRes->size(tagID + MKTAG(0, 0, 0, (uint8)i))
/ sizeof(ActiveItem); // Not portable?
- /* // Initialize the state index for the each active item
- // instance. NOTE: This code will need to be removed when
- // the active item instance states are their own resource.
- uint16 instanceCtr;
-
- for ( j = 0, instanceCtr = 0; j < mapData->activeCount; j++ )
- {
- ActiveItem *ai = &mapData->activeItemList[ j ];
-
- if ( ai->itemType == activeTypeInstance )
- ai->instance.stateIndex = instanceCtr++;
- }
- */
// Allocate an object ripping table ID list
mapData->ripTableIDList = new RipTableID[mapData->metaCount];
if (mapData->ripTableIDList == nullptr)
@@ -1539,7 +1526,6 @@ void initMaps(void) {
initPlatformCache();
initMapFeatures();
-
}
//-----------------------------------------------------------------------
@@ -1551,7 +1537,7 @@ void cleanupMaps(void) {
termMapFeatures();
// Iterate through each map, dumping the data
for (i = 0; i < worldCount; i++) {
- WorldMapData *mapData = &mapList[ i ];
+ WorldMapData *mapData = &mapList[i];
// Dump the map
free(mapData->map);
@@ -1572,11 +1558,10 @@ void cleanupMaps(void) {
free(mapData->activeItemList);
// Dump the object ripping table ID list
- delete mapData->ripTableIDList;
+ delete[] mapData->ripTableIDList;
}
// Dump the map data list
- //RDisposePtr(mapList);
delete[] mapList;
// Dump all of the tile terrain banks
@@ -1597,8 +1582,8 @@ void setCurrentMap(int mapNum) {
audioEnvironmentSetWorld(mapNum);
}
-// tileScroll.x = mapList[ mapNum ].mapHeight - tileRect.width - 800;
-// tileScroll.y = mapList[ mapNum ].mapHeight - tileRect.width / 2;
+// tileScroll.x = mapList[mapNum].mapHeight - tileRect.width - 800;
+// tileScroll.y = mapList[mapNum].mapHeight - tileRect.width / 2;
lastUpdateTime = gameTime;
}
@@ -1625,7 +1610,7 @@ void initAutoMap(void) {
// Clear the high bit for each map position
for (mapIndex = 0; mapIndex < mapSize; mapIndex++)
- mapData[ mapIndex ] &= ~metaTileVisited;
+ mapData[mapIndex] &= ~metaTileVisited;
}
}
@@ -1655,8 +1640,8 @@ void saveAutoMap(SaveFileConstructor &saveGame) {
// for each map metatile slot
archiveBufSize = (totalMapSize + 7) >> 3;
- archiveBuffer = (uint8 *)RNewPtr(archiveBufSize, NULL, "archive buffer");
- if (archiveBuffer == NULL)
+ archiveBuffer = (uint8 *)RNewPtr(archiveBufSize, nullptr, "archive buffer");
+ if (archiveBuffer == nullptr)
error("Unable to allocate auto map archive buffer");
for (i = 0; i < worldCount; i++) {
@@ -1671,13 +1656,13 @@ void saveAutoMap(SaveFileConstructor &saveGame) {
mapData = map->mapData;
for (mapIndex = 0; mapIndex < mapSize; mapIndex++) {
- if (mapData[ mapIndex ] & metaTileVisited) {
+ if (mapData[mapIndex] & metaTileVisited) {
// Set the bit in the archive buffer
- archiveBuffer[ totalMapIndex >> 3 ] |=
+ archiveBuffer[totalMapIndex >> 3] |=
(1 << (totalMapIndex & 7));
} else {
// Clear the bit in the archive buffer
- archiveBuffer[ totalMapIndex >> 3 ] &=
+ archiveBuffer[totalMapIndex >> 3] &=
~(1 << (totalMapIndex & 7));
}
@@ -1705,8 +1690,8 @@ void loadAutoMap(SaveFileReader &saveGame) {
archiveBufSize = saveGame.getChunkSize();
- archiveBuffer = (uint8 *)RNewPtr(archiveBufSize, NULL, "archive buffer");
- if (archiveBuffer == NULL)
+ archiveBuffer = (uint8 *)RNewPtr(archiveBufSize, nullptr, "archive buffer");
+ if (archiveBuffer == nullptr)
error("Unable to allocate auto map archive buffer");
saveGame.read(archiveBuffer, archiveBufSize);
@@ -1727,11 +1712,11 @@ void loadAutoMap(SaveFileReader &saveGame) {
// If the bit is set in the archive buffer, set the visited
// bit in the map data
- if (archiveBuffer[ totalMapIndex >> 3 ]
+ if (archiveBuffer[totalMapIndex >> 3]
& (1 << (totalMapIndex & 7)))
- mapData[ mapIndex ] |= metaTileVisited;
+ mapData[mapIndex] |= metaTileVisited;
else
- mapData[ mapIndex ] &= ~metaTileVisited;
+ mapData[mapIndex] &= ~metaTileVisited;
totalMapIndex++;
}
@@ -1749,7 +1734,7 @@ void loadAutoMap(SaveFileReader &saveGame) {
void initPlatformCache(void) {
for (int i = 0; i < platformCacheSize; i++) {
- PlatformCacheEntry *pce = &platformCache[ i ];
+ PlatformCacheEntry *pce = &platformCache[i];
// Fill up the LRU with empty platforms
pce->metaID = NoMetaTile;
@@ -1762,7 +1747,7 @@ void initPlatformCache(void) {
* ===================================================================== */
TilePoint XYToUV(const Point32 &pt) {
- int32 mapHeight = mapList[ currentMapNum ].mapHeight;
+ int32 mapHeight = mapList[currentMapNum].mapHeight;
TilePoint coords;
// coordinates of the view in U,V
@@ -1779,7 +1764,7 @@ TilePoint XYToUV(const Point32 &pt) {
* ===================================================================== */
void TileToScreenCoords(const TilePoint &tp, Point16 &p) {
- int32 mapHeight = mapList[ currentMapNum ].mapHeight;
+ int32 mapHeight = mapList[currentMapNum].mapHeight;
// screen coords of the point
p.x = (((int32)tp.u - (int32)tp.v) << 1) - tileScroll.x + mapHeight;
@@ -1808,19 +1793,19 @@ int16 TilePoint::quickDir(void) {
* ===================================================================== */
int16 ptHeight(const TilePoint &tp, uint8 *cornerHeight) {
- int16 slopeHeight = cornerHeight[ 0 ];
+ int16 slopeHeight = cornerHeight[0];
- if (cornerHeight[ 1 ] == slopeHeight &&
- cornerHeight[ 2 ] == slopeHeight &&
- cornerHeight[ 3 ] == slopeHeight)
+ if (cornerHeight[1] == slopeHeight &&
+ cornerHeight[2] == slopeHeight &&
+ cornerHeight[3] == slopeHeight)
return slopeHeight;
slopeHeight
- = (cornerHeight[ 0 ] * (tileUVSize - tp.u)
- + cornerHeight[ 1 ] * tp.u)
+ = (cornerHeight[0] * (tileUVSize - tp.u)
+ + cornerHeight[1] * tp.u)
* (tileUVSize - tp.v)
- + (cornerHeight[ 3 ] * (tileUVSize - tp.u)
- + cornerHeight[ 2 ] * tp.u)
+ + (cornerHeight[3] * (tileUVSize - tp.u)
+ + cornerHeight[2] * tp.u)
* tp.v;
return slopeHeight >> (tileUVShift + tileUVShift);
@@ -1841,7 +1826,7 @@ TileInfo *Platform::fetchTile(
const TilePoint &origin,
int16 &height,
int16 &trFlags) {
- TileRef *tr = &tiles[ pt.u ][ pt.v ];
+ TileRef *tr = &tiles[pt.u][pt.v];
TileInfo *ti;
int16 h = tr->tileHeight * 8;
@@ -1870,7 +1855,7 @@ TileInfo *Platform::fetchTile(
absPos.z = h;
// Look up the group instance in the hash.
- instanceItem = mapList[ mapNum ].findHashedInstance(
+ instanceItem = mapList[mapNum].findHashedInstance(
absPos,
tr->tile);
if (instanceItem) {
@@ -1881,7 +1866,7 @@ TileInfo *Platform::fetchTile(
groupItem->group.grDataOffset
+ state * groupItem->group.animArea
+ relPos.u * groupItem->group.vSize
- + relPos.v ];
+ + relPos.v];
h += tr->tileHeight * 8;
}
@@ -1894,7 +1879,7 @@ TileInfo *Platform::fetchTile(
}
- if ((ti = TileInfo::tileAddress(tr->tile)) == NULL) return NULL;
+ if ((ti = TileInfo::tileAddress(tr->tile)) == nullptr) return nullptr;
trFlags = tr->flags;
height = h;
@@ -1907,7 +1892,7 @@ TileInfo *Platform::fetchTile(
TileID2Bank(tr->tile, tileBank, tileNo);
WriteStatusF(0, "Bad Tile: %d/%d", tileNo, tileBank);
- return NULL;
+ return nullptr;
}
#endif
@@ -1922,7 +1907,7 @@ TileInfo *Platform::fetchTAGInstance(
const TilePoint &pt,
const TilePoint &origin,
StandingTileInfo &sti) {
- TileRef *tr = &tiles[ pt.u ][ pt.v ];
+ TileRef *tr = &tiles[pt.u][pt.v];
TileInfo *ti;
int16 h = tr->tileHeight * 8;
@@ -1951,7 +1936,7 @@ TileInfo *Platform::fetchTAGInstance(
absPos.z = h;
// Look up the group instance in the hash.
- instanceItem = mapList[ mapNum ].findHashedInstance(
+ instanceItem = mapList[mapNum].findHashedInstance(
absPos,
tr->tile);
if (instanceItem) {
@@ -1963,7 +1948,7 @@ TileInfo *Platform::fetchTAGInstance(
groupItem->group.grDataOffset
+ state * groupItem->group.animArea
+ relPos.u * groupItem->group.vSize
- + relPos.v ];
+ + relPos.v];
h += tr->tileHeight * 8;
}
@@ -1974,10 +1959,10 @@ TileInfo *Platform::fetchTAGInstance(
}
#endif
} else {
- sti.surfaceTAG = NULL;
+ sti.surfaceTAG = nullptr;
}
- if ((ti = TileInfo::tileAddress(tr->tile)) == NULL) return NULL;
+ if ((ti = TileInfo::tileAddress(tr->tile)) == nullptr) return nullptr;
sti.surfaceTile = ti;
sti.surfaceRef = *tr;
@@ -1998,7 +1983,7 @@ TileInfo *Platform::fetchTile(
uint8 **imageData,
int16 &height,
int16 &trFlags) {
- TileRef *tr = &tiles[ pt.u ][ pt.v ];
+ TileRef *tr = &tiles[pt.u][pt.v];
TileInfo *ti;
int16 h = tr->tileHeight * 8;
@@ -2027,7 +2012,7 @@ TileInfo *Platform::fetchTile(
absPos.z = h;
// Look up the group instance in the hash.
- instanceItem = mapList[ mapNum ].findHashedInstance(
+ instanceItem = mapList[mapNum].findHashedInstance(
absPos,
tr->tile);
if (instanceItem) {
@@ -2038,7 +2023,7 @@ TileInfo *Platform::fetchTile(
groupItem->group.grDataOffset
+ state * groupItem->group.animArea
+ relPos.u * groupItem->group.vSize
- + relPos.v ];
+ + relPos.v];
h += tr->tileHeight * 8;
}
@@ -2051,7 +2036,7 @@ TileInfo *Platform::fetchTile(
}
- if ((ti = TileInfo::tileAddress(tr->tile, imageData)) == NULL) return NULL;
+ if ((ti = TileInfo::tileAddress(tr->tile, imageData)) == nullptr) return nullptr;
trFlags = tr->flags;
height = h;
@@ -2064,7 +2049,7 @@ TileInfo *Platform::fetchTile(
TileID2Bank(tr->tile, tileBank, tileNo);
WriteStatusF(0, "Bad Tile: %d/%d", tileNo, tileBank);
- return NULL;
+ return nullptr;
}
#endif
@@ -2080,7 +2065,7 @@ TileInfo *Platform::fetchTAGInstance(
const TilePoint &origin,
uint8 **imageData,
StandingTileInfo &sti) {
- TileRef *tr = &tiles[ pt.u ][ pt.v ];
+ TileRef *tr = &tiles[pt.u][pt.v];
TileInfo *ti;
int16 h = tr->tileHeight * 8;
@@ -2109,7 +2094,7 @@ TileInfo *Platform::fetchTAGInstance(
absPos.z = h;
// Look up the group instance in the hash.
- instanceItem = mapList[ mapNum ].findHashedInstance(
+ instanceItem = mapList[mapNum].findHashedInstance(
absPos,
tr->tile);
if (instanceItem) {
@@ -2121,7 +2106,7 @@ TileInfo *Platform::fetchTAGInstance(
groupItem->group.grDataOffset
+ state * groupItem->group.animArea
+ relPos.u * groupItem->group.vSize
- + relPos.v ];
+ + relPos.v];
h += tr->tileHeight * 8;
}
@@ -2132,10 +2117,10 @@ TileInfo *Platform::fetchTAGInstance(
}
#endif
} else {
- sti.surfaceTAG = NULL;
+ sti.surfaceTAG = nullptr;
}
- if ((ti = TileInfo::tileAddress(tr->tile, imageData)) == NULL) return NULL;
+ if ((ti = TileInfo::tileAddress(tr->tile, imageData)) == nullptr) return nullptr;
sti.surfaceTile = ti;
sti.surfaceRef = *tr;
@@ -2152,7 +2137,7 @@ TileInfo *Platform::fetchTAGInstance(
// Return a pointer to a rip table give the rip table's ID
RipTable *RipTable::ripTableAddress(RipTableID id) {
- return id != -1 ? &ripTableList[ id ] : NULL;
+ return id != -1 ? &ripTableList[id] : nullptr;
}
//-----------------------------------------------------------------------
@@ -2171,7 +2156,7 @@ RipTableID RipTable::thisID(void) {
MetaTile *MetaTile::metaTileAddress(MetaTileID id) {
return id.map != nullID && id.index != nullID
- ? &(mapList[id.map].metaList)[ id.index ]
+ ? &(mapList[id.map].metaList)[id.index]
: nullptr;
}
@@ -2195,16 +2180,16 @@ metaTileNoise MetaTile::HeavyMetaMusic(void) {
Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
const int cacheFlag = 0x8000;
- uint16 plIndex = stack[ layer ];
+ uint16 plIndex = stack[layer];
PlatformCacheEntry *pce;
assert(layer >= 0);
assert(this >= mapList[mapNum].metaList
- && this < & (mapList[ mapNum ].metaList)[
- mapList[ mapNum ].metaCount ]);
+ && this < & (mapList[mapNum].metaList)[
+ mapList[mapNum].metaCount]);
if (plIndex == nullID) {
- return NULL;
+ return nullptr;
}
// if platform in cache
else if (plIndex & cacheFlag) {
@@ -2213,7 +2198,7 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
assert(plIndex < platformCacheSize);
// Get the address of the pce from the cache
- pce = &platformCache[ plIndex ];
+ pce = &platformCache[plIndex];
assert(pce->platformNum >= 0);
assert(pce->metaID != NoMetaTile);
@@ -2249,15 +2234,15 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
MetaTile *oldMeta = metaTileAddress(pce->metaID);
assert(pce->layerNum < maxPlatforms);
- assert(oldMeta->stack[ pce->layerNum ] == (cacheFlag | cacheIndex));
- oldMeta->stack[ pce->layerNum ] = pce->platformNum;
+ assert(oldMeta->stack[pce->layerNum] == (cacheFlag | cacheIndex));
+ oldMeta->stack[pce->layerNum] = pce->platformNum;
}
// Initialize the cache entry to the new platform data.
pce->platformNum = plIndex;
pce->layerNum = layer;
pce->metaID = thisID(mapNum);
- stack[ layer ] = (cacheFlag | cacheIndex);
+ stack[layer] = (cacheFlag | cacheIndex);
assert(plIndex >= 0);
assert(plIndex * sizeof(Platform) < tileRes->size(platformID + MKTAG(0, 0, 0, mapNum)));
@@ -2274,7 +2259,7 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
error("Unable to read Platform %d of map %d", plIndex, mapNum);
#ifdef _WIN32
- return NULL;
+ return nullptr;
#endif
}
}
@@ -2284,20 +2269,20 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
// table
RipTable *MetaTile::ripTable(int16 mapNum) {
- WorldMapData *mapData = &mapList[ mapNum ];
+ WorldMapData *mapData = &mapList[mapNum];
return RipTable::ripTableAddress((mapData->ripTableIDList)[
this
- - mapData->metaList ]);
+ - mapData->metaList]);
}
//-----------------------------------------------------------------------
// Return a reference to this meta tile's rip table ID
RipTableID &MetaTile::ripTableID(int16 mapNum) {
- WorldMapData *mapData = &mapList[ mapNum ];
+ WorldMapData *mapData = &mapList[mapNum];
- return (mapData->ripTableIDList)[ this - mapData->metaList ];
+ return (mapData->ripTableIDList)[this - mapData->metaList];
}
/* ====================================================================== *
@@ -2337,14 +2322,14 @@ MetaTilePtr WorldMapData::lookupMeta(TilePoint coords) {
case edgeTypeRepeat:
coords.u = clamp(0, coords.u, mapSizeMask);
coords.v = clamp(0, coords.v, mapSizeMask);
- mtile = mapData[ clipCoords.u * mapSize + clipCoords.v ];
+ mtile = mapData[clipCoords.u * mapSize + clipCoords.v];
break;
case edgeTypeWrap:
- mtile = mapData[ clipCoords.u * mapSize + clipCoords.v ];
+ mtile = mapData[clipCoords.u * mapSize + clipCoords.v];
break;
}
- } else mtile = mapData[ clipCoords.u * mapSize + clipCoords.v ];
+ } else mtile = mapData[clipCoords.u * mapSize + clipCoords.v];
#else
// Check to see if coords are less than zero or greater
@@ -2359,7 +2344,7 @@ MetaTilePtr WorldMapData::lookupMeta(TilePoint coords) {
} else {
// When getting the metatile number, make sure to mask off the
// bit indicating that this map square has been visited.
- mtile = mapData[ coords.u * mapSize + coords.v ] & ~metaTileVisited;
+ mtile = mapData[coords.u * mapSize + coords.v] & ~metaTileVisited;
}
#endif
@@ -2387,8 +2372,8 @@ void WorldMapData::buildInstanceHash(void) {
+ ai->instance.v + (ai->instance.groupID << 2))
% elementsof(instHash);
- ai->nextHash = instHash[ hashVal ];
- instHash[ hashVal ] = ai;
+ ai->nextHash = instHash[hashVal];
+ instHash[hashVal] = ai;
}
}
}
@@ -2404,7 +2389,7 @@ ActiveItem *WorldMapData::findHashedInstance(
% elementsof(instHash);
ActiveItem *ai;
- for (ai = instHash[ hashVal ];
+ for (ai = instHash[hashVal];
ai;
ai = ai->nextHash) {
if (ai->instance.u == tp.u
@@ -2413,7 +2398,7 @@ ActiveItem *WorldMapData::findHashedInstance(
&& ai->instance.groupID == group)
return ai;
}
- return NULL;
+ return nullptr;
}
/* ====================================================================== *
@@ -2422,11 +2407,11 @@ ActiveItem *WorldMapData::findHashedInstance(
bool MetaTileIterator::iterate(void) {
if (++mCoords.v >= region.max.v) {
- if (++mCoords.u >= region.max.u) return FALSE;
+ if (++mCoords.u >= region.max.u) return false;
mCoords.v = region.min.v;
}
- return TRUE;
+ return true;
}
MetaTile *MetaTileIterator::first(TilePoint *loc) {
@@ -2434,12 +2419,12 @@ MetaTile *MetaTileIterator::first(TilePoint *loc) {
mCoords = region.min;
if (mCoords.u >= region.max.u || mCoords.v >= region.max.v)
- return NULL;
+ return nullptr;
- mtRes = mapList[ mapNum ].lookupMeta(mCoords);
- while (mtRes == NULL) {
- if (!iterate()) return NULL;
- mtRes = mapList[ mapNum ].lookupMeta(mCoords);
+ mtRes = mapList[mapNum].lookupMeta(mCoords);
+ while (mtRes == nullptr) {
+ if (!iterate()) return nullptr;
+ mtRes = mapList[mapNum].lookupMeta(mCoords);
}
if (loc) *loc = mCoords << platShift;
@@ -2447,12 +2432,12 @@ MetaTile *MetaTileIterator::first(TilePoint *loc) {
}
MetaTile *MetaTileIterator::next(TilePoint *loc) {
- MetaTile *mtRes = NULL;
+ MetaTile *mtRes = nullptr;
do {
- if (!iterate()) return NULL;
- mtRes = mapList[ mapNum ].lookupMeta(mCoords);
- } while (mtRes == NULL);
+ if (!iterate()) return nullptr;
+ mtRes = mapList[mapNum].lookupMeta(mCoords);
+ } while (mtRes == nullptr);
if (loc) *loc = mCoords << platShift;
return mtRes;
@@ -2468,7 +2453,7 @@ bool TileIterator::iterate(void) {
do {
platIndex++;
if (platIndex >= maxPlatforms) {
- if ((mt = metaIter.next(&origin)) != NULL) {
+ if ((mt = metaIter.next(&origin)) != nullptr) {
tCoordsReg.min.u = tCoordsReg.min.v = 0;
tCoordsReg.max.u = tCoordsReg.max.v = platformWidth;
@@ -2480,21 +2465,22 @@ bool TileIterator::iterate(void) {
tCoordsReg.min.v = region.min.v & platMask;
if (origin.v + platformWidth > region.max.v)
tCoordsReg.max.v = region.max.v & platMask;
- } else return NULL;
+ } else
+ return false;
platIndex = 0;
}
platform = mt->fetchPlatform(
metaIter.getMapNum(),
platIndex);
- } while (platform == NULL);
+ } while (platform == nullptr);
tCoords.u = tCoordsReg.min.u;
}
tCoords.v = tCoordsReg.min.v;
}
- return TRUE;
+ return true;
}
TileInfo *TileIterator::first(TilePoint *loc, StandingTileInfo *stiResult) {
@@ -2502,15 +2488,15 @@ TileInfo *TileIterator::first(TilePoint *loc, StandingTileInfo *stiResult) {
StandingTileInfo sti;
if (region.max.u <= region.min.u || region.max.v <= region.min.v)
- return NULL;
+ return nullptr;
- if ((mt = metaIter.first(&origin)) == NULL) return NULL;
+ if ((mt = metaIter.first(&origin)) == nullptr) return nullptr;
platform = mt->fetchPlatform(metaIter.getMapNum(), platIndex = 0);
- while (platform == NULL) {
+ while (platform == nullptr) {
platIndex++;
if (platIndex >= maxPlatforms) {
- if ((mt = metaIter.next(&origin)) == NULL) return NULL;
+ if ((mt = metaIter.next(&origin)) == nullptr) return nullptr;
platIndex = 0;
}
platform = mt->fetchPlatform(metaIter.getMapNum(), platIndex);
@@ -2534,8 +2520,8 @@ TileInfo *TileIterator::first(TilePoint *loc, StandingTileInfo *stiResult) {
tCoords,
origin,
sti);
- while (tiRes == NULL) {
- if (!iterate()) return NULL;
+ while (tiRes == nullptr) {
+ if (!iterate()) return nullptr;
tiRes = platform->fetchTAGInstance(
metaIter.getMapNum(),
tCoords,
@@ -2549,17 +2535,17 @@ TileInfo *TileIterator::first(TilePoint *loc, StandingTileInfo *stiResult) {
}
TileInfo *TileIterator::next(TilePoint *loc, StandingTileInfo *stiResult) {
- TileInfo *tiRes = NULL;
+ TileInfo *tiRes = nullptr;
StandingTileInfo sti;
do {
- if (!iterate()) return NULL;
+ if (!iterate()) return nullptr;
tiRes = platform->fetchTAGInstance(
metaIter.getMapNum(),
tCoords,
origin,
sti);
- } while (tiRes == NULL);
+ } while (tiRes == nullptr);
*loc = tCoords + origin;
if (stiResult) *stiResult = sti;
@@ -2575,12 +2561,12 @@ TileInfo *TileIterator::next(TilePoint *loc, StandingTileInfo *stiResult) {
* ============================================================================ */
inline void drawMetaRow(TilePoint coords, Point16 pos) {
- WorldMapData *curMap = &mapList[ currentMapNum ];
+ WorldMapData *curMap = &mapList[currentMapNum];
int16 uOrg = coords.u * platformWidth,
vOrg = coords.v * platformWidth;
- Platform *drawList[ maxPlatforms + 1 ],
+ Platform *drawList[maxPlatforms + 1],
**put = drawList;
int16 mapSizeMask = curMap->mapSize - 1,
@@ -2625,21 +2611,21 @@ inline void drawMetaRow(TilePoint coords, Point16 pos) {
case edgeTypeRepeat:
coords.u = clamp(0, coords.u, mapSizeMask);
coords.v = clamp(0, coords.v, mapSizeMask);
- mtile = mapData[ clipCoords.u * curMap->mapSize + clipCoords.v ] & ~metaTileVisited;
+ mtile = mapData[clipCoords.u * curMap->mapSize + clipCoords.v] & ~metaTileVisited;
break;
case edgeTypeWrap:
- mtile = mapData[ clipCoords.u * curMap->mapSize + clipCoords.v ] & ~metaTileVisited;
+ mtile = mapData[clipCoords.u * curMap->mapSize + clipCoords.v] & ~metaTileVisited;
break;
}
- } else mtile = mapData[ clipCoords.u * curMap->mapSize + clipCoords.v ] & ~metaTileVisited;
+ } else mtile = mapData[clipCoords.u * curMap->mapSize + clipCoords.v] & ~metaTileVisited;
if (mtile >= curMap->metaCount) mtile = curMap->metaCount - 1;
- metaPtr = &metaArray[ mtile ];
+ metaPtr = &metaArray[mtile];
put = drawList;
- if (metaPtr == NULL) return;
+ if (metaPtr == nullptr) return;
// REM: Reject whole metatiles based on coords, based on
// max height
@@ -2669,9 +2655,9 @@ inline void drawMetaRow(TilePoint coords, Point16 pos) {
*put++ = p;
}
}
- *put++ = NULL;
+ *put++ = nullptr;
- if (drawList[ 0 ] != NULL) {
+ if (drawList[0] != nullptr) {
drawPlatform(drawList, pos, uOrg, vOrg);
}
// gThread::yield();
@@ -2711,12 +2697,12 @@ void buildRipTable(
for (i = 0; i < maxPlatforms; i++) {
Platform *p;
- if ((p = mt->fetchPlatform(currentMapNum, i)) == NULL) continue;
+ if ((p = mt->fetchPlatform(currentMapNum, i)) == nullptr) continue;
if (p->roofRipID() != ripID) continue;
for (; i < maxPlatforms && tilesToGo > 0; i++) {
- if ((p = mt->fetchPlatform(currentMapNum, i)) == NULL)
+ if ((p = mt->fetchPlatform(currentMapNum, i)) == nullptr)
continue;
uint16 platHeight = p->height << 3;
@@ -2724,13 +2710,13 @@ void buildRipTable(
for (u = 0; u < platformWidth; u++)
for (v = 0; v < platformWidth; v++)
- if (ripTable->zTable[ u ][ v ] == maxint16) {
+ if (ripTable->zTable[u][v] == maxint16) {
TileRef &tr = p->getTileRef(u, v);
if (tr.tile != 0) {
// Calculate object ripping altitude for
// tile position
- ripTable->zTable[ u ][ v ] =
+ ripTable->zTable[u][v] =
platHeight + (tr.tileHeight << 3);
tilesToGo--;
}
@@ -2752,7 +2738,7 @@ void buildRipTables(void) {
MetaTile *mt;
TileRegion ripTableReg;
- MetaTile *mtTable[ 25 ]; // Largest region is 5x5
+ MetaTile *mtTable[25]; // Largest region is 5x5
int16 mtTableSize = 0;
getViewTrackPos(actorCoords);
@@ -2774,7 +2760,7 @@ void buildRipTables(void) {
// Build meta tile pointer array
mt = mIter.first();
while (mt) {
- mtTable[ mtTableSize++ ] = mt;
+ mtTable[mtTableSize++] = mt;
mt = mIter.next();
}
@@ -2784,12 +2770,12 @@ void buildRipTables(void) {
int16 tableIndex;
// bit array of available rip tables
- uint8 tableAvail[(elementsof(ripTableList) + 7) >> 3 ];
+ uint8 tableAvail[(elementsof(ripTableList) + 7) >> 3];
memset(tableAvail, 0xFF, sizeof(tableAvail));
for (i = 0; i < mtTableSize; i++) {
- mt = mtTable[ i ];
+ mt = mtTable[i];
RipTable *mtRipTable = mt->ripTable(currentMapNum);
@@ -2797,46 +2783,46 @@ void buildRipTables(void) {
// recycle it
if (mtRipTable && mtRipTable->ripID == rippedRoofID) {
// Null out pointer
- mtTable[ i ] = NULL;
+ mtTable[i] = nullptr;
// Mark the table as unavailable
tableIndex = mtRipTable - ripTableList;
- tableAvail[ tableIndex >> 3 ] &= ~(1 << (tableIndex & 0x7));
+ tableAvail[tableIndex >> 3] &= ~(1 << (tableIndex & 0x7));
}
}
// Remove empty entries from meta tile pointer array
int16 oldMtTableSize = mtTableSize;
for (i = 0, j = 0; i < oldMtTableSize; i++) {
- if (mtTable[ i ] != NULL)
- mtTable[ j++ ] = mtTable[ i ];
+ if (mtTable[i] != nullptr)
+ mtTable[j++] = mtTable[i];
else
mtTableSize--;
}
for (i = 0; i < mtTableSize; i++) {
- mt = mtTable[ i ];
+ mt = mtTable[i];
// Find available table
for (j = 0; j < elementsof(ripTableList); j++) {
- if (tableAvail[ j >> 3 ] & (1 << (j & 0x7)))
+ if (tableAvail[j >> 3] & (1 << (j & 0x7)))
break;
}
- tableAvail[ j >> 3 ] &= ~(1 << (j & 0x7));
+ tableAvail[j >> 3] &= ~(1 << (j & 0x7));
// If rip table has a valid metatile, remove that meta tile's
// reference to its rip table
- if (ripTableList[ j ].metaID != NoMetaTile) {
+ if (ripTableList[j].metaID != NoMetaTile) {
MetaTile *mt = MetaTile::metaTileAddress(
- ripTableList[ j ].metaID);
+ ripTableList[j].metaID);
RipTableID &rt = mt->ripTableID(currentMapNum);
// Assign -1 to the meta tile's rip table ID
- if (RipTable::ripTableAddress(rt) == &ripTableList[ j ])
+ if (RipTable::ripTableAddress(rt) == &ripTableList[j])
rt = -1;
}
// Build meta tile's object ripping table
- buildRipTable(rippedRoofID, &ripTableList[ j ], mt);
+ buildRipTable(rippedRoofID, &ripTableList[j], mt);
}
}
@@ -2866,9 +2852,9 @@ inline void drawMetaTiles(void) {
// coordinates of the view window on the map in X,Y (in 16 pixel units)
viewPos.x = (tileScroll.x >> tileDXShift)
- - (platformWidth * mapList[ currentMapNum ].mapSize),
+ - (platformWidth * mapList[currentMapNum].mapSize),
viewPos.y = (platformWidth
- * mapList[ currentMapNum ].mapSize
+ * mapList[currentMapNum].mapSize
* tileDX)
- tileScroll.y;
@@ -3026,13 +3012,13 @@ inline bool maskRule(TilePoint &l, TileInfo &ti) {
&& l.z >= slopeHeight)
|| l.u < -3
|| l.v < -3)
- return FALSE;
+ return false;
if (l.u > 0 && l.v > 0) {
if (l.u > thresh3 || l.v > thresh3) {
- if (l.z < slopeHeight - 8) return TRUE;
+ if (l.z < slopeHeight - 8) return true;
} else {
- if (l.z < slopeHeight - 56) return TRUE;
+ if (l.z < slopeHeight - 56) return true;
}
}
@@ -3046,11 +3032,11 @@ inline bool maskRule(TilePoint &l, TileInfo &ti) {
switch (ti.attrs.maskRule) {
case maskRuleNever:
-// if (l.z < -8 && (l.u > thresh3 || l.v > thresh3)) return TRUE;
- return FALSE;
+// if (l.z < -8 && (l.u > thresh3 || l.v > thresh3)) return true;
+ return false;
case maskRuleAlways:
- return TRUE;
+ return true;
case maskRuleUClose:
return (l.u > thresh1);
@@ -3083,7 +3069,7 @@ inline bool maskRule(TilePoint &l, TileInfo &ti) {
case maskRuleConcaveFar:
return (l.u > thresh3 || l.v > thresh3);
}
- return FALSE;
+ return false;
}
void maskPlatform(
@@ -3165,7 +3151,7 @@ void maskPlatform(
&imageData,
h,
trFlags);
- if (ti == NULL) continue;
+ if (ti == nullptr) continue;
// Compute height of character above tile.
@@ -3211,12 +3197,12 @@ void maskMetaRow(
TilePoint relLoc,
Point16 pos,
uint16 roofID) {
- WorldMapData *curMap = &mapList[ currentMapNum ];
+ WorldMapData *curMap = &mapList[currentMapNum];
int16 uOrg = coords.u * platformWidth,
vOrg = coords.v * platformWidth;
- Platform *drawList[ maxPlatforms + 1 ],
+ Platform *drawList[maxPlatforms + 1],
**put = drawList;
int16 mapSizeMask = curMap->mapSize - 1,
@@ -3259,21 +3245,21 @@ void maskMetaRow(
case edgeTypeRepeat:
coords.u = clamp(0, coords.u, mapSizeMask);
coords.v = clamp(0, coords.v, mapSizeMask);
- mtile = mapData[ clipCoords.u * curMap->mapSize + clipCoords.v ] & ~metaTileVisited;
+ mtile = mapData[clipCoords.u * curMap->mapSize + clipCoords.v] & ~metaTileVisited;
break;
case edgeTypeWrap:
- mtile = mapData[ clipCoords.u * curMap->mapSize + clipCoords.v ] & ~metaTileVisited;
+ mtile = mapData[clipCoords.u * curMap->mapSize + clipCoords.v] & ~metaTileVisited;
break;
}
- } else mtile = mapData[ clipCoords.u * curMap->mapSize + clipCoords.v ] & ~metaTileVisited;
+ } else mtile = mapData[clipCoords.u * curMap->mapSize + clipCoords.v] & ~metaTileVisited;
if (mtile >= curMap->metaCount) mtile = curMap->metaCount - 1;
- metaPtr = &metaArray[ mtile ];
+ metaPtr = &metaArray[mtile];
put = drawList;
- if (metaPtr == NULL) return;
+ if (metaPtr == nullptr) return;
// REM: Reject whole metatiles based on coords, based on
// max height
@@ -3283,7 +3269,7 @@ void maskMetaRow(
for (int i = 0; i < layerLimit; i++) {
Platform *p;
- if ((p = metaPtr->fetchPlatform(currentMapNum, i)) == NULL)
+ if ((p = metaPtr->fetchPlatform(currentMapNum, i)) == nullptr)
continue;
if (p->roofRipID() == roofID && roofID > 0) break;
@@ -3301,9 +3287,9 @@ void maskMetaRow(
*put++ = p;
}
}
- *put++ = NULL;
+ *put++ = nullptr;
- if (drawList[ 0 ] != NULL) {
+ if (drawList[0] != nullptr) {
maskPlatform(sMap, drawList, pos, relLoc, uOrg, vOrg);
}
}
@@ -3328,9 +3314,9 @@ void drawTileMask(
// coordinates of the view window on the map in X,Y (in 16 pixel units)
viewPos.x = (aPos.x >> tileDXShift)
- - (platformWidth * mapList[ currentMapNum ].mapSize),
+ - (platformWidth * mapList[currentMapNum].mapSize),
viewPos.y = (platformWidth
- * mapList[ currentMapNum ].mapSize << tileDXShift)
+ * mapList[currentMapNum].mapSize << tileDXShift)
- aPos.y;
// coordinates of the view window upper left corner in U,V
@@ -3387,7 +3373,7 @@ void drawTileMask(
#if DEBUG
-bool showTile = FALSE;
+bool showTile = false;
const uint16 lowerRightMask = 0x1111;
@@ -3448,7 +3434,7 @@ inline void drawSubTiles(const TilePoint &tp, uint16 subTileMask, uint8 *cornerH
void showAbstractTile(const TilePoint &tp, TileInfo *ti) {
TilePoint workTp = tp;
uint8 *chPtr;
- uint8 raisedCornerHeight[ 4 ] = { 0, 0, 0, 0 };
+ uint8 raisedCornerHeight[4] = { 0, 0, 0, 0 };
if (ti->combinedTerrainMask() & terrainRaised) {
if ((1L << ti->attrs.bgdTerrain) & terrainRaised) {
@@ -3500,7 +3486,7 @@ bool isTilePixelOpaque(int16 baseX, int16 baseY, int16 mapHeight, uint8 *td) {
y = mapHeight - baseY,
accum = 0;
- if (y < 0 || y >= mapHeight) return FALSE;
+ if (y < 0 || y >= mapHeight) return false;
while (y) {
// skip initial transparency
@@ -3521,17 +3507,17 @@ bool isTilePixelOpaque(int16 baseX, int16 baseY, int16 mapHeight, uint8 *td) {
// skip initial transparency
x -= *td;
td++;
- opaque = FALSE;
+ opaque = false;
while (x >= 0) {
x -= *td;
if (opaque) {
// skip transparency
td++;
- opaque = FALSE;
+ opaque = false;
} else {
// skip opaque run
td += *td + 1;
- opaque = TRUE;
+ opaque = true;
}
}
@@ -3660,8 +3646,8 @@ SurfaceType pointOnTile(TileInfo *ti,
pickCoords.v += yBound;
type = surfaceVertV;
} else {
- bool subTileToRight = FALSE,
- subTileToLeft = FALSE;
+ bool subTileToRight = false,
+ subTileToLeft = false;
if (subTile.u > 0
&& (ti->attrs.testTerrain(
@@ -3669,7 +3655,7 @@ SurfaceType pointOnTile(TileInfo *ti,
subTile.u - 1,
subTile.v))
& terrainRaised))
- subTileToLeft = TRUE;
+ subTileToLeft = true;
if (subTile.v > 0
&& (ti->attrs.testTerrain(
@@ -3677,7 +3663,7 @@ SurfaceType pointOnTile(TileInfo *ti,
subTile.u,
subTile.v - 1))
& terrainRaised))
- subTileToRight = TRUE;
+ subTileToRight = true;
if ((subTileToRight && subTileToLeft)
|| (!subTileToRight && ! subTileToLeft)) {
@@ -3725,7 +3711,7 @@ SurfaceType pointOnTile(TileInfo *ti,
} else {
// mouse is on unraised section
- bool foundPoint = FALSE;
+ bool foundPoint = false;
// Calculate the position of the first point on subtile
// to check.
@@ -3751,7 +3737,7 @@ SurfaceType pointOnTile(TileInfo *ti,
pickCoords.v += (subTile.v << subTileShift) + subUVPoint.v;
pickCoords.z = h + pointH;
floorCoords = pickCoords;
- foundPoint = TRUE;
+ foundPoint = true;
break;
}
@@ -3917,7 +3903,7 @@ bool pointOnHiddenSurface(
SurfaceType surfaceType) {
assert(surfaceType == surfaceVertU || surfaceType == surfaceVertV);
- WorldMapData *curMap = &mapList[ currentMapNum ];
+ WorldMapData *curMap = &mapList[currentMapNum];
TilePoint testCoords,
mCoords,
@@ -3933,7 +3919,7 @@ bool pointOnHiddenSurface(
// If picked point is not along edge of tile, then its not hidden
if ((surfaceType == surfaceVertV && testCoords.u != 0)
|| (surfaceType == surfaceVertU && testCoords.v != 0))
- return FALSE;
+ return false;
TileInfo *adjTile;
TilePoint adjTCoords = tileCoords;
@@ -3955,7 +3941,7 @@ bool pointOnHiddenSurface(
// If metatile of adjacent tile does not exist, the pick point
// is valid.
- if ((mt = curMap->lookupMeta(mCoords)) == NULL) return FALSE;
+ if ((mt = curMap->lookupMeta(mCoords)) == nullptr) return false;
tCoords.u = adjTCoords.u & platMask;
tCoords.v = adjTCoords.v & platMask;
@@ -3969,7 +3955,7 @@ bool pointOnHiddenSurface(
int16 h,
trFlags;
- if ((p = mt->fetchPlatform(currentMapNum, i)) == NULL)
+ if ((p = mt->fetchPlatform(currentMapNum, i)) == nullptr)
continue;
if (!(p->flags & plVisible) || platformRipped(p)) continue;
@@ -3982,7 +3968,7 @@ bool pointOnHiddenSurface(
h,
trFlags);
- if (adjTile == NULL) continue;
+ if (adjTile == nullptr) continue;
// If current tile is higher or lower than the picked point
// skip this tile.
@@ -3998,9 +3984,9 @@ bool pointOnHiddenSurface(
}
// If all platforms have been checked, the pick point is valid
- if (i >= maxPlatforms) return FALSE;
+ if (i >= maxPlatforms) return false;
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -4010,7 +3996,7 @@ TilePoint pickTile(Point32 pos,
const TilePoint &protagPos,
TilePoint *floorResult,
ActiveItemPtr *pickTAI) {
- WorldMapData *curMap = &mapList[ currentMapNum ];
+ WorldMapData *curMap = &mapList[currentMapNum];
TilePoint pickCoords,
floorCoords,
@@ -4030,7 +4016,7 @@ TilePoint pickTile(Point32 pos,
MetaTile *mt;
ActiveItemPtr bestTileTAI;
TileInfo *ti,
- *bestTile = NULL;
+ *bestTile = nullptr;
uint8 *imageData;
int i;
@@ -4096,13 +4082,13 @@ TilePoint pickTile(Point32 pos,
// While we are less than the pick altitude
while (relPos.y < zMax + tileDX + maxStepHeight - abs(relPos.x >> 1)) {
// If there is a metatile on this spot
- if (mt != NULL) {
+ if (mt != nullptr) {
// Iterate through all platforms
for (i = 0; i < maxPlatforms; i++) {
Platform *p;
StandingTileInfo sti;
- if ((p = mt->fetchPlatform(currentMapNum, i)) == NULL)
+ if ((p = mt->fetchPlatform(currentMapNum, i)) == nullptr)
continue;
if (platformRipped(p)) break;
@@ -4116,7 +4102,7 @@ TilePoint pickTile(Point32 pos,
origin,
&imageData,
sti);
- if (ti == NULL) continue;
+ if (ti == nullptr) continue;
// Reject the tile if it's too low.
if (sti.surfaceHeight + ti->attrs.terrainHeight < zMin)
@@ -4145,7 +4131,7 @@ TilePoint pickTile(Point32 pos,
pCoords,
fCoords);
- if (sti.surfaceTAG == NULL) {
+ if (sti.surfaceTAG == nullptr) {
if (surface != surfaceHoriz
&& pointOnHiddenSurface(
tCoords + origin,
@@ -4216,7 +4202,7 @@ TilePoint pickTile(Point32 pos,
// If no tile was found, return the default.
if (!bestTile) {
if (floorResult) *floorResult = floorCoords;
- if (pickTAI) *pickTAI = NULL;
+ if (pickTAI) *pickTAI = nullptr;
return pickCoords;
}
@@ -4278,7 +4264,7 @@ void cycleTiles(int32 delta) {
if (delta <= 0) return;
for (int i = 0; i < cycleCount; i++) {
- TileCycleData &tcd = (*cycleList)[ i ];
+ TileCycleData &tcd = (*cycleList)[i];
tcd.counter += tcd.cycleSpeed * delta;
if (tcd.counter >= 400) {
@@ -4300,7 +4286,7 @@ struct TileCycleArchive {
void initTileCyclingStates(void) {
cycleList = (CycleHandle)LoadResourceToHandle(tileRes, cycleID, "tile cycle data");
- if (cycleList == NULL)
+ if (cycleList == nullptr)
error("Unable to load tile cycling data");
cycleCount = RPtrSize(*cycleList) / sizeof(TileCycleData);
@@ -4315,14 +4301,14 @@ void saveTileCyclingStates(SaveFileConstructor &saveGame) {
archiveBuffer = (TileCycleArchive *)RNewPtr(
sizeof(TileCycleArchive) * cycleCount,
- NULL,
+ nullptr,
"archive buffer");
- if (archiveBuffer == NULL)
+ if (archiveBuffer == nullptr)
error("Unable to allocate tile cycle data archive buffer");
for (i = 0; i < cycleCount; i++) {
- archiveBuffer[ i ].counter = (*cycleList)[ i ].counter;
- archiveBuffer[ i ].currentState = (*cycleList)[ i ].currentState;
+ archiveBuffer[i].counter = (*cycleList)[i].counter;
+ archiveBuffer[i].currentState = (*cycleList)[i].currentState;
}
saveGame.writeChunk(
@@ -4346,16 +4332,16 @@ void loadTileCyclingStates(SaveFileReader &saveGame) {
archiveBuffer = (TileCycleArchive *)RNewPtr(
sizeof(TileCycleArchive) * cycleCount,
- NULL,
+ nullptr,
"archive buffer");
- if (archiveBuffer == NULL)
+ if (archiveBuffer == nullptr)
error("Unable to allocate tile cycle data archive buffer");
saveGame.read(archiveBuffer, sizeof(TileCycleArchive) * cycleCount);
for (i = 0; i < cycleCount; i++) {
- (*cycleList)[ i ].counter = archiveBuffer[ i ].counter;
- (*cycleList)[ i ].currentState = archiveBuffer[ i ].currentState;
+ (*cycleList)[i].counter = archiveBuffer[i].counter;
+ (*cycleList)[i].currentState = archiveBuffer[i].currentState;
}
RDisposePtr(archiveBuffer);
@@ -4365,9 +4351,9 @@ void loadTileCyclingStates(SaveFileReader &saveGame) {
// Cleanup the tile cycling state array
void cleanupTileCyclingStates(void) {
- if (cycleList != NULL) {
+ if (cycleList != nullptr) {
RDisposeHandle((RHANDLE)cycleList);
- cycleList = NULL;
+ cycleList = nullptr;
}
}
@@ -4380,7 +4366,7 @@ uint16 objRoofID(GameObject *obj) {
}
uint16 objRoofID(GameObject *obj, int16 objMapNum, const TilePoint &objCoords) {
- WorldMapData *objMap = &mapList[ objMapNum ];
+ WorldMapData *objMap = &mapList[objMapNum];
TileRegion objTileReg,
objMetaReg;
@@ -4411,7 +4397,7 @@ uint16 objRoofID(GameObject *obj, int16 objMapNum, const TilePoint &objCoords) {
meta = objMap->lookupMeta(TilePoint(metaU, metaV, 0));
- if (meta == NULL) continue;
+ if (meta == nullptr) continue;
TilePoint origin;
TileRegion relTileReg;
@@ -4443,7 +4429,7 @@ uint16 objRoofID(GameObject *obj, int16 objMapNum, const TilePoint &objCoords) {
int16 height;
int16 trFlags;
- if ((p = meta->fetchPlatform(objMapNum, i)) == NULL)
+ if ((p = meta->fetchPlatform(objMapNum, i)) == nullptr)
continue;
if (!(p->flags & plVisible) || p->roofRipID() <= 0)
@@ -4456,7 +4442,7 @@ uint16 objRoofID(GameObject *obj, int16 objMapNum, const TilePoint &objCoords) {
height,
trFlags);
- if (t != NULL && height > objHeight + 32) {
+ if (t != nullptr && height > objHeight + 32) {
tileRoofID = p->roofRipID();
tilePlatNum = i;
break;
@@ -4480,13 +4466,13 @@ uint16 objRoofID(GameObject *obj, int16 objMapNum, const TilePoint &objCoords) {
// Determine if roof over an object is ripped
bool objRoofRipped(GameObject *obj) {
- return obj->world() != NULL && objRoofID(obj) == rippedRoofID;
+ return obj->world() != nullptr && objRoofID(obj) == rippedRoofID;
}
// Determine if two objects are both under the same roof
bool underSameRoof(GameObject *obj1, GameObject *obj2) {
- return obj1->world() != NULL
- && obj2->world() != NULL
+ return obj1->world() != nullptr
+ && obj2->world() != nullptr
&& objRoofID(obj1) == objRoofID(obj2);
}
@@ -4498,7 +4484,7 @@ extern void testSprites(void);
#ifdef _WIN32
-void *LockTileDrawMapSurface(LPRECT rc = NULL);
+void *LockTileDrawMapSurface(LPRECT rc = nullptr);
bool UnlockTileDrawMapSurface(void *);
void drawTileMapToScreen(Rect16 tileRect, void *);
#include "ftawin.h"
@@ -4528,7 +4514,7 @@ void updateMainDisplay(void) {
setCurrentMap(currentWorld->mapNum);
}
- WorldMapData *curMap = &mapList[ currentMapNum ];
+ WorldMapData *curMap = &mapList[currentMapNum];
Point32 scrollCenter,
scrollDelta;
@@ -4748,7 +4734,7 @@ const int mappingRadius = 2;
void markMetaAsVisited(const TilePoint &pt) {
// If (they have cartography)
{
- WorldMapData *curMap = &mapList[ currentMapNum ];
+ WorldMapData *curMap = &mapList[currentMapNum];
uint16 *mapData = curMap->map->mapData;
TilePoint metaCoords = pt >> (tileUVShift + platShift);
@@ -4761,7 +4747,7 @@ void markMetaAsVisited(const TilePoint &pt) {
for (u = minU; u <= maxU; u++) {
for (v = minV; v <= maxV; v++) {
if ((u == minU || u == maxU) && (v == minV || v == maxV)) continue;
- mapData[ u * curMap->mapSize + v ] |= metaTileVisited;
+ mapData[u * curMap->mapSize + v] |= metaTileVisited;
}
}
}
Commit: 2fe25abd98d3983d9ab8ba858919de5505cbf2b1
https://github.com/scummvm/scummvm/commit/2fe25abd98d3983d9ab8ba858919de5505cbf2b1
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:53+02:00
Commit Message:
SAGA2: Add kDebugTiles
Changed paths:
engines/saga2/detection.cpp
engines/saga2/saga2.h
diff --git a/engines/saga2/detection.cpp b/engines/saga2/detection.cpp
index 6bc6382ff4..52f5b46458 100644
--- a/engines/saga2/detection.cpp
+++ b/engines/saga2/detection.cpp
@@ -31,6 +31,7 @@ static const DebugChannelDef debugFlagList[] = {
{Saga2::kDebugScripts, "scripts", "Debug the scripts"},
{Saga2::kDebugEventLoop, "eventloop", "Debug the event loop"},
{Saga2::kDebugInit, "init", "Debug the initialization process"},
+ {Saga2::kDebugTiles, "tiles", "Debug the tiles"},
DEBUG_CHANNEL_END
};
diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h
index 3ea9abc221..012ae2ef76 100644
--- a/engines/saga2/saga2.h
+++ b/engines/saga2/saga2.h
@@ -39,7 +39,8 @@ enum {
kDebugActors = 1 << 1,
kDebugScripts = 1 << 2,
kDebugEventLoop = 1 << 3,
- kDebugInit = 1 << 4
+ kDebugInit = 1 << 4,
+ kDebugTiles = 1 << 5
};
class Saga2Engine : public Engine {
Commit: ee8ffa657d3ecdc805be397212191a12b1657583
https://github.com/scummvm/scummvm/commit/ee8ffa657d3ecdc805be397212191a12b1657583
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:53+02:00
Commit Message:
SAGA2: Fix tile cycle initialization
Changed paths:
engines/saga2/main.cpp
engines/saga2/tile.cpp
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index c3cde675f1..e22d84297b 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -760,17 +760,19 @@ void testTileRendering() {
resImports = (ResImportTable *)LoadResource(listRes, MKTAG('I', 'M', 'P', 'O'), "res imports");
initMaps();
-
- //uint8 *img = nullptr;
- //TileInfo *ti;
- //for (int i = 0; i < 65535; ++i) {
- // ti = TileInfo::tileAddress(i, &img);
- // if (ti) {
- // debug("height: %d", ti->attrs.height);
- // Common::hexdump(img, ti->attrs.height);
- // }
- //}
-
+ initTileCyclingStates();
+
+// uint8 *img = nullptr;
+// TileInfo *ti;
+// for (int i = 0; i <= 65535; ++i) {
+// ti = TileInfo::tileAddress(i, &img);
+// if (ti) {
+// debugC(3, kDebugTiles, "terrainHeight = %d, height = %d", ti->attrs.terrainHeight, ti->attrs.height);
+// Common::hexdump(img, ti->attrs.height);
+// }
+// }
+
+ cleanupTileCyclingStates();
cleanupMaps();
}
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index f0be279538..1edbcd6895 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -45,6 +45,8 @@
#include "saga2/script.h"
#include "saga2/methods.r" // generated by SAGA
+#include "common/debug.h"
+
namespace Saga2 {
extern void writeLog(char *str);
@@ -193,7 +195,7 @@ WorldMapData *mapList; // master map data array
UByteHandle *stateArray; // Array of active item instance
// state arrays
-CycleHandle cycleList; // list of tile cycling info
+CyclePtr cycleList; // list of tile cycling info
// Platform caching management
const int platformCacheSize = 256;
@@ -278,7 +280,7 @@ TileInfo *TileInfo::tileAddress(TileID id) {
ti = tbh->tile(tileNum);
if (ti->attrs.cycleRange > 0) {
- TileCycleData &tcd = (*cycleList)[ti->attrs.cycleRange - 1];
+ TileCycleData &tcd = cycleList[ti->attrs.cycleRange - 1];
TileID2Bank(tcd.cycleList[tcd.currentState],
tileBank,
@@ -305,11 +307,12 @@ TileInfo *TileInfo::tileAddress(TileID id, uint8 **imageData) {
if (id == 0) return nullptr;
TileID2Bank(id, tileBank, tileNum);
+ debugC(3, kDebugTiles, "TileID2Bank: id = %d, tileBank = %d, tileNum = %d", id, tileBank, tileNum);
if ((tbh = tileBanks[tileBank]) == nullptr) return nullptr;
ti = tbh->tile(tileNum);
if (ti->attrs.cycleRange > 0) {
- TileCycleData &tcd = (*cycleList)[ti->attrs.cycleRange - 1];
+ TileCycleData &tcd = cycleList[ti->attrs.cycleRange - 1];
TileID2Bank(tcd.cycleList[tcd.currentState],
tileBank,
@@ -4264,7 +4267,7 @@ void cycleTiles(int32 delta) {
if (delta <= 0) return;
for (int i = 0; i < cycleCount; i++) {
- TileCycleData &tcd = (*cycleList)[i];
+ TileCycleData &tcd = cycleList[i];
tcd.counter += tcd.cycleSpeed * delta;
if (tcd.counter >= 400) {
@@ -4285,11 +4288,11 @@ struct TileCycleArchive {
// Initialize the tile cycling state array
void initTileCyclingStates(void) {
- cycleList = (CycleHandle)LoadResourceToHandle(tileRes, cycleID, "tile cycle data");
+ cycleList = (CyclePtr)LoadResource(tileRes, cycleID, "tile cycle data");
if (cycleList == nullptr)
error("Unable to load tile cycling data");
- cycleCount = RPtrSize(*cycleList) / sizeof(TileCycleData);
+ cycleCount = tileRes->size(cycleID) / sizeof(TileCycleData);
}
//-----------------------------------------------------------------------
@@ -4307,8 +4310,8 @@ void saveTileCyclingStates(SaveFileConstructor &saveGame) {
error("Unable to allocate tile cycle data archive buffer");
for (i = 0; i < cycleCount; i++) {
- archiveBuffer[i].counter = (*cycleList)[i].counter;
- archiveBuffer[i].currentState = (*cycleList)[i].currentState;
+ archiveBuffer[i].counter = cycleList[i].counter;
+ archiveBuffer[i].currentState = cycleList[i].currentState;
}
saveGame.writeChunk(
@@ -4340,8 +4343,8 @@ void loadTileCyclingStates(SaveFileReader &saveGame) {
saveGame.read(archiveBuffer, sizeof(TileCycleArchive) * cycleCount);
for (i = 0; i < cycleCount; i++) {
- (*cycleList)[i].counter = archiveBuffer[i].counter;
- (*cycleList)[i].currentState = archiveBuffer[i].currentState;
+ cycleList[i].counter = archiveBuffer[i].counter;
+ cycleList[i].currentState = archiveBuffer[i].currentState;
}
RDisposePtr(archiveBuffer);
@@ -4352,7 +4355,7 @@ void loadTileCyclingStates(SaveFileReader &saveGame) {
void cleanupTileCyclingStates(void) {
if (cycleList != nullptr) {
- RDisposeHandle((RHANDLE)cycleList);
+ free(cycleList);
cycleList = nullptr;
}
}
Commit: 5d86b6c2f6029f55b1d8f2da26ac7a09fd74dc43
https://github.com/scummvm/scummvm/commit/5d86b6c2f6029f55b1d8f2da26ac7a09fd74dc43
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:53+02:00
Commit Message:
SAGA2: Remove video routines
Changed paths:
R engines/saga2/video.cpp
R engines/saga2/video.h
R engines/saga2/videomem.cpp
R engines/saga2/videomem.h
R engines/saga2/vidhook.cpp
R engines/saga2/vidsmk.cpp
engines/saga2/itevideo.cpp
engines/saga2/itevideo.h
engines/saga2/module.mk
engines/saga2/tromode.cpp
diff --git a/engines/saga2/itevideo.cpp b/engines/saga2/itevideo.cpp
index 4439b4e3a4..e4b226ef72 100644
--- a/engines/saga2/itevideo.cpp
+++ b/engines/saga2/itevideo.cpp
@@ -24,370 +24,39 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
-#include "saga2/video.h"
-#include "saga2/config.h"
-
-#include "saga2/panel.h"
-
-#include "saga2/fta.h"
-
-#include "saga2/itevideo.h"
-#include "saga2/palette.h"
-#include "saga2/messager.h"
-
namespace Saga2 {
#define VIDEO_EXT ".SMK"
-/* ===================================================================== *
- Imports
- * ===================================================================== */
-
-extern gMouseState mouseState;
-extern gMousePointer pointer; // the actual pointer
-extern configuration globalConfig;
-extern bool cliWriteStatusF;
-extern configuration globalConfig;
-
-#ifdef _WIN32
-extern HWND hWndMain;
-extern HINSTANCE mainInst;
-#endif
-
-//-----------------------------------------------------------------------
-// External prototypes
-
-HDIGDRIVER &digitalAudioDriver(void);
-
-/* ===================================================================== *
- Locals
- * ===================================================================== */
-
-static VideoPlayer *vp = NULL;
-
-static gPort mouseVidSavePort; // for tweaking mouse backsave
-static gPort videoSavePort; // for tweaking mouse backsave
-static gPixelMap tileVidDrawMap;
-
-/* ===================================================================== *
- Code
- * ===================================================================== */
-
-//-----------------------------------------------------------------------
-// Name building hook
-
-bool nameCheck(char name[], char ext[]) {
+static bool nameCheck(char name[], char ext[]) {
size_t l = strlen(name);
if (l < 5 || 0 != scumm_stricmp(name + (l - strlen(ext)), ext))
strcat(name, ext);
- return TRUE; //fileExists(name);
+ return true; //fileExists(name);
}
-
-//-----------------------------------------------------------------------
-// Routine to play a video
-
-void startVideo(char *fileName, int x, int y, bool erase, int16, int16) {
+void startVideo(char *fileName, int x, int y) {
char file[260];
strncpy(file, fileName, 260);
nameCheck(file, VIDEO_EXT);
- vp->StartPlay(file, x, y,VideoSMK, erase);
+ //vp->StartPlay(file, x, y,VideoSMK);
}
-//-----------------------------------------------------------------------
-// General video maintainence & status check
-
bool checkVideo(void) {
- return vp->CheckPlay();
+ return true;
+ //return vp->CheckPlay();
}
-//-----------------------------------------------------------------------
-// Routine to abort a video
-
-bool abortVideo(void) {
- bool old = checkVideo();
- endVideo();
- return old;
+void abortVideo(void) {
+ //endVideo();
}
-//-----------------------------------------------------------------------
-// Routine to end a video
-
void endVideo() {
- if (vp)
- vp->EndPlay();
-}
-
-//-----------------------------------------------------------------------
-// Obsolete
-
-void beginVideo(char *, int, int, bool, int16, int16) {
-}
-
-void resumeVideo(int16, int16) {
-}
-
-void finaleVideo(int16, int16) {
-}
-
-
-//-----------------------------------------------------------------------
-// Config calls
-
-void setVideoVolume(uint8 v) {
-#if USE_SMK
- vp->vright = v;
- vp->vleft = v;
-#endif
-}
-
-bool OurBlits = TRUE;
-
-//-----------------------------------------------------------------------
-// name hook
-
-void pathHook(char *vPath, char *dPath, char *sPath) {
- char *ev;
- strcpy(vPath, ".\\");
- ev = globalConfig.videoFilePath;
- if (strlen(ev)) {
- strcpy(vPath, ev);
- }
- if (vPath[strlen(vPath) - 1] != '\\')
- strcat(vPath, "\\");
- strcpy(dPath, "");
- strcpy(sPath, "");
-}
-
-//-----------------------------------------------------------------------
-// General video initialization
-
-void initVideo(void) {
- vp = new VideoPlayer(
-#if USE_SMK
- TICKSPERSECOND, 0
-#endif
-#ifdef _WIN32
-#if USE_SMK
- ,
-#endif
- hWndMain
-#if USE_MOV
- ,
- mainInst
-#endif
-#endif
- );
- if (vp == NULL)
- error("Cannot create video player");
-#if USE_SMK && defined(_WIN32)
- if (OurBlits) {
- vp->setBuffer(640, 480);
- }
-#endif
-#if DEBUG
-#if USE_SMK
- if (cliWriteStatusF)
- vp->dumpStats = 1;
-#endif
-#endif
-
- setVideoVolume(globalConfig.soundVolume);
-}
-
-
-void cleanupVideo(void) {
- endVideo();
- if (vp)
- delete vp;
- vp = NULL;
-}
-
-
-//-----------------------------------------------------------------------
-// Video hook for blitting the buffer
-
-#ifdef __WATCOMC__
-#pragma off (unreferenced);
-#endif
-
-void bltBufferHook(const void *buffer,
- const uint16 bufferWidth,
- const uint16 bufferHeight,
- const uint16 left,
- const uint16 top,
- const uint16 width,
- const uint16 height) {
-#ifndef _WIN32
- Rect16 r(left, top, width, height);
- tileVidDrawMap.data = (uint8 *) buffer;
- tileVidDrawMap.size = Extent16(640, 480);
- videoSavePort.setMap(&tileVidDrawMap);
- //drawVideoMousePointer(r,(char *) buffer, bufferWidth);
-#endif
-}
-
-#ifdef __WATCOMC__
-#pragma on (unreferenced);
-#endif
-
-//-----------------------------------------------------------------------
-// This routine blits the video buffer foreward but the mouse pointer
-// is temporarily blitted into it
-
-void drawVideoMousePointer(
- Rect16 showZone,
- char *buffer,
- int bufferWidth
-) {
-#ifndef _WIN32
- gPixelMap *currentPtr,
- *saveMap;
- Point16 offset;
- Rect16 saveExtent,
- blitExtent;
-
- // Get the image of the pointer and the hotspot offset
- currentPtr = pointer.getImage(offset);
-
- // If pointer exists, and is in a visible state
- if (currentPtr && pointer.isShown()) {
- // Get address of pointer's backsave rect
- saveMap = pointer.getSaveMap(saveExtent);
-
- // If the pointer overlaps the tile scrolling area
- if (saveExtent.overlap(showZone)) {
- // get the intersecting area
- blitExtent = intersect(saveExtent, showZone);
-
- mouseVidSavePort.setMap(saveMap);
- mouseVidSavePort.setMode(drawModeReplace);
-
- // Blit the tile data into the backsave buffer
- mouseVidSavePort.bltPixels(
- tileVidDrawMap,
- blitExtent.x - showZone.x,
- blitExtent.y - showZone.y,
- blitExtent.x - saveExtent.x,
- blitExtent.y - saveExtent.y,
- blitExtent.width,
- blitExtent.height);
-
- // Blit the mouse pointer onto the video buffer
- TBlit(&tileVidDrawMap,
- currentPtr,
- mouseState.pos.x + offset.x - showZone.x,
- mouseState.pos.y + offset.y - showZone.y);
-
-
- // blit the video buffer to the screen
- drawPage->writePixels(showZone, (uint8 *)buffer, bufferWidth);
-
- // restore mouse area
- //videoSavePort.bltPixels(ngpm,0,0,x,y,w,h);
- videoSavePort.setMode(drawModeReplace);
- videoSavePort.bltPixels(
- *saveMap,
- blitExtent.x - saveExtent.x,
- blitExtent.y - saveExtent.y,
- blitExtent.x - showZone.x,
- blitExtent.y - showZone.y,
- blitExtent.width,
- blitExtent.height);
-
- } else {
- // blit the video buffer to the screen
- drawPage->writePixels(showZone,(uint8 *)buffer, bufferWidth);
- }
- } else {
- // blit the video buffer to the screen
- drawPage->writePixels(showZone, (uint8 *)buffer, bufferWidth);
- }
-#endif
-}
-
-
-
-//-----------------------------------------------------------------------
-// Video hook for crude mouse enabling / disabling
-
-void mouseHook(const bool) {
-}
-
-
-void videoErrorHook(
- const char *errMsg
-) {
- error("%s", errMsg);
-}
-
-
-
-//-----------------------------------------------------------------------
-// Video hook for generating filenames
-#define F_OK 0
-
-#define FileForm "%s"
-
-inline bool file_exists(const char f[]) {
-#if 0
- return (!access(f, F_OK));
-#endif
- warning("STUB: file_exists");
- return false;
-}
-
-void nameHook(char *targ, const char *bpath, const char *, const char *fname) {
- char filename[260] = "";
- assert(targ);
-
- if (strcmp(bpath, ".\\")) { //if env var set
- strcpy(filename, bpath);
- if (filename[strlen(filename) - 1] != '\\')
- strcat(filename, "\\");
- strcat(filename, fname);
- //if file not there
- if (file_exists(filename)) {
- sprintf(targ, FileForm, filename);
- return;
- }
- }
- sprintf(targ, FileForm, fname);
- return;
-}
-
-//-----------------------------------------------------------------------
-// Video hook to get the AIL digital audio driver
-
-HDIGDRIVER &audioInitHook(void) {
- return digitalAudioDriver();
-}
-
-//-----------------------------------------------------------------------
-// Video hook to free the AIL digital audio driver
-
-void audioTermHook(HDIGDRIVER) {}
-
-
-
-/* palette Hook */
-/* Override this call to set the palette manually */
-
-extern UByteHandle newPalette,
- our64Palette;
-
-void setPaletteHook(
- void *paletteMinusFour
-) {
-#ifndef _WIN32
- gPalette *gp = (gPalette *)(void *)(((uint8 *) paletteMinusFour));
- _LoadPalette((uint8 *)paletteMinusFour, 0, 256);
-#endif
+ //if (vp)
+ // vp->EndPlay();
}
} // end of namespace Saga2
diff --git a/engines/saga2/itevideo.h b/engines/saga2/itevideo.h
index e2e1723d82..f92e23ee9b 100644
--- a/engines/saga2/itevideo.h
+++ b/engines/saga2/itevideo.h
@@ -27,18 +27,17 @@
#ifndef SAGA2_ITEVIDEO_H
#define SAGA2_ITEVIDEO_H
-#include "saga2/video.h"
-#include "saga2/fta.h"
-
namespace Saga2 {
+#define TICKSPERSECOND (728L/10L)
+
void initVideo(void);
void cleanupVideo(void);
//-----------------------------------------------------------------------
// Calls for individual videos
-void startVideo(char *fileName, int x, int y, bool erase = TRUE, int16 from = 0, int16 to = 0);
+void startVideo(char *fileName, int x, int y);
bool checkVideo(void);
void endVideo(void);
@@ -46,9 +45,7 @@ void endVideo(void);
// Player configuration & other obsolete calls
void setVideoVolume(uint8 v);
-void drawVideoMousePointer(Rect16 showZone, char *buffer, int bufferWidth);
-void playVideo(char *fileName, int x, int y); //, int16 from=0, int16 to=0 );
bool abortVideo(void);
} // end of namespace Saga2
diff --git a/engines/saga2/module.mk b/engines/saga2/module.mk
index 30bb6cd1c8..3ae0eb866d 100644
--- a/engines/saga2/module.mk
+++ b/engines/saga2/module.mk
@@ -96,11 +96,7 @@ MODULE_OBJS := \
tromode.o \
uidialog.o \
vbacksav.o \
- video.o \
videobox.o \
- videomem.o \
- vidhook.o \
- vidsmk.o \
vpal.o \
vwdraw.o \
vwpage.o \
diff --git a/engines/saga2/tromode.cpp b/engines/saga2/tromode.cpp
index e17268572d..98de4c19cb 100644
--- a/engines/saga2/tromode.cpp
+++ b/engines/saga2/tromode.cpp
@@ -93,7 +93,6 @@ void waitForVideoFile(char *fileName);
static void waitForTimer(uint32 tenthsOfSecond);
static void waitForVideo(void);
void waitForInput(void);
-static void playVideo(char *fileName, int x, int y, int16 from, int16 to);
static void TroModeSetup(void);
static void TroModeCleanup(void);
@@ -326,7 +325,6 @@ static void doIntro(void) {
playAVideo(INTRO_VID1, 0, 0);
abortFlag = FALSE;
playAVideo(INTRO_VID2, 0, 0);
- // playVideo(INTRO_VID,VIDEO_X,VIDEO_Y,0,0); //if (abortFlag) { resumeAudio(); return; }
}
// ------------------------------------------------------------------------
@@ -356,80 +354,4 @@ static void doLostro(void) {
playAVideo(LOSE_VID, 0, 0);
}
-
-
-// ------------------------------------------------------------------------
-// ------------------------------------------------------------------------
-// ------------------------------------------------------------------------
-
-
-
-#if 0
-// ------------------------------------------------------------------------
-// I didn't end up using GameModes
-
-GameMode TroMode = {
- NULL, // no previous mode
- FALSE, // mode is not nestable
- TroModeSetup,
- TroModeCleanup,
- TroModeHandleTask,
- SystemKeyHandler,
-};
-
-static GameMode *prevModeStackPtr[ Max_Modes ];
-static int prevModeStackCtr;
-
-// ------------------------------------------------------------------------
-// dummy code (originally for game mode)
-
-static void TroModeHandleTask(void) {
-
-}
-
-static void goTroMode(void) {
- prevModeStackCtr = GameMode::getStack(prevModeStackPtr);
- GameMode::SetStack(&TroMode, End_List);
-}
-
-static void noTroMode(void) {
- GameMode::SetStack(prevModeStackPtr, prevModeStackCtr);
-}
-
-
-// ------------------------------------------------------------------------
-// I didn't end up using partial playback either
-
-
-void doVideo(char *fileName, int x, int y, int16 from, int16 to) {
- beginVideo(fileName, x, y, ERASE_BETWEEN, from, to);
- if (!checkVideo()) {
- endVideo();
- abortFlag = TRUE;
- return;
- }
- waitForVideo();
-}
-
-void contVideo(int16 from, int16 to) {
- resumeVideo(from, to);
- if (!checkVideo()) {
- endVideo();
- abortFlag = TRUE;
- return;
- }
- waitForVideo();
-}
-
-void lastVideo(int16 from, int16 to) {
- finaleVideo(from, to);
- if (!checkVideo()) {
- endVideo();
- abortFlag = TRUE;
- return;
- }
- //waitForVideo();
-}
-#endif
-
} // end of namespace Saga2
diff --git a/engines/saga2/video.cpp b/engines/saga2/video.cpp
deleted file mode 100644
index f4f60a8f50..0000000000
--- a/engines/saga2/video.cpp
+++ /dev/null
@@ -1,291 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * aint32 with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-// Tiny Smacker player for the Miles Sound System
-
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
-#include "saga2/std.h"
-#include "saga2/video.h"
-
-namespace Saga2 {
-
-/*****************************************************************************/
-/* globals */
-
-char tNameBuffer[260];
-
-/*****************************************************************************/
-/* ctor */
-
-VideoPlayer::VideoPlayer(
-#if USE_SMK
- uint32 maxTimer, bool UseBuffer
-#endif
-#ifdef _WIN32
-#if USE_SMK
- ,
-#endif
- HWND wnd
-#if USE_MOV
- ,
- HINSTANCE inst
-#endif
-#endif
-) {
- type = VideoNone;
-#ifdef _WIN32
- hWnd = wnd;
-#endif
- autoEnd = FALSE;
- toBuffer = FALSE;
- buffer = NULL;
- bufferWidth = bufferHeight = bufferLeft = bufferTop = 0;
- pathHook(vidPath, dgvPath, smkPath);
-#if USE_SMK
-#ifdef _WIN32
- smBuf = NULL;
-#endif
- dig = audioInitHook();
- InitSMK(maxTimer, UseBuffer);
-#endif
-#if USE_MOV
- InitMOV(wnd, inst);
-#endif
-}
-
-
-/*****************************************************************************/
-/* dtor */
-
-VideoPlayer::~VideoPlayer() {
- setType(VideoNone);
-#if USE_SMK
- TermSMK();
-#endif
-#if USE_MOV
- TermMOV();
-#endif
- audioTermHook(dig);
-}
-
-
-/*****************************************************************************/
-/* set up video buffer */
-
-void VideoPlayer::setBuffer(uint32 newWidth, uint32 newHeight) {
- bufferWidth = newWidth;
- toBuffer = (newWidth != 0 &&
- newHeight != 0);
- if (toBuffer)
- bufferHeight = newHeight;
- else {
- bufferHeight = 0;
- }
- buffer = NULL;
-}
-
-void VideoPlayer::setBuffer(uint32 newWidth, uint32 newHeight, void *buf) {
- bufferWidth = newWidth;
- toBuffer = (newWidth != 0 && newHeight != 0);
- if (toBuffer) {
- bufferHeight = newHeight;
- buffer = buf;
- } else {
- bufferHeight = 0;
- buffer = NULL;
- }
-}
-
-/*****************************************************************************/
-/* blitting call */
-
-void VideoPlayer::bltBuffer(void) {
- bltBufferHook(buffer, bufferWidth, bufferHeight, bufferLeft, bufferTop, videoWidth, videoHeight);
-}
-
-
-/*****************************************************************************/
-/* file type detection */
-
-VideoInterface VideoPlayer::detectType(char *filespec) {
- size_t l = strlen(filespec);
- if (l < 5)
- return VideoNone;
-// if ( 0==stricmp(filespec+(l-strlen(VEXT_DGV)),VEXT_DGV) )
-// return VideoDGV;
-#if USE_MOV
- if (0 == stricmp(filespec + (l - strlen(VEXT_MOV)), VEXT_MOV))
- return VideoMOV;
-#endif
-#if USE_SMK
- //if ( 0==stricmp(filespec+(l-strlen(VEXT_SMK)),VEXT_SMK) )
- return VideoSMK;
-#else
- return VideoNone;
-#endif
-}
-
-
-/*****************************************************************************/
-/* type initialization to avoid multiple plays */
-
-void VideoPlayer::setType(VideoInterface vi) {
- if (type && vi) EndPlay();
- type = vi;
-}
-
-
-/*****************************************************************************/
-/* Play */
-#ifdef __WATCOMC__
-#pragma off (unreferenced);
-#endif
-
-bool VideoPlayer::StartPlay(char *filespec,
- uint16 xxx, uint16 yyy,
-#if USE_SMK
- uint32 extraBuf,
- bool noSkip,
-#endif
- VideoInterface vi,
- bool eraseWhenDone,
- int16 from,
- int16 to
- ) {
- bool res;
- char fullPath[MAXVPATH];
-
- if (vi == VideoAutoDetect)
- vi = detectType(filespec);
- setType(vi);
- mouseHook(FALSE);
- if (toBuffer) {
- bufferLeft = xxx;
- bufferTop = yyy;
- }
- strcpy(tNameBuffer, filespec);
- switch (vi) {
-// case VideoDGV:
-// nameHook(fullPath,vidPath,dgvPath,filespec);
-// res=StartDGV(fullPath,xxx,yyy);
-// break;
-#if USE_SMK
- case VideoSMK:
- nameHook(fullPath, vidPath, smkPath, filespec);
- res = StartSMK(fullPath, xxx, yyy, extraBuf, noSkip);
- break;
-#endif
-#if USE_MOV
- case VideoMOV:
- nameHook(fullPath, vidPath, smkPath, filespec);
-
- res = StartMOV(fullPath, xxx, yyy, eraseWhenDone, from, to);
-
- break;
-#endif
- case VideoNone:
- res = FALSE;
- break;
- default:
- assert(0);
- res = FALSE;
- }
- mouseHook(TRUE);
- playing = res;
- if (!res)
- setType(VideoNone);
- else
- abort = FALSE;
- return res;
-
-}
-
-#ifdef __WATCOMC__
-#pragma on (unreferenced);
-#endif
-
-/*****************************************************************************/
-/* Update & status */
-
-bool VideoPlayer::CheckPlay(void) {
- bool res = FALSE;
- if (playing && type) {
- mouseHook(FALSE);
- autoEnd = TRUE;
- switch (type) {
-// case VideoDGV: res=CheckDGV(); break;
-#if USE_SMK
- case VideoSMK:
- res = CheckSMK();
- break;
-#endif
-#if USE_MOV
- case VideoMOV:
- res = CheckMOV();
- break;
-#endif
- case VideoNone:
- break;
- default:
- assert(0);
- }
- autoEnd = FALSE;
- mouseHook(TRUE);
- }
- return res;
-}
-
-
-/*****************************************************************************/
-/* Stop */
-
-void VideoPlayer::EndPlay(void) {
- abort = (!autoEnd);
- playing = FALSE;
- mouseHook(FALSE);
- switch (type) {
- case VideoNone:
- break;
-// case VideoDGV: EndDGV(); break;
-#if USE_SMK
- case VideoSMK:
- EndSMK();
- break;
-#endif
-#if USE_MOV
- case VideoMOV:
- EndMOV();
- break;
-#endif
- default:
- assert(0);
- }
- mouseHook(TRUE);
- setType(VideoNone);
-}
-
-} // end of namespace Saga2
diff --git a/engines/saga2/video.h b/engines/saga2/video.h
deleted file mode 100644
index 9ed6cfe5f6..0000000000
--- a/engines/saga2/video.h
+++ /dev/null
@@ -1,378 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * aint32 with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#ifndef SAGA2_VIDEO_H
-#define SAGA2_VIDEO_H
-
-#include "saga2/videomem.h"
-
-// ------------------------------------------------------------------
-// Interface selection
-
-#define USE_DGV 0
-#define USE_SMK 1
-#define USE_MOV 0
-
-
-namespace Saga2 {
-
-typedef int HDIGDRIVER;
-typedef void *Smack;
-#define SMACKAUTOEXTRA 1
-
-/* ===================================================================== *
- Definitions
- * ===================================================================== */
-
-// ------------------------------------------------------------------
-// AIL default
-
-#ifndef TICKSPERSECOND
-#define TICKSPERSECOND ( 728L/10L )
-#endif
-
-// ------------------------------------------------------------------
-// Known video interfaces
-
-enum VideoInterface {
- VideoAutoDetect = -1, // Let the interface detect type
- VideoNone, // Invalid video type
- VideoDGV, // DGV video
- VideoSMK, // Smacker video
- VideoMOV, // Smacker video
-};
-
-// ------------------------------------------------------------------
-// Extensions for video type autodetection
-
-#define VEXT_DGV ".DGV"
-#define VEXT_SMK ".SMK"
-#define VEXT_MOV ".AVI"
-// Note : don't change these without recompiling the Library
-
-// ------------------------------------------------------------------
-// sizes
-
-#define MAXVPATH 260
-// Note : don't change this without recompiling the Library
-
-
-/* ===================================================================== *
- Class Definitions
- * ===================================================================== */
-
-#ifdef __cplusplus
-
-// ------------------------------------------------------------------
-// General video playback interface object
-// - yeah virtual functions would have been better
-
-class VideoPlayer {
-private:
- VideoInterface type; // The type of video currently playing
- bool autoEnd;
- HDIGDRIVER dig;
- bool toBuffer;
- uint32 bufferWidth, bufferHeight;
- bool StartFrame; // time to show nother frame?
-#ifdef _WIN32
- HWND hWnd;
-#endif
-
-#if USE_DGV
- // DGV internal variables
- char pal[256 * 3]; // palette?
- uint16 newcount; // ???
- uint16 x, y, lx, ly, x1, yy1, x2, y2; // assorted screen positions
- Image Im; // ???
- bool OldSoundOn; // ???
- bool dopal; // need new palette?
- bool norebuild; // ???
- ChunkyMap *DGVChunkyMap; // pointer to DGV structure
- ChunkyMap BackChunkyMap; // The thickerer chocolate bar
-#endif
-#if USE_SMK
- // SMK internal variables
- uint8 lvleft, lvright; // current volume levels
- Smack *smk; // pointer to smacker structure
- uint32 i; // current frame
-#ifdef _WIN32
- SmackBuf *smBuf;
-#endif
-#endif
-#if USE_MOV
- // MOV internal variables
- HINSTANCE hInst;
- HWND mciWnd;
- uint16 tox, toy;
-#endif
-
-
-public:
-
- void *buffer;
- bool playing; // whether or not a video is playing
- bool abort; // terminate immediately
- char vidPath[MAXVPATH]; // base path for videos
- char dgvPath[MAXVPATH]; // added path for dgv videos
- char smkPath[MAXVPATH]; // added path for smk videos
- uint32 bufferLeft, bufferTop;
- uint32 videoWidth, videoHeight;
-#if USE_DGV
- // DGV public varaiables
- bool asBack; // show DGV as background pic only
-#endif
-#if USE_SMK
- // SMK public vars
- uint8 vright; // right volume
- uint8 vleft; // wrong volume
- uint8 changePalette; // palette changes enabled
- uint8 restoreChangePalette; // palette changes enabled
- bool dumpStats; // If enabled a .DMP file w/ stats is generated for each video
-#endif
-#if USE_MOV
- // MOV public
-#endif
-
-private:
- void setType(VideoInterface vi);
-#if USE_DGV
- // DGV specific routines
- void InitDGV(void);
- bool StartDGV(char *filespec, uint16 xxx, uint16 yyy);
- bool CheckDGV(void);
- void EndDGV(void);
- void TermDGV(void);
-#endif
-#if USE_SMK
- // SMK specific routines
- void InitSMK(uint32 maxTimer, bool UseBuffer = TRUE);
- bool StartSMK(char *filespec, uint16 xxx, uint16 yyy, uint32 extraBuf = SMACKAUTOEXTRA, bool noSkip = FALSE);
- bool CheckSMK(void);
- void EndSMK(void);
- void TermSMK(void);
-#endif
-#if USE_MOV
- // MOV specific routines
- void InitMOV(HWND hWnd, HINSTANCE inst);
- bool StartMOV(char *filespec, uint16 xxx, uint16 yyy, bool eraseWhenDone, int16 from = 0, int16 to = 0);
- bool CheckMOV(void);
- void EndMOV(void);
- void TermMOV(void);
-public:
- void BeginMOV(char *fileName, int x, int y, bool erase = TRUE, int16 from = 0, int16 to = 0);
- void ResumeMOV(int16 from = 0, int16 to = 0);
- void FinaleMOV(int16 from = 0, int16 to = 0);
-#endif
-
-public:
- VideoPlayer(
-#if USE_SMK
- uint32 maxTimer, bool UseBuffer
-#endif
-#ifdef _WIN32
-#if USE_SMK
- ,
-#endif
- HWND wnd
-#if USE_MOV
- ,
- HINSTANCE inst
-#endif
-#endif
- );
- ~VideoPlayer();
-
- // memory management mapping
-
- void *operator new (size_t s) {
- return videoAlloc(s, "VidPlayer");
- }
- void operator delete (void *m) {
- videoFree(m);
- }
-
- // detectType attempts to determine the video type based
- // on the filename extension
-
- VideoInterface detectType(char *filespec);
-
- // StartPlay attempts to open and start playing the video
- // file named in filespec at the given coordinates
- // if no file type is given detectType() will be used
- // returns true if the video was successfully started
-
- bool StartPlay(char *filespec, // Filename of video
- uint16 xxx, uint16 yyy, // x,y of upper left corner
-#if USE_SMK
- uint32 extraBuf = SMACKAUTOEXTRA,
- bool noSkip = FALSE,
-#endif
- VideoInterface vi = VideoAutoDetect,
- bool eraseWhenDone = TRUE,
- int16 from = 0, int16 to = 0
- ); // video type
-
- // CheckPlay is a video maintainence call. It takes care of
- // any updating the video interface must do to the screen, sound
- // palettes etc. It can be safely called whether a video is
- // playing or not. This call should be put in a main event loop
- // or given itsown thread.
- // It returns true if a video is playing
-
- bool CheckPlay(void);
-
- // EndPlay is a cleanup routine for the video interfaces. It is
- // usually called automatically by CheckPlay at the end of
- // a video, but can be called manually to abort a video
-
- void EndPlay(void);
-
- // setBuffer tells the player that videos should be played into
- // a memory buffer of a given size. If 0 is passed for either
- // parameter, the screen will be used. This currently only
- // works for SMK files
-
- void setBuffer(uint32 newWidth, uint32 newHeight);
-
- // this version explicitly sets the buffer to use
-
- void setBuffer(uint32 newWidth, uint32 newHeight, void *buffer);
-
- // bltBuffer is called when a buffer is being used to blt that
- // buffer to the screen.
-
- void bltBuffer(void);
-
-#if USE_SMK
- Smack *getSmack(void) {
- return smk;
- }
-#ifdef _WIN32
- LRESULT OnPaletteChanged(HWND win_handle, WORD wparam, LONG lparam);
- LRESULT OnQueryNewPalette(HWND win_handle, WORD wparam, LONG lparam);
-#endif
-#endif
-
-};
-#endif
-
-
-/*****************************************************************************/
-/* Global DGV stuff */
-/*****************************************************************************/
-
-#if USE_DGV
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern uint16 VGAScreenWidth,
- VGAScreenHeight;
-extern bool SoundOn;
-
-#ifdef __cplusplus
-}
-#endif
-#endif
-
-/*****************************************************************************/
-/* External Hooks */
-/* To override default behaviors you can create routines with these */
-/* prototypes that perform the appropriate function */
-/*****************************************************************************/
-
-/* Mouse Hook */
-/* Use this routine to eliminate mouse droppings */
-/* put your local mouse pointer enable/disable code in it */
-
-void mouseHook(
- const bool // TRUE=enable FALSE=disable
-) ;
-
-/* Path Hook */
-/* Use this routine to initialize the base paths for video files */
-/* See the name hook for more on how these are used */
-
-void pathHook(
- char *vPath, // base path for all video files, default=".\"
- char *dPath, // dgv file path modifier default=""
- char *sPath // smk file path modifier default=""
-) ;
-
-/* Name Hook */
-/* Use this routine to change how filenames are built */
-/* By default the three sections are simply concatenated into the target */
-/* This can be modified if desired */
-/* This can be modified if desired */
-
-
-void nameHook(
- char *targ, // copy a valid filename into here
- const char *bpath, // vPath from pathHook
- const char *tpath, // either dPath or sPath from pathHook (dgv or smk)
- const char *fname // the filename that the we are about to try to open
-);
-
-/* Audio Hooks */
-/* Use these routine to initialize audio somewhere else in the code. */
-
-#ifdef __cplusplus
-HDIGDRIVER &audioInitHook(void);
-void audioTermHook(HDIGDRIVER d);
-#endif
-
-/* blt Hook */
-/* Override this call to use an external blitting routine */
-
-void bltBufferHook(
- const void *buffer,
- const uint16 bufferWidth,
- const uint16 bufferHeight,
- const uint16 left,
- const uint16 top,
- const uint16 width,
- const uint16 height
-);
-
-
-/* palette Hook */
-/* Override this call to set the palette manually */
-
-void setPaletteHook(
- void *paletteMinusFour
-);
-
-/* error Hook */
-/* This hook is called to deal with memory allocation errors */
-
-void videoErrorHook(
- const char *errMsg
-);
-
-} // end of namespace Saga2
-
-#endif
diff --git a/engines/saga2/videomem.cpp b/engines/saga2/videomem.cpp
deleted file mode 100644
index 313efdf301..0000000000
--- a/engines/saga2/videomem.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
-#include "saga2/std.h"
-#include "saga2/videomem.h"
-
-namespace Saga2 {
-
-void *videoAlloc(size_t s, char desc[], bool noFail, bool noSwap) {
- warning("STUB: videoAlloc()");
-}
-
-void videoFree(void *mem, bool unLock) {
- warning("STUB: videoFree()");
-}
-
-} // end of namespace Saga2
diff --git a/engines/saga2/videomem.h b/engines/saga2/videomem.h
deleted file mode 100644
index 3e537a6222..0000000000
--- a/engines/saga2/videomem.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * aint32 with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#ifndef SAGA2_VIDEOMEM_H
-#define SAGA2_VIDEOMEM_H
-
-namespace Saga2 {
-
-#ifndef _WIN32
-#define VIDMEM_LOCK_DEFAULT TRUE
-#else
-#define VIDMEM_LOCK_DEFAULT FALSE
-#endif
-
-/* ===================================================================== *
- Prototypes
- * ===================================================================== */
-
-#ifdef __cplusplus
-void *videoAlloc(size_t s, char desc[], bool noFail = FALSE, bool noSwap = VIDMEM_LOCK_DEFAULT);
-void videoFree(void *mem, bool unLock = VIDMEM_LOCK_DEFAULT);
-#else
-void *videoAlloc(size_t s, char desc[], bool noFail, bool noSwap);
-void videoFree(void *mem, bool unLock);
-#endif
-
-} // end of namespace Saga2
-
-#endif
diff --git a/engines/saga2/vidhook.cpp b/engines/saga2/vidhook.cpp
deleted file mode 100644
index fd0337147b..0000000000
--- a/engines/saga2/vidhook.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * aint32 with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
-#include "saga2/std.h"
-#include "saga2/video.h"
-
-namespace Saga2 {
-
-/*****************************************************************************/
-/* Constants used for paths */
-
-const char DEFAULT_VID_PATH[] = ".\\";
-const char DEFAULT_DGV_PATH[] = "";
-const char DEFAULT_SMK_PATH[] = "";
-
-
-/*****************************************************************************/
-/* pre blit / post blit */
-
-void mouseHook(const bool) {
-}
-
-#ifndef _WIN32
-/*****************************************************************************/
-/* path defaults */
-
-void pathHook(char *vPath, char *dPath, char *sPath) {
- strcpy(vPath, DEFAULT_VID_PATH); // base path for videos
- strcpy(dPath, DEFAULT_DGV_PATH); // base path for videos
- strcpy(sPath, DEFAULT_SMK_PATH); // base path for videos
-}
-
-/*****************************************************************************/
-/* path building */
-
-void nameHook(char *targ, const char *bpath, const char *tpath, const char *fname) {
- if (NULL == strchr(fname, '\\') && NULL == strchr(fname, ':')) {
- strcpy(targ, bpath);
- strcat(targ, tpath);
- } else
- targ[0] = '\0';
- strcat(targ, fname);
-}
-
-/*****************************************************************************/
-/* AIL hooks */
-
-HDIGDRIVER &audioInitHook(void) {
- HDIGDRIVER *d = new HDIGDRIVER;
-#if 0
-#ifndef _WIN32
- AIL_startup();
- AIL_install_DIG_INI(d);
- if (*d == NULL)
- AIL_shutdown();
-#endif
-
-#endif
- return *d;
-}
-
-void audioTermHook(HDIGDRIVER d) {
-#if 0
-#ifndef _WIN32
- if (d)
- AIL_uninstall_DIG_driver(d);
- AIL_shutdown();
-#endif
-#endif
-}
-
-
-/*****************************************************************************/
-/* Blitting */
-
-void bltBufferHook(
- const void *buffer,
- const uint16 bufferWidth,
- const uint16 bufferHeight,
- const uint16 left,
- const uint16 top,
- const uint16 width,
- const uint16 height
-) {
-}
-
-/*****************************************************************************/
-/* Palette Setting */
-
-#ifndef _WIN32
-void setPaletteHook(
- void *paletteMinusFour
-) {
-#if 0
- cSVGASetPalette(paletteMinusFour);
-#endif
-}
-#endif
-
-/*****************************************************************************/
-/* Error Hook */
-
-void videoErrorHook(
- const char *errMsg
-) {
- fprintf(stderr, errMsg);
-}
-#endif
-
-} // end of namespace Saga2
diff --git a/engines/saga2/vidsmk.cpp b/engines/saga2/vidsmk.cpp
deleted file mode 100644
index 52518c1501..0000000000
--- a/engines/saga2/vidsmk.cpp
+++ /dev/null
@@ -1,297 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * aint32 with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
-#include "saga2/std.h"
-#include "saga2/video.h"
-
-namespace Saga2 {
-
-// ------------------------------------------------------------------
-// Make sure we're actually using it
-
-#if USE_SMK
-
-/* ===================================================================== *
- definitions
- * ===================================================================== */
-
-#ifndef _WIN32
-#define LOCK_MEM TRUE
-#else
-#define LOCK_MEM FALSE
-#endif
-
-/* ===================================================================== *
- declarations
- * ===================================================================== */
-
-extern char tNameBuffer[]; // filename storage for debugging
-
-char errMsg[80];
-
-/* ===================================================================== *
- VideoPlayer object implementation
- * ===================================================================== */
-
-// ------------------------------------------------------------------
-// initialization
-
-#ifndef _WIN32
-void VideoPlayer::InitSMK(uint32 maxTimer, bool UseBuffer)
-#else
-void VideoPlayer::InitSMK(uint32, bool)
-#endif
-{
- vleft = 128;
- vright = 128;
- changePalette = 1;
- restoreChangePalette = 1;
- dumpStats = FALSE;
- smk = NULL;
-
- warning("STUB: InitSMK");
-
-#if 0
- if (dig)
- //SetSmackAILDigDriver(dig,maxTimer);
-#ifndef _WIN32
- SmackSoundUseMSS(dig, maxTimer);
-#else
- SmackSoundUseMSS(dig);
-#endif
- else
-#ifndef _WIN32
- SmackSoundUseMSS(NULL, maxTimer);
-#else
- SmackSoundUseMSS(NULL);
-#endif
-#ifndef _WIN32
- if (!UseBuffer) {
- //SmackInitSVGA();
- SVGADetect(1);
- }
-#endif
-
-#endif
-}
-
-// ------------------------------------------------------------------
-// cleanup
-
-void VideoPlayer::TermSMK(void) {
-}
-
-// ------------------------------------------------------------------
-// palette twiddling for Windows
-
-#ifdef _WIN32
-
-LRESULT VideoPlayer::OnPaletteChanged(HWND win_handle, WORD wparam, LONG lparam) {
- if ((HWND)wparam == win_handle)
- return (0L);
- return ((smBuf) ? SmackBufferSetPalette(smBuf) : 0);
-}
-
-LRESULT VideoPlayer::OnQueryNewPalette(HWND win_handle, WORD wparam, LONG lparam) {
- return ((smBuf) ? SmackBufferSetPalette(smBuf) : 0);
-}
-
-#endif
-
-// ------------------------------------------------------------------
-// START command
-
-bool VideoPlayer::StartSMK(char *filespec,
- uint16 xxx, uint16 yyy,
- uint32 extraBuf,
- bool noSkip
- ) {
- warning("STUB: StartSMK");
- return TRUE;
-#if 0
-
-#ifdef _WIN32
- toBuffer = FALSE;
- smBuf = SmackBufferOpen(hWnd, SMACKAUTOBLIT, bufferWidth, bufferHeight, 0, 0);
- if (smBuf == NULL) {
- return FALSE;
- }
-#endif
- //smk=SmackOpen(filespec,SMACKTRACKS ,0); //| (noSkip ? SMACKNOSKIP : 0), extraBuf);
-
- smk = SmackOpen(filespec, SMACKTRACKS | (noSkip ? SMACKNOSKIP : 0), extraBuf);
-
- if (smk) {
-#ifndef _WIN32
- if (toBuffer) {
- buffer = videoAlloc(bufferWidth * bufferHeight, "VidWorkBuf");
- if (buffer == NULL) {
- SmackClose(smk);
- smk = NULL;
- return FALSE;
- }
- }
- if (toBuffer)
- SmackToBuffer(smk, 0, 0, bufferWidth, bufferHeight, buffer, FALSE);
- else {
- SetSmackerSVGA();
- SmackToScreen(smk, xxx, yyy, SVGABytesPS(), SVGAWinTbl(), SVGASetBank());
- }
-#else
- SmackToBuffer(smk, (smBuf->Width - smk->Width) / 2, (smBuf->Height - smk->Height) / 2, smBuf->Width, smBuf->Height, smBuf->Buffer, (u8)smBuf->Reversed);
- while (SmackToBufferRect(smk, smBuf->SurfaceType)) {
- SmackBufferBlit(smBuf, 0, 0, 0, smk->LastRectx, smk->LastRecty, smk->LastRectw, smk->LastRecth);
- }
-#endif
- videoWidth = smk->Width;
- videoHeight = smk->Height;
- StartFrame = TRUE;
- //SmackVolume(smk,SMACKTRACK1,vleft,vright);
- lvleft = vleft;
- lvright = vright;
- i = 1;
- return TRUE;
- }
- return FALSE;
-
-#endif
-}
-
-// ------------------------------------------------------------------
-// CHECK command
-
-bool VideoPlayer::CheckSMK(void) {
-#if 0
- assert(smk);
- if (abort)
- i = smk->Frames + 1;
- if (i > smk->Frames) {
- EndPlay();
- return FALSE;
- }
- if (StartFrame) {
-#ifndef _WIN32
- if (smk->NewPalette && changePalette)
- //setPaletteHook((smk->NewPalette==1)?smk->Col1:smk->Col2);
- setPaletteHook(smk->Palette);
-#else
- if (smk->NewPalette) {
- SmackBufferNewPalette(smBuf, smk->Palette, 0);
- SmackColorRemap(smk, smBuf->Palette, smBuf->MaxPalColors, smBuf->PalType);
- }
-#endif
-
- SmackDoFrame(smk);
-
-#ifndef _WIN32
- if (toBuffer)
- bltBuffer();
-#else
- while (SmackToBufferRect(smk, smBuf->SurfaceType)) {
- if (SmackBufferBlit(smBuf, 0, 0, 0, smk->LastRectx, smk->LastRecty, smk->LastRectw, smk->LastRecth))
- break;
- }
-#endif
- StartFrame = FALSE;
- if (i < smk->Frames)
- SmackNextFrame(smk);
- i++;
- }
- if (lvleft != vleft || lvright != vright) {
- //SmackVolume(smk,SMACKTRACK1,vleft,vright);
- lvleft = vleft;
- lvright = vright;
- }
- if (!SmackWait(smk))
- StartFrame = TRUE;
-
-#endif
- warning("STUB: CheckSMK");
- return TRUE;
-}
-
-
-uint8 blackPal[1024];
-
-// ------------------------------------------------------------------
-// END command
-
-void VideoPlayer::EndSMK(void) {
-#if 0
- SmackSum ss;
- FILE *fp;
- char dNameBuffer[260];
- if (smk) {
- if (!abort) {
- while (SmackWait(smk));
- }
- if (dumpStats) {
- SmackSummary(smk, &ss);
- strcpy(dNameBuffer, tNameBuffer);
- strcpy(dNameBuffer + strlen(dNameBuffer) - 3, "DMP");
- if (NULL != (fp = fopen(dNameBuffer, "wt"))) {
- fprintf(fp, "File : %s\n", tNameBuffer);
- fprintf(fp, "Total time : %d\n", ss.TotalTime);
- fprintf(fp, "ms/100 frms: %d\n", ss.MS100PerFrame);
- fprintf(fp, "Total frms : %d\n", ss.TotalFrames);
- fprintf(fp, "Skippd frms: %d\n", ss.SkippedFrames);
- fprintf(fp, "Blit Time : %d\n", ss.TotalBlitTime);
- fprintf(fp, "Read Time : %d\n", ss.TotalReadTime);
- fprintf(fp, "Decomp Time: %d\n", ss.TotalReadTime);
- fclose(fp);
- }
- }
- memset(blackPal, 1024, '\0');
- setPaletteHook((void *)blackPal);
- SmackClose(smk);
- smk = NULL;
- if (toBuffer) {
- if (buffer)
- videoFree(buffer);
- }
-#ifndef _WIN32
- else {
- ClearSmackerSVGA();
- }
-#endif
- if (restoreChangePalette)
- changePalette = 1;
- }
-#ifdef _WIN32
- if (smBuf) {
- SmackBufferClose(smBuf);
- smBuf = NULL;
- }
-#endif
-#endif
- warning("STUB: EndSMK");
-}
-
-#endif
-
-} // end of namespace Saga2
Commit: c9f74624ac44c752eb818e7fb84522e66e4eda08
https://github.com/scummvm/scummvm/commit/c9f74624ac44c752eb818e7fb84522e66e4eda08
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:53+02:00
Commit Message:
SAGA2: Rename itevideo.cpp -> video.cpp and move it to Saga2Engine
Changed paths:
A engines/saga2/video.cpp
R engines/saga2/itevideo.cpp
R engines/saga2/itevideo.h
engines/saga2/gamemode.cpp
engines/saga2/main.cpp
engines/saga2/module.mk
engines/saga2/saga2.h
engines/saga2/tromode.cpp
engines/saga2/uidialog.cpp
engines/saga2/videobox.cpp
diff --git a/engines/saga2/gamemode.cpp b/engines/saga2/gamemode.cpp
index 5fa08e6ed2..20ac114c4c 100644
--- a/engines/saga2/gamemode.cpp
+++ b/engines/saga2/gamemode.cpp
@@ -41,7 +41,6 @@
#include "saga2/player.h"
#include "saga2/cmisc.h"
#include "saga2/annoy.h"
-#include "saga2/itevideo.h"
namespace Saga2 {
diff --git a/engines/saga2/itevideo.h b/engines/saga2/itevideo.h
deleted file mode 100644
index f92e23ee9b..0000000000
--- a/engines/saga2/itevideo.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * aint32 with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#ifndef SAGA2_ITEVIDEO_H
-#define SAGA2_ITEVIDEO_H
-
-namespace Saga2 {
-
-#define TICKSPERSECOND (728L/10L)
-
-void initVideo(void);
-void cleanupVideo(void);
-
-//-----------------------------------------------------------------------
-// Calls for individual videos
-
-void startVideo(char *fileName, int x, int y);
-bool checkVideo(void);
-void endVideo(void);
-
-//-----------------------------------------------------------------------
-// Player configuration & other obsolete calls
-
-void setVideoVolume(uint8 v);
-
-bool abortVideo(void);
-
-} // end of namespace Saga2
-
-#endif
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index e22d84297b..3d275125d4 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -37,7 +37,6 @@
#include "saga2/transit.h"
#include "saga2/player.h"
#include "saga2/calender.h"
-#include "saga2/itevideo.h"
#include "saga2/tile.h"
#include "saga2/messager.h"
#include "saga2/intrface.h"
@@ -357,7 +356,7 @@ void processEventLoop(bool updateScreen) {
// Handle updating of the display.
debugC(1, kDebugEventLoop, "EventLoop: display update");
- if (!checkVideo()) {
+ if (!g_vm->checkVideo()) {
displayUpdate();
}
diff --git a/engines/saga2/module.mk b/engines/saga2/module.mk
index 3ae0eb866d..0f74a3acb5 100644
--- a/engines/saga2/module.mk
+++ b/engines/saga2/module.mk
@@ -37,7 +37,6 @@ MODULE_OBJS := \
input.o \
interp.o \
intrface.o \
- itevideo.o \
keybored.o \
loadmsg.o \
loadsave.o \
@@ -96,6 +95,7 @@ MODULE_OBJS := \
tromode.o \
uidialog.o \
vbacksav.o \
+ video.o \
videobox.o \
vpal.o \
vwdraw.o \
diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h
index 012ae2ef76..d2fd2d63ac 100644
--- a/engines/saga2/saga2.h
+++ b/engines/saga2/saga2.h
@@ -43,6 +43,8 @@ enum {
kDebugTiles = 1 << 5
};
+#define TICKSPERSECOND (728L/10L)
+
class Saga2Engine : public Engine {
public:
Saga2Engine(OSystem *syst);
@@ -59,6 +61,12 @@ public:
void loadExeResources();
void freeExeResources();
+ // itevideo.cpp
+ void startVideo(char *fileName, int x, int y);
+ bool checkVideo(void);
+ void endVideo(void);
+ void abortVideo(void);
+
public:
// We need random numbers
Common::RandomSource *_rnd;
diff --git a/engines/saga2/tromode.cpp b/engines/saga2/tromode.cpp
index 98de4c19cb..72a182881d 100644
--- a/engines/saga2/tromode.cpp
+++ b/engines/saga2/tromode.cpp
@@ -32,7 +32,6 @@
#include "saga2/cmisc.h"
#include "saga2/input.h"
#include "saga2/fta.h"
-#include "saga2/itevideo.h"
#include "saga2/videos.h"
#include "saga2/player.h"
#include "saga2/tromode.h"
@@ -209,7 +208,7 @@ static void TroModeSetup(void) {
// Exit
static void TroModeCleanup(void) {
- endVideo();
+ g_vm->endVideo();
popVidState();
displayEnable(PlayingVideo);
blackOut();
@@ -280,7 +279,7 @@ static void waitForTimer(uint32 tenthsOfSecond) {
// Wait till a video completes
static void waitForVideo(void) {
- while (checkVideo()) {
+ while (g_vm->checkVideo()) {
SystemEventLoop();
if (abortFlag)
return;
@@ -304,9 +303,9 @@ void waitForInput(void) {
* ===================================================================== */
static void playAVideo(char *fileName, int x, int y) { //, int16 from, int16 to )
- startVideo(fileName, x, y); //, ERASE_BETWEEN, 0,0 );
- if (!checkVideo()) {
- endVideo();
+ g_vm->startVideo(fileName, x, y);
+ if (!g_vm->checkVideo()) {
+ g_vm->endVideo();
abortFlag = TRUE;
return;
}
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index 1f7648336f..9bcaad3087 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -39,7 +39,6 @@
#include "saga2/gtextbox.h"
#include "saga2/loadsave.h"
#include "saga2/script.h"
-#include "saga2/itevideo.h"
#include "saga2/audio.h"
#include "saga2/annoy.h"
#include "saga2/uidialog.h"
diff --git a/engines/saga2/itevideo.cpp b/engines/saga2/video.cpp
similarity index 87%
rename from engines/saga2/itevideo.cpp
rename to engines/saga2/video.cpp
index e4b226ef72..42ed317a8c 100644
--- a/engines/saga2/itevideo.cpp
+++ b/engines/saga2/video.cpp
@@ -30,14 +30,14 @@ namespace Saga2 {
#define VIDEO_EXT ".SMK"
-static bool nameCheck(char name[], char ext[]) {
+static bool nameCheck(char name[], const char ext[]) {
size_t l = strlen(name);
if (l < 5 || 0 != scumm_stricmp(name + (l - strlen(ext)), ext))
strcat(name, ext);
return true; //fileExists(name);
}
-void startVideo(char *fileName, int x, int y) {
+void Saga2Engine::startVideo(char *fileName, int x, int y) {
char file[260];
strncpy(file, fileName, 260);
nameCheck(file, VIDEO_EXT);
@@ -45,16 +45,16 @@ void startVideo(char *fileName, int x, int y) {
//vp->StartPlay(file, x, y,VideoSMK);
}
-bool checkVideo(void) {
+bool Saga2Engine::checkVideo(void) {
return true;
//return vp->CheckPlay();
}
-void abortVideo(void) {
+void Saga2Engine::abortVideo(void) {
//endVideo();
}
-void endVideo() {
+void Saga2Engine::endVideo() {
//if (vp)
// vp->EndPlay();
}
diff --git a/engines/saga2/videobox.cpp b/engines/saga2/videobox.cpp
index f9f0de930a..9bb7944d96 100644
--- a/engines/saga2/videobox.cpp
+++ b/engines/saga2/videobox.cpp
@@ -29,7 +29,6 @@
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/videobox.h"
-#include "saga2/itevideo.h"
namespace Saga2 {
@@ -58,11 +57,12 @@ CVideoBox::CVideoBox(const Rect16 &box,
CVideoBox::~CVideoBox(void) {
// remove the resource handle
- if (decRes) resFile->disposeContext(decRes);
+ if (decRes)
+ resFile->disposeContext(decRes);
decRes = NULL;
// stop video if not done
- abortVideo();
+ g_vm->abortVideo();
}
void CVideoBox::deactivate(void) {
@@ -156,13 +156,13 @@ int16 CVideoBox::openVidBox(char *fileName) {
ModalWindow::open();
// start the video playback
- startVideo(fileName, x + borderWidth, y + borderWidth);
+ g_vm->startVideo(fileName, x + borderWidth, y + borderWidth);
// run this modal event loop
//EventLoop( rInfo.running, TRUE );
- rInfo.running = checkVideo();
+ rInfo.running = g_vm->checkVideo();
while (rInfo.running)
- rInfo.running = checkVideo();
+ rInfo.running = g_vm->checkVideo();
// get the result
return rInfo.result;
Commit: 6e47bc1dcdb9efbe0be23732a959304f05bf06b8
https://github.com/scummvm/scummvm/commit/6e47bc1dcdb9efbe0be23732a959304f05bf06b8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:53+02:00
Commit Message:
SAGA2: Implement SMK videoplayer and play intro video
Changed paths:
engines/saga2/saga2.cpp
engines/saga2/saga2.h
engines/saga2/video.cpp
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index 215dd52dd7..1b137650ad 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -59,6 +59,9 @@ Saga2Engine::Saga2Engine(OSystem *syst)
g_vm = this;
+ _smkDecoder = nullptr;
+ _videoX = _videoY = 0;
+
SearchMan.addSubDirectoryMatching(gameDataDir, "res");
debug("Saga2Engine::Saga2Engine");
@@ -85,7 +88,12 @@ Common::Error Saga2Engine::run() {
loadExeResources();
- loadingScreen();
+ startVideo("INTRO", 0, 0);
+ while (!shouldQuit() && checkVideo()) {
+ Common::Event event;
+ g_system->getEventManager()->pollEvent(event);
+ g_system->delayMillis(10);
+ }
if (openResources()) {
testOpenImage();
diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h
index d2fd2d63ac..28f0ad1a9e 100644
--- a/engines/saga2/saga2.h
+++ b/engines/saga2/saga2.h
@@ -29,6 +29,9 @@
#include "engines/engine.h"
#include "gui/debugger.h"
+namespace Video {
+class SmackerDecoder;
+};
namespace Saga2 {
@@ -62,7 +65,7 @@ public:
void freeExeResources();
// itevideo.cpp
- void startVideo(char *fileName, int x, int y);
+ void startVideo(const char *fileName, int x, int y);
bool checkVideo(void);
void endVideo(void);
void abortVideo(void);
@@ -70,6 +73,10 @@ public:
public:
// We need random numbers
Common::RandomSource *_rnd;
+
+private:
+ Video::SmackerDecoder *_smkDecoder;
+ int _videoX, _videoY;
};
extern Saga2Engine *g_vm;
diff --git a/engines/saga2/video.cpp b/engines/saga2/video.cpp
index 42ed317a8c..aa9d0e7958 100644
--- a/engines/saga2/video.cpp
+++ b/engines/saga2/video.cpp
@@ -24,6 +24,9 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#include "graphics/palette.h"
+#include "video/smk_decoder.h"
+
#include "saga2/std.h"
namespace Saga2 {
@@ -34,29 +37,62 @@ static bool nameCheck(char name[], const char ext[]) {
size_t l = strlen(name);
if (l < 5 || 0 != scumm_stricmp(name + (l - strlen(ext)), ext))
strcat(name, ext);
- return true; //fileExists(name);
+ return true;
}
-void Saga2Engine::startVideo(char *fileName, int x, int y) {
+void Saga2Engine::startVideo(const char *fileName, int x, int y) {
char file[260];
- strncpy(file, fileName, 260);
+ strcpy(file, "video/");
+ strncat(file, fileName, 260);
nameCheck(file, VIDEO_EXT);
- //vp->StartPlay(file, x, y,VideoSMK);
+ if (!_smkDecoder)
+ _smkDecoder = new Video::SmackerDecoder();
+
+ if (!_smkDecoder->loadFile(file)) {
+ warning("startVideo: Cannot open file %s", file);
+
+ return;
+ }
+
+ _videoX = x;
+ _videoY = y;
+
+ _smkDecoder->start();
}
bool Saga2Engine::checkVideo(void) {
+ if (!_smkDecoder)
+ return false;
+
+ if (_smkDecoder->endOfVideo())
+ return false;
+
+ if (_smkDecoder->needsUpdate()) {
+ const Graphics::Surface *frame = _smkDecoder->decodeNextFrame();
+ if (frame) {
+ g_system->copyRectToScreen(frame->getPixels(), frame->pitch, _videoX, _videoY, frame->w, frame->h);
+
+ if (_smkDecoder->hasDirtyPalette())
+ g_system->getPaletteManager()->setPalette(_smkDecoder->getPalette(), 0, 256);
+
+ g_system->updateScreen();
+ }
+ }
+
return true;
- //return vp->CheckPlay();
}
void Saga2Engine::abortVideo(void) {
- //endVideo();
+ endVideo();
}
void Saga2Engine::endVideo() {
- //if (vp)
- // vp->EndPlay();
+ if (_smkDecoder)
+ _smkDecoder->stop();
+
+ delete _smkDecoder;
+ _smkDecoder = nullptr;
}
} // end of namespace Saga2
Commit: 65060ab0ca769031e46a9bc33a7d330b117d2fa3
https://github.com/scummvm/scummvm/commit/65060ab0ca769031e46a9bc33a7d330b117d2fa3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:54+02:00
Commit Message:
SAGA2: Decrease header dependency
Changed paths:
R engines/saga2/videos.h
engines/saga2/actor.h
engines/saga2/assign.cpp
engines/saga2/assign.h
engines/saga2/automap.cpp
engines/saga2/blitters.cpp
engines/saga2/dispnode.cpp
engines/saga2/document.h
engines/saga2/grequest.cpp
engines/saga2/intrface.cpp
engines/saga2/keybored.cpp
engines/saga2/modal.cpp
engines/saga2/modal.h
engines/saga2/mouseimg.cpp
engines/saga2/objects.h
engines/saga2/objproto.h
engines/saga2/playmode.cpp
engines/saga2/saga2.cpp
engines/saga2/sensor.cpp
engines/saga2/sprite.cpp
engines/saga2/std.h
engines/saga2/tile.cpp
engines/saga2/transit.cpp
engines/saga2/tromode.cpp
engines/saga2/videobox.cpp
diff --git a/engines/saga2/actor.h b/engines/saga2/actor.h
index c587a29e55..d283909d39 100644
--- a/engines/saga2/actor.h
+++ b/engines/saga2/actor.h
@@ -28,8 +28,6 @@
#define SAGA2_ACTOR_H
#include "saga2/objects.h"
-#include "saga2/tile.h"
-#include "saga2/effects.h"
namespace Saga2 {
diff --git a/engines/saga2/assign.cpp b/engines/saga2/assign.cpp
index 8081627556..f44d1df77f 100644
--- a/engines/saga2/assign.cpp
+++ b/engines/saga2/assign.cpp
@@ -31,15 +31,26 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
+#include "saga2/actor.h"
#include "saga2/assign.h"
+#include "saga2/calender.h"
#include "saga2/patrol.h"
+#include "saga2/task.h"
namespace Saga2 {
+const uint16 indefinitely = CalenderTime::framesPerDay;
+
/* ===================================================================== *
ActorAssignment member functions
* ===================================================================== */
+// Constructor
+ActorAssignment::ActorAssignment(uint16 until) :
+ startFrame(calender.frameInDay()),
+ endFrame(until) {
+}
+
//----------------------------------------------------------------------
// Constructor -- reconstruct from archive buffer
@@ -138,6 +149,13 @@ TaskStack *ActorAssignment::createTask(void) {
return ts;
}
+Actor *ActorAssignment::getActor(void) const {
+ // FIXME: This is utterly evil
+ warning("getActor(): dangerous pointer arithmetic, this will not work");
+ return (Actor *)(this - offsetof(Actor, assignmentBuf));
+}
+
+
//----------------------------------------------------------------------
// This function is called to notify the assignment of the completion
// of a task which the assignment had created.
@@ -324,6 +342,17 @@ Task *PatrolRouteAssignment::getTask(TaskStack *ts) {
HuntToBeNearLocationAssignment member functions
* ===================================================================== */
+HuntToBeNearLocationAssignment::HuntToBeNearLocationAssignment(const TilePoint &tp, uint16 r) :
+ ActorAssignment(indefinitely) {
+ initialize(LocationTarget(tp), r);
+}
+
+// Construct with no time limit and an abstract target
+HuntToBeNearLocationAssignment::HuntToBeNearLocationAssignment(const Target &targ, uint16 r) :
+ ActorAssignment(indefinitely) {
+ initialize(targ, r);
+}
+
//----------------------------------------------------------------------
// An initialization function which provides a common ground for
// the initial constructors.
@@ -410,6 +439,25 @@ Task *HuntToBeNearLocationAssignment::getTask(TaskStack *ts) {
HuntToBeNearActorAssignment member functions
* ===================================================================== */
+// Construct with no time limit and specific actor
+HuntToBeNearActorAssignment::HuntToBeNearActorAssignment(
+ Actor *a,
+ uint16 r,
+ bool trackFlag) :
+ ActorAssignment(indefinitely) {
+ assert(isActor(a) && a != getActor());
+ initialize(SpecificActorTarget(a), r, trackFlag);
+}
+
+// Construct with no time limit and abstract actor target
+HuntToBeNearActorAssignment::HuntToBeNearActorAssignment(
+ const ActorTarget &at,
+ uint16 r,
+ bool trackFlag) :
+ ActorAssignment(indefinitely) {
+ initialize(at, r, trackFlag);
+}
+
//----------------------------------------------------------------------
// An initialization function which provides a common ground for the
// initial constructors.
@@ -516,6 +564,22 @@ Task *HuntToBeNearActorAssignment::getTask(TaskStack *ts) {
HuntToKillAssignment member functions
* ===================================================================== */
+// Construct with no time limit and specific actor
+HuntToKillAssignment::HuntToKillAssignment(Actor *a, bool trackFlag) :
+ ActorAssignment(indefinitely) {
+ assert(isActor(a) && a != getActor());
+ initialize(SpecificActorTarget(a), trackFlag, TRUE);
+}
+
+// Construct with no time limit and abstract actor target
+HuntToKillAssignment::HuntToKillAssignment(
+ const ActorTarget &at,
+ bool trackFlag) :
+ ActorAssignment(indefinitely) {
+ initialize(at, trackFlag, FALSE);
+}
+
+
//----------------------------------------------------------------------
// An initialization function which provides a common ground for the
// initial constructors.
diff --git a/engines/saga2/assign.h b/engines/saga2/assign.h
index 3d77ef43e2..74a1e72715 100644
--- a/engines/saga2/assign.h
+++ b/engines/saga2/assign.h
@@ -31,17 +31,13 @@
Includes
* ===================================================================== */
-#include "saga2/actor.h"
-#include "saga2/task.h"
-#include "saga2/calender.h"
+#include "saga2/target.h"
namespace Saga2 {
-/* ===================================================================== *
- Constants
- * ===================================================================== */
-
-const uint16 indefinitely = CalenderTime::framesPerDay;
+class Actor;
+class Task;
+class TaskStack;
// Constants representing the non-virtual ActorAssignment classes
enum AssignmentTypes {
@@ -63,10 +59,7 @@ class ActorAssignment {
public:
// Constructor
- ActorAssignment(uint16 until) :
- startFrame(calender.frameInDay()),
- endFrame(until) {
- }
+ ActorAssignment(uint16 until);
// Constructor -- reconstruct from archive buffer
ActorAssignment(void **buf);
@@ -99,11 +92,7 @@ public:
virtual bool isValid(void);
// Return a pointer to the actor to which this assignment belongs
- Actor *getActor(void) const {
- // FIXME: This is utterly evil
- warning("getActor(): dangerous pointer arithmetic, this will not work");
- return (Actor *)(this - offsetof(Actor, assignmentBuf));
- }
+ Actor *getActor(void) const;
// Return an integer representing the class of this assignment
virtual int16 type(void) const = 0;
@@ -189,10 +178,7 @@ public:
// Constructors -- initial assignment construction
// Construct with no time limit and a specific TilePoint
- HuntToBeNearLocationAssignment(const TilePoint &tp, uint16 r) :
- ActorAssignment(indefinitely) {
- initialize(LocationTarget(tp), r);
- }
+ HuntToBeNearLocationAssignment(const TilePoint &tp, uint16 r);
// Construct with time limit and a specific TilePoint
HuntToBeNearLocationAssignment(
@@ -204,10 +190,7 @@ public:
}
// Construct with no time limit and an abstract target
- HuntToBeNearLocationAssignment(const Target &targ, uint16 r) :
- ActorAssignment(indefinitely) {
- initialize(targ, r);
- }
+ HuntToBeNearLocationAssignment(const Target &targ, uint16 r);
// Construct with time limit and an abstract target
HuntToBeNearLocationAssignment(
@@ -269,11 +252,7 @@ public:
HuntToBeNearActorAssignment(
Actor *a,
uint16 r,
- bool trackFlag = FALSE) :
- ActorAssignment(indefinitely) {
- assert(isActor(a) && a != getActor());
- initialize(SpecificActorTarget(a), r, trackFlag);
- }
+ bool trackFlag = FALSE);
// Construct with time limit and specific actor
HuntToBeNearActorAssignment(
@@ -290,10 +269,7 @@ public:
HuntToBeNearActorAssignment(
const ActorTarget &at,
uint16 r,
- bool trackFlag = FALSE) :
- ActorAssignment(indefinitely) {
- initialize(at, r, trackFlag);
- }
+ bool trackFlag = FALSE);
// Construct with time limit and abstract actor target
HuntToBeNearActorAssignment(
@@ -352,11 +328,7 @@ public:
// Constructors -- initial assignment construction
// Construct with no time limit and specific actor
- HuntToKillAssignment(Actor *a, bool trackFlag = FALSE) :
- ActorAssignment(indefinitely) {
- assert(isActor(a) && a != getActor());
- initialize(SpecificActorTarget(a), trackFlag, TRUE);
- }
+ HuntToKillAssignment(Actor *a, bool trackFlag = FALSE);
// Construct with time limit and specific actor
HuntToKillAssignment(
@@ -371,10 +343,7 @@ public:
// Construct with no time limit and abstract actor target
HuntToKillAssignment(
const ActorTarget &at,
- bool trackFlag = FALSE) :
- ActorAssignment(indefinitely) {
- initialize(at, trackFlag, FALSE);
- }
+ bool trackFlag = FALSE);
// Construct with time limit and abstract actor target
HuntToKillAssignment(
diff --git a/engines/saga2/automap.cpp b/engines/saga2/automap.cpp
index c3c26c7d6d..ea88056a65 100644
--- a/engines/saga2/automap.cpp
+++ b/engines/saga2/automap.cpp
@@ -28,6 +28,7 @@
#include "saga2/std.h"
#include "saga2/automap.h"
+#include "saga2/blitters.h"
#include "saga2/tile.h"
#include "saga2/objects.h"
#include "saga2/player.h"
diff --git a/engines/saga2/blitters.cpp b/engines/saga2/blitters.cpp
index afd65d230d..a000a91bd9 100644
--- a/engines/saga2/blitters.cpp
+++ b/engines/saga2/blitters.cpp
@@ -28,6 +28,7 @@
#include "saga2/std.h"
#include "saga2/saga2.h"
+#include "saga2/blitters.h"
#include "common/debug.h"
namespace Saga2 {
diff --git a/engines/saga2/dispnode.cpp b/engines/saga2/dispnode.cpp
index a9d2c512a9..a512d36505 100644
--- a/engines/saga2/dispnode.cpp
+++ b/engines/saga2/dispnode.cpp
@@ -27,6 +27,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
+#include "saga2/blitters.h"
#include "saga2/rmemfta.h"
#include "saga2/dispnode.h"
#include "saga2/tile.h"
diff --git a/engines/saga2/document.h b/engines/saga2/document.h
index 2813326d58..85f825a1b6 100644
--- a/engines/saga2/document.h
+++ b/engines/saga2/document.h
@@ -27,6 +27,7 @@
#ifndef SAGA2_DOCUMENT_H
#define SAGA2_DOCUMENT_H
+#include "saga2/floating.h"
#include "saga2/modal.h"
namespace Saga2 {
diff --git a/engines/saga2/grequest.cpp b/engines/saga2/grequest.cpp
index b925b60a84..ab00d21766 100644
--- a/engines/saga2/grequest.cpp
+++ b/engines/saga2/grequest.cpp
@@ -27,6 +27,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
+#include "saga2/floating.h"
#include "saga2/rmemfta.h"
#include "saga2/grequest.h"
#include "saga2/modal.h"
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index 00e27b3068..49ce5ee6ee 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -27,6 +27,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
+#include "saga2/blitters.h"
#include "saga2/objects.h"
#include "saga2/button.h"
#include "saga2/contain.h"
diff --git a/engines/saga2/keybored.cpp b/engines/saga2/keybored.cpp
index 555f41eda6..afe1653299 100644
--- a/engines/saga2/keybored.cpp
+++ b/engines/saga2/keybored.cpp
@@ -29,6 +29,7 @@
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/tilemode.h"
+#include "saga2/calender.h"
#include "saga2/tile.h"
#include "saga2/setup.h"
diff --git a/engines/saga2/modal.cpp b/engines/saga2/modal.cpp
index bea28d22f7..bfc7de2e89 100644
--- a/engines/saga2/modal.cpp
+++ b/engines/saga2/modal.cpp
@@ -28,6 +28,7 @@
#include "saga2/std.h"
#include "saga2/fta.h"
+#include "saga2/floating.h"
#include "saga2/modal.h"
#include "saga2/setup.h"
#include "saga2/speech.h"
diff --git a/engines/saga2/modal.h b/engines/saga2/modal.h
index 4697759665..af3e6bb1a6 100644
--- a/engines/saga2/modal.h
+++ b/engines/saga2/modal.h
@@ -27,8 +27,6 @@
#ifndef SAGA2_MODAL_H
#define SAGA2_MODAL_H
-#include "saga2/floating.h"
-
namespace Saga2 {
void ModalModeSetup(void);
diff --git a/engines/saga2/mouseimg.cpp b/engines/saga2/mouseimg.cpp
index 0408094166..5c679e7ba4 100644
--- a/engines/saga2/mouseimg.cpp
+++ b/engines/saga2/mouseimg.cpp
@@ -27,6 +27,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
+#include "saga2/blitters.h"
#include "saga2/rmemfta.h"
#include "saga2/fta.h"
#include "saga2/mouseimg.h"
diff --git a/engines/saga2/objects.h b/engines/saga2/objects.h
index e5eb335f9a..69ff88e665 100644
--- a/engines/saga2/objects.h
+++ b/engines/saga2/objects.h
@@ -27,17 +27,8 @@
#ifndef SAGA2_OBJECTS_H
#define SAGA2_OBJECTS_H
-#include "saga2/idtypes.h"
-#include "saga2/tcoords.h"
-#include "saga2/sprite.h"
#include "saga2/property.h"
-#include "saga2/savefile.h"
-#include "saga2/spells.h"
-#include "saga2/effects.h"
-#include "saga2/combat.h"
#include "saga2/tilevect.h"
-// Include list of prototype classes created by MicrosoftAccess script
-#include "saga2/pclass.r"
#include "saga2/objproto.h"
namespace Saga2 {
diff --git a/engines/saga2/objproto.h b/engines/saga2/objproto.h
index 3b1e4d1451..c9e655f687 100644
--- a/engines/saga2/objproto.h
+++ b/engines/saga2/objproto.h
@@ -28,7 +28,6 @@
#define SAGA2_OBJPROTO_H
#include "saga2/idtypes.h"
-#include "saga2/tcoords.h"
#include "saga2/sprite.h"
#include "saga2/property.h"
#include "saga2/savefile.h"
diff --git a/engines/saga2/playmode.cpp b/engines/saga2/playmode.cpp
index 51b2abb49f..4b57da870f 100644
--- a/engines/saga2/playmode.cpp
+++ b/engines/saga2/playmode.cpp
@@ -27,6 +27,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
+#include "saga2/blitters.h"
#include "saga2/rmemfta.h"
#include "saga2/tcoords.h"
#include "saga2/objects.h"
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index 1b137650ad..caecc03bac 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -37,6 +37,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
+#include "saga2/blitters.h"
#include "saga2/loadmsg.h"
namespace Saga2 {
diff --git a/engines/saga2/sensor.cpp b/engines/saga2/sensor.cpp
index c25cf0254f..c261154b62 100644
--- a/engines/saga2/sensor.cpp
+++ b/engines/saga2/sensor.cpp
@@ -30,6 +30,7 @@
#include "saga2/sensor.h"
#include "saga2/pool.h"
#include "saga2/player.h"
+#include "saga2/tile.h"
namespace Saga2 {
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index 366c5743ee..f47cc9b786 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -27,6 +27,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
+#include "saga2/blitters.h"
#include "saga2/sprite.h"
#include "saga2/tcoords.h"
#include "saga2/input.h"
diff --git a/engines/saga2/std.h b/engines/saga2/std.h
index dc9cb17176..3e592252b8 100644
--- a/engines/saga2/std.h
+++ b/engines/saga2/std.h
@@ -32,7 +32,6 @@
typedef uint32 ChunkID;
#define MakeID(a,b,c,d) ((d<<24L)|(c<<16L)|(b<<8L)|a)
-#include "saga2/rmemfta.h"
#include "saga2/saga2.h"
#define FTA
@@ -69,6 +68,4 @@ typedef bool BOOL;
#define maxuint32 0xffffffffu
#define minuint32 0u
-#include "saga2/blitters.h"
-
#endif //SAGA2_STD_H
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 1edbcd6895..8566f36b82 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -27,6 +27,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
+#include "saga2/blitters.h"
#include "saga2/tcoords.h"
#include "saga2/objects.h"
#include "saga2/tile.h"
diff --git a/engines/saga2/transit.cpp b/engines/saga2/transit.cpp
index 243e6bd099..4cd9787a46 100644
--- a/engines/saga2/transit.cpp
+++ b/engines/saga2/transit.cpp
@@ -28,6 +28,7 @@
#include "saga2/std.h"
#include "saga2/fta.h"
+#include "saga2/floating.h"
#include "saga2/tile.h"
#include "saga2/transit.h"
#include "saga2/palette.h"
diff --git a/engines/saga2/tromode.cpp b/engines/saga2/tromode.cpp
index 72a182881d..6259436277 100644
--- a/engines/saga2/tromode.cpp
+++ b/engines/saga2/tromode.cpp
@@ -32,28 +32,34 @@
#include "saga2/cmisc.h"
#include "saga2/input.h"
#include "saga2/fta.h"
-#include "saga2/videos.h"
#include "saga2/player.h"
#include "saga2/tromode.h"
-#include "saga2/messager.h"
-#include "saga2/config.h"
#include "saga2/display.h"
#include "saga2/mainmap.h"
namespace Saga2 {
+#define VIDEO_EXTENSION ".SMK"
+
+#define INTRO_VID1 "TRIMARK" VIDEO_EXTENSION
+#define INTRO_VID2 "INTRO" VIDEO_EXTENSION
+
+#define WIN_VID_1 "END_1" VIDEO_EXTENSION
+#define WIN_VID_2 "END_2" VIDEO_EXTENSION
+#define WIN_VID_3 "END_3A" VIDEO_EXTENSION
+#define WIN_VID_4 "END_3B" VIDEO_EXTENSION
+
+#define LOSE_VID "END_4" VIDEO_EXTENSION
+
+
#define ERASE_BETWEEN TRUE
#define VIDEO_X 0
#define VIDEO_Y 0
-/* ===================================================================== *
- Imports
- * ===================================================================== */
-
-extern bool gameRunning; // true while game running
+extern bool gameRunning;
extern gMouseState prevState;
-extern gMousePointer pointer; // the actual pointer
+extern gMousePointer pointer;
extern MouseExtState mouseQueue[];
extern configuration globalConfig;
extern bool allPlayerActorsDead;
@@ -61,10 +67,6 @@ extern bool allPlayerActorsDead;
extern int16 queueIn,
queueOut;
-/* ===================================================================== *
- External Prototypes
- * ===================================================================== */
-
int16 OptionsDialog(bool disableSaveResume = FALSE);
void SystemEventLoop(void);
void ClearMessageQueue(void);
@@ -80,36 +82,22 @@ void suspendWinTimer(void);
void resumeWinTimer(void);
#endif
-/* ===================================================================== *
- Local Prototypes
- * ===================================================================== */
-
static void doIntro(void);
static void doWintro(int16 whichOne);
static void doLostro(void);
-void waitForVideoFile(char *fileName);
-static void waitForTimer(uint32 tenthsOfSecond);
static void waitForVideo(void);
void waitForInput(void);
static void TroModeSetup(void);
static void TroModeCleanup(void);
-/* ===================================================================== *
- Locals
- * ===================================================================== */
-
static bool abortFlag = FALSE;
#ifndef NO_LOAD_AFTER_WIN
//DO_OUTRO_IN_CLEANUP
static int whichOutro = -1;
#endif
-/* ===================================================================== *
- Main entry points
- * ===================================================================== */
-
// ------------------------------------------------------------------------
// Play intro video
@@ -136,7 +124,6 @@ extern GameWorld *currentWorld; // pointer to the current wo
void setWintroMode(int16 whichOne) {
#ifdef NO_LOAD_AFTER_WIN
- waitForVideoFile("INTRO.SMK");
if (!abortFlag) {
freeAllTileBanks();
currentWorld = NULL;
@@ -159,7 +146,6 @@ void fadeUp();
void dumpGBASE(char *msg);
void setLostroMode(void) {
- waitForVideoFile("INTRO.SMK");
allPlayerActorsDead = FALSE;
if (GameMode::newmodeFlag)
GameMode::update();
@@ -226,55 +212,6 @@ static void TroModeCleanup(void) {
Wait for Event type routines
* ===================================================================== */
-//-----------------------------------------------------------------------
-// Wait till file exists
-
-void waitForVideoFile(char *fileName) { // file name & extension
- char filespec[260];
- bool fe;
-
- abortFlag = FALSE;
-
- if (ConfMan.getBool("disable_videos")) {
- abortFlag = TRUE;
- return;
- }
-
- strncpy(filespec, globalConfig.videoFilePath, 260);
- if (filespec[strlen(filespec) - 1] != '\\')
- strcat(filespec, "\\");
-
- strcat(filespec, fileName);
-
- fe = fileExists(filespec);
-
- if (!fe) {
- abortFlag = TRUE;
- return;
- }
-
- if (!fileReadable(filespec)) {
- //systemConfigError( cpResFileLocked, filespec);
- abortFlag = TRUE;
- return;
- }
-
- return;
-}
-
-// ------------------------------------------------------------------------
-// Wait a certain amount of time
-
-static void waitForTimer(uint32 tenthsOfSecond) {
- uint32 start = gameTime;
- uint32 target = start + (TICKSPERSECOND * tenthsOfSecond / 10);
- while (gameTime < target) {
- SystemEventLoop();
- if (abortFlag)
- return;
- }
-}
-
// ------------------------------------------------------------------------
// Wait till a video completes
@@ -283,6 +220,8 @@ static void waitForVideo(void) {
SystemEventLoop();
if (abortFlag)
return;
+
+ g_system->delayMillis(10);
}
}
@@ -295,6 +234,9 @@ void waitForInput(void) {
SystemEventLoop();
if (abortFlag)
return;
+
+ g_system->updateScreen();
+ g_system->delayMillis(10);
}
}
@@ -302,7 +244,7 @@ void waitForInput(void) {
Video playback
* ===================================================================== */
-static void playAVideo(char *fileName, int x, int y) { //, int16 from, int16 to )
+static void playAVideo(const char *fileName, int x, int y) { //, int16 from, int16 to )
g_vm->startVideo(fileName, x, y);
if (!g_vm->checkVideo()) {
g_vm->endVideo();
diff --git a/engines/saga2/videobox.cpp b/engines/saga2/videobox.cpp
index 9bb7944d96..87a0fa47df 100644
--- a/engines/saga2/videobox.cpp
+++ b/engines/saga2/videobox.cpp
@@ -27,6 +27,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
+#include "saga2/floating.h"
#include "saga2/rmemfta.h"
#include "saga2/videobox.h"
diff --git a/engines/saga2/videos.h b/engines/saga2/videos.h
deleted file mode 100644
index 3321c51eef..0000000000
--- a/engines/saga2/videos.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * aint32 with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#ifndef SAGA2_VIDEOS_H
-#define SAGA2_VIDEOS_H
-
-namespace Saga2 {
-
-// Intro / Outro video configuration
-
-#define VIDEO_EXTENSION ".SMK"
-
-#define INTRO_VID1 "TRIMARK" VIDEO_EXTENSION
-#define INTRO_VID2 "INTRO" VIDEO_EXTENSION
-
-#define WIN_VID_1 "END_1" VIDEO_EXTENSION
-#define WIN_VID_2 "END_2" VIDEO_EXTENSION
-#define WIN_VID_3 "END_3A" VIDEO_EXTENSION
-#define WIN_VID_4 "END_3B" VIDEO_EXTENSION
-
-#define LOSE_VID "END_4" VIDEO_EXTENSION
-
-} // end of namespace Saga2
-
-#endif
Commit: a58fb4ac298e4da0bdcef1d128646c81fa6a5d91
https://github.com/scummvm/scummvm/commit/a58fb4ac298e4da0bdcef1d128646c81fa6a5d91
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:54+02:00
Commit Message:
SAGA2: Reduce header dependency
Changed paths:
engines/saga2/assign.h
engines/saga2/objects.cpp
engines/saga2/objects.h
diff --git a/engines/saga2/assign.h b/engines/saga2/assign.h
index 74a1e72715..d76083ce3d 100644
--- a/engines/saga2/assign.h
+++ b/engines/saga2/assign.h
@@ -27,10 +27,6 @@
#ifndef SAGA2_ASSIGN_H
#define SAGA2_ASSIGN_H
-/* ===================================================================== *
- Includes
- * ===================================================================== */
-
#include "saga2/target.h"
namespace Saga2 {
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 4861376c71..16848dcf81 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -3622,6 +3622,23 @@ ObjectID RegionalObjectIterator::next(GameObject **obj) {
RectangularObjectIterator member functions
* ======================================================================= */
+// Constructor
+RectangularObjectIterator::RectangularObjectIterator(
+ GameWorld *world,
+ const TilePoint &c,
+ const TilePoint &cdelta1,
+ const TilePoint &cdelta2) :
+ RegionalObjectIterator(
+ world,
+ MinTilePoint(c, c + cdelta1, c + cdelta2, c + cdelta1 + cdelta2),
+ MaxTilePoint(c, c + cdelta1, c + cdelta2, c + cdelta1 + cdelta2)),
+ coords1(c),
+ coords2(c + cdelta1),
+ coords3(c + cdelta1 + cdelta2),
+ coords4(c + cdelta2),
+ center((c + (cdelta1 + cdelta2) / 2)) {
+}
+
//------------------------------------------------------------------------
// Determine if the specified point is within the region
@@ -3671,6 +3688,21 @@ ObjectID RectangularObjectIterator::next(GameObject **obj) {
TriangularObjectIterator member functions
* ======================================================================= */
+// Constructor
+TriangularObjectIterator::TriangularObjectIterator(
+ GameWorld *world,
+ const TilePoint &c1,
+ const TilePoint &c2,
+ const TilePoint &c3) :
+ RegionalObjectIterator(
+ world,
+ MinTilePoint(c1, c2, c3),
+ MaxTilePoint(c1, c2, c3)),
+ coords1(c1),
+ coords2(c2),
+ coords3(c3) {
+}
+
//------------------------------------------------------------------------
// Determine if the specified point is within the region
diff --git a/engines/saga2/objects.h b/engines/saga2/objects.h
index 69ff88e665..77727f244f 100644
--- a/engines/saga2/objects.h
+++ b/engines/saga2/objects.h
@@ -27,8 +27,6 @@
#ifndef SAGA2_OBJECTS_H
#define SAGA2_OBJECTS_H
-#include "saga2/property.h"
-#include "saga2/tilevect.h"
#include "saga2/objproto.h"
namespace Saga2 {
@@ -1111,24 +1109,6 @@ class RectangularObjectIterator : public RegionalObjectIterator {
coords3,
coords4;
- // Calculate the sector region to pass to the ObjectIterator
- // constructor
- static TilePoint computeMinPoint(
- const TilePoint &c1,
- const TilePoint &c2,
- const TilePoint &c3,
- const TilePoint &c4) {
- return MinTilePoint(c1, c2, c3, c4);
- }
-
- static TilePoint computeMaxPoint(
- const TilePoint &c1,
- const TilePoint &c2,
- const TilePoint &c3,
- const TilePoint &c4) {
- return MaxTilePoint(c1, c2, c3, c4);
- }
-
// Test to see if the specified point is within the region
bool inRegion(const TilePoint &tp);
@@ -1138,17 +1118,7 @@ public:
GameWorld *world,
const TilePoint &c,
const TilePoint &cdelta1,
- const TilePoint &cdelta2) :
- RegionalObjectIterator(
- world,
- computeMinPoint(c, c + cdelta1, c + cdelta2, c + cdelta1 + cdelta2),
- computeMaxPoint(c, c + cdelta1, c + cdelta2, c + cdelta1 + cdelta2)),
- coords1(c),
- coords2(c + cdelta1),
- coords3(c + cdelta1 + cdelta2),
- coords4(c + cdelta2),
- center((c + (cdelta1 + cdelta2) / 2)) {
- }
+ const TilePoint &cdelta2);
virtual ObjectID first(GameObject **obj);
virtual ObjectID next(GameObject **obj);
@@ -1167,22 +1137,6 @@ class TriangularObjectIterator : public RegionalObjectIterator {
coords2,
coords3;
- // Calculate the sector region to pass to the ObjectIterator
- // constructor
- static TilePoint computeMinPoint(
- const TilePoint &c1,
- const TilePoint &c2,
- const TilePoint &c3) {
- return MinTilePoint(c1, c2, c3);
- }
-
- static TilePoint computeMaxPoint(
- const TilePoint &c1,
- const TilePoint &c2,
- const TilePoint &c3) {
- return MaxTilePoint(c1, c2, c3);
- }
-
// Test to see if the specified point is within the region
bool inRegion(const TilePoint &tp);
@@ -1192,15 +1146,7 @@ public:
GameWorld *world,
const TilePoint &c1,
const TilePoint &c2,
- const TilePoint &c3) :
- RegionalObjectIterator(
- world,
- computeMinPoint(c1, c2, c3),
- computeMaxPoint(c1, c2, c3)),
- coords1(c1),
- coords2(c2),
- coords3(c3) {
- }
+ const TilePoint &c3);
// Iteration functions
ObjectID first(GameObject **obj);
Commit: e71207f6802d5406ff55df3e1c57fb50ef57103a
https://github.com/scummvm/scummvm/commit/e71207f6802d5406ff55df3e1c57fb50ef57103a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:54+02:00
Commit Message:
SAGA2: Reduce header dependency in audio.*
Changed paths:
R engines/saga2/audiogvc.h
R engines/saga2/audiomem.h
engines/saga2/annoy.h
engines/saga2/audio.cpp
engines/saga2/audio.h
engines/saga2/audiobuf.cpp
engines/saga2/audiobuf.h
engines/saga2/audiocmp.h
engines/saga2/audiodec.h
engines/saga2/audiofnc.h
engines/saga2/audiores.cpp
engines/saga2/audiores.h
engines/saga2/audiosmp.h
engines/saga2/audiosys.h
engines/saga2/audqueue.h
engines/saga2/band.cpp
engines/saga2/band.h
engines/saga2/combat.h
engines/saga2/contain.cpp
engines/saga2/effects.h
engines/saga2/idtypes.h
engines/saga2/noise.cpp
engines/saga2/objects.cpp
engines/saga2/objects.h
engines/saga2/objproto.cpp
engines/saga2/objproto.h
engines/saga2/property.cpp
engines/saga2/tcoords.h
engines/saga2/terrain.h
engines/saga2/timer.cpp
engines/saga2/uidialog.cpp
diff --git a/engines/saga2/annoy.h b/engines/saga2/annoy.h
index 7bfd3fcfae..293e0e37a3 100644
--- a/engines/saga2/annoy.h
+++ b/engines/saga2/annoy.h
@@ -27,16 +27,6 @@
#ifndef SAGA2_ANNOY_H
#define SAGA2_ANNOY_H
-/* ===================================================================== *
- Nested includes
- * ===================================================================== */
-
-#include "saga2/tcoords.h"
-
-/* ===================================================================== *
- Constants
- * ===================================================================== */
-
namespace Saga2 {
//-----------------------------------------------------------------------
diff --git a/engines/saga2/audio.cpp b/engines/saga2/audio.cpp
index 64d48b2928..3059bcb072 100644
--- a/engines/saga2/audio.cpp
+++ b/engines/saga2/audio.cpp
@@ -27,6 +27,16 @@
#include "saga2/std.h"
#include "saga2/audio.h"
+#include "saga2/rect.h"
+#include "saga2/queues.h"
+#include "saga2/idtypes.h"
+#include "saga2/audiosmp.h"
+#include "saga2/audqueue.h"
+#include "saga2/audiosys.h"
+
+#include "saga2/audiodec.h"
+#include "saga2/audiofnc.h"
+
namespace Saga2 {
void initAudio() {
diff --git a/engines/saga2/audio.h b/engines/saga2/audio.h
index 82aaa0b6cc..4dab1ab807 100644
--- a/engines/saga2/audio.h
+++ b/engines/saga2/audio.h
@@ -77,14 +77,4 @@ inline void audioFatal(char *msg) {
error("Sound error %s", msg);
}
-#include "saga2/rect.h"
-#include "saga2/audiomem.h"
-#include "saga2/queues.h"
-#include "saga2/audiobuf.h"
-#include "saga2/audiodec.h"
-#include "saga2/audiosmp.h"
-#include "saga2/audqueue.h"
-#include "saga2/audiosys.h"
-#include "saga2/audiofnc.h"
-
#endif
diff --git a/engines/saga2/audiobuf.cpp b/engines/saga2/audiobuf.cpp
index 2d62ca5848..91b677bed9 100644
--- a/engines/saga2/audiobuf.cpp
+++ b/engines/saga2/audiobuf.cpp
@@ -29,6 +29,15 @@
#include "saga2/std.h"
#include "saga2/audio.h"
+#include "saga2/rect.h"
+#include "saga2/queues.h"
+#include "saga2/idtypes.h"
+#include "saga2/audiosmp.h"
+#include "saga2/audqueue.h"
+#include "saga2/audiosys.h"
+
+#include "saga2/audiobuf.h"
+
namespace Saga2 {
extern audioInterface *audio;
@@ -65,8 +74,7 @@ Buffer::Buffer(size_t newSize) {
internallyAllocated = TRUE;
size = newSize;
- data[0] = audioAlloc(newSize, "Audio data buffer"); //( void * ) new char[newSize];
- audio_lock(data[0], size); //musicRes->size( s ));
+ data[0] = malloc(newSize);
data[1] = NULL;
wData = data[0];
@@ -78,8 +86,7 @@ Buffer::Buffer(size_t newSize) {
Buffer::~Buffer(void) {
if (internallyAllocated) {
assert(data[0]);
- audio_unlock(data[0], size);
- audioFree(data[0]); //delete [] data[0];
+ free(data[0]);
data[0] = NULL;
}
}
@@ -122,13 +129,12 @@ doubleBuffer::doubleBuffer(size_t newSize, audioInterface *sd, int16 newID)
targetSated = FALSE;
ailSampleHandle = AIL_allocate_sample_handle(sd->dig);
if (ailSampleHandle == NULL)
- audioFatal("Unable to allocate audio handle");
+ error("Unable to allocate audio handle");
AIL_init_sample(ailSampleHandle);
AILLOCated = -1;
audioSet = 0;
- data[1] = audioAlloc(newSize, "audio double buffer"); // ( void * ) new char[newSize];
- audio_lock(data[1], newSize); //musicRes->size( s ));
+ data[1] = (void *)malloc(newSize);
//drain( 1 );
}
}
@@ -136,8 +142,7 @@ doubleBuffer::doubleBuffer(size_t newSize, audioInterface *sd, int16 newID)
doubleBuffer::~doubleBuffer(void) {
assert(ailSampleHandle);
if (data[1]) {
- audio_unlock(data[1], size);
- audioFree(data[1]); //delete [] data[1];
+ free(data[1]);
data[1] = NULL;
}
if (ailSampleHandle) {
@@ -223,13 +228,13 @@ void workBuffer::shiftdown(int16 bufNo) {
assert(rData);
if (dif > 0 && rSize > 0) {
- char *tbuf = (char *) audioAlloc(rSize, "audio work buffer"); //new char[rSize];
+ char *tbuf = (char *)malloc(rSize);
memcpy(tbuf, rData, rSize);
memcpy(data[bufNo], tbuf, rSize);
rData = data[bufNo];
wSize += dif;
wData = (void *)(((char *) data[bufNo]) + (size - wSize));
- audioFree(tbuf);
+ free(tbuf);
}
}
diff --git a/engines/saga2/audiobuf.h b/engines/saga2/audiobuf.h
index 2c531abeef..8d485dd7d6 100644
--- a/engines/saga2/audiobuf.h
+++ b/engines/saga2/audiobuf.h
@@ -78,13 +78,6 @@ public:
uint32 rSize; // virtual remaining read size
void *rData; // virtual read data buffer
- // Note that buffers do not follow canonical form
- void *operator new (size_t s) {
- return audioAlloc(s, "audio buffer mgr");
- }
- void operator delete (void *m) {
- audioFree(m);
- }
Buffer(size_t newSize);
virtual ~Buffer(void);
@@ -125,12 +118,6 @@ public:
workBuffer(size_t newSize, int16 newID);
~workBuffer(void);
- void *operator new (size_t s) {
- return audioAlloc(s, "audio wk bfr mgr");
- }
- void operator delete (void *m) {
- audioFree(m);
- }
uint32 sample_status(void); // gives the status of the buffer as a whole
void reset(void); // initialize buffer
@@ -173,12 +160,6 @@ public:
doubleBuffer(size_t newSize, audioInterface *sd, int16 newID);
~doubleBuffer(void);
- void *operator new (size_t s) {
- return audioAlloc(s, "aud dble buf mgr");
- }
- void operator delete (void *m) {
- audioFree(m);
- }
uint32 sample_status(void); // gives the status of the buffer as a whole
void reset(void); // initialize buffer
@@ -219,12 +200,6 @@ public:
singleBuffer(size_t newSize, audioInterface *sd, int16 newID);
~singleBuffer(void);
- void *operator new (size_t s) {
- return audioAlloc(s, "aud sgl buf mgr");
- }
- void operator delete (void *m) {
- audioFree(m);
- }
uint32 sample_status(void); // gives the status of the buffer as a whole
void reset(void); // initialize buffer
@@ -272,12 +247,6 @@ public:
musicBuffer(size_t newSize, audioInterface *sd, int16 newID);
~musicBuffer(void);
- void *operator new (size_t s) {
- return audioAlloc(s, "aud music buf mgr");
- }
- void operator delete (void *m) {
- audioFree(m);
- }
uint32 sample_status(void); // gives the status of the buffer as a whole
void reset(void); // initialize buffer
@@ -321,12 +290,6 @@ public:
cacheBuffer(size_t newSize, int16 newID);
~cacheBuffer(void);
- void *operator new (size_t s) {
- return audioAlloc(s, "aud cache buf mgr");
- }
- void operator delete (void *m) {
- audioFree(m);
- }
uint32 sample_status(void); // gives the status of the buffer as a whole
void reset(void); // initialize buffer
diff --git a/engines/saga2/audiocmp.h b/engines/saga2/audiocmp.h
index a4d74ee00c..d4d7c63664 100644
--- a/engines/saga2/audiocmp.h
+++ b/engines/saga2/audiocmp.h
@@ -27,8 +27,6 @@
#ifndef SAGA2_AUDIOCMP_H
#define SAGA2_AUDIOCMP_H
-#include "saga2/audiogvc.h"
-
namespace Saga2 {
/* ===================================================================== *
diff --git a/engines/saga2/audiodec.h b/engines/saga2/audiodec.h
index b6ad989e2d..bc45305635 100644
--- a/engines/saga2/audiodec.h
+++ b/engines/saga2/audiodec.h
@@ -29,6 +29,13 @@
namespace Saga2 {
+class Buffer;
+class audioInterface;
+class soundDecoder;
+class soundSample;
+class workBuffer;
+class soundQueue;
+
/* ===================================================================== *
Sound Sample Decoders
@@ -75,12 +82,7 @@ union soundServer {
INPLACEDECODER *pDec;
BUFFERDECODER *bDec;
BUFFERLOADER *lDec;
- void *operator new (size_t s) {
- return audioAlloc(s, "aud snd server");
- }
- void operator delete (void *m) {
- audioFree(m);
- }
+
soundServer() {
pDec = NULL;
}
@@ -149,12 +151,6 @@ public:
soundDecoder(BUFFERLOADER, BUFFERLOADER, BUFFERLOADER);
#endif
~soundDecoder(void);
- void *operator new (size_t s) {
- return audioAlloc(s, "audio decoder");
- }
- void operator delete (void *m) {
- audioFree(m);
- }
soundDecoder &operator=(const soundDecoder &src);
soundDecoder(const soundDecoder &src);
bool operator==(const soundDecoder &src2) const;
@@ -194,12 +190,7 @@ public:
if (decode) delete decode;
decode = NULL;
}
- void *operator new (size_t s) {
- return audioAlloc(s, "audio decdr set");
- }
- void operator delete (void *m) {
- audioFree(m);
- }
+
void addDecoder(soundDecoder *sodec);
#if DEBUG_AUDIO
diff --git a/engines/saga2/audiofnc.h b/engines/saga2/audiofnc.h
index ca84aeceef..227b98f452 100644
--- a/engines/saga2/audiofnc.h
+++ b/engines/saga2/audiofnc.h
@@ -27,8 +27,6 @@
#ifndef SAGA2_AUDIOFNC_H
#define SAGA2_AUDIOFNC_H
-#include "saga2/audiobuf.h"
-
namespace Saga2 {
/* ===================================================================== *
diff --git a/engines/saga2/audiogvc.h b/engines/saga2/audiogvc.h
deleted file mode 100644
index 40a21aa0ab..0000000000
--- a/engines/saga2/audiogvc.h
+++ /dev/null
@@ -1,296 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#ifndef SAGA2_AUDIOGVC_H
-#define SAGA2_AUDIOGVC_H
-
-namespace Saga2 {
-
-#define BUGFIX_RELEASE "22"
-
-#define HAVE_STDARG_H 1
-
-
-# define OLD_MAGIC "ajkg"
-# define MAGIC "dgvc"
-
-// file formats
-
-enum decompFTypes {
- dft_au, // Unix .AU file
- dft_ulaw, // mu-law encoding
- dft_s8, // signed 8 bit PCM
- dft_u8, // unsigned 8 bit PCM
- dft_s16, // signed 16 bit PCM
- dft_u16, // unsigned 16 bit PCM
- dft_s16x, // signed 16 bit PCM
- dft_u16x, // unsigned 16 bit PCM
- dft_s16hl, // signed 16 bit PCM 680x0 ordering
- dft_u16hl, // unsigned 16 bit PCM 680x0 ordering
- dft_s16lh, // signed 16 bit PCM 80x86 ordering
- dft_u16lh, // unsigned 16 bit PCM 80x86 ordering
-};
-
-#define DEFAULT_FTYPE ( dft_s16 )
-
-
-
-
-# define FORMAT_VERSION 1
-# define MIN_SUPPORTED_VERSION 0
-# define MAX_SUPPORTED_VERSION 2
-# define MAX_VERSION 7
-# define UNDEFINED_UINT -1
-# define DEFAULT_BLOCK_SIZE 256
-# define DEFAULT_V0NMEAN 0
-# define DEFAULT_V2NMEAN 4
-# define DEFAULT_MAXNLPC 0
-# define DEFAULT_NCHAN 1
-# define DEFAULT_NSKIP 0
-# define DEFAULT_NDISCARD 0
-# define NBITPERLONG 32
-# define DEFAULT_MINSNR 99
-# define DEFAULT_MAXRESNSTR "32.0"
-# define DEFAULT_QUANTERROR 0
-# define MINBITRATE 2.5
-
-# define MAX_LPC_ORDER 64
-# define CHANSIZE 0
-# define ENERGYSIZE 3
-# define BITSHIFTSIZE 2
-# define NWRAP 3
-
-# define FNSIZE 2
-# define FN_DIFF0 0
-# define FN_DIFF1 1
-# define FN_DIFF2 2
-# define FN_DIFF3 3
-# define FN_QUIT 4
-# define FN_BLOCKSIZE 5
-# define FN_BITSHIFT 6
-# define FN_QLPC 7
-# define FN_ZERO 8
-
-# define ULONGSIZE 2
-# define NSKIPSIZE 1
-# define LPCQSIZE 2
-# define LPCQUANT 5
-# define XBYTESIZE 7
-
-# define TYPESIZE 4
-# define TYPE_AU 0
-# define TYPE_S8 1
-# define TYPE_U8 2
-# define TYPE_S16HL 3
-# define TYPE_U16HL 4
-# define TYPE_S16LH 5
-# define TYPE_U16LH 6
-# define TYPE_ULAW 7
-# define TYPE_EOF 8
-
-#ifndef MIN
-# define MIN( a, b ) ((( a )<( b ))?( a ):( b ))
-#endif
-
-#ifndef MAX
-# define MAX( a, b ) ((( a )>( b ))?( a ):( b ))
-#endif
-
-#if defined( unix ) && !defined( linux )
-# define labs abs
-#endif
-
-# define ROUNDEDSHIFTDOWN( x, n ) ((( n ) == 0 ) ? ( x ) : (( x ) >> (( n ) - 1 )) >> 1 )
-
-#ifndef M_LN2
-#define M_LN2 0.69314718055994530942
-#endif
-
-/* BUFSIZ must be a multiple of four to contain a whole number of words */
-#ifndef BUFSIZ
-# define BUFSIZ 1024
-#endif
-
-#define putc_exit( val, stream )\
- { char rval;\
- if(( rval = buffputc(( val ), ( stream ))) != ( char ) ( val ))\
- SegFatal( serrCompPutFailed );\
- }
-//update_exit( 1, "write failed: putc returns EOF\n");
-
-extern int getc_exit_val;
-#define getc_exit( stream )\
- ((( getc_exit_val = buffgetc( stream )) == EOF ) ? \
- update_exit( 1, "read failed: getc returns EOF\n"), 0: getc_exit_val )
-
-#undef uchar
-#define uchar unsigned char
-#undef ushort
-#define ushort unsigned short
-#undef ulong
-#define ulong unsigned long
-
-#if defined( __STDC__ ) || defined( __GNUC__ ) || defined( sgi ) || !defined( unix )
-typedef signed char schar;
-#define PROTO( ARGS ) ARGS
-#else
-typedef char schar;
-#define PROTO( ARGS ) ()
-#endif
-
-#ifdef NEED_OLD_PROTOTYPES
-/*******************************************/
-/* this should be in string.h or strings.h */
-extern int strcmp PROTO((const char *, const char *));
-extern char *strcpy PROTO((char *, const char *));
-extern char *strcat PROTO((char *, const char *));
-extern int strlen PROTO((const char *));
-
-/**************************************/
-/* defined in stdlib.h if you have it */
-extern void *malloc PROTO((unsigned long));
-extern void free PROTO((void *));
-extern int atoi PROTO((const char *));
-extern void swab PROTO((char *, char *, int));
-extern int buffseek PROTO((doubleBuffer *, long, int));
-
-/***************************/
-/* other misc system calls */
-extern int unlink PROTO((const char *));
-extern void exit PROTO((int));
-#endif
-
-/************************/
-/* defined in shorten.c */
-extern long init_offset PROTO((long **, int, int, int));
-
-/*********************/
-/* defined in ulaw.c */
-extern uchar linear2ulaw PROTO((long));
-extern int ulaw2linear PROTO((uchar));
-
-/********************/
-/* defined in lpc.c */
-extern int wav2lpc PROTO((long *, int, long, int *, int, int, float *, float *));
-
-/*********************/
-/* defined in poly.c */
-extern int wav2poly PROTO((long *, int, long, int, float *, float *));
-
-/*********************/
-/* defined in exit.c */
-
-extern void basic_exit PROTO((int));
-
-#ifdef HAVE_STDARG_H
-extern void perror_exit PROTO((char *, ...));
-extern void usage_exit PROTO((int, char *, ...));
-extern void update_exit PROTO((int, char *, ...));
-# else
-extern void perror_exit PROTO(());
-extern void usage_exit PROTO(());
-extern void update_exit PROTO(());
-# endif
-
-/***********************/
-/* defined in hsgetopt.c */
-extern void hs_resetopt PROTO((void));
-extern int hs_getopt PROTO((int, char **, char *));
-extern int hs_optind;
-extern char *hs_optarg;
-
-/**********************/
-/* defined in array.c */
-extern void *pmalloc PROTO((ulong));
-extern long **long2d PROTO((ulong, ulong));
-
-/****************************/
-/* defined in dupfileinfo.c */
-extern int dupfileinfo PROTO((char *, char *));
-
-
-// PROTO() is an annoying parameter definition macro to allow compatibility
-// with the K&R style parameter declarations
-
-/**********************/
-/* defined in fixio.c */
-extern void init_sizeof_sample PROTO((void));
-extern void fread_type_init PROTO((void));
-extern void fread_type_quit PROTO((void));
-extern void fwrite_type_init PROTO((void));
-extern int fread_type PROTO((long **, int, int, int, Buffer *));
-extern void fwrite_type PROTO((long **, int, int, int, Buffer *));
-extern void fwrite_type_quit PROTO((void));
-extern int find_bitshift PROTO((long *, int, int));
-extern void fix_bitshift PROTO((long *, int, int, int));
-
-/**********************/
-/* defined in vario.c */
-extern void var_put_init PROTO((void));
-extern void uvar_put PROTO((ulong, int, Buffer *));
-extern void var_put PROTO((long, int, Buffer *));
-extern void ulong_put PROTO((ulong, Buffer *));
-extern void var_put_quit PROTO((Buffer *));
-
-extern void var_get_init PROTO((void));
-extern long uvar_get PROTO((int, Buffer *));
-extern long var_get PROTO((int, Buffer *));
-extern ulong ulong_get PROTO((Buffer *));
-extern void var_get_quit PROTO((void));
-
-extern int sizeof_uvar PROTO((ulong, int));
-extern int sizeof_var PROTO((long, int));
-
-extern void mkmasktab PROTO((void));
-extern void word_put PROTO((ulong, Buffer *));
-extern ulong word_get PROTO((Buffer *));
-
-
-extern int shorten PROTO((Buffer *, Buffer *, int, char **));
-
-
-long init_offset(long **offset, int nchan, int nblock, int ftype) ;
-float Satof(char *string) ;
-float *parseList(char *maxresnstr, int nchan) ;
-int16 getFType(decompFTypes dft);
-int unShorten(Buffer *stdi, Buffer *stdo, int, char **);
-
-# define V2LPCQOFFSET ( 1 << LPCQUANT );
-
-# define UINT_PUT( val, nbit, file ) \
- if ( version == 0 ) uvar_put(( unsigned long ) val, nbit, file ); \
- else ulong_put(( unsigned long ) val, file )
-
-# define UINT_GET( nbit, file ) \
- (( version == 0 ) ? uvar_get( nbit, file ) : ulong_get( file ))
-
-# define VAR_PUT( val, nbit, file ) \
- if ( version == 0 ) var_put(( unsigned long ) val, nbit - 1, file ); \
- else var_put(( unsigned long ) val, nbit, file )
-
-} // end of namespace Saga2
-
-#endif
diff --git a/engines/saga2/audiomem.h b/engines/saga2/audiomem.h
deleted file mode 100644
index 1961c5d471..0000000000
--- a/engines/saga2/audiomem.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-
-#ifndef SAGA2_AUDIOMEM_H
-#define SAGA2_AUDIOMEM_H
-
-namespace Saga2{
-
-/* ===================================================================== *
- Memory alloc/free
- * ===================================================================== */
-
-void *audioAlloc(size_t s, const char[]);
-void audioFree(void *mem);
-
-#define audionew( s ) (( s* )audioAlloc( sizeof( s )))
-#define audiodelete( m ) ( audioFree( m ))
-
-/* ===================================================================== *
- VMM locking
- * ===================================================================== */
-
-bool audio_lock(void *p, size_t s);
-bool audio_unlock(void *p, size_t s);
-
-} // end of namespace Saga2
-
-#endif
diff --git a/engines/saga2/audiores.cpp b/engines/saga2/audiores.cpp
index 91cc4ad2e1..b163c0ab9a 100644
--- a/engines/saga2/audiores.cpp
+++ b/engines/saga2/audiores.cpp
@@ -30,8 +30,14 @@
#include "saga2/audio.h"
#include "saga2/hresmgr.h"
#include "saga2/audiores.h"
+#include "saga2/audiodec.h"
#include "saga2/fta.h"
+#include "saga2/queues.h"
+#include "saga2/idtypes.h"
+#include "saga2/audiosmp.h"
+#include "saga2/audiobuf.h"
+
namespace Saga2 {
#define ASYNCH_AUDIO 0
diff --git a/engines/saga2/audiores.h b/engines/saga2/audiores.h
index 3cb6f6bee3..d92726652b 100644
--- a/engines/saga2/audiores.h
+++ b/engines/saga2/audiores.h
@@ -29,6 +29,9 @@
namespace Saga2 {
+class Buffer;
+class soundSample;
+
int16 hResSeek(Buffer &sb, soundSample &ss, hResContext *hrc, bool Cheksize);
int16 hResRead(Buffer &sb, soundSample &ss, hResContext *hrc);
int16 hResFlush(Buffer &sb, soundSample &ss, hResContext *hrc);
diff --git a/engines/saga2/audiosmp.h b/engines/saga2/audiosmp.h
index e65bcec334..ffcb8588af 100644
--- a/engines/saga2/audiosmp.h
+++ b/engines/saga2/audiosmp.h
@@ -28,6 +28,9 @@
#define SAGA2_AUDIOSMP_H
namespace Saga2 {
+
+class decoderSet;
+
/* ===================================================================== *
Sound Sample Attributes
@@ -47,7 +50,6 @@ namespace Saga2 {
#define ENDSAMP 0xFFFFFFFF
typedef uint32 soundSampleID;
-typedef uint32 soundSegment;
typedef soundSegment *segmentArray;
typedef int8 Volume;
typedef Point32 sampleLocation;
@@ -115,12 +117,6 @@ public:
soundSample(soundSegment sa[]); //, sampleLocation pos=Point32( 0, 0 ));
soundSample(soundSegment seg); //, sampleLocation pos=Point32( 0, 0 ));
virtual ~soundSample();
- void *operator new (size_t s) {
- return audioAlloc(s, "audio sample");
- }
- void operator delete (void *m) {
- audioFree(m);
- }
soundSample &operator=(const soundSample &src);
soundSample(const soundSample &src);
@@ -194,12 +190,7 @@ public:
movingSample(soundSegment sa[], sampleLocation pos, sampleVelocity vel, sampleAcceleration acc);
movingSample(soundSegment seg, sampleLocation pos, sampleVelocity vel, sampleAcceleration acc);
~movingSample() {};
- void *operator new (size_t s) {
- return audioAlloc(s, "moving sample");
- }
- void operator delete (void *m) {
- audioFree(m);
- }
+
Volume getVolume(void);
};
diff --git a/engines/saga2/audiosys.h b/engines/saga2/audiosys.h
index 5dfd929d22..1cba411bc0 100644
--- a/engines/saga2/audiosys.h
+++ b/engines/saga2/audiosys.h
@@ -27,10 +27,13 @@
#ifndef SAGA2_AUDIOSYS_H
#define SAGA2_AUDIOSYS_H
-#include "saga2/audiobuf.h"
-
namespace Saga2 {
+class Buffer;
+class musicBuffer;
+class soundQueue;
+class decoderSet;
+
/*******************************************************************/
/* DRIVERS subdirectory */
@@ -114,12 +117,7 @@ struct audioInterfaceSettings {
soundBufferSize = sbs;
loopBufferSize = lbs;
}
- void *operator new (size_t s) {
- return audioAlloc(s, "audio settings");
- }
- void operator delete (void *m) {
- audioFree(m);
- }
+
private:
audioInterfaceSettings();
};
@@ -232,13 +230,6 @@ private:
#endif
public:
- void *operator new (size_t s) {
- return audioAlloc(s, "audio interface");
- }
- void operator delete (void *m) {
- audioFree(m);
- }
-
// ctor, dtor, initialization
audioInterface(const char *driver_path = DRIVER_PATH, const char *undriver_path = UNDRIVER_PATH);
~audioInterface();
diff --git a/engines/saga2/audqueue.h b/engines/saga2/audqueue.h
index 6004f2bb6b..5c46de4e58 100644
--- a/engines/saga2/audqueue.h
+++ b/engines/saga2/audqueue.h
@@ -42,12 +42,6 @@ public:
tip = NULL;
}
~soundQueue(void);
- void *operator new (size_t s) {
- return audioAlloc(s, "aud smpl queue");
- }
- void operator delete (void *m) {
- audioFree(m);
- }
positionedSample *firstSample(void);
positionedSample *nextSample(void);
diff --git a/engines/saga2/band.cpp b/engines/saga2/band.cpp
index f242330e4a..0360df5b77 100644
--- a/engines/saga2/band.cpp
+++ b/engines/saga2/band.cpp
@@ -27,6 +27,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
+#include "saga2/actor.h"
#include "saga2/band.h"
namespace Saga2 {
diff --git a/engines/saga2/band.h b/engines/saga2/band.h
index b480a0670b..abf250e0ce 100644
--- a/engines/saga2/band.h
+++ b/engines/saga2/band.h
@@ -27,10 +27,11 @@
#ifndef SAGA2_BAND_H
#define SAGA2_BAND_H
-#include "saga2/actor.h"
+#include "saga2/idtypes.h"
namespace Saga2 {
+class Actor;
class Band;
const int maxBandMembers = 32;
diff --git a/engines/saga2/combat.h b/engines/saga2/combat.h
index 1b3bc278a3..cf5cdaf47d 100644
--- a/engines/saga2/combat.h
+++ b/engines/saga2/combat.h
@@ -27,10 +27,9 @@
#ifndef SAGA2_COMBAT_H
#define SAGA2_COMBAT_H
-#include "saga2/annoy.h"
-
namespace Saga2 {
-//-----------------------------------------------------------------------
+
+class Location;
enum weaponHitType {
hitMiss = 0,
diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index 1d01c0e9ab..851f0dced9 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -41,6 +41,8 @@
#include "saga2/spellbuk.h"
#include "saga2/imagcach.h"
+#include "saga2/pclass.r"
+
namespace Saga2 {
// debug
diff --git a/engines/saga2/effects.h b/engines/saga2/effects.h
index 1718db6d72..ccd1697749 100644
--- a/engines/saga2/effects.h
+++ b/engines/saga2/effects.h
@@ -31,6 +31,9 @@
namespace Saga2 {
+class Actor;
+class GameObject;
+
// ------------------------------------------------------------------
// Effects of spells and other things
diff --git a/engines/saga2/idtypes.h b/engines/saga2/idtypes.h
index c346ab73c8..6d31812b9b 100644
--- a/engines/saga2/idtypes.h
+++ b/engines/saga2/idtypes.h
@@ -217,6 +217,8 @@ typedef int16 SensorID;
typedef int16 BandID;
const BandID NoBand = -1;
+typedef uint32 soundSegment;
+
} // end of namespace Saga2
#endif
diff --git a/engines/saga2/noise.cpp b/engines/saga2/noise.cpp
index a0181c861f..b6bbe92ca5 100644
--- a/engines/saga2/noise.cpp
+++ b/engines/saga2/noise.cpp
@@ -31,12 +31,19 @@
#include "saga2/fta.h"
#include "saga2/audio.h"
#include "saga2/audiores.h"
+#include "saga2/audiodec.h"
+#include "saga2/audiofnc.h"
#include "saga2/tcoords.h"
#include "saga2/button.h"
#include "saga2/annoy.h"
#include "saga2/objproto.h"
#include "saga2/player.h"
+#include "saga2/queues.h"
+#include "saga2/audiosmp.h"
+#include "saga2/audqueue.h"
+#include "saga2/audiosys.h"
+
namespace Saga2 {
//#define AUDIO_DISABLED
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 16848dcf81..09ee2d2a90 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -48,8 +48,9 @@
#include "saga2/grabinfo.h"
#include "saga2/localize.h"
#include "saga2/spellbuk.h"
-#include "saga2/methods.r" // generated by SAGA
+#include "saga2/methods.r" // generated by SAGA
+#include "saga2/pclass.r"
namespace Saga2 {
APPFUNC(cmdControl);
diff --git a/engines/saga2/objects.h b/engines/saga2/objects.h
index 77727f244f..943549a7bb 100644
--- a/engines/saga2/objects.h
+++ b/engines/saga2/objects.h
@@ -28,6 +28,7 @@
#define SAGA2_OBJECTS_H
#include "saga2/objproto.h"
+#include "saga2/property.h"
namespace Saga2 {
diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp
index 8ac68b9f0d..19d6c344f3 100644
--- a/engines/saga2/objproto.cpp
+++ b/engines/saga2/objproto.cpp
@@ -42,7 +42,9 @@
#include "saga2/magic.h"
#include "saga2/weapons.h"
#include "saga2/spellbuk.h"
+
#include "saga2/methods.r"
+#include "saga2/pclass.r"
namespace Saga2 {
diff --git a/engines/saga2/objproto.h b/engines/saga2/objproto.h
index c9e655f687..c8376ca4c3 100644
--- a/engines/saga2/objproto.h
+++ b/engines/saga2/objproto.h
@@ -29,16 +29,16 @@
#include "saga2/idtypes.h"
#include "saga2/sprite.h"
-#include "saga2/property.h"
-#include "saga2/savefile.h"
#include "saga2/spells.h"
#include "saga2/effects.h"
#include "saga2/combat.h"
-
-#include "saga2/pclass.r"
+#include "saga2/tcoords.h"
namespace Saga2 {
+class Actor;
+class gameObject;
+
/* ===================================================================== *
Exports
* ===================================================================== */
diff --git a/engines/saga2/property.cpp b/engines/saga2/property.cpp
index 22e3aaec86..8bbdfdafc9 100644
--- a/engines/saga2/property.cpp
+++ b/engines/saga2/property.cpp
@@ -31,6 +31,8 @@
#include "saga2/tile.h"
#include "saga2/property.h"
+#include "saga2/pclass.r"
+
namespace Saga2 {
// Determine if this object is just an object
diff --git a/engines/saga2/tcoords.h b/engines/saga2/tcoords.h
index c2584eeeda..9cccc1e58e 100644
--- a/engines/saga2/tcoords.h
+++ b/engines/saga2/tcoords.h
@@ -27,8 +27,6 @@
#ifndef SAGA2_TCOORDS_H
#define SAGA2_TCOORDS_H
-#include "saga2/rect.h"
-
namespace Saga2 {
enum facingDirections {
diff --git a/engines/saga2/terrain.h b/engines/saga2/terrain.h
index bd67a0d302..f5994507f0 100644
--- a/engines/saga2/terrain.h
+++ b/engines/saga2/terrain.h
@@ -29,10 +29,8 @@
namespace Saga2 {
-/* ===================================================================== *
- Constants
- * ===================================================================== */
-
+class TilePoint;
+struct TileRegion;
// these control the rate of drowning damage
// the first two determine the chances of doing damage on a
diff --git a/engines/saga2/timer.cpp b/engines/saga2/timer.cpp
index fafc84f396..b9c52a8ae3 100644
--- a/engines/saga2/timer.cpp
+++ b/engines/saga2/timer.cpp
@@ -30,6 +30,12 @@
#include "saga2/fta.h"
#include "saga2/audio.h"
+#include "saga2/queues.h"
+#include "saga2/idtypes.h"
+#include "saga2/audiosmp.h"
+#include "saga2/audqueue.h"
+#include "saga2/audiosys.h"
+
namespace Saga2 {
/* ====================================================================== *
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index 9bcaad3087..68c724eeec 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -40,6 +40,12 @@
#include "saga2/loadsave.h"
#include "saga2/script.h"
#include "saga2/audio.h"
+
+#include "saga2/queues.h"
+#include "saga2/audiosmp.h"
+#include "saga2/audqueue.h"
+#include "saga2/audiosys.h"
+
#include "saga2/annoy.h"
#include "saga2/uidialog.h"
#include "saga2/document.h"
Commit: d5dca407815aebe98ba3bd8c1018ef7aa2032ae9
https://github.com/scummvm/scummvm/commit/d5dca407815aebe98ba3bd8c1018ef7aa2032ae9
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:54+02:00
Commit Message:
SAGA2: Add draw map test
Changed paths:
engines/saga2/main.cpp
engines/saga2/tile.cpp
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 3d275125d4..74cfdd2f67 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -208,6 +208,8 @@ void displayUpdate(void);
void updatePerfStats(void);
//EO//#endif
+void testTiles();
+
/********************************************************************/
/* */
/* MAIN FUNCTION */
@@ -758,21 +760,7 @@ void testTileRendering() {
listRes = objResFile->newContext(MKTAG('L', 'I', 'S', 'T'), "list resources");
resImports = (ResImportTable *)LoadResource(listRes, MKTAG('I', 'M', 'P', 'O'), "res imports");
- initMaps();
- initTileCyclingStates();
-
-// uint8 *img = nullptr;
-// TileInfo *ti;
-// for (int i = 0; i <= 65535; ++i) {
-// ti = TileInfo::tileAddress(i, &img);
-// if (ti) {
-// debugC(3, kDebugTiles, "terrainHeight = %d, height = %d", ti->attrs.terrainHeight, ti->attrs.height);
-// Common::hexdump(img, ti->attrs.height);
-// }
-// }
-
- cleanupTileCyclingStates();
- cleanupMaps();
+ testTiles();
}
//-----------------------------------------------------------------------
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 8566f36b82..be70c3b350 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -47,6 +47,7 @@
#include "saga2/methods.r" // generated by SAGA
#include "common/debug.h"
+#include "graphics/surface.h"
namespace Saga2 {
@@ -1444,7 +1445,7 @@ void initMaps(void) {
worldCount++) ;
// Allocate the map data array
- mapList = new WorldMapData[worldCount];
+ mapList = new WorldMapData[worldCount]();
if (mapList == nullptr)
error("Unable to allocate map data array");
@@ -1461,6 +1462,7 @@ void initMaps(void) {
mapID + MKTAG(0, 0, 0, (uint8)i), "world map");
if (mapData->map == nullptr)
error("Unable to load map");
+ debugC(3, kDebugTiles, "map: size = %d, mapData = %p", mapData->map->size, (void*)mapData->map->mapData);
// Load the meta tile list
mapData->metaList = (MetaTilePtr)LoadResource(tileRes,
@@ -2613,8 +2615,8 @@ inline void drawMetaRow(TilePoint coords, Point16 pos) {
break;
case edgeTypeRepeat:
- coords.u = clamp(0, coords.u, mapSizeMask);
- coords.v = clamp(0, coords.v, mapSizeMask);
+ coords.u = CLIP(coords.u, (int16)0, mapSizeMask);
+ coords.v = CLIP(coords.v, (int16)0, mapSizeMask);
mtile = mapData[clipCoords.u * curMap->mapSize + clipCoords.v] & ~metaTileVisited;
break;
@@ -4613,6 +4615,45 @@ void updateMainDisplay(void) {
cycleTiles(deltaTime);
}
+void testTiles() {
+ initMaps();
+ initTileCyclingStates();
+
+ //buildRoofTable();
+ //buildDisplayList();
+ //setCurrentMap(0);
+
+ // draws tiles to tileDrawMap.data
+ //drawMetaTiles();
+
+ uint8 *img = (uint8*)mapList[0].map->mapData;
+ int16 size = mapList[0].map->size;
+ debugC(3, kDebugTiles, "img = %p, size = %d", (void *)img, size);
+ //Common::hexdump(img, size*size);
+
+ Graphics::Surface sur;
+ sur.create(size, size, Graphics::PixelFormat::createFormatCLUT8());
+ sur.setPixels(img);
+ sur.debugPrint();
+ g_system->copyRectToScreen(sur.getPixels(), sur.pitch, 0, 112, sur.w, sur.h);
+
+ // Draw sprites onto back buffer
+ //drawDisplayList();
+
+ // Render the image of the mouse pointer on everything else
+ //drawTileMousePointer();
+
+ // Blit it all onto the screen
+ //drawPage->writePixels(
+ // tileRect,
+ // tileDrawMap.data
+ // + fineScroll.x
+ // + fineScroll.y * tileDrawMap.size.x,
+ // tileDrawMap.size.x);
+
+ cleanupTileCyclingStates();
+ cleanupMaps();
+}
void drawMainDisplay(void) {
Commit: 8d16b5156db8ff3cf1b8d1ebf4f10d119d726278
https://github.com/scummvm/scummvm/commit/8d16b5156db8ff3cf1b8d1ebf4f10d119d726278
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:54+02:00
Commit Message:
SAGA2: Further include dependency reduction
Changed paths:
engines/saga2/detection.cpp
engines/saga2/detection.h
engines/saga2/dispnode.cpp
engines/saga2/effects.cpp
engines/saga2/magic.cpp
engines/saga2/modal.h
engines/saga2/objects.cpp
engines/saga2/setup.h
engines/saga2/spelcast.cpp
engines/saga2/speldata.cpp
engines/saga2/speldraw.cpp
engines/saga2/spellbuk.h
engines/saga2/spellini.cpp
engines/saga2/spellio.cpp
engines/saga2/spellio.h
engines/saga2/spellloc.cpp
engines/saga2/spellsiz.cpp
engines/saga2/spellspr.cpp
engines/saga2/spellsta.cpp
diff --git a/engines/saga2/detection.cpp b/engines/saga2/detection.cpp
index 52f5b46458..14b5ffacec 100644
--- a/engines/saga2/detection.cpp
+++ b/engines/saga2/detection.cpp
@@ -20,11 +20,12 @@
*
*/
-#include "saga2/saga2.h"
-#include "saga2/detection.h"
#include "base/plugins.h"
#include "engines/advancedDetector.h"
+#include "saga2/saga2.h"
+#include "saga2/detection.h"
+
static const DebugChannelDef debugFlagList[] = {
{Saga2::kDebugResources, "resources", "Debug the resources"},
{Saga2::kDebugActors, "actors", "Debug the actors"},
diff --git a/engines/saga2/detection.h b/engines/saga2/detection.h
index 771b6ad564..74028829b2 100644
--- a/engines/saga2/detection.h
+++ b/engines/saga2/detection.h
@@ -23,8 +23,6 @@
#ifndef SAGA2_DETECTION_H
#define SAGA2_DETECTION_H
-#include "advancedDetector.h"
-
namespace Saga2 {
enum GameIds {
diff --git a/engines/saga2/dispnode.cpp b/engines/saga2/dispnode.cpp
index a512d36505..5d7e2c86ea 100644
--- a/engines/saga2/dispnode.cpp
+++ b/engines/saga2/dispnode.cpp
@@ -32,6 +32,8 @@
#include "saga2/dispnode.h"
#include "saga2/tile.h"
#include "saga2/actor.h"
+#include "saga2/spells.h"
+#include "saga2/spelshow.h"
#include "saga2/spellbuk.h"
#include "saga2/images.h"
#include "saga2/player.h"
diff --git a/engines/saga2/effects.cpp b/engines/saga2/effects.cpp
index 8d7e79e008..d3f854bfa4 100644
--- a/engines/saga2/effects.cpp
+++ b/engines/saga2/effects.cpp
@@ -28,6 +28,8 @@
#include "saga2/std.h"
#include "saga2/cmisc.h"
+#include "saga2/spells.h"
+#include "saga2/spelshow.h"
#include "saga2/spellbuk.h"
#include "saga2/idtypes.h"
#include "saga2/script.h"
diff --git a/engines/saga2/magic.cpp b/engines/saga2/magic.cpp
index af6ca39419..6b1c9305a4 100644
--- a/engines/saga2/magic.cpp
+++ b/engines/saga2/magic.cpp
@@ -29,7 +29,9 @@
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/magic.h"
+#include "saga2/speldefs.h"
#include "saga2/spellbuk.h"
+#include "saga2/spelshow.h"
#include "saga2/motion.h"
#include "saga2/actor.h"
#include "saga2/player.h"
diff --git a/engines/saga2/modal.h b/engines/saga2/modal.h
index af3e6bb1a6..4697759665 100644
--- a/engines/saga2/modal.h
+++ b/engines/saga2/modal.h
@@ -27,6 +27,8 @@
#ifndef SAGA2_MODAL_H
#define SAGA2_MODAL_H
+#include "saga2/floating.h"
+
namespace Saga2 {
void ModalModeSetup(void);
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 09ee2d2a90..4c3af99b0d 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -48,6 +48,8 @@
#include "saga2/grabinfo.h"
#include "saga2/localize.h"
#include "saga2/spellbuk.h"
+#include "saga2/tilevect.h"
+#include "saga2/dispnode.h"
#include "saga2/methods.r" // generated by SAGA
#include "saga2/pclass.r"
diff --git a/engines/saga2/setup.h b/engines/saga2/setup.h
index 4777e54e63..161a7f9287 100644
--- a/engines/saga2/setup.h
+++ b/engines/saga2/setup.h
@@ -27,10 +27,10 @@
#ifndef SAGA2_SETUP_H
#define SAGA2_SETUP_H
-#include "saga2/floating.h"
-
namespace Saga2 {
+struct WindowDecoration;
+
//If Defined Then It Will Print Status
#define WriteStatus
diff --git a/engines/saga2/spelcast.cpp b/engines/saga2/spelcast.cpp
index 5b347d9c22..e0c0efa859 100644
--- a/engines/saga2/spelcast.cpp
+++ b/engines/saga2/spelcast.cpp
@@ -29,11 +29,14 @@
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/magic.h"
+#include "saga2/speldefs.h"
#include "saga2/spellbuk.h"
+#include "saga2/spelshow.h"
#include "saga2/motion.h"
#include "saga2/spelvals.h"
#include "saga2/annoy.h"
#include "saga2/tileline.h"
+#include "saga2/tilevect.h"
namespace Saga2 {
diff --git a/engines/saga2/speldata.cpp b/engines/saga2/speldata.cpp
index acc59c8234..c0e0fe091e 100644
--- a/engines/saga2/speldata.cpp
+++ b/engines/saga2/speldata.cpp
@@ -31,6 +31,7 @@
#include "saga2/dispnode.h"
#include "saga2/spells.h"
#include "saga2/spellbuk.h"
+#include "saga2/spelshow.h"
namespace Saga2 {
diff --git a/engines/saga2/speldraw.cpp b/engines/saga2/speldraw.cpp
index f0094860f6..88e03c9bdb 100644
--- a/engines/saga2/speldraw.cpp
+++ b/engines/saga2/speldraw.cpp
@@ -30,6 +30,7 @@
#include "saga2/rmemfta.h"
#include "saga2/dispnode.h"
#include "saga2/spellbuk.h"
+#include "saga2/spelshow.h"
namespace Saga2 {
diff --git a/engines/saga2/spellbuk.h b/engines/saga2/spellbuk.h
index 55b5ffea6d..c408cb0135 100644
--- a/engines/saga2/spellbuk.h
+++ b/engines/saga2/spellbuk.h
@@ -27,14 +27,11 @@
#ifndef SAGA2_SPELLBUK_H
#define SAGA2_SPELLBUK_H
-#include "saga2/spelshow.h"
-#include "saga2/spells.h"
-#include "saga2/dice.h"
-#include "saga2/effects.h"
-#include "saga2/actor.h"
-
namespace Saga2 {
+struct ResourceSpellEffect;
+struct ResourceSpellItem;
+
// Mana IDs as spells see them
enum SpellManaID {
diff --git a/engines/saga2/spellini.cpp b/engines/saga2/spellini.cpp
index f03c2eafe4..034ce4348d 100644
--- a/engines/saga2/spellini.cpp
+++ b/engines/saga2/spellini.cpp
@@ -27,7 +27,10 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
+#include "saga2/spells.h"
+#include "saga2/objects.h"
#include "saga2/spellbuk.h"
+#include "saga2/spelshow.h"
#include "saga2/spelvals.h"
#include "saga2/tilevect.h"
diff --git a/engines/saga2/spellio.cpp b/engines/saga2/spellio.cpp
index 0d8138371b..73329ff9bb 100644
--- a/engines/saga2/spellio.cpp
+++ b/engines/saga2/spellio.cpp
@@ -30,6 +30,8 @@
#include "saga2/rmemfta.h"
#include "saga2/magic.h"
#include "saga2/spellbuk.h"
+#include "saga2/spellio.h"
+#include "saga2/spelshow.h"
#include "saga2/savefile.h"
namespace Saga2 {
diff --git a/engines/saga2/spellio.h b/engines/saga2/spellio.h
index be27daef02..a5f2849fa4 100644
--- a/engines/saga2/spellio.h
+++ b/engines/saga2/spellio.h
@@ -27,9 +27,6 @@
#ifndef SAGA2_SPELLIO_H
#define SAGA2_SPELLIO_H
-#include "saga2/tile.h"
-#include "saga2/objects.h"
-
namespace Saga2 {
class SpellTarget;
diff --git a/engines/saga2/spellloc.cpp b/engines/saga2/spellloc.cpp
index 556739db38..8f69dc6f49 100644
--- a/engines/saga2/spellloc.cpp
+++ b/engines/saga2/spellloc.cpp
@@ -27,7 +27,9 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
+#include "saga2/objproto.h"
#include "saga2/spellbuk.h"
+#include "saga2/spelshow.h"
#include "saga2/spelvals.h"
diff --git a/engines/saga2/spellsiz.cpp b/engines/saga2/spellsiz.cpp
index 6263616497..51450da1ee 100644
--- a/engines/saga2/spellsiz.cpp
+++ b/engines/saga2/spellsiz.cpp
@@ -27,7 +27,9 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
+#include "saga2/objproto.h"
#include "saga2/spellbuk.h"
+#include "saga2/spelshow.h"
namespace Saga2 {
diff --git a/engines/saga2/spellspr.cpp b/engines/saga2/spellspr.cpp
index c65b859fdc..1ac4347acd 100644
--- a/engines/saga2/spellspr.cpp
+++ b/engines/saga2/spellspr.cpp
@@ -27,7 +27,9 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
+#include "saga2/objproto.h"
#include "saga2/spellbuk.h"
+#include "saga2/spelshow.h"
namespace Saga2 {
diff --git a/engines/saga2/spellsta.cpp b/engines/saga2/spellsta.cpp
index 49fe49274c..49449306c8 100644
--- a/engines/saga2/spellsta.cpp
+++ b/engines/saga2/spellsta.cpp
@@ -27,8 +27,11 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
+#include "saga2/objproto.h"
#include "saga2/spellbuk.h"
#include "saga2/spelvals.h"
+#include "saga2/spelshow.h"
+
namespace Saga2 {
Commit: b1ac2cfe01b7de66a62f0123c8ad97c4cb9d65cc
https://github.com/scummvm/scummvm/commit/b1ac2cfe01b7de66a62f0123c8ad97c4cb9d65cc
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:54+02:00
Commit Message:
SAGA2: Cleanup playmode.cpp
Changed paths:
engines/saga2/playmode.cpp
diff --git a/engines/saga2/playmode.cpp b/engines/saga2/playmode.cpp
index 4b57da870f..a26c204819 100644
--- a/engines/saga2/playmode.cpp
+++ b/engines/saga2/playmode.cpp
@@ -49,8 +49,8 @@
namespace Saga2 {
-const uint32 imageGroupID = RES_ID('I', 'M', 'A', 'G'),
- borderID = RES_ID('B', 'R', 'D', 0);
+const uint32 imageGroupID = MKTAG('I', 'M', 'A', 'G'),
+ borderID = MKTAG('B', 'R', 'D', 0);
const int defaultStatusWait = 15;
@@ -113,13 +113,13 @@ void PlayModeCleanup(void);
// The Mode object for the main "play" mode.
GameMode PlayMode = {
- NULL, // no previous mode
- FALSE, // mode is not nestable
+ nullptr, // no previous mode
+ false, // mode is not nestable
PlayModeSetup,
PlayModeCleanup,
- NULL,
- NULL,
- NULL,
+ nullptr,
+ nullptr,
+ nullptr,
};
/* ===================================================================== *
@@ -163,29 +163,29 @@ extern bool gameRunning;
// Initialize the Play mode
bool checkTileAreaPort(void) {
- if (gameRunning && tileDrawMap.data == NULL) {
+ if (gameRunning && tileDrawMap.data == nullptr) {
// Allocate back buffer for tile rendering
tileDrawMap.size.x = (tileRect.width + tileWidth - 1) & ~tileDXMask;
tileDrawMap.size.y = (tileRect.height + tileWidth - 1) & ~tileDXMask;
- tileDrawMap.data = (uint8 *)RNewPtr(tileDrawMap.bytes(), NULL, "tile display map");
+ tileDrawMap.data = new uint8[tileDrawMap.bytes()];
}
- return tileDrawMap.data != NULL;
+ return tileDrawMap.data != nullptr;
}
void clearTileAreaPort(void) {
- if (gameRunning && tileDrawMap.data != NULL) {
+ if (gameRunning && tileDrawMap.data != nullptr) {
_FillRect(tileDrawMap.data, tileDrawMap.size.x, tileDrawMap.size.x, tileDrawMap.size.y, 0);
}
+
Rect16 rect(0, 0, 640, 480);
mainWindow->invalidate(rect);
-
}
void PlayModeSetup(void) {
// Init resources for images
- if (imageRes == NULL)
+ if (imageRes == nullptr)
imageRes = resFile->newContext(imageGroupID, "image resources");
// Init resources needed by containers.
@@ -200,54 +200,54 @@ void PlayModeSetup(void) {
// Allocate bitmap for drag & drop mouse pointer
objPointerMap.size.x = objPointerMap.size.y = 32;
- objPointerMap.data = (uint8 *)RNewPtr(objPointerMap.bytes(), NULL, "mouse display map");
+ objPointerMap.data = new uint8[objPointerMap.bytes()];
// Create a panelList to contain all controls created
// for tile mode.
// NOTE: Make sure these are allocated first, so that they
// can over-ride other controls.
- assert(speakButtonControls = NEW_UI gPanelList(*mainWindow));
+ assert(speakButtonControls = new gPanelList(*mainWindow));
// Create a control covering the map area.
- speakButtonPanel = NEW_UI gGenericControl(*speakButtonControls,
+ speakButtonPanel = new gGenericControl(*speakButtonControls,
Rect16(0, 0, screenWidth, screenHeight),
0,
cmdClickSpeech);
- speakButtonControls->enable(FALSE);
+ speakButtonControls->enable(false);
// Create a panelList to contain all controls created
// for play mode.
- assert(playControls = NEW_UI gPanelList(*mainWindow));
+ assert(playControls = new gPanelList(*mainWindow));
// Create a panelList to contain all controls created
// for tile mode.
- assert(tileControls = NEW_UI gPanelList(*mainWindow));
+ assert(tileControls = new gPanelList(*mainWindow));
// Create a panelList to contain all controls created
// for stage mode.
- tileControls->enable(FALSE);
+ tileControls->enable(false);
// activate the status line
// this will get deleted by parent panel
- checkAlloc(StatusLine = NEW_UI CStatusLine(*playControls,
+ StatusLine = new CStatusLine(*playControls,
statusLineArea,
"",
&Script10Font,
- NULL,
+ 0,
genericTextPal,
defaultStatusWait, // in frames
0,
- NULL));
+ (void (*)(gEvent&))nullptr);
// placement configurations
Point16 massWeightIndicator = Point16(531, 265);
// activate the indiv mode character mass and weight indicator
- checkAlloc(MassWeightIndicator = NEW_UI CMassWeightIndicator(indivControls, massWeightIndicator));
+ MassWeightIndicator = new CMassWeightIndicator(indivControls, massWeightIndicator);
// activate the plyaer health indicator
- checkAlloc(HealthIndicator = NEW_UI CHealthIndicator(cmdHealthStar));
+ HealthIndicator = new CHealthIndicator(cmdHealthStar);
SetupUserControls();
@@ -275,12 +275,12 @@ void PlayModeCleanup(void) {
closeAllFloatingWindows();
if (playControls) {
delete playControls;
- playControls = NULL;
- StatusLine = NULL;
+ playControls = nullptr;
+ StatusLine = nullptr;
}
if (speakButtonControls) {
delete speakButtonControls;
- speakButtonControls = NULL;
+ speakButtonControls = nullptr;
}
// delete standalone indicators
@@ -294,19 +294,20 @@ void PlayModeCleanup(void) {
// Deallocate back buffer for tile rendering
if (tileDrawMap.data) {
- RDisposePtr(tileDrawMap.data);
- tileDrawMap.data = NULL;
+ delete[] tileDrawMap.data;
+ tileDrawMap.data = nullptr;
}
if (objPointerMap.data) {
- RDisposePtr(objPointerMap.data);
- objPointerMap.data = NULL;
+ delete[] objPointerMap.data;
+ objPointerMap.data = nullptr;
}
mainWindow->removeDecorations();
- if (imageRes) resFile->disposeContext(imageRes);
- imageRes = NULL;
+ if (imageRes)
+ resFile->disposeContext(imageRes);
+ imageRes = nullptr;
cleanupContainers();
}
@@ -337,8 +338,8 @@ void drawCompressedImage(gPort &port, const Point16 pos, void *image) {
map.size = hdr->size;
if (hdr->compress) {
- map.data = (uint8 *)malloc(map.bytes());
- if (map.data == NULL)
+ map.data = new uint8[map.bytes()];
+ if (map.data == nullptr)
return;
unpackImage(&map, map.size.x, map.size.y, hdr->data);
@@ -357,7 +358,7 @@ void drawCompressedImage(gPort &port, const Point16 pos, void *image) {
map.size.x, map.size.y);
if (hdr->compress)
- free(map.data);
+ delete[] map.data;
}
void drawCompressedImageGhosted(gPort &port, const Point16 pos, void *image) {
@@ -368,8 +369,9 @@ void drawCompressedImageGhosted(gPort &port, const Point16 pos, void *image) {
map.size = hdr->size;
- map.data = (uint8 *)RNewPtr(map.bytes(), NULL, "sprite decompression map");
- if (map.data == NULL) return;
+ map.data = new uint8[map.bytes()];
+ if (map.data == nullptr)
+ return;
if (hdr->compress)
unpackImage(&map, map.size.x, map.size.y, hdr->data);
@@ -385,7 +387,7 @@ void drawCompressedImageGhosted(gPort &port, const Point16 pos, void *image) {
pos.x, pos.y,
map.size.x, map.size.y);
- RDisposePtr(map.data);
+ delete[] map.data;
}
void drawCompressedImageToMap(gPixelMap &map, void *image) {
@@ -399,7 +401,8 @@ void drawCompressedImageToMap(gPixelMap &map, void *image) {
if (hdr->compress) {
// if it is then upack it to spec'ed coords.
unpackImage(&map, map.size.x, map.size.y, hdr->data);
- } else map.data = (uint8 *)hdr->data;
+ } else
+ map.data = (uint8 *)hdr->data;
}
Commit: 137e62441e1ce5bdc6ab1c9c43d59ba6b321d20e
https://github.com/scummvm/scummvm/commit/137e62441e1ce5bdc6ab1c9c43d59ba6b321d20e
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:54+02:00
Commit Message:
SAGA2: Cleanup intrface.cpp
Changed paths:
engines/saga2/intrface.cpp
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index 49ce5ee6ee..35d18b41e0 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -51,7 +51,7 @@ namespace Saga2 {
/* ===================================================================== *
External delarations
* ===================================================================== */
-extern ReadyContainerView *TrioCviews[ kNumViews ];
+extern ReadyContainerView *TrioCviews[kNumViews];
extern ReadyContainerView *indivCviewTop, *indivCviewBot;
extern PlayerActor playerList[]; // Master list of all PlayerActors
extern gPanelList *trioControls, *indivControls;
@@ -59,7 +59,7 @@ extern gPanelList *playControls;
extern const uint32 imageGroupID;
extern gPanelList *tileControls;
extern BackWindow *mainWindow;
-extern uint8 fixedColors[ 16 ];
+extern uint8 fixedColors[16];
/* ===================================================================== *
@@ -77,7 +77,7 @@ public:
void setValue(PlayerActorID pID);
- gArmorIndicator(gPanelList &list, const Rect16 &box, void *img, uint16 ident, AppFunc *cmd = NULL)
+ gArmorIndicator(gPanelList &list, const Rect16 &box, void *img, uint16 ident, AppFunc *cmd = nullptr)
: gCompImage(list, box, img, ident, cmd) {
attr.damageAbsorbtion = 0;
attr.damageDivider = 1;
@@ -184,20 +184,20 @@ char *enchantmentNames[] = {
"Immunity to Poison / Green Magic",
"Immunity to Mental Damage",
- NULL
+ nullptr
};
class gEnchantmentDisplay : public gControl {
- uint8 iconFlags[ iconCount ];
+ uint8 iconFlags[iconCount];
void drawClipped(gPort &, const Point16 &, const Rect16 &);
void pointerMove(gPanelMessage &msg);
public:
void setValue(PlayerActorID pID);
- gEnchantmentDisplay(gPanelList &list, uint16 ident, AppFunc *cmd = NULL)
- : gControl(list, Rect16(0, 0, 630, 18), NULL, ident, cmd) {
+ gEnchantmentDisplay(gPanelList &list, uint16 ident, AppFunc *cmd = nullptr)
+ : gControl(list, Rect16(0, 0, 630, 18), nullptr, ident, cmd) {
memset(iconFlags, 0, sizeof iconFlags);
}
};
@@ -224,7 +224,7 @@ extern void unpackImage(gPixelMap *map,
typedef struct {
Point16 size;
int16 compress;
- int8 data[ 2 ];
+ int8 data[2];
} ImageHeader;
@@ -260,7 +260,7 @@ bool userControlsSetup = FALSE;
* ===================================================================== */
// position arrays for all buttons on the individual panels
-Rect16 topBox[ numButtons ] = {
+Rect16 topBox[numButtons] = {
/* portrait */ Rect16(489, 22 + (yContOffset * 0), 65, 72),
/* agress */ Rect16(559, 86 + (yContOffset * 0), 28, 27),
/* jump */ Rect16(592, 86 + (yContOffset * 0), 28, 27),
@@ -271,7 +271,7 @@ Rect16 topBox[ numButtons ] = {
};
-Rect16 midBox[ numButtons ] = {
+Rect16 midBox[numButtons] = {
Rect16(489, 22 + (yContOffset * 1), 65, 72),
Rect16(559, 86 + (yContOffset * 1), 28, 27),
Rect16(592, 86 + (yContOffset * 1), 28, 27),
@@ -283,7 +283,7 @@ Rect16 midBox[ numButtons ] = {
-Rect16 botBox[ numButtons ] = {
+Rect16 botBox[numButtons] = {
Rect16(489, 22 + (yContOffset * 2), 65, 72),
Rect16(559, 86 + (yContOffset * 2), 28, 27),
Rect16(592, 86 + (yContOffset * 2), 28, 27),
@@ -307,14 +307,14 @@ gCompImage *broBtnFrame;
// trio controls
-gMultCompButton *portBtns[ kNumViews ];
-gOwnerSelCompButton *aggressBtns[ kNumViews ];
-//gCompButton *jumpBtns[ kNumViews ];
-gOwnerSelCompButton *centerBtns[ kNumViews ];
-gOwnerSelCompButton *bandingBtns[ kNumViews ];
-gCompImage *namePlates[ kNumViews ];
-gCompImage *namePlateFrames[ kNumViews ];
-gArmorIndicator *armorInd[ kNumViews ];
+gMultCompButton *portBtns[kNumViews];
+gOwnerSelCompButton *aggressBtns[kNumViews];
+//gCompButton *jumpBtns[kNumViews];
+gOwnerSelCompButton *centerBtns[kNumViews];
+gOwnerSelCompButton *bandingBtns[kNumViews];
+gCompImage *namePlates[kNumViews];
+gCompImage *namePlateFrames[kNumViews];
+gArmorIndicator *armorInd[kNumViews];
// individual
gMultCompButton *indivPortBtn;
@@ -330,8 +330,8 @@ gArmorIndicator *indivArmorInd;
gCompButton *menConBtn;
-// [ brother panels ] compressed image non-allocated pointer arrays
-void **portImag[ kNumViews ];
+// [brother panels] compressed image non-allocated pointer arrays
+void **portImag[kNumViews];
void **aggressImag;
//void **jumpImag;
void **centerImag;
@@ -343,7 +343,7 @@ void **phiBtnImag;
void **kevBtnImag;
// portrait name plate things
-void *namePlateImages[ kNumViews];
+void *namePlateImages[kNumViews];
void *namePlateFrameImag;
void *armorImag;
@@ -418,10 +418,10 @@ Rect16 statusLineArea(49, 445, 407, 15);
* ===================================================================== */
// these objhets have to be initialized after resource are initialized
-CStatusLine *StatusLine = NULL;
-CMassWeightIndicator *MassWeightIndicator = NULL;
-CHealthIndicator *HealthIndicator = NULL;
-CManaIndicator *ManaIndicator = NULL;
+CStatusLine *StatusLine = nullptr;
+CMassWeightIndicator *MassWeightIndicator = nullptr;
+CHealthIndicator *HealthIndicator = nullptr;
+CManaIndicator *ManaIndicator = nullptr;
/* ===================================================================== *
Clicks
@@ -451,7 +451,7 @@ CPlaqText::CPlaqText(gPanelList &list,
if (strlen(msg) <= bufSize) {
strcpy(lineBuf, msg);
} else {
- *lineBuf = NULL;
+ *lineBuf = '\0';
}
textFacePal = pal;
@@ -517,7 +517,7 @@ CPortrait::CPortrait(gMultCompButton **portraits,
assert(indivPort);
for (uint16 i = 0; i < numBrothers; i++) {
- assert(portraits[ i ]);
+ assert(portraits[i]);
};
buttons = portraits; // set the pointer for class
@@ -527,7 +527,7 @@ CPortrait::CPortrait(gMultCompButton **portraits,
// start off in a normal facial state
for (uint16 i = 0; i < _numViews + 1; i++) {
- currentState[ i ] = normal;
+ currentState[i] = normal;
}
}
@@ -538,16 +538,16 @@ void CPortrait::setPortrait(uint16 brotherID) {
if (brotherID == uiIndiv) {
WriteStatusF(4, " Brother id %d", brotherID);
- indivButton->setCurrent(currentState[ brotherID ]);
+ indivButton->setCurrent(currentState[brotherID]);
indivButton->invalidate();
} else {
- buttons[ brotherID ]->setCurrent(currentState[ brotherID ]);
- buttons[ brotherID ]->invalidate();
+ buttons[brotherID]->setCurrent(currentState[brotherID]);
+ buttons[brotherID]->invalidate();
}
}
void CPortrait::set(uint16 brotherID, PortraitType type) {
- currentState[ brotherID ] = type;
+ currentState[brotherID] = type;
setPortrait(brotherID);
}
@@ -555,10 +555,10 @@ void CPortrait::set(uint16 brotherID, PortraitType type) {
void CPortrait::ORset(uint16 brotherID, PortraitType type) { // brotherID = post 0
assert(brotherID < _numViews + 1);
- if (type == currentState[ brotherID ]) {
- currentState[ brotherID ] = normal;
+ if (type == currentState[brotherID]) {
+ currentState[brotherID] = normal;
} else {
- currentState[ brotherID ] = type;
+ currentState[brotherID] = type;
}
// set this button to the new state
@@ -570,7 +570,7 @@ size_t appendToStr(char *dst, const char *src, size_t srcLen, size_t maxCpyLen)
cpyLen = MIN(srcLen, maxCpyLen);
memcpy(dst, src, cpyLen);
- dst[ cpyLen ] = '\0';
+ dst[cpyLen] = '\0';
return cpyLen;
}
@@ -593,42 +593,42 @@ void CPortrait::getStateString(char buf[], int8 size, uint16 brotherID) {
ActorAttributes &stats = pa->getBaseStats();
size_t length = 0;
- buf[ size - 1 ] = '\0';
+ buf[size - 1] = '\0';
if (a->isDead()) {
strncpy(buf, DEAD_STATE, size - 1);
return;
}
- buf[ 0 ] = '\0';
+ buf[0] = '\0';
if (a->enchantmentFlags & (1 << actorAsleep)) {
length += appendToStr(
- &buf[ length ],
+ &buf[length],
asleepStr,
elementsof(asleepStr) - 1,
size - length - 1);
} else if (a->enchantmentFlags & (1 << actorParalyzed)) {
length += appendToStr(
- &buf[ length ],
+ &buf[length],
paralysedStr,
elementsof(paralysedStr) - 1,
size - length - 1);
} else if (a->enchantmentFlags & (1 << actorBlind)) {
length += appendToStr(
- &buf[ length ],
+ &buf[length],
blindStr,
elementsof(blindStr) - 1,
size - length - 1);
} else if (a->enchantmentFlags & (1 << actorFear)) {
length += appendToStr(
- &buf[ length ],
+ &buf[length],
afraidStr,
elementsof(afraidStr) - 1,
size - length - 1);
} else if (pa->isAggressive()) {
length += appendToStr(
- &buf[ length ],
+ &buf[length],
angryStr,
elementsof(angryStr) - 1,
size - length - 1);
@@ -637,24 +637,24 @@ void CPortrait::getStateString(char buf[], int8 size, uint16 brotherID) {
if (stats.vitality >= a->effectiveStats.vitality * 3) {
if (length != 0)
length += appendToStr(
- &buf[ length ],
+ &buf[length],
commaStr,
elementsof(commaStr) - 1,
size - length - 1);
length += appendToStr(
- &buf[ length ],
+ &buf[length],
badlyWoundedStr,
elementsof(badlyWoundedStr) - 1,
size - length - 1);
} else if (stats.vitality * 2 > a->effectiveStats.vitality * 3) {
if (length != 0)
length += appendToStr(
- &buf[ length ],
+ &buf[length],
commaStr,
elementsof(commaStr) - 1,
size - length - 1);
length += appendToStr(
- &buf[ length ],
+ &buf[length],
hurtStr,
elementsof(hurtStr) - 1,
size - length - 1);
@@ -663,24 +663,24 @@ void CPortrait::getStateString(char buf[], int8 size, uint16 brotherID) {
if (a->enchantmentFlags & (1 << actorPoisoned)) {
if (length != 0)
length += appendToStr(
- &buf[ length ],
+ &buf[length],
commaStr,
elementsof(commaStr) - 1,
size - length - 1);
length += appendToStr(
- &buf[ length ],
+ &buf[length],
poisonedStr,
elementsof(poisonedStr) - 1,
size - length - 1);
} else if (a->enchantmentFlags & (1 << actorDiseased)) {
if (length != 0)
length += appendToStr(
- &buf[ length ],
+ &buf[length],
commaStr,
elementsof(commaStr) - 1,
size - length - 1);
length += appendToStr(
- &buf[ length ],
+ &buf[length],
diseasedStr,
elementsof(diseasedStr) - 1,
size - length - 1);
@@ -688,7 +688,7 @@ void CPortrait::getStateString(char buf[], int8 size, uint16 brotherID) {
if (length == 0) {
length += appendToStr(
- &buf[ length ],
+ &buf[length],
normalStr,
elementsof(normalStr) - 1,
size - length - 1);
@@ -718,14 +718,14 @@ CStatusLine::CStatusLine(gPanelList &list,
queueHead = queueTail = 0;
for (i = 0; i < elementsof(lineQueue); i++)
- lineQueue[ i ].text = NULL;
+ lineQueue[i].text = nullptr;
}
CStatusLine::~CStatusLine(void) {
while (queueTail != queueHead) {
- assert(lineQueue[ queueTail ].text != NULL);
+ assert(lineQueue[queueTail].text != nullptr);
- RDisposePtr(lineQueue[ queueTail ].text);
+ delete[] lineQueue[queueTail].text;
queueTail = bump(queueTail);
}
}
@@ -736,11 +736,9 @@ void CStatusLine::setLine(char *msg, uint32 frameTime) { // frametime def
if (newHead != queueTail) {
size_t msgLen = strlen(msg);
- if ((lineQueue[ queueHead ].text
- = (char *)RNewPtr(msgLen + 1, NULL, "Status line text"))
- != NULL) {
- strcpy(lineQueue[ queueHead ].text, msg);
- lineQueue[ queueHead ].frameTime = frameTime;
+ if ((lineQueue[queueHead].text = new char[msgLen + 1]()) != nullptr) {
+ strcpy(lineQueue[queueHead].text, msg);
+ lineQueue[queueHead].frameTime = frameTime;
queueHead = newHead;
}
}
@@ -761,16 +759,16 @@ void CStatusLine::experationCheck(void) {
enable(TRUE);
// set up the time for this message
- waitAlarm.set(lineQueue[ queueTail ].frameTime);
- minWaitAlarm.set(lineQueue[ queueTail ].frameTime / 5);
+ waitAlarm.set(lineQueue[queueTail].frameTime);
+ minWaitAlarm.set(lineQueue[queueTail].frameTime / 5);
// copy upto the buffer's size in chars
- strncpy(lineBuf, lineQueue[ queueTail ].text, bufSize - 1);
- lineBuf[ bufSize - 1 ] = '\0';
+ strncpy(lineBuf, lineQueue[queueTail].text, bufSize - 1);
+ lineBuf[bufSize - 1] = '\0';
// free the queue text buffer
- RDisposePtr(lineQueue[ queueTail ].text);
- lineQueue[ queueTail ].text = NULL;
+ delete[] lineQueue[queueTail].text;
+ lineQueue[queueTail].text = nullptr;
// bump the queue tail
queueTail = bump(queueTail);
@@ -832,7 +830,7 @@ CMassWeightIndicator::CMassWeightIndicator(gPanelList *panel, const Point16 &pos
// attach controls to the indivControls panel
// these butttons will get deactivated along with the panel
- checkAlloc(pieMass = NEW_UI gCompImage(*panel,
+ checkAlloc(pieMass = new gCompImage(*panel,
Rect16(massPiePos.x, massPiePos.y, pieXSize, pieYSize),
pieIndImag,
numPieIndImages,
@@ -840,7 +838,7 @@ CMassWeightIndicator::CMassWeightIndicator(gPanelList *panel, const Point16 &pos
type,
cmdMassInd));
- checkAlloc(pieBulk = NEW_UI gCompImage(*panel,
+ checkAlloc(pieBulk = new gCompImage(*panel,
Rect16(bulkPiePos.x, bulkPiePos.y, pieXSize, pieYSize),
pieIndImag,
numPieIndImages,
@@ -849,16 +847,16 @@ CMassWeightIndicator::CMassWeightIndicator(gPanelList *panel, const Point16 &pos
cmdBulkInd));
// mass/bulk back image
- checkAlloc(NEW_UI gCompImage(*panel,
+ checkAlloc(new gCompImage(*panel,
Rect16(backImagePos.x, backImagePos.y, backImageXSize, backImageYSize),
massBulkImag,
uiIndiv,
- NULL));
+ nullptr));
// release resource context
if (containerRes) {
resFile->disposeContext(containerRes);
- containerRes = NULL;
+ containerRes = nullptr;
}
currentMass = 0;
@@ -868,7 +866,7 @@ CMassWeightIndicator::CMassWeightIndicator(gPanelList *panel, const Point16 &pos
if (type > 1) {
containerObject = (GameObject *)panel->userData;
} else {
- containerObject = NULL;
+ containerObject = nullptr;
}
indList.addHead(*this);
@@ -899,8 +897,8 @@ void CMassWeightIndicator::recalculate(void) {
setMassPie(retMass = getWeightRatio(containerObject, mass, FALSE));
setBulkPie(retBulk = getBulkRatio(containerObject, bulk, FALSE));
} else {
- setMassPie(retMass = getWeightRatio(playerList[ getCenterActorPlayerID() ].getActor(), mass, FALSE));
- setBulkPie(retBulk = getBulkRatio(playerList[ getCenterActorPlayerID() ].getActor(), bulk, FALSE));
+ setMassPie(retMass = getWeightRatio(playerList[getCenterActorPlayerID()].getActor(), mass, FALSE));
+ setBulkPie(retBulk = getBulkRatio(playerList[getCenterActorPlayerID()].getActor(), bulk, FALSE));
}
}
@@ -910,7 +908,7 @@ void CMassWeightIndicator::recalculate(void) {
** weight/bulk control ( so it refreshes )
**/
void CMassWeightIndicator::update(void) {
- CMassWeightIndicator *indNode = NULL;
+ CMassWeightIndicator *indNode = nullptr;
if (bRedraw == TRUE) {
for (indNode = (CMassWeightIndicator *)indList.first();
@@ -929,7 +927,7 @@ void CMassWeightIndicator::update(void) {
* ===================================================================== */
// setup the mana color tables
-static uint8 manaColorMap[ CManaIndicator::numManaTypes ][ CManaIndicator::numManaColors + 9 ] = {
+static uint8 manaColorMap[CManaIndicator::numManaTypes][CManaIndicator::numManaColors + 9] = {
// each row has 9 leading zero's to acount for windows colors
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x74, 0x73, 0x72, 0x80, 0x84, 0x83, 0x82, 0x82, 0x81, 0x81, 0xF4, 0xE9, // Red
@@ -947,7 +945,7 @@ static uint8 manaColorMap[ CManaIndicator::numManaTypes ][ CManaIndicator::numMa
CManaIndicator::CManaIndicator(gPanelList &list) : gCompImage(list,
Rect16(x, y, xSize, ySize),
- NULL,
+ nullptr,
0,
cmdManaInd) {
assert(resFile);
@@ -973,43 +971,43 @@ CManaIndicator::CManaIndicator(gPanelList &list) : gCompImage(list,
checkAlloc(wellImage = ImageCache.requestImage(resContext, MKTAG('W', 'E', 'L', 'L')));
// hmm this could be cleaner...
- starRingEndPos[ 0 ] = Point16(redEndX, redEndY);
- starRingEndPos[ 1 ] = Point16(orangeEndX, orangeEndY);
- starRingEndPos[ 2 ] = Point16(yellowEndX, yellowEndY);
- starRingEndPos[ 3 ] = Point16(greenEndX, greenEndY);
- starRingEndPos[ 4 ] = Point16(blueEndX, blueEndY);
- starRingEndPos[ 5 ] = Point16(violetEndX, violetEndY);
-
- starSizes[ 0 ] = Point16(star1XSize, star1YSize);
- starSizes[ 1 ] = Point16(star2XSize, star2YSize);
- starSizes[ 2 ] = Point16(star3XSize, star3YSize);
- starSizes[ 3 ] = Point16(star4XSize, star4YSize);
- starSizes[ 4 ] = Point16(star5XSize, star5YSize);
- starSizes[ 5 ] = Point16(star6XSize, star6YSize);
- starSizes[ 6 ] = Point16(star7XSize, star7YSize);
-
- ringSizes[ 0 ] = Point16(ring1XSize, ring1YSize);
- ringSizes[ 1 ] = Point16(ring2XSize, ring2YSize);
- ringSizes[ 2 ] = Point16(ring3XSize, ring3YSize);
- ringSizes[ 3 ] = Point16(ring4XSize, ring4YSize);
- ringSizes[ 4 ] = Point16(ring5XSize, ring5YSize);
- ringSizes[ 5 ] = Point16(ring6XSize, ring6YSize);
- ringSizes[ 6 ] = Point16(ring7XSize, ring7YSize);
+ starRingEndPos[0] = Point16(redEndX, redEndY);
+ starRingEndPos[1] = Point16(orangeEndX, orangeEndY);
+ starRingEndPos[2] = Point16(yellowEndX, yellowEndY);
+ starRingEndPos[3] = Point16(greenEndX, greenEndY);
+ starRingEndPos[4] = Point16(blueEndX, blueEndY);
+ starRingEndPos[5] = Point16(violetEndX, violetEndY);
+
+ starSizes[0] = Point16(star1XSize, star1YSize);
+ starSizes[1] = Point16(star2XSize, star2YSize);
+ starSizes[2] = Point16(star3XSize, star3YSize);
+ starSizes[3] = Point16(star4XSize, star4YSize);
+ starSizes[4] = Point16(star5XSize, star5YSize);
+ starSizes[5] = Point16(star6XSize, star6YSize);
+ starSizes[6] = Point16(star7XSize, star7YSize);
+
+ ringSizes[0] = Point16(ring1XSize, ring1YSize);
+ ringSizes[1] = Point16(ring2XSize, ring2YSize);
+ ringSizes[2] = Point16(ring3XSize, ring3YSize);
+ ringSizes[3] = Point16(ring4XSize, ring4YSize);
+ ringSizes[4] = Point16(ring5XSize, ring5YSize);
+ ringSizes[5] = Point16(ring6XSize, ring6YSize);
+ ringSizes[6] = Point16(ring7XSize, ring7YSize);
// get rid of resource context
resFile->disposeContext(resContext);
- resContext = NULL;
+ resContext = nullptr;
// set update checks to nominal values
for (uint16 i = 0; i < numManaTypes; i++) {
- currentMana[ i ] = -1;
- currentBaseMana[ i ] = -1;
+ currentMana[i] = -1;
+ currentBaseMana[i] = -1;
}
// init the save map
savedMap.size = Extent16(xSize, ySize);
- savedMap.data = (uint8 *)RNewPtr(savedMap.bytes(), NULL, "Mana indicator save map");
+ savedMap.data = new uint8[savedMap.bytes()];
checkAlloc(savedMap.data);
}
@@ -1023,7 +1021,8 @@ CManaIndicator::~CManaIndicator(void) {
ImageCache.releaseImage(wellImage);
// release the saved map
- if (savedMap.data) RDisposePtr(savedMap.data);
+ if (savedMap.data)
+ delete[] savedMap.data;
}
// this method provides a rect for any of the six mana regions of the control
@@ -1039,7 +1038,7 @@ Rect16 CManaIndicator::getManaRegionRect(int8 nRegion) {
int boxSizeX = xSize / 3;
int boxSizeY = ySize / 2;
- static Rect16 manaRegionRects[ numManaRegions ] = {
+ static Rect16 manaRegionRects[numManaRegions] = {
Rect16(x, y, boxSizeX, boxSizeY),
Rect16(x + boxSizeX, y, boxSizeX, boxSizeY),
Rect16(x + boxSizeX * 2, y, boxSizeX, boxSizeY),
@@ -1048,7 +1047,7 @@ Rect16 CManaIndicator::getManaRegionRect(int8 nRegion) {
Rect16(x + boxSizeX * 2, y + boxSizeY, boxSizeX, boxSizeY)
};
- return manaRegionRects[ nRegion ];
+ return manaRegionRects[nRegion];
}
void CManaIndicator::draw(void) {
@@ -1077,7 +1076,7 @@ void CManaIndicator::drawClipped(gPort &port,
// Do an update to the mana star info if needed,
// if not, do not draw stuff
- calcDraw = update(&playerList[ getCenterActorPlayerID() ]);
+ calcDraw = update(&playerList[getCenterActorPlayerID()]);
if (!calcDraw) {
if (!extent.overlap(clipRect)) return;
@@ -1113,11 +1112,10 @@ void CManaIndicator::drawClipped(gPort &port,
// make a mixing plane and blank it
mixMap.size = Extent16(xSize, ySize);
- mixMap.data = (uint8 *)RNewPtr(mixMap.bytes(), NULL, "Mana indicator work map");
-
+ mixMap.data = new uint8[mixMap.bytes()]();
// make a temp plane and blank it
tempMap.size = Extent16(xSize, ySize);
- tempMap.data = (uint8 *)RNewPtr(tempMap.bytes(), NULL, "Mana indicator work map");
+ tempMap.data = new uint8[tempMap.bytes()]();
// clear out the blit surfaces
memset(mixMap.data, 0, mixMap.bytes());
@@ -1129,8 +1127,8 @@ void CManaIndicator::drawClipped(gPort &port,
// draw each star and ring with color remap
for (uint16 i = 0; i < numManaTypes; i++) {
// get the header for the image pointer passed
- ImageHeader *starHdr = (ImageHeader *)starImages[ manaLines[ i ].starImageIndex ];
- ImageHeader *ringHdr = (ImageHeader *)ringImages[ manaLines[ i ].ringImageIndex ];
+ ImageHeader *starHdr = (ImageHeader *)starImages[manaLines[i].starImageIndex];
+ ImageHeader *ringHdr = (ImageHeader *)ringImages[manaLines[i].ringImageIndex];
// set the buffer blit area to the image size
starMap.size = starHdr->size;
@@ -1139,7 +1137,7 @@ void CManaIndicator::drawClipped(gPort &port,
// see if it's compressed
if (starHdr->compress) {
// allocation of the temp buffer
- starMap.data = (uint8 *)RNewPtr(starMap.bytes(), NULL, "Mana indicator work map");
+ starMap.data = new uint8[starMap.bytes()]();
checkAlloc(starMap.data);
// if it is then upack it to spec'ed coords.
@@ -1149,7 +1147,7 @@ void CManaIndicator::drawClipped(gPort &port,
// see if it's compressed
if (ringHdr->compress) {
// allocation of the temp buffer
- ringMap.data = (uint8 *)RNewPtr(ringMap.bytes(), NULL, "Mana indicator work map");
+ ringMap.data = new uint8[ringMap.bytes()]();
checkAlloc(ringMap.data);
// if it is then upack it to spec'ed coords.
@@ -1157,8 +1155,8 @@ void CManaIndicator::drawClipped(gPort &port,
} else ringMap.data = (uint8 *)ringHdr->data;
// now blit the rings to the mixing surface
- TBlit(&mixMap, &ringMap, manaLines[ i ].ringPos.x, manaLines[ i ].ringPos.y);
- TBlit(&tempMap, &starMap, manaLines[ i ].starPos.x, manaLines[ i ].starPos.y);
+ TBlit(&mixMap, &ringMap, manaLines[i].ringPos.x, manaLines[i].ringPos.y);
+ TBlit(&tempMap, &starMap, manaLines[i].starPos.x, manaLines[i].starPos.y);
// now do a peusdo-log additive thing to the images
uint8 *dst = (uint8 *)mixMap.data;
@@ -1169,12 +1167,12 @@ void CManaIndicator::drawClipped(gPort &port,
for (uint16 j = 0; j < bufferSize; j++) {
// image bug fix/kludge
- if (dst[ j ] > 21) dst[ j ] = 10;
- if (src[ j ] > 21) src[ j ] = 10;
+ if (dst[j] > 21) dst[j] = 10;
+ if (src[j] > 21) src[j] = 10;
// if the tempMap pixel is greater then zero
- if (src[ j ] != 0 && src[ j ] > dst[ j ]) {
- dst[ j ] += src[ j ] - dst[ j ];
+ if (src[j] != 0 && src[j] > dst[j]) {
+ dst[j] += src[j] - dst[j];
}
}
@@ -1186,15 +1184,17 @@ void CManaIndicator::drawClipped(gPort &port,
&mixMap,
0,
0,
- manaColorMap[ i ]);
+ manaColorMap[i]);
// clear out the mixing surfaces
memset(mixMap.data, 0, mixMap.bytes());
memset(tempMap.data, 0, tempMap.bytes());
// dispose the temporary gPixelMap
- if (starHdr->compress) RDisposePtr(starMap.data);
- if (ringHdr->compress) RDisposePtr(ringMap.data);
+ if (starHdr->compress)
+ delete[] starMap.data;
+ if (ringHdr->compress)
+ delete[] ringMap.data;
}
// save this frame
@@ -1211,8 +1211,10 @@ void CManaIndicator::drawClipped(gPort &port,
// dispose of temporary pixelmap
DisposeTempPort(tempPort);
- if (mixMap.data) RDisposePtr(mixMap.data);
- if (tempMap.data) RDisposePtr(tempMap.data);
+ if (mixMap.data)
+ delete[] mixMap.data;
+ if (tempMap.data)
+ delete[] tempMap.data;
pointer.show();
}
@@ -1235,7 +1237,7 @@ bool CManaIndicator::needUpdate(PlayerActor *player) {
baseManaAmount = baseStatsRef.mana(i);
// check for new data
- if (manaAmount != currentMana[ i ] || baseManaAmount != currentBaseMana[ i ]) {
+ if (manaAmount != currentMana[i] || baseManaAmount != currentBaseMana[i]) {
return TRUE;
}
}
@@ -1262,18 +1264,18 @@ bool CManaIndicator::update(PlayerActor *player) {
baseManaAmount = baseStatsRef.mana(i);
// check for new data
- if (manaAmount != currentMana[ i ] || baseManaAmount != currentBaseMana[ i ]) {
+ if (manaAmount != currentMana[i] || baseManaAmount != currentBaseMana[i]) {
newData = TRUE;
- currentMana[ i ] = manaAmount;
- currentBaseMana[ i ] = baseManaAmount;
+ currentMana[i] = manaAmount;
+ currentBaseMana[i] = baseManaAmount;
}
// get manaLine info ( which star/ring image, and position on screen )
// from getStarInfo which takes the mana type index ( i ),
// current mana total, and the player base mana
if (newData == TRUE) {
- getManaLineInfo(i, manaAmount, baseManaAmount, &manaLines[ i ]);
+ getManaLineInfo(i, manaAmount, baseManaAmount, &manaLines[i]);
}
}
@@ -1304,12 +1306,12 @@ void CManaIndicator::getManaLineInfo(uint16 index,
// Calculate the positions of the mana stars, and which images to use.
manaInfo.starPos = LERP(basePos,
- starRingEndPos[ index ],
+ starRingEndPos[index],
(int32)maxLevel,
(int32)manaAmount);
manaInfo.ringPos = LERP(basePos,
- starRingEndPos[ index ],
+ starRingEndPos[index],
(int32)maxLevel,
(int32)baseManaAmount);
@@ -1317,10 +1319,10 @@ void CManaIndicator::getManaLineInfo(uint16 index,
manaInfo.ringImageIndex = clamp(0, baseManaAmount * numStars / maxLevel, numRings - 1);
// now do centering correct for images
- manaInfo.starPos.x -= starSizes[ manaInfo.starImageIndex ].x / 2;
- manaInfo.starPos.y -= starSizes[ manaInfo.starImageIndex ].y / 2;
- manaInfo.ringPos.x -= ringSizes[ manaInfo.ringImageIndex ].x / 2;
- manaInfo.ringPos.y -= ringSizes[ manaInfo.ringImageIndex ].y / 2;
+ manaInfo.starPos.x -= starSizes[manaInfo.starImageIndex].x / 2;
+ manaInfo.starPos.y -= starSizes[manaInfo.starImageIndex].y / 2;
+ manaInfo.ringPos.x -= ringSizes[manaInfo.ringImageIndex].x / 2;
+ manaInfo.ringPos.y -= ringSizes[manaInfo.ringImageIndex].y / 2;
// return the manaLineInfo struct info about mana star ring
*info = manaInfo;
@@ -1344,19 +1346,19 @@ CHealthIndicator::CHealthIndicator(AppFunc *cmd) {
// set the image indexes to nominal startup values
for (i = 0; i < numControls + 1; i++) {
- imageIndexMemory[ i ] = -1;
+ imageIndexMemory[i] = -1;
}
// setup the id's for each of the stars
- starIDs[ 0 ] = uiJulian;
- starIDs[ 1 ] = uiPhillip;
- starIDs[ 2 ] = uiKevin;
+ starIDs[0] = uiJulian;
+ starIDs[1] = uiPhillip;
+ starIDs[2] = uiKevin;
// health controls for the trio view
// deallocated with panel
for (i = 0; i < numControls; i++) {
- checkAlloc(starBtns[ i ] = NEW_UI gCompImage(*trioControls,
+ checkAlloc(starBtns[i] = new gCompImage(*trioControls,
Rect16(starXPos,
starYPos + starYOffset * i,
starXSize,
@@ -1364,25 +1366,25 @@ CHealthIndicator::CHealthIndicator(AppFunc *cmd) {
starImag,
starNum,
starInitial,
- starIDs[ i ],
+ starIDs[i],
cmd));
// image control for the star border/frame trio mode
- checkAlloc(NEW_UI gCompImage(*trioControls,
+ checkAlloc(new gCompImage(*trioControls,
Rect16(frameXPos,
frameYPos + starYOffset * i,
frameXSize,
frameYSize),
starFrameImag,
0,
- NULL));
+ nullptr));
}
// health control for individual mode
// deallocated with panel
- checkAlloc(indivStarBtn = NEW_UI gCompImage(*indivControls,
+ checkAlloc(indivStarBtn = new gCompImage(*indivControls,
Rect16(starXPos,
starYPos,
starXSize,
@@ -1394,19 +1396,19 @@ CHealthIndicator::CHealthIndicator(AppFunc *cmd) {
cmd));
// image control for the star border/frame indiv mode
- checkAlloc(NEW_UI gCompImage(*indivControls,
+ checkAlloc(new gCompImage(*indivControls,
Rect16(frameXPos,
frameYPos,
frameXSize,
frameYSize),
starFrameImag,
0,
- NULL));
+ nullptr));
// release resource context
if (healthRes) {
resFile->disposeContext(healthRes);
- healthRes = NULL;
+ healthRes = nullptr;
}
}
@@ -1434,29 +1436,29 @@ void CHealthIndicator::updateStar(gCompImage *starCtl, int32 bro, int32 baseVita
imageIndex = (int16)(sqrt((double)MAX(0, curVitality)) * maxStar) / sqrt((double)baseVitality);
// prevent needless draws
- if (imageIndexMemory[ bro ] != imageIndex) {
+ if (imageIndexMemory[bro] != imageIndex) {
starCtl->setCurrent(imageIndex);
starCtl->invalidate();
- imageIndexMemory[ bro ] = imageIndex;
+ imageIndexMemory[bro] = imageIndex;
}
}
void CHealthIndicator::update(void) {
if (indivControlsFlag) {
// get the stats for the selected brother
- int16 baseVitality = playerList[ translatePanID(uiIndiv) ].getBaseStats().vitality;
- int16 currVitality = playerList[ translatePanID(uiIndiv) ].getEffStats()->vitality;
+ int16 baseVitality = playerList[translatePanID(uiIndiv)].getBaseStats().vitality;
+ int16 currVitality = playerList[translatePanID(uiIndiv)].getEffStats()->vitality;
updateStar(indivStarBtn, uiIndiv, baseVitality, currVitality);
} else {
for (uint16 i = 0; i < numControls; i++) {
// get the stats for the selected brother
- int16 baseVitality = playerList[ i ].getBaseStats().vitality;
- int16 currVitality = playerList[ i ].getEffStats()->vitality;
+ int16 baseVitality = playerList[i].getBaseStats().vitality;
+ int16 currVitality = playerList[i].getEffStats()->vitality;
- updateStar(starBtns[ i ], i, baseVitality, currVitality);
+ updateStar(starBtns[i], i, baseVitality, currVitality);
}
}
}
@@ -1471,7 +1473,7 @@ void writePlaqText(gPort &port,
textPallete &pal,
bool hiLite,
const char *msg, ...) {
- char lineBuf[ 128 ];
+ char lineBuf[128];
va_list argptr;
int16 cnt;
Rect16 workRect;
@@ -1523,7 +1525,7 @@ void writePlaqTextPos(gPort &port,
textPallete &pal,
bool hiLite,
const char *msg, ...) {
- char lineBuf[ 128 ];
+ char lineBuf[128];
va_list argptr;
int16 cnt;
Point16 drawPos;
@@ -1598,7 +1600,7 @@ void **loadButtonRes(hResContext *con, int16 resID, int16 numRes) {
for (i = 0, k = resID; i < numRes; i++, k++) {
// get an image from the image cache
- images[ i ] = ImageCache.requestImage(con, MKTAG('B', 'T', 'N', k));
+ images[i] = ImageCache.requestImage(con, MKTAG('B', 'T', 'N', k));
}
return images;
@@ -1614,7 +1616,7 @@ void **loadButtonRes(hResContext *con, int16 resID, int16 numRes, char a, char b
void **images = (void **) TALLOC(sizeof(void *)*numRes, memInterface);
for (i = 0, k = resID; i < numRes; i++, k++) {
- images[ i ] = ImageCache.requestImage(con, MKTAG(a, b, c, k));
+ images[i] = ImageCache.requestImage(con, MKTAG(a, b, c, k));
}
return images;
@@ -1632,7 +1634,7 @@ void unloadImageRes(void **images, int16 numRes) {
if (images) {
for (i = 0; i < numRes; i++) {
- ImageCache.releaseImage(images[ i ]);
+ ImageCache.releaseImage(images[i]);
}
delete images;
@@ -1649,7 +1651,7 @@ void SetupUserControls(void) {
hResContext *imageRes;
// brother panel id's
- uint16 brotherIDs[ kNumViews ] = { uiJulian, uiPhillip, uiKevin };
+ uint16 brotherIDs[kNumViews] = { uiJulian, uiPhillip, uiKevin };
// portrait resource indexes
int16 portResNum[] = { 0, 0, 0 };
@@ -1680,7 +1682,7 @@ void SetupUserControls(void) {
// set up the portrait name plates
for (n = 0; n < kNumViews; n++) {
- checkAlloc(namePlateImages[ n ] = ImageCache.requestImage(imageRes, MKTAG('B', 'T', 'N', namePlateResNum[ n ])));
+ checkAlloc(namePlateImages[n] = ImageCache.requestImage(imageRes, MKTAG('B', 'T', 'N', namePlateResNum[n])));
}
// get the frame image
@@ -1689,58 +1691,58 @@ void SetupUserControls(void) {
// clean out the old context
if (imageRes) resFile->disposeContext(imageRes);
- imageRes = NULL;
+ imageRes = nullptr;
// init the resource handle with the face group context
imageRes = resFile->newContext(faceGroupID, "face resources");
// set up the portrait button images
for (n = 0; n < kNumViews; n++) {
- checkAlloc(portImag[ n ] = loadButtonRes(imageRes, portResNum[ n ], numPortImages, broNames[ n ].a, broNames[ n ].b, broNames[ n ].c));
+ checkAlloc(portImag[n] = loadButtonRes(imageRes, portResNum[n], numPortImages, broNames[n].a, broNames[n].b, broNames[n].c));
}
// setup stand alone controls
- checkAlloc(optBtn = NEW_UI gCompButton(*playControls, optBtnRect, optBtnImag,
+ checkAlloc(optBtn = new gCompButton(*playControls, optBtnRect, optBtnImag,
numBtnImages, 0, cmdOptions));
- checkAlloc(enchDisp = NEW_UI gEnchantmentDisplay(*playControls, 0));
+ checkAlloc(enchDisp = new gEnchantmentDisplay(*playControls, 0));
// setup the trio user cntl buttons
for (n = 0; n < kNumViews; n++) {
// portrait button
- checkAlloc(portBtns[ n ] = NEW_UI gMultCompButton(*trioControls, views[ n ][ index++ ],
- portImag[ n ], numPortImages, 0, FALSE, brotherIDs[ n ], cmdPortrait));
+ checkAlloc(portBtns[n] = new gMultCompButton(*trioControls, views[n][index++],
+ portImag[n], numPortImages, 0, FALSE, brotherIDs[n], cmdPortrait));
- portBtns[ n ]->setMousePoll(TRUE);
+ portBtns[n]->setMousePoll(TRUE);
// aggressive button
- checkAlloc(aggressBtns[ n ] = NEW_UI gOwnerSelCompButton(*trioControls, views[ n ][ index++ ],
- aggressImag, numBtnImages, brotherIDs[ n ], cmdAggressive));
+ checkAlloc(aggressBtns[n] = new gOwnerSelCompButton(*trioControls, views[n][index++],
+ aggressImag, numBtnImages, brotherIDs[n], cmdAggressive));
// jump button
-// checkAlloc( jumpBtns[ n ] = NEW_UI gCompButton( *trioControls, views[ n ][ index++ ],
-// jumpImag, numBtnImages, brotherIDs[ n ], cmdJump ) );
+// checkAlloc( jumpBtns[n] = new gCompButton( *trioControls, views[n][index++],
+// jumpImag, numBtnImages, brotherIDs[n], cmdJump ) );
// name plates that go under the portraits
- checkAlloc(armorInd[ n ] = NEW_UI gArmorIndicator(*trioControls, views[ n ][ index++ ],
- armorImag, brotherIDs[ n ], cmdArmor));
+ checkAlloc(armorInd[n] = new gArmorIndicator(*trioControls, views[n][index++],
+ armorImag, brotherIDs[n], cmdArmor));
// center on brother
- checkAlloc(centerBtns[ n ] = NEW_UI gOwnerSelCompButton(*trioControls, views[ n ][ index++ ],
- centerImag, numBtnImages, brotherIDs[ n ], cmdCenter));
+ checkAlloc(centerBtns[n] = new gOwnerSelCompButton(*trioControls, views[n][index++],
+ centerImag, numBtnImages, brotherIDs[n], cmdCenter));
// banding
- checkAlloc(bandingBtns[ n ] = NEW_UI gOwnerSelCompButton(*trioControls, views[ n ][ index++ ],
- bandingImag, numBtnImages, brotherIDs[ n ], cmdBand));
+ checkAlloc(bandingBtns[n] = new gOwnerSelCompButton(*trioControls, views[n][index++],
+ bandingImag, numBtnImages, brotherIDs[n], cmdBand));
// name plates that go under the portraits
- checkAlloc(namePlates[ n ] = NEW_UI gCompImage(*trioControls, views[ n ][ index++ ],
- namePlateImages[ n ], 0, NULL));
+ checkAlloc(namePlates[n] = new gCompImage(*trioControls, views[n][index++],
+ namePlateImages[n], 0, nullptr));
// the frames for the name plates
- checkAlloc(namePlateFrames[ n ] = NEW_UI gCompImage(*trioControls, views[ n ][ index++ ],
- namePlateFrameImag, 0, NULL));
+ checkAlloc(namePlateFrames[n] = new gCompImage(*trioControls, views[n][index++],
+ namePlateFrameImag, 0, nullptr));
index = 0;
}
@@ -1748,69 +1750,69 @@ void SetupUserControls(void) {
// individual control buttons
// portrait button
- checkAlloc(indivPortBtn = NEW_UI gMultCompButton(*indivControls, views[ 0 ][ index++ ],
- portImag[ 0 ], numPortImages, 0, FALSE, uiIndiv, cmdPortrait));
+ checkAlloc(indivPortBtn = new gMultCompButton(*indivControls, views[0][index++],
+ portImag[0], numPortImages, 0, FALSE, uiIndiv, cmdPortrait));
indivPortBtn->setMousePoll(TRUE);
// aggressive button
- checkAlloc(indivAggressBtn = NEW_UI gOwnerSelCompButton(*indivControls, views[ 0 ][ index++ ],
+ checkAlloc(indivAggressBtn = new gOwnerSelCompButton(*indivControls, views[0][index++],
aggressImag, numBtnImages, uiIndiv, cmdAggressive));
// jump button
-// checkAlloc( indivJumpBtn = NEW_UI gCompButton( *indivControls, views[ 0 ][ index++ ],
+// checkAlloc( indivJumpBtn = new gCompButton( *indivControls, views[0][index++],
// jumpImag, numBtnImages, uiIndiv, cmdJump ) );
- checkAlloc(indivArmorInd = NEW_UI gArmorIndicator(*indivControls, views[ 0 ][ index++ ],
+ checkAlloc(indivArmorInd = new gArmorIndicator(*indivControls, views[0][index++],
armorImag, uiIndiv, cmdArmor));
// center on brother
- checkAlloc(indivCenterBtn = NEW_UI gOwnerSelCompButton(*indivControls, views[ 0 ][ index++ ],
+ checkAlloc(indivCenterBtn = new gOwnerSelCompButton(*indivControls, views[0][index++],
centerImag, numBtnImages, uiIndiv, cmdCenter));
// banding
- checkAlloc(indivBandingBtn = NEW_UI gOwnerSelCompButton(*indivControls, views[ 0 ][ index++ ],
+ checkAlloc(indivBandingBtn = new gOwnerSelCompButton(*indivControls, views[0][index++],
bandingImag, numBtnImages, uiIndiv, cmdBand));
// name plates that go under the portraits
- checkAlloc(indivNamePlate = NEW_UI gCompImage(*indivControls, views[ 0 ][ index++ ],
- namePlateImages[ 0 ], 0, NULL));
+ checkAlloc(indivNamePlate = new gCompImage(*indivControls, views[0][index++],
+ namePlateImages[0], 0, nullptr));
// the frames for the name plates
- checkAlloc(indivNamePlateFrame = NEW_UI gCompImage(*indivControls, views[ 0 ][ index++ ],
- namePlateFrameImag, 0, NULL));
+ checkAlloc(indivNamePlateFrame = new gCompImage(*indivControls, views[0][index++],
+ namePlateFrameImag, 0, nullptr));
// setup the portrait object
- checkAlloc(Portrait = NEW_UI CPortrait(portBtns, // portrait buttons
+ checkAlloc(Portrait = new CPortrait(portBtns, // portrait buttons
indivPortBtn,
numPortImages,// num of images per button
kNumViews)); // number of brothers
// mental container button
- checkAlloc(menConBtn = NEW_UI gCompButton(*indivControls, menConBtnRect,
+ checkAlloc(menConBtn = new gCompButton(*indivControls, menConBtnRect,
menConBtnImag, numBtnImages, uiIndiv, cmdBrain));
// brother selection buttons >>> need to replace these with sticky buttons
- checkAlloc(julBtn = NEW_UI gOwnerSelCompButton(*indivControls, julBtnRect,
+ checkAlloc(julBtn = new gOwnerSelCompButton(*indivControls, julBtnRect,
julBtnImag, numBtnImages, uiJulian, cmdBroChange));
- checkAlloc(phiBtn = NEW_UI gOwnerSelCompButton(*indivControls, phiBtnRect,
+ checkAlloc(phiBtn = new gOwnerSelCompButton(*indivControls, phiBtnRect,
phiBtnImag, numBtnImages, uiPhillip, cmdBroChange));
- checkAlloc(kevBtn = NEW_UI gOwnerSelCompButton(*indivControls, kevBtnRect,
+ checkAlloc(kevBtn = new gOwnerSelCompButton(*indivControls, kevBtnRect,
kevBtnImag, numBtnImages, uiKevin, cmdBroChange));
// frame for brother buttons
- checkAlloc(broBtnFrame = NEW_UI gCompImage(*indivControls, broBtnRect,
- broBtnFrameImag, uiIndiv, NULL));
+ checkAlloc(broBtnFrame = new gCompImage(*indivControls, broBtnRect,
+ broBtnFrameImag, uiIndiv, nullptr));
// make the mana indicator
- checkAlloc(ManaIndicator = NEW_UI CManaIndicator(*indivControls));
+ checkAlloc(ManaIndicator = new CManaIndicator(*indivControls));
ManaIndicator->setMousePoll(TRUE);
// get rid of the resource contexts
if (imageRes) {
resFile->disposeContext(imageRes);
- imageRes = NULL;
+ imageRes = nullptr;
}
//The controls need to be enabled but undrawn at startup
@@ -1856,7 +1858,7 @@ void CleanupButtonImages(void) {
// portraits
for (i = 0; i < kNumViews; i++) {
- unloadImageRes(portImag[ i ], numPortImages);
+ unloadImageRes(portImag[i], numPortImages);
}
// name plate frame
@@ -1868,7 +1870,7 @@ void CleanupButtonImages(void) {
// name plates
for (i = 0; i < kNumViews; i++) {
- ImageCache.releaseImage(namePlateImages[ i ]);
+ ImageCache.releaseImage(namePlateImages[i]);
}
}
@@ -1878,7 +1880,7 @@ void updateIndicators(void) {
// mana indicator update check
if (isIndivMode()) {
- if (ManaIndicator->needUpdate(&playerList[ getCenterActorPlayerID() ])) {
+ if (ManaIndicator->needUpdate(&playerList[getCenterActorPlayerID()])) {
// redraw the region that is not covered by any other window
ManaIndicator->invalidate();
}
@@ -1963,8 +1965,8 @@ void updateReadyContainers(void) {
if (indivControlsFlag) {
indivCviewTop->invalidate();
indivCviewBot->invalidate();
- } else if (TrioCviews[ getCenterActorPlayerID() ]) {
- TrioCviews[ getCenterActorPlayerID() ]->invalidate();
+ } else if (TrioCviews[getCenterActorPlayerID()]) {
+ TrioCviews[getCenterActorPlayerID()]->invalidate();
}
}
@@ -1980,32 +1982,32 @@ void setIndivBtns(uint16 brotherID) { // top = 0, mid = 1, bot = 2
indivBrother = brotherID;
// set all the individual brother buttons to the correct states
- indivCenterBtn->select(centerBtns[ brotherID ]->isSelected());
- indivCenterBtn->ghost(centerBtns[ brotherID ]->isGhosted());
- //indivStarBtn->setCurrent( ( uint16 )starBtns[ brotherID ]->getCurrent() );
- indivPortBtn->setImages(portImag[ brotherID ]);
- indivNamePlate->setImage(namePlateImages[ brotherID ]);
+ indivCenterBtn->select(centerBtns[brotherID]->isSelected());
+ indivCenterBtn->ghost(centerBtns[brotherID]->isGhosted());
+ //indivStarBtn->setCurrent( ( uint16 )starBtns[brotherID]->getCurrent() );
+ indivPortBtn->setImages(portImag[brotherID]);
+ indivNamePlate->setImage(namePlateImages[brotherID]);
Portrait->set(uiIndiv, Portrait->getCurrentState(brotherID));
- indivBandingBtn->select(bandingBtns[ brotherID ]->isSelected());
- indivBandingBtn->ghost(bandingBtns[ brotherID ]->isGhosted());
- indivAggressBtn->select(aggressBtns[ brotherID ]->isSelected());
- indivAggressBtn->ghost(aggressBtns[ brotherID ]->isGhosted());
+ indivBandingBtn->select(bandingBtns[brotherID]->isSelected());
+ indivBandingBtn->ghost(bandingBtns[brotherID]->isGhosted());
+ indivAggressBtn->select(aggressBtns[brotherID]->isSelected());
+ indivAggressBtn->ghost(aggressBtns[brotherID]->isGhosted());
indivArmorInd->setValue(brotherID);
- indivArmorInd->ghost(armorInd[ brotherID ]->isGhosted());
+ indivArmorInd->ghost(armorInd[brotherID]->isGhosted());
setEnchantmentDisplay();
// point the read containers to the correct brother
if (brotherID > playerActors) brotherID = playerActors;
indivCviewTop->setContainer(GameObject::objectAddress(ActorBaseID + brotherID));
- indivCviewTop->ghost(TrioCviews[ brotherID ]->isGhosted());
+ indivCviewTop->ghost(TrioCviews[brotherID]->isGhosted());
indivCviewBot->setContainer(GameObject::objectAddress(ActorBaseID + brotherID));
- indivCviewBot->ghost(TrioCviews[ brotherID ]->isGhosted());
+ indivCviewBot->ghost(TrioCviews[brotherID]->isGhosted());
// now set the indicators for mass and bulk
uint16 pieWeightRatio = MassWeightIndicator->getMassPieDiv();
uint16 pieBulkRatio = MassWeightIndicator->getBulkPieDiv();
- PlayerActor *brother = &playerList[ brotherID ];
+ PlayerActor *brother = &playerList[brotherID];
MassWeightIndicator->setMassPie(getWeightRatio(brother->getActor(), pieWeightRatio, FALSE));
MassWeightIndicator->setBulkPie(getBulkRatio(brother->getActor(), pieBulkRatio, FALSE));
@@ -2016,12 +2018,12 @@ void setTrioBtns(void) {
indivControlsFlag = FALSE;
// reset any value that might have changed in idividual mode
- centerBtns[ indivBrother ]->select(indivCenterBtn->isSelected());
- bandingBtns[ indivBrother ]->select(indivBandingBtn->isSelected());
+ centerBtns[indivBrother]->select(indivCenterBtn->isSelected());
+ bandingBtns[indivBrother]->select(indivBandingBtn->isSelected());
Portrait->set(indivBrother, Portrait->getCurrentState(uiIndiv));
- aggressBtns[ indivBrother ]->select(indivAggressBtn->isSelected());
+ aggressBtns[indivBrother]->select(indivAggressBtn->isSelected());
- armorInd[ indivBrother ]->setValue(indivBrother);
+ armorInd[indivBrother]->setValue(indivBrother);
setEnchantmentDisplay();
}
@@ -2052,7 +2054,7 @@ void setCenterBrother(uint16 whichBrother) {
mouseInfo.replaceObject();
// set the new center actor
- setCenterActor(&playerList[ whichBrother ]);
+ setCenterActor(&playerList[whichBrother]);
}
uint16 translatePanID(uint16 panID) {
@@ -2075,8 +2077,8 @@ void updateBrotherPortrait(uint16 brotherID, int16 pType) {
void updateBrotherAggressionButton(uint16 brotherID, bool aggressive) {
if (userControlsSetup) {
- aggressBtns[ brotherID ]->select(aggressive);
- aggressBtns[ brotherID ]->ghost(isBrotherDead(brotherID));
+ aggressBtns[brotherID]->select(aggressive);
+ aggressBtns[brotherID]->ghost(isBrotherDead(brotherID));
if (brotherID == indivBrother) {
indivAggressBtn->select(aggressive);
@@ -2090,8 +2092,8 @@ void updateBrotherAggressionButton(uint16 brotherID, bool aggressive) {
void updateBrotherBandingButton(uint16 brotherID, bool banded) {
if (userControlsSetup) {
- bandingBtns[ brotherID ]->select(banded);
- bandingBtns[ brotherID ]->ghost(isBrotherDead(brotherID));
+ bandingBtns[brotherID]->select(banded);
+ bandingBtns[brotherID]->ghost(isBrotherDead(brotherID));
if (brotherID == indivBrother) {
indivBandingBtn->select(banded);
@@ -2116,13 +2118,13 @@ void updateBrotherRadioButtons(uint16 brotherID) {
kevBtn->ghost(isBrotherDead(uiKevin));
// set the center brother buttons
- centerBtns[ uiJulian ]->select(jul);
- centerBtns[ uiPhillip ]->select(phi);
- centerBtns[ uiKevin ]->select(kev);
+ centerBtns[uiJulian]->select(jul);
+ centerBtns[uiPhillip]->select(phi);
+ centerBtns[uiKevin]->select(kev);
- centerBtns[ uiJulian ]->ghost(isBrotherDead(uiJulian));
- centerBtns[ uiPhillip ]->ghost(isBrotherDead(uiPhillip));
- centerBtns[ uiKevin ]->ghost(isBrotherDead(uiKevin));
+ centerBtns[uiJulian]->ghost(isBrotherDead(uiJulian));
+ centerBtns[uiPhillip]->ghost(isBrotherDead(uiPhillip));
+ centerBtns[uiKevin]->ghost(isBrotherDead(uiKevin));
if (brotherID == indivBrother) {
indivCenterBtn->select(TRUE);
@@ -2136,8 +2138,8 @@ void updateBrotherRadioButtons(uint16 brotherID) {
void updateBrotherArmor(uint16 brotherID) {
if (userControlsSetup) {
- armorInd[ brotherID ]->setValue(brotherID);
- armorInd[ brotherID ]->ghost(isBrotherDead(brotherID));
+ armorInd[brotherID]->setValue(brotherID);
+ armorInd[brotherID]->ghost(isBrotherDead(brotherID));
if (brotherID == indivBrother) {
indivArmorInd->setValue(brotherID);
@@ -2173,7 +2175,7 @@ void updateAllUserControls(void) {
}
// Ghost the ready container if he's dead.
- TrioCviews[ brotherID ]->ghost(dead);
+ TrioCviews[brotherID]->ghost(dead);
}
}
} else {
@@ -2198,7 +2200,7 @@ void updateBrotherControls(PlayerActorID brotherID) {
}
// Ghost the ready container if he's dead.
- TrioCviews[ brotherID ]->ghost(dead);
+ TrioCviews[brotherID]->ghost(dead);
}
}
@@ -2214,7 +2216,7 @@ APPFUNC(cmdPortrait) {
case gEventNewValue:
- if (mouseObject != NULL) {
+ if (mouseObject != nullptr) {
PlayerActor *pa = getPlayerActorAddress(translatePanID(panID));
Actor *centerActorPtr = getCenterActor();
@@ -2266,19 +2268,19 @@ APPFUNC(cmdPortrait) {
case gEventMouseMove:
if (ev.value == gCompImage::leave) {
- mouseInfo.setText(NULL);
+ mouseInfo.setText(nullptr);
mouseInfo.setDoable(TRUE);
break;
}
// if (ev.value == gCompImage::enter)
{
- if (mouseObject != NULL) {
+ if (mouseObject != nullptr) {
PlayerActor *pa = getPlayerActorAddress(translatePanID(panID));
Actor *targetActor = pa->getActor(),
*enactor = getCenterActor();
- mouseInfo.setText(NULL);
+ mouseInfo.setText(nullptr);
if ((enactor->getLocation() - targetActor->getLocation()).quickHDistance() > 96) {
mouseInfo.setDoable(FALSE);
@@ -2288,8 +2290,8 @@ APPFUNC(cmdPortrait) {
} else {
// working buffer
- char buf[ bufSize ];
- char state[ stateBufSize ];
+ char buf[bufSize];
+ char state[stateBufSize];
uint16 brotherID = translatePanID(panID);
Portrait->getStateString(state, stateBufSize, brotherID);
@@ -2345,7 +2347,7 @@ APPFUNC(cmdAggressive) {
// ? ON_AGRESS
// : OFF_AGRESS);
} else if (ev.value == gCompImage::leave) {
- mouseInfo.setText(NULL);
+ mouseInfo.setText(nullptr);
}
}
}
@@ -2374,7 +2376,7 @@ APPFUNC(cmdArmor) {
if (ev.value == gCompImage::enter) {
gArmorIndicator *gai = (gArmorIndicator *)ev.panel;
- char buf[ 128 ];
+ char buf[128];
if (gai->attr.damageAbsorbtion == 0
&& gai->attr.defenseBonus == 0) {
@@ -2390,7 +2392,7 @@ APPFUNC(cmdArmor) {
mouseInfo.setText(buf);
}
} else if (ev.value == gCompImage::leave) {
- mouseInfo.setText(NULL);
+ mouseInfo.setText(nullptr);
}
}
}
@@ -2411,7 +2413,7 @@ APPFUNC(cmdCenter) {
// ? ON_CENTER
// : OFF_CENTER);
} else if (ev.value == gCompImage::leave) {
- mouseInfo.setText(NULL);
+ mouseInfo.setText(nullptr);
}
}
}
@@ -2446,7 +2448,7 @@ APPFUNC(cmdBand) {
// ? ON_BANDED
// : OFF_BANDED);
} else if (ev.value == gCompImage::leave) {
- mouseInfo.setText(NULL);
+ mouseInfo.setText(nullptr);
}
}
}
@@ -2457,7 +2459,7 @@ APPFUNC(cmdOptions) {
//openOptionsPanel();
} else if (ev.eventType == gEventMouseMove) {
if (ev.value == gCompImage::enter) mouseInfo.setText(OPTIONS_PANEL);
- else if (ev.value == gCompImage::leave) mouseInfo.setText(NULL);
+ else if (ev.value == gCompImage::leave) mouseInfo.setText(nullptr);
}
}
@@ -2478,8 +2480,8 @@ APPFUNC(cmdBroChange) {
if (ev.value == gCompImage::enter) {
// working buffer
- char buf[ bufSize ];
- char state[ stateBufSize ];
+ char buf[bufSize];
+ char state[stateBufSize];
uint16 brotherID = translatePanID(panID);
Portrait->getStateString(state, stateBufSize, brotherID);
@@ -2498,7 +2500,7 @@ APPFUNC(cmdBroChange) {
// set the text in the cursor
mouseInfo.setText(buf);
} else if (ev.value == gCompImage::leave) {
- mouseInfo.setText(NULL);
+ mouseInfo.setText(nullptr);
}
}
}
@@ -2508,7 +2510,7 @@ APPFUNC(cmdHealthStar) {
if (ev.eventType == gEventMouseMove) {
if (ev.value == gCompImage::leave) {
- mouseInfo.setText(NULL);
+ mouseInfo.setText(nullptr);
return;
}
@@ -2517,10 +2519,10 @@ APPFUNC(cmdHealthStar) {
}
// get the stats for the selected brother
- int16 baseVitality = playerList[ transBroID ].getBaseStats().vitality;
- int16 currVitality = playerList[ transBroID ].getEffStats()->vitality;
+ int16 baseVitality = playerList[transBroID].getBaseStats().vitality;
+ int16 currVitality = playerList[transBroID].getEffStats()->vitality;
- char buf[ 40 ];
+ char buf[40];
sprintf(buf, "%s %d/%d", HEALTH_HINT, currVitality, baseVitality);
mouseInfo.setText(buf);
@@ -2528,15 +2530,15 @@ APPFUNC(cmdHealthStar) {
}
APPFUNC(cmdMassInd) {
- gWindow *win = NULL;
- GameObject *containerObject = NULL;
+ gWindow *win = nullptr;
+ GameObject *containerObject = nullptr;
if (ev.eventType == gEventMouseMove) {
if (ev.value == gCompImage::enter) {
const int bufSize = 40;
int curWeight;
uint16 baseWeight;
- char buf[ bufSize ];
+ char buf[bufSize];
win = ev.panel->getWindow(); // get the window pointer
@@ -2546,7 +2548,7 @@ APPFUNC(cmdMassInd) {
if (ev.panel->id > 1) {
containerObject = (GameObject *)win->userData;
} else {
- containerObject = (GameObject *)playerList[ getCenterActorPlayerID() ].getActor();
+ containerObject = (GameObject *)playerList[getCenterActorPlayerID()].getActor();
}
assert(containerObject);
@@ -2559,21 +2561,21 @@ APPFUNC(cmdMassInd) {
} else
mouseInfo.setText(UNK_WEIGHT_HINT);
} else if (ev.value == gCompImage::leave) {
- mouseInfo.setText(NULL);
+ mouseInfo.setText(nullptr);
}
}
}
APPFUNC(cmdBulkInd) {
- gWindow *win = NULL;
- GameObject *containerObject = NULL;
+ gWindow *win = nullptr;
+ GameObject *containerObject = nullptr;
if (ev.eventType == gEventMouseMove) {
if (ev.value == gCompImage::enter) {
const int bufSize = 40;
uint16 baseBulk = 100;
- char buf[ bufSize ];
+ char buf[bufSize];
int curBulk;
win = ev.panel->getWindow(); // get the window pointer
@@ -2584,7 +2586,7 @@ APPFUNC(cmdBulkInd) {
if (ev.panel->id > 1) {
containerObject = (GameObject *)win->userData;
} else {
- containerObject = (GameObject *)playerList[ getCenterActorPlayerID() ].getActor();
+ containerObject = (GameObject *)playerList[getCenterActorPlayerID()].getActor();
}
assert(containerObject);
@@ -2597,7 +2599,7 @@ APPFUNC(cmdBulkInd) {
} else
mouseInfo.setText(UNK_BULK_HINT);
} else if (ev.value == gCompImage::leave) {
- mouseInfo.setText(NULL);
+ mouseInfo.setText(nullptr);
}
}
}
@@ -2606,12 +2608,12 @@ APPFUNC(cmdManaInd) {
if (ev.eventType == gEventMouseMove) {
if (ev.value != gCompImage::leave) {
const int BUF_SIZE = 64;
- char textBuffer[ BUF_SIZE ];
+ char textBuffer[BUF_SIZE];
int manaType = -1;
int numManaRegions = ManaIndicator->getNumManaRegions();
int i;
int curMana, baseMana;
- PlayerActor *player = &playerList[ getCenterActorPlayerID() ];
+ PlayerActor *player = &playerList[getCenterActorPlayerID()];
ActorAttributes *stats = player->getEffStats();
ActorAttributes baseStatsRef = player->getBaseStats();
Point16 pos = ev.mouse;
@@ -2688,7 +2690,7 @@ APPFUNC(cmdManaInd) {
// set the text in the cursor
mouseInfo.setText(textBuffer);
} else
- mouseInfo.setText(NULL);
+ mouseInfo.setText(nullptr);
}
}
@@ -2732,12 +2734,12 @@ void loadUIState(SaveFileReader &saveGame) {
}
void cleanupUIState(void) {
- if (StatusLine != NULL)
+ if (StatusLine != nullptr)
StatusLine->clear();
}
void gArmorIndicator::setValue(PlayerActorID brotherID) {
- Actor *bro = playerList[ brotherID ].getActor();
+ Actor *bro = playerList[brotherID].getActor();
bro->totalArmorAttributes(attr);
invalidate();
}
@@ -2758,7 +2760,7 @@ void gArmorIndicator::drawClipped(gPort &port,
if (dispImage) {
// will part of this be drawn on screen?
if (extent.overlap(r)) {
- char buf[ 8 ];
+ char buf[8];
// offset the image?
Point16 pos(extent.x - offset.x,
@@ -2803,7 +2805,7 @@ void gEnchantmentDisplay::drawClipped(gPort &port, const Point16 &offset, con
if (!extent.overlap(r)) return;
for (int i = 0; i < iconCount; i++) {
- if (iconFlags[ i ]) {
+ if (iconFlags[i]) {
Sprite *sp = (*mentalSprites)->sprite(i + 162);
pos.x -= sp->size.x + 2;
@@ -2814,7 +2816,7 @@ void gEnchantmentDisplay::drawClipped(gPort &port, const Point16 &offset, con
void gEnchantmentDisplay::pointerMove(gPanelMessage &msg) {
if (msg.pointerLeave) {
- mouseInfo.setText(NULL);
+ mouseInfo.setText(nullptr);
} else {
int16 x = extent.width - 10;
@@ -2822,17 +2824,17 @@ void gEnchantmentDisplay::pointerMove(gPanelMessage &msg) {
setValue(getCenterActorPlayerID());
for (int i = 0; i < iconCount; i++) {
- if (iconFlags[ i ]) {
+ if (iconFlags[i]) {
Sprite *sp = (*mentalSprites)->sprite(i + 162);
x -= sp->size.x + 2;
if (msg.pickPos.x >= x) {
// set the text in the cursor
- char buf[ 128 ];
+ char buf[128];
- if (iconFlags[ i ] == 255)
- sprintf(buf, "%s", enchantmentNames[ i ]);
- else sprintf(buf, "%s : %d", enchantmentNames[ i ], iconFlags[ i ]);
+ if (iconFlags[i] == 255)
+ sprintf(buf, "%s", enchantmentNames[i]);
+ else sprintf(buf, "%s : %d", enchantmentNames[i], iconFlags[i]);
mouseInfo.setText(buf);
return;
}
@@ -2842,8 +2844,8 @@ void gEnchantmentDisplay::pointerMove(gPanelMessage &msg) {
}
void gEnchantmentDisplay::setValue(PlayerActorID pID) {
- Actor *a = playerList[ pID ].getActor();
- uint8 newIconFlags[ iconCount ];
+ Actor *a = playerList[pID].getActor();
+ uint8 newIconFlags[iconCount];
GameObject *wornObj;
EnchantmentIterator iter(a);
ContainerIterator cIter(a);
@@ -2877,17 +2879,17 @@ void gEnchantmentDisplay::setValue(PlayerActorID pID) {
case skillIDBludgeon:
case skillIDSwordcraft:
- if (eAmount > 0) newIconFlags[ iconSurestrike ] = duration;
- else newIconFlags[ iconClumsy ] = duration;
+ if (eAmount > 0) newIconFlags[iconSurestrike] = duration;
+ else newIconFlags[iconClumsy] = duration;
break;
case skillIDAgility:
- if (eAmount > 0) newIconFlags[ iconInnerBalance ] = duration;
- else newIconFlags[ iconClumsy ] = duration;
+ if (eAmount > 0) newIconFlags[iconInnerBalance] = duration;
+ else newIconFlags[iconClumsy] = duration;
break;
case skillIDBrawn:
- newIconFlags[ iconBattleFever ] = duration;
+ newIconFlags[iconBattleFever] = duration;
break;
}
break;
@@ -2896,37 +2898,37 @@ void gEnchantmentDisplay::setValue(PlayerActorID pID) {
switch (eSubType) {
case damageImpact:
- newIconFlags[ iconResistImpact ] = duration;
+ newIconFlags[iconResistImpact] = duration;
break;
case damageSlash:
- newIconFlags[ iconResistSlash ] = duration;
+ newIconFlags[iconResistSlash] = duration;
break;
case damageProjectile:
- newIconFlags[ iconResistProjectile] = duration;
+ newIconFlags[iconResistProjectile] = duration;
break;
case damageFire:
- newIconFlags[ iconResistFire ] = duration;
+ newIconFlags[iconResistFire] = duration;
break;
case damageAcid:
- newIconFlags[ iconResistAcid ] = duration;
+ newIconFlags[iconResistAcid] = duration;
break;
case damageHeat:
- newIconFlags[ iconResistHeat ] = duration;
+ newIconFlags[iconResistHeat] = duration;
break;
case damageCold:
- newIconFlags[ iconResistCold ] = duration;
+ newIconFlags[iconResistCold] = duration;
break;
case damageLightning:
- newIconFlags[ iconResistLightning ] = duration;
+ newIconFlags[iconResistLightning] = duration;
break;
case damagePoison:
- newIconFlags[ iconResistPoison ] = duration;
+ newIconFlags[iconResistPoison] = duration;
break;
case damageMental:
- newIconFlags[ iconResistPsionic ] = duration;
+ newIconFlags[iconResistPsionic] = duration;
break;
case damageDirMagic:
- newIconFlags[ iconResistDirectMagic] = duration;
+ newIconFlags[iconResistDirectMagic] = duration;
break;
}
break;
@@ -2934,31 +2936,31 @@ void gEnchantmentDisplay::setValue(PlayerActorID pID) {
case effectImmune:
switch (eSubType) {
case damageImpact:
- newIconFlags[ iconIronskin ] = duration;
+ newIconFlags[iconIronskin] = duration;
break;
case damageSlash:
- newIconFlags[ iconIronskin ] = duration;
+ newIconFlags[iconIronskin] = duration;
break;
case damageFire:
- newIconFlags[ iconImmuneFire ] = duration;
+ newIconFlags[iconImmuneFire] = duration;
break;
case damageAcid:
- newIconFlags[ iconImmuneAcid ] = duration;
+ newIconFlags[iconImmuneAcid] = duration;
break;
case damageHeat:
- newIconFlags[ iconImmuneHeat ] = duration;
+ newIconFlags[iconImmuneHeat] = duration;
break;
case damageCold:
- newIconFlags[ iconImmuneCold ] = duration;
+ newIconFlags[iconImmuneCold] = duration;
break;
case damageLightning:
- newIconFlags[ iconImmuneLightning ] = duration;
+ newIconFlags[iconImmuneLightning] = duration;
break;
case damagePoison:
- newIconFlags[ iconImmunePoison ] = duration;
+ newIconFlags[iconImmunePoison] = duration;
break;
case damageMental:
- newIconFlags[ iconImmunePsionic ] = duration;
+ newIconFlags[iconImmunePsionic] = duration;
break;
}
break;
@@ -2967,44 +2969,44 @@ void gEnchantmentDisplay::setValue(PlayerActorID pID) {
switch (eSubType) {
case actorPoisoned:
case actorDiseased:
- newIconFlags[ iconPoisoned ] = duration;
+ newIconFlags[iconPoisoned] = duration;
break;
case actorFear:
- newIconFlags[ iconAfraid ] = duration;
+ newIconFlags[iconAfraid] = duration;
break;
case actorParalyzed:
- newIconFlags[ iconParalysed ] = duration;
+ newIconFlags[iconParalysed] = duration;
break; // iconFrozen ??
case actorSlowFall:
- newIconFlags[ iconCushionAir ] = duration;
+ newIconFlags[iconCushionAir] = duration;
break;
case actorImmobile:
- newIconFlags[ iconConstrained ] = duration;
+ newIconFlags[iconConstrained] = duration;
break;
case actorSeeInvis:
- newIconFlags[ iconSoulSight ] = duration;
+ newIconFlags[iconSoulSight] = duration;
break;
case actorInvisible:
- newIconFlags[ iconInvisible ] = duration;
+ newIconFlags[iconInvisible] = duration;
break;
case actorUndetectable:
- newIconFlags[ iconNumbscent ] = duration;
+ newIconFlags[iconNumbscent] = duration;
break;
case actorDetPoison:
- newIconFlags[ iconDetectPoison ] = duration;
+ newIconFlags[iconDetectPoison] = duration;
break;
case actorNoDrain:
- newIconFlags[ iconNetherWard ] = duration;
+ newIconFlags[iconNetherWard] = duration;
break;
case actorWaterBreathe:
- newIconFlags[ iconSeawalk ] = duration;
+ newIconFlags[iconSeawalk] = duration;
break;
case actorRepelEvil:
- newIconFlags[ iconProtectEvil ] = duration;
+ newIconFlags[iconProtectEvil] = duration;
break;
-// case actorRepelUndead: newIconFlags[ iconProtectUndead] = duration; break;
-// case actorRepelGhosts: newIconFlags[ iconProtectGhosts] = duration; break;
+// case actorRepelUndead: newIconFlags[iconProtectUndead] = duration; break;
+// case actorRepelGhosts: newIconFlags[iconProtectGhosts] = duration; break;
}
}
}
@@ -3015,38 +3017,38 @@ void gEnchantmentDisplay::setValue(PlayerActorID pID) {
if ((cSet & (ProtoObj::isArmor | ProtoObj::isWeapon | ProtoObj::isWearable))
&& proto->isObjectBeingUsed(obj)) {
- if (proto->immunity & (1 << resistImpact)) newIconFlags[ iconResistImpact ] = 255;
- else if (proto->resistance & (1 << resistImpact)) newIconFlags[ iconResistImpact ] = 255;
+ if (proto->immunity & (1 << resistImpact)) newIconFlags[iconResistImpact] = 255;
+ else if (proto->resistance & (1 << resistImpact)) newIconFlags[iconResistImpact] = 255;
- if (proto->immunity & (1 << resistSlash)) newIconFlags[ iconResistSlash ] = 255;
- else if (proto->resistance & (1 << resistSlash)) newIconFlags[ iconResistSlash ] = 255;
+ if (proto->immunity & (1 << resistSlash)) newIconFlags[iconResistSlash] = 255;
+ else if (proto->resistance & (1 << resistSlash)) newIconFlags[iconResistSlash] = 255;
- if (proto->immunity & (1 << resistProjectile)) newIconFlags[ iconResistProjectile ] = 255;
- else if (proto->resistance & (1 << resistProjectile)) newIconFlags[ iconResistProjectile ] = 255;
+ if (proto->immunity & (1 << resistProjectile)) newIconFlags[iconResistProjectile] = 255;
+ else if (proto->resistance & (1 << resistProjectile)) newIconFlags[iconResistProjectile] = 255;
- if (proto->immunity & (1 << immuneFire)) newIconFlags[ iconImmuneFire ] = 255;
- else if (proto->resistance & (1 << resistFire)) newIconFlags[ iconResistFire ] = 255;
+ if (proto->immunity & (1 << immuneFire)) newIconFlags[iconImmuneFire] = 255;
+ else if (proto->resistance & (1 << resistFire)) newIconFlags[iconResistFire] = 255;
- if (proto->immunity & (1 << immuneAcid)) newIconFlags[ iconImmuneAcid ] = 255;
- else if (proto->resistance & (1 << resistAcid)) newIconFlags[ iconResistAcid ] = 255;
+ if (proto->immunity & (1 << immuneAcid)) newIconFlags[iconImmuneAcid] = 255;
+ else if (proto->resistance & (1 << resistAcid)) newIconFlags[iconResistAcid] = 255;
- if (proto->immunity & (1 << immuneHeat)) newIconFlags[ iconImmuneHeat ] = 255;
- else if (proto->resistance & (1 << resistHeat)) newIconFlags[ iconResistHeat ] = 255;
+ if (proto->immunity & (1 << immuneHeat)) newIconFlags[iconImmuneHeat] = 255;
+ else if (proto->resistance & (1 << resistHeat)) newIconFlags[iconResistHeat] = 255;
- if (proto->immunity & (1 << immuneCold)) newIconFlags[ iconImmuneCold ] = 255;
- else if (proto->resistance & (1 << resistCold)) newIconFlags[ iconResistCold ] = 255;
+ if (proto->immunity & (1 << immuneCold)) newIconFlags[iconImmuneCold] = 255;
+ else if (proto->resistance & (1 << resistCold)) newIconFlags[iconResistCold] = 255;
- if (proto->immunity & (1 << immuneLightning)) newIconFlags[ iconImmuneLightning ] = 255;
- else if (proto->resistance & (1 << resistLightning)) newIconFlags[ iconResistLightning ] = 255;
+ if (proto->immunity & (1 << immuneLightning)) newIconFlags[iconImmuneLightning] = 255;
+ else if (proto->resistance & (1 << resistLightning)) newIconFlags[iconResistLightning] = 255;
- if (proto->immunity & (1 << immunePoison)) newIconFlags[ iconImmunePoison ] = 255;
- else if (proto->resistance & (1 << resistPoison)) newIconFlags[ iconResistPoison ] = 255;
+ if (proto->immunity & (1 << immunePoison)) newIconFlags[iconImmunePoison] = 255;
+ else if (proto->resistance & (1 << resistPoison)) newIconFlags[iconResistPoison] = 255;
- if (proto->immunity & (1 << immuneMental)) newIconFlags[ iconImmunePsionic ] = 255;
- else if (proto->resistance & (1 << resistMental)) newIconFlags[ iconResistPsionic ] = 255;
+ if (proto->immunity & (1 << immuneMental)) newIconFlags[iconImmunePsionic] = 255;
+ else if (proto->resistance & (1 << resistMental)) newIconFlags[iconResistPsionic] = 255;
- if (proto->immunity & (1 << resistDirMagic)) newIconFlags[ iconResistDirectMagic ] = 255;
- else if (proto->resistance & (1 << resistDirMagic))newIconFlags[ iconResistDirectMagic ] = 255;
+ if (proto->immunity & (1 << resistDirMagic)) newIconFlags[iconResistDirectMagic] = 255;
+ else if (proto->resistance & (1 << resistDirMagic))newIconFlags[iconResistDirectMagic] = 255;
}
}
@@ -3112,7 +3114,7 @@ bool isBrotherDead(PlayerActorID brotherID) {
void StatusMsg(char *msg, ...) { // frametime def
va_list argptr;
- char buffer[ 128 ];
+ char buffer[128];
if (StatusLine) {
va_start(argptr, msg);
Commit: 57089894819862fcc22bd16018486e9f32467a48
https://github.com/scummvm/scummvm/commit/57089894819862fcc22bd16018486e9f32467a48
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:54+02:00
Commit Message:
SAGA2: Fix display-related system initializations
Changed paths:
engines/saga2/display.cpp
engines/saga2/main.cpp
engines/saga2/playmode.cpp
engines/saga2/tile.cpp
engines/saga2/tileload.cpp
engines/saga2/towerfta.cpp
diff --git a/engines/saga2/display.cpp b/engines/saga2/display.cpp
index 40307eeafe..47384cfb9f 100644
--- a/engines/saga2/display.cpp
+++ b/engines/saga2/display.cpp
@@ -183,11 +183,15 @@ void niceScreenStartup(void) {
// backbuffer startup
void initBackPanel(void) {
- mainWindow = NEW_UI BackWindow(
+ if (mainWindow)
+ return;
+
+ mainWindow = new BackWindow(
Rect16(0, 0, screenWidth, screenHeight),
0,
cmdWindowFunc);
- checkAlloc(mainWindow);
+ if (mainWindow == nullptr)
+ error("Error initializing the back panel");
}
/* ===================================================================== *
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 74cfdd2f67..e359b1aa08 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -75,11 +75,12 @@ const uint32 gameTimeID = MKTAG('T', 'I', 'M', 'E');
extern WindowDecoration autoMapDecorations[];
extern gToolBase G_BASE;
extern configuration globalConfig;
-extern char *gameTimeStr;
+extern char *gameTimeStr;
extern bool underground;
extern char commandLineHelp[];
-extern hResContext *tileRes; // tile resource handle
-extern hResContext *listRes;
+extern hResContext *tileRes; // tile resource handle
+extern hResContext *listRes;
+extern vDisplayPage protoPage;
/* ===================================================================== *
Globals
@@ -210,6 +211,12 @@ void updatePerfStats(void);
void testTiles();
+bool initResourceHandles();
+bool initDisplayPort();
+bool initPanelSystem();
+bool initDisplay();
+bool initGameMaps();
+
/********************************************************************/
/* */
/* MAIN FUNCTION */
@@ -760,6 +767,12 @@ void testTileRendering() {
listRes = objResFile->newContext(MKTAG('L', 'I', 'S', 'T'), "list resources");
resImports = (ResImportTable *)LoadResource(listRes, MKTAG('I', 'M', 'P', 'O'), "res imports");
+ initResourceHandles();
+ mainPort.setDisplayPage(&protoPage);
+ initPanelSystem();
+ initDisplayPort();
+ initDisplay();
+ initGameMaps();
testTiles();
}
diff --git a/engines/saga2/playmode.cpp b/engines/saga2/playmode.cpp
index a26c204819..c6a2d841c1 100644
--- a/engines/saga2/playmode.cpp
+++ b/engines/saga2/playmode.cpp
@@ -276,6 +276,7 @@ void PlayModeCleanup(void) {
if (playControls) {
delete playControls;
playControls = nullptr;
+ delete StatusLine;
StatusLine = nullptr;
}
if (speakButtonControls) {
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index be70c3b350..95162abc18 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -52,6 +52,8 @@
namespace Saga2 {
extern void writeLog(char *str);
+void PlayModeSetup();
+void initBackPanel();
#define TATLOG 0
@@ -4616,26 +4618,31 @@ void updateMainDisplay(void) {
}
void testTiles() {
- initMaps();
+ //initBackPanel();
+ //initMaps();
initTileCyclingStates();
+ setCurrentMap(0);
+ PlayModeSetup();
+
//buildRoofTable();
//buildDisplayList();
- //setCurrentMap(0);
// draws tiles to tileDrawMap.data
- //drawMetaTiles();
+ drawMetaTiles();
- uint8 *img = (uint8*)mapList[0].map->mapData;
- int16 size = mapList[0].map->size;
- debugC(3, kDebugTiles, "img = %p, size = %d", (void *)img, size);
+ //uint8 *img = (uint8*)mapList[0].map->mapData;
+ //int16 size = mapList[0].map->size;
+ uint8 *img = tileDrawMap.data;
+ Point16 size = tileDrawMap.size;
+ debugC(3, kDebugTiles, "img = %p, size = %d,%d", (void *)img, size.x, size.y);
//Common::hexdump(img, size*size);
Graphics::Surface sur;
- sur.create(size, size, Graphics::PixelFormat::createFormatCLUT8());
+ sur.create(size.x, size.y, Graphics::PixelFormat::createFormatCLUT8());
sur.setPixels(img);
sur.debugPrint();
- g_system->copyRectToScreen(sur.getPixels(), sur.pitch, 0, 112, sur.w, sur.h);
+ //g_system->copyRectToScreen(sur.getPixels(), sur.pitch, 0, 112, sur.w, sur.h);
// Draw sprites onto back buffer
//drawDisplayList();
diff --git a/engines/saga2/tileload.cpp b/engines/saga2/tileload.cpp
index b38f704447..4caa54f644 100644
--- a/engines/saga2/tileload.cpp
+++ b/engines/saga2/tileload.cpp
@@ -34,6 +34,7 @@
#include "saga2/objects.h"
#include "saga2/tileload.h"
#include "saga2/oncall.h"
+#include "common/debug.h"
namespace Saga2 {
@@ -177,6 +178,9 @@ void drawPlatform(
u = platformWidth - 1;
v = platformWidth - 1;
+ debugC(3, kDebugTiles, "drawPlatform: right = %d, bottom = %d, x = %d, x2 = %d, origin = %d,%d, tilePos.y=%d, u,v = %d,%d", right, bottom, x, x2, origin.u, origin.v,
+ tilePos.y, u, v);
+
for (int row = 0; row < 15; row++) {
if (tilePos.y > 0) {
int16 col = 0;
diff --git a/engines/saga2/towerfta.cpp b/engines/saga2/towerfta.cpp
index e1ac4cbdbc..c496c1ee03 100644
--- a/engines/saga2/towerfta.cpp
+++ b/engines/saga2/towerfta.cpp
@@ -300,7 +300,7 @@ INITIALIZER(initDisplayPort) {
TERMINATOR(termDisplayPort) {
if (mainWindow) delete mainWindow;
- mainWindow = NULL;
+ mainWindow = nullptr;
}
@@ -358,19 +358,19 @@ INITIALIZER(initDisplay) {
// Create a panelList to contain the controls which are
// only active when all three brothers are shown
- if ((trioControls = NEW_UI gPanelList(*mainWindow)) == NULL)
- return FALSE;
+ if ((trioControls = new gPanelList(*mainWindow)) == nullptr)
+ return false;
// Create a panelList to contain the controls which are
// only active when a single brother is shown
- if ((indivControls = NEW_UI gPanelList(*mainWindow)) == NULL)
- return FALSE;
+ if ((indivControls = new gPanelList(*mainWindow)) == nullptr)
+ return false;
// Since we start in "trio" mode, turn off the "individual"
// controls...
- indivControls->enable(FALSE);
+ indivControls->enable(false);
- return TRUE;
+ return true;
}
TERMINATOR(termDisplay) {
Commit: d7ea7c0541ed647a25a12cc12b3d2d6e6c357096
https://github.com/scummvm/scummvm/commit/d7ea7c0541ed647a25a12cc12b3d2d6e6c357096
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:55+02:00
Commit Message:
SAGA2: Import drawTile from SAGA
Changed paths:
engines/saga2/blitters.cpp
engines/saga2/oncall.h
engines/saga2/tile.cpp
diff --git a/engines/saga2/blitters.cpp b/engines/saga2/blitters.cpp
index a000a91bd9..52abd1ed3f 100644
--- a/engines/saga2/blitters.cpp
+++ b/engines/saga2/blitters.cpp
@@ -88,10 +88,215 @@ void unpackSprite(gPixelMap *map, uint8 *sprData) {
warning("STUB: unpackSprite()");
}
+//void drawTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData) {
+// warning("STUB: drawTile()");
+//}
+
void drawTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData) {
warning("STUB: drawTile()");
+ const byte *tilePointer;
+ const byte *readPointer;
+ byte *drawPointer;
+ Point32 drawPoint;
+ int widthCount = 0;
+ int row, col, count, lowBound;
+ int bgRunCount;
+ int fgRunCount;
+ const int32 SAGA_ISOTILE_WIDTH = 32;
+ Point16 point(x, y);
+
+
+// if (tileIndex >= _tilesTable.size()) {
+// error("IsoMap::drawTile wrong tileIndex");
+// }
+
+
+ if (point.x + SAGA_ISOTILE_WIDTH < 0) {
+ return;
+ }
+
+ if (point.x - SAGA_ISOTILE_WIDTH >= map->size.x) {
+ return;
+ }
+
+ if ((height <= 8) || (height > 64)) {
+ return;
+ }
+
+ tilePointer = srcData;
+
+ drawPoint = point;
+
+ drawPoint.y -= height;
+
+ if (drawPoint.y >= map->size.y) {
+ return;
+ }
+
+#if 0
+ if (location != NULL) {
+ if (location->z <= -16) {
+ if (location->z <= -48) {
+ if (location->u() < -THRESH8 || location->v() < -THRESH8) {
+ return;
+ }
+ } else {
+ if (location->u() < THRESH0 || location->v() < THRESH0) {
+ return;
+ }
+ }
+ } else {
+ if (location->z >= 16) {
+ return;
+ } else {
+ switch (_tilesTable[tileIndex].getMaskRule()) {
+ case kMaskRuleNever:
+ return;
+ case kMaskRuleAlways:
+ default:
+ break;
+ case kMaskRuleUMIN:
+ if (location->u() < THRESH0) {
+ return;
+ }
+ break;
+ case kMaskRuleUMID:
+ if (location->u() < THRESH8) {
+ return;
+ }
+ break;
+ case kMaskRuleUMAX:
+ if (location->u() < THRESH16) {
+ return;
+ }
+ break;
+ case kMaskRuleVMIN:
+ if (location->v() < THRESH0) {
+ return;
+ }
+ break;
+ case kMaskRuleVMID:
+ if (location->v() < THRESH8) {
+ return;
+ }
+ break;
+ case kMaskRuleVMAX:
+ if (location->v() < THRESH16) {
+ return;
+ }
+ break;
+ case kMaskRuleYMIN:
+ if (location->uv() < THRESH0 * 2) {
+ return;
+ }
+ break;
+ case kMaskRuleYMID:
+ if (location->uv() < THRESH8 * 2) {
+ return;
+ }
+ break;
+ case kMaskRuleYMAX:
+ if (location->uv() < THRESH16 * 2) {
+ return;
+ }
+ break;
+ case kMaskRuleUVMAX:
+ if (location->u() < THRESH16 && location->v() < THRESH16) {
+ return;
+ }
+ break;
+ case kMaskRuleUVMIN:
+ if (location->u() < THRESH0 || location->v() < THRESH0) {
+ return;
+ }
+ break;
+ case kMaskRuleUorV:
+ if (location->u() < THRESH8 && location->v() < THRESH8) {
+ return;
+ }
+ break;
+ case kMaskRuleUandV:
+ if (location->u() < THRESH8 || location->v() < THRESH8) {
+ return;
+ }
+ break;
+ }
+ }
+ }
+ }
+#endif
+
+ readPointer = tilePointer;
+ lowBound = MIN((int)(drawPoint.y + height), (int)map->size.y);
+ for (row = drawPoint.y; row < lowBound; row++) {
+ widthCount = 0;
+ if (row >= 0) {
+ drawPointer = map->data + drawPoint.x + (row * map->size.x);
+ col = drawPoint.x;
+ for (;;) {
+ bgRunCount = *readPointer++;
+ widthCount += bgRunCount;
+ if (widthCount >= SAGA_ISOTILE_WIDTH) {
+ break;
+ }
+
+ drawPointer += bgRunCount;
+ col += bgRunCount;
+ fgRunCount = *readPointer++;
+ widthCount += fgRunCount;
+
+ count = 0;
+ int colDiff = - col;
+ if (colDiff > 0) {
+ if (colDiff > fgRunCount) {
+ colDiff = fgRunCount;
+ }
+ count = colDiff;
+ col += colDiff;
+ }
+
+ colDiff = map->size.x - col;
+ if (colDiff > 0) {
+ int countDiff = fgRunCount - count;
+ if (colDiff > countDiff) {
+ colDiff = countDiff;
+ }
+ if (colDiff > 0) {
+ byte *dst = (byte *)(drawPointer + count);
+ memcpy(dst, (readPointer + count), colDiff);
+ col += colDiff;
+ }
+ }
+
+ readPointer += fgRunCount;
+ drawPointer += fgRunCount;
+ }
+ } else {
+ for (;;) {
+ bgRunCount = *readPointer++;
+ widthCount += bgRunCount;
+ if (widthCount >= SAGA_ISOTILE_WIDTH) {
+ break;
+ }
+
+ fgRunCount = *readPointer++;
+ widthCount += fgRunCount;
+
+ readPointer += fgRunCount;
+ }
+ }
+ }
+
+ // Compute dirty rect
+ int rectX = MAX<int>(drawPoint.x, 0);
+ int rectY = MAX<int>(drawPoint.y, 0);
+ int rectX2 = MIN<int>(drawPoint.x + SAGA_ISOTILE_WIDTH, map->size.x);
+ int rectY2 = lowBound;
+ debugC(3, kDebugTiles, "Rect = (%d,%d,%d,%d)", rectX, rectY, rectX2, rectY2);
+ //g_vm->_render->addDirtyRect(Common::Rect(rectX, rectY, rectX2, rectY2));
}
+
void maskTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData) {
warning("STUB: maskTile()");
}
diff --git a/engines/saga2/oncall.h b/engines/saga2/oncall.h
index 9feddcecd3..9e79ada827 100644
--- a/engines/saga2/oncall.h
+++ b/engines/saga2/oncall.h
@@ -42,7 +42,8 @@ private:
byte*(*_loader)(hResID, bool);
public:
HandleArray(uint16 size, byte*(*loadfunction)(hResID, bool), uint32 newID) {
- _handles.resize(size);
+ for (int i = 0; i < size; ++i)
+ _handles.push_back(nullptr);
_loader = loadfunction;
_tileID = newID;
}
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 95162abc18..75b4740532 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -105,7 +105,7 @@ void setAreaSound(const TilePoint &baseCoords);
* ===================================================================== */
TileBankPtr tileBanks[maxBanks];
-extern byte* tileImageBanks[];
+extern HandleArray tileImageBanks;
void tileFault(int bank, int num);
void updateHandleRefs(const TilePoint &pt); //, StandingTileInfo *stiResult )
@@ -4642,7 +4642,7 @@ void testTiles() {
sur.create(size.x, size.y, Graphics::PixelFormat::createFormatCLUT8());
sur.setPixels(img);
sur.debugPrint();
- //g_system->copyRectToScreen(sur.getPixels(), sur.pitch, 0, 112, sur.w, sur.h);
+ g_system->copyRectToScreen(sur.getPixels(), sur.pitch, 0, 0, sur.w, sur.h);
// Draw sprites onto back buffer
//drawDisplayList();
Commit: 14781813cac8f9cf6f2a2e22b278ac3bb2ebdd51
https://github.com/scummvm/scummvm/commit/14781813cac8f9cf6f2a2e22b278ac3bb2ebdd51
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:55+02:00
Commit Message:
SAGA2: Reduce header dependency
Changed paths:
engines/saga2/assign.cpp
engines/saga2/patrol.cpp
engines/saga2/patrol.h
engines/saga2/std.h
engines/saga2/target.cpp
engines/saga2/target.h
engines/saga2/task.cpp
engines/saga2/task.h
engines/saga2/tile.h
diff --git a/engines/saga2/assign.cpp b/engines/saga2/assign.cpp
index f44d1df77f..c209db8ff6 100644
--- a/engines/saga2/assign.cpp
+++ b/engines/saga2/assign.cpp
@@ -36,6 +36,7 @@
#include "saga2/calender.h"
#include "saga2/patrol.h"
#include "saga2/task.h"
+#include "saga2/tile.h"
namespace Saga2 {
diff --git a/engines/saga2/patrol.cpp b/engines/saga2/patrol.cpp
index b47ba1d36c..0d05824526 100644
--- a/engines/saga2/patrol.cpp
+++ b/engines/saga2/patrol.cpp
@@ -29,6 +29,8 @@
#include "saga2/std.h"
#include "saga2/fta.h"
#include "saga2/patrol.h"
+#include "saga2/cmisc.h"
+#include "saga2/tcoords.h"
namespace Saga2 {
@@ -46,6 +48,13 @@ PatrolRouteList *patrolRouteList = NULL; // Global patrol route arra
static PatrolRouteData **patrolRouteData; // Data for patrol routes
+
+// Returns a const reference to a specified way point
+const TilePoint &PatrolRoute::operator [](int16 index) const {
+ return *((TilePoint *)&this[ 1 ] + index);
+}
+
+
/* ===================================================================== *
PatrolRouteList member functions
* ===================================================================== */
diff --git a/engines/saga2/patrol.h b/engines/saga2/patrol.h
index a8da35ffa1..260f0716b5 100644
--- a/engines/saga2/patrol.h
+++ b/engines/saga2/patrol.h
@@ -27,11 +27,9 @@
#ifndef SAGA2_PATROL_H
#define SAGA2_PATROL_H
-#include "saga2/cmisc.h"
-#include "saga2/tcoords.h"
-
namespace Saga2 {
+class TilePoint;
class PatrolRouteList;
extern PatrolRouteList *patrolRouteList; // Global patrol route array
@@ -54,9 +52,7 @@ public:
}
// Returns a const reference to a specified way point
- const TilePoint &operator [](int16 index) const {
- return *((TilePoint *)&this[ 1 ] + index);
- }
+ const TilePoint &operator [](int16 index) const;
};
/* ===================================================================== *
diff --git a/engines/saga2/std.h b/engines/saga2/std.h
index 3e592252b8..fe2622fb49 100644
--- a/engines/saga2/std.h
+++ b/engines/saga2/std.h
@@ -68,4 +68,10 @@ typedef bool BOOL;
#define maxuint32 0xffffffffu
#define minuint32 0u
+// Plaftorm metrics
+const int platformWidth = 8, // width and height of platform
+ platMask = platformWidth - 1,
+ platShift = 3;
+
+
#endif //SAGA2_STD_H
diff --git a/engines/saga2/target.cpp b/engines/saga2/target.cpp
index f7f51869de..aa7a90e223 100644
--- a/engines/saga2/target.cpp
+++ b/engines/saga2/target.cpp
@@ -28,8 +28,10 @@
#include "saga2/std.h"
#include "saga2/cmisc.h"
+#include "saga2/objects.h"
#include "saga2/target.h"
#include "saga2/actor.h"
+#include "saga2/tile.h"
namespace Saga2 {
diff --git a/engines/saga2/target.h b/engines/saga2/target.h
index 6ab98bdae3..d13830b497 100644
--- a/engines/saga2/target.h
+++ b/engines/saga2/target.h
@@ -27,12 +27,10 @@
#ifndef SAGA2_TARGET_H
#define SAGA2_TARGET_H
-#include "saga2/property.h"
-#include "saga2/objects.h"
-#include "saga2/tile.h"
-
namespace Saga2 {
+struct StandingTileInfo;
+
const int maxObjDist = platformWidth * tileUVSize * 8;
const int maxTileDist = platformWidth * tileUVSize * 2;
const int maxMetaDist = platformWidth * tileUVSize * 8;
diff --git a/engines/saga2/task.cpp b/engines/saga2/task.cpp
index 3b57bce301..d9e981c7bc 100644
--- a/engines/saga2/task.cpp
+++ b/engines/saga2/task.cpp
@@ -28,8 +28,8 @@
#include "saga2/std.h"
#include "saga2/cmisc.h"
-#include "saga2/task.h"
#include "saga2/actor.h"
+#include "saga2/task.h"
#include "saga2/motion.h"
#include "saga2/band.h"
#include "saga2/sensor.h"
diff --git a/engines/saga2/task.h b/engines/saga2/task.h
index e4eb2c3aec..d0d1654670 100644
--- a/engines/saga2/task.h
+++ b/engines/saga2/task.h
@@ -27,11 +27,8 @@
#ifndef SAGA2_TASK_H
#define SAGA2_TASK_H
-#include "saga2/tcoords.h"
#include "saga2/target.h"
#include "saga2/patrol.h"
-#include "saga2/actor.h"
-#include "saga2/savefile.h"
namespace Saga2 {
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index 2aa05946bc..392935597d 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -75,11 +75,6 @@ const int tileWidth = 64, // width of tile
const int maxTileHeight = 160; // tallest possible tile
-// Plaftorm metrics
-const int platformWidth = 8, // width and height of platform
- platMask = platformWidth - 1,
- platShift = 3;
-
const int platUVSize = tileUVSize * platformWidth;
// Metatile metrics
Commit: eca51bba379552c8db3cbdaae5cb05e9ef995b00
https://github.com/scummvm/scummvm/commit/eca51bba379552c8db3cbdaae5cb05e9ef995b00
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:55+02:00
Commit Message:
SAGA2: Reduce header dependency
Changed paths:
engines/saga2/hresmgr.h
engines/saga2/loadsave.cpp
engines/saga2/magic.h
engines/saga2/messager.cpp
engines/saga2/messager.h
engines/saga2/mission.cpp
engines/saga2/mission.h
engines/saga2/msgbox.cpp
engines/saga2/msgbox.h
engines/saga2/rserver.cpp
engines/saga2/spellbuk.h
engines/saga2/spellio.cpp
engines/saga2/timers.cpp
engines/saga2/timers.h
diff --git a/engines/saga2/hresmgr.h b/engines/saga2/hresmgr.h
index 91041b1785..7f2689f3db 100644
--- a/engines/saga2/hresmgr.h
+++ b/engines/saga2/hresmgr.h
@@ -30,7 +30,6 @@
#include "common/file.h"
#include "saga2/rmem.h"
-#include "saga2/ioerrors.h"
namespace Saga2 {
diff --git a/engines/saga2/loadsave.cpp b/engines/saga2/loadsave.cpp
index 08211210c0..bfffa5e6ec 100644
--- a/engines/saga2/loadsave.cpp
+++ b/engines/saga2/loadsave.cpp
@@ -48,6 +48,7 @@
#include "saga2/intrface.h"
#include "saga2/palette.h"
#include "saga2/contain.h"
+#include "saga2/ioerrors.h"
namespace Saga2 {
diff --git a/engines/saga2/magic.h b/engines/saga2/magic.h
index 4a7aedaade..a70cb6d78d 100644
--- a/engines/saga2/magic.h
+++ b/engines/saga2/magic.h
@@ -27,12 +27,18 @@
#ifndef SAGA2_MAGIC_H
#define SAGA2_MAGIC_H
-#include "saga2/tile.h"
-#include "saga2/objects.h"
#include "saga2/spells.h"
namespace Saga2 {
+class ActiveItem;
+class Location;
+class SkillProto;
+class GameObject;
+
+class SaveFileConstructor;
+class SaveFileReader;
+
// ------------------------------------------------------------------
// This is an include file for the spellcasting interface. This file
// is meant to publish the main API functions for spell casting.
diff --git a/engines/saga2/messager.cpp b/engines/saga2/messager.cpp
index 367c3069c6..c1ac41c15b 100644
--- a/engines/saga2/messager.cpp
+++ b/engines/saga2/messager.cpp
@@ -26,6 +26,7 @@
#include "saga2/std.h"
#include "saga2/messager.h"
+#include "saga2/vdraw.h"
namespace Saga2 {
diff --git a/engines/saga2/messager.h b/engines/saga2/messager.h
index 9433b56b0d..29c24b5fcd 100644
--- a/engines/saga2/messager.h
+++ b/engines/saga2/messager.h
@@ -27,11 +27,10 @@
#ifndef SAGA2_MESSAGER_H
#define SAGA2_MESSAGER_H
-#include "saga2/vdraw.h"
-#include "saga2/grequest.h"
-
namespace Saga2 {
+class gDisplayPort;
+
// max filename length
#define MAX_LOG_NAME_LENGTH 260
diff --git a/engines/saga2/mission.cpp b/engines/saga2/mission.cpp
index f2cac4015e..2d620a8a52 100644
--- a/engines/saga2/mission.cpp
+++ b/engines/saga2/mission.cpp
@@ -28,6 +28,7 @@
#include "saga2/std.h"
#include "saga2/mission.h"
+#include "saga2/actor.h"
namespace Saga2 {
diff --git a/engines/saga2/mission.h b/engines/saga2/mission.h
index bf4d0667a1..0cee63c447 100644
--- a/engines/saga2/mission.h
+++ b/engines/saga2/mission.h
@@ -28,8 +28,6 @@
#define SAGA2_MISSION_H
#include "saga2/objects.h"
-#include "saga2/actor.h"
-#include "saga2/savefile.h"
namespace Saga2 {
diff --git a/engines/saga2/msgbox.cpp b/engines/saga2/msgbox.cpp
index 85c40d967c..0dec978b2c 100644
--- a/engines/saga2/msgbox.cpp
+++ b/engines/saga2/msgbox.cpp
@@ -27,8 +27,10 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
+#include "saga2/button.h"
#include "saga2/localize.h"
#include "saga2/msgbox.h"
+#include "saga2/floating.h"
namespace Saga2 {
diff --git a/engines/saga2/msgbox.h b/engines/saga2/msgbox.h
index 9b2602051d..36871a0fa2 100644
--- a/engines/saga2/msgbox.h
+++ b/engines/saga2/msgbox.h
@@ -27,13 +27,12 @@
#ifndef SAGA2_MSGBOX_H
#define SAGA2_MSGBOX_H
-#include "saga2/fta.h"
-#include "saga2/floating.h"
#include "saga2/grequest.h"
-#include "saga2/button.h"
namespace Saga2 {
+struct textPallete;
+
void ModalModeSetup(void);
void ModalModeCleanup(void);
void ModalModeHandleTask(void);
diff --git a/engines/saga2/rserver.cpp b/engines/saga2/rserver.cpp
index 7b78c258bc..3119549394 100644
--- a/engines/saga2/rserver.cpp
+++ b/engines/saga2/rserver.cpp
@@ -30,6 +30,8 @@
#include "saga2/rmemfta.h"
#include "saga2/dlist.h"
#include "saga2/fta.h"
+#include "saga2/ioerrors.h"
+
namespace Saga2 {
diff --git a/engines/saga2/spellbuk.h b/engines/saga2/spellbuk.h
index c408cb0135..4af4edb0c7 100644
--- a/engines/saga2/spellbuk.h
+++ b/engines/saga2/spellbuk.h
@@ -32,6 +32,9 @@ namespace Saga2 {
struct ResourceSpellEffect;
struct ResourceSpellItem;
+class SpellTarget;
+class ProtoEffect;
+
// Mana IDs as spells see them
enum SpellManaID {
diff --git a/engines/saga2/spellio.cpp b/engines/saga2/spellio.cpp
index 73329ff9bb..bac61b9c61 100644
--- a/engines/saga2/spellio.cpp
+++ b/engines/saga2/spellio.cpp
@@ -27,9 +27,13 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
+#include "saga2/idtypes.h"
#include "saga2/rmemfta.h"
#include "saga2/magic.h"
+#include "saga2/effects.h"
#include "saga2/spellbuk.h"
+#include "saga2/tcoords.h"
+#include "saga2/rect.h"
#include "saga2/spellio.h"
#include "saga2/spelshow.h"
#include "saga2/savefile.h"
diff --git a/engines/saga2/timers.cpp b/engines/saga2/timers.cpp
index 2d6329eecf..c7d26345ed 100644
--- a/engines/saga2/timers.cpp
+++ b/engines/saga2/timers.cpp
@@ -29,6 +29,7 @@
#include "saga2/std.h"
#include "saga2/timers.h"
#include "saga2/pool.h"
+#include "saga2/objects.h"
namespace Saga2 {
diff --git a/engines/saga2/timers.h b/engines/saga2/timers.h
index 80843ec131..b8d0787648 100644
--- a/engines/saga2/timers.h
+++ b/engines/saga2/timers.h
@@ -27,11 +27,15 @@
#ifndef SAGA2_TIMERS_H
#define SAGA2_TIMERS_H
-#include "saga2/objects.h"
+#include "saga2/idtypes.h"
+#include "saga2/dlist.h"
#include "saga2/calender.h"
namespace Saga2 {
+class GameObject;
+class TimerList;
+
// Allocate an new TimerList
void *newTimerList(void);
// Deallocate an TimerList
Commit: 20e0ee7e70c604c1058aa1f90d2cc42696d8f7b5
https://github.com/scummvm/scummvm/commit/20e0ee7e70c604c1058aa1f90d2cc42696d8f7b5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:55+02:00
Commit Message:
SAGA2: More work on reducing header dependency
Changed paths:
engines/saga2/actor.cpp
engines/saga2/automap.h
engines/saga2/band.h
engines/saga2/blitters.cpp
engines/saga2/blitters.h
engines/saga2/contain.h
engines/saga2/dispnode.cpp
engines/saga2/dispnode.h
engines/saga2/idtypes.h
engines/saga2/imagcach.h
engines/saga2/images.h
engines/saga2/input.cpp
engines/saga2/input.h
engines/saga2/msgbox.cpp
engines/saga2/palette.h
engines/saga2/panel.cpp
engines/saga2/panel.h
engines/saga2/rmem.cpp
engines/saga2/rmembase.h
engines/saga2/saga2.cpp
engines/saga2/saga2.h
engines/saga2/sagafunc.cpp
engines/saga2/speldata.cpp
engines/saga2/speldraw.cpp
engines/saga2/spellloc.cpp
engines/saga2/spelshow.h
engines/saga2/tilemode.cpp
engines/saga2/tilevect.h
engines/saga2/towerfta.cpp
engines/saga2/vpage.h
engines/saga2/vpal.h
engines/saga2/vwdraw.cpp
engines/saga2/vwpage.cpp
engines/saga2/vwpage.h
engines/saga2/weapons.cpp
engines/saga2/weapons.h
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 8bbd17b996..de4e0d164a 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -46,7 +46,7 @@
#include "saga2/messager.h"
#include "saga2/weapons.h"
#include "saga2/localize.h"
-
+#include "saga2/intrface.h"
// Include files needed for SAGA script dispatch
#include "saga2/script.h"
diff --git a/engines/saga2/automap.h b/engines/saga2/automap.h
index de515c0199..afb80af566 100644
--- a/engines/saga2/automap.h
+++ b/engines/saga2/automap.h
@@ -27,12 +27,7 @@
#ifndef SAGA2_AUTOMAP_H
#define SAGA2_AUTOMAP_H
-#include "saga2/idtypes.h"
-#include "saga2/contain.h"
-#include "saga2/cmisc.h"
-#include "saga2/button.h"
#include "saga2/intrface.h"
-#include "saga2/floating.h"
namespace Saga2 {
diff --git a/engines/saga2/band.h b/engines/saga2/band.h
index abf250e0ce..6c1dce4659 100644
--- a/engines/saga2/band.h
+++ b/engines/saga2/band.h
@@ -27,8 +27,6 @@
#ifndef SAGA2_BAND_H
#define SAGA2_BAND_H
-#include "saga2/idtypes.h"
-
namespace Saga2 {
class Actor;
diff --git a/engines/saga2/blitters.cpp b/engines/saga2/blitters.cpp
index 52abd1ed3f..e050164347 100644
--- a/engines/saga2/blitters.cpp
+++ b/engines/saga2/blitters.cpp
@@ -26,10 +26,12 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+#include "common/debug.h"
+
#include "saga2/std.h"
#include "saga2/saga2.h"
#include "saga2/blitters.h"
-#include "common/debug.h"
+#include "saga2/gdraw.h"
namespace Saga2 {
diff --git a/engines/saga2/blitters.h b/engines/saga2/blitters.h
index 72e6370ecf..9fb4269dc4 100644
--- a/engines/saga2/blitters.h
+++ b/engines/saga2/blitters.h
@@ -27,10 +27,10 @@
#ifndef SAGA2_BLITTERS_H
#define SAGA2_BLITTERS_H
-#include "saga2/gdraw.h"
-
namespace Saga2 {
+class gPixelMap;
+
// VWPAGE.CPP , GDRAW.CPP
// Assembly-language function to copy pixel to SVGA (opaque)
diff --git a/engines/saga2/contain.h b/engines/saga2/contain.h
index c7f5173f41..f0cb88cfbd 100644
--- a/engines/saga2/contain.h
+++ b/engines/saga2/contain.h
@@ -27,12 +27,7 @@
#ifndef SAGA2_CONTAIN_H
#define SAGA2_CONTAIN_H
-#include "saga2/fta.h"
-#include "saga2/panel.h"
#include "saga2/floating.h"
-#include "saga2/images.h"
-#include "saga2/button.h"
-#include "saga2/intrface.h"
namespace Saga2 {
@@ -54,6 +49,14 @@ class ContainerNode;
class ContainerList;
struct ContainerAppearanceDef;
+class CMassWeightIndicator;
+class ProtoObj;
+
+class gCompButton;
+class gCompImage;
+class gMultCompButton;
+class TilePoint;
+
/* ===================================================================== *
Class definitions
* ===================================================================== */
diff --git a/engines/saga2/dispnode.cpp b/engines/saga2/dispnode.cpp
index 5d7e2c86ea..5ea82f772f 100644
--- a/engines/saga2/dispnode.cpp
+++ b/engines/saga2/dispnode.cpp
@@ -142,6 +142,13 @@ DisplayNode::DisplayNode() {
efx = NULL;
}
+TilePoint DisplayNode::SpellPos(void) {
+ if (efx)
+ return efx->current;
+ return Nowhere;
+}
+
+
inline void DisplayNode::updateEffect(const int32 deltaTime) {
if (efx) efx->updateEffect(deltaTime);
}
diff --git a/engines/saga2/dispnode.h b/engines/saga2/dispnode.h
index a02e3557dc..c06ca335dd 100644
--- a/engines/saga2/dispnode.h
+++ b/engines/saga2/dispnode.h
@@ -27,11 +27,16 @@
#ifndef SAGA2_DISPNODE_H
#define SAGA2_DISPNODE_H
-#include "saga2/objects.h"
-#include "saga2/speldefs.h"
+#include "saga2/idtypes.h"
+#include "saga2/rect.h"
namespace Saga2 {
+class GameObject;
+class TilePoint;
+
+class Effectron;
+
enum nodeType {
nodeTypeObject = 0,
nodeTypeEffect,
@@ -66,18 +71,7 @@ public:
void drawEffect(void);
void updateObject(const int32 deltaTime);
void updateEffect(const int32 deltaTime);
- TilePoint SpellPos(void) {
- if (efx) return efx->current;
- return Nowhere;
- }
-
- void *operator new (size_t s) {
- return RNewPtr(s, NULL, "Display Node");
- }
- void operator delete (void *m) {
- RDisposePtr(m);
- }
-
+ TilePoint SpellPos(void);
};
/* ============================================================================ *
@@ -98,17 +92,17 @@ public:
static DisplayNode *head; // head of list
DisplayNodeList(uint16 newSize) {
- displayList = (DisplayNode *)TALLOC(sizeof(DisplayNode) * newSize, memDispNode);
+ displayList = (DisplayNode *)malloc(sizeof(DisplayNode) * newSize);
init(newSize);
count = 0;
}
DisplayNodeList() {
- displayList = (DisplayNode *)TALLOC(sizeof(DisplayNode) * maxDisplayed, memDispNode);
+ displayList = (DisplayNode *)malloc(sizeof(DisplayNode) * maxDisplayed);
init(maxDisplayed);
count = 0;
}
~DisplayNodeList() {
- delete [] displayList;
+ free(displayList);
}
void reset(void) {
@@ -126,12 +120,6 @@ public:
private:
int16 sortDepth; // for sorting by depth
- void *operator new (size_t s) {
- return RNewPtr(s, NULL, "Display List");
- }
- void operator delete (void *m) {
- RDisposePtr(m);
- }
};
/* ============================================================================ *
diff --git a/engines/saga2/idtypes.h b/engines/saga2/idtypes.h
index 6d31812b9b..7e56da7e0f 100644
--- a/engines/saga2/idtypes.h
+++ b/engines/saga2/idtypes.h
@@ -219,6 +219,10 @@ const BandID NoBand = -1;
typedef uint32 soundSegment;
+typedef uint8 gPen; // a pen index number
+
+typedef uint16 weaponID;
+
} // end of namespace Saga2
#endif
diff --git a/engines/saga2/imagcach.h b/engines/saga2/imagcach.h
index 3b50e9f7ca..2b880e924c 100644
--- a/engines/saga2/imagcach.h
+++ b/engines/saga2/imagcach.h
@@ -27,8 +27,6 @@
#ifndef SAGA2_IMAGCACH_H
#define SAGA2_IMAGCACH_H
-#include "saga2/dlist.h"
-
namespace Saga2 {
/* ===================================================================== *
diff --git a/engines/saga2/images.h b/engines/saga2/images.h
index 1c0131cba9..347981597e 100644
--- a/engines/saga2/images.h
+++ b/engines/saga2/images.h
@@ -27,8 +27,6 @@
#ifndef SAGA2_IMAGES_H
#define SAGA2_IMAGES_H
-#include "saga2/gdraw.h"
-
namespace Saga2 {
// unselected button image
diff --git a/engines/saga2/input.cpp b/engines/saga2/input.cpp
index 9d6161934f..7b6f998360 100644
--- a/engines/saga2/input.cpp
+++ b/engines/saga2/input.cpp
@@ -31,9 +31,8 @@
namespace Saga2 {
-errorCode InitMouse(int16 width, int16 height) {
+void InitMouse(int16 width, int16 height) {
warning("STUB: InitMouse()");
- return errUnknown;
}
void CleanupMouse(void) {
diff --git a/engines/saga2/input.h b/engines/saga2/input.h
index f286b095a6..949c430705 100644
--- a/engines/saga2/input.h
+++ b/engines/saga2/input.h
@@ -28,7 +28,6 @@
#define SAGA2_INPUT_H
#include "saga2/rect.h"
-#include "saga2/errors.h"
namespace Saga2 {
@@ -113,7 +112,7 @@ struct gMouseState {
typedef uint32 gTimeStamp;
-errorCode InitMouse(int16 width, int16 height);
+void InitMouse(int16 width, int16 height);
void CleanupMouse(void);
void ReadMouse(gMouseState &st);
uint16 ReadQualifiers(void);
diff --git a/engines/saga2/msgbox.cpp b/engines/saga2/msgbox.cpp
index 0dec978b2c..f14639b50e 100644
--- a/engines/saga2/msgbox.cpp
+++ b/engines/saga2/msgbox.cpp
@@ -31,6 +31,7 @@
#include "saga2/localize.h"
#include "saga2/msgbox.h"
#include "saga2/floating.h"
+#include "saga2/gbevel.h"
namespace Saga2 {
diff --git a/engines/saga2/palette.h b/engines/saga2/palette.h
index 9051f40154..8999f75f94 100644
--- a/engines/saga2/palette.h
+++ b/engines/saga2/palette.h
@@ -27,9 +27,6 @@
#ifndef SAGA2_PALETTE_H
#define SAGA2_PALETTE_H
-#include "saga2/vpal.h"
-#include "saga2/savefile.h"
-
namespace Saga2 {
/* ===================================================================== *
diff --git a/engines/saga2/panel.cpp b/engines/saga2/panel.cpp
index 0019c16a01..4201b3cc76 100644
--- a/engines/saga2/panel.cpp
+++ b/engines/saga2/panel.cpp
@@ -34,6 +34,7 @@
#include "saga2/floating.h"
#include "saga2/fta.h"
#include "saga2/display.h"
+#include "saga2/gbevel.h"
namespace Saga2 {
diff --git a/engines/saga2/panel.h b/engines/saga2/panel.h
index 34081e23e0..9543f6bd5d 100644
--- a/engines/saga2/panel.h
+++ b/engines/saga2/panel.h
@@ -28,11 +28,8 @@
#define SAGA2_PANEL_H
#include "saga2/dlist.h"
-#include "saga2/gdraw.h"
-#include "saga2/errors.h"
-#include "saga2/gbevel.h"
#include "saga2/input.h"
-#include "saga2/vwpage.h"
+#include "saga2/vdraw.h"
namespace Saga2 {
// Fix problem with DOS's encroachment on name space that should
diff --git a/engines/saga2/rmem.cpp b/engines/saga2/rmem.cpp
index a9d6042908..9408d54839 100644
--- a/engines/saga2/rmem.cpp
+++ b/engines/saga2/rmem.cpp
@@ -27,6 +27,7 @@
#include "saga2/std.h"
#define NO_LOCAL_MEMORY_OVERRIDES 1
+#include "saga2/rmem.h"
#include "saga2/rmembase.h"
#include "saga2/errors.h"
diff --git a/engines/saga2/rmembase.h b/engines/saga2/rmembase.h
index 7d1448bfb4..70d53cc50b 100644
--- a/engines/saga2/rmembase.h
+++ b/engines/saga2/rmembase.h
@@ -27,8 +27,6 @@
#ifndef SAGA2_RMEMBASE_H
#define SAGA2_RMEMBASE_H
-#include "saga2/rmem.h"
-
namespace Saga2 {
/* ===================================================================== *
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index caecc03bac..3ab62443af 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -39,6 +39,7 @@
#include "saga2/std.h"
#include "saga2/blitters.h"
#include "saga2/loadmsg.h"
+#include "saga2/gdraw.h"
namespace Saga2 {
diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h
index 28f0ad1a9e..862df22831 100644
--- a/engines/saga2/saga2.h
+++ b/engines/saga2/saga2.h
@@ -27,7 +27,6 @@
#include "common/serializer.h"
#include "common/system.h"
#include "engines/engine.h"
-#include "gui/debugger.h"
namespace Video {
class SmackerDecoder;
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index 07a8fee83e..3f750fa4e0 100644
--- a/engines/saga2/sagafunc.cpp
+++ b/engines/saga2/sagafunc.cpp
@@ -53,6 +53,7 @@
#include "saga2/videobox.h"
#include "saga2/display.h"
#include "saga2/transit.h"
+#include "saga2/contain.h"
void drawMainDisplay(void);
diff --git a/engines/saga2/speldata.cpp b/engines/saga2/speldata.cpp
index c0e0fe091e..17077cbf08 100644
--- a/engines/saga2/speldata.cpp
+++ b/engines/saga2/speldata.cpp
@@ -29,6 +29,7 @@
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/dispnode.h"
+#include "saga2/objproto.h"
#include "saga2/spells.h"
#include "saga2/spellbuk.h"
#include "saga2/spelshow.h"
diff --git a/engines/saga2/speldraw.cpp b/engines/saga2/speldraw.cpp
index 88e03c9bdb..50d5a66944 100644
--- a/engines/saga2/speldraw.cpp
+++ b/engines/saga2/speldraw.cpp
@@ -29,6 +29,7 @@
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/dispnode.h"
+#include "saga2/objproto.h"
#include "saga2/spellbuk.h"
#include "saga2/spelshow.h"
diff --git a/engines/saga2/spellloc.cpp b/engines/saga2/spellloc.cpp
index 8f69dc6f49..cecff91cb4 100644
--- a/engines/saga2/spellloc.cpp
+++ b/engines/saga2/spellloc.cpp
@@ -31,7 +31,7 @@
#include "saga2/spellbuk.h"
#include "saga2/spelshow.h"
#include "saga2/spelvals.h"
-
+#include "saga2/tilevect.h"
namespace Saga2 {
diff --git a/engines/saga2/spelshow.h b/engines/saga2/spelshow.h
index 86a64d32bd..4753471135 100644
--- a/engines/saga2/spelshow.h
+++ b/engines/saga2/spelshow.h
@@ -29,9 +29,6 @@
#include "saga2/dispnode.h"
#include "saga2/speldefs.h"
-#include "saga2/spells.h"
-#include "saga2/dice.h"
-#include "saga2/tilevect.h"
namespace Saga2 {
diff --git a/engines/saga2/tilemode.cpp b/engines/saga2/tilemode.cpp
index 4b3ea1da6c..693174d960 100644
--- a/engines/saga2/tilemode.cpp
+++ b/engines/saga2/tilemode.cpp
@@ -49,6 +49,7 @@
#include "saga2/loadsave.h"
#include "saga2/display.h"
#include "saga2/automap.h"
+#include "saga2/images.h"
namespace Saga2 {
diff --git a/engines/saga2/tilevect.h b/engines/saga2/tilevect.h
index 754621fb11..c169210469 100644
--- a/engines/saga2/tilevect.h
+++ b/engines/saga2/tilevect.h
@@ -27,9 +27,6 @@
#ifndef SAGA2_TILEVECT_H
#define SAGA2_TILEVECT_H
-#include "saga2/tcoords.h"
-#include "saga2/dice.h"
-
namespace Saga2 {
// This routine returns a random vector between two bounding vectors
diff --git a/engines/saga2/towerfta.cpp b/engines/saga2/towerfta.cpp
index c496c1ee03..754115ca10 100644
--- a/engines/saga2/towerfta.cpp
+++ b/engines/saga2/towerfta.cpp
@@ -48,6 +48,7 @@
#include "saga2/loadsave.h"
#include "saga2/display.h"
#include "saga2/transit.h"
+#include "saga2/tile.h"
namespace Saga2 {
diff --git a/engines/saga2/vpage.h b/engines/saga2/vpage.h
index ec6b9d4cc9..b40c5d5860 100644
--- a/engines/saga2/vpage.h
+++ b/engines/saga2/vpage.h
@@ -27,9 +27,6 @@
#ifndef SAGA2_VPAGE_H
#define SAGA2_VPAGE_H
-#include "saga2/rect.h"
-#include "saga2/errors.h"
-
namespace Saga2 {
class vDisplayPage {
diff --git a/engines/saga2/vpal.h b/engines/saga2/vpal.h
index 3330b1854c..095d7091d7 100644
--- a/engines/saga2/vpal.h
+++ b/engines/saga2/vpal.h
@@ -27,6 +27,8 @@
#ifndef SAGA2_VPAL_H
#define SAGA2_VPAL_H
+#include "saga2/idtypes.h"
+
namespace Saga2 {
// Stores an RGB value
diff --git a/engines/saga2/vwdraw.cpp b/engines/saga2/vwdraw.cpp
index 899470e34a..20a69099ac 100644
--- a/engines/saga2/vwdraw.cpp
+++ b/engines/saga2/vwdraw.cpp
@@ -28,6 +28,7 @@
#include "saga2/std.h"
#include "saga2/vwpage.h"
+#include "saga2/vdraw.h"
namespace Saga2 {
diff --git a/engines/saga2/vwpage.cpp b/engines/saga2/vwpage.cpp
index db8533065b..f798a89032 100644
--- a/engines/saga2/vwpage.cpp
+++ b/engines/saga2/vwpage.cpp
@@ -27,8 +27,11 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
+#include "saga2/rect.h"
+#include "saga2/vdraw.h"
#include "saga2/vwpage.h"
#include "saga2/display.h"
+#include "saga2/vpage.h"
namespace Saga2 {
diff --git a/engines/saga2/vwpage.h b/engines/saga2/vwpage.h
index d6300a7ad7..45848dbbbb 100644
--- a/engines/saga2/vwpage.h
+++ b/engines/saga2/vwpage.h
@@ -27,10 +27,10 @@
#ifndef SAGA2_VWPAGE_H
#define SAGA2_VWPAGE_H
-#include "vdraw.h"
-
namespace Saga2 {
+class gDisplayPort;
+
#define CDDWindow void
extern void initDDGraphics(gDisplayPort &mainPort, CDDWindow *displayWin);
diff --git a/engines/saga2/weapons.cpp b/engines/saga2/weapons.cpp
index 9336b12a01..ac381d3e12 100644
--- a/engines/saga2/weapons.cpp
+++ b/engines/saga2/weapons.cpp
@@ -27,8 +27,11 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
+#include "saga2/idtypes.h"
#include "saga2/rmemfta.h"
#include "saga2/weapons.h"
+#include "saga2/spellbuk.h"
+#include "saga2/actor.h"
namespace Saga2 {
diff --git a/engines/saga2/weapons.h b/engines/saga2/weapons.h
index b72181029a..b2912a9390 100644
--- a/engines/saga2/weapons.h
+++ b/engines/saga2/weapons.h
@@ -28,14 +28,11 @@
#define SAGA2_WEAPONS_H
#include "saga2/spelshow.h"
-#include "saga2/spells.h"
-#include "saga2/dice.h"
-#include "saga2/effects.h"
-#include "saga2/actor.h"
-#include "saga2/spellbuk.h"
namespace Saga2 {
+struct ResourceItemEffect;
+
ProtoEffect *createNewProtoEffect(ResourceItemEffect *rie);
//-----------------------------------------------------------------------
Commit: a24d6c7a1c053ed8c09ebc6f7f2e1a36bbd7249b
https://github.com/scummvm/scummvm/commit/a24d6c7a1c053ed8c09ebc6f7f2e1a36bbd7249b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:55+02:00
Commit Message:
SAGA2: More work on includes
Changed paths:
engines/saga2/actor.cpp
engines/saga2/automap.cpp
engines/saga2/band.cpp
engines/saga2/button.cpp
engines/saga2/button.h
engines/saga2/contain.cpp
engines/saga2/document.cpp
engines/saga2/fta.h
engines/saga2/idtypes.h
engines/saga2/imagcach.cpp
engines/saga2/interp.cpp
engines/saga2/main.cpp
engines/saga2/mission.cpp
engines/saga2/noise.cpp
engines/saga2/objects.cpp
engines/saga2/objects.h
engines/saga2/patrol.cpp
engines/saga2/playmode.cpp
engines/saga2/property.h
engines/saga2/rserver.cpp
engines/saga2/speech.cpp
engines/saga2/spelcast.cpp
engines/saga2/speldata.cpp
engines/saga2/speldefs.h
engines/saga2/sprite.cpp
engines/saga2/tile.cpp
engines/saga2/tile.h
engines/saga2/tileload.cpp
engines/saga2/tilemode.cpp
engines/saga2/timer.cpp
engines/saga2/towerfta.cpp
engines/saga2/tromode.cpp
engines/saga2/uidialog.cpp
engines/saga2/videobox.cpp
engines/saga2/vpal.cpp
engines/saga2/weapons.cpp
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index de4e0d164a..0815bd546a 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -47,6 +47,7 @@
#include "saga2/weapons.h"
#include "saga2/localize.h"
#include "saga2/intrface.h"
+#include "saga2/hresmgr.cpp"
// Include files needed for SAGA script dispatch
#include "saga2/script.h"
diff --git a/engines/saga2/automap.cpp b/engines/saga2/automap.cpp
index ea88056a65..ed6ee61ebd 100644
--- a/engines/saga2/automap.cpp
+++ b/engines/saga2/automap.cpp
@@ -35,6 +35,7 @@
#include "saga2/grequest.h"
#include "saga2/mapfeatr.h"
#include "saga2/grabinfo.h"
+#include "saga2/hresmgr.h"
namespace Saga2 {
diff --git a/engines/saga2/band.cpp b/engines/saga2/band.cpp
index 0360df5b77..935d542a50 100644
--- a/engines/saga2/band.cpp
+++ b/engines/saga2/band.cpp
@@ -29,6 +29,7 @@
#include "saga2/std.h"
#include "saga2/actor.h"
#include "saga2/band.h"
+#include "saga2/savefile.h"
namespace Saga2 {
diff --git a/engines/saga2/button.cpp b/engines/saga2/button.cpp
index daf59f8c19..e605af935f 100644
--- a/engines/saga2/button.cpp
+++ b/engines/saga2/button.cpp
@@ -33,6 +33,7 @@
#include "saga2/rmem.h"
#include "saga2/objects.h"
#include "saga2/grabinfo.h"
+#include "saga2/hresmgr.h"
namespace Saga2 {
diff --git a/engines/saga2/button.h b/engines/saga2/button.h
index d8b8fd63b3..0cee9bc345 100644
--- a/engines/saga2/button.h
+++ b/engines/saga2/button.h
@@ -33,6 +33,7 @@
#include "saga2/sprite.h"
namespace Saga2 {
+
/* ======================================================================= *
Misc. Structs and classes
* ======================================================================= */
diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index 851f0dced9..7bfaf11ffb 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -40,6 +40,7 @@
#include "saga2/magic.h"
#include "saga2/spellbuk.h"
#include "saga2/imagcach.h"
+#include "saga2/hresmgr.h"
#include "saga2/pclass.r"
diff --git a/engines/saga2/document.cpp b/engines/saga2/document.cpp
index d54a7f481c..6590312d08 100644
--- a/engines/saga2/document.cpp
+++ b/engines/saga2/document.cpp
@@ -38,6 +38,7 @@
#include "saga2/script.h"
#include "saga2/program.h"
#include "saga2/version.h"
+#include "saga2/hresmgr.h"
namespace Saga2 {
diff --git a/engines/saga2/fta.h b/engines/saga2/fta.h
index e043dca48e..6e91ab732c 100644
--- a/engines/saga2/fta.h
+++ b/engines/saga2/fta.h
@@ -33,11 +33,14 @@
#include "saga2/gpointer.h"
#include "saga2/fontlib.h"
#include "saga2/rmem.h"
-#include "saga2/hresmgr.h"
-#include "saga2/savefile.h"
-#include "saga2/config.h"
namespace Saga2 {
+
+class SaveFileConstructor;
+class SaveFileReader;
+class hResContext;
+class hResource;
+
/* ===================================================================== *
Constants
* ===================================================================== */
diff --git a/engines/saga2/idtypes.h b/engines/saga2/idtypes.h
index 7e56da7e0f..c2a7badb14 100644
--- a/engines/saga2/idtypes.h
+++ b/engines/saga2/idtypes.h
@@ -219,10 +219,12 @@ const BandID NoBand = -1;
typedef uint32 soundSegment;
-typedef uint8 gPen; // a pen index number
+typedef uint8 gPen; // a pen index number
typedef uint16 weaponID;
+typedef uint32 hResID;
+
} // end of namespace Saga2
#endif
diff --git a/engines/saga2/imagcach.cpp b/engines/saga2/imagcach.cpp
index 0b2a7c7f20..8ee1f24451 100644
--- a/engines/saga2/imagcach.cpp
+++ b/engines/saga2/imagcach.cpp
@@ -31,6 +31,7 @@
#include "saga2/fta.h"
#include "saga2/dlist.h"
#include "saga2/imagcach.h"
+#include "saga2/hresmgr.h"
namespace Saga2 {
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index bc082e2f7c..0ce9823b5b 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -37,6 +37,7 @@
#include "saga2/objects.h"
#include "saga2/tile.h"
#include "saga2/mission.h"
+#include "saga2/hresmgr.h"
namespace Saga2 {
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index e359b1aa08..0352d0b247 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -52,6 +52,9 @@
#include "saga2/gamerate.h"
#include "saga2/msgbox.h"
#include "saga2/script.h"
+#include "saga2/config.h"
+#include "saga2/hresmgr.h"
+
namespace Saga2 {
diff --git a/engines/saga2/mission.cpp b/engines/saga2/mission.cpp
index 2d620a8a52..19447f5a52 100644
--- a/engines/saga2/mission.cpp
+++ b/engines/saga2/mission.cpp
@@ -29,6 +29,7 @@
#include "saga2/std.h"
#include "saga2/mission.h"
#include "saga2/actor.h"
+#include "saga2/savefile.h"
namespace Saga2 {
diff --git a/engines/saga2/noise.cpp b/engines/saga2/noise.cpp
index b6bbe92ca5..1c6f80bc80 100644
--- a/engines/saga2/noise.cpp
+++ b/engines/saga2/noise.cpp
@@ -44,6 +44,9 @@
#include "saga2/audqueue.h"
#include "saga2/audiosys.h"
+#include "saga2/config.h"
+#include "saga2/hresmgr.h"
+
namespace Saga2 {
//#define AUDIO_DISABLED
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 4c3af99b0d..8741f8d8a2 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -50,6 +50,7 @@
#include "saga2/spellbuk.h"
#include "saga2/tilevect.h"
#include "saga2/dispnode.h"
+#include "saga2/hresmgr.h"
#include "saga2/methods.r" // generated by SAGA
#include "saga2/pclass.r"
diff --git a/engines/saga2/objects.h b/engines/saga2/objects.h
index 943549a7bb..a26f9e2e96 100644
--- a/engines/saga2/objects.h
+++ b/engines/saga2/objects.h
@@ -41,6 +41,8 @@ namespace Saga2 {
* ======================================================================= */
class GameWorld;
+class SaveFileConstructor;
+class SaveFileReader;
const uint16 unlimitedCapacity = maxuint16;
diff --git a/engines/saga2/patrol.cpp b/engines/saga2/patrol.cpp
index 0d05824526..c53486fe85 100644
--- a/engines/saga2/patrol.cpp
+++ b/engines/saga2/patrol.cpp
@@ -31,6 +31,7 @@
#include "saga2/patrol.h"
#include "saga2/cmisc.h"
#include "saga2/tcoords.h"
+#include "saga2/hresmgr.h"
namespace Saga2 {
diff --git a/engines/saga2/playmode.cpp b/engines/saga2/playmode.cpp
index c6a2d841c1..c63101018c 100644
--- a/engines/saga2/playmode.cpp
+++ b/engines/saga2/playmode.cpp
@@ -46,6 +46,7 @@
#include "saga2/cmisc.h"
#include "saga2/button.h"
#include "graphics/surface.h"
+#include "saga2/hresmgr.h"
namespace Saga2 {
diff --git a/engines/saga2/property.h b/engines/saga2/property.h
index 36371cea67..2d60c22fb9 100644
--- a/engines/saga2/property.h
+++ b/engines/saga2/property.h
@@ -27,9 +27,6 @@
#ifndef SAGA2_PROPERTY_H
#define SAGA2_PROPERTY_H
-#include "saga2/fta.h"
-#include "saga2/tcoords.h"
-
namespace Saga2 {
/* ===================================================================== *
diff --git a/engines/saga2/rserver.cpp b/engines/saga2/rserver.cpp
index 3119549394..d959c0ac49 100644
--- a/engines/saga2/rserver.cpp
+++ b/engines/saga2/rserver.cpp
@@ -31,6 +31,7 @@
#include "saga2/dlist.h"
#include "saga2/fta.h"
#include "saga2/ioerrors.h"
+#include "saga2/hresmgr.h"
namespace Saga2 {
diff --git a/engines/saga2/speech.cpp b/engines/saga2/speech.cpp
index 4068d390d3..be53940597 100644
--- a/engines/saga2/speech.cpp
+++ b/engines/saga2/speech.cpp
@@ -39,6 +39,8 @@
#include "saga2/annoy.h"
#include "saga2/savefile.h"
#include "saga2/cmisc.h"
+#include "saga2/config.h"
+#include "saga2/hresmgr.h"
namespace Saga2 {
diff --git a/engines/saga2/spelcast.cpp b/engines/saga2/spelcast.cpp
index e0c0efa859..08b487438a 100644
--- a/engines/saga2/spelcast.cpp
+++ b/engines/saga2/spelcast.cpp
@@ -37,6 +37,7 @@
#include "saga2/annoy.h"
#include "saga2/tileline.h"
#include "saga2/tilevect.h"
+#include "saga2/hresmgr.h"
namespace Saga2 {
diff --git a/engines/saga2/speldata.cpp b/engines/saga2/speldata.cpp
index 17077cbf08..d18f20bd0a 100644
--- a/engines/saga2/speldata.cpp
+++ b/engines/saga2/speldata.cpp
@@ -33,6 +33,8 @@
#include "saga2/spells.h"
#include "saga2/spellbuk.h"
#include "saga2/spelshow.h"
+#include "saga2/spellio.h"
+#include "saga2/hresmgr.h"
namespace Saga2 {
diff --git a/engines/saga2/speldefs.h b/engines/saga2/speldefs.h
index 9b3fec21cd..5864363ee6 100644
--- a/engines/saga2/speldefs.h
+++ b/engines/saga2/speldefs.h
@@ -29,11 +29,17 @@
#include "saga2/tile.h"
#include "saga2/objects.h"
-#include "saga2/spellio.h"
-#include "saga2/spells.h"
namespace Saga2 {
+class StorageSpellTarget;
+class SpellInstance;
+class StorageEffectron;
+class SpellDisplayPrototype;
+class EffectDisplayPrototype;
+class ResourceSpellItem;
+class StorageSpellInstance;
+
/* ===================================================================== *
Constants
* ===================================================================== */
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index f47cc9b786..7543cb28bf 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -32,6 +32,7 @@
#include "saga2/tcoords.h"
#include "saga2/input.h"
#include "saga2/cmisc.h"
+#include "saga2/hresmgr.h"
namespace Saga2 {
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 75b4740532..c0b707206a 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -29,6 +29,7 @@
#include "saga2/std.h"
#include "saga2/blitters.h"
#include "saga2/tcoords.h"
+#include "saga2/hresmgr.h"
#include "saga2/objects.h"
#include "saga2/tile.h"
#include "saga2/oncall.h"
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index 392935597d..84e5c00e5e 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -28,12 +28,12 @@
#define SAGA2_TILE_H
#include "saga2/fta.h"
-#include "saga2/idtypes.h"
#include "saga2/tileload.h"
#include "saga2/annoy.h"
#include "saga2/terrain.h"
#include "saga2/dlist.h"
#include "saga2/property.h"
+#include "saga2/tcoords.h"
#ifdef _WIN32 // Set structure alignment packing value to 1 byte
#pragma pack( push, 1 )
diff --git a/engines/saga2/tileload.cpp b/engines/saga2/tileload.cpp
index 4caa54f644..5d469c89a2 100644
--- a/engines/saga2/tileload.cpp
+++ b/engines/saga2/tileload.cpp
@@ -33,6 +33,7 @@
#include "saga2/tile.h"
#include "saga2/objects.h"
#include "saga2/tileload.h"
+#include "saga2/hresmgr.h"
#include "saga2/oncall.h"
#include "common/debug.h"
diff --git a/engines/saga2/tilemode.cpp b/engines/saga2/tilemode.cpp
index 693174d960..507707791b 100644
--- a/engines/saga2/tilemode.cpp
+++ b/engines/saga2/tilemode.cpp
@@ -50,6 +50,7 @@
#include "saga2/display.h"
#include "saga2/automap.h"
#include "saga2/images.h"
+#include "saga2/config.h"
namespace Saga2 {
diff --git a/engines/saga2/timer.cpp b/engines/saga2/timer.cpp
index b9c52a8ae3..4df2ad70c9 100644
--- a/engines/saga2/timer.cpp
+++ b/engines/saga2/timer.cpp
@@ -36,6 +36,7 @@
#include "saga2/audqueue.h"
#include "saga2/audiosys.h"
+#include "saga2/savefile.h"
namespace Saga2 {
/* ====================================================================== *
diff --git a/engines/saga2/towerfta.cpp b/engines/saga2/towerfta.cpp
index 754115ca10..090bea18f0 100644
--- a/engines/saga2/towerfta.cpp
+++ b/engines/saga2/towerfta.cpp
@@ -49,6 +49,7 @@
#include "saga2/display.h"
#include "saga2/transit.h"
#include "saga2/tile.h"
+#include "saga2/hresmgr.h"
namespace Saga2 {
diff --git a/engines/saga2/tromode.cpp b/engines/saga2/tromode.cpp
index 6259436277..636db5ff2b 100644
--- a/engines/saga2/tromode.cpp
+++ b/engines/saga2/tromode.cpp
@@ -37,6 +37,7 @@
#include "saga2/display.h"
#include "saga2/mainmap.h"
+#include "saga2/config.h"
namespace Saga2 {
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index 68c724eeec..7ed51e5da7 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -57,6 +57,9 @@
#include "saga2/program.h"
#include "saga2/version.h"
+#include "saga2/config.h"
+#include "saga2/hresmgr.h"
+
namespace Saga2 {
#define PROGRAM_ABOUT PROGRAM_FULL_NAME "\r\n\r\n"\
diff --git a/engines/saga2/videobox.cpp b/engines/saga2/videobox.cpp
index 87a0fa47df..7389eba760 100644
--- a/engines/saga2/videobox.cpp
+++ b/engines/saga2/videobox.cpp
@@ -30,6 +30,7 @@
#include "saga2/floating.h"
#include "saga2/rmemfta.h"
#include "saga2/videobox.h"
+#include "saga2/hresmgr.h"
namespace Saga2 {
diff --git a/engines/saga2/vpal.cpp b/engines/saga2/vpal.cpp
index 75dd6d0b63..f2fbca270f 100644
--- a/engines/saga2/vpal.cpp
+++ b/engines/saga2/vpal.cpp
@@ -34,6 +34,7 @@
#include "saga2/calender.h"
#include "saga2/player.h"
#include "saga2/display.h"
+#include "saga2/hresmgr.h"
namespace Saga2 {
diff --git a/engines/saga2/weapons.cpp b/engines/saga2/weapons.cpp
index ac381d3e12..6c25180b65 100644
--- a/engines/saga2/weapons.cpp
+++ b/engines/saga2/weapons.cpp
@@ -32,6 +32,8 @@
#include "saga2/weapons.h"
#include "saga2/spellbuk.h"
#include "saga2/actor.h"
+#include "saga2/spellio.h"
+#include "saga2/hresmgr.h"
namespace Saga2 {
Commit: a6b19daa9ace6c7f33a43952b7dd57e054eb779f
https://github.com/scummvm/scummvm/commit/a6b19daa9ace6c7f33a43952b7dd57e054eb779f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:55+02:00
Commit Message:
SAGA2: Fix include order
Changed paths:
engines/saga2/playmode.cpp
engines/saga2/tile.cpp
engines/saga2/tileload.cpp
diff --git a/engines/saga2/playmode.cpp b/engines/saga2/playmode.cpp
index c63101018c..56c5ffc645 100644
--- a/engines/saga2/playmode.cpp
+++ b/engines/saga2/playmode.cpp
@@ -26,6 +26,8 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+#include "graphics/surface.h"
+
#include "saga2/std.h"
#include "saga2/blitters.h"
#include "saga2/rmemfta.h"
@@ -45,7 +47,6 @@
#include "saga2/testmap.h"
#include "saga2/cmisc.h"
#include "saga2/button.h"
-#include "graphics/surface.h"
#include "saga2/hresmgr.h"
namespace Saga2 {
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index c0b707206a..564a388141 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -26,6 +26,9 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+#include "common/debug.h"
+#include "graphics/surface.h"
+
#include "saga2/std.h"
#include "saga2/blitters.h"
#include "saga2/tcoords.h"
@@ -47,9 +50,6 @@
#include "saga2/script.h"
#include "saga2/methods.r" // generated by SAGA
-#include "common/debug.h"
-#include "graphics/surface.h"
-
namespace Saga2 {
extern void writeLog(char *str);
diff --git a/engines/saga2/tileload.cpp b/engines/saga2/tileload.cpp
index 5d469c89a2..739e9ec3df 100644
--- a/engines/saga2/tileload.cpp
+++ b/engines/saga2/tileload.cpp
@@ -26,6 +26,8 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+#include "common/debug.h"
+
#include "saga2/std.h"
#include "saga2/input.h"
#include "saga2/cmisc.h"
@@ -35,7 +37,6 @@
#include "saga2/tileload.h"
#include "saga2/hresmgr.h"
#include "saga2/oncall.h"
-#include "common/debug.h"
namespace Saga2 {
Commit: c571279f1bcfa48b939768046ee4315e41638b31
https://github.com/scummvm/scummvm/commit/c571279f1bcfa48b939768046ee4315e41638b31
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:55+02:00
Commit Message:
SAGA2: Reduced header dependency for fta.h
Changed paths:
engines/saga2/automap.cpp
engines/saga2/beegee.cpp
engines/saga2/bitarray.h
engines/saga2/button.cpp
engines/saga2/button.h
engines/saga2/calender.cpp
engines/saga2/contain.cpp
engines/saga2/document.cpp
engines/saga2/floating.h
engines/saga2/fta.h
engines/saga2/gamemode.cpp
engines/saga2/gtextbox.cpp
engines/saga2/intrface.cpp
engines/saga2/loadsave.cpp
engines/saga2/magic.cpp
engines/saga2/msgbox.cpp
engines/saga2/oncall.h
engines/saga2/playmode.cpp
engines/saga2/property.h
engines/saga2/spelcast.cpp
engines/saga2/task.cpp
engines/saga2/terrain.cpp
engines/saga2/tileload.cpp
engines/saga2/towerfta.cpp
engines/saga2/transit.cpp
engines/saga2/uidialog.cpp
engines/saga2/vpal.cpp
diff --git a/engines/saga2/automap.cpp b/engines/saga2/automap.cpp
index ed6ee61ebd..85d4b0befa 100644
--- a/engines/saga2/automap.cpp
+++ b/engines/saga2/automap.cpp
@@ -27,6 +27,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
+#include "saga2/hresmgr.h"
#include "saga2/automap.h"
#include "saga2/blitters.h"
#include "saga2/tile.h"
@@ -35,7 +36,7 @@
#include "saga2/grequest.h"
#include "saga2/mapfeatr.h"
#include "saga2/grabinfo.h"
-#include "saga2/hresmgr.h"
+#include "saga2/rmemfta.h"
namespace Saga2 {
diff --git a/engines/saga2/beegee.cpp b/engines/saga2/beegee.cpp
index 9938e088c0..a6cd94570f 100644
--- a/engines/saga2/beegee.cpp
+++ b/engines/saga2/beegee.cpp
@@ -27,6 +27,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
+#include "saga2/idtypes.h"
#include "saga2/fta.h"
#include "saga2/tile.h"
#include "saga2/annoy.h"
diff --git a/engines/saga2/bitarray.h b/engines/saga2/bitarray.h
index 1ba3664f4f..a1bcbc489e 100644
--- a/engines/saga2/bitarray.h
+++ b/engines/saga2/bitarray.h
@@ -41,7 +41,7 @@ private:
public:
BitArray(uint16 newSize = 0) {
- if (newSize) b = (uint32 *) TALLOC(sizeof(uint32) * (newSize / 32 + 1), memBitArray);
+ if (newSize) b = (uint32 *)malloc(sizeof(uint32) * (newSize / 32 + 1));
size = newSize;
clear(newSize);
}
@@ -53,7 +53,7 @@ public:
void resize(uint16 newSize) {
uint32 *t = b;
if (newSize) {
- b = (uint32 *) TALLOC(sizeof(uint32) * (newSize / 32 + 1), memBitArray);
+ b = (uint32 *)malloc(sizeof(uint32) * (newSize / 32 + 1));
clear(newSize);
if (size) for (int i = 0; i < MIN(size, newSize) / 32 + 1; i++) b[i] = t[i];
}
diff --git a/engines/saga2/button.cpp b/engines/saga2/button.cpp
index e605af935f..39f2d65026 100644
--- a/engines/saga2/button.cpp
+++ b/engines/saga2/button.cpp
@@ -29,11 +29,12 @@
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/cmisc.h"
+#include "saga2/hresmgr.h"
#include "saga2/button.h"
#include "saga2/rmem.h"
#include "saga2/objects.h"
#include "saga2/grabinfo.h"
-#include "saga2/hresmgr.h"
+#include "saga2/fontlib.h"
namespace Saga2 {
diff --git a/engines/saga2/button.h b/engines/saga2/button.h
index 0cee9bc345..51d5882911 100644
--- a/engines/saga2/button.h
+++ b/engines/saga2/button.h
@@ -28,6 +28,7 @@
#define SAGA2_BUTTON_H
#include "saga2/fta.h"
+#include "saga2/hresmgr.h"
#include "saga2/panel.h"
#include "saga2/cmisc.h"
#include "saga2/sprite.h"
diff --git a/engines/saga2/calender.cpp b/engines/saga2/calender.cpp
index c31a3787d0..ea9d8c7d19 100644
--- a/engines/saga2/calender.cpp
+++ b/engines/saga2/calender.cpp
@@ -27,6 +27,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
+#include "saga2/hresmgr.h"
#include "saga2/calender.h"
#include "saga2/intrface.h"
#include "saga2/config.h"
diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index 7bfaf11ffb..08343e2d40 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -41,6 +41,8 @@
#include "saga2/spellbuk.h"
#include "saga2/imagcach.h"
#include "saga2/hresmgr.h"
+#include "saga2/fontlib.h"
+#include "saga2/rmemfta.h"
#include "saga2/pclass.r"
diff --git a/engines/saga2/document.cpp b/engines/saga2/document.cpp
index 6590312d08..67626667fb 100644
--- a/engines/saga2/document.cpp
+++ b/engines/saga2/document.cpp
@@ -39,6 +39,7 @@
#include "saga2/program.h"
#include "saga2/version.h"
#include "saga2/hresmgr.h"
+#include "saga2/fontlib.h"
namespace Saga2 {
diff --git a/engines/saga2/floating.h b/engines/saga2/floating.h
index f683d786ad..3e57b65109 100644
--- a/engines/saga2/floating.h
+++ b/engines/saga2/floating.h
@@ -28,6 +28,7 @@
#define SAGA2_FLOATING_H
#include "saga2/fta.h"
+#include "saga2/hresmgr.h"
#include "saga2/panel.h"
namespace Saga2 {
diff --git a/engines/saga2/fta.h b/engines/saga2/fta.h
index 6e91ab732c..2e789b438a 100644
--- a/engines/saga2/fta.h
+++ b/engines/saga2/fta.h
@@ -27,11 +27,7 @@
#ifndef SAGA2_FTA_H
#define SAGA2_FTA_H
-#include "saga2/rmemfta.h"
-#include "saga2/vwpage.h"
-#include "saga2/vpal.h"
#include "saga2/gpointer.h"
-#include "saga2/fontlib.h"
#include "saga2/rmem.h"
namespace Saga2 {
diff --git a/engines/saga2/gamemode.cpp b/engines/saga2/gamemode.cpp
index 20ac114c4c..a7dfb254a6 100644
--- a/engines/saga2/gamemode.cpp
+++ b/engines/saga2/gamemode.cpp
@@ -35,6 +35,7 @@
#include "saga2/floating.h"
#include "saga2/images.h"
#include "saga2/setup.h"
+#include "saga2/vpal.h"
#include "saga2/palette.h"
#include "saga2/transit.h"
#include "saga2/mouseimg.h"
diff --git a/engines/saga2/gtextbox.cpp b/engines/saga2/gtextbox.cpp
index 0da11b839e..0cf7c72199 100644
--- a/engines/saga2/gtextbox.cpp
+++ b/engines/saga2/gtextbox.cpp
@@ -183,7 +183,7 @@ gTextBox::gTextBox(
flags = flg;
currentLen[ index ] = buffer ? strlen(buffer) : 0;
cursorPos = anchorPos = scrollPixels = 0;
- undoBuffer = (char *) TALLOC(sizeof(char) * (maxLen + 1), memInterface);
+ undoBuffer = (char *)malloc(sizeof(char) * (maxLen + 1));
textFont = font;
fontHeight = height;
fontOffset = fontHeight + 2;
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index 35d18b41e0..03aa9130e1 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -45,6 +45,7 @@
#include "saga2/display.h"
#include "saga2/localize.h"
#include "saga2/imagcach.h"
+#include "saga2/fontlib.h"
namespace Saga2 {
@@ -1596,7 +1597,7 @@ void writePlaqTextPos(gPort &port,
void **loadButtonRes(hResContext *con, int16 resID, int16 numRes) {
int16 i, k;
- void **images = (void **) TALLOC(sizeof(void *)*numRes, memInterface);
+ void **images = (void **)malloc(sizeof(void *)*numRes);
for (i = 0, k = resID; i < numRes; i++, k++) {
// get an image from the image cache
@@ -1613,7 +1614,7 @@ void **loadButtonRes(hResContext *con, int16 resID, int16 numRes, char a, char b
int16 i, k;
- void **images = (void **) TALLOC(sizeof(void *)*numRes, memInterface);
+ void **images = (void **)malloc(sizeof(void *)*numRes);
for (i = 0, k = resID; i < numRes; i++, k++) {
images[i] = ImageCache.requestImage(con, MKTAG(a, b, c, k));
diff --git a/engines/saga2/loadsave.cpp b/engines/saga2/loadsave.cpp
index bfffa5e6ec..0474715b32 100644
--- a/engines/saga2/loadsave.cpp
+++ b/engines/saga2/loadsave.cpp
@@ -46,6 +46,7 @@
#include "saga2/tilemode.h"
#include "saga2/magic.h"
#include "saga2/intrface.h"
+#include "saga2/vpal.h"
#include "saga2/palette.h"
#include "saga2/contain.h"
#include "saga2/ioerrors.h"
diff --git a/engines/saga2/magic.cpp b/engines/saga2/magic.cpp
index 6b1c9305a4..ffc3716967 100644
--- a/engines/saga2/magic.cpp
+++ b/engines/saga2/magic.cpp
@@ -29,6 +29,7 @@
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/magic.h"
+#include "saga2/idtypes.h"
#include "saga2/speldefs.h"
#include "saga2/spellbuk.h"
#include "saga2/spelshow.h"
diff --git a/engines/saga2/msgbox.cpp b/engines/saga2/msgbox.cpp
index f14639b50e..c75c4354ee 100644
--- a/engines/saga2/msgbox.cpp
+++ b/engines/saga2/msgbox.cpp
@@ -32,6 +32,8 @@
#include "saga2/msgbox.h"
#include "saga2/floating.h"
#include "saga2/gbevel.h"
+#include "saga2/fontlib.h"
+#include "saga2/rmemfta.h"
namespace Saga2 {
diff --git a/engines/saga2/oncall.h b/engines/saga2/oncall.h
index 9e79ada827..da02ca432e 100644
--- a/engines/saga2/oncall.h
+++ b/engines/saga2/oncall.h
@@ -85,7 +85,7 @@ public:
wanted.resize(newSize);
locked.resize(newSize);
recent.resize(newSize);
- handle = (RESTYPE *) TALLOC(sizeof(RESTYPE) * newSize, memPrgResMan);
+ handle = (RESTYPE *)malloc(sizeof(RESTYPE) * newSize);
handles = newSize;
loader = loadfunction;
for (uint16 i = 0; i < newSize; i++)
diff --git a/engines/saga2/playmode.cpp b/engines/saga2/playmode.cpp
index 56c5ffc645..4151e9a832 100644
--- a/engines/saga2/playmode.cpp
+++ b/engines/saga2/playmode.cpp
@@ -48,6 +48,7 @@
#include "saga2/cmisc.h"
#include "saga2/button.h"
#include "saga2/hresmgr.h"
+#include "saga2/fontlib.h"
namespace Saga2 {
diff --git a/engines/saga2/property.h b/engines/saga2/property.h
index 2d60c22fb9..213e36444c 100644
--- a/engines/saga2/property.h
+++ b/engines/saga2/property.h
@@ -26,7 +26,6 @@
#ifndef SAGA2_PROPERTY_H
#define SAGA2_PROPERTY_H
-
namespace Saga2 {
/* ===================================================================== *
@@ -115,7 +114,7 @@ CompoundProperty< T >::CompoundProperty(
uint16 arrayBytes = sizeof(Property< T > *) * size;
// Allocate memory to copy the array.
- propertyArray = (Property< T > **)TALLOC(arrayBytes, memPropList);
+ propertyArray = (Property< T > **)malloc(arrayBytes);
#if DEBUG
assert(propertyArray);
#endif
diff --git a/engines/saga2/spelcast.cpp b/engines/saga2/spelcast.cpp
index 08b487438a..391a1e4151 100644
--- a/engines/saga2/spelcast.cpp
+++ b/engines/saga2/spelcast.cpp
@@ -29,6 +29,7 @@
#include "saga2/std.h"
#include "saga2/rmemfta.h"
#include "saga2/magic.h"
+#include "saga2/idtypes.h"
#include "saga2/speldefs.h"
#include "saga2/spellbuk.h"
#include "saga2/spelshow.h"
diff --git a/engines/saga2/task.cpp b/engines/saga2/task.cpp
index d9e981c7bc..54d7c5648a 100644
--- a/engines/saga2/task.cpp
+++ b/engines/saga2/task.cpp
@@ -34,6 +34,7 @@
#include "saga2/band.h"
#include "saga2/sensor.h"
#include "saga2/tilemode.h"
+#include "saga2/rmemfta.h"
namespace Saga2 {
diff --git a/engines/saga2/terrain.cpp b/engines/saga2/terrain.cpp
index 35ccf5e428..e675c459f3 100644
--- a/engines/saga2/terrain.cpp
+++ b/engines/saga2/terrain.cpp
@@ -28,6 +28,7 @@
#include "saga2/std.h"
#include "saga2/tcoords.h"
+#include "saga2/idtypes.h"
#include "saga2/tile.h"
#include "saga2/terrain.h"
#include "saga2/objects.h"
diff --git a/engines/saga2/tileload.cpp b/engines/saga2/tileload.cpp
index 739e9ec3df..43a6893590 100644
--- a/engines/saga2/tileload.cpp
+++ b/engines/saga2/tileload.cpp
@@ -32,6 +32,7 @@
#include "saga2/input.h"
#include "saga2/cmisc.h"
#include "saga2/tcoords.h"
+#include "saga2/idtypes.h"
#include "saga2/tile.h"
#include "saga2/objects.h"
#include "saga2/tileload.h"
diff --git a/engines/saga2/towerfta.cpp b/engines/saga2/towerfta.cpp
index 090bea18f0..d6774abd73 100644
--- a/engines/saga2/towerfta.cpp
+++ b/engines/saga2/towerfta.cpp
@@ -37,6 +37,7 @@
#include "saga2/audio.h"
#include "saga2/annoy.h"
#include "saga2/script.h"
+#include "saga2/vpal.h"
#include "saga2/palette.h"
#include "saga2/intrface.h"
#include "saga2/mouseimg.h"
diff --git a/engines/saga2/transit.cpp b/engines/saga2/transit.cpp
index 4cd9787a46..556d4a8b56 100644
--- a/engines/saga2/transit.cpp
+++ b/engines/saga2/transit.cpp
@@ -29,8 +29,10 @@
#include "saga2/std.h"
#include "saga2/fta.h"
#include "saga2/floating.h"
+#include "saga2/idtypes.h"
#include "saga2/tile.h"
#include "saga2/transit.h"
+#include "saga2/vpal.h"
#include "saga2/palette.h"
#include "saga2/calender.h"
#include "saga2/cmisc.h"
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index 7ed51e5da7..c8875251a7 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -52,6 +52,7 @@
#include "saga2/tilemode.h"
#include "saga2/display.h"
#include "saga2/uitext.h"
+#include "saga2/vpal.h"
#include "saga2/palette.h"
#include "saga2/display.h"
#include "saga2/program.h"
@@ -59,6 +60,7 @@
#include "saga2/config.h"
#include "saga2/hresmgr.h"
+#include "saga2/fontlib.h"
namespace Saga2 {
diff --git a/engines/saga2/vpal.cpp b/engines/saga2/vpal.cpp
index f2fbca270f..76294248f5 100644
--- a/engines/saga2/vpal.cpp
+++ b/engines/saga2/vpal.cpp
@@ -28,6 +28,7 @@
#include "saga2/std.h"
#include "saga2/fta.h"
+#include "saga2/vpal.h"
#include "saga2/palette.h"
#include "saga2/transit.h"
#include "saga2/cmisc.h"
Commit: 3e79f9cd1bc831b3aca77e76bc9cb40ca8e5ee72
https://github.com/scummvm/scummvm/commit/3e79f9cd1bc831b3aca77e76bc9cb40ca8e5ee72
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:55+02:00
Commit Message:
SAGA2: Remove rmemfta.h
Changed paths:
R engines/saga2/rmemfta.h
engines/saga2/actor.cpp
engines/saga2/automap.cpp
engines/saga2/button.cpp
engines/saga2/config.cpp
engines/saga2/contain.cpp
engines/saga2/display.cpp
engines/saga2/dispnode.cpp
engines/saga2/floating.cpp
engines/saga2/grequest.cpp
engines/saga2/hresmgr.cpp
engines/saga2/imagcach.cpp
engines/saga2/keybored.cpp
engines/saga2/magic.cpp
engines/saga2/main.cpp
engines/saga2/module.mk
engines/saga2/mouseimg.cpp
engines/saga2/msgbox.cpp
engines/saga2/noise.cpp
engines/saga2/objects.cpp
engines/saga2/panel.cpp
engines/saga2/playmode.cpp
engines/saga2/rserver.cpp
engines/saga2/spelcast.cpp
engines/saga2/speldata.cpp
engines/saga2/speldraw.cpp
engines/saga2/spellio.cpp
engines/saga2/task.cpp
engines/saga2/towerfta.cpp
engines/saga2/uidialog.cpp
engines/saga2/vbacksav.cpp
engines/saga2/videobox.cpp
engines/saga2/weapons.cpp
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 0815bd546a..ec22487a6c 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -29,7 +29,6 @@
#include "common/debug.h"
#include "saga2/std.h"
-#include "saga2/rmemfta.h"
#include "saga2/dispnode.h"
#include "saga2/tile.h"
#include "saga2/motion.h"
@@ -47,7 +46,7 @@
#include "saga2/weapons.h"
#include "saga2/localize.h"
#include "saga2/intrface.h"
-#include "saga2/hresmgr.cpp"
+#include "saga2/hresmgr.h"
// Include files needed for SAGA script dispatch
#include "saga2/script.h"
diff --git a/engines/saga2/automap.cpp b/engines/saga2/automap.cpp
index 85d4b0befa..e26e13376c 100644
--- a/engines/saga2/automap.cpp
+++ b/engines/saga2/automap.cpp
@@ -36,7 +36,6 @@
#include "saga2/grequest.h"
#include "saga2/mapfeatr.h"
#include "saga2/grabinfo.h"
-#include "saga2/rmemfta.h"
namespace Saga2 {
@@ -554,12 +553,12 @@ int16 openAutoMap() {
checkAlloc(closeBtnImage = loadButtonRes(decRes, closeButtonResID, numBtnImages));
checkAlloc(scrollBtnImage = loadButtonRes(decRes, scrollButtonResID, 2));
- pAutoMap = NEW_UI CAutoMap(autoMapRect, (uint8 *)summaryData, 0, NULL);
+ pAutoMap = new CAutoMap(autoMapRect, (uint8 *)summaryData, 0, NULL);
- checkAlloc(closeAutoMap = NEW_UI gCompButton(*pAutoMap, closeAutoMapBtnRect,
+ checkAlloc(closeAutoMap = new gCompButton(*pAutoMap, closeAutoMapBtnRect,
closeBtnImage, numBtnImages, 0, cmdAutoMapQuit));
- checkAlloc(scrollBtn = NEW_UI gCompButton(*pAutoMap, scrollBtnRect,
+ checkAlloc(scrollBtn = new gCompButton(*pAutoMap, scrollBtnRect,
scrollBtnImage, numBtnImages, 0, cmdAutoMapScroll));
pAutoMap->setDecorations(autoMapDecorations,
diff --git a/engines/saga2/button.cpp b/engines/saga2/button.cpp
index 39f2d65026..173c944185 100644
--- a/engines/saga2/button.cpp
+++ b/engines/saga2/button.cpp
@@ -27,7 +27,6 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
-#include "saga2/rmemfta.h"
#include "saga2/cmisc.h"
#include "saga2/hresmgr.h"
#include "saga2/button.h"
@@ -64,7 +63,7 @@ gCompImage::gCompImage(gPanelList &list, const Rect16 &box, void *image, uint16
init();
if (image) {
- compImages = (void **) TALLOC(sizeof(pVOID) * 1, memInterface); // allocate room for one pointer
+ compImages = (void **)malloc(sizeof(pVOID) * 1); // allocate room for one pointer
compImages[ 0 ] = image;
internalAlloc = FALSE;
numPtrAlloc = 1;
@@ -86,7 +85,7 @@ gCompImage::gCompImage(gPanelList &list,
hResContext *resContext = resFile->newContext(contextID, "container window resource");
// setup for a numImages image configuration
- compImages = (void **) TALLOC(sizeof(void *)*numImages, memInterface); // allocate room for numImages pointers
+ compImages = (void **)malloc(sizeof(void *)*numImages); // allocate room for numImages pointers
for (i = 0, rNum = resNum; i < numImages; i++, rNum++) {
compImages[ i ] = LoadResource(resContext,
@@ -110,7 +109,7 @@ gCompImage::gCompImage(gPanelList &list, const Rect16 &box, void *image, const c
if (!image) return;
- compImages = (void **) TALLOC(sizeof(void *) * 1, memInterface); // allocate room for one pointer
+compImages = (void **)malloc(sizeof(void *) * 1); // allocate room for one pointer
compImages[ 0 ] = image;
max = 0;
@@ -691,7 +690,7 @@ gMultCompButton::gMultCompButton(gPanelList &list, const Rect16 &box, hResContex
int16 i, k;
- images = (void **) TALLOC(sizeof(void *)*numRes, memInterface);
+ images = (void **)malloc(sizeof(void *)*numRes);
for (i = 0, k = resStart; i < numRes; i++, k++) {
images[ i ] = LoadResource(con, MKTAG(a, b, c, k), "Multi btn image");
diff --git a/engines/saga2/config.cpp b/engines/saga2/config.cpp
index e4c38cb871..016b804566 100644
--- a/engines/saga2/config.cpp
+++ b/engines/saga2/config.cpp
@@ -27,7 +27,6 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
-#include "saga2/rmemfta.h"
#include "saga2/config.h"
#include "saga2/program.h"
diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index 08343e2d40..0fa906f3af 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -42,7 +42,6 @@
#include "saga2/imagcach.h"
#include "saga2/hresmgr.h"
#include "saga2/fontlib.h"
-#include "saga2/rmemfta.h"
#include "saga2/pclass.r"
@@ -1188,7 +1187,7 @@ ContainerWindow::ContainerWindow(ContainerNode &nd,
view = NULL;
// create the close button for this window
- closeCompButton = NEW_UI gCompButton(
+ closeCompButton = new gCompButton(
*this,
app.closeRect, // rect for button
containerRes, // resource context
@@ -1212,10 +1211,10 @@ ContainerView &ContainerWindow::getView(void) {
ScrollableContainerWindow::ScrollableContainerWindow(
ContainerNode &nd, ContainerAppearanceDef &app, const char saveas[])
: ContainerWindow(nd, app, saveas) {
- view = NEW_UI ContainerView(*this, app.viewRect, nd, app);
+ view = new ContainerView(*this, app.viewRect, nd, app);
// make the button conected to this window
- scrollCompButton = NEW_UI gCompButton(
+ scrollCompButton = new gCompButton(
*this,
app.scrollRect, // rect for button
containerRes, // resource context
@@ -1273,7 +1272,7 @@ TangibleContainerWindow::TangibleContainerWindow(
// through an appfunc.
this->userData = view->containerObject;
- massWeightIndicator = NEW_UI CMassWeightIndicator(
+ massWeightIndicator = new CMassWeightIndicator(
this,
Point16(app.massRect.x, app.massRect.y),
weightIndicatorType,
@@ -1301,7 +1300,7 @@ void TangibleContainerWindow::setContainerSprite(void) {
sprPos.x = objRect.x - (spr->size.x >> 1); //objRect.x + ( spr->size.x >> 1 );
sprPos.y = objRect.y - (spr->size.y >> 1);
- containerSpriteImg = NEW_UI gSpriteImage(
+ containerSpriteImg = new gSpriteImage(
*this,
Rect16(sprPos.x,
sprPos.y,
@@ -1339,7 +1338,7 @@ IntangibleContainerWindow::IntangibleContainerWindow(
ContainerNode &nd, ContainerAppearanceDef &app)
: ScrollableContainerWindow(nd, app, "MentalWindow") {
// make the button conected to this window
- mindSelectorCompButton = NEW_UI gMultCompButton(
+ mindSelectorCompButton = new gMultCompButton(
*this,
Rect16(49, 15 - 13, 52, 67),
containerRes,
@@ -1366,10 +1365,10 @@ IntangibleContainerWindow::IntangibleContainerWindow(
EnchantmentContainerWindow::EnchantmentContainerWindow(
ContainerNode &nd, ContainerAppearanceDef &app)
: ContainerWindow(nd, app, "EnchantmentWindow") {
- view = NEW_UI EnchantmentContainerView(*this, nd, app);
+ view = new EnchantmentContainerView(*this, nd, app);
// make the button conected to this window
- scrollCompButton = NEW_UI gCompButton(
+ scrollCompButton = new gCompButton(
*this,
app.scrollRect, // rect for button
containerRes, // resource context
@@ -1516,22 +1515,22 @@ void ContainerNode::show(void) {
physicalContainerAppearance.rows = proto->getViewableRows();
physicalContainerAppearance.cols = proto->getViewableCols();
physicalContainerAppearance.totRows = proto->getMaxRows();
- window = NEW_UI TangibleContainerWindow(*this, physicalContainerAppearance);
+ window = new TangibleContainerWindow(*this, physicalContainerAppearance);
break;
case deadType:
deathContainerAppearance.rows = proto->getViewableRows();
deathContainerAppearance.cols = proto->getViewableCols();
deathContainerAppearance.totRows = proto->getMaxRows();
- window = NEW_UI TangibleContainerWindow(*this, deathContainerAppearance);
+ window = new TangibleContainerWindow(*this, deathContainerAppearance);
break;
case mentalType:
- window = NEW_UI IntangibleContainerWindow(*this, mentalContainerAppearance);
+ window = new IntangibleContainerWindow(*this, mentalContainerAppearance);
break;
case enchantType:
- window = NEW_UI EnchantmentContainerWindow(*this, enchantmentContainerAppearance);
+ window = new EnchantmentContainerWindow(*this, enchantmentContainerAppearance);
break;
}
}
@@ -1703,11 +1702,11 @@ ContainerNode *CreateContainerNode(ObjectID id, bool open, int16) {
if (((Actor *)obj)->isDead()) {
// Open dead container for dead actor
if (!(cn = globalContainerList.find(owner, ContainerNode::deadType)))
- cn = NEW_UI ContainerNode(globalContainerList, id, ContainerNode::deadType);
+ cn = new ContainerNode(globalContainerList, id, ContainerNode::deadType);
} else if (owner != ContainerNode::nobody) {
// Open mental container for living player actor.
// if (!(cn = globalContainerList.find( owner, ContainerNode::mentalType )))
-// cn = NEW_UI ContainerNode( globalContainerList, id, ContainerNode::mentalType );
+// cn = new ContainerNode( globalContainerList, id, ContainerNode::mentalType );
return OpenMindContainer(owner, open, /*mType*/ openMindType);
}
#if DEBUG
@@ -1718,7 +1717,7 @@ ContainerNode *CreateContainerNode(ObjectID id, bool open, int16) {
owner = ContainerNode::nobody;
if (!(cn = globalContainerList.find(id, ContainerNode::physicalType)))
- cn = NEW_UI ContainerNode(globalContainerList, id, ContainerNode::physicalType);
+ cn = new ContainerNode(globalContainerList, id, ContainerNode::physicalType);
}
// If node was successfull created, and we wanted it open, and the owner
@@ -1733,7 +1732,7 @@ ContainerNode *CreateContainerNode(ObjectID id, bool open, int16) {
}
ContainerNode *CreateReadyContainerNode(PlayerActorID player) {
- return NEW_UI ContainerNode(globalContainerList,
+ return new ContainerNode(globalContainerList,
getPlayerActorAddress(player)->getActorID(),
ContainerNode::readyType);
}
@@ -1743,7 +1742,7 @@ ContainerNode *OpenMindContainer(PlayerActorID player, int16 open, int16 type) {
ObjectID id = getPlayerActorAddress(player)->getActorID();
if (!(cn = globalContainerList.find(id, ContainerNode::mentalType))) {
- cn = NEW_UI ContainerNode(globalContainerList, id, ContainerNode::mentalType);
+ cn = new ContainerNode(globalContainerList, id, ContainerNode::mentalType);
cn->mindType = type;
// If node was successfull created, and we wanted it open, and the owner
@@ -1871,7 +1870,7 @@ void loadContainerNodes(SaveFileReader &saveGame) {
for (i = 0; i < numNodes; i++) {
// Allocate a new uninitialized ContainerNode
- node = NEW_UI ContainerNode;
+ node = new ContainerNode;
if (node == NULL)
error("Unable to allocate ContainerNode");
diff --git a/engines/saga2/display.cpp b/engines/saga2/display.cpp
index 47384cfb9f..35dbe04122 100644
--- a/engines/saga2/display.cpp
+++ b/engines/saga2/display.cpp
@@ -32,7 +32,6 @@
#include "saga2/intrface.h"
#include "saga2/loadmsg.h"
#include "saga2/grabinfo.h"
-#include "saga2/rmemfta.h"
namespace Saga2 {
diff --git a/engines/saga2/dispnode.cpp b/engines/saga2/dispnode.cpp
index 5ea82f772f..07c6e65d9b 100644
--- a/engines/saga2/dispnode.cpp
+++ b/engines/saga2/dispnode.cpp
@@ -28,7 +28,6 @@
#include "saga2/std.h"
#include "saga2/blitters.h"
-#include "saga2/rmemfta.h"
#include "saga2/dispnode.h"
#include "saga2/tile.h"
#include "saga2/actor.h"
diff --git a/engines/saga2/floating.cpp b/engines/saga2/floating.cpp
index a892c3363c..3fa151f868 100644
--- a/engines/saga2/floating.cpp
+++ b/engines/saga2/floating.cpp
@@ -27,7 +27,6 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
-#include "saga2/rmemfta.h"
#include "saga2/fta.h"
#include "saga2/panel.h"
#include "saga2/images.h"
@@ -448,7 +447,7 @@ void LabeledButton::drawClipped(
FloatingWindow::FloatingWindow(const Rect16 &r, uint16 ident, const char saveas[], AppFunc *cmd)
: DecoratedWindow(r, ident, saveas, cmd) {
- assert(db = NEW_UI DragBar(*this, Rect16(0, 0, r.width, r.height)));
+ assert(db = new DragBar(*this, Rect16(0, 0, r.width, r.height)));
origPos.x = r.x;
origPos.y = r.y;
diff --git a/engines/saga2/grequest.cpp b/engines/saga2/grequest.cpp
index ab00d21766..c656e042f2 100644
--- a/engines/saga2/grequest.cpp
+++ b/engines/saga2/grequest.cpp
@@ -28,7 +28,6 @@
#include "saga2/std.h"
#include "saga2/floating.h"
-#include "saga2/rmemfta.h"
#include "saga2/grequest.h"
#include "saga2/modal.h"
#include "saga2/images.h"
@@ -296,7 +295,7 @@ ModalRequestWindow::ModalRequestWindow(
width += extra;
- NEW_UI LabeledButton(*this,
+ new LabeledButton(*this,
Rect16(xPos,
r.height - fontHeight - 8,
width,
@@ -357,7 +356,7 @@ int16 GameDialogA(
rInfo.result = -1;
rInfo.running = TRUE;
- win = NEW_UI ModalRequestWindow(
+ win = new ModalRequestWindow(
Rect16((drawPage->size.x - 200) / 2,
(drawPage->size.y - 100) / 3,
200,
@@ -410,7 +409,7 @@ int16 GameDisplayA(
rInfo.result = -1;
rInfo.running = TRUE;
- win = NEW_UI ModalDisplayWindow(
+ win = new ModalDisplayWindow(
Rect16((drawPage->size.x - 200) / 2,
(drawPage->size.y - 100) / 3,
200,
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index d325644b31..886030d8a0 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -28,7 +28,6 @@
#include "saga2/std.h"
#include "saga2/saga2.h"
-#include "saga2/rmemfta.h"
#include "saga2/hresmgr.h"
#include "saga2/fta.h"
#include "common/debug.h"
diff --git a/engines/saga2/imagcach.cpp b/engines/saga2/imagcach.cpp
index 8ee1f24451..c786b8eb80 100644
--- a/engines/saga2/imagcach.cpp
+++ b/engines/saga2/imagcach.cpp
@@ -27,7 +27,6 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
-#include "saga2/rmemfta.h"
#include "saga2/fta.h"
#include "saga2/dlist.h"
#include "saga2/imagcach.h"
@@ -178,7 +177,7 @@ void *CImageCache::requestImage(hResContext *con, uint32 resID) {
// if no previously allocated image node then make one and return the
// ptr to the new image resource
// creates node and loads in the resource
- imageNode = NEW_UI CImageNode(con, resID);
+ imageNode = new CImageNode(con, resID);
checkAlloc(imageNode);
// add this node to the list
diff --git a/engines/saga2/keybored.cpp b/engines/saga2/keybored.cpp
index afe1653299..24e91b4805 100644
--- a/engines/saga2/keybored.cpp
+++ b/engines/saga2/keybored.cpp
@@ -27,7 +27,6 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
-#include "saga2/rmemfta.h"
#include "saga2/tilemode.h"
#include "saga2/calender.h"
diff --git a/engines/saga2/magic.cpp b/engines/saga2/magic.cpp
index ffc3716967..5bd43c892b 100644
--- a/engines/saga2/magic.cpp
+++ b/engines/saga2/magic.cpp
@@ -27,7 +27,6 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
-#include "saga2/rmemfta.h"
#include "saga2/magic.h"
#include "saga2/idtypes.h"
#include "saga2/speldefs.h"
@@ -307,7 +306,7 @@ bool implementSpell(GameObject *enactor, Location &target, SkillProto *spell)
}
}
- activeSpells.add(NEW_SPEL SpellInstance(GetOwner(enactor), target, sProto.getDisplayID()));
+ activeSpells.add(new SpellInstance(GetOwner(enactor), target, sProto.getDisplayID()));
sProto.playSound(enactor);
return TRUE;
}
@@ -347,7 +346,7 @@ bool implementSpell(GameObject *enactor, ActiveItem *target, SkillProto *spell)
}
}
- activeSpells.add(NEW_SPEL SpellInstance(GetOwner(enactor), l, sProto.getDisplayID()));
+ activeSpells.add(new SpellInstance(GetOwner(enactor), l, sProto.getDisplayID()));
sProto.playSound(enactor);
return TRUE;
}
@@ -385,7 +384,7 @@ bool implementSpell(GameObject *enactor, GameObject *target, SkillProto *spell)
}
}
- activeSpells.add(NEW_SPEL SpellInstance(GetOwner(enactor), target, sProto.getDisplayID()));
+ activeSpells.add(new SpellInstance(GetOwner(enactor), target, sProto.getDisplayID()));
sProto.playSound(enactor);
return TRUE;
}
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 0352d0b247..f50c2e60d9 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -30,7 +30,6 @@
#include "saga2/std.h"
-#include "saga2/rmemfta.h"
#include "saga2/fta.h"
#include "saga2/setup.h"
@@ -695,12 +694,12 @@ static bool openResource(
if (hr) delete hr;
hr = NULL;
- hr = NEW_PRES hResource(fileName, defaultPath, description);
+ hr = new hResource(fileName, defaultPath, description);
while (hr == NULL || !hr->_valid) {
if (hr) delete hr;
hr = NULL;
- hr = NEW_PRES hResource(fileName, defaultPath, description);
+ hr = new hResource(fileName, defaultPath, description);
}
if (hr == NULL || !hr->_valid) {
@@ -914,14 +913,14 @@ bool initGUIMessagers(void) {
for (int i = 0; i < 10; i++) {
char debItem[16];
sprintf(debItem, "Status%1.1d", i);
- Status[i] = NEW_MSGR StatusLineMessager(debItem, i, &mainPort);
+ Status[i] = new StatusLineMessager(debItem, i, &mainPort);
if (Status[i] == NULL)
return false;
sprintf(debItem, "Status%2.2d", i + 10);
- Status2[i] = NEW_MSGR StatusLineMessager(debItem, i, &mainPort, 468, 21 + (11 * i));
+ Status2[i] = new StatusLineMessager(debItem, i, &mainPort, 468, 21 + (11 * i));
}
for (int j = 0; j < 3; j++)
- ratemess[j] = NEW_MSGR StatusLineMessager("FrameRates", j, &mainPort, 5, 450 + (11 * j), 500);
+ ratemess[j] = new StatusLineMessager("FrameRates", j, &mainPort, 5, 450 + (11 * j), 500);
return true;
}
diff --git a/engines/saga2/module.mk b/engines/saga2/module.mk
index 0f74a3acb5..3fec5acdbf 100644
--- a/engines/saga2/module.mk
+++ b/engines/saga2/module.mk
@@ -49,9 +49,9 @@ MODULE_OBJS := \
mission.o \
modal.o \
motion.o \
+ mouseimg.o \
msgbox.o \
noise.o \
- mouseimg.o \
objects.o \
objproto.o \
panel.o \
diff --git a/engines/saga2/mouseimg.cpp b/engines/saga2/mouseimg.cpp
index 5c679e7ba4..64f4b8cba3 100644
--- a/engines/saga2/mouseimg.cpp
+++ b/engines/saga2/mouseimg.cpp
@@ -28,7 +28,6 @@
#include "saga2/std.h"
#include "saga2/blitters.h"
-#include "saga2/rmemfta.h"
#include "saga2/fta.h"
#include "saga2/mouseimg.h"
#include "saga2/images.h"
@@ -163,7 +162,7 @@ void createStackedImage(
newImage->size.y += images - 1;
newImageBytes = newImage->bytes();
- newImage->data = (uint8 *) TALLOC(newImageBytes, memPrgOutput) ;
+ newImage->data = (uint8 *)malloc(newImageBytes) ;
memset(newImage->data, 0, newImageBytes);
@@ -292,7 +291,7 @@ void setNewText(char *text) {
// Allocate a new buffer for the text image bitmap
textImageBytes = textImage.bytes();
- textImage.data = (uint8 *) TALLOC(textImageBytes, memPrgOutput);
+ textImage.data = (uint8 *)malloc(textImageBytes);
memset(textImage.data, 0, textImageBytes);
gPort textImagePort; // gPort used to draw text onto bitmap
diff --git a/engines/saga2/msgbox.cpp b/engines/saga2/msgbox.cpp
index c75c4354ee..a949290f3b 100644
--- a/engines/saga2/msgbox.cpp
+++ b/engines/saga2/msgbox.cpp
@@ -33,7 +33,6 @@
#include "saga2/floating.h"
#include "saga2/gbevel.h"
#include "saga2/fontlib.h"
-#include "saga2/rmemfta.h"
namespace Saga2 {
@@ -110,7 +109,7 @@ int16 FTAMessageBox(char *msg,
int16 MsgBox(char *msg,
char *btnMsg1,
char *btnMsg2) {
- ErrorWindow *win = NEW_MSGR ErrorWindow(msg, btnMsg1, btnMsg2);
+ ErrorWindow *win = new ErrorWindow(msg, btnMsg1, btnMsg2);
int16 res = win->getResult();
delete win;
return res;
diff --git a/engines/saga2/noise.cpp b/engines/saga2/noise.cpp
index 1c6f80bc80..dcff52d020 100644
--- a/engines/saga2/noise.cpp
+++ b/engines/saga2/noise.cpp
@@ -27,7 +27,6 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
-#include "saga2/rmemfta.h"
#include "saga2/fta.h"
#include "saga2/audio.h"
#include "saga2/audiores.h"
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 8741f8d8a2..0b5f5909af 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -27,7 +27,6 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
-#include "saga2/rmemfta.h"
#include "saga2/objects.h"
#include "saga2/actor.h"
#include "saga2/tile.h"
@@ -4385,7 +4384,7 @@ void readyContainerSetup(void) {
for (i = 0; i < kNumViews && i < playerActors ; i++) {
playerList[ i ].readyNode = CreateReadyContainerNode(i);
- TrioCviews[ i ] = NEW_UI ReadyContainerView(
+ TrioCviews[ i ] = new ReadyContainerView(
*trioControls,
Rect16(trioReadyContInfo[ i ].xPos,
trioReadyContInfo[ i ].yPos + 8,
@@ -4402,7 +4401,7 @@ void readyContainerSetup(void) {
TrioCviews[ i ]->draw();
}
- indivCviewTop = NEW_UI ReadyContainerView(*indivControls,
+ indivCviewTop = new ReadyContainerView(*indivControls,
Rect16(indivReadyContInfoTop.xPos,
indivReadyContInfoTop.yPos + 8,
iconOriginX * 2 + iconWidth * indivReadyContInfoTop.cols + iconSpacingY * (indivReadyContInfoTop.cols - 1),
@@ -4417,7 +4416,7 @@ void readyContainerSetup(void) {
indivCviewTop->draw();
- indivCviewBot = NEW_UI ReadyContainerView(*indivControls,
+ indivCviewBot = new ReadyContainerView(*indivControls,
Rect16(indivReadyContInfoBot.xPos,
indivReadyContInfoBot.yPos + 8,
iconOriginX * 2 + iconWidth * indivReadyContInfoBot.cols + iconSpacingY * (indivReadyContInfoBot.cols - 1),
diff --git a/engines/saga2/panel.cpp b/engines/saga2/panel.cpp
index 4201b3cc76..8786c68d43 100644
--- a/engines/saga2/panel.cpp
+++ b/engines/saga2/panel.cpp
@@ -27,7 +27,6 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
-#include "saga2/rmemfta.h"
#include "saga2/panel.h"
#include "saga2/gpointer.h"
#include "saga2/fontlib.h"
diff --git a/engines/saga2/playmode.cpp b/engines/saga2/playmode.cpp
index 4151e9a832..7d0d01c17a 100644
--- a/engines/saga2/playmode.cpp
+++ b/engines/saga2/playmode.cpp
@@ -30,7 +30,6 @@
#include "saga2/std.h"
#include "saga2/blitters.h"
-#include "saga2/rmemfta.h"
#include "saga2/tcoords.h"
#include "saga2/objects.h"
#include "saga2/sprite.h"
diff --git a/engines/saga2/rmemfta.h b/engines/saga2/rmemfta.h
deleted file mode 100644
index b32b08c872..0000000000
--- a/engines/saga2/rmemfta.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#ifndef SAGA2_RMEMFTA_H
-#define SAGA2_RMEMFTA_H
-
-namespace Saga2 {
-
-/* ===================================================================== *
- Memory Classes
- * ===================================================================== */
-
-enum memUsageGroup {
- memUnknown = 0, // Unknown Allocation
- // system classes
- memMain, // Init & Cleanup
- memMessagers, // Error handling, debugging
- memSysEnviron, // System Environment Interface
- memSysResource, // System Resource (subtyped)
- memSysTaskMan, // Task & thread management
- // program classes
- memPrgResMan, // General resource management
- memPrgInput, // Global input queues
- memPrgOutput, // Global output services
- // app classes
- memPropList, // Property lists
- memTempAlloc, // Temp bitmaps for interface
- memBitArray, // Bit Array class
- memDispNode, // Display Node Memory
- memInterface, // User Interface
- memSpells, // Spell memory
- memEffects, // Effect memory
- memTimer, // Game Timers
- memPathFind, // PathFinders
- memScripts, // SAGA memory
- memObjects, // Iterators mostly
-
- NumMemGroups, // max value
-};
-
-enum memSysResSubtype {
- msrsMemory = 'M',
- msrsFile = 'F',
- msrsSocket = 'N',
- msrsGraphics = 'G',
- msrsVideo = 'V',
- msrsAudio = 'A',
- msrsTimer = 'T',
-};
-
-
-// FIXME: These have to go
-
-#define MALLOC(s) malloc(s)
-#define TALLOC(s,t) malloc(s)
-#define SALLOC(s,t,c) malloc(s)
-
-#define NEW new
-#define NEW_MAIN new
-#define NEW_MSGR new
-#define NEW_SYSE new
-#define NEW_SYST new
-#define NEW_PRES new
-#define NEW_PINP new
-#define NEW_POUT new
-#define NEW_UI new
-#define NEW_SPEL new
-#define NEW_TMR new
-#define NEW_PATH new
-#define NEW_DISP new
-#define NEW_ITER new
-#define NEW_SAGA new
-#define NEW_EFCT new
-
-#define NEW_SRMEM new
-#define NEW_SRFIL new
-#define NEW_SRSOK new
-#define NEW_SRGRF new
-#define NEW_SRVID new
-#define NEW_SRAUD new
-#define NEW_SRTIM new
-
-}
-
-#endif //SAGA2_RMEMFTA_H
diff --git a/engines/saga2/rserver.cpp b/engines/saga2/rserver.cpp
index d959c0ac49..78ed636e06 100644
--- a/engines/saga2/rserver.cpp
+++ b/engines/saga2/rserver.cpp
@@ -27,7 +27,6 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
-#include "saga2/rmemfta.h"
#include "saga2/dlist.h"
#include "saga2/fta.h"
#include "saga2/ioerrors.h"
diff --git a/engines/saga2/spelcast.cpp b/engines/saga2/spelcast.cpp
index 391a1e4151..4f3333cbfa 100644
--- a/engines/saga2/spelcast.cpp
+++ b/engines/saga2/spelcast.cpp
@@ -27,7 +27,6 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
-#include "saga2/rmemfta.h"
#include "saga2/magic.h"
#include "saga2/idtypes.h"
#include "saga2/speldefs.h"
@@ -248,7 +247,7 @@ void SpellStuff::buildTargetList(GameObject *caster, SpellTarget &trg) {
GameObject *go;
it.first(&go);
while (go) {
- addTarget(NEW_SPEL SpellTarget(go));
+ addTarget(new SpellTarget(go));
it.next(&go);
}
break;
@@ -267,7 +266,7 @@ void SpellStuff::buildTargetList(GameObject *caster, SpellTarget &trg) {
GameObject *go;
it.first(&go);
while (go) {
- addTarget(NEW_SPEL SpellTarget(go));
+ addTarget(new SpellTarget(go));
it.next(&go);
}
break;
@@ -286,7 +285,7 @@ void SpellStuff::buildTargetList(GameObject *caster, SpellTarget &trg) {
GameObject *go;
it.first(&go);
while (go) {
- addTarget(NEW_SPEL SpellTarget(go));
+ addTarget(new SpellTarget(go));
it.next(&go);
}
break;
@@ -298,7 +297,7 @@ void SpellStuff::buildTargetList(GameObject *caster, SpellTarget &trg) {
GameObject *go;
it.first(&go);
while (go) {
- addTarget(NEW_SPEL SpellTarget(go));
+ addTarget(new SpellTarget(go));
it.next(&go);
}
break;
@@ -309,7 +308,7 @@ void SpellStuff::buildTargetList(GameObject *caster, SpellTarget &trg) {
GameObject *go;
it.first(&go);
while (go) {
- addTarget(NEW_SPEL SpellTarget(go));
+ addTarget(new SpellTarget(go));
it.next(&go);
}
break;
@@ -320,7 +319,7 @@ void SpellStuff::buildTargetList(GameObject *caster, SpellTarget &trg) {
GameObject *go;
it.first(&go);
while (go) {
- addTarget(NEW_SPEL SpellTarget(go));
+ addTarget(new SpellTarget(go));
it.next(&go);
}
break;
@@ -338,7 +337,7 @@ void SpellStuff::buildTargetList(GameObject *caster, SpellTarget &trg) {
GameObject *go;
it.first(&go);
while (go) {
- addTarget(NEW_SPEL SpellTarget(go));
+ addTarget(new SpellTarget(go));
it.next(&go);
}
break;
@@ -356,7 +355,7 @@ void SpellStuff::buildTargetList(GameObject *caster, SpellTarget &trg) {
GameObject *go;
it.first(&go);
while (go) {
- addTarget(NEW_SPEL SpellTarget(go));
+ addTarget(new SpellTarget(go));
it.next(&go);
}
break;
@@ -589,7 +588,7 @@ SpellInstance::SpellInstance(SpellCaster *newCaster, SpellTarget *newTarget, Spe
assert(newCaster);
assert(newTarget);
caster = newCaster;
- target = NEW_SPEL SpellTarget(*newTarget);
+ target = new SpellTarget(*newTarget);
world = newCaster->world();
spell = spellNo;
init();
@@ -600,7 +599,7 @@ SpellInstance::SpellInstance(SpellCaster *newCaster, SpellTarget *newTarget, Spe
SpellInstance::SpellInstance(SpellCaster *newCaster, GameObject &newTarget, SpellID spellNo) {
assert(newCaster);
- target = NEW_SPEL SpellTarget(newTarget);
+ target = new SpellTarget(newTarget);
caster = newCaster;
world = newCaster->world();
spell = spellNo;
@@ -613,7 +612,7 @@ SpellInstance::SpellInstance(SpellCaster *newCaster, GameObject &newTarget, Spel
SpellInstance::SpellInstance(SpellCaster *newCaster, GameObject *newTarget, SpellID spellNo) {
assert(newCaster);
assert(newTarget);
- target = NEW_SPEL SpellTarget(newTarget);
+ target = new SpellTarget(newTarget);
caster = newCaster;
world = newCaster->world();
spell = spellNo;
@@ -625,7 +624,7 @@ SpellInstance::SpellInstance(SpellCaster *newCaster, GameObject *newTarget, Spel
SpellInstance::SpellInstance(SpellCaster *newCaster, TilePoint &newTarget, SpellID spellNo) {
assert(newCaster);
- target = NEW_SPEL SpellTarget(newTarget);
+ target = new SpellTarget(newTarget);
caster = newCaster;
world = newCaster->world();
spell = spellNo;
@@ -692,7 +691,7 @@ void SpellInstance::initEffect(TilePoint startpoint) {
eList.count = effect->nodeCount; //sdp->effCount;
if (eList.count)
for (int32 i = 0; i < eList.count; i++) {
- Effectron *e = NEW_SPEL Effectron(0, i);
+ Effectron *e = new Effectron(0, i);
eList.displayList[i].efx = e;
e->parent = this;
e->start = startpoint;
diff --git a/engines/saga2/speldata.cpp b/engines/saga2/speldata.cpp
index d18f20bd0a..43f3eef7f6 100644
--- a/engines/saga2/speldata.cpp
+++ b/engines/saga2/speldata.cpp
@@ -27,7 +27,6 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
-#include "saga2/rmemfta.h"
#include "saga2/dispnode.h"
#include "saga2/objproto.h"
#include "saga2/spells.h"
@@ -159,9 +158,9 @@ void cleanupMagic(void) {
// the macros make things more legible than the entire call
// Set up a display effect shape
-#define ADD_EFFECT( n, p, s, f, h, b, i ) ( EffectDisplayPrototypeList::edpList.add( NEW_SPEL EffectDisplayPrototype(n,&p,&s,&f,&h,&b,&i )))
+#define ADD_EFFECT( n, p, s, f, h, b, i ) ( EffectDisplayPrototypeList::edpList.add( new EffectDisplayPrototype(n,&p,&s,&f,&h,&b,&i )))
// Chain another effect when done
-#define SECOND_EFFECT( e, n, p, s, f, h, b, i ) ( EffectDisplayPrototypeList::edpList.append( NEW_SPEL EffectDisplayPrototype(n,&p,&s,&f,&h,&b,&i ),e))
+#define SECOND_EFFECT( e, n, p, s, f, h, b, i ) ( EffectDisplayPrototypeList::edpList.append( new EffectDisplayPrototype(n,&p,&s,&f,&h,&b,&i ),e))
//-----------------------------------------------------------------------
@@ -189,7 +188,7 @@ static void defineEffects(void) {
}
//-----------------------------------------------------------------------
-#define ADD_SHOW( e, a, b, c, d, f, g, m, i, s, n ) ( SpellDisplayPrototypeList::sdpList.add( NEW_SPEL SpellDisplayPrototype( e, a, b, c, d, f, g, m, i, s, n )))
+#define ADD_SHOW( e, a, b, c, d, f, g, m, i, s, n ) ( SpellDisplayPrototypeList::sdpList.add( new SpellDisplayPrototype( e, a, b, c, d, f, g, m, i, s, n )))
//-----------------------------------------------------------------------
// loadMagicData : reads magic related data from the resource file
@@ -221,7 +220,7 @@ static void loadMagicData(void) {
error("Unable to load data for spell %d", i);
spellBook[rsi->spell].setupFromResource(rsi);
- SpellDisplayPrototypeList::sdpList.add(NEW_SPEL SpellDisplayPrototype(rsi));
+ SpellDisplayPrototypeList::sdpList.add(new SpellDisplayPrototype(rsi));
RDisposePtr(rsi);
i++;
diff --git a/engines/saga2/speldraw.cpp b/engines/saga2/speldraw.cpp
index 50d5a66944..226f72bf20 100644
--- a/engines/saga2/speldraw.cpp
+++ b/engines/saga2/speldraw.cpp
@@ -27,7 +27,6 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
-#include "saga2/rmemfta.h"
#include "saga2/dispnode.h"
#include "saga2/objproto.h"
#include "saga2/spellbuk.h"
@@ -81,7 +80,7 @@ EffectDisplayPrototype::EffectDisplayPrototype(
EffectDisplayPrototypeList::EffectDisplayPrototypeList(int32 c) {
count = 0;
maxCount = 0;
- effects = (pEffectDisplayPrototype *) TALLOC(sizeof(pEffectDisplayPrototype) * c, memSpells);
+ effects = (pEffectDisplayPrototype *)malloc(sizeof(pEffectDisplayPrototype) * c);
for (int i = 0; i < c; i++)
effects[i] = NULL;
assert(effects);
@@ -193,7 +192,7 @@ void SpellDisplayPrototypeList::cleanup(void) {
SpellDisplayPrototypeList::SpellDisplayPrototypeList(uint16 s) {
count = 0;
maxCount = 0;
- spells = (pSpellDisplayPrototype *) TALLOC(sizeof(pSpellDisplayPrototype) * s, memSpells);
+ spells = (pSpellDisplayPrototype *)malloc(sizeof(pSpellDisplayPrototype) * s);
for (int i = 0; i < s; i++)
spells[i] = NULL;
assert(spells);
@@ -226,7 +225,7 @@ int32 SpellDisplayPrototypeList::add(SpellDisplayPrototype *sdp) {
SpellDisplayList::SpellDisplayList(uint16 s) {
count = 0;
maxCount = 0;
- spells = (pSpellInstance *) TALLOC(sizeof(pSpellInstance) * s, memSpells);
+ spells = (pSpellInstance *)malloc(sizeof(pSpellInstance) * s);
for (int i = 0; i < s; i++)
spells[i] = NULL;
if (spells) maxCount = s;
diff --git a/engines/saga2/spellio.cpp b/engines/saga2/spellio.cpp
index bac61b9c61..4ae66403e9 100644
--- a/engines/saga2/spellio.cpp
+++ b/engines/saga2/spellio.cpp
@@ -28,7 +28,6 @@
#include "saga2/std.h"
#include "saga2/idtypes.h"
-#include "saga2/rmemfta.h"
#include "saga2/magic.h"
#include "saga2/effects.h"
#include "saga2/spellbuk.h"
@@ -107,7 +106,7 @@ void SpellStuff::addEffect(ResourceSpellEffect *rse) {
case effectNone :
return;
case effectAttrib :
- pe = NEW_EFCT ProtoEnchantment(
+ pe = new ProtoEnchantment(
makeEnchantmentID(
rse->effectGroup,
rse->effectType,
@@ -119,7 +118,7 @@ void SpellStuff::addEffect(ResourceSpellEffect *rse) {
case effectImmune :
case effectOthers :
case effectNonActor :
- pe = NEW_EFCT ProtoEnchantment(
+ pe = new ProtoEnchantment(
makeEnchantmentID(
rse->effectGroup,
rse->effectType,
@@ -128,7 +127,7 @@ void SpellStuff::addEffect(ResourceSpellEffect *rse) {
rse->enchTimeHi);
break;
case effectDamage :
- pe = NEW_EFCT ProtoDamage(
+ pe = new ProtoDamage(
rse->baseDice,
rse->diceSides ? rse->diceSides : 6,
rse->skillDice,
@@ -138,7 +137,7 @@ void SpellStuff::addEffect(ResourceSpellEffect *rse) {
rse->targeting & spellTargCaster);
break;
case effectDrains :
- pe = NEW_EFCT ProtoDrainage(
+ pe = new ProtoDrainage(
rse->baseDice,
rse->diceSides ? rse->diceSides : 6,
rse->skillDice,
@@ -148,53 +147,53 @@ void SpellStuff::addEffect(ResourceSpellEffect *rse) {
rse->targeting & spellTargCaster);
break;
case effectTAG :
- pe = NEW_EFCT ProtoTAGEffect(
+ pe = new ProtoTAGEffect(
(effectTAGTypes) rse->effectType,
rse->flagSet,
rse->attribModifier);
break;
case effectLocation :
- pe = NEW_EFCT ProtoLocationEffect(
+ pe = new ProtoLocationEffect(
(effectLocationTypes) rse->effectType,
rse->attribModifier);
break;
case effectSpecial : {
switch (rse->effectType) {
case specialDispellHelpfulEnch : // clears helpful enchantments
- pe = NEW_EFCT ProtoSpecialEffect(DispellProtections, rse->attribModifier);
+ pe = new ProtoSpecialEffect(DispellProtections, rse->attribModifier);
break;
case specialDispellHarmfulEnch : // clears harmful enchantments
- pe = NEW_EFCT ProtoSpecialEffect(DispellCurses, rse->attribModifier);
+ pe = new ProtoSpecialEffect(DispellCurses, rse->attribModifier);
break;
case specialKill : // death spell
- pe = NEW_EFCT ProtoSpecialEffect(DeathSpell, rse->attribModifier);
+ pe = new ProtoSpecialEffect(DeathSpell, rse->attribModifier);
break;
case specialRessurect : // raise dead spell
- pe = NEW_EFCT ProtoSpecialEffect(Resurrect, rse->attribModifier);
+ pe = new ProtoSpecialEffect(Resurrect, rse->attribModifier);
break;
case specialTeleport : // Teleportation
- pe = NEW_EFCT ProtoSpecialEffect(TeleportToLocation, rse->attribModifier);
+ pe = new ProtoSpecialEffect(TeleportToLocation, rse->attribModifier);
break;
case specialCreateActor : // Create an actor or wall
- pe = NEW_EFCT ProtoSpecialEffect(CreateWraith, rse->attribModifier);
+ pe = new ProtoSpecialEffect(CreateWraith, rse->attribModifier);
break;
case specialSagaFunc : // calls a saga function
- pe = NEW_EFCT ProtoSpecialEffect(SagaSpellCall, rse->attribModifier);
+ pe = new ProtoSpecialEffect(SagaSpellCall, rse->attribModifier);
break;
case specialRejoin : // Create an actor or wall
- pe = NEW_EFCT ProtoSpecialEffect(Rejoin, rse->attribModifier);
+ pe = new ProtoSpecialEffect(Rejoin, rse->attribModifier);
break;
case specialCreateWWisp : // calls a saga function
- pe = NEW_EFCT ProtoSpecialEffect(CreateWWisp, rse->attribModifier);
+ pe = new ProtoSpecialEffect(CreateWWisp, rse->attribModifier);
break;
case specialCreateFWisp : // calls a saga function
- pe = NEW_EFCT ProtoSpecialEffect(CreateFWisp, rse->attribModifier);
+ pe = new ProtoSpecialEffect(CreateFWisp, rse->attribModifier);
break;
case specialCreateWraith : // calls a saga function
- pe = NEW_EFCT ProtoSpecialEffect(CreateWraith, rse->attribModifier);
+ pe = new ProtoSpecialEffect(CreateWraith, rse->attribModifier);
break;
case specialCreateFood : // calls a saga function
- pe = NEW_EFCT ProtoSpecialEffect(CreateFood, rse->attribModifier);
+ pe = new ProtoSpecialEffect(CreateFood, rse->attribModifier);
break;
}
break;
@@ -309,7 +308,7 @@ SpellInstance::SpellInstance(StorageSpellInstance &ssi) {
implementAge = ssi.implementAge; // age at which to implement the spell effects
dProto = SpellDisplayPrototypeList::sdpList[ssi.dProto];
caster = GameObject::objectAddress(ssi.caster);
- target = NEW_SPEL SpellTarget(ssi.target);
+ target = new SpellTarget(ssi.target);
GameObject *go = GameObject::objectAddress(ssi.world);
assert(isWorld(go));
world = (GameWorld *) go;
@@ -365,7 +364,7 @@ void SpellDisplayList::load(SaveFileReader &saveGame) {
SpellInstance *si;
StorageSpellInstance ssi;
saveGame.read(&ssi, sizeof(ssi));
- si = NEW_SPEL SpellInstance(ssi);
+ si = new SpellInstance(ssi);
add(si);
si->loadEffect(saveGame, ssi.eListSize);
}
@@ -409,7 +408,7 @@ void SpellInstance::loadEffect(SaveFileReader &saveGame, uint16 eListSize) {
for (int32 i = 0; i < eList.count; i++) {
StorageEffectron se;
saveGame.read(&se, sizeof(se));
- Effectron *e = NEW_SPEL Effectron(se, this);
+ Effectron *e = new Effectron(se, this);
eList.displayList[i].efx = e;
}
}
diff --git a/engines/saga2/task.cpp b/engines/saga2/task.cpp
index 54d7c5648a..7e7cc48067 100644
--- a/engines/saga2/task.cpp
+++ b/engines/saga2/task.cpp
@@ -34,7 +34,6 @@
#include "saga2/band.h"
#include "saga2/sensor.h"
#include "saga2/tilemode.h"
-#include "saga2/rmemfta.h"
namespace Saga2 {
@@ -4408,7 +4407,7 @@ int16 BandTask::getRunThreshold(void) {
//----------------------------------------------------------------------
BandTask::RepulsorIterator *BandTask::getNewRepulsorIterator(void) {
- return NEW_ITER BandingRepulsorIterator(stack->getActor());
+ return new BandingRepulsorIterator(stack->getActor());
}
/* ===================================================================== *
@@ -4520,7 +4519,7 @@ int16 BandAndAvoidEnemiesTask::getRunThreshold(void) {
//----------------------------------------------------------------------
BandTask::RepulsorIterator *BandAndAvoidEnemiesTask::getNewRepulsorIterator(void) {
- return NEW_ITER BandAndAvoidEnemiesRepulsorIterator(stack->getActor());
+ return new BandAndAvoidEnemiesRepulsorIterator(stack->getActor());
}
/* ===================================================================== *
diff --git a/engines/saga2/towerfta.cpp b/engines/saga2/towerfta.cpp
index d6774abd73..4bff0343cd 100644
--- a/engines/saga2/towerfta.cpp
+++ b/engines/saga2/towerfta.cpp
@@ -27,7 +27,6 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
-#include "saga2/rmemfta.h"
#include "saga2/towerwin.h"
#include "saga2/towerfta.h"
#include "saga2/fta.h"
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index c8875251a7..5a0d2348ab 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -27,7 +27,6 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
-#include "saga2/rmemfta.h"
#include "saga2/objects.h"
#include "saga2/button.h"
#include "saga2/contain.h"
diff --git a/engines/saga2/vbacksav.cpp b/engines/saga2/vbacksav.cpp
index 1117b482b1..8a37166a19 100644
--- a/engines/saga2/vbacksav.cpp
+++ b/engines/saga2/vbacksav.cpp
@@ -28,7 +28,6 @@
#include "saga2/std.h"
#include "saga2/vbacksav.h"
-#include "saga2/rmemfta.h"
namespace Saga2 {
@@ -44,7 +43,7 @@ gBackSave::gBackSave(const Rect16 &extent) {
savedPixels.size.x = savedRegion.width;
savedPixels.size.y = savedRegion.height;
// savedPixels.data = (uint8 *)malloc( savedPixels.bytes() );
- savedPixels.data = (uint8 *) TALLOC(savedPixels.bytes(), memTempAlloc);
+ savedPixels.data = (uint8 *)malloc(savedPixels.bytes());
// Initialize the graphics port
diff --git a/engines/saga2/videobox.cpp b/engines/saga2/videobox.cpp
index 7389eba760..e405e1faa0 100644
--- a/engines/saga2/videobox.cpp
+++ b/engines/saga2/videobox.cpp
@@ -28,7 +28,6 @@
#include "saga2/std.h"
#include "saga2/floating.h"
-#include "saga2/rmemfta.h"
#include "saga2/videobox.h"
#include "saga2/hresmgr.h"
diff --git a/engines/saga2/weapons.cpp b/engines/saga2/weapons.cpp
index 6c25180b65..200384a7d3 100644
--- a/engines/saga2/weapons.cpp
+++ b/engines/saga2/weapons.cpp
@@ -28,7 +28,6 @@
#include "saga2/std.h"
#include "saga2/idtypes.h"
-#include "saga2/rmemfta.h"
#include "saga2/weapons.h"
#include "saga2/spellbuk.h"
#include "saga2/actor.h"
@@ -78,7 +77,7 @@ ProtoEffect *createNewProtoEffect(ResourceItemEffect *rie) {
return NULL;
case effectAttrib :
- pe = NEW_EFCT ProtoEnchantment(
+ pe = new ProtoEnchantment(
makeEnchantmentID(
rie->effectGroup,
rie->effectType,
@@ -90,7 +89,7 @@ ProtoEffect *createNewProtoEffect(ResourceItemEffect *rie) {
case effectImmune :
case effectOthers :
case effectNonActor :
- pe = NEW_EFCT ProtoEnchantment(
+ pe = new ProtoEnchantment(
makeEnchantmentID(
rie->effectGroup,
rie->effectType,
@@ -99,7 +98,7 @@ ProtoEffect *createNewProtoEffect(ResourceItemEffect *rie) {
rie->reserved1);
break;
case effectDamage :
- pe = NEW_EFCT ProtoDamage(
+ pe = new ProtoDamage(
rie->baseDice,
rie->diceSides ? rie->diceSides : 6,
rie->skillDice,
@@ -110,7 +109,7 @@ ProtoEffect *createNewProtoEffect(ResourceItemEffect *rie) {
rie->skillDamage);
break;
case effectDrains :
- pe = NEW_EFCT ProtoDrainage(
+ pe = new ProtoDrainage(
rie->baseDice,
rie->diceSides ? rie->diceSides : 6,
rie->skillDice,
@@ -121,24 +120,24 @@ ProtoEffect *createNewProtoEffect(ResourceItemEffect *rie) {
break;
case effectPoison :
- pe = NEW_EFCT ProtoEnchantment(
+ pe = new ProtoEnchantment(
makeEnchantmentID(rie->baseDamage), // poison
rie->reserved0,
rie->reserved1);
case effectTAG :
- pe = NEW_EFCT ProtoTAGEffect(
+ pe = new ProtoTAGEffect(
(effectTAGTypes) rie->effectType,
rie->skillDamage,
rie->baseDamage);
break;
case effectLocation :
- pe = NEW_EFCT ProtoLocationEffect(
+ pe = new ProtoLocationEffect(
(effectLocationTypes) rie->effectType,
rie->baseDamage);
break;
case effectSpecial :
- pe = NEW_EFCT ProtoSpecialEffect(
+ pe = new ProtoSpecialEffect(
SagaSpellCall,
rie->baseDamage);
break;
@@ -279,7 +278,7 @@ void WeaponStuff::addEffect(ResourceItemEffect *rie) {
assert(rie && rie->item == master);
if (rie->effectGroup == effectStrike) {
- we = NEW_EFCT WeaponStrikeEffect(
+ we = new WeaponStrikeEffect(
(effectDamageTypes)rie->effectType,
rie->baseDice,
rie->diceSides != 0 ? rie->diceSides : 6,
@@ -287,7 +286,7 @@ void WeaponStuff::addEffect(ResourceItemEffect *rie) {
rie->baseDamage,
rie->skillDamage);
} else
- we = NEW_EFCT WeaponProtoEffect(rie);
+ we = new WeaponProtoEffect(rie);
if (we == NULL)
error("failed to alloc weapon effect");
Commit: 0dba551dd55c38d9049a8042d0649f0b1942aca0
https://github.com/scummvm/scummvm/commit/0dba551dd55c38d9049a8042d0649f0b1942aca0
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:56+02:00
Commit Message:
SAGA2: Further work on include dependency reduction
Changed paths:
engines/saga2/actor.cpp
engines/saga2/document.h
engines/saga2/gbevel.h
engines/saga2/grabinfo.h
engines/saga2/keybored.cpp
engines/saga2/mapfeatr.h
engines/saga2/mouseimg.h
engines/saga2/oncall.h
engines/saga2/pool.cpp
engines/saga2/pool.h
engines/saga2/sensor.cpp
engines/saga2/sensor.h
engines/saga2/speldefs.h
engines/saga2/tileline.h
engines/saga2/tilemode.cpp
engines/saga2/tilemode.h
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index ec22487a6c..9b26cc06e9 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -47,6 +47,7 @@
#include "saga2/localize.h"
#include "saga2/intrface.h"
#include "saga2/hresmgr.h"
+#include "saga2/contain.h"
// Include files needed for SAGA script dispatch
#include "saga2/script.h"
diff --git a/engines/saga2/document.h b/engines/saga2/document.h
index 85f825a1b6..2813326d58 100644
--- a/engines/saga2/document.h
+++ b/engines/saga2/document.h
@@ -27,7 +27,6 @@
#ifndef SAGA2_DOCUMENT_H
#define SAGA2_DOCUMENT_H
-#include "saga2/floating.h"
#include "saga2/modal.h"
namespace Saga2 {
diff --git a/engines/saga2/gbevel.h b/engines/saga2/gbevel.h
index 93e8cfb2da..e0451e2947 100644
--- a/engines/saga2/gbevel.h
+++ b/engines/saga2/gbevel.h
@@ -27,9 +27,6 @@
#ifndef SAGA2_GBEVEL_H
#define SAGA2_GBEVEL_H
-#include "saga2/gdraw.h"
-#include "saga2/errors.h"
-
namespace Saga2 {
/* ===================================================================== *
diff --git a/engines/saga2/grabinfo.h b/engines/saga2/grabinfo.h
index 9bf46551e5..66cf0aa074 100644
--- a/engines/saga2/grabinfo.h
+++ b/engines/saga2/grabinfo.h
@@ -27,11 +27,6 @@
#ifndef SAGA2_GRABINFO_H
#define SAGA2_GRABINFO_H
-#include "saga2/objects.h"
-#include "saga2/contain.h"
-#include "saga2/uimetrcs.h"
-
-
namespace Saga2 {
/* ===================================================================== *
class GrabInfo
diff --git a/engines/saga2/keybored.cpp b/engines/saga2/keybored.cpp
index 24e91b4805..ae16dec486 100644
--- a/engines/saga2/keybored.cpp
+++ b/engines/saga2/keybored.cpp
@@ -30,6 +30,7 @@
#include "saga2/tilemode.h"
#include "saga2/calender.h"
+#include "saga2/objects.h"
#include "saga2/tile.h"
#include "saga2/setup.h"
#include "saga2/grabinfo.h"
diff --git a/engines/saga2/mapfeatr.h b/engines/saga2/mapfeatr.h
index 506ae7409b..94d5b973a1 100644
--- a/engines/saga2/mapfeatr.h
+++ b/engines/saga2/mapfeatr.h
@@ -27,17 +27,15 @@
#ifndef SAGA2_MAPFEATR_H
#define SAGA2_MAPFEATR_H
-#include "saga2/idtypes.h"
-#include "saga2/contain.h"
-#include "saga2/cmisc.h"
-#include "saga2/button.h"
-#include "saga2/intrface.h"
-#include "saga2/floating.h"
+#include "saga2/rect.h"
+#include "saga2/tcoords.h"
namespace Saga2 {
-#define MAX_MAP_FEATURE_NAME_LENGTH 32
+class gPort;
+class gPixelMap;
+#define MAX_MAP_FEATURE_NAME_LENGTH 32
/* ===================================================================== *
Types
diff --git a/engines/saga2/mouseimg.h b/engines/saga2/mouseimg.h
index b650cc008a..f9127d98e9 100644
--- a/engines/saga2/mouseimg.h
+++ b/engines/saga2/mouseimg.h
@@ -27,8 +27,6 @@
#ifndef SAGA2_MOUSEIMG_H
#define SAGA2_MOUSEIMG_H
-#include "saga2/gdraw.h"
-
namespace Saga2 {
// Set a new image for the mouse pointer
diff --git a/engines/saga2/oncall.h b/engines/saga2/oncall.h
index da02ca432e..e3863b54b7 100644
--- a/engines/saga2/oncall.h
+++ b/engines/saga2/oncall.h
@@ -28,8 +28,6 @@
#define SAGA2_ONCALL_H
#include "saga2/bitarray.h"
-#include "saga2/rmem.h"
-#include "saga2/localize.h"
namespace Saga2 {
diff --git a/engines/saga2/pool.cpp b/engines/saga2/pool.cpp
index e3a90fbdc0..f394118186 100644
--- a/engines/saga2/pool.cpp
+++ b/engines/saga2/pool.cpp
@@ -27,6 +27,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
+#include "saga2/dlist.h"
#include "saga2/pool.h"
namespace Saga2 {
diff --git a/engines/saga2/pool.h b/engines/saga2/pool.h
index 6c174f2cdc..fd48e86f69 100644
--- a/engines/saga2/pool.h
+++ b/engines/saga2/pool.h
@@ -27,8 +27,6 @@
#ifndef SAGA2_POOL_H
#define SAGA2_POOL_H
-#include "saga2/dlist.h"
-
namespace Saga2 {
/* ===================================================================== *
diff --git a/engines/saga2/sensor.cpp b/engines/saga2/sensor.cpp
index c261154b62..d7ee4e1015 100644
--- a/engines/saga2/sensor.cpp
+++ b/engines/saga2/sensor.cpp
@@ -27,6 +27,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
+#include "saga2/objects.h"
#include "saga2/sensor.h"
#include "saga2/pool.h"
#include "saga2/player.h"
diff --git a/engines/saga2/sensor.h b/engines/saga2/sensor.h
index fca3722d47..e4a0157233 100644
--- a/engines/saga2/sensor.h
+++ b/engines/saga2/sensor.h
@@ -27,8 +27,6 @@
#ifndef SAGA2_SENSOR_H
#define SAGA2_SENSOR_H
-#include "saga2/objects.h"
-
namespace Saga2 {
const uint32 nonActorSenseFlags = actorSeeInvis;
diff --git a/engines/saga2/speldefs.h b/engines/saga2/speldefs.h
index 5864363ee6..ae691728d7 100644
--- a/engines/saga2/speldefs.h
+++ b/engines/saga2/speldefs.h
@@ -32,13 +32,13 @@
namespace Saga2 {
-class StorageSpellTarget;
+struct StorageSpellTarget;
class SpellInstance;
-class StorageEffectron;
+struct StorageEffectron;
class SpellDisplayPrototype;
class EffectDisplayPrototype;
-class ResourceSpellItem;
-class StorageSpellInstance;
+struct ResourceSpellItem;
+struct StorageSpellInstance;
/* ===================================================================== *
Constants
diff --git a/engines/saga2/tileline.h b/engines/saga2/tileline.h
index 71fa158a67..41c3cf06a5 100644
--- a/engines/saga2/tileline.h
+++ b/engines/saga2/tileline.h
@@ -27,8 +27,6 @@
#ifndef SAGA2_TILELINE_H
#define SAGA2_TILELINE_H
-#include "saga2/tcoords.h"
-
namespace Saga2 {
#if DEBUG
diff --git a/engines/saga2/tilemode.cpp b/engines/saga2/tilemode.cpp
index 507707791b..6aeced3d76 100644
--- a/engines/saga2/tilemode.cpp
+++ b/engines/saga2/tilemode.cpp
@@ -30,6 +30,7 @@
#include "saga2/tilemode.h"
#include "saga2/tile.h"
#include "saga2/setup.h"
+#include "saga2/objects.h"
#include "saga2/grabinfo.h"
#include "saga2/mouseimg.h"
#include "saga2/motion.h"
@@ -51,6 +52,7 @@
#include "saga2/automap.h"
#include "saga2/images.h"
#include "saga2/config.h"
+#include "saga2/contain.h"
namespace Saga2 {
diff --git a/engines/saga2/tilemode.h b/engines/saga2/tilemode.h
index f5c10e1533..e4179adeda 100644
--- a/engines/saga2/tilemode.h
+++ b/engines/saga2/tilemode.h
@@ -27,11 +27,13 @@
#ifndef SAGA2_TILEMODE_H
#define SAGA2_TILEMODE_H
-#include "saga2/fta.h"
#include "saga2/idtypes.h"
namespace Saga2 {
+class SaveFileConstructor;
+class SaveFileReader;
+
// Function to enable/disable user interface keys
bool enableUIKeys(bool enabled);
Commit: 358c3f7f8479cec8ec54a570cf5f8b34a2495633
https://github.com/scummvm/scummvm/commit/358c3f7f8479cec8ec54a570cf5f8b34a2495633
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:56+02:00
Commit Message:
SAGA2: Cleanup path.cpp
Changed paths:
engines/saga2/path.cpp
diff --git a/engines/saga2/path.cpp b/engines/saga2/path.cpp
index 39ec43b386..b934a1867e 100644
--- a/engines/saga2/path.cpp
+++ b/engines/saga2/path.cpp
@@ -89,7 +89,7 @@ const int subMetaSize = 4,
-static TilePoint tDirTable[ 8 ] = {
+static TilePoint tDirTable[8] = {
TilePoint(4, 4, 0),
TilePoint(0, 4, 0),
TilePoint(-4, 4, 0),
@@ -100,7 +100,7 @@ static TilePoint tDirTable[ 8 ] = {
TilePoint(4, 0, 0)
};
-static TilePoint tDirTable2[ 8 ] = {
+static TilePoint tDirTable2[8] = {
TilePoint(1, 1, 0),
TilePoint(0, 1, 0),
TilePoint(-1, 1, 0),
@@ -111,7 +111,7 @@ static TilePoint tDirTable2[ 8 ] = {
TilePoint(1, 0, 0)
};
-static TilePoint tDirTable3[ 8 ] = {
+static TilePoint tDirTable3[8] = {
TilePoint(16, 16, 0),
TilePoint(0, 16, 0),
TilePoint(-16, 16, 0),
@@ -133,11 +133,11 @@ struct PathTileInfo {
int16 surfaceHeight;
};
-typedef PathTileInfo PathTilePosInfo[ maxPlatforms ];
+typedef PathTileInfo PathTilePosInfo[maxPlatforms];
typedef PathTilePosInfo PathTilePosArray
-[ searchDiameter + 4 ]
-[ searchDiameter + 4 ];
+[searchDiameter + 4]
+[searchDiameter + 4];
typedef uint8 PathSubMetaFlags
[((((searchDiameter
@@ -146,7 +146,7 @@ typedef uint8 PathSubMetaFlags
+ subMetaMask + 4))
>> subMetaShift)
+ 7)
- >> 3 ];
+ >> 3];
// This class manages an array containing terrain information, which
@@ -180,7 +180,7 @@ public:
PathTilePosInfo *tilePos(const TilePoint &pos) {
assert(pos.u >= origin.u && (pos.u - origin.u) < area.u);
assert(pos.v >= origin.v && (pos.v - origin.v) < area.v);
- return &array[(pos.u - origin.u) * area.v + pos.v - origin.v ];
+ return &array[(pos.u - origin.u) * area.v + pos.v - origin.v];
}
};
@@ -207,13 +207,13 @@ void PathTileRegion::init(
// clear all of the submetatile flags
memset(subMetaFlags, 0, (subMetaArea.u * subMetaArea.v + 7) >> 3);
- // NULL the tile pointers in the array
+ // nullptr the tile pointers in the array
int16 arraySize = area.u * area.v;
PathTilePosInfo *tiPtr = array;
for (; arraySize > 0; arraySize--, tiPtr++) {
PathTilePosInfo &ptpi = *tiPtr;
for (int i = 0; i < maxPlatforms; i++)
- ptpi[ i ].surfaceTile = NULL;
+ ptpi[i].surfaceTile = nullptr;
}
}
@@ -262,12 +262,12 @@ void PathTileRegion::fetchTileSection(const TilePoint &org,
for (v = 0; v < secSubMetaArea.v; v++, flagIndex++) {
// Check the submetatile flag in the bit array
- if (!(subMetaFlags[ flagIndex >> 3 ] & (1 << (flagIndex & 7)))) {
+ if (!(subMetaFlags[flagIndex >> 3] & (1 << (flagIndex & 7)))) {
// Load the submetatile and set its flag
fetchSubMeta(TilePoint(secSubMetaOrigin.u + u,
secSubMetaOrigin.v + v,
0));
- subMetaFlags[ flagIndex >> 3 ] |= 1 << (flagIndex & 7);
+ subMetaFlags[flagIndex >> 3] |= 1 << (flagIndex & 7);
}
}
}
@@ -276,7 +276,7 @@ void PathTileRegion::fetchTileSection(const TilePoint &org,
// This function will load a submeta tile in the array
void PathTileRegion::fetchSubMeta(const TilePoint &subMeta) {
- WorldMapData *map = &mapList[ mapNum ];
+ WorldMapData *map = &mapList[mapNum];
TilePoint mCoords;
MetaTile *mt;
@@ -345,13 +345,13 @@ void PathTileRegion::fetchSubMeta(const TilePoint &subMeta) {
TileRef *tr;
int16 height;
- if ((p = mt->fetchPlatform(mapNum, i)) == NULL)
+ if ((p = mt->fetchPlatform(mapNum, i)) == nullptr)
continue;
if (!(p->flags & plVisible)) continue;
for (u = tileReg.min.u; u < tileReg.max.u; u++) {
- PathTilePosInfo *arrRow = &array[(u + offset.u) * area.v ];
+ PathTilePosInfo *arrRow = &array[(u + offset.u) * area.v];
assert(u >= 0);
assert(u < platformWidth);
@@ -365,7 +365,7 @@ void PathTileRegion::fetchSubMeta(const TilePoint &subMeta) {
if (!(tpFlags & (1 << flagIndex))) {
tpFlags |= (1 << flagIndex);
- tr = &p->tiles[ u ][ v ];
+ tr = &p->tiles[u][v];
height = tr->tileHeight << 3;
if (tr->flags & trTileTAG) {
@@ -412,34 +412,34 @@ void PathTileRegion::fetchSubMeta(const TilePoint &subMeta) {
stateData = &(map->activeItemData)[
groupItem->group.grDataOffset
- + state * groupItem->group.animArea ];
+ + state * groupItem->group.animArea];
for (tempU = subMetaTag.min.u; tempU < subMetaTag.max.u; tempU++) {
- TileRef *rowData = &stateData[(tempU - tagU) * groupItem->group.vSize ];
- PathTilePosInfo *tempArrRow = &array[(tempU + offset.u) * area.v ];
+ TileRef *rowData = &stateData[(tempU - tagU) * groupItem->group.vSize];
+ PathTilePosInfo *tempArrRow = &array[(tempU + offset.u) * area.v];
for (tempV = subMetaTag.min.v; tempV < subMetaTag.max.v; tempV++) {
flagIndex = ((tempU & subMetaMask) << subMetaShift) + (tempV & subMetaMask);
tpFlags |= (1 << flagIndex);
- if (instanceItem) tr = &rowData[ tempV - tagV ];
+ if (instanceItem) tr = &rowData[tempV - tagV];
#if DEBUG
else {
static TileRef dummyRef = { 1, 0, 0 };
tr = &dummyRef;
}
#endif
- tempArrRow[ tempV + offset.v ][ i ].surfaceTile =
+ tempArrRow[tempV + offset.v][i].surfaceTile =
TileInfo::tileAddress(tr->tile);
- tempArrRow[ tempV + offset.v ][ i ].surfaceHeight =
+ tempArrRow[tempV + offset.v][i].surfaceHeight =
height + (tr->tileHeight << 3);
}
}
} else {
- arrRow[ v + offset.v ][ i ].surfaceTile =
+ arrRow[v + offset.v][i].surfaceTile =
TileInfo::tileAddress(tr->tile);
- arrRow[ v + offset.v ][ i ].surfaceHeight =
+ arrRow[v + offset.v][i].surfaceHeight =
height;
}
}
@@ -479,13 +479,13 @@ private:
uint16 mask; // Mask indicating which cells in chunk are
// allocated
// The cell array
- PathCell array[ chunkTileDiameter ][ chunkTileDiameter ];
+ PathCell array[chunkTileDiameter][chunkTileDiameter];
PathArrayChunk(void) : mask(0) {}
};
// Master array of chunk pointers
- PathArrayChunk *array[ maxPlatforms ][ regionChunkDiameter ][ regionChunkDiameter ];
+ PathArrayChunk *array[maxPlatforms][regionChunkDiameter][regionChunkDiameter];
public:
// Exception class
@@ -498,13 +498,13 @@ public:
~PathArray(void);
// Make a new cell or access an existing cell. If the specified
- // cell already exists *newCell will be set to FALSE, else it will
- // be TRUE. If it fails to allocate a new cell it will throw
+ // cell already exists *newCell will be set to false, else it will
+ // be true. If it fails to allocate a new cell it will throw
// a CellAllocationFailure.
PathCell *makeCell(int plat, int uCoord, int vCoord, bool *newCell);
// Get a pointer to an existing cell. If the specified cell has
- // not been created, it will return NULL.
+ // not been created, it will return nullptr.
PathCell *getCell(int plat, int uCoord, int vCoord);
// Delete an existing cell
@@ -521,7 +521,7 @@ PathArray::PathArray(void) {
for (plat = 0; plat < maxPlatforms; plat++) {
for (chunkU = 0; chunkU < regionChunkDiameter; chunkU++) {
for (chunkV = 0; chunkV < regionChunkDiameter; chunkV++)
- array[ plat ][ chunkU ][ chunkV ] = NULL;
+ array[plat][chunkU][chunkV] = nullptr;
}
}
}
@@ -533,25 +533,24 @@ PathArray::~PathArray(void) {
// Make a new cell or access an existing cell. If the specified
-// cell already exists *newCell will be set to FALSE, else it will
-// be TRUE. If it fails to allocate a new cell it will throw
+// cell already exists *newCell will be set to false, else it will
+// be true. If it fails to allocate a new cell it will throw
// a CellAllocationFailure.
PathCell *PathArray::makeCell(int plat, int uCoord, int vCoord, bool *newCell) {
assert(plat >= 0 && plat < maxPlatforms);
assert(uCoord >= 0 && uCoord < searchDiameter);
assert(vCoord >= 0 && vCoord < searchDiameter);
- assert(newCell != NULL);
+ assert(newCell != nullptr);
// Compute the chunk coords
int chunkUCoord = uCoord >> 2,
chunkVCoord = vCoord >> 2;
// Get a pointer to the chunk pointer in the array
- PathArrayChunk **chunkPtrPtr = &array[ plat ][ chunkUCoord ][ chunkVCoord ];
+ PathArrayChunk **chunkPtrPtr = &array[plat][chunkUCoord][chunkVCoord];
// Get existing chunk or allocate a new one
- if (*chunkPtrPtr != NULL || (*chunkPtrPtr = new (RNewPtr(sizeof(PathArrayChunk),
- NULL, "Path array chunk")) PathArrayChunk) != NULL) {
+ if (*chunkPtrPtr != nullptr || (*chunkPtrPtr = new PathArrayChunk) != nullptr) {
PathArrayChunk *chunkPtr = *chunkPtrPtr;
uint16 chunkCellMask;
@@ -568,7 +567,7 @@ PathCell *PathArray::makeCell(int plat, int uCoord, int vCoord, bool *newCell) {
// Mark the cell as allocated
chunkPtr->mask |= chunkCellMask;
- return &chunkPtr->array[ uCoord ][ vCoord ];
+ return &chunkPtr->array[uCoord][vCoord];
} else {
// Failed to allocate cell so throw exception
error("Cell Allocation failure");
@@ -577,13 +576,13 @@ PathCell *PathArray::makeCell(int plat, int uCoord, int vCoord, bool *newCell) {
// Visual C++ 4.0 requires this return because it appearently
// does not recognize the 'throw' statement as a return
// structure
- return NULL;
+ return nullptr;
#endif
}
}
// Get a pointer to an existing cell. If the specified cell has
-// not been created, it will return NULL.
+// not been created, it will return nullptr.
PathCell *PathArray::getCell(int plat, int uCoord, int vCoord) {
assert(plat >= 0 && plat < maxPlatforms);
assert(uCoord >= 0 && uCoord < searchDiameter);
@@ -594,9 +593,9 @@ PathCell *PathArray::getCell(int plat, int uCoord, int vCoord) {
chunkVCoord = vCoord >> 2;
uint16 chunkCellMask;
- PathArrayChunk *chunkPtr = array[ plat ][ chunkUCoord ][ chunkVCoord ];
+ PathArrayChunk *chunkPtr = array[plat][chunkUCoord][chunkVCoord];
- if (chunkPtr == NULL) return NULL;
+ if (chunkPtr == nullptr) return nullptr;
// Compute the coordinates of the cell relative to the chunk
uCoord &= chunkTileDiameter - 1;
@@ -606,9 +605,10 @@ PathCell *PathArray::getCell(int plat, int uCoord, int vCoord) {
chunkCellMask = 1 << ((uCoord << 2) | vCoord);
// Determine if cell has been allocated
- if ((chunkPtr->mask & chunkCellMask) == 0) return NULL;
+ if ((chunkPtr->mask & chunkCellMask) == 0)
+ return nullptr;
- return &chunkPtr->array[ uCoord ][ vCoord ];
+ return &chunkPtr->array[uCoord][vCoord];
}
void PathArray::deleteCell(int plat, int uCoord, int vCoord) {
@@ -621,9 +621,10 @@ void PathArray::deleteCell(int plat, int uCoord, int vCoord) {
chunkVCoord = vCoord >> 2;
uint16 chunkCellMask;
- PathArrayChunk *chunkPtr = array[ plat ][ chunkUCoord ][ chunkVCoord ];
+ PathArrayChunk *chunkPtr = array[plat][chunkUCoord][chunkVCoord];
- if (chunkPtr == NULL) return;
+ if (chunkPtr == nullptr)
+ return;
// Compute the coordinates of the cell relative to the chunk
uCoord &= chunkTileDiameter - 1;
@@ -645,13 +646,11 @@ void PathArray::reset(void) {
for (chunkV = 0; chunkV < regionChunkDiameter; chunkV++) {
PathArrayChunk **chunkPtrPtr;
- chunkPtrPtr = &array[ plat ][ chunkU ][ chunkV ];
+ chunkPtrPtr = &array[plat][chunkU][chunkV];
- if (*chunkPtrPtr != NULL) {
- // Call destructor
- (*chunkPtrPtr)->~PathArrayChunk();
- RDisposePtr(*chunkPtrPtr);
- *chunkPtrPtr = NULL;
+ if (*chunkPtrPtr != nullptr) {
+ delete *chunkPtrPtr;
+ *chunkPtrPtr = nullptr;
}
}
}
@@ -682,7 +681,7 @@ struct QueueItem {
struct PointMask {
TilePoint size;
TilePoint offset;
- uint16 mask[ 16 ];
+ uint16 mask[16];
};
@@ -691,11 +690,11 @@ struct PointMask {
class DirMask {
friend class DirMaskGroup;
- PointMask pathPt[ 4 ];
+ PointMask pathPt[4];
public:
PointMask &operator[](int16 index) {
- return pathPt[ index ];
+ return pathPt[index];
}
};
@@ -705,13 +704,13 @@ class DirMaskGroup {
friend class MaskComputer;
uint8 crossSection;
- DirMask dMask[ 8 ];
+ DirMask dMask[8];
void computeMask(uint8 objSection);
public:
DirMask &operator[](int16 index) {
- return dMask[ index ];
+ return dMask[index];
}
};
@@ -720,15 +719,12 @@ public:
class MaskComputer {
private:
- DirMaskGroup array[ 8 ],
- *ptrArray[ 8 ];
+ DirMaskGroup array[8],
+ *ptrArray[8];
int16 arraySize;
public:
MaskComputer(void) : arraySize(0) {}
- void *operator new (size_t, void *p) {
- return p;
- }
DirMaskGroup *computeMask(uint8 objSection);
};
@@ -794,12 +790,12 @@ void DirMaskGroup::computeMask(uint8 objSection) {
int u,
v;
TileRegion ptMaskArea;
- uint16 tempMask[ 16 ];
- PointMask *ptMask = &dMask[ dir ].pathPt[ ptNum ];
+ uint16 tempMask[16];
+ PointMask *ptMask = &dMask[dir].pathPt[ptNum];
// Compute the point mask area
- ptMaskArea.min = baseMaskArea.min + tDirTable2[ dir ] * (ptNum + 1);
- ptMaskArea.max = baseMaskArea.max + tDirTable2[ dir ] * (ptNum + 1);
+ ptMaskArea.min = baseMaskArea.min + tDirTable2[dir] * (ptNum + 1);
+ ptMaskArea.max = baseMaskArea.max + tDirTable2[dir] * (ptNum + 1);
ptMask->offset.u = ptMaskArea.min.u >> tileSubShift;
ptMask->offset.v = ptMaskArea.min.v >> tileSubShift;
@@ -816,41 +812,41 @@ void DirMaskGroup::computeMask(uint8 objSection) {
uint16 vMask = makeMask16(ptMaskArea.min.v, ptMaskArea.max.v);
for (u = ptMaskArea.min.u; u < ptMaskArea.max.u; u++)
- tempMask[ u ] = vMask;
+ tempMask[u] = vMask;
for (u = 0; u < ptMask->size.u; u++) {
- uint16 *srcMask = &tempMask[ u << 2 ];
- uint16 *destMask = &ptMask->mask[ u << 2 ];
+ uint16 *srcMask = &tempMask[u << 2];
+ uint16 *destMask = &ptMask->mask[u << 2];
for (v = 0; v < ptMask->size.v; v++) {
switch (v) {
case 0:
- destMask[ 0 ] = (srcMask[ 0 ] & 0x000f) |
- (srcMask[ 1 ] & 0x000f) << 4 |
- (srcMask[ 2 ] & 0x000f) << 8 |
- (srcMask[ 3 ] & 0x000f) << 12;
+ destMask[0] = (srcMask[0] & 0x000f) |
+ (srcMask[1] & 0x000f) << 4 |
+ (srcMask[2] & 0x000f) << 8 |
+ (srcMask[3] & 0x000f) << 12;
break;
case 1:
- destMask[ 1 ] = (srcMask[ 0 ] & 0x00f0) >> 4 |
- (srcMask[ 1 ] & 0x00f0) |
- (srcMask[ 2 ] & 0x00f0) << 4 |
- (srcMask[ 3 ] & 0x00f0) << 8;
+ destMask[1] = (srcMask[0] & 0x00f0) >> 4 |
+ (srcMask[1] & 0x00f0) |
+ (srcMask[2] & 0x00f0) << 4 |
+ (srcMask[3] & 0x00f0) << 8;
break;
case 2:
- destMask[ 2 ] = (srcMask[ 0 ] & 0x0f00) >> 8 |
- (srcMask[ 1 ] & 0x0f00) >> 4 |
- (srcMask[ 2 ] & 0x0f00) |
- (srcMask[ 3 ] & 0x0f00) << 4;
+ destMask[2] = (srcMask[0] & 0x0f00) >> 8 |
+ (srcMask[1] & 0x0f00) >> 4 |
+ (srcMask[2] & 0x0f00) |
+ (srcMask[3] & 0x0f00) << 4;
break;
case 3:
- destMask[ 3 ] = (srcMask[ 0 ] & 0xf000) >> 12 |
- (srcMask[ 1 ] & 0xf000) >> 8 |
- (srcMask[ 2 ] & 0xf000) >> 4 |
- (srcMask[ 3 ] & 0xf000);
+ destMask[3] = (srcMask[0] & 0xf000) >> 12 |
+ (srcMask[1] & 0xf000) >> 8 |
+ (srcMask[2] & 0xf000) >> 4 |
+ (srcMask[3] & 0xf000);
}
}
}
@@ -864,14 +860,14 @@ DirMaskGroup *MaskComputer::computeMask(uint8 crossSection) {
// Check if this mask group has already been computed
for (i = 0; i < arraySize; i++) {
- maskGroup = ptrArray[ i ];
+ maskGroup = ptrArray[i];
if (maskGroup->crossSection == crossSection) {
// This mask group has already been computed
if (i > 0) {
// Move the reference to this mask group up one position
- ptrArray[ i ] = ptrArray[ i - 1 ];
- ptrArray[ i - 1 ] = maskGroup;
+ ptrArray[i] = ptrArray[i - 1];
+ ptrArray[i - 1] = maskGroup;
}
return maskGroup;
@@ -880,11 +876,11 @@ DirMaskGroup *MaskComputer::computeMask(uint8 crossSection) {
if (arraySize < elementsof(array)) {
// Allocate a new place for this mask group
- maskGroup = ptrArray[ arraySize ] = &array[ arraySize ];
+ maskGroup = ptrArray[arraySize] = &array[arraySize];
arraySize++;
} else
// Discard last referenced mask group in array
- maskGroup = ptrArray[ elementsof(array) - 1 ];
+ maskGroup = ptrArray[elementsof(array) - 1];
// Compute the new group of masks
maskGroup->computeMask(crossSection);
@@ -904,10 +900,10 @@ uint32 tileTerrain(
int32 height, tileMinZ, tileMaxZ;
TileInfo *ti;
- ti = (*tilePos)[ i ].surfaceTile;
+ ti = (*tilePos)[i].surfaceTile;
if (ti) {
- height = (*tilePos)[ i ]. surfaceHeight;
+ height = (*tilePos)[i]. surfaceHeight;
TileAttrs &attrs = ti->attrs;
tileMinZ = tileMaxZ = height;
int32 combinedMask = ti->combinedTerrainMask();
@@ -983,15 +979,15 @@ int16 tileSlopeHeight(
highestSupportHeight = -100;
lowestSupportHeight = 0x7FFF;
- highestTileFlag = FALSE;
- lowestTileFlag = FALSE;
+ highestTileFlag = false;
+ lowestTileFlag = false;
int objProtHt = obj->proto()->height;
// Search each platform until we find a tile which is under
// the character.
for (int i = 0; i < maxPlatforms; i++) {
- PathTileInfo *pti = ((PathTileInfo *)(&tilePosInfo)) + i; // &tilePosInfo[ i ];
+ PathTileInfo *pti = ((PathTileInfo *)(&tilePosInfo)) + i; // &tilePosInfo[i];
TileInfo *ti = pti->surfaceTile;
if (ti) {
@@ -1027,7 +1023,7 @@ int16 tileSlopeHeight(
&& supportHeight >= highestSupportHeight
&& (ti->combinedTerrainMask() &
terrainSurface | terrainRaised)) {
- highestTileFlag = TRUE;
+ highestTileFlag = true;
highestTile = *pti;
highestSupportHeight = supportHeight;
highestSupportPlatform = i;
@@ -1035,7 +1031,7 @@ int16 tileSlopeHeight(
supportHeight <= lowestSupportHeight &&
(ti->combinedTerrainMask() &
terrainSurface | terrainRaised)) {
- lowestTileFlag = TRUE;
+ lowestTileFlag = true;
lowestTile = *pti;
lowestSupportHeight = supportHeight;
lowestSupportPlatform = i;
@@ -1055,7 +1051,7 @@ int16 tileSlopeHeight(
}
if (ptiResult) {
- ptiResult->surfaceTile = NULL;
+ ptiResult->surfaceTile = nullptr;
ptiResult->surfaceHeight = 0;
}
if (platformResult) *platformResult = 0;
@@ -1101,7 +1097,7 @@ protected:
// These static members are initialized when the path request
// becomes the current active request being serviced.
- static TilePoint path[ 16 ];
+ static TilePoint path[16];
static int16 pathLength;
static TilePoint baseCoords,
@@ -1289,13 +1285,13 @@ public:
const int numPathRequests = 32; // up to 32 messages allowed
-typedef uint8 PathRequestPlaceHolder[ sizeof(WanderPathRequest) ];
+typedef uint8 PathRequestPlaceHolder[sizeof(WanderPathRequest)];
typedef RPool< PathRequestPlaceHolder, numPathRequests > PathRequestPool;
PathRequestPool pathRequestPool;
DList pathQueue;
-PathRequest *currentRequest = NULL;
+PathRequest *currentRequest = nullptr;
static PathTilePosArray *pathTileArray;
static PathSubMetaFlags subMetaFlags;
@@ -1305,17 +1301,17 @@ static MaskComputer *maskComp;
static PriorityQueue<QueueItem, 192> queue;
static PathArray *cellArray;
-static TileRegion objectVolumeArray[ 128 ];
+static TileRegion objectVolumeArray[128];
struct VolumeLookupNode {
VolumeLookupNode *next;
TileRegion *volume;
};
-static VolumeLookupNode volumeLookupNodePool[ 256 ];
-static VolumeLookupNode *volumeLookupTable[ searchDiameter ][ searchDiameter ];
+static VolumeLookupNode volumeLookupNodePool[256];
+static VolumeLookupNode *volumeLookupTable[searchDiameter][searchDiameter];
-TilePoint PathRequest::path[ 16 ];
+TilePoint PathRequest::path[16];
int16 PathRequest::pathLength;
TilePoint PathRequest::baseCoords,
@@ -1354,7 +1350,7 @@ static void push(
int cost,
int direction,
int8 platformDelta) {
- assert(cellArray != NULL);
+ assert(cellArray != nullptr);
PathCell *cellPtr;
bool newCell;
@@ -1367,7 +1363,7 @@ static void push(
cellPtr = cellArray->makeCell(platform, tp.u, tp.v, &newCell);
- assert(cellPtr != NULL);
+ assert(cellPtr != nullptr);
// If the cell is already visited, only
// update it if it was less cost to get here.
@@ -1397,25 +1393,23 @@ static void push(
* ===================================================================== */
void initPathFinder(void) {
- pathTileArray = (PathTilePosArray *)RNewPtr(sizeof * pathTileArray, NULL, "path tile array");
- maskComp = new (RNewPtr(sizeof * maskComp, NULL, "path mask comp")) MaskComputer;
- cellArray = new (RNewPtr(sizeof(PathArray), NULL, "path cell array")) PathArray;
+ pathTileArray = (PathTilePosArray *)malloc( sizeof *pathTileArray);
+ maskComp = new MaskComputer;
+ cellArray = new PathArray;
}
void cleanupPathFinder(void) {
if (pathTileArray) {
- RDisposePtr(pathTileArray);
- pathTileArray = NULL;
+ free(pathTileArray);
+ pathTileArray = nullptr;
}
if (maskComp) {
- RDisposePtr(maskComp);
- maskComp = NULL;
+ delete maskComp;
+ maskComp = nullptr;
}
- if (cellArray != NULL) {
- // Call destructor
- cellArray->~PathArray();
- RDisposePtr(cellArray);
- cellArray = NULL;
+ if (cellArray != nullptr) {
+ delete cellArray;
+ cellArray = nullptr;
}
}
@@ -1489,7 +1483,7 @@ void PathRequest::initialize(void) {
for (uCoord = 0; uCoord < searchDiameter; uCoord++) {
for (vCoord = 0; vCoord < searchDiameter; vCoord++)
- volumeLookupTable[ uCoord ][ vCoord ] = NULL;
+ volumeLookupTable[uCoord][vCoord] = nullptr;
}
RegionalObjectIterator iter(
@@ -1504,11 +1498,11 @@ void PathRequest::initialize(void) {
GameObject *obj;
for (iter.first(&obj);
- obj != NULL;
+ obj != nullptr;
iter.next(&obj)) {
TilePoint objLoc = obj->getLocation() - baseCoords;
ProtoObj *objProto = obj->proto();
- TileRegion *objRegion = &objectVolumeArray[ objectVolumes ];
+ TileRegion *objRegion = &objectVolumeArray[objectVolumes];
uint8 poCross = objProto->crossSection;
// Obviously, we shouldn't block ourselves.
@@ -1553,8 +1547,8 @@ void PathRequest::initialize(void) {
VolumeLookupNode **tablePtrPtr;
// Get the next lookup node
- node = &volumeLookupNodePool[ nextAvailableLookupNode++ ];
- tablePtrPtr = &volumeLookupTable[ curTileRegU ][ curTileRegV ];
+ node = &volumeLookupNodePool[nextAvailableLookupNode++];
+ tablePtrPtr = &volumeLookupTable[curTileRegU][curTileRegV];
// Link into lookup table
node->volume = objRegion;
@@ -1599,7 +1593,7 @@ big_break:
quantizedCoords.z = tileSlopeHeight(
quantizedCoords,
actor,
- NULL,
+ nullptr,
&platform);
// If the height difference is too great skip this tile
@@ -1637,14 +1631,14 @@ void PathRequest::finish(void) {
TilePoint *res;
PathCell *cell;
- static TilePoint tempResult[ 32 ];
+ static TilePoint tempResult[32];
if (bestLoc != Nowhere) {
cell = cellArray->getCell(bestPlatform, bestLoc.u, bestLoc.v);
- assert(cell != NULL);
+ assert(cell != nullptr);
if (cell->direction != dirInvalid) {
- res = &tempResult[ elementsof(tempResult) ];
+ res = &tempResult[elementsof(tempResult)];
prevDir = dirInvalid;
@@ -1652,7 +1646,7 @@ void PathRequest::finish(void) {
int16 reverseDir;
cell = cellArray->getCell(bestPlatform, bestLoc.u, bestLoc.v);
- assert(cell != NULL);
+ assert(cell != nullptr);
if (cell->direction != dirInvalid) {
if (cell->direction != prevDir
@@ -1675,7 +1669,7 @@ void PathRequest::finish(void) {
}
reverseDir = (cell->direction + 4) & 0x07;
- bestLoc += tDirTable2[ reverseDir ];
+ bestLoc += tDirTable2[reverseDir];
assert(bestLoc.u >= 0 && bestLoc.u < searchDiameter);
assert(bestLoc.v >= 0 && bestLoc.v < searchDiameter);
bestPlatform -= cell->platformDelta;
@@ -1686,7 +1680,7 @@ void PathRequest::finish(void) {
if (resultSteps) {
while (stepCount < elementsof(path)
- && res < &tempResult[ elementsof(tempResult) ]) {
+ && res < &tempResult[elementsof(tempResult)]) {
*resultSteps++ = *res++;
stepCount++;
}
@@ -1699,25 +1693,25 @@ void PathRequest::finish(void) {
pathLength = stepCount;
if (mTask->pathFindTask == this && mTask->isWalk()) {
- memcpy(mTask->pathList, path, pathLength * sizeof path[ 0 ]);
+ memcpy(mTask->pathList, path, pathLength * sizeof path[0]);
mTask->pathCount = pathLength;
mTask->pathIndex = 0;
mTask->flags |= MotionTask::reset;
if (flags & completed) mTask->flags |= MotionTask::finalPath;
- mTask->pathFindTask = NULL;
+ mTask->pathFindTask = nullptr;
}
}
void PathRequest::abort(void) {
if (mTask->pathFindTask == this)
- mTask->pathFindTask = NULL;
+ mTask->pathFindTask = nullptr;
}
static uint32 severePathFinderOverruns = 0;
PathResult PathRequest::findPath(void) {
- assert(cellArray != NULL);
+ assert(cellArray != nullptr);
static const uint8 costTable[] =
{ 4, 10, 12, 16, 12, 10, 4, 0, 4, 10, 12, 16, 12, 10, 4, 0 };
@@ -1732,7 +1726,7 @@ PathResult PathRequest::findPath(void) {
lastTick = gameTime;
while (queue.remove(qi)) {
- assert(cellArray->getCell(qi.platform, qi.u, qi.v) != NULL);
+ assert(cellArray->getCell(qi.platform, qi.u, qi.v) != nullptr);
assert(qi.u >= 1 && qi.u < searchDiameter - 1);
assert(qi.v >= 1 && qi.v < searchDiameter - 1);
@@ -1770,7 +1764,7 @@ PathResult PathRequest::findPath(void) {
} else {
// Check only the forward directions
i = dir = (qi.direction + 6) & 0x7;
- tDir = &tDirTable2[ dir ];
+ tDir = &tDirTable2[dir];
endDir = i + 5;
switch (qi.direction) {
@@ -1847,8 +1841,8 @@ PathResult PathRequest::findPath(void) {
for (;
i < endDir;
- tDir = &tDirTable2[(dir = (++i & 0x7)) ]) {
- if (!validMove(centerPt + tDirTable3[ dir ]))
+ tDir = &tDirTable2[(dir = (++i & 0x7))]) {
+ if (!validMove(centerPt + tDirTable3[dir]))
continue;
PathTileInfo pti;
@@ -1856,13 +1850,13 @@ PathResult PathRequest::findPath(void) {
uint8 testPlatform;
uint32 terrain = 0;
int32 cost;
- DirMask &dMask = (*dirMasks)[ dir ];
+ DirMask &dMask = (*dirMasks)[dir];
int16 prevZ = centerPt.z;
for (int d = 0; d < 4; d++) {
int u, v;
uint8 maskU, maskV;
- PointMask &ptMask = dMask[ d ];
+ PointMask &ptMask = dMask[d];
TileRegion maskReg,
actorVolume;
@@ -1871,8 +1865,8 @@ PathResult PathRequest::findPath(void) {
maskReg.min.v = centerTileCoords.v + ptMask.offset.v;
maskReg.max.v = maskReg.min.v + ptMask.size.v;
- testPt.u += tDirTable[ dir ].u;
- testPt.v += tDirTable[ dir ].v;
+ testPt.u += tDirTable[dir].u;
+ testPt.v += tDirTable[dir].v;
testPt.z = tileSlopeHeight(
tileArray,
testPt,
@@ -1906,7 +1900,7 @@ PathResult PathRequest::findPath(void) {
PathTilePosInfo *arrRow =
&tileArray.array[
(u - tileArray.origin.u)
- * tileArray.area.v ];
+ * tileArray.area.v];
for (v = maskReg.min.v, maskV = 0;
v < maskReg.max.v;
@@ -1916,9 +1910,9 @@ PathResult PathRequest::findPath(void) {
// Lookup any potentially intersecting object
// volumes
for (node = volumeLookupTable
- [ u - baseTileCoords.u ]
- [ v - baseTileCoords.v ];
- node != NULL;
+ [u - baseTileCoords.u]
+ [v - baseTileCoords.v];
+ node != nullptr;
node = node->next) {
TileRegion *trv = node->volume;
// Check for volume intersection
@@ -1933,8 +1927,8 @@ PathResult PathRequest::findPath(void) {
}
terrain |= tileTerrain(
- &arrRow[ v - tileArray.origin.v ],
- ptMask.mask[(maskU << 2) | maskV ],
+ &arrRow[v - tileArray.origin.v],
+ ptMask.mask[(maskU << 2) | maskV],
testPt.z,
testPt.z + aph);
}
@@ -1958,7 +1952,7 @@ PathResult PathRequest::findPath(void) {
// We must treat stairs as a special case
- if (pti.surfaceTile != NULL
+ if (pti.surfaceTile != nullptr
&& (pti.surfaceTile->combinedTerrainMask() & terrainStair)) {
uint8 *cornerHeight = pti.surfaceTile->attrs.cornerHeight;
uint8 stairDir;
@@ -1967,18 +1961,18 @@ PathResult PathRequest::findPath(void) {
// Determine the direction and upper altitude of the
// stairs
- if (*((uint16 *)&cornerHeight[ 0 ]) == 0) {
+ if (*((uint16 *)&cornerHeight[0]) == 0) {
stairDir = 1;
- stairHeight = pti.surfaceHeight + cornerHeight[ 2 ];
- } else if (*((uint16 *)&cornerHeight[ 1 ]) == 0) {
+ stairHeight = pti.surfaceHeight + cornerHeight[2];
+ } else if (*((uint16 *)&cornerHeight[1]) == 0) {
stairDir = 3;
- stairHeight = pti.surfaceHeight + cornerHeight[ 3 ];
- } else if (*((uint16 *)&cornerHeight[ 2 ]) == 0) {
+ stairHeight = pti.surfaceHeight + cornerHeight[3];
+ } else if (*((uint16 *)&cornerHeight[2]) == 0) {
stairDir = 5;
- stairHeight = pti.surfaceHeight + cornerHeight[ 0 ];
- } else if (cornerHeight[ 0 ] == 0 && cornerHeight[ 3 ] == 0) {
+ stairHeight = pti.surfaceHeight + cornerHeight[0];
+ } else if (cornerHeight[0] == 0 && cornerHeight[3] == 0) {
stairDir = 7;
- stairHeight = pti.surfaceHeight + cornerHeight[ 1 ];
+ stairHeight = pti.surfaceHeight + cornerHeight[1];
} else continue;
// Do not go onto the stair at a right angle
@@ -2023,7 +2017,7 @@ PathResult PathRequest::findPath(void) {
+ dir
- (qi.direction != dirInvalid
? qi.direction
- : actor->currentFacing) ];
+ : actor->currentFacing)];
#if VISUAL1
TPLine(centerPt, testPt);
@@ -2049,7 +2043,7 @@ PathResult PathRequest::findPath(void) {
cost,
dir,
testPlatform - centerPlatform);
- assert(cellArray->getCell(centerPlatform, qi.u, qi.v) != NULL);
+ assert(cellArray->getCell(centerPlatform, qi.u, qi.v) != nullptr);
big_continue:
;
@@ -2095,7 +2089,7 @@ DestinationPathRequest::DestinationPathRequest(Actor *a, int16 howSmart) :
mTask->finalTarget.z = tileSlopeHeight(
mTask->finalTarget,
a,
- NULL,
+ nullptr,
&destPlatform);
destination = mTask->finalTarget;
@@ -2149,16 +2143,16 @@ bool DestinationPathRequest::setCenter(
if (dist == 0 && zDist <= maxStepHeight) {
flags |= PathRequest::completed;
- // Return TRUE to indicate that the path finding is done.
- return TRUE;
+ // Return true to indicate that the path finding is done.
+ return true;
}
}
- return FALSE;
+ return false;
}
bool DestinationPathRequest::validMove(const TilePoint &) {
- return TRUE;
+ return true;
}
// Evaluate the cost of moving on the specified stairs in the specified
@@ -2219,13 +2213,13 @@ WanderPathRequest::WanderPathRequest(
int16 howSmart) :
PathRequest(a, howSmart) {
if (mTask->flags & MotionTask::tethered) {
- tethered = TRUE;
+ tethered = true;
tetherMinU = mTask->tetherMinU;
tetherMinV = mTask->tetherMinV;
tetherMaxU = mTask->tetherMaxU;
tetherMaxV = mTask->tetherMaxV;
} else
- tethered = FALSE;
+ tethered = false;
}
// Initialize the static data members
@@ -2267,7 +2261,7 @@ bool WanderPathRequest::setCenter(
bestDist = centerCost;
}
- return FALSE;
+ return false;
}
bool WanderPathRequest::validMove(const TilePoint &testPt) {
@@ -2317,15 +2311,15 @@ void deletePathRequest(void *p) {
}
void runPathFinder(void) {
- if (currentRequest == NULL) {
+ if (currentRequest == nullptr) {
currentRequest = (PathRequest *)pathQueue.first();
- if (currentRequest != NULL) {
+ if (currentRequest != nullptr) {
currentRequest->remove();
currentRequest->initialize();
}
}
- if (currentRequest != NULL) {
+ if (currentRequest != nullptr) {
PathResult result;
result = currentRequest->findPath();
@@ -2337,7 +2331,7 @@ void runPathFinder(void) {
currentRequest->abort();
delete currentRequest;
- currentRequest = NULL;
+ currentRequest = nullptr;
cellArray->reset();
}
@@ -2355,7 +2349,7 @@ void addPathRequestToQueue(PathRequest *pr) {
PathRequest *prInQueue;
for (prInQueue = (PathRequest *)pathQueue.first();
- prInQueue != NULL;
+ prInQueue != nullptr;
prInQueue = (PathRequest *)prInQueue->next()) {
Actor *prActor = prInQueue->actor;
@@ -2363,7 +2357,7 @@ void addPathRequestToQueue(PathRequest *pr) {
break;
}
- if (prInQueue != NULL)
+ if (prInQueue != nullptr)
pathQueue.insert(*pr, *prInQueue);
else
pathQueue.addTail(*pr);
@@ -2376,7 +2370,7 @@ void RequestPath(MotionTask *mTask, int16 smartness) {
DestinationPathRequest *pr;
Actor *a = (Actor *)mTask->object;
- if ((pr = new DestinationPathRequest(a, smartness)) != NULL)
+ if ((pr = new DestinationPathRequest(a, smartness)) != nullptr)
addPathRequestToQueue(pr);
}
@@ -2384,7 +2378,7 @@ void RequestWanderPath(MotionTask *mTask, int16 smartness) {
WanderPathRequest *pr;
Actor *a = (Actor *)mTask->object;
- if ((pr = new WanderPathRequest(a, smartness)) != NULL)
+ if ((pr = new WanderPathRequest(a, smartness)) != nullptr)
addPathRequestToQueue(pr);
}
@@ -2399,7 +2393,7 @@ void abortPathFind(MotionTask *mTask) {
delete pr;
}
- mTask->pathFindTask = NULL;
+ mTask->pathFindTask = nullptr;
}
}
@@ -2427,7 +2421,7 @@ enum cellStates {
cellVisited = (1 << 1),
};
-typedef uint8 SimpleCellArray[ searchDiameter ][ searchDiameter ];
+typedef uint8 SimpleCellArray[searchDiameter][searchDiameter];
static PriorityQueue<QueueItem, 128> squeue;
@@ -2480,7 +2474,7 @@ negUMask = 0x0666,
posVMask = 0x0770,
negVMask = 0x0ee0;
-uint16 sTerrainMasks[ 8 ] = {
+uint16 sTerrainMasks[8] = {
posUMask, negUMask, // dirUpLeft (U+)
negVMask, posVMask, // dirDownLeft (V-)
negUMask, posUMask, // dirDownRight (U-)
@@ -2492,7 +2486,7 @@ TilePoint selectNearbySite(
const TilePoint &startingCoords,
int32 minDist,
int32 maxDist,
- bool offScreenOnly) { // TRUE if we want it off-screen
+ bool offScreenOnly) { // true if we want it off-screen
assert(isWorld(worldID));
TilePoint baseCoords,
@@ -2511,7 +2505,7 @@ TilePoint selectNearbySite(
// Allocate the array of cells
cellArray = (SimpleCellArray *)
- RNewPtr(sizeof * cellArray, NULL, "path cell array");
+ malloc(sizeof * cellArray);
// Nowhere indicates failure of the algorithm.
bestLoc = Nowhere;
@@ -2543,7 +2537,7 @@ TilePoint selectNearbySite(
GameObject *obj;
for (iter.first(&obj);
- obj != NULL;
+ obj != nullptr;
iter.next(&obj)) {
TilePoint objLoc = obj->getLocation();
ProtoObj *objProto = obj->proto();
@@ -2561,7 +2555,7 @@ TilePoint selectNearbySite(
// If that tile is in the search area, then mark it.
if (objLoc.u >= 0 && objLoc.u < searchDiameter
&& objLoc.v >= 0 && objLoc.v < searchDiameter) {
- (*cellArray)[ objLoc.u ][ objLoc.v ] = cellOccupied;
+ (*cellArray)[objLoc.u][objLoc.v] = cellOccupied;
}
}
@@ -2602,8 +2596,8 @@ TilePoint selectNearbySite(
// If this is the best cell found so far, and it is not
// occupied, then mark it as the best cell.
if (rating > bestRating
- && !((*cellArray)[ qi.u ][ qi.v ] & cellOccupied)) {
- bool cellOK = TRUE;
+ && !((*cellArray)[qi.u][qi.v] & cellOccupied)) {
+ bool cellOK = true;
// if this point is on-screen, we might want to reject it...
if (offScreenOnly) {
@@ -2618,7 +2612,7 @@ TilePoint selectNearbySite(
// not 'pop in').
if (screenCoords.x >= -16 && screenCoords.x <= tileRect.width + 16
&& screenCoords.y >= -16 && screenCoords.y <= tileRect.height + 80) {
- cellOK = FALSE;
+ cellOK = false;
}
}
@@ -2644,24 +2638,24 @@ TilePoint selectNearbySite(
StandingTileInfo sti;
TilePoint fromSubPt,
toSubPt;
- bool traversable = TRUE;
+ bool traversable = true;
int16 i;
- uint16 *moveMask = &sTerrainMasks[ dir - 1 ];
+ uint16 *moveMask = &sTerrainMasks[dir - 1];
- tDir = &tDirTable2[ dir ];
- cell = &(*cellArray)[ qi.u + tDir->u ][ qi.v + tDir->v ];
+ tDir = &tDirTable2[dir];
+ cell = &(*cellArray)[qi.u + tDir->u][qi.v + tDir->v];
// Only visit each cell once. Do this before terrain
// is checked, to save time.
if (*cell & cellVisited) continue;
- testPt = centerPt + tDirTable3[ dir ];
+ testPt = centerPt + tDirTable3[dir];
// Get info about the terrain at that point
terrain = tileTerrain(mapNum,
centerTileCoords,
- moveMask[ 0 ],
+ moveMask[0],
centerPt.z + 8,
centerPt.z + 68);
@@ -2681,14 +2675,14 @@ TilePoint selectNearbySite(
int16 deltaZ;
// Next sub tile
- toSubPt = fromSubPt + tDirTable[ dir ];
+ toSubPt = fromSubPt + tDirTable[dir];
toSubPt.z = tileSlopeHeight(toSubPt, mapNum, 68);
deltaZ = toSubPt.z - fromSubPt.z;
// If it's too high to step, then don't continue
if (deltaZ > maxStepHeight || deltaZ < -(maxStepHeight * 2)) {
- traversable = FALSE;
+ traversable = false;
break;
}
@@ -2701,7 +2695,7 @@ TilePoint selectNearbySite(
// Get info about terrain at new point
terrain = tileTerrain(mapNum,
centerTileCoords + *tDir,
- moveMask[ 1 ],
+ moveMask[1],
testPt.z + 8,
testPt.z + 68);
@@ -2725,7 +2719,7 @@ TilePoint selectNearbySite(
}
}
- RDisposePtr(cellArray);
+ free(cellArray);
return bestLoc != Nowhere
? TilePoint(
@@ -2761,7 +2755,7 @@ TilePoint selectDistantSite(
int metaProperties) {
GameWorld *world = (GameWorld *)GameObject::objectAddress(worldID);
int32 u, v;
- int32 mapSize = mapList[ world->mapNum ].mapSize * platformWidth;
+ int32 mapSize = mapList[world->mapNum].mapSize * platformWidth;
int matchCount = 0;
// Make sure the location spec'd is within the bounds of the map
@@ -2839,12 +2833,12 @@ bool checkPath(
|| destTileCoords.u >= startingTileCoords.u + searchCenter
|| destTileCoords.v < startingTileCoords.v - searchCenter
|| destTileCoords.v >= startingTileCoords.v + searchCenter)
- return FALSE;
+ return false;
// Allocate the array of cells
- cellArray = (SimpleCellArray *)
- RNewPtr(sizeof * cellArray, NULL, "path cell array");
- if (cellArray == NULL) return FALSE;
+ cellArray = (SimpleCellArray *)malloc(sizeof * cellArray);
+ if (cellArray == nullptr)
+ return false;
// Calculate where search cells will be projected onto map
baseTileCoords.u = startingTileCoords.u - searchCenter;
@@ -2937,22 +2931,22 @@ bool checkPath(
int16 testDistFromDest,
deltaDistFromDest;
int i;
- bool traversable = TRUE;
+ bool traversable = true;
- uint16 *moveMask = &sTerrainMasks[ dir - 1 ];
+ uint16 *moveMask = &sTerrainMasks[dir - 1];
- tDir = &tDirTable2[ dir ];
+ tDir = &tDirTable2[dir];
testTileCoords.u = centerTileCoords.u + tDir->u;
testTileCoords.v = centerTileCoords.v + tDir->v;
testTileCoords.z = 0;
- cell = &(*cellArray)[ qi.u + tDir->u ][ qi.v + tDir->v ];
+ cell = &(*cellArray)[qi.u + tDir->u][qi.v + tDir->v];
// Only visit each cell once..
if (*cell & cellVisited) continue;
- testPt = centerPt + tDirTable3[ dir ];
+ testPt = centerPt + tDirTable3[dir];
testDistFromDest = (testPt - destCoords).quickHDistance();
deltaDistFromDest = testDistFromDest - centerDistFromDest;
@@ -2960,7 +2954,7 @@ bool checkPath(
// Get info about the terrain at that point
terrain = tileTerrain(mapNum,
centerTileCoords,
- moveMask[ 0 ],
+ moveMask[0],
centerPt.z + 8,
centerPt.z + height);
@@ -2975,14 +2969,14 @@ bool checkPath(
int16 deltaZ;
// Next sub tile
- toSubPt = fromSubPt + tDirTable[ dir ];
+ toSubPt = fromSubPt + tDirTable[dir];
toSubPt.z = tileSlopeHeight(toSubPt, mapNum, height);
deltaZ = toSubPt.z - fromSubPt.z;
// If it's too high to step, then don't continue
if (deltaZ > maxStepHeight || deltaZ < -(maxStepHeight * 2)) {
- traversable = FALSE;
+ traversable = false;
break;
}
@@ -2994,7 +2988,7 @@ bool checkPath(
// Get info about terrain at new point
terrain = tileTerrain(mapNum,
centerTileCoords + *tDir,
- moveMask[ 1 ],
+ moveMask[1],
testPt.z + 8,
testPt.z + height);
@@ -3009,11 +3003,11 @@ bool checkPath(
// If we're there, we're done
if (testTileCoords == destTileCoords) {
- RDisposePtr(cellArray);
+ free(cellArray);
// If the resulting height is significantly different
// from the destination height, assume we're on a
- // different level and return FALSE.
+ // different level and return false.
return abs(testPt.z - destCoords.z) <= maxStepHeight;
}
@@ -3027,10 +3021,10 @@ bool checkPath(
}
}
- RDisposePtr(cellArray);
+ free(cellArray);
// If we're here we've haven't found a path
- return FALSE;
+ return false;
}
} // end of namespace Saga2
Commit: 238c445ba36132f2aaa9f691ea142075330b2f77
https://github.com/scummvm/scummvm/commit/238c445ba36132f2aaa9f691ea142075330b2f77
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:56+02:00
Commit Message:
SAGA2: Fix memory-magament issues in speldraw.cpp
Changed paths:
engines/saga2/speldraw.cpp
diff --git a/engines/saga2/speldraw.cpp b/engines/saga2/speldraw.cpp
index 226f72bf20..a1f9202aed 100644
--- a/engines/saga2/speldraw.cpp
+++ b/engines/saga2/speldraw.cpp
@@ -70,7 +70,7 @@ EffectDisplayPrototype::EffectDisplayPrototype(
height = newHeight;
breadth = newBreadth;
init = newInit;
- next = NULL;
+ next = nullptr;
}
/* ===================================================================== *
@@ -80,24 +80,18 @@ EffectDisplayPrototype::EffectDisplayPrototype(
EffectDisplayPrototypeList::EffectDisplayPrototypeList(int32 c) {
count = 0;
maxCount = 0;
- effects = (pEffectDisplayPrototype *)malloc(sizeof(pEffectDisplayPrototype) * c);
+ effects = new pEffectDisplayPrototype[c]();
for (int i = 0; i < c; i++)
- effects[i] = NULL;
+ effects[i] = nullptr;
assert(effects);
if (effects) maxCount = c;
}
EffectDisplayPrototypeList::~EffectDisplayPrototypeList() {
if (maxCount && effects)
- for (int i = 0; i < maxCount; i++)
- if (effects[i]) {
- delete effects[i];
- effects[i] = NULL;
- }
+ delete[] effects;
maxCount = 0;
- if (effects)
- delete effects;
- effects = NULL;
+ effects = nullptr;
}
int32 EffectDisplayPrototypeList::add(EffectDisplayPrototype *edp) {
@@ -112,7 +106,7 @@ void EffectDisplayPrototypeList::cleanup(void) {
for (int i = 0; i < maxCount; i++)
if (effects[i]) {
delete effects[i];
- effects[i] = NULL;
+ effects[i] = nullptr;
}
maxCount = 0;
}
@@ -163,7 +157,7 @@ void SpellDisplayPrototype::getColorTranslation(ColorTable map, Effectron *e) {
int32 i = colorMap[whichColorMap(effect, e)];
i = MAX(0, MIN(loadedColorMaps, i));
buildColorTable(map,
- (*spellSchemes)[ i ].bank,
+ (*spellSchemes)[i].bank,
11);
}
@@ -181,10 +175,10 @@ void SpellDisplayPrototypeList::cleanup(void) {
for (int i = 0; i < maxCount; i++)
if (spells[i]) {
delete spells[i];
- spells[i] = NULL;
+ spells[i] = nullptr;
}
delete spells;
- spells = NULL;
+ spells = nullptr;
maxCount = 0;
}
}
@@ -192,23 +186,17 @@ void SpellDisplayPrototypeList::cleanup(void) {
SpellDisplayPrototypeList::SpellDisplayPrototypeList(uint16 s) {
count = 0;
maxCount = 0;
- spells = (pSpellDisplayPrototype *)malloc(sizeof(pSpellDisplayPrototype) * s);
+ spells = new pSpellDisplayPrototype[s]();
for (int i = 0; i < s; i++)
- spells[i] = NULL;
+ spells[i] = nullptr;
assert(spells);
if (spells) maxCount = s;
}
SpellDisplayPrototypeList::~SpellDisplayPrototypeList() {
if (maxCount && spells)
- for (int i = 0; i < maxCount; i++)
- if (spells[i]) {
- delete spells[i];
- spells[i] = NULL;
- }
- if (spells)
- delete spells;
- spells = NULL;
+ delete[] spells;
+ spells = nullptr;
}
int32 SpellDisplayPrototypeList::add(SpellDisplayPrototype *sdp) {
@@ -225,9 +213,9 @@ int32 SpellDisplayPrototypeList::add(SpellDisplayPrototype *sdp) {
SpellDisplayList::SpellDisplayList(uint16 s) {
count = 0;
maxCount = 0;
- spells = (pSpellInstance *)malloc(sizeof(pSpellInstance) * s);
+ spells = new pSpellInstance[s]();
for (int i = 0; i < s; i++)
- spells[i] = NULL;
+ spells[i] = nullptr;
if (spells) maxCount = s;
init();
}
@@ -242,14 +230,8 @@ void SpellDisplayList::init(void) {
void SpellDisplayList::cleanup(void) {
if (maxCount && spells)
- for (int i = 0; i < maxCount; i++)
- if (spells[i]) {
- delete spells[i];
- spells[i] = NULL;
- }
- if (spells)
- delete spells;
- spells = NULL;
+ delete[] spells;
+ spells = nullptr;
}
void SpellDisplayList::add(SpellInstance *newSpell) {
@@ -276,12 +258,12 @@ void SpellDisplayList::tidyKill(uint16 spellNo) {
assert(count);
if (spells[spellNo]) {
delete spells[spellNo];
- spells[spellNo] = NULL;
+ spells[spellNo] = nullptr;
}
if (spellNo < count--) {
for (uint16 i = spellNo; i <= count; i++)
spells[i] = spells[i + 1];
- spells[count + 1] = NULL;
+ spells[count + 1] = nullptr;
}
}
Commit: 78d8cf362e23cffaabb43e5fdd8a0da636c95939
https://github.com/scummvm/scummvm/commit/78d8cf362e23cffaabb43e5fdd8a0da636c95939
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:56+02:00
Commit Message:
SAGA2: Fix more memory-related errors
Changed paths:
engines/saga2/gamerate.h
engines/saga2/noise.cpp
diff --git a/engines/saga2/gamerate.h b/engines/saga2/gamerate.h
index c84acde115..9153d4b470 100644
--- a/engines/saga2/gamerate.h
+++ b/engines/saga2/gamerate.h
@@ -155,8 +155,8 @@ public:
~frameSmoother() {
- if (frameHistory) delete frameHistory;
- frameHistory = NULL;
+ if (frameHistory) delete[] frameHistory;
+ frameHistory = nullptr;
}
virtual void updateFrameCount(void) {
diff --git a/engines/saga2/noise.cpp b/engines/saga2/noise.cpp
index dcff52d020..e0b949fc62 100644
--- a/engines/saga2/noise.cpp
+++ b/engines/saga2/noise.cpp
@@ -242,13 +242,12 @@ void startAudio(void) {
(uint32) 400000 // sound buffer size
);
+ warning("STUB: startAudio, sync sound settings");
#if 0
disMusic = !GetPrivateProfileInt("Sound", "Music", 1, iniFile);
disVoice = !GetPrivateProfileInt("Sound", "Voice", 1, iniFile);
disLoops = !GetPrivateProfileInt("Sound", "Loops", 1, iniFile);
disSound = !GetPrivateProfileInt("Sound", "Sound", 1, iniFile);
-#endif
- warning("STUB: startAudio, sync sound settings");
assert(audio);
if (audio->active()) {
@@ -350,6 +349,7 @@ void startAudio(void) {
audio->disable(volLoops);
if (disSound)
audio->disable(volSound);
+#endif
}
//-----------------------------------------------------------------------
Commit: 46f062d54a77cb1239d2f2b4be088e0db32494cd
https://github.com/scummvm/scummvm/commit/46f062d54a77cb1239d2f2b4be088e0db32494cd
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:56+02:00
Commit Message:
SAGA2: Fix warnings
Changed paths:
engines/saga2/mapfeatr.cpp
engines/saga2/mapfeatr.h
diff --git a/engines/saga2/mapfeatr.cpp b/engines/saga2/mapfeatr.cpp
index 8af94545f6..e505e249a0 100644
--- a/engines/saga2/mapfeatr.cpp
+++ b/engines/saga2/mapfeatr.cpp
@@ -315,7 +315,7 @@ void termMapFeatures(void) {
-CMapFeature::CMapFeature(TilePoint where, int16 inWorld, char *desc) {
+CMapFeature::CMapFeature(TilePoint where, int16 inWorld, const char *desc) {
visible = FALSE;
featureCoords = where;
world = inWorld;
@@ -398,7 +398,7 @@ bool CMapFeature::hitCheck(TileRegion viewRegion,
CStaticMapFeatute class implementation
* ===================================================================== */
-CStaticMapFeature::CStaticMapFeature(TilePoint where, int16 inWorld, char *desc, int16 bColor)
+CStaticMapFeature::CStaticMapFeature(TilePoint where, int16 inWorld, const char *desc, int16 bColor)
: CMapFeature(where, inWorld, desc) {
color = bColor;
}
diff --git a/engines/saga2/mapfeatr.h b/engines/saga2/mapfeatr.h
index 94d5b973a1..134ff003e5 100644
--- a/engines/saga2/mapfeatr.h
+++ b/engines/saga2/mapfeatr.h
@@ -52,7 +52,7 @@ class CMapFeature {
public:
- CMapFeature(TilePoint where, int16 inWorld, char *desc);
+ CMapFeature(TilePoint where, int16 inWorld, const char *desc);
virtual ~CMapFeature() {}
void expose(bool canSee = TRUE) {
@@ -89,7 +89,7 @@ class CStaticMapFeature : public CMapFeature {
int16 color;
public:
- CStaticMapFeature(TilePoint where, int16 inWorld, char *desc, int16 bColor);
+ CStaticMapFeature(TilePoint where, int16 inWorld, const char *desc, int16 bColor);
virtual void blit(gPort &tp, int32 x, int32 y);
virtual void update(void) {}
virtual bool isHit(TilePoint disp, TilePoint mouse);
Commit: 9a8c31cde3feb7a7561f9247dcc4802822d33ad9
https://github.com/scummvm/scummvm/commit/9a8c31cde3feb7a7561f9247dcc4802822d33ad9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:56+02:00
Commit Message:
SAGA2: Finish work on the nested includes
Changed paths:
engines/saga2/actor.cpp
engines/saga2/button.cpp
engines/saga2/button.h
engines/saga2/calender.cpp
engines/saga2/calender.h
engines/saga2/contain.cpp
engines/saga2/idtypes.h
engines/saga2/interp.cpp
engines/saga2/intrface.cpp
engines/saga2/intrface.h
engines/saga2/main.cpp
engines/saga2/motion.cpp
engines/saga2/motion.h
engines/saga2/msgbox.cpp
engines/saga2/objects.cpp
engines/saga2/objproto.cpp
engines/saga2/objproto.h
engines/saga2/player.cpp
engines/saga2/player.h
engines/saga2/sagafunc.cpp
engines/saga2/script.h
engines/saga2/sensor.cpp
engines/saga2/setup.h
engines/saga2/sprite.cpp
engines/saga2/sprite.h
engines/saga2/task.cpp
engines/saga2/tile.cpp
engines/saga2/tilemode.cpp
engines/saga2/timers.cpp
engines/saga2/tromode.cpp
engines/saga2/uidialog.cpp
engines/saga2/uidialog.h
engines/saga2/vpal.cpp
engines/saga2/weapons.cpp
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 9b26cc06e9..c593004f44 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -48,6 +48,8 @@
#include "saga2/intrface.h"
#include "saga2/hresmgr.h"
#include "saga2/contain.h"
+#include "saga2/savefile.h"
+#include "saga2/combat.h"
// Include files needed for SAGA script dispatch
#include "saga2/script.h"
diff --git a/engines/saga2/button.cpp b/engines/saga2/button.cpp
index 173c944185..5596f6dace 100644
--- a/engines/saga2/button.cpp
+++ b/engines/saga2/button.cpp
@@ -27,6 +27,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
+#include "saga2/fta.h"
#include "saga2/cmisc.h"
#include "saga2/hresmgr.h"
#include "saga2/button.h"
diff --git a/engines/saga2/button.h b/engines/saga2/button.h
index 51d5882911..cbf74ec939 100644
--- a/engines/saga2/button.h
+++ b/engines/saga2/button.h
@@ -27,14 +27,17 @@
#ifndef SAGA2_BUTTON_H
#define SAGA2_BUTTON_H
-#include "saga2/fta.h"
-#include "saga2/hresmgr.h"
#include "saga2/panel.h"
#include "saga2/cmisc.h"
-#include "saga2/sprite.h"
+#include "saga2/idtypes.h"
+
+//#include "saga2/sprite.h"
namespace Saga2 {
+class Sprite;
+class hResContext;
+
/* ======================================================================= *
Misc. Structs and classes
* ======================================================================= */
diff --git a/engines/saga2/calender.cpp b/engines/saga2/calender.cpp
index ea9d8c7d19..fda45ea1e6 100644
--- a/engines/saga2/calender.cpp
+++ b/engines/saga2/calender.cpp
@@ -32,6 +32,7 @@
#include "saga2/intrface.h"
#include "saga2/config.h"
#include "saga2/localize.h"
+#include "saga2/savefile.h"
namespace Saga2 {
diff --git a/engines/saga2/calender.h b/engines/saga2/calender.h
index 840fbfad7c..d947fe5942 100644
--- a/engines/saga2/calender.h
+++ b/engines/saga2/calender.h
@@ -27,10 +27,11 @@
#ifndef SAGA2_CALENDER_H
#define SAGA2_CALENDER_H
-#include "saga2/savefile.h"
-
namespace Saga2 {
+class SaveFileConstructor;
+class SaveFileReader;
+
/* ===================================================================== *
CalenderTime class
* ===================================================================== */
diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index 0fa906f3af..4ef993ddc4 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -42,6 +42,7 @@
#include "saga2/imagcach.h"
#include "saga2/hresmgr.h"
#include "saga2/fontlib.h"
+#include "saga2/savefile.h"
#include "saga2/pclass.r"
diff --git a/engines/saga2/idtypes.h b/engines/saga2/idtypes.h
index c2a7badb14..438f81cf0f 100644
--- a/engines/saga2/idtypes.h
+++ b/engines/saga2/idtypes.h
@@ -225,6 +225,12 @@ typedef uint16 weaponID;
typedef uint32 hResID;
+typedef uint8 ColorTable[ 256 ];
+
+// number of containers
+const int kNumViews = 3;
+
+
} // end of namespace Saga2
#endif
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 0ce9823b5b..b555a6b33b 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -38,6 +38,7 @@
#include "saga2/tile.h"
#include "saga2/mission.h"
#include "saga2/hresmgr.h"
+#include "saga2/savefile.h"
namespace Saga2 {
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index 03aa9130e1..16bc37c096 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -46,6 +46,7 @@
#include "saga2/localize.h"
#include "saga2/imagcach.h"
#include "saga2/fontlib.h"
+#include "saga2/uimetrcs.h"
namespace Saga2 {
diff --git a/engines/saga2/intrface.h b/engines/saga2/intrface.h
index 2d50a0e425..ad6299fa3b 100644
--- a/engines/saga2/intrface.h
+++ b/engines/saga2/intrface.h
@@ -28,8 +28,6 @@
#define SAGA2_INTRFACE_H
#include "saga2/button.h"
-#include "saga2/setup.h"
-#include "saga2/uimetrcs.h"
#include "saga2/modal.h"
#include "saga2/player.h"
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index f50c2e60d9..6f56414897 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -53,7 +53,7 @@
#include "saga2/script.h"
#include "saga2/config.h"
#include "saga2/hresmgr.h"
-
+#include "saga2/savefile.h"
namespace Saga2 {
diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp
index bb3d9b7195..cf8f81cd6c 100644
--- a/engines/saga2/motion.cpp
+++ b/engines/saga2/motion.cpp
@@ -41,6 +41,7 @@
#include "saga2/player.h"
#include "saga2/contain.h"
#include "saga2/intrface.h"
+#include "saga2/savefile.h"
namespace Saga2 {
diff --git a/engines/saga2/motion.h b/engines/saga2/motion.h
index 9eb27878f4..44431e95e2 100644
--- a/engines/saga2/motion.h
+++ b/engines/saga2/motion.h
@@ -28,12 +28,11 @@
#define SAGA2_MOTION_H
#include "saga2/actor.h"
-#include "saga2/tile.h"
-#include "saga2/savefile.h"
namespace Saga2 {
class PathRequest;
+struct StandingTileInfo;
extern TilePoint dirTable[];
diff --git a/engines/saga2/msgbox.cpp b/engines/saga2/msgbox.cpp
index a949290f3b..fb6f73c62b 100644
--- a/engines/saga2/msgbox.cpp
+++ b/engines/saga2/msgbox.cpp
@@ -27,6 +27,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
+#include "saga2/fta.h"
#include "saga2/button.h"
#include "saga2/localize.h"
#include "saga2/msgbox.h"
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 0b5f5909af..33efa16a72 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -50,6 +50,7 @@
#include "saga2/tilevect.h"
#include "saga2/dispnode.h"
#include "saga2/hresmgr.h"
+#include "saga2/savefile.h"
#include "saga2/methods.r" // generated by SAGA
#include "saga2/pclass.r"
diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp
index 19d6c344f3..584995d45d 100644
--- a/engines/saga2/objproto.cpp
+++ b/engines/saga2/objproto.cpp
@@ -27,6 +27,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
+#include "saga2/gdraw.h"
#include "saga2/sprite.h"
#include "saga2/objects.h"
#include "saga2/actor.h"
@@ -42,6 +43,7 @@
#include "saga2/magic.h"
#include "saga2/weapons.h"
#include "saga2/spellbuk.h"
+#include "saga2/combat.h"
#include "saga2/methods.r"
#include "saga2/pclass.r"
diff --git a/engines/saga2/objproto.h b/engines/saga2/objproto.h
index c8376ca4c3..8e5b75fdd3 100644
--- a/engines/saga2/objproto.h
+++ b/engines/saga2/objproto.h
@@ -31,7 +31,6 @@
#include "saga2/sprite.h"
#include "saga2/spells.h"
#include "saga2/effects.h"
-#include "saga2/combat.h"
#include "saga2/tcoords.h"
namespace Saga2 {
diff --git a/engines/saga2/player.cpp b/engines/saga2/player.cpp
index 9c13adadb2..bcbb21cc2e 100644
--- a/engines/saga2/player.cpp
+++ b/engines/saga2/player.cpp
@@ -36,6 +36,7 @@
#include "saga2/motion.h"
#include "saga2/transit.h"
#include "saga2/localize.h"
+#include "saga2/savefile.h"
namespace Saga2 {
diff --git a/engines/saga2/player.h b/engines/saga2/player.h
index d46f016c38..08ad59692b 100644
--- a/engines/saga2/player.h
+++ b/engines/saga2/player.h
@@ -27,10 +27,7 @@
#ifndef SAGA2_PLAYER_H
#define SAGA2_PLAYER_H
-#include "saga2/idtypes.h"
#include "saga2/actor.h"
-#include "saga2/panel.h"
-#include "saga2/savefile.h"
namespace Saga2 {
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index 3f750fa4e0..2445be432c 100644
--- a/engines/saga2/sagafunc.cpp
+++ b/engines/saga2/sagafunc.cpp
@@ -54,6 +54,7 @@
#include "saga2/display.h"
#include "saga2/transit.h"
#include "saga2/contain.h"
+#include "saga2/tile.h"
void drawMainDisplay(void);
diff --git a/engines/saga2/script.h b/engines/saga2/script.h
index 6224e53fc4..2de231c633 100644
--- a/engines/saga2/script.h
+++ b/engines/saga2/script.h
@@ -29,7 +29,6 @@
#include "saga2/objects.h"
#include "saga2/calender.h"
-#include "saga2/savefile.h"
namespace Saga2 {
diff --git a/engines/saga2/sensor.cpp b/engines/saga2/sensor.cpp
index d7ee4e1015..d418fa5b1a 100644
--- a/engines/saga2/sensor.cpp
+++ b/engines/saga2/sensor.cpp
@@ -32,6 +32,7 @@
#include "saga2/pool.h"
#include "saga2/player.h"
#include "saga2/tile.h"
+#include "saga2/savefile.h"
namespace Saga2 {
diff --git a/engines/saga2/setup.h b/engines/saga2/setup.h
index 161a7f9287..abacbcccdb 100644
--- a/engines/saga2/setup.h
+++ b/engines/saga2/setup.h
@@ -44,9 +44,6 @@ struct WindowDecoration;
//If No Ready Containers Then Following Const's not needed
-// number of containers
-const int kNumViews = 3;
-
// enum for the three levels in the trio view
enum trioViews {
top,
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index 7543cb28bf..e8a60dc147 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -27,6 +27,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
+#include "saga2/fta.h"
#include "saga2/blitters.h"
#include "saga2/sprite.h"
#include "saga2/tcoords.h"
diff --git a/engines/saga2/sprite.h b/engines/saga2/sprite.h
index ef74090788..c0aacf7787 100644
--- a/engines/saga2/sprite.h
+++ b/engines/saga2/sprite.h
@@ -27,11 +27,15 @@
#ifndef SAGA2_SPRITE_H
#define SAGA2_SPRITE_H
-#include "saga2/fta.h"
+#include "saga2/rect.h"
#include "saga2/dlist.h"
+#include "saga2/rmem.h"
namespace Saga2 {
+class gPort;
+class gPixelMap;
+
#ifdef _WIN32 // Set structure alignment packing value to 1 byte
#pragma pack( push, 1 )
#endif
diff --git a/engines/saga2/task.cpp b/engines/saga2/task.cpp
index 7e7cc48067..053bb8fbb4 100644
--- a/engines/saga2/task.cpp
+++ b/engines/saga2/task.cpp
@@ -27,6 +27,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
+#include "saga2/fta.h"
#include "saga2/cmisc.h"
#include "saga2/actor.h"
#include "saga2/task.h"
@@ -34,6 +35,8 @@
#include "saga2/band.h"
#include "saga2/sensor.h"
#include "saga2/tilemode.h"
+#include "saga2/savefile.h"
+#include "saga2/tile.h"
namespace Saga2 {
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 564a388141..61d071e2ff 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -45,6 +45,7 @@
#include "saga2/tagnoise.h"
#include "saga2/player.h"
#include "saga2/mapfeatr.h"
+#include "saga2/savefile.h"
// Include files needed for SAGA script dispatch
#include "saga2/script.h"
diff --git a/engines/saga2/tilemode.cpp b/engines/saga2/tilemode.cpp
index 6aeced3d76..e0f10faa2c 100644
--- a/engines/saga2/tilemode.cpp
+++ b/engines/saga2/tilemode.cpp
@@ -53,6 +53,7 @@
#include "saga2/images.h"
#include "saga2/config.h"
#include "saga2/contain.h"
+#include "saga2/savefile.h"
namespace Saga2 {
diff --git a/engines/saga2/timers.cpp b/engines/saga2/timers.cpp
index c7d26345ed..ceaf899bc9 100644
--- a/engines/saga2/timers.cpp
+++ b/engines/saga2/timers.cpp
@@ -30,6 +30,7 @@
#include "saga2/timers.h"
#include "saga2/pool.h"
#include "saga2/objects.h"
+#include "saga2/savefile.h"
namespace Saga2 {
diff --git a/engines/saga2/tromode.cpp b/engines/saga2/tromode.cpp
index 636db5ff2b..657254c27f 100644
--- a/engines/saga2/tromode.cpp
+++ b/engines/saga2/tromode.cpp
@@ -38,6 +38,7 @@
#include "saga2/mainmap.h"
#include "saga2/config.h"
+#include "saga2/panel.h"
namespace Saga2 {
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index 5a0d2348ab..e5a37377c6 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -60,6 +60,7 @@
#include "saga2/config.h"
#include "saga2/hresmgr.h"
#include "saga2/fontlib.h"
+#include "saga2/savefile.h"
namespace Saga2 {
diff --git a/engines/saga2/uidialog.h b/engines/saga2/uidialog.h
index cb29aa3acd..81b5095e70 100644
--- a/engines/saga2/uidialog.h
+++ b/engines/saga2/uidialog.h
@@ -29,6 +29,8 @@
namespace Saga2 {
+class SaveFileHeader;
+
// constants
const uint32 dialogGroupID = MKTAG('D', 'I', 'A', 'L');
diff --git a/engines/saga2/vpal.cpp b/engines/saga2/vpal.cpp
index 76294248f5..0e3e12dae7 100644
--- a/engines/saga2/vpal.cpp
+++ b/engines/saga2/vpal.cpp
@@ -36,6 +36,7 @@
#include "saga2/player.h"
#include "saga2/display.h"
#include "saga2/hresmgr.h"
+#include "saga2/savefile.h"
namespace Saga2 {
diff --git a/engines/saga2/weapons.cpp b/engines/saga2/weapons.cpp
index 200384a7d3..83d397c73a 100644
--- a/engines/saga2/weapons.cpp
+++ b/engines/saga2/weapons.cpp
@@ -33,6 +33,7 @@
#include "saga2/actor.h"
#include "saga2/spellio.h"
#include "saga2/hresmgr.h"
+#include "saga2/combat.h"
namespace Saga2 {
Commit: b9162e3de5edb3f2358fe8e5294bbb3438b6e278
https://github.com/scummvm/scummvm/commit/b9162e3de5edb3f2358fe8e5294bbb3438b6e278
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:56+02:00
Commit Message:
SAGA2: Cleanup test code on the engine start
Changed paths:
engines/saga2/saga2.cpp
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index 3ab62443af..1f8f5e3532 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -90,13 +90,9 @@ Common::Error Saga2Engine::run() {
loadExeResources();
- startVideo("INTRO", 0, 0);
- while (!shouldQuit() && checkVideo()) {
- Common::Event event;
- g_system->getEventManager()->pollEvent(event);
- g_system->delayMillis(10);
- }
+ main_saga2();
+#if 0
if (openResources()) {
testOpenImage();
initScripts();
@@ -112,8 +108,7 @@ Common::Error Saga2Engine::run() {
g_system->updateScreen();
g_system->delayMillis(10);
}
-
- main_saga2();
+#endif
return Common::kNoError;
}
Commit: 6e8a939be75501c6e5bb53a638d29a562669b8ef
https://github.com/scummvm/scummvm/commit/6e8a939be75501c6e5bb53a638d29a562669b8ef
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:56+02:00
Commit Message:
SAGA2: Fix initSystemTimer() stub
Changed paths:
engines/saga2/mainmap.cpp
diff --git a/engines/saga2/mainmap.cpp b/engines/saga2/mainmap.cpp
index e4da371bc8..252cf878fd 100644
--- a/engines/saga2/mainmap.cpp
+++ b/engines/saga2/mainmap.cpp
@@ -65,7 +65,7 @@ void shutdownGame() {
bool initSystemTimer() {
warning("STUB: initSystemTimer()");
- return false;
+ return true;
}
void cleanupSystemTimer() {
warning("STUB: cleanupSystemTimer()");
Commit: 7fbe19751b444b4de53d3fa3f0c72637cd7db5aa
https://github.com/scummvm/scummvm/commit/7fbe19751b444b4de53d3fa3f0c72637cd7db5aa
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:56+02:00
Commit Message:
SAGA2: Cleanup task.h
Changed paths:
engines/saga2/actor.cpp
engines/saga2/assign.cpp
engines/saga2/task.cpp
engines/saga2/task.h
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index c593004f44..6e4b81a5d7 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -32,21 +32,15 @@
#include "saga2/dispnode.h"
#include "saga2/tile.h"
#include "saga2/motion.h"
-#include "saga2/grabinfo.h"
#include "saga2/task.h"
-#include "saga2/actor.h"
-#include "saga2/player.h"
#include "saga2/assign.h"
#include "saga2/setup.h"
#include "saga2/stimtype.h"
#include "saga2/band.h"
#include "saga2/sensor.h"
-#include "saga2/tromode.h"
-#include "saga2/messager.h"
#include "saga2/weapons.h"
#include "saga2/localize.h"
#include "saga2/intrface.h"
-#include "saga2/hresmgr.h"
#include "saga2/contain.h"
#include "saga2/savefile.h"
#include "saga2/combat.h"
@@ -2493,8 +2487,7 @@ void Actor::updateState(void) {
if (curTask == NULL) {
if ((curTask = new TaskStack(this)) != NULL) {
- Task *task = NEW_TASK
- GoAwayFromActorTask(
+ Task *task = new GoAwayFromActorTask(
curTask,
ActorPropertyTarget(
disposition == dispositionEnemy
@@ -2520,7 +2513,7 @@ void Actor::updateState(void) {
? leader->disposition
: disposition;
- Task *task = NEW_TASK HuntToKillTask(
+ Task *task = new HuntToKillTask(
curTask,
ActorPropertyTarget(
disp == dispositionEnemy
@@ -2554,7 +2547,7 @@ void Actor::updateState(void) {
if (curTask == NULL) {
if ((curTask = new TaskStack(this)) != NULL) {
- Task *task = NEW_TASK BandAndAvoidEnemiesTask(curTask);
+ Task *task = new BandAndAvoidEnemiesTask(curTask);
if (task != NULL)
curTask->setTask(task);
@@ -2963,7 +2956,7 @@ TaskStack *Actor::createFollowerTask(Actor *bandMember) {
TaskStack *ts = NULL;
if ((ts = new TaskStack(bandMember)) != NULL) {
- Task *task = NEW_TASK BandTask(ts);
+ Task *task = new BandTask(ts);
if (task != NULL)
ts->setTask(task);
diff --git a/engines/saga2/assign.cpp b/engines/saga2/assign.cpp
index c209db8ff6..2ad3e8de9e 100644
--- a/engines/saga2/assign.cpp
+++ b/engines/saga2/assign.cpp
@@ -34,7 +34,6 @@
#include "saga2/actor.h"
#include "saga2/assign.h"
#include "saga2/calender.h"
-#include "saga2/patrol.h"
#include "saga2/task.h"
#include "saga2/tile.h"
@@ -335,8 +334,8 @@ Task *PatrolRouteAssignment::getTask(TaskStack *ts) {
// Construct a FollowPatrolRouteTask
return endingWayPoint != -1
- ? NEW_TASK FollowPatrolRouteTask(ts, iter, endingWayPoint)
- : NEW_TASK FollowPatrolRouteTask(ts, iter);
+ ? new FollowPatrolRouteTask(ts, iter, endingWayPoint)
+ : new FollowPatrolRouteTask(ts, iter);
}
/* ===================================================================== *
@@ -433,7 +432,7 @@ bool HuntToBeNearLocationAssignment::taskNeeded(void) {
// Construct a Task for this assignment
Task *HuntToBeNearLocationAssignment::getTask(TaskStack *ts) {
- return NEW_TASK HuntToBeNearLocationTask(ts, *getTarget(), range);
+ return new HuntToBeNearLocationTask(ts, *getTarget(), range);
}
/* ===================================================================== *
@@ -554,7 +553,7 @@ bool HuntToBeNearActorAssignment::taskNeeded(void) {
// Construct a Task for this assignment
Task *HuntToBeNearActorAssignment::getTask(TaskStack *ts) {
- return NEW_TASK HuntToBeNearActorTask(
+ return new HuntToBeNearActorTask(
ts,
*getTarget(),
range,
@@ -688,7 +687,7 @@ bool HuntToKillAssignment::taskNeeded(void) {
// Construct a Task for this assignment
Task *HuntToKillAssignment::getTask(TaskStack *ts) {
- return NEW_TASK HuntToKillTask(
+ return new HuntToKillTask(
ts,
*getTarget(),
(flags & track) != FALSE);
@@ -769,7 +768,7 @@ int16 TetheredWanderAssignment::type(void) const {
// Construct a Task for this assignment
Task *TetheredWanderAssignment::getTask(TaskStack *ts) {
- return NEW_TASK TetheredWanderTask(ts, minU, minV, maxU, maxV);
+ return new TetheredWanderTask(ts, minU, minV, maxU, maxV);
}
/* ===================================================================== *
@@ -840,7 +839,7 @@ int16 AttendAssignment::type(void) const {
// Construct a Task for this assignment
Task *AttendAssignment::getTask(TaskStack *ts) {
- return NEW_TASK AttendTask(ts, obj);
+ return new AttendTask(ts, obj);
}
/* ===================================================================== *
diff --git a/engines/saga2/task.cpp b/engines/saga2/task.cpp
index 053bb8fbb4..b539d483e1 100644
--- a/engines/saga2/task.cpp
+++ b/engines/saga2/task.cpp
@@ -1011,84 +1011,84 @@ void *constructTask(TaskID id, void *buf) {
// Reconstruct the Task based upon the type
switch (type) {
case wanderTask:
- NEW_TASK_ID(id) WanderTask(&buf);
+ new(id) WanderTask(&buf);
break;
case tetheredWanderTask:
- NEW_TASK_ID(id) TetheredWanderTask(&buf);
+ new(id) TetheredWanderTask(&buf);
break;
case gotoLocationTask:
- NEW_TASK_ID(id) GotoLocationTask(&buf);
+ new(id) GotoLocationTask(&buf);
break;
case gotoRegionTask:
- NEW_TASK_ID(id) GotoRegionTask(&buf);
+ new(id) GotoRegionTask(&buf);
break;
case gotoObjectTask:
- NEW_TASK_ID(id) GotoObjectTask(&buf);
+ new(id) GotoObjectTask(&buf);
break;
case gotoActorTask:
- NEW_TASK_ID(id) GotoActorTask(&buf);
+ new(id) GotoActorTask(&buf);
break;
case goAwayFromObjectTask:
- NEW_TASK_ID(id) GoAwayFromObjectTask(&buf);
+ new(id) GoAwayFromObjectTask(&buf);
break;
case goAwayFromActorTask:
- NEW_TASK_ID(id) GoAwayFromActorTask(&buf);
+ new(id) GoAwayFromActorTask(&buf);
break;
case huntToBeNearLocationTask:
- NEW_TASK_ID(id) HuntToBeNearLocationTask(&buf);
+ new(id) HuntToBeNearLocationTask(&buf);
break;
case huntToBeNearObjectTask:
- NEW_TASK_ID(id) HuntToBeNearObjectTask(&buf);
+ new(id) HuntToBeNearObjectTask(&buf);
break;
case huntToPossessTask:
- NEW_TASK_ID(id) HuntToPossessTask(&buf);
+ new(id) HuntToPossessTask(&buf);
break;
case huntToBeNearActorTask:
- NEW_TASK_ID(id) HuntToBeNearActorTask(&buf);
+ new(id) HuntToBeNearActorTask(&buf);
break;
case huntToKillTask:
- NEW_TASK_ID(id) HuntToKillTask(&buf);
+ new(id) HuntToKillTask(&buf);
break;
case huntToGiveTask:
- NEW_TASK_ID(id) HuntToGiveTask(&buf);
+ new(id) HuntToGiveTask(&buf);
break;
case bandTask:
- NEW_TASK_ID(id) BandTask(&buf);
+ new(id) BandTask(&buf);
break;
case bandAndAvoidEnemiesTask:
- NEW_TASK_ID(id) BandAndAvoidEnemiesTask(&buf);
+ new(id) BandAndAvoidEnemiesTask(&buf);
break;
case followPatrolRouteTask:
- NEW_TASK_ID(id) FollowPatrolRouteTask(&buf);
+ new(id) FollowPatrolRouteTask(&buf);
break;
case attendTask:
- NEW_TASK_ID(id) AttendTask(&buf);
+ new(id) AttendTask(&buf);
break;
#if 0
case defendTask:
- NEW_TASK_ID(id) DefendTask(&buf);
+ new(id) DefendTask(&buf);
break;
case parryTask:
- NEW_TASK_ID(id) ParryTask(&buf);
+ new(id) ParryTask(&buf);
break;
#endif
}
@@ -1465,7 +1465,7 @@ TaskResult TetheredWanderTask::handleWander(void) {
if (gotoTether != NULL)
gotoTether->update();
else {
- gotoTether = NEW_TASK GotoRegionTask(stack, minU, minV, maxU, maxV);
+ gotoTether = new GotoRegionTask(stack, minU, minV, maxU, maxV);
if (gotoTether != NULL) gotoTether->update();
}
} else {
@@ -1689,7 +1689,7 @@ TaskResult GotoTask::update(void) {
if (wander != NULL)
wander->update();
else {
- wander = NEW_TASK WanderTask(stack);
+ wander = new WanderTask(stack);
if (wander != NULL) wander->update();
}
@@ -2330,8 +2330,8 @@ TaskResult GoAwayFromTask::update(void) {
goTask->update();
} else {
if ((goTask = flags & run
- ? NEW_TASK GotoLocationTask(stack, dest, 0)
- : NEW_TASK GotoLocationTask(stack, dest))
+ ? new GotoLocationTask(stack, dest, 0)
+ : new GotoLocationTask(stack, dest))
!= NULL)
goTask->update();
}
@@ -2665,7 +2665,7 @@ TaskResult HuntTask::update(void) {
} else {
// If we couldn't setup a goto task, setup a wander task
if (!(huntFlags & huntWander)) {
- if ((subTask = NEW_TASK WanderTask(stack)) != NULL)
+ if ((subTask = new WanderTask(stack)) != NULL)
huntFlags |= huntWander;
}
}
@@ -2764,7 +2764,7 @@ bool HuntLocationTask::targetHasChanged(GotoTask *gotoTarget) {
GotoTask *HuntLocationTask::setupGoto(void) {
// If there is somewhere to go, setup a goto task, else return NULL
return currentTarget != Nowhere
- ? NEW_TASK GotoLocationTask(stack, currentTarget)
+ ? new GotoLocationTask(stack, currentTarget)
: NULL;
}
@@ -2967,7 +2967,7 @@ GotoTask *HuntObjectTask::setupGoto(void) {
// If there is an object to goto, setup a GotoObjectTask, else
// return NULL
return currentTarget
- ? NEW_TASK GotoObjectTask(stack, currentTarget)
+ ? new GotoObjectTask(stack, currentTarget)
: NULL;
}
@@ -3354,11 +3354,11 @@ GotoTask *HuntActorTask::setupGoto(void) {
// If there is an actor to goto, setup a GotoActorTask, else
// return NULL
/* return currentTarget
- ? NEW_TASK GotoActorTask( stack, currentTarget, flags & track )
+ ? new GotoActorTask( stack, currentTarget, flags & track )
: NULL;
*/
if (currentTarget != NULL) {
- return NEW_TASK GotoActorTask(
+ return new GotoActorTask(
stack,
currentTarget,
flags & track);
@@ -3589,7 +3589,7 @@ TaskResult HuntToBeNearActorTask::atTargetUpdate(void) {
if (a->inRange(targetLoc, tooClose)) {
// Setup a go away task if necessary and update it
if (goAway == NULL) {
- goAway = NEW_TASK GoAwayFromObjectTask(stack, currentTarget);
+ goAway = new GoAwayFromObjectTask(stack, currentTarget);
if (goAway != NULL) goAway->update();
} else
goAway->update();
@@ -4341,7 +4341,7 @@ bool BandTask::targetHasChanged(GotoTask *gotoTarget) {
//----------------------------------------------------------------------
GotoTask *BandTask::setupGoto(void) {
- return NEW_TASK GotoLocationTask(stack, currentTarget, getRunThreshold());
+ return new GotoLocationTask(stack, currentTarget, getRunThreshold());
}
//----------------------------------------------------------------------
@@ -4393,7 +4393,7 @@ TaskResult BandTask::atTargetUpdate(void) {
if (attend != NULL)
attend->update();
else {
- attend = NEW_TASK AttendTask(stack, a->leader);
+ attend = new AttendTask(stack, a->leader);
if (attend != NULL)
attend->update();
}
@@ -4725,7 +4725,7 @@ TaskResult FollowPatrolRouteTask::handleFollowPatrolRoute(void) {
if (gotoWayPoint != NULL)
gotoWayPoint->update();
else {
- gotoWayPoint = NEW_TASK GotoLocationTask(stack, currentWayPoint);
+ gotoWayPoint = new GotoLocationTask(stack, currentWayPoint);
if (gotoWayPoint != NULL) gotoWayPoint->update();
}
@@ -4983,7 +4983,7 @@ TaskResult DefendTask::update(void) {
& 0x7;
if (relDir == 7 || relDir <= 1)
- subTask = NEW_TASK ParryTask(stack, attacker, defensiveObj);
+ subTask = new ParryTask(stack, attacker, defensiveObj);
else
return taskFailed;
}
diff --git a/engines/saga2/task.h b/engines/saga2/task.h
index d0d1654670..2a0801c1c7 100644
--- a/engines/saga2/task.h
+++ b/engines/saga2/task.h
@@ -62,18 +62,6 @@ enum TaskType {
#endif
};
-/* ===================================================================== *
- Macros
- * ===================================================================== */
-
-#if DEBUG
-#define NEW_TASK new ( __FILE__, __LINE__ )
-#define NEW_TASK_ID( id ) new ( __FILE__, __LINE__, ( id ) )
-#else
-#define NEW_TASK new
-#define NEW_TASK_ID( id ) new ( id )
-#endif
-
/* ===================================================================== *
Function prototypes
* ===================================================================== */
Commit: 2d0fdf1fe289a8fe7b68b93181ff8ebddbf0e835
https://github.com/scummvm/scummvm/commit/2d0fdf1fe289a8fe7b68b93181ff8ebddbf0e835
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:57+02:00
Commit Message:
SAGA2: Fix palette loading
Changed paths:
engines/saga2/palette.h
engines/saga2/transit.cpp
engines/saga2/vpal.cpp
diff --git a/engines/saga2/palette.h b/engines/saga2/palette.h
index 8999f75f94..bfd4356c7d 100644
--- a/engines/saga2/palette.h
+++ b/engines/saga2/palette.h
@@ -34,14 +34,13 @@ namespace Saga2 {
* ===================================================================== */
typedef gPalette *gPalettePtr;
-typedef gPalette **gPaletteHandle;
/* ===================================================================== *
Exports
* ===================================================================== */
// Global palette resource handles
-extern gPaletteHandle midnightPalette,
+extern gPalettePtr midnightPalette,
noonPalette,
darkPalette;
diff --git a/engines/saga2/transit.cpp b/engines/saga2/transit.cpp
index 556d4a8b56..e0f1adb7b0 100644
--- a/engines/saga2/transit.cpp
+++ b/engines/saga2/transit.cpp
@@ -89,8 +89,8 @@ void dayNightUpdate(void) {
createPalette(
&newPalette,
- *midnightPalette,
- *noonPalette,
+ midnightPalette,
+ noonPalette,
lightLevel,
MAX_LIGHT);
@@ -102,7 +102,7 @@ void dayNightUpdate(void) {
gPalettePtr neededPalette;
gPalette currentPalette;
- neededPalette = currentMapNum == 0 ? &newPalette : *noonPalette;
+ neededPalette = currentMapNum == 0 ? &newPalette : noonPalette;
getCurrentPalette(¤tPalette);
if (memcmp(¤tPalette, neededPalette, sizeof(gPalette)) != 0)
setCurrentPalette(neededPalette);
@@ -128,7 +128,7 @@ void enableUserControls(void);
void fadeDown(void) {
if (fadeDepth++ == 0) {
- beginFade(*darkPalette, 20);
+ beginFade(darkPalette, 20);
while (updatePalette());
clearTileAreaPort();
blackOut();
@@ -146,7 +146,7 @@ void fadeUp(void) {
drawMainDisplay();
reDrawScreen();
enablePaletteChanges();
- beginFade(currentMapNum != 0 ? *noonPalette : &newPalette, 20);
+ beginFade(currentMapNum != 0 ? noonPalette : &newPalette, 20);
while (updatePalette()) ;
}
}
diff --git a/engines/saga2/vpal.cpp b/engines/saga2/vpal.cpp
index 0e3e12dae7..018485b2ed 100644
--- a/engines/saga2/vpal.cpp
+++ b/engines/saga2/vpal.cpp
@@ -40,7 +40,7 @@
namespace Saga2 {
-const uint32 paletteID = RES_ID('P', 'A', 'L', 0);
+const uint32 paletteID = MKTAG('P', 'A', 'L', 0);
/* ===================================================================== *
Imports
@@ -67,8 +67,8 @@ struct PaletteStateArchive {
void lightsOut(void);
-gPaletteHandle midnightPalette,
- noonPalette = NULL,
+gPalettePtr midnightPalette,
+ noonPalette = nullptr,
darkPalette;
/* ===================================================================== *
@@ -111,57 +111,48 @@ void loadPalettes(void) {
int i;
// Create a black palette for fades
- darkPalette = (gPaletteHandle)RNewHandle(
- sizeof(gPalette),
- NULL,
- "dark palette");
- memset(*darkPalette, 0, sizeof(gPalette));
+ darkPalette = new gPalette;
+ memset(darkPalette, 0, sizeof(gPalette));
// Load standard palette
- noonPalette = (gPaletteHandle)LoadResourceToHandle(
- tileRes,
- paletteID,
- "noon palette");
+ noonPalette = (gPalettePtr)LoadResource(tileRes, paletteID, "noon palette");
// Create a midnight palette for night time effect
- midnightPalette = (gPaletteHandle)RNewHandle(
- sizeof(gPalette),
- NULL,
- "midnight palette");
+ midnightPalette = new gPalette;
- gPalette *dayPal = *noonPalette;
- gPalette *nightPal = *midnightPalette;
+ gPalette *dayPal = noonPalette;
+ gPalette *nightPal = midnightPalette;
// these colors darkened
for (i = 10; i < 240; i++) {
-// nightPal->entry[ i ].r = dayPal->entry[ i ].r / 2;
-// nightPal->entry[ i ].g = dayPal->entry[ i ].g * 2 / 3;
-// nightPal->entry[ i ].b = dayPal->entry[ i ].b;
+// nightPal->entry[i].r = dayPal->entry[i].r / 2;
+// nightPal->entry[i].g = dayPal->entry[i].g * 2 / 3;
+// nightPal->entry[i].b = dayPal->entry[i].b;
- nightPal->entry[ i ].r = dayPal->entry[ i ].r / 3;
- nightPal->entry[ i ].g = dayPal->entry[ i ].g / 2;
- nightPal->entry[ i ].b = bscale(dayPal->entry[ i ].b);
+ nightPal->entry[i].r = dayPal->entry[i].r / 3;
+ nightPal->entry[i].g = dayPal->entry[i].g / 2;
+ nightPal->entry[i].b = bscale(dayPal->entry[i].b);
}
// these colors are not
for (i = 0; i < 10; i++) {
- nightPal->entry[ i ].r = dayPal->entry[ i ].r;
- nightPal->entry[ i ].g = dayPal->entry[ i ].g;
- nightPal->entry[ i ].b = dayPal->entry[ i ].b;
+ nightPal->entry[i].r = dayPal->entry[i].r;
+ nightPal->entry[i].g = dayPal->entry[i].g;
+ nightPal->entry[i].b = dayPal->entry[i].b;
}
// and these colors are not
for (i = 240; i < 256; i++) {
- nightPal->entry[ i ].r = dayPal->entry[ i ].r;
- nightPal->entry[ i ].g = dayPal->entry[ i ].g;
- nightPal->entry[ i ].b = dayPal->entry[ i ].b;
+ nightPal->entry[i].r = dayPal->entry[i].r;
+ nightPal->entry[i].g = dayPal->entry[i].g;
+ nightPal->entry[i].b = dayPal->entry[i].b;
}
// single color additions to palette shift
- nightPal->entry[ 244 ].r = dayPal->entry[ 244 ].r / 3;
- nightPal->entry[ 244 ].g = dayPal->entry[ 244 ].g / 2;
- nightPal->entry[ 244 ].b = bscale(dayPal->entry[ 244 ].b);
+ nightPal->entry[244].r = dayPal->entry[244].r / 3;
+ nightPal->entry[244].g = dayPal->entry[244].g / 2;
+ nightPal->entry[244].b = bscale(dayPal->entry[244].b);
}
//----------------------------------------------------------------------
@@ -170,17 +161,17 @@ void loadPalettes(void) {
void cleanupPalettes(void) {
if (noonPalette) {
RDisposeHandle((RHANDLE) noonPalette);
- noonPalette = NULL;
+ noonPalette = nullptr;
}
if (darkPalette) {
- RDisposeHandle((RHANDLE) darkPalette);
- darkPalette = NULL;
+ delete darkPalette;
+ darkPalette = nullptr;
}
if (midnightPalette) {
- RDisposeHandle((RHANDLE) midnightPalette);
- midnightPalette = NULL;
+ delete midnightPalette;
+ midnightPalette = nullptr;
}
}
@@ -206,14 +197,14 @@ bool updatePalette() {
elapsedTime = gameTime - startTime;
if (totalTime == 0)
- return FALSE;
+ return false;
if (elapsedTime >= totalTime) {
// Fade is completed
totalTime = 0;
memcpy(¤tPalette, &destPalette, sizeof(gPalette));
assertCurrentPalette();
- return FALSE;
+ return false;
} else {
gPalette tempPalette;
@@ -233,7 +224,7 @@ bool updatePalette() {
assertCurrentPalette();
}
- return TRUE;
+ return true;
}
}
@@ -252,9 +243,9 @@ void createPalette(
uint32 fadeProgress = (elapsedTime << 8) / totalTime;
for (i = 0; i < elementsof(newP->entry); i++) {
- gPaletteEntry *srcPal = &srcP->entry[ i ];
- gPaletteEntry *dstPal = &dstP->entry[ i ];
- gPaletteEntry *curPal = &newP->entry[ i ];
+ gPaletteEntry *srcPal = &srcP->entry[i];
+ gPaletteEntry *dstPal = &dstP->entry[i];
+ gPaletteEntry *curPal = &newP->entry[i];
// Linearly interpolate between the source and end palette.
curPal->r = srcPal->r + (((dstPal->r - srcPal->r) * fadeProgress) >> 8);
@@ -281,7 +272,7 @@ void getCurrentPalette(gPalettePtr pal) {
//----------------------------------------------------------------------
void setPaletteToBlack(void) {
- setCurrentPalette(*darkPalette);
+ setCurrentPalette(darkPalette);
}
@@ -302,7 +293,7 @@ void lightsOut(void) {
}
void lightsOn(void) {
- setCurrentPalette(*noonPalette);
+ setCurrentPalette(noonPalette);
totalTime = startTime = 0;
assertCurrentPalette();
}
Commit: 3e0d5ec5cd71c6eecf67678c76525c97e0818e40
https://github.com/scummvm/scummvm/commit/3e0d5ec5cd71c6eecf67678c76525c97e0818e40
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:57+02:00
Commit Message:
SAGA2: Fix panel loading
Changed paths:
engines/saga2/panel.cpp
diff --git a/engines/saga2/panel.cpp b/engines/saga2/panel.cpp
index 8786c68d43..6016f32d0f 100644
--- a/engines/saga2/panel.cpp
+++ b/engines/saga2/panel.cpp
@@ -40,6 +40,7 @@ namespace Saga2 {
//extern vDisplayPage *drawPage;
extern gMousePointer pointer; // the actual pointer
extern char iniFile[];
+extern vDisplayPage protoPage;
// Function to enable/disable user interface keys
extern bool enableUIKeys(bool enabled);
@@ -1076,6 +1077,7 @@ void EventLoop( bool &running )
* ===================================================================== */
void initPanels(gDisplayPort &port) {
+ port.setDisplayPage(&protoPage);
globalPort = &port;
InitMouse(gDisplaySize.x, gDisplaySize.y);
mainFont = &Helv11Font;
Commit: 392690a107ccb4dd0f4b3aaf724fd4e6ec03ca3d
https://github.com/scummvm/scummvm/commit/392690a107ccb4dd0f4b3aaf724fd4e6ec03ca3d
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:57+02:00
Commit Message:
SAGA2: Fix RES_ID calls
Changed paths:
engines/saga2/objects.cpp
engines/saga2/oncall.h
engines/saga2/patrol.cpp
engines/saga2/speech.cpp
engines/saga2/spelcast.cpp
engines/saga2/speldata.cpp
engines/saga2/sprite.cpp
engines/saga2/videobox.cpp
engines/saga2/weapons.cpp
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 33efa16a72..a7344e3f46 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -62,11 +62,11 @@ APPFUNC(cmdControl);
Resource ID constants
* ===================================================================== */
-const uint32 nameListID = RES_ID('N', 'A', 'M', 'E'),
- objListID = RES_ID('O', 'B', 'J', 'E'),
- worldListID = RES_ID('W', 'R', 'L', 'D'),
- objProtoID = RES_ID('P', 'R', 'O', 0),
- actorProtoID = RES_ID('P', 'R', 'O', 1);
+const uint32 nameListID = MKTAG('N', 'A', 'M', 'E'),
+ objListID = MKTAG('O', 'B', 'J', 'E'),
+ worldListID = MKTAG('W', 'R', 'L', 'D'),
+ objProtoID = MKTAG('P', 'R', 'O', 0),
+ actorProtoID = MKTAG('P', 'R', 'O', 1);
/* ===================================================================== *
Locals
@@ -151,7 +151,7 @@ extern SpellStuff spellBook[];
extern DisplayNodeList mainDisplayList;
extern ObjectID pickedObject;
-const uint32 imageGroupID = RES_ID('I', 'M', 'A', 'G');
+const uint32 imageGroupID = MKTAG('I', 'M', 'A', 'G');
extern TilePoint incDirTable[];
@@ -2366,7 +2366,7 @@ uint16 GameObject::totalContainedBulk(void) {
// Initial constructor
GameWorld::GameWorld(int16 map) {
- if (tileRes->seek(RES_ID('M', 'A', 'P', (char)map))) {
+ if (tileRes->seek(MKTAG('M', 'A', 'P', (char)map))) {
int16 mapSize; // Size of map in MetaTiles
tileRes->read(&mapSize, sizeof(mapSize));
@@ -2679,7 +2679,7 @@ void initObjectSoundFXTable(void) {
hResContext *itemRes;
itemRes = auxResFile->newContext(
- RES_ID('I', 'T', 'E', 'M'),
+ MKTAG('I', 'T', 'E', 'M'),
"item resources");
if (itemRes == NULL || !itemRes->_valid)
error("Error accessing item resource group.\n");
@@ -2687,7 +2687,7 @@ void initObjectSoundFXTable(void) {
objectSoundFXTable =
(ObjectSoundFXs *)LoadResource(
itemRes,
- RES_ID('S', 'N', 'D', 'T'),
+ MKTAG('S', 'N', 'D', 'T'),
"object sound effect table");
if (objectSoundFXTable == NULL)
diff --git a/engines/saga2/oncall.h b/engines/saga2/oncall.h
index e3863b54b7..89fbd0982f 100644
--- a/engines/saga2/oncall.h
+++ b/engines/saga2/oncall.h
@@ -138,8 +138,8 @@ template <class RESTYPE> RESTYPE LoadOnCall<RESTYPE>::rLoad(uint16 ind, bool asy
return NULL;
}
- //t = (RESTYPE) tileRes->load( tileID + RES_ID( 0,0,0,bankNum ) );
- t = (RESTYPE) loader(tileID + RES_ID(0, 0, 0, ind), asynch);
+ //t = (RESTYPE) tileRes->load( tileID + MKTAG( 0,0,0,bankNum ) );
+ t = (RESTYPE) loader(tileID + MKTAG(0, 0, 0, ind), asynch);
locked.Bit(ind, !asynch);
wanted.Bit(ind, asynch);
@@ -168,7 +168,7 @@ template <class RESTYPE> void LoadOnCall<RESTYPE>::rFree(uint16 ind) {
template <class RESTYPE> void LoadOnCall<RESTYPE>::rInit(uint16 ind) {
RESTYPE t;
if (!isValidPtr(handle[ ind ])) {
- t = (RESTYPE) loader(tileID + RES_ID(0, 0, 0, ind), FALSE);
+ t = (RESTYPE) loader(tileID + MKTAG(0, 0, 0, ind), FALSE);
handle[ ind ] = t;
locked.Bit(ind, TRUE);
RUnlockHandle((RHANDLE) handle[ ind ]);
diff --git a/engines/saga2/patrol.cpp b/engines/saga2/patrol.cpp
index c53486fe85..02c4adf2db 100644
--- a/engines/saga2/patrol.cpp
+++ b/engines/saga2/patrol.cpp
@@ -271,7 +271,7 @@ void initPatrolRoutes(void) {
// Get patrol route resource context
patrolRouteRes = auxResFile->newContext(
- RES_ID('P', 'T', 'R', 'L'),
+ MKTAG('P', 'T', 'R', 'L'),
"patrol route resource");
if (patrolRouteRes == NULL || !patrolRouteRes->_valid)
error("Error accessing patrol route resource group.");
@@ -303,11 +303,11 @@ void initPatrolRoutes(void) {
// Load this worlds's patrol routes
if (patrolRouteRes->size(
- RES_ID('R', 'T', 'E', i)) > 0) {
+ MKTAG('R', 'T', 'E', i)) > 0) {
patrolRouteData[ i ] =
(PatrolRouteData *)LoadResource(
patrolRouteRes,
- RES_ID('R', 'T', 'E', i),
+ MKTAG('R', 'T', 'E', i),
"patrol route data");
if (patrolRouteData[ i ] == NULL)
diff --git a/engines/saga2/speech.cpp b/engines/saga2/speech.cpp
index be53940597..26f3e1fa36 100644
--- a/engines/saga2/speech.cpp
+++ b/engines/saga2/speech.cpp
@@ -149,7 +149,7 @@ static char convBuf[5];
inline uint32 extendID(int16 smallID) {
sprintf(convBuf, "%4.4d", smallID);
- return smallID ? RES_ID(convBuf[0] + 'A' - '0', convBuf[1], convBuf[2], convBuf[3]) : 0 ;
+ return smallID ? MKTAG(convBuf[0] + 'A' - '0', convBuf[1], convBuf[2], convBuf[3]) : 0 ;
}
/* ===================================================================== *
diff --git a/engines/saga2/spelcast.cpp b/engines/saga2/spelcast.cpp
index 4f3333cbfa..f2382fea16 100644
--- a/engines/saga2/spelcast.cpp
+++ b/engines/saga2/spelcast.cpp
@@ -133,7 +133,7 @@ void SpellStuff::addEffect(ProtoEffect *pe) {
void SpellStuff::playSound(GameObject *go) {
if (sound) {
Location cal = go->notGetWorldLocation(); //Location(go->getLocation(),go->IDParent());
- Saga2::playSoundAt(RES_ID('S', 'P', 'L', sound), cal);
+ Saga2::playSoundAt(MKTAG('S', 'P', 'L', sound), cal);
}
}
diff --git a/engines/saga2/speldata.cpp b/engines/saga2/speldata.cpp
index 43f3eef7f6..7c107fc70f 100644
--- a/engines/saga2/speldata.cpp
+++ b/engines/saga2/speldata.cpp
@@ -52,7 +52,7 @@ namespace Saga2 {
Constants
* ===================================================================== */
-const uint32 spellSpriteID = RES_ID('S', 'P', 'F', 'X');
+const uint32 spellSpriteID = MKTAG('S', 'P', 'F', 'X');
const int32 maxSpells = totalSpellBookPages;
const int32 maxSpellPrototypes = totalSpellBookPages;
@@ -199,21 +199,21 @@ static void loadMagicData(void) {
// Get spell definitions
spellRes = auxResFile->newContext(
- RES_ID('S', 'P', 'E', 'L'),
+ MKTAG('S', 'P', 'E', 'L'),
"spell resources");
if (spellRes == NULL || !spellRes->_valid)
error("Error accessing spell resource group.\n");
i = 1;
- ADD_SHOW(eAreaInvisible, 0, 0, 0, 0, diFlagInc, ecFlagNone, 30, RES_ID('S', 'T', 'A', 0), 23, 24);
+ ADD_SHOW(eAreaInvisible, 0, 0, 0, 0, diFlagInc, ecFlagNone, 30, MKTAG('S', 'T', 'A', 0), 23, 24);
spellBook[0].setManaType(sManaIDSkill);
while (spellRes->size(
- RES_ID('I', 'N', 'F', i)) > 0) {
+ MKTAG('I', 'N', 'F', i)) > 0) {
ResourceSpellItem *rsi =
(ResourceSpellItem *)LoadResource(
spellRes,
- RES_ID('I', 'N', 'F', i),
+ MKTAG('I', 'N', 'F', i),
"spell");
if (rsi == NULL)
@@ -230,11 +230,11 @@ static void loadMagicData(void) {
// get spell effects
i = 0;
while (spellRes->size(
- RES_ID('E', 'F', 'F', i)) > 0) {
+ MKTAG('E', 'F', 'F', i)) > 0) {
ResourceSpellEffect *rse =
(ResourceSpellEffect *)LoadResource(
spellRes,
- RES_ID('E', 'F', 'F', i),
+ MKTAG('E', 'F', 'F', i),
"spell effect");
if (rse == NULL)
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index e8a60dc147..c9f2425e94 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -39,14 +39,14 @@ namespace Saga2 {
const int maxWeaponSpriteSets = 40;
-const uint32 spriteGroupID = RES_ID('S', 'P', 'R', 'I'),
- frameGroupID = RES_ID('F', 'R', 'M', 'L'),
- poseGroupID = RES_ID('P', 'O', 'S', 'E'),
- schemeGroupID = RES_ID('S', 'C', 'H', 'M'),
- objectSpriteID = RES_ID('O', 'B', 'J', 'S'),
- mentalSpriteID = RES_ID('M', 'E', 'N', 'T'),
- weaponSpriteBaseID = RES_ID('W', 'P', 'N', 0),
- missileSpriteID = RES_ID('M', 'I', 'S', 'S');
+const uint32 spriteGroupID = MKTAG('S', 'P', 'R', 'I'),
+ frameGroupID = MKTAG('F', 'R', 'M', 'L'),
+ poseGroupID = MKTAG('P', 'O', 'S', 'E'),
+ schemeGroupID = MKTAG('S', 'C', 'H', 'M'),
+ objectSpriteID = MKTAG('O', 'B', 'J', 'S'),
+ mentalSpriteID = MKTAG('M', 'E', 'N', 'T'),
+ weaponSpriteBaseID = MKTAG('W', 'P', 'N', 0),
+ missileSpriteID = MKTAG('M', 'I', 'S', 'S');
/* ===================================================================== *
Prototypes
@@ -620,7 +620,7 @@ void ActorAppearance::loadSpriteBanks(int16 banksNeeded) {
// Load the sprite handle...
if (spriteBanks[bank] == NULL && (banksNeeded & (1 << bank))) {
- spriteBanks[bank] = (SpriteSet **)spriteRes->load(id + RES_ID(0, 0, 0, bank), "sprite bank", FALSE);
+ spriteBanks[bank] = (SpriteSet **)spriteRes->load(id + MKTAG(0, 0, 0, bank), "sprite bank", FALSE);
#if DEBUG
if (spriteBanks[bank] == NULL)
@@ -751,7 +751,7 @@ void initSprites(void) {
for (i = 0; i < maxWeaponSpriteSets; i++) {
hResID weaponSpriteID;
- weaponSpriteID = weaponSpriteBaseID + RES_ID(0, 0, 0, i);
+ weaponSpriteID = weaponSpriteBaseID + MKTAG(0, 0, 0, i);
if (spriteRes->size(weaponSpriteID) == 0) {
weaponSprites[i] = NULL;
diff --git a/engines/saga2/videobox.cpp b/engines/saga2/videobox.cpp
index e405e1faa0..874ae512fb 100644
--- a/engines/saga2/videobox.cpp
+++ b/engines/saga2/videobox.cpp
@@ -135,7 +135,7 @@ void CVideoBox::init(void) {
rInfo.running = TRUE;
// init the resource context handle
- decRes = resFile->newContext(RES_ID('V', 'I', 'D', 'O'),
+ decRes = resFile->newContext(MKTAG('V', 'I', 'D', 'O'),
"Video border resources");
diff --git a/engines/saga2/weapons.cpp b/engines/saga2/weapons.cpp
index 83d397c73a..37b5ddf15c 100644
--- a/engines/saga2/weapons.cpp
+++ b/engines/saga2/weapons.cpp
@@ -322,7 +322,7 @@ static void loadWeaponData(void) {
// Get spell definitions
spellRes = auxResFile->newContext(
- RES_ID('I', 'T', 'E', 'M'),
+ MKTAG('I', 'T', 'E', 'M'),
"weapon resources");
if (spellRes == NULL || !spellRes->_valid)
error("Error accessing weapon resource group.");
@@ -330,11 +330,11 @@ static void loadWeaponData(void) {
// get spell effects
i = 0;
while (spellRes->size(
- RES_ID('E', 'F', 'F', i)) > 0) {
+ MKTAG('E', 'F', 'F', i)) > 0) {
ResourceItemEffect *rie =
(ResourceItemEffect *)LoadResource(
spellRes,
- RES_ID('E', 'F', 'F', i),
+ MKTAG('E', 'F', 'F', i),
"weapon effect");
if (rie == NULL)
Commit: 6d3cc8c9e4e66b0f8eb1e36b025eab329ba948b6
https://github.com/scummvm/scummvm/commit/6d3cc8c9e4e66b0f8eb1e36b025eab329ba948b6
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:57+02:00
Commit Message:
SAGA2: Fix Route Data initialization
Changed paths:
engines/saga2/patrol.cpp
diff --git a/engines/saga2/patrol.cpp b/engines/saga2/patrol.cpp
index 02c4adf2db..9d32b2bd53 100644
--- a/engines/saga2/patrol.cpp
+++ b/engines/saga2/patrol.cpp
@@ -35,13 +35,15 @@
namespace Saga2 {
+typedef PatrolRouteData *PatrolRouteDataPtr;
+
extern int16 worldCount; // Number of worlds
/* ===================================================================== *
Exports
* ===================================================================== */
-PatrolRouteList *patrolRouteList = NULL; // Global patrol route array
+PatrolRouteList *patrolRouteList = nullptr; // Global patrol route array
/* ===================================================================== *
Globals
@@ -52,7 +54,7 @@ static PatrolRouteData **patrolRouteData; // Data for patrol routes
// Returns a const reference to a specified way point
const TilePoint &PatrolRoute::operator [](int16 index) const {
- return *((TilePoint *)&this[ 1 ] + index);
+ return *((TilePoint *)&this[1] + index);
}
@@ -66,11 +68,11 @@ const TilePoint &PatrolRoute::operator [](int16 index) const {
void PatrolRouteList::clearRouteData(void) {
// If there is an offset array deallocated it.
if (offsetArray) {
- RDisposePtr(offsetArray);
- offsetArray = NULL;
+ delete[] offsetArray;
+ offsetArray = nullptr;
}
- routeData = NULL;
+ routeData = nullptr;
}
//-----------------------------------------------------------------------
@@ -81,32 +83,29 @@ void PatrolRouteList::setRouteData(PatrolRouteData *data) {
noRoutes = data->routes;
PatrolRoute *currentRoute;
- // If routeData is NULL simply return
- if ((routeData = data) == NULL) {
- offsetArray = NULL;
+ // If routeData is nullptr simply return
+ if ((routeData = data) == nullptr) {
+ offsetArray = nullptr;
return;
}
// Allocate a new offsetArray
- offsetArray = (int32 *)RNewPtr(
- noRoutes * sizeof(int32),
- NULL,
- "patrol route offset array");
+ offsetArray = new int32[noRoutes]();
- if (offsetArray == NULL)
+ if (offsetArray == nullptr)
error("Cannot allocate patrol route list offset array.");
// Iterate through each patrol route a compute its offset
- for (i = 0, currentRoute = (PatrolRoute *)&routeData[ 1 ];
+ for (i = 0, currentRoute = (PatrolRoute *)&routeData[1];
i < noRoutes;
i++,
currentRoute =
- (PatrolRoute *) & (*currentRoute)[ currentRoute->vertices() ]) {
+ (PatrolRoute *) & (*currentRoute)[currentRoute->vertices()]) {
#if DEBUG
assert(currentRoute->vertices() > 1);
#endif
warning("STUB: PatrolRouteList::setRouteData: unsafe arithmetics");
- offsetArray[ i ] = 0; // FIXME: It was "currentRoute - routeData";
+ offsetArray[i] = 0; // FIXME: It was "currentRoute - routeData";
}
}
@@ -121,7 +120,7 @@ PatrolRouteIterator::PatrolRouteIterator(uint8 map, int16 rte, uint8 type) :
mapNum(map),
routeNo(rte),
flags(type & 0xF) {
- const PatrolRoute &route = patrolRouteList[ mapNum ][ routeNo ];
+ const PatrolRoute &route = patrolRouteList[mapNum][routeNo];
if (flags & patrolRouteRandom)
vertexNo = rand() % route.vertices();
@@ -141,7 +140,7 @@ PatrolRouteIterator::PatrolRouteIterator(
mapNum(map),
routeNo(rte),
flags(type & 0xF) {
- const PatrolRoute &route = patrolRouteList[ mapNum ][ routeNo ];
+ const PatrolRoute &route = patrolRouteList[mapNum][routeNo];
vertexNo = clamp(0, startingPoint, route.vertices() - 1);
}
@@ -150,7 +149,7 @@ PatrolRouteIterator::PatrolRouteIterator(
// Increment the waypoint index
void PatrolRouteIterator::increment(void) {
- const PatrolRoute &route = patrolRouteList[ mapNum ][ routeNo ];
+ const PatrolRoute &route = patrolRouteList[mapNum][routeNo];
vertexNo++;
@@ -170,7 +169,7 @@ void PatrolRouteIterator::increment(void) {
// Decrement the waypoint index
void PatrolRouteIterator::decrement(void) {
- const PatrolRoute &route = patrolRouteList[ mapNum ][ routeNo ];
+ const PatrolRoute &route = patrolRouteList[mapNum][routeNo];
vertexNo--;
@@ -190,7 +189,7 @@ void PatrolRouteIterator::decrement(void) {
// Increment the waypoint index in the alternate direction
void PatrolRouteIterator::altIncrement(void) {
- const PatrolRoute &route = patrolRouteList[ mapNum ][ routeNo ];
+ const PatrolRoute &route = patrolRouteList[mapNum][routeNo];
vertexNo++;
@@ -207,7 +206,7 @@ void PatrolRouteIterator::altIncrement(void) {
// Decrement the waypoint index in the alternate direction
void PatrolRouteIterator::altDecrement(void) {
- const PatrolRoute &route = patrolRouteList[ mapNum ][ routeNo ];
+ const PatrolRoute &route = patrolRouteList[mapNum][routeNo];
vertexNo--;
@@ -224,10 +223,10 @@ void PatrolRouteIterator::altDecrement(void) {
// Return the coordinates of the current waypoint
const TilePoint &PatrolRouteIterator::operator * (void) const {
- const PatrolRoute &route = patrolRouteList[ mapNum ][ routeNo ];
+ const PatrolRoute &route = patrolRouteList[mapNum][routeNo];
return vertexNo >= 0 && vertexNo < route.vertices()
- ? route[ vertexNo ]
+ ? route[vertexNo]
: Nowhere;
}
@@ -235,7 +234,7 @@ const TilePoint &PatrolRouteIterator::operator * (void) const {
// Iterate
const PatrolRouteIterator &PatrolRouteIterator::operator ++ (void) {
- const PatrolRoute &route = patrolRouteList[ mapNum ][ routeNo ];
+ const PatrolRoute &route = patrolRouteList[mapNum][routeNo];
if (vertexNo >= 0 & vertexNo < route.vertices()) {
if (!(flags & patrolRouteRandom)) {
@@ -273,50 +272,43 @@ void initPatrolRoutes(void) {
patrolRouteRes = auxResFile->newContext(
MKTAG('P', 'T', 'R', 'L'),
"patrol route resource");
- if (patrolRouteRes == NULL || !patrolRouteRes->_valid)
+ if (patrolRouteRes == nullptr || !patrolRouteRes->_valid)
error("Error accessing patrol route resource group.");
// Allocate the patrol route list array
patrolRouteList =
- (PatrolRouteList *)RNewPtr(
- sizeof(PatrolRouteList) * worldCount,
- NULL,
- "patrol route list");
+ new PatrolRouteList[worldCount];
- if (patrolRouteList == NULL)
+ if (patrolRouteList == nullptr)
error("Unable to allocate the patrol route list");
// Allocate the patrol route data pointer array
- patrolRouteData =
- (PatrolRouteData **)RNewPtr(
- sizeof(PatrolRouteData *) * worldCount,
- NULL,
- "patrol route data pointers");
+ patrolRouteData = new PatrolRouteDataPtr[worldCount];
- if (patrolRouteData == NULL)
+ if (patrolRouteData == nullptr)
error("Unable to allocate the patrol route data pointers");
for (i = 0; i < worldCount; i++) {
// Initialize the patrol route data members
- patrolRouteList[ i ].routeData = NULL;
- patrolRouteList[ i ].offsetArray = NULL;
+ patrolRouteList[i].routeData = nullptr;
+ patrolRouteList[i].offsetArray = nullptr;
// Load this worlds's patrol routes
if (patrolRouteRes->size(
MKTAG('R', 'T', 'E', i)) > 0) {
- patrolRouteData[ i ] =
+ patrolRouteData[i] =
(PatrolRouteData *)LoadResource(
patrolRouteRes,
MKTAG('R', 'T', 'E', i),
"patrol route data");
- if (patrolRouteData[ i ] == NULL)
+ if (patrolRouteData[i] == nullptr)
error("Unable to load the patrol route data");
// Initialize the PatrolRouteList with the resource data
- patrolRouteList[ i ].setRouteData(patrolRouteData[ i ]);
+ patrolRouteList[i].setRouteData(patrolRouteData[i]);
} else
- patrolRouteData[ i ] = NULL;
+ patrolRouteData[i] = nullptr;
}
// Dispose of the patrol route resource context
@@ -331,15 +323,16 @@ void cleanupPatrolRoutes(void) {
// Cleanup the patrol route list
for (i = 0; i < worldCount; i++) {
- patrolRouteList[ i ].clearRouteData();
- RDisposePtr(patrolRouteData[ i ]);
+ patrolRouteList[i].clearRouteData();
+ if (patrolRouteData[i])
+ free(patrolRouteData[i]);
}
// Deallocate the patrol route data pointer list
- RDisposePtr(patrolRouteData);
+ delete[] patrolRouteData;
// Deallocate the patrol route list
- RDisposePtr(patrolRouteList);
+ delete[] patrolRouteList;
}
} // end of namespace Saga2
Commit: 4a5b055e106535f291500437dd576773f84bf044
https://github.com/scummvm/scummvm/commit/4a5b055e106535f291500437dd576773f84bf044
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:57+02:00
Commit Message:
SAGA2: Reduce header dependencies
Changed paths:
R engines/saga2/exit.cpp
engines/saga2/assign.cpp
engines/saga2/audiobuf.cpp
engines/saga2/audiores.cpp
engines/saga2/automap.cpp
engines/saga2/beegee.cpp
engines/saga2/blitters.cpp
engines/saga2/button.cpp
engines/saga2/calender.cpp
engines/saga2/cmisc.h
engines/saga2/config.cpp
engines/saga2/contain.cpp
engines/saga2/display.cpp
engines/saga2/dispnode.cpp
engines/saga2/dlist.cpp
engines/saga2/document.cpp
engines/saga2/effects.cpp
engines/saga2/enchant.cpp
engines/saga2/floating.cpp
engines/saga2/gamemode.cpp
engines/saga2/gpointer.cpp
engines/saga2/grabinfo.cpp
engines/saga2/grequest.cpp
engines/saga2/gtext.cpp
engines/saga2/gtextbox.cpp
engines/saga2/hresmgr.cpp
engines/saga2/imagcach.cpp
engines/saga2/images.cpp
engines/saga2/input.cpp
engines/saga2/interp.cpp
engines/saga2/intrface.cpp
engines/saga2/keybored.cpp
engines/saga2/loadmsg.cpp
engines/saga2/loadsave.cpp
engines/saga2/main.cpp
engines/saga2/mainmap.h
engines/saga2/module.mk
diff --git a/engines/saga2/assign.cpp b/engines/saga2/assign.cpp
index 2ad3e8de9e..4ba28b614b 100644
--- a/engines/saga2/assign.cpp
+++ b/engines/saga2/assign.cpp
@@ -24,12 +24,6 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-/* ===================================================================== *
- Includes
- * ===================================================================== */
-
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/actor.h"
#include "saga2/assign.h"
diff --git a/engines/saga2/audiobuf.cpp b/engines/saga2/audiobuf.cpp
index 91b677bed9..6854d9233c 100644
--- a/engines/saga2/audiobuf.cpp
+++ b/engines/saga2/audiobuf.cpp
@@ -24,8 +24,6 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/audio.h"
diff --git a/engines/saga2/audiores.cpp b/engines/saga2/audiores.cpp
index b163c0ab9a..8acf414888 100644
--- a/engines/saga2/audiores.cpp
+++ b/engines/saga2/audiores.cpp
@@ -24,14 +24,11 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/audio.h"
#include "saga2/hresmgr.h"
-#include "saga2/audiores.h"
#include "saga2/audiodec.h"
-#include "saga2/fta.h"
+#include "saga2/rect.h"
#include "saga2/queues.h"
#include "saga2/idtypes.h"
diff --git a/engines/saga2/automap.cpp b/engines/saga2/automap.cpp
index e26e13376c..98d68d914b 100644
--- a/engines/saga2/automap.cpp
+++ b/engines/saga2/automap.cpp
@@ -24,15 +24,10 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
-#include "saga2/hresmgr.h"
#include "saga2/automap.h"
#include "saga2/blitters.h"
#include "saga2/tile.h"
-#include "saga2/objects.h"
-#include "saga2/player.h"
#include "saga2/grequest.h"
#include "saga2/mapfeatr.h"
#include "saga2/grabinfo.h"
diff --git a/engines/saga2/beegee.cpp b/engines/saga2/beegee.cpp
index a6cd94570f..172ab4c312 100644
--- a/engines/saga2/beegee.cpp
+++ b/engines/saga2/beegee.cpp
@@ -24,19 +24,10 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/idtypes.h"
-#include "saga2/fta.h"
#include "saga2/tile.h"
-#include "saga2/annoy.h"
-#include "saga2/audio.h"
-#include "saga2/beegee.h"
-#include "saga2/actor.h"
#include "saga2/music.h"
-#include "saga2/messager.h"
-#include "saga2/tileline.h"
#include "saga2/player.h"
#include "saga2/audtweak.h"
@@ -302,7 +293,7 @@ void audioEnvironmentCheck(void) {
totalProb += iar.soundOdds[i];
if (totalProb <= iar.noSoundOdds)
return;
- int32 pval = rand() % totalProb;
+ int32 pval = g_vm->_rnd->getRandomNumber(totalProb - 1);
if (pval < iar.noSoundOdds)
return;
pval -= iar.noSoundOdds;
@@ -350,7 +341,7 @@ void Deejay::select(void) {
//else if ( !day )
// choice=4;
else if (current != 4 && (current > 2 || current < 1)) {
- choice = 1 + (rand() % 3);
+ choice = 1 + g_vm->_rnd->getRandomNumber(2);
if (choice == 3) choice++;
} else
choice = current;
diff --git a/engines/saga2/blitters.cpp b/engines/saga2/blitters.cpp
index e050164347..76b3af5c79 100644
--- a/engines/saga2/blitters.cpp
+++ b/engines/saga2/blitters.cpp
@@ -24,13 +24,9 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "common/debug.h"
#include "saga2/std.h"
-#include "saga2/saga2.h"
-#include "saga2/blitters.h"
#include "saga2/gdraw.h"
namespace Saga2 {
diff --git a/engines/saga2/button.cpp b/engines/saga2/button.cpp
index 5596f6dace..0a7a101b32 100644
--- a/engines/saga2/button.cpp
+++ b/engines/saga2/button.cpp
@@ -24,16 +24,11 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/fta.h"
-#include "saga2/cmisc.h"
#include "saga2/hresmgr.h"
#include "saga2/button.h"
-#include "saga2/rmem.h"
#include "saga2/objects.h"
-#include "saga2/grabinfo.h"
#include "saga2/fontlib.h"
namespace Saga2 {
diff --git a/engines/saga2/calender.cpp b/engines/saga2/calender.cpp
index fda45ea1e6..18d1395f82 100644
--- a/engines/saga2/calender.cpp
+++ b/engines/saga2/calender.cpp
@@ -27,7 +27,6 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
-#include "saga2/hresmgr.h"
#include "saga2/calender.h"
#include "saga2/intrface.h"
#include "saga2/config.h"
diff --git a/engines/saga2/cmisc.h b/engines/saga2/cmisc.h
index 48a4f8d8bd..0d81e7535e 100644
--- a/engines/saga2/cmisc.h
+++ b/engines/saga2/cmisc.h
@@ -35,11 +35,6 @@ int32 clamp(int32 lowerLimit, int32 num, int32 upperLimit);
// Converts x/y point to angle + distance
int16 ptToAngle(int16 dx, int16 dy, int16 *dist = NULL);
-// Standardized "program exit" functions which can be
-// replaced for Windows or MPGNet programs.
-void normalExit(void);
-void failExit(void);
-
// Byte-swap a 16-bit integer
inline int16 swap16(uint16 w) {
return (w >> 8) | (w << 8);
diff --git a/engines/saga2/config.cpp b/engines/saga2/config.cpp
index 016b804566..60ff621ab0 100644
--- a/engines/saga2/config.cpp
+++ b/engines/saga2/config.cpp
@@ -24,15 +24,12 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/config.h"
-#include "saga2/program.h"
namespace Saga2 {
-char iniFile[] = PROGRAM_CONFIG_FILE;
+char iniFile[] = "FTA2.INI";
configuration globalConfig;
static char originalDir[ PATH_STR_SIZE ];
diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index 4ef993ddc4..e1a44c9107 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -31,13 +31,9 @@
#include "saga2/contain.h"
#include "saga2/grabinfo.h"
#include "saga2/motion.h"
-#include "saga2/images.h"
-#include "saga2/player.h"
-#include "saga2/cmisc.h"
#include "saga2/uimetrcs.h"
#include "saga2/localize.h"
#include "saga2/intrface.h"
-#include "saga2/magic.h"
#include "saga2/spellbuk.h"
#include "saga2/imagcach.h"
#include "saga2/hresmgr.h"
diff --git a/engines/saga2/display.cpp b/engines/saga2/display.cpp
index 35dbe04122..d82286dcf1 100644
--- a/engines/saga2/display.cpp
+++ b/engines/saga2/display.cpp
@@ -24,11 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/display.h"
-#include "saga2/floating.h"
#include "saga2/intrface.h"
#include "saga2/loadmsg.h"
#include "saga2/grabinfo.h"
diff --git a/engines/saga2/dispnode.cpp b/engines/saga2/dispnode.cpp
index 07c6e65d9b..c1b75e58ab 100644
--- a/engines/saga2/dispnode.cpp
+++ b/engines/saga2/dispnode.cpp
@@ -24,16 +24,9 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/blitters.h"
-#include "saga2/dispnode.h"
-#include "saga2/tile.h"
-#include "saga2/actor.h"
-#include "saga2/spells.h"
#include "saga2/spelshow.h"
-#include "saga2/spellbuk.h"
#include "saga2/images.h"
#include "saga2/player.h"
#include "saga2/sensor.h"
diff --git a/engines/saga2/dlist.cpp b/engines/saga2/dlist.cpp
index b1aa8ab370..d93411a355 100644
--- a/engines/saga2/dlist.cpp
+++ b/engines/saga2/dlist.cpp
@@ -24,8 +24,6 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/dlist.h"
diff --git a/engines/saga2/document.cpp b/engines/saga2/document.cpp
index 67626667fb..6f7148f58e 100644
--- a/engines/saga2/document.cpp
+++ b/engines/saga2/document.cpp
@@ -24,21 +24,14 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/document.h"
-#include "saga2/cmisc.h"
#include "saga2/script.h"
-#include "saga2/button.h"
#include "saga2/intrface.h"
#include "saga2/grequest.h"
#include "saga2/images.h"
#include "saga2/mouseimg.h"
-#include "saga2/script.h"
-#include "saga2/program.h"
#include "saga2/version.h"
-#include "saga2/hresmgr.h"
#include "saga2/fontlib.h"
namespace Saga2 {
diff --git a/engines/saga2/effects.cpp b/engines/saga2/effects.cpp
index d3f854bfa4..78a1c7596d 100644
--- a/engines/saga2/effects.cpp
+++ b/engines/saga2/effects.cpp
@@ -24,14 +24,9 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/cmisc.h"
-#include "saga2/spells.h"
#include "saga2/spelshow.h"
-#include "saga2/spellbuk.h"
-#include "saga2/idtypes.h"
#include "saga2/script.h"
#include "saga2/actor.h"
@@ -210,7 +205,7 @@ bool ProtoEnchantment::realSavingThrow(Actor *a) {
power *= power;
int32 saveSpace = absoluteMaximumVitality;
saveSpace *= saveSpace;
- return ((rand() % saveSpace) < power);
+ return (g_vm->_rnd->getRandomNumber(saveSpace - 1) < power);
}
diff --git a/engines/saga2/enchant.cpp b/engines/saga2/enchant.cpp
index 3dda57b7ae..14b8edf705 100644
--- a/engines/saga2/enchant.cpp
+++ b/engines/saga2/enchant.cpp
@@ -24,16 +24,11 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+//#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
-#include "saga2/objects.h"
-#include "saga2/actor.h"
#include "saga2/cmisc.h"
-#include "saga2/contain.h"
-#include "saga2/script.h"
#include "saga2/player.h"
-#include "saga2/target.h"
#include "saga2/enchant.h"
namespace Saga2 {
diff --git a/engines/saga2/exit.cpp b/engines/saga2/exit.cpp
deleted file mode 100644
index 08ecff06e5..0000000000
--- a/engines/saga2/exit.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * aint32 with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
-#include "saga2/std.h"
-
-namespace Saga2 {
-
-static bool loopCheck = FALSE;
-
-/****** exit.cpp/normalExit *******************************
-*
-* NAME
-* normalExit -- exits from program
-*
-* SYNOPSIS
-* normalExit();
-*
-* void normalExit( void );
-*
-* FUNCTION
-* This function exits the program. The DOS error state is
-* set to "No error". The "atexit" cleanup handler is called.
-* If, for some reason, the cleanup handler should call exit,
-* the call will be ignored.
-*
-* INPUTS
-* none
-*
-* SEE ALSO
-* failExit()
-*
-*******************************************************************/
-
-void normalExit(void) {
- if (loopCheck == FALSE) {
- loopCheck = TRUE;
- exit(EXIT_SUCCESS);
- }
-}
-
-
-/****** exit.cpp/failExit *******************************
-*
-* NAME
-* failExit -- exits from program
-*
-* SYNOPSIS
-* failExit();
-*
-* void failExit( void );
-*
-* FUNCTION
-* This function exits the program. The DOS error state is
-* set to EXIT_FAILURE. The "atexit" cleanup handler is called.
-* If, for some reason, the cleanup handler should call exit,
-* the call will be ignored.
-*
-* INPUTS
-* none
-*
-* SEE ALSO
-* normalExit()
-*
-*******************************************************************/
-
-void failExit(void) {
- if (loopCheck == FALSE) {
- loopCheck = TRUE;
- exit(EXIT_FAILURE);
- }
-}
-
-
-} // end of namespace Saga
diff --git a/engines/saga2/floating.cpp b/engines/saga2/floating.cpp
index 3fa151f868..77029fb218 100644
--- a/engines/saga2/floating.cpp
+++ b/engines/saga2/floating.cpp
@@ -24,15 +24,9 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
-#include "saga2/fta.h"
-#include "saga2/panel.h"
-#include "saga2/images.h"
#include "saga2/floating.h"
#include "saga2/objects.h"
-#include "saga2/contain.h"
#include "saga2/imagcach.h"
#include "saga2/grabinfo.h"
#include "saga2/display.h"
diff --git a/engines/saga2/gamemode.cpp b/engines/saga2/gamemode.cpp
index a7dfb254a6..428607a226 100644
--- a/engines/saga2/gamemode.cpp
+++ b/engines/saga2/gamemode.cpp
@@ -24,25 +24,10 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+//#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
-
-
-#include "saga2/fta.h"
-#include "saga2/audio.h"
-#include "saga2/panel.h"
#include "saga2/floating.h"
-#include "saga2/images.h"
-#include "saga2/setup.h"
-#include "saga2/vpal.h"
-#include "saga2/palette.h"
-#include "saga2/transit.h"
-#include "saga2/mouseimg.h"
-#include "saga2/player.h"
-#include "saga2/cmisc.h"
-#include "saga2/annoy.h"
-
namespace Saga2 {
diff --git a/engines/saga2/gpointer.cpp b/engines/saga2/gpointer.cpp
index 9a0f27bbde..649e2e7e77 100644
--- a/engines/saga2/gpointer.cpp
+++ b/engines/saga2/gpointer.cpp
@@ -25,9 +25,7 @@
*/
#include "saga2/std.h"
-#include "saga2/vdraw.h"
#include "saga2/gpointer.h"
-#include "saga2/input.h"
namespace Saga2 {
diff --git a/engines/saga2/grabinfo.cpp b/engines/saga2/grabinfo.cpp
index 76b5db4889..245770ebc8 100644
--- a/engines/saga2/grabinfo.cpp
+++ b/engines/saga2/grabinfo.cpp
@@ -24,17 +24,13 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/gdraw.h"
#include "saga2/images.h"
-#include "saga2/sprite.h"
#include "saga2/objects.h"
#include "saga2/contain.h"
#include "saga2/mouseimg.h"
#include "saga2/grabinfo.h"
-#include "saga2/methods.r"
namespace Saga2 {
diff --git a/engines/saga2/grequest.cpp b/engines/saga2/grequest.cpp
index c656e042f2..a2aaf64e7f 100644
--- a/engines/saga2/grequest.cpp
+++ b/engines/saga2/grequest.cpp
@@ -24,10 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
-#include "saga2/floating.h"
#include "saga2/grequest.h"
#include "saga2/modal.h"
#include "saga2/images.h"
diff --git a/engines/saga2/gtext.cpp b/engines/saga2/gtext.cpp
index 5335c86c31..d2f4dc4656 100644
--- a/engines/saga2/gtext.cpp
+++ b/engines/saga2/gtext.cpp
@@ -24,10 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
-#include "saga2/errors.h"
#include "saga2/gdraw.h"
namespace Saga2 {
diff --git a/engines/saga2/gtextbox.cpp b/engines/saga2/gtextbox.cpp
index 0cf7c72199..e847a182ab 100644
--- a/engines/saga2/gtextbox.cpp
+++ b/engines/saga2/gtextbox.cpp
@@ -24,8 +24,6 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/cmisc.h"
#include "saga2/fta.h"
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index 886030d8a0..c3c223dfea 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -24,13 +24,11 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+#include "common/debug.h"
#include "saga2/std.h"
-#include "saga2/saga2.h"
#include "saga2/hresmgr.h"
#include "saga2/fta.h"
-#include "common/debug.h"
namespace Saga2 {
diff --git a/engines/saga2/imagcach.cpp b/engines/saga2/imagcach.cpp
index c786b8eb80..e5626ba2e6 100644
--- a/engines/saga2/imagcach.cpp
+++ b/engines/saga2/imagcach.cpp
@@ -24,8 +24,6 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/fta.h"
#include "saga2/dlist.h"
diff --git a/engines/saga2/images.cpp b/engines/saga2/images.cpp
index 73b94c6cb2..a9acedb15f 100644
--- a/engines/saga2/images.cpp
+++ b/engines/saga2/images.cpp
@@ -24,8 +24,6 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/gdraw.h"
diff --git a/engines/saga2/input.cpp b/engines/saga2/input.cpp
index 7b6f998360..f9939c6ff3 100644
--- a/engines/saga2/input.cpp
+++ b/engines/saga2/input.cpp
@@ -24,8 +24,6 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/input.h"
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index b555a6b33b..ae585c21a8 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -28,13 +28,10 @@
#include "common/debug.h"
-#include "saga2/saga2.h"
-
#include "saga2/std.h"
#include "saga2/fta.h"
#include "saga2/script.h"
#include "saga2/code.h"
-#include "saga2/objects.h"
#include "saga2/tile.h"
#include "saga2/mission.h"
#include "saga2/hresmgr.h"
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index 16bc37c096..6676aa847a 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -29,15 +29,9 @@
#include "saga2/std.h"
#include "saga2/blitters.h"
#include "saga2/objects.h"
-#include "saga2/button.h"
#include "saga2/contain.h"
#include "saga2/intrface.h"
-#include "saga2/player.h"
-#include "saga2/hresmgr.h"
-#include "saga2/grequest.h"
-#include "saga2/assign.h"
#include "saga2/grabinfo.h"
-#include "saga2/mouseimg.h"
#include "saga2/uidialog.h"
#include "saga2/savefile.h"
#include "saga2/motion.h"
diff --git a/engines/saga2/keybored.cpp b/engines/saga2/keybored.cpp
index ae16dec486..1f7ddb8dd9 100644
--- a/engines/saga2/keybored.cpp
+++ b/engines/saga2/keybored.cpp
@@ -24,26 +24,15 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/tilemode.h"
#include "saga2/calender.h"
-#include "saga2/objects.h"
#include "saga2/tile.h"
-#include "saga2/setup.h"
-#include "saga2/grabinfo.h"
#include "saga2/motion.h"
-#include "saga2/actor.h"
#include "saga2/modal.h"
#include "saga2/transit.h"
#include "saga2/player.h"
-#include "saga2/annoy.h"
-#include "saga2/intrface.h"
-
-#include "saga2/cmisc.h"
-#include "saga2/button.h"
#define TEST1 1 // enable test code
#define TEST2 1
@@ -54,11 +43,6 @@
#include "saga2/loadsave.h"
#endif
-#include "saga2/imagcach.h"
-
-
-#include "saga2/assign.h"
-
#ifdef ALEXS
#include "saga2/automap.h"
#include "saga2/uidialog.h"
diff --git a/engines/saga2/loadmsg.cpp b/engines/saga2/loadmsg.cpp
index 8f64daabd0..4301c8cd35 100644
--- a/engines/saga2/loadmsg.cpp
+++ b/engines/saga2/loadmsg.cpp
@@ -24,11 +24,10 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "graphics/palette.h"
+
namespace Saga2 {
extern uint32 loadingWindowWidth;
diff --git a/engines/saga2/loadsave.cpp b/engines/saga2/loadsave.cpp
index 0474715b32..3eee9b5f5e 100644
--- a/engines/saga2/loadsave.cpp
+++ b/engines/saga2/loadsave.cpp
@@ -29,12 +29,8 @@
#include "saga2/std.h"
#include "saga2/loadsave.h"
#include "saga2/savefile.h"
-#include "saga2/fta.h"
-#include "saga2/calender.h"
#include "saga2/objects.h"
-#include "saga2/actor.h"
#include "saga2/tile.h"
-#include "saga2/player.h"
#include "saga2/script.h"
#include "saga2/motion.h"
#include "saga2/task.h"
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 6f56414897..975e4fb126 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -226,7 +226,7 @@ bool initGameMaps();
/********************************************************************/
void termFaultHandler(void);
-MAIN_RETURN_TYPE main_saga2() {
+void main_saga2() {
gameInitialized = false;
mainDisable();
@@ -246,11 +246,6 @@ MAIN_RETURN_TYPE main_saga2() {
shutdownGame();
gameInitialized = false;
-
- if (cleanExit)
- exitMain;
- else
- abortMain;
}
// ------------------------------------------------------------------------
diff --git a/engines/saga2/mainmap.h b/engines/saga2/mainmap.h
index 6d717f5358..06513a35c3 100644
--- a/engines/saga2/mainmap.h
+++ b/engines/saga2/mainmap.h
@@ -31,17 +31,6 @@ namespace Saga2 {
void main_saga2();
-#ifndef _WIN32
-typedef void MAIN_RETURN_TYPE;
-#define abortMain failExit()
-#define exitMain normalExit()
-#else // _WIN32
-typedef int MAIN_RETURN_TYPE;
-#define abortMain return -1
-#define exitMain return 0
-#endif // _WIN32
-
-
/* ===================================================================== *
Multitasking control
* ===================================================================== */
diff --git a/engines/saga2/module.mk b/engines/saga2/module.mk
index 3fec5acdbf..884a7bdb71 100644
--- a/engines/saga2/module.mk
+++ b/engines/saga2/module.mk
@@ -22,7 +22,6 @@ MODULE_OBJS := \
document.o \
effects.o \
enchant.o \
- exit.o \
floating.o \
gamemode.o \
gdraw.o \
Commit: 68bbf3c16cb7569b0c19e132ca480d99c2b83ef5
https://github.com/scummvm/scummvm/commit/68bbf3c16cb7569b0c19e132ca480d99c2b83ef5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:57+02:00
Commit Message:
SAGA2: Reduce header dependency
Changed paths:
engines/saga2/magic.cpp
engines/saga2/main.cpp
engines/saga2/mainmap.cpp
engines/saga2/mapfeatr.cpp
engines/saga2/modal.cpp
engines/saga2/motion.cpp
engines/saga2/mouseimg.cpp
engines/saga2/msgbox.cpp
engines/saga2/noise.cpp
engines/saga2/objects.cpp
engines/saga2/objproto.cpp
engines/saga2/speech.cpp
engines/saga2/speech.h
engines/saga2/uidialog.cpp
engines/saga2/vbacksav.cpp
engines/saga2/videobox.cpp
engines/saga2/vpal.cpp
engines/saga2/vwdraw.cpp
engines/saga2/vwpage.cpp
engines/saga2/weapons.cpp
diff --git a/engines/saga2/magic.cpp b/engines/saga2/magic.cpp
index 5bd43c892b..d572a0ba03 100644
--- a/engines/saga2/magic.cpp
+++ b/engines/saga2/magic.cpp
@@ -24,8 +24,6 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/magic.h"
#include "saga2/idtypes.h"
@@ -33,7 +31,6 @@
#include "saga2/spellbuk.h"
#include "saga2/spelshow.h"
#include "saga2/motion.h"
-#include "saga2/actor.h"
#include "saga2/player.h"
namespace Saga2 {
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 975e4fb126..62d4efa1af 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -29,13 +29,9 @@
#include "common/debug.h"
#include "saga2/std.h"
-
-#include "saga2/fta.h"
-
#include "saga2/setup.h"
#include "saga2/transit.h"
#include "saga2/player.h"
-#include "saga2/calender.h"
#include "saga2/tile.h"
#include "saga2/messager.h"
#include "saga2/intrface.h"
@@ -45,14 +41,10 @@
#include "saga2/display.h"
#include "saga2/tower.h"
#include "saga2/tromode.h"
-#include "saga2/loadmsg.h"
-#include "saga2/ioerrors.h"
#include "saga2/loadsave.h"
#include "saga2/gamerate.h"
#include "saga2/msgbox.h"
-#include "saga2/script.h"
#include "saga2/config.h"
-#include "saga2/hresmgr.h"
#include "saga2/savefile.h"
namespace Saga2 {
diff --git a/engines/saga2/mainmap.cpp b/engines/saga2/mainmap.cpp
index 252cf878fd..c47073b22e 100644
--- a/engines/saga2/mainmap.cpp
+++ b/engines/saga2/mainmap.cpp
@@ -25,8 +25,6 @@
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/fta.h"
#include "saga2/mainmap.h"
diff --git a/engines/saga2/mapfeatr.cpp b/engines/saga2/mapfeatr.cpp
index e505e249a0..98466ce68b 100644
--- a/engines/saga2/mapfeatr.cpp
+++ b/engines/saga2/mapfeatr.cpp
@@ -24,15 +24,10 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/mapfeatr.h"
#include "saga2/automap.h"
#include "saga2/tile.h"
-#include "saga2/objects.h"
-#include "saga2/player.h"
-#include "saga2/grequest.h"
namespace Saga2 {
diff --git a/engines/saga2/modal.cpp b/engines/saga2/modal.cpp
index bfc7de2e89..9b6e9ad271 100644
--- a/engines/saga2/modal.cpp
+++ b/engines/saga2/modal.cpp
@@ -24,13 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
-#include "saga2/fta.h"
-#include "saga2/floating.h"
#include "saga2/modal.h"
-#include "saga2/setup.h"
#include "saga2/speech.h"
#include "saga2/grabinfo.h"
diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp
index cf8f81cd6c..dc35f454a7 100644
--- a/engines/saga2/motion.cpp
+++ b/engines/saga2/motion.cpp
@@ -27,18 +27,12 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
-#include "saga2/cmisc.h"
#include "saga2/dispnode.h"
#include "saga2/tile.h"
#include "saga2/motion.h"
-#include "saga2/actor.h"
-#include "saga2/panel.h"
#include "saga2/tilemode.h"
-#include "saga2/transit.h"
-#include "saga2/assign.h"
#include "saga2/magic.h"
#include "saga2/spellbuk.h"
-#include "saga2/player.h"
#include "saga2/contain.h"
#include "saga2/intrface.h"
#include "saga2/savefile.h"
diff --git a/engines/saga2/mouseimg.cpp b/engines/saga2/mouseimg.cpp
index 64f4b8cba3..bb3d1c4c18 100644
--- a/engines/saga2/mouseimg.cpp
+++ b/engines/saga2/mouseimg.cpp
@@ -24,8 +24,6 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/blitters.h"
#include "saga2/fta.h"
diff --git a/engines/saga2/msgbox.cpp b/engines/saga2/msgbox.cpp
index fb6f73c62b..b3d2a11b5e 100644
--- a/engines/saga2/msgbox.cpp
+++ b/engines/saga2/msgbox.cpp
@@ -24,8 +24,6 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/fta.h"
#include "saga2/button.h"
diff --git a/engines/saga2/noise.cpp b/engines/saga2/noise.cpp
index e0b949fc62..12b2cdd644 100644
--- a/engines/saga2/noise.cpp
+++ b/engines/saga2/noise.cpp
@@ -24,27 +24,19 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/fta.h"
#include "saga2/audio.h"
#include "saga2/audiores.h"
#include "saga2/audiodec.h"
#include "saga2/audiofnc.h"
-#include "saga2/tcoords.h"
-#include "saga2/button.h"
#include "saga2/annoy.h"
-#include "saga2/objproto.h"
#include "saga2/player.h"
-
#include "saga2/queues.h"
#include "saga2/audiosmp.h"
#include "saga2/audqueue.h"
#include "saga2/audiosys.h"
-
#include "saga2/config.h"
-#include "saga2/hresmgr.h"
namespace Saga2 {
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index a7344e3f46..7de69b416a 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -28,28 +28,22 @@
#include "saga2/std.h"
#include "saga2/objects.h"
-#include "saga2/actor.h"
#include "saga2/tile.h"
-#include "saga2/terrain.h"
-#include "saga2/cmisc.h"
#include "saga2/motion.h"
#include "saga2/contain.h"
#include "saga2/setup.h"
#include "saga2/script.h"
-#include "saga2/player.h"
#include "saga2/target.h"
#include "saga2/uimetrcs.h"
#include "saga2/magic.h"
#include "saga2/intrface.h"
#include "saga2/sensor.h"
#include "saga2/timers.h"
-#include "saga2/magic.h"
#include "saga2/grabinfo.h"
#include "saga2/localize.h"
#include "saga2/spellbuk.h"
#include "saga2/tilevect.h"
#include "saga2/dispnode.h"
-#include "saga2/hresmgr.h"
#include "saga2/savefile.h"
#include "saga2/methods.r" // generated by SAGA
diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp
index 584995d45d..3e956b43ee 100644
--- a/engines/saga2/objproto.cpp
+++ b/engines/saga2/objproto.cpp
@@ -24,22 +24,15 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/gdraw.h"
-#include "saga2/sprite.h"
#include "saga2/objects.h"
-#include "saga2/actor.h"
#include "saga2/grabinfo.h"
#include "saga2/contain.h"
#include "saga2/motion.h"
-#include "saga2/setup.h"
#include "saga2/player.h"
#include "saga2/script.h"
-#include "saga2/intrface.h"
#include "saga2/document.h"
-#include "saga2/stimtype.h"
#include "saga2/magic.h"
#include "saga2/weapons.h"
#include "saga2/spellbuk.h"
@@ -634,7 +627,7 @@ bool ProtoObj::acceptHealing(
damage = absDamage;
if (dice)
for (int d = 0; d < abs(dice); d++)
- damage += ((rand() % sides) + pdm + 1) * (dice > 0 ? 1 : -1);
+ damage += (g_vm->_rnd->getRandomNumber(sides - 1) + pdm + 1) * (dice > 0 ? 1 : -1);
#if 0
if ((scriptResult = stdActionScript(
Method_GameObject_onAcceptDamage,
@@ -811,7 +804,7 @@ uint16 ProtoObj::containmentSet(void) {
// return the sprite data
ObjectSpriteInfo ProtoObj::getSprite(GameObject *obj, enum spriteTypes spr, int16 count) {
- ObjectSpriteInfo sprInfo = { NULL, static_cast<bool>(flags & objPropFlipped != 0) };
+ ObjectSpriteInfo sprInfo = { NULL, static_cast<bool>((flags & objPropFlipped) != 0) };
int16 openOffset = ((flags & objPropVisOpen) && obj->isOpen()) ? 1 : 0;
switch (spr) {
@@ -1817,7 +1810,7 @@ void BludgeoningWeaponProto::applySkillGrowth(ObjectID enactor, uint8 points) {
player->skillAdvance(skillIDBludgeon, points);
- if (rand() & 1)
+ if (g_vm->_rnd->getRandomNumber(65534) & 1)
player->skillAdvance(skillIDBrawn, points);
}
}
@@ -1854,7 +1847,7 @@ void SlashingWeaponProto::applySkillGrowth(ObjectID enactor, uint8 points) {
player->skillAdvance(skillIDSwordcraft, points);
- if (rand() & 1)
+ if (g_vm->_rnd->getRandomNumber(65534) & 1)
player->skillAdvance(skillIDBrawn, points);
}
}
@@ -2181,7 +2174,7 @@ void ArrowProto::applySkillGrowth(ObjectID enactor, uint8 points) {
player->skillAdvance(skillIDArchery, points);
- if (rand() & 1)
+ if (g_vm->_rnd->getRandomNumber(65534) & 1)
player->skillAdvance(skillIDBrawn, points);
}
}
@@ -2406,7 +2399,7 @@ void ShieldProto::applySkillGrowth(ObjectID enactor, uint8 points) {
player->skillAdvance(skillIDShieldcraft, points);
- if (rand() & 1)
+ if (g_vm->_rnd->getRandomNumber(65534) & 1)
player->skillAdvance(skillIDBrawn, points);
}
}
@@ -2945,7 +2938,7 @@ void EncounterGeneratorProto::doBackgroundUpdate(GameObject *obj) {
// Now, roll to see if we got an encounter!
- if (rand() & 0x0000ffff < prob) {
+ if ((g_vm->_rnd->getRandomNumber(65534) & 0x0000ffff) < prob) {
scriptCallFrame scf;
#if DEBUG
diff --git a/engines/saga2/speech.cpp b/engines/saga2/speech.cpp
index 26f3e1fa36..77442d71a2 100644
--- a/engines/saga2/speech.cpp
+++ b/engines/saga2/speech.cpp
@@ -610,7 +610,7 @@ bool Speech::longEnough(void) {
// Gets rid of the current speech
-void Speech::abort(void) {
+void Speech::abortSpeech(void) {
// Start by displaying first frame straight off, no delay
speechFinished.set(0);
if (speechFlags & spHasVoice) {
@@ -619,7 +619,7 @@ void Speech::abort(void) {
}
void abortSpeech(void) {
- if (speechList.currentActive()) speechList.currentActive()->abort();
+ if (speechList.currentActive()) speechList.currentActive()->abortSpeech();
}
diff --git a/engines/saga2/speech.h b/engines/saga2/speech.h
index 9b4d8c5c5d..4fd4a30f44 100644
--- a/engines/saga2/speech.h
+++ b/engines/saga2/speech.h
@@ -154,7 +154,7 @@ public:
bool longEnough(void);
// Abort the current speech.
- void abort(void);
+ void abortSpeech(void);
};
class SpeechTaskList {
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index e5a37377c6..39624d18f4 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -27,13 +27,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
-#include "saga2/objects.h"
-#include "saga2/button.h"
-#include "saga2/contain.h"
-#include "saga2/modal.h"
#include "saga2/intrface.h"
-#include "saga2/player.h"
-#include "saga2/hresmgr.h"
#include "saga2/grequest.h"
#include "saga2/gtextbox.h"
#include "saga2/loadsave.h"
@@ -45,7 +39,6 @@
#include "saga2/audqueue.h"
#include "saga2/audiosys.h"
-#include "saga2/annoy.h"
#include "saga2/uidialog.h"
#include "saga2/document.h"
#include "saga2/tilemode.h"
@@ -53,12 +46,8 @@
#include "saga2/uitext.h"
#include "saga2/vpal.h"
#include "saga2/palette.h"
-#include "saga2/display.h"
-#include "saga2/program.h"
-#include "saga2/version.h"
#include "saga2/config.h"
-#include "saga2/hresmgr.h"
#include "saga2/fontlib.h"
#include "saga2/savefile.h"
diff --git a/engines/saga2/vbacksav.cpp b/engines/saga2/vbacksav.cpp
index 8a37166a19..d73d11081b 100644
--- a/engines/saga2/vbacksav.cpp
+++ b/engines/saga2/vbacksav.cpp
@@ -24,8 +24,6 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/vbacksav.h"
diff --git a/engines/saga2/videobox.cpp b/engines/saga2/videobox.cpp
index 874ae512fb..fd4889029e 100644
--- a/engines/saga2/videobox.cpp
+++ b/engines/saga2/videobox.cpp
@@ -24,12 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
-#include "saga2/floating.h"
#include "saga2/videobox.h"
-#include "saga2/hresmgr.h"
namespace Saga2 {
diff --git a/engines/saga2/vpal.cpp b/engines/saga2/vpal.cpp
index 018485b2ed..84fffed28f 100644
--- a/engines/saga2/vpal.cpp
+++ b/engines/saga2/vpal.cpp
@@ -30,10 +30,6 @@
#include "saga2/fta.h"
#include "saga2/vpal.h"
#include "saga2/palette.h"
-#include "saga2/transit.h"
-#include "saga2/cmisc.h"
-#include "saga2/calender.h"
-#include "saga2/player.h"
#include "saga2/display.h"
#include "saga2/hresmgr.h"
#include "saga2/savefile.h"
diff --git a/engines/saga2/vwdraw.cpp b/engines/saga2/vwdraw.cpp
index 20a69099ac..2792e53dee 100644
--- a/engines/saga2/vwdraw.cpp
+++ b/engines/saga2/vwdraw.cpp
@@ -24,10 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
-#include "saga2/vwpage.h"
#include "saga2/vdraw.h"
namespace Saga2 {
diff --git a/engines/saga2/vwpage.cpp b/engines/saga2/vwpage.cpp
index f798a89032..07fab694db 100644
--- a/engines/saga2/vwpage.cpp
+++ b/engines/saga2/vwpage.cpp
@@ -24,14 +24,9 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
-#include "saga2/rect.h"
#include "saga2/vdraw.h"
#include "saga2/vwpage.h"
-#include "saga2/display.h"
-#include "saga2/vpage.h"
namespace Saga2 {
diff --git a/engines/saga2/weapons.cpp b/engines/saga2/weapons.cpp
index 37b5ddf15c..ea3c7629a5 100644
--- a/engines/saga2/weapons.cpp
+++ b/engines/saga2/weapons.cpp
@@ -24,10 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
-#include "saga2/idtypes.h"
#include "saga2/weapons.h"
#include "saga2/spellbuk.h"
#include "saga2/actor.h"
Commit: 9ba0a2e46c8c6792342bcf8a58970878f0ee15ba
https://github.com/scummvm/scummvm/commit/9ba0a2e46c8c6792342bcf8a58970878f0ee15ba
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:57+02:00
Commit Message:
SAGA2: Finish reducing include dependencies
Changed paths:
engines/saga2/panel.cpp
engines/saga2/path.cpp
engines/saga2/patrol.cpp
engines/saga2/player.cpp
engines/saga2/playmode.cpp
engines/saga2/pool.cpp
engines/saga2/property.cpp
engines/saga2/rmem.cpp
engines/saga2/rserver.cpp
engines/saga2/saga2.cpp
engines/saga2/sagafunc.cpp
engines/saga2/speech.cpp
engines/saga2/spelcast.cpp
engines/saga2/speldata.cpp
engines/saga2/speldraw.cpp
engines/saga2/spellini.cpp
engines/saga2/spellloc.cpp
engines/saga2/spellsiz.cpp
engines/saga2/spellspr.cpp
engines/saga2/spellsta.cpp
engines/saga2/sprite.cpp
engines/saga2/target.cpp
engines/saga2/terrain.cpp
engines/saga2/tile.cpp
engines/saga2/tileline.cpp
engines/saga2/tileload.cpp
engines/saga2/tilemode.cpp
engines/saga2/timer.cpp
engines/saga2/tower.cpp
engines/saga2/towerfta.cpp
engines/saga2/transit.cpp
engines/saga2/tromode.cpp
diff --git a/engines/saga2/panel.cpp b/engines/saga2/panel.cpp
index 6016f32d0f..e93f57adf4 100644
--- a/engines/saga2/panel.cpp
+++ b/engines/saga2/panel.cpp
@@ -24,14 +24,10 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/panel.h"
-#include "saga2/gpointer.h"
#include "saga2/fontlib.h"
#include "saga2/floating.h"
-#include "saga2/fta.h"
#include "saga2/display.h"
#include "saga2/gbevel.h"
diff --git a/engines/saga2/path.cpp b/engines/saga2/path.cpp
index b934a1867e..d1d7db5b23 100644
--- a/engines/saga2/path.cpp
+++ b/engines/saga2/path.cpp
@@ -24,14 +24,10 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/dispnode.h"
-#include "saga2/tcoords.h"
#include "saga2/tile.h"
#include "saga2/motion.h"
-#include "saga2/actor.h"
#include "saga2/player.h"
#include "saga2/pool.h"
#include "saga2/cmisc.h"
@@ -1150,7 +1146,7 @@ public:
virtual void initialize(void);
virtual void finish(void); // completion method
- virtual void abort(void); // abnormal termination method
+ virtual void abortReq(void); // abnormal termination method
PathResult findPath(void);
@@ -1702,7 +1698,7 @@ void PathRequest::finish(void) {
}
}
-void PathRequest::abort(void) {
+void PathRequest::abortReq(void) {
if (mTask->pathFindTask == this)
mTask->pathFindTask = nullptr;
}
@@ -2328,7 +2324,7 @@ void runPathFinder(void) {
if (result == pathDone)
currentRequest->finish();
else
- currentRequest->abort();
+ currentRequest->abortReq();
delete currentRequest;
currentRequest = nullptr;
@@ -2714,7 +2710,7 @@ TilePoint selectNearbySite(
spush(TilePoint(qi.u + tDir->u,
qi.v + tDir->v,
testPt.z),
- qi.cost + (rand() & 3),
+ qi.cost + (g_vm->_rnd->getRandomNumber(65534) & 3),
dir);
}
}
diff --git a/engines/saga2/patrol.cpp b/engines/saga2/patrol.cpp
index 9d32b2bd53..5cff6038ed 100644
--- a/engines/saga2/patrol.cpp
+++ b/engines/saga2/patrol.cpp
@@ -24,8 +24,6 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/fta.h"
#include "saga2/patrol.h"
@@ -123,7 +121,7 @@ PatrolRouteIterator::PatrolRouteIterator(uint8 map, int16 rte, uint8 type) :
const PatrolRoute &route = patrolRouteList[mapNum][routeNo];
if (flags & patrolRouteRandom)
- vertexNo = rand() % route.vertices();
+ vertexNo = g_vm->_rnd->getRandomNumber(route.vertices() - 1);
else {
if (flags & patrolRouteReverse)
vertexNo = route.vertices() - 1;
@@ -250,7 +248,7 @@ const PatrolRouteIterator &PatrolRouteIterator::operator ++ (void) {
altIncrement();
}
} else {
- vertexNo = rand() % route.vertices();
+ vertexNo = g_vm->_rnd->getRandomNumber(route.vertices() - 1);
}
}
diff --git a/engines/saga2/player.cpp b/engines/saga2/player.cpp
index bcbb21cc2e..95820810b2 100644
--- a/engines/saga2/player.cpp
+++ b/engines/saga2/player.cpp
@@ -27,12 +27,9 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "saga2/std.h"
-#include "saga2/cmisc.h"
-#include "saga2/player.h"
#include "saga2/intrface.h"
#include "saga2/contain.h"
#include "saga2/task.h"
-#include "saga2/tromode.h"
#include "saga2/motion.h"
#include "saga2/transit.h"
#include "saga2/localize.h"
diff --git a/engines/saga2/playmode.cpp b/engines/saga2/playmode.cpp
index 7d0d01c17a..a558008032 100644
--- a/engines/saga2/playmode.cpp
+++ b/engines/saga2/playmode.cpp
@@ -24,29 +24,15 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "graphics/surface.h"
#include "saga2/std.h"
#include "saga2/blitters.h"
-#include "saga2/tcoords.h"
#include "saga2/objects.h"
-#include "saga2/sprite.h"
#include "saga2/tile.h"
-#include "saga2/actor.h"
-#include "saga2/panel.h"
-#include "saga2/motion.h"
-#include "saga2/floating.h"
#include "saga2/contain.h"
#include "saga2/grabinfo.h"
-#include "saga2/setup.h"
-#include "saga2/player.h"
#include "saga2/intrface.h"
-#include "saga2/testmap.h"
-#include "saga2/cmisc.h"
-#include "saga2/button.h"
-#include "saga2/hresmgr.h"
#include "saga2/fontlib.h"
namespace Saga2 {
diff --git a/engines/saga2/pool.cpp b/engines/saga2/pool.cpp
index f394118186..a42197a8cc 100644
--- a/engines/saga2/pool.cpp
+++ b/engines/saga2/pool.cpp
@@ -24,8 +24,6 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/dlist.h"
#include "saga2/pool.h"
diff --git a/engines/saga2/property.cpp b/engines/saga2/property.cpp
index 8bbdfdafc9..b370d46814 100644
--- a/engines/saga2/property.cpp
+++ b/engines/saga2/property.cpp
@@ -24,12 +24,9 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/player.h"
#include "saga2/tile.h"
-#include "saga2/property.h"
#include "saga2/pclass.r"
diff --git a/engines/saga2/rmem.cpp b/engines/saga2/rmem.cpp
index 9408d54839..e9f0d95335 100644
--- a/engines/saga2/rmem.cpp
+++ b/engines/saga2/rmem.cpp
@@ -29,7 +29,6 @@
#define NO_LOCAL_MEMORY_OVERRIDES 1
#include "saga2/rmem.h"
#include "saga2/rmembase.h"
-#include "saga2/errors.h"
namespace Saga2 {
diff --git a/engines/saga2/rserver.cpp b/engines/saga2/rserver.cpp
index 78ed636e06..5c42c999df 100644
--- a/engines/saga2/rserver.cpp
+++ b/engines/saga2/rserver.cpp
@@ -28,7 +28,6 @@
#include "saga2/std.h"
#include "saga2/dlist.h"
-#include "saga2/fta.h"
#include "saga2/ioerrors.h"
#include "saga2/hresmgr.h"
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index 1f8f5e3532..aead7a4445 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -34,11 +34,7 @@
#include "saga2/saga2.h"
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
-#include "saga2/blitters.h"
-#include "saga2/loadmsg.h"
#include "saga2/gdraw.h"
namespace Saga2 {
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index 2445be432c..b8082f3a91 100644
--- a/engines/saga2/sagafunc.cpp
+++ b/engines/saga2/sagafunc.cpp
@@ -31,21 +31,15 @@
#include "saga2/std.h"
#include "saga2/fta.h"
#include "saga2/script.h"
-#include "saga2/code.h"
-#include "saga2/objects.h"
#include "saga2/actor.h"
#include "saga2/speech.h"
-#include "saga2/grequest.h"
#include "saga2/assign.h"
-#include "saga2/annoy.h"
-#include "saga2/calender.h"
#include "saga2/intrface.h"
#include "saga2/document.h"
#include "saga2/motion.h"
#include "saga2/sensor.h"
#include "saga2/magic.h"
#include "saga2/uidialog.h"
-#include "saga2/player.h"
#include "saga2/mission.h"
#include "saga2/band.h"
#include "saga2/tromode.h"
diff --git a/engines/saga2/speech.cpp b/engines/saga2/speech.cpp
index 77442d71a2..6de9cab1f0 100644
--- a/engines/saga2/speech.cpp
+++ b/engines/saga2/speech.cpp
@@ -29,8 +29,6 @@
#include "saga2/std.h"
#include "saga2/fta.h"
#include "saga2/fontlib.h"
-#include "saga2/objects.h"
-#include "saga2/actor.h"
#include "saga2/speech.h"
#include "saga2/motion.h"
#include "saga2/panel.h"
@@ -40,7 +38,6 @@
#include "saga2/savefile.h"
#include "saga2/cmisc.h"
#include "saga2/config.h"
-#include "saga2/hresmgr.h"
namespace Saga2 {
diff --git a/engines/saga2/spelcast.cpp b/engines/saga2/spelcast.cpp
index f2382fea16..1db14b14b4 100644
--- a/engines/saga2/spelcast.cpp
+++ b/engines/saga2/spelcast.cpp
@@ -24,20 +24,13 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
-#include "saga2/magic.h"
#include "saga2/idtypes.h"
#include "saga2/speldefs.h"
#include "saga2/spellbuk.h"
#include "saga2/spelshow.h"
-#include "saga2/motion.h"
#include "saga2/spelvals.h"
-#include "saga2/annoy.h"
-#include "saga2/tileline.h"
#include "saga2/tilevect.h"
-#include "saga2/hresmgr.h"
namespace Saga2 {
@@ -754,7 +747,7 @@ int32 scatterer(int32 i, int32 m, int32 s) {
return (i * s) % m;
case 5:
default:
- return rand() % m;
+ return g_vm->_rnd->getRandomNumber(m - 1);
}
}
@@ -982,13 +975,13 @@ int16 tileNopeHeight(
if (supportHeight <= pt.z + obj->hgtCall()
&& supportHeight >= highestSupportHeight
&& (ti->combinedTerrainMask() &
- terrainSurface | terrainRaised)) {
+ (terrainSurface | terrainRaised))) {
highestTile = sti;
highestSupportHeight = supportHeight;
} else if (highestTile.surfaceTile == NULL &&
supportHeight <= lowestSupportHeight &&
(ti->combinedTerrainMask() &
- terrainSurface | terrainRaised)) {
+ (terrainSurface | terrainRaised))) {
lowestTile = sti;
lowestSupportHeight = supportHeight;
}
diff --git a/engines/saga2/speldata.cpp b/engines/saga2/speldata.cpp
index 7c107fc70f..2b5bfcdb91 100644
--- a/engines/saga2/speldata.cpp
+++ b/engines/saga2/speldata.cpp
@@ -24,12 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
-#include "saga2/dispnode.h"
#include "saga2/objproto.h"
-#include "saga2/spells.h"
#include "saga2/spellbuk.h"
#include "saga2/spelshow.h"
#include "saga2/spellio.h"
diff --git a/engines/saga2/speldraw.cpp b/engines/saga2/speldraw.cpp
index a1f9202aed..8d9a78e2fc 100644
--- a/engines/saga2/speldraw.cpp
+++ b/engines/saga2/speldraw.cpp
@@ -24,12 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
-#include "saga2/dispnode.h"
-#include "saga2/objproto.h"
-#include "saga2/spellbuk.h"
#include "saga2/spelshow.h"
namespace Saga2 {
diff --git a/engines/saga2/spellini.cpp b/engines/saga2/spellini.cpp
index 034ce4348d..0bfa5e57b2 100644
--- a/engines/saga2/spellini.cpp
+++ b/engines/saga2/spellini.cpp
@@ -24,12 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
-#include "saga2/spells.h"
-#include "saga2/objects.h"
-#include "saga2/spellbuk.h"
#include "saga2/spelshow.h"
#include "saga2/spelvals.h"
#include "saga2/tilevect.h"
diff --git a/engines/saga2/spellloc.cpp b/engines/saga2/spellloc.cpp
index cecff91cb4..373f9d0d0a 100644
--- a/engines/saga2/spellloc.cpp
+++ b/engines/saga2/spellloc.cpp
@@ -24,13 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
-#include "saga2/objproto.h"
-#include "saga2/spellbuk.h"
#include "saga2/spelshow.h"
-#include "saga2/spelvals.h"
#include "saga2/tilevect.h"
namespace Saga2 {
diff --git a/engines/saga2/spellsiz.cpp b/engines/saga2/spellsiz.cpp
index 51450da1ee..6fc0b454fc 100644
--- a/engines/saga2/spellsiz.cpp
+++ b/engines/saga2/spellsiz.cpp
@@ -24,11 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
-#include "saga2/objproto.h"
-#include "saga2/spellbuk.h"
#include "saga2/spelshow.h"
namespace Saga2 {
diff --git a/engines/saga2/spellspr.cpp b/engines/saga2/spellspr.cpp
index 1ac4347acd..348e10a58c 100644
--- a/engines/saga2/spellspr.cpp
+++ b/engines/saga2/spellspr.cpp
@@ -24,8 +24,6 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/objproto.h"
#include "saga2/spellbuk.h"
@@ -43,11 +41,11 @@ namespace Saga2 {
// random sprite from primary range
#define PRIMARY (effectron->parent->dProto->primarySpriteNo?\
- (effectron->parent->dProto->primarySpriteID + rand()%effectron->parent->dProto->primarySpriteNo):\
+ (effectron->parent->dProto->primarySpriteID + g_vm->_rnd->getRandomNumber(effectron->parent->dProto->primarySpriteNo - 1)):\
effectron->parent->dProto->primarySpriteID)
// random sprite from secondary range
#define SECONDARY (effectron->parent->dProto->secondarySpriteNo?\
- (effectron->parent->dProto->secondarySpriteID + rand()%effectron->parent->dProto->secondarySpriteNo):\
+ (effectron->parent->dProto->secondarySpriteID + g_vm->_rnd->getRandomNumber(effectron->parent->dProto->secondarySpriteNo - 1)):\
effectron->parent->dProto->secondarySpriteID)
// ordered sprite from primary range
#define SEQUENTIAL (effectron->parent->dProto->primarySpriteNo?\
@@ -170,11 +168,11 @@ SPELLSPRITATIONFUNCTION(stormSprites) {
//-----------------------------------------------------------------------
SPELLSPRITATIONFUNCTION(RandomFacing) {
- return (rand() % 256);
+ return g_vm->_rnd->getRandomNumber(255);
}
SPELLSPRITATIONFUNCTION(FaceOut) {
- return (rand() % 256);
+ return g_vm->_rnd->getRandomNumber(255);
}
} // end of namespace Saga2
diff --git a/engines/saga2/spellsta.cpp b/engines/saga2/spellsta.cpp
index 49449306c8..55ae0fa600 100644
--- a/engines/saga2/spellsta.cpp
+++ b/engines/saga2/spellsta.cpp
@@ -24,15 +24,9 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
-#include "saga2/objproto.h"
-#include "saga2/spellbuk.h"
-#include "saga2/spelvals.h"
#include "saga2/spelshow.h"
-
namespace Saga2 {
// ------------------------------------------------------------------
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index c9f2425e94..bb7007cdcb 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -24,15 +24,11 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/fta.h"
#include "saga2/blitters.h"
#include "saga2/sprite.h"
#include "saga2/tcoords.h"
-#include "saga2/input.h"
-#include "saga2/cmisc.h"
#include "saga2/hresmgr.h"
namespace Saga2 {
diff --git a/engines/saga2/target.cpp b/engines/saga2/target.cpp
index aa7a90e223..4cd4c9b628 100644
--- a/engines/saga2/target.cpp
+++ b/engines/saga2/target.cpp
@@ -24,8 +24,6 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/cmisc.h"
#include "saga2/objects.h"
diff --git a/engines/saga2/terrain.cpp b/engines/saga2/terrain.cpp
index e675c459f3..bcfc1e0118 100644
--- a/engines/saga2/terrain.cpp
+++ b/engines/saga2/terrain.cpp
@@ -24,16 +24,10 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
-#include "saga2/tcoords.h"
#include "saga2/idtypes.h"
#include "saga2/tile.h"
-#include "saga2/terrain.h"
-#include "saga2/objects.h"
#include "saga2/actor.h"
-#include "saga2/cmisc.h"
namespace Saga2 {
@@ -55,7 +49,7 @@ void drown(GameObject *obj) {
if (isActor(obj)) {
Actor *a = (Actor *) obj;
if (!a->hasEffect(actorWaterBreathe)) {
- if (rand() % (drowningDamageOddsYes + drowningDamageOddsNo) > drowningDamageOddsNo - 1) {
+ if (g_vm->_rnd->getRandomNumber(drowningDamageOddsYes + drowningDamageOddsNo - 1) > drowningDamageOddsNo - 1) {
a->acceptDamage(a->thisID(), drowningDamagePerFrame);
}
}
@@ -69,7 +63,7 @@ void lavaDamage(GameObject *obj) {
if (a->resists(resistHeat))
return;
}
- if (rand() % (heatDamageOddsYes + heatDamageOddsNo) > heatDamageOddsNo - 1) {
+ if (g_vm->_rnd->getRandomNumber(heatDamageOddsYes + heatDamageOddsNo - 1) > heatDamageOddsNo - 1) {
obj->acceptDamage(obj->thisID(), heatDamagePerFrame, damageHeat, heatDamageDicePerFrame, 6);
}
}
@@ -80,19 +74,19 @@ void coldDamage(GameObject *obj) {
if (a->resists(resistCold))
return;
}
- if (rand() % (coldDamageOddsYes + coldDamageOddsNo) > coldDamageOddsNo - 1) {
+ if (g_vm->_rnd->getRandomNumber(coldDamageOddsYes + coldDamageOddsNo - 1) > coldDamageOddsNo - 1) {
obj->acceptDamage(obj->thisID(), coldDamagePerFrame, damageCold, coldDamageDicePerFrame, 6);
}
}
void terrainDamageSlash(GameObject *obj) {
- if (rand() % (terrainDamageOddsYes + terrainDamageOddsNo) > terrainDamageOddsNo - 1) {
+ if (g_vm->_rnd->getRandomNumber(terrainDamageOddsYes + terrainDamageOddsNo - 1) > terrainDamageOddsNo - 1) {
obj->acceptDamage(obj->thisID(), terrainDamagePerFrame, damageSlash, terrainDamageDicePerFrame, 6);
}
}
void terrainDamageBash(GameObject *obj) {
- if (rand() % (terrainDamageOddsYes + terrainDamageOddsNo) > terrainDamageOddsNo - 1) {
+ if (g_vm->_rnd->getRandomNumber(terrainDamageOddsYes + terrainDamageOddsNo - 1) > terrainDamageOddsNo - 1) {
obj->acceptDamage(obj->thisID(), terrainDamagePerFrame, damageImpact, terrainDamageDicePerFrame, 6);
}
}
@@ -687,14 +681,14 @@ int16 tileSlopeHeight(
if (tileBase < pt.z + objectHeight
&& supportHeight >= highestSupportHeight
&& (ti->combinedTerrainMask() &
- terrainSurface | terrainRaised)) {
+ (terrainSurface | terrainRaised))) {
highestTile = sti;
highestSupportHeight = supportHeight;
highestSupportPlatform = i;
} else if (highestTile.surfaceTile == NULL &&
supportHeight <= lowestSupportHeight &&
(ti->combinedTerrainMask() &
- terrainSurface | terrainRaised)) {
+ (terrainSurface | terrainRaised))) {
lowestTile = sti;
lowestSupportHeight = supportHeight;
lowestSupportPlatform = i;
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 61d071e2ff..0d0fc2d21d 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -31,17 +31,14 @@
#include "saga2/std.h"
#include "saga2/blitters.h"
-#include "saga2/tcoords.h"
#include "saga2/hresmgr.h"
#include "saga2/objects.h"
#include "saga2/tile.h"
#include "saga2/oncall.h"
-#include "saga2/motion.h"
#include "saga2/input.h"
#include "saga2/cmisc.h"
#include "saga2/setup.h"
-#include "saga2/annoy.h"
#include "saga2/tagnoise.h"
#include "saga2/player.h"
#include "saga2/mapfeatr.h"
diff --git a/engines/saga2/tileline.cpp b/engines/saga2/tileline.cpp
index 235056b827..c5da29e227 100644
--- a/engines/saga2/tileline.cpp
+++ b/engines/saga2/tileline.cpp
@@ -24,14 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
-#include "saga2/tileline.h"
-#include "saga2/tcoords.h"
-#include "saga2/objects.h"
-#include "saga2/tile.h"
-#include "saga2/actor.h"
namespace Saga2 {
diff --git a/engines/saga2/tileload.cpp b/engines/saga2/tileload.cpp
index 43a6893590..64ff9870ba 100644
--- a/engines/saga2/tileload.cpp
+++ b/engines/saga2/tileload.cpp
@@ -24,18 +24,11 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "common/debug.h"
#include "saga2/std.h"
-#include "saga2/input.h"
-#include "saga2/cmisc.h"
-#include "saga2/tcoords.h"
#include "saga2/idtypes.h"
#include "saga2/tile.h"
-#include "saga2/objects.h"
-#include "saga2/tileload.h"
#include "saga2/hresmgr.h"
#include "saga2/oncall.h"
diff --git a/engines/saga2/tilemode.cpp b/engines/saga2/tilemode.cpp
index e0f10faa2c..2e492a5a0c 100644
--- a/engines/saga2/tilemode.cpp
+++ b/engines/saga2/tilemode.cpp
@@ -34,22 +34,14 @@
#include "saga2/grabinfo.h"
#include "saga2/mouseimg.h"
#include "saga2/motion.h"
-#include "saga2/actor.h"
#include "saga2/task.h"
-#include "saga2/modal.h"
#include "saga2/transit.h"
-#include "saga2/player.h"
-#include "saga2/calender.h"
#include "saga2/magic.h"
#include "saga2/sensor.h"
#include "saga2/timers.h"
#include "saga2/intrface.h"
#include "saga2/dispnode.h"
-#include "saga2/annoy.h"
#include "saga2/uidialog.h"
-#include "saga2/loadsave.h"
-#include "saga2/display.h"
-#include "saga2/automap.h"
#include "saga2/images.h"
#include "saga2/config.h"
#include "saga2/contain.h"
diff --git a/engines/saga2/timer.cpp b/engines/saga2/timer.cpp
index 4df2ad70c9..ec3430a6d6 100644
--- a/engines/saga2/timer.cpp
+++ b/engines/saga2/timer.cpp
@@ -37,6 +37,7 @@
#include "saga2/audiosys.h"
#include "saga2/savefile.h"
+
namespace Saga2 {
/* ====================================================================== *
diff --git a/engines/saga2/tower.cpp b/engines/saga2/tower.cpp
index 7713cb355b..789e186470 100644
--- a/engines/saga2/tower.cpp
+++ b/engines/saga2/tower.cpp
@@ -24,13 +24,10 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "common/debug.h"
#include "saga2/std.h"
#include "saga2/tower.h"
-#include "saga2/messager.h"
namespace Saga2 {
diff --git a/engines/saga2/towerfta.cpp b/engines/saga2/towerfta.cpp
index 4bff0343cd..c2ec4d6e85 100644
--- a/engines/saga2/towerfta.cpp
+++ b/engines/saga2/towerfta.cpp
@@ -24,32 +24,22 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
#include "saga2/towerwin.h"
#include "saga2/towerfta.h"
#include "saga2/fta.h"
#include "saga2/mainmap.h"
-#include "saga2/config.h"
#include "saga2/tromode.h"
-#include "saga2/audio.h"
-#include "saga2/annoy.h"
#include "saga2/script.h"
#include "saga2/vpal.h"
#include "saga2/palette.h"
#include "saga2/intrface.h"
#include "saga2/mouseimg.h"
-#include "saga2/panel.h"
-#include "saga2/floating.h"
#include "saga2/images.h"
#include "saga2/patrol.h"
#include "saga2/weapons.h"
#include "saga2/loadsave.h"
#include "saga2/display.h"
-#include "saga2/transit.h"
-#include "saga2/tile.h"
-#include "saga2/hresmgr.h"
namespace Saga2 {
diff --git a/engines/saga2/transit.cpp b/engines/saga2/transit.cpp
index e0f1adb7b0..00645ed667 100644
--- a/engines/saga2/transit.cpp
+++ b/engines/saga2/transit.cpp
@@ -24,21 +24,13 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "saga2/std.h"
-#include "saga2/fta.h"
-#include "saga2/floating.h"
#include "saga2/idtypes.h"
#include "saga2/tile.h"
-#include "saga2/transit.h"
#include "saga2/vpal.h"
#include "saga2/palette.h"
#include "saga2/calender.h"
-#include "saga2/cmisc.h"
#include "saga2/modal.h"
-#include "saga2/annoy.h"
-#include "saga2/mainmap.h"
#include "saga2/display.h"
namespace Saga2 {
diff --git a/engines/saga2/tromode.cpp b/engines/saga2/tromode.cpp
index 657254c27f..40f25fd7c3 100644
--- a/engines/saga2/tromode.cpp
+++ b/engines/saga2/tromode.cpp
@@ -24,19 +24,12 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
#include "common/config-manager.h"
#include "saga2/std.h"
-#include "saga2/cmisc.h"
-#include "saga2/input.h"
#include "saga2/fta.h"
#include "saga2/player.h"
-#include "saga2/tromode.h"
#include "saga2/display.h"
-
-#include "saga2/mainmap.h"
#include "saga2/config.h"
#include "saga2/panel.h"
Commit: 34af614f8eae24e043959596aa6d390443b766d7
https://github.com/scummvm/scummvm/commit/34af614f8eae24e043959596aa6d390443b766d7
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:57+02:00
Commit Message:
SAGA2: Fix actor sprite initialization
Changed paths:
engines/saga2/contain.cpp
engines/saga2/dispnode.cpp
engines/saga2/intrface.cpp
engines/saga2/objproto.cpp
engines/saga2/playmode.cpp
engines/saga2/sprite.cpp
engines/saga2/sprite.h
diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index e1a44c9107..f938d6cf0a 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -62,7 +62,7 @@ static void *selImage;
extern ReadyContainerView *TrioCviews[ kNumViews ];
extern ReadyContainerView *indivCviewTop, *indivCviewBot;
extern SpellStuff spellBook[];
-extern SpriteSet **objectSprites; // object sprites
+extern SpriteSet *objectSprites; // object sprites
extern PlayerActor playerList[]; // Master list of all PlayerActors
extern Alarm containerObjTextAlarm;
extern bool gameSetupComplete;
diff --git a/engines/saga2/dispnode.cpp b/engines/saga2/dispnode.cpp
index c1b75e58ab..2213ebe95b 100644
--- a/engines/saga2/dispnode.cpp
+++ b/engines/saga2/dispnode.cpp
@@ -59,7 +59,7 @@ extern Rect16 tileRect;
extern Point16 fineScroll;
extern gPort backPort;
-extern SpriteSet **objectSprites, // object sprites
+extern SpriteSet *objectSprites, // object sprites
* *spellSprites; // spell effect sprites
ActorAppearance *tempAppearance; // test structure
@@ -168,7 +168,7 @@ void DisplayNodeList::draw(void) {
SpriteSet *objectSet,
*spellSet;
- objectSet = (SpriteSet *)lockResource((RHANDLE) objectSprites);
+ objectSet = objectSprites;
if (objectSet == NULL)
error("Object sprites have been dumped!\n");
spellSet = (SpriteSet *)lockResource((RHANDLE) spellSprites);
@@ -181,9 +181,6 @@ void DisplayNodeList::draw(void) {
else
dn->drawObject();
}
-
- unlockResource((RHANDLE) objectSprites);
- unlockResource((RHANDLE) spellSprites);
}
//-----------------------------------------------------------------------
@@ -831,7 +828,7 @@ ObjectID pickObject(const Point16 &mouse, TilePoint &objPos) {
int32 dist = maxint32;
SpriteSet *objectSet;
- objectSet = (SpriteSet *)lockResource((RHANDLE) objectSprites);
+ objectSet = objectSprites;
if (objectSet == NULL)
error("Object sprites have been dumped!");
@@ -913,8 +910,6 @@ ObjectID pickObject(const Point16 &mouse, TilePoint &objPos) {
}
}
- unlockResource((RHANDLE) objectSprites);
-
return result;
}
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index 6676aa847a..bcb8da7a22 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -2802,7 +2802,7 @@ void gEnchantmentDisplay::drawClipped(gPort &port, const Point16 &offset, con
for (int i = 0; i < iconCount; i++) {
if (iconFlags[i]) {
- Sprite *sp = (*mentalSprites)->sprite(i + 162);
+ Sprite *sp = mentalSprites->sprite(i + 162);
pos.x -= sp->size.x + 2;
DrawSprite(port, pos, sp);
@@ -2821,7 +2821,7 @@ void gEnchantmentDisplay::pointerMove(gPanelMessage &msg) {
for (int i = 0; i < iconCount; i++) {
if (iconFlags[i]) {
- Sprite *sp = (*mentalSprites)->sprite(i + 162);
+ Sprite *sp = mentalSprites->sprite(i + 162);
x -= sp->size.x + 2;
if (msg.pickPos.x >= x) {
diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp
index 3e956b43ee..d441a2beec 100644
--- a/engines/saga2/objproto.cpp
+++ b/engines/saga2/objproto.cpp
@@ -824,9 +824,9 @@ ObjectSpriteInfo ProtoObj::getSprite(GameObject *obj, enum spriteTypes spr, int1
sprInfo.flipped = TRUE;
}
- sprInfo.sp = (*missileSprites)->sprite(sprIndex);
+ sprInfo.sp = missileSprites->sprite(sprIndex);
} else {
- sprInfo.sp = (*objectSprites)->sprite(groundSprite + openOffset + obj->getSprOffset(count));
+ sprInfo.sp = objectSprites->sprite(groundSprite + openOffset + obj->getSprOffset(count));
sprInfo.flipped =
(flags & ResourceObjectPrototype::objPropFlipped) != 0;
}
@@ -836,7 +836,7 @@ ObjectSpriteInfo ProtoObj::getSprite(GameObject *obj, enum spriteTypes spr, int1
case objInContainerView:
case objAsMousePtr:
- sprInfo.sp = (*objectSprites)->sprite(iconSprite + openOffset + obj->getSprOffset(count));
+ sprInfo.sp = objectSprites->sprite(iconSprite + openOffset + obj->getSprOffset(count));
sprInfo.flipped =
(flags & ResourceObjectPrototype::objPropFlipped) != 0;
break;
@@ -1521,7 +1521,7 @@ uint16 WeaponProto::containmentSet(void) {
// return the address of the sprite when held in hand
Sprite *WeaponProto::getOrientedSprite(GameObject *obj, int16 offset) {
- return (*weaponSprites[ heldSpriteBase ])->sprite(offset);
+ return weaponSprites[ heldSpriteBase ]->sprite(offset);
}
//-----------------------------------------------------------------------
@@ -2300,7 +2300,7 @@ bool ShieldProto::acceptDamageAction(
}
Sprite *ShieldProto::getOrientedSprite(GameObject *obj, int16 offset) {
- return (*weaponSprites[ heldSpriteBase ])->sprite(offset);
+ return weaponSprites[heldSpriteBase]->sprite(offset);
}
// Initiate a shield parrying motion
@@ -2592,12 +2592,12 @@ ObjectSpriteInfo IntangibleObjProto::getSprite(
switch (spr) {
case objOnGround:
- sprInfo.sp = (*mentalSprites)->sprite(groundSprite);
+ sprInfo.sp = mentalSprites->sprite(groundSprite);
break;
case objInContainerView:
case objAsMousePtr:
- sprInfo.sp = (*mentalSprites)->sprite(iconSprite);
+ sprInfo.sp = mentalSprites->sprite(iconSprite);
}
return sprInfo;
}
diff --git a/engines/saga2/playmode.cpp b/engines/saga2/playmode.cpp
index a558008032..a88ce26b89 100644
--- a/engines/saga2/playmode.cpp
+++ b/engines/saga2/playmode.cpp
@@ -50,7 +50,7 @@ extern Rect16 tileRect;
extern gPixelMap tileDrawMap;
extern gPort tileDrawPort;
extern BackWindow *mainWindow;
-extern SpriteSet **objectSprites; // object sprites
+extern SpriteSet *objectSprites; // object sprites
extern gToolBase G_BASE;
extern char ***nameList; // handle to list of names
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index bb7007cdcb..bff7711bee 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -98,10 +98,10 @@ extern uint8 fixedColors[] = {
101, 104, 130, 132, 197, 199, 228, 230
};
-SpriteSet **objectSprites, // object sprites
- * *mentalSprites, // intangible object sprites
- * *weaponSprites[maxWeaponSpriteSets], // weapon sprites
- * *missileSprites; // missile sprites
+SpriteSet *objectSprites, // object sprites
+ *mentalSprites, // intangible object sprites
+ *weaponSprites[maxWeaponSpriteSets], // weapon sprites
+ *missileSprites; // missile sprites
hResContext *spriteRes, // sprite resource handle
*frameRes, // framelist resource handle
@@ -124,15 +124,17 @@ static uint8 *quickMemBase,
int32 quickMemSize;
void initQuickMem(int32 size) {
- quickMemBase = (uint8 *)RNewPtr(size, NULL, "Quickmem heap");
- if (quickMemBase == NULL)
+ quickMemBase = new uint8[size]();
+ if (quickMemBase == nullptr)
error("Error: Memory allocation size %d failed!", size);
quickMemSize = size;
quickMemPtr = quickMemBase;
}
void cleanupQuickMem(void) {
- RDisposePtr(quickMemBase);
+ if (quickMemBase)
+ delete[] quickMemBase;
+ quickMemBase = nullptr;
}
void *getQuickMem(int32 size) {
@@ -308,7 +310,7 @@ void DrawCompositeMaskedSprite(
effects |= sprFXGhosted;
}
- if (obscured != NULL) *obscured = isObscured;
+ if (obscured != nullptr) *obscured = isObscured;
freeQuickMem(tempMap.data);
}
@@ -615,11 +617,11 @@ void ActorAppearance::loadSpriteBanks(int16 banksNeeded) {
washHandle((RHANDLE &)(spriteBanks[bank]));
// Load the sprite handle...
- if (spriteBanks[bank] == NULL && (banksNeeded & (1 << bank))) {
+ if (spriteBanks[bank] == nullptr && (banksNeeded & (1 << bank))) {
spriteBanks[bank] = (SpriteSet **)spriteRes->load(id + MKTAG(0, 0, 0, bank), "sprite bank", FALSE);
#if DEBUG
- if (spriteBanks[bank] == NULL)
+ if (spriteBanks[bank] == nullptr)
fatal("Sprite '%s' bank %d failed to load!\n",
idname(id),
bank);
@@ -643,10 +645,10 @@ ActorAppearance *LoadActorAppearance(uint32 id, int16 banksNeeded) {
// Search the table for either a matching appearance,
// or for an empty one.
for (aa = (ActorAppearance *)appearanceLRU.first();
- aa != NULL;
+ aa != nullptr;
aa = (ActorAppearance *)aa->next()) {
if (aa->id == id // If has same ID
- && aa->poseList != NULL) { // and frames not dumped
+ && aa->poseList != nullptr) { // and frames not dumped
// then use this one!
aa->useCount++;
aa->loadSpriteBanks(banksNeeded);
@@ -656,17 +658,17 @@ ActorAppearance *LoadActorAppearance(uint32 id, int16 banksNeeded) {
// If we couldn't find an extact match, search for an
// empty one.
- if (aa == NULL) {
+ if (aa == nullptr) {
// Search from LRU end of list.
for (aa = (ActorAppearance *)appearanceLRU.first();
- aa != NULL;
+ aa != nullptr;
aa = (ActorAppearance *)aa->next()) {
if (aa->useCount == 0) // If not in use
break; // then use this one!
}
// If none available, that's fatal...
- if (aa == NULL) {
+ if (aa == nullptr) {
error("All ActorAppearance records are in use!");
}
}
@@ -675,14 +677,14 @@ ActorAppearance *LoadActorAppearance(uint32 id, int16 banksNeeded) {
for (bank = 0; bank < elementsof(aa->spriteBanks); bank++) {
if (aa->spriteBanks[bank])
spriteRes->release((RHANDLE) aa->spriteBanks[bank]);
- aa->spriteBanks[bank] = NULL;
+ aa->spriteBanks[bank] = nullptr;
}
if (aa->poseList) poseRes->release((RHANDLE) aa->poseList);
- aa->poseList = NULL;
+ aa->poseList = nullptr;
if (aa->schemeList) schemeRes->release((RHANDLE) aa->schemeList);
- aa->schemeList = NULL;
+ aa->schemeList = nullptr;
// Set ID and use count
aa->id = id;
@@ -694,7 +696,7 @@ ActorAppearance *LoadActorAppearance(uint32 id, int16 banksNeeded) {
// I just added these - dispnode may have to lock & unlock the handle now - EO
if (aa->poseList) RUnlockHandle((RHANDLE) aa->poseList);
#if DEBUG
- if (aa->poseList == NULL)
+ if (aa->poseList == nullptr)
fatal("PoseList '%s' failed to load!\n", idname(id));
#endif
// REM: It's OK if schemelist fails to load...
@@ -737,11 +739,11 @@ void initSprites(void) {
assert(schemeRes && schemeRes->_valid);
// object sprites
- objectSprites = (SpriteSet **)spriteRes->load(objectSpriteID, "object sprites");
+ objectSprites = (SpriteSet *)spriteRes->loadResource(objectSpriteID, "object sprites");
assert(objectSprites);
// intagible object sprites
- mentalSprites = (SpriteSet **)spriteRes->load(mentalSpriteID, "mental sprites");
+ mentalSprites = (SpriteSet *)spriteRes->loadResource(mentalSpriteID, "mental sprites");
assert(mentalSprites);
for (i = 0; i < maxWeaponSpriteSets; i++) {
@@ -750,16 +752,16 @@ void initSprites(void) {
weaponSpriteID = weaponSpriteBaseID + MKTAG(0, 0, 0, i);
if (spriteRes->size(weaponSpriteID) == 0) {
- weaponSprites[i] = NULL;
+ weaponSprites[i] = nullptr;
continue;
}
- weaponSprites[i] = (SpriteSet **)spriteRes->load(
+ weaponSprites[i] = (SpriteSet *)spriteRes->loadResource(
weaponSpriteID,
"weapon sprite set");
}
- missileSprites = (SpriteSet **)spriteRes->load(missileSpriteID, "missle sprites");
+ missileSprites = (SpriteSet *)spriteRes->loadResource(missileSpriteID, "missle sprites");
initQuickMem(0x10000);
@@ -777,30 +779,32 @@ void cleanupSprites(void) {
cleanupQuickMem();
- if (objectSprites) spriteRes->release((RHANDLE) objectSprites);
- objectSprites = NULL;
+ if (objectSprites)
+ free(objectSprites);
+ objectSprites = nullptr;
- if (mentalSprites) spriteRes->release((RHANDLE) mentalSprites);
- mentalSprites = NULL;
+ if (mentalSprites)
+ free(mentalSprites);
+ mentalSprites = nullptr;
for (i = 0; i < maxWeaponSpriteSets; i++) {
if (weaponSprites[i]) {
- spriteRes->release((RHANDLE) weaponSprites[i]);
- weaponSprites[i] = NULL;
+ free(weaponSprites[i]);
+ weaponSprites[i] = nullptr;
}
}
if (schemeRes) resFile->disposeContext(schemeRes);
- schemeRes = NULL;
+ schemeRes = nullptr;
if (poseRes) resFile->disposeContext(poseRes);
- poseRes = NULL;
+ poseRes = nullptr;
if (frameRes) resFile->disposeContext(frameRes);
- frameRes = NULL;
+ frameRes = nullptr;
if (spriteRes) resFile->disposeContext(spriteRes);
- spriteRes = NULL;
+ spriteRes = nullptr;
}
} // end of namespace Saga2
diff --git a/engines/saga2/sprite.h b/engines/saga2/sprite.h
index c0aacf7787..3f3a00bd9e 100644
--- a/engines/saga2/sprite.h
+++ b/engines/saga2/sprite.h
@@ -73,10 +73,10 @@ struct SpriteSet {
};
-extern SpriteSet **objectSprites, // object sprites
- * *mentalSprites, // intagible object sprites
- * *weaponSprites[], // weapon sprites
- * *missileSprites; // missile sprites
+extern SpriteSet *objectSprites, // object sprites
+ *mentalSprites, // intagible object sprites
+ *weaponSprites[], // weapon sprites
+ *missileSprites; // missile sprites
/* ===================================================================== *
Describes the facing directions of actor sprites
Commit: 5969577a2b48bf44d48fee774f32b600def1443e
https://github.com/scummvm/scummvm/commit/5969577a2b48bf44d48fee774f32b600def1443e
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:57+02:00
Commit Message:
SAGA2: Fix object prototypes initialization
Changed paths:
engines/saga2/objects.cpp
engines/saga2/objects.h
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 7de69b416a..48b69fd5fe 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -66,23 +66,23 @@ const uint32 nameListID = MKTAG('N', 'A', 'M', 'E'),
Locals
* ===================================================================== */
-uint16 **nameList; // handle to list of names
+uint16 *nameList; // handle to list of names
uint32 nameListCount;
-ProtoObj *objectProtos = NULL; // object prototypes
-ActorProto *actorProtos = NULL; // actor prototypes
-uint16 *tempActorCount = NULL; // array of temporary actor counts
+ProtoObj *objectProtos = nullptr; // object prototypes
+ActorProto *actorProtos = nullptr; // actor prototypes
+uint16 *tempActorCount = nullptr; // array of temporary actor counts
int16 objectProtoCount, // object prototype count
actorProtoCount; // actor prototype count
-GameObject *objectList = NULL; // list of all objects
+GameObject *objectList = nullptr; // list of all objects
int16 objectCount; // count of objects
-Actor *actorList = NULL; // list of all actors
+Actor *actorList = nullptr; // list of all actors
int16 actorCount;
-GameWorld *worldList = NULL; // list of all worlds
+GameWorld *worldList = nullptr; // list of all worlds
int16 worldCount; // number of worlds
int32 objectListSize,
@@ -100,7 +100,7 @@ uint8 *ProtoObj::nextAvailObj;
// trio ready container consts
-const ContainerInfo trioReadyContInfo[ kNumViews ] = { { 476, 105 + 0, 1, 3 },
+const ContainerInfo trioReadyContInfo[kNumViews] = { { 476, 105 + 0, 1, 3 },
{ 476, 105 + 150, 1, 3 },
{ 476, 105 + 300, 1, 3 }
};
@@ -109,9 +109,9 @@ const ContainerInfo indivReadyContInfoTop = { 476, 105 + 0, 1, 3 };
const ContainerInfo indivReadyContInfoBot = { 476, 105 + 57, 2, 3 };
// view controls
-ReadyContainerView *TrioCviews[ kNumViews ] = { NULL, NULL, NULL };
-ReadyContainerView *indivCviewTop = NULL,
- *indivCviewBot = NULL;
+ReadyContainerView *TrioCviews[kNumViews] = { nullptr, nullptr, nullptr };
+ReadyContainerView *indivCviewTop = nullptr,
+ *indivCviewBot = nullptr;
ContainerNode *indivReadyNode;
// array of image pointers for ready container backgrounds
@@ -194,7 +194,7 @@ struct GameObjectArchive {
// Default constructor
GameObject::GameObject(void) {
- prototype = NULL;
+ prototype = nullptr;
location = Nowhere;
nameIndex = 0;
parentID = Nothing;
@@ -215,7 +215,7 @@ GameObject::GameObject(void) {
// Constructor -- initial object construction
GameObject::GameObject(const ResourceGameObject &res) {
- prototype = &objectProtos[ res.protoIndex ];
+ prototype = &objectProtos[res.protoIndex];
location = res.location;
nameIndex = res.nameIndex;
parentID = res.parentID;
@@ -240,8 +240,8 @@ GameObject::GameObject(void **buf) {
// Convert the protoype index into an object proto pointer
prototype = a->protoIndex != -1
- ? &objectProtos[ a->protoIndex ]
- : NULL;
+ ? &objectProtos[a->protoIndex]
+ : nullptr;
location = a->location;
nameIndex = a->nameIndex;
@@ -258,7 +258,7 @@ GameObject::GameObject(void **buf) {
sightCtr = a->sightCtr;
memset(&reserved, 0, sizeof(reserved));
- *buf = &a[ 1 ];
+ *buf = &a[1];
}
//-----------------------------------------------------------------------
@@ -276,7 +276,7 @@ void *GameObject::archive(void *buf) {
GameObjectArchive *a = (GameObjectArchive *)buf;
// Convert the prototype pointer to a prototype index
- a->protoIndex = prototype != NULL ? prototype - objectProtos : -1;
+ a->protoIndex = prototype != nullptr ? prototype - objectProtos : -1;
a->location = location;
a->nameIndex = nameIndex;
@@ -292,7 +292,7 @@ void *GameObject::archive(void *buf) {
a->currentTAG = currentTAG;
a->sightCtr = sightCtr;
- return &a[ 1 ];
+ return &a[1];
}
// Same as above but use object addresses instead of ID's
@@ -320,26 +320,26 @@ GameObject *GameObject::objectAddress(ObjectID id) {
if (id >= objectCount)
error("Invalid object ID: %d", id);
- return objectList != NULL ? &objectList[ id ] : NULL;
+ return objectList != nullptr ? &objectList[id] : nullptr;
}
if (isWorld(id)) {
if (id - WorldBaseID >= worldCount)
error("Invalid object ID: %d", id);
- return worldList != NULL ? &worldList[ id - WorldBaseID ] : NULL;
+ return worldList != nullptr ? &worldList[id - WorldBaseID] : nullptr;
}
if (id - ActorBaseID >= actorCount)
error("Invalid object ID: %d!", id);
- return actorList != NULL ? &actorList[ id - ActorBaseID ] : NULL;
+ return actorList != nullptr ? &actorList[id - ActorBaseID] : nullptr;
}
ProtoObj *GameObject::protoAddress(ObjectID id) {
GameObject *obj = objectAddress(id);
- return obj ? obj->prototype : NULL ;
+ return obj ? obj->prototype : nullptr ;
}
@@ -380,8 +380,8 @@ ObjectID *GameObject::getHeadPtr(ObjectID parentID, TilePoint &l) {
int16 u = clamp(0, l.u / sectorSize, sectors.u - 1),
v = clamp(0, l.v / sectorSize, sectors.v - 1);
- return &(*world->sectorArray)[
- v * world->sectorArraySize + u ].childID;
+ return &(world->sectorArray)[
+ v * world->sectorArraySize + u].childID;
} else return &parentObj->childID;
}
@@ -522,7 +522,7 @@ void GameObject::objCursorText(char nameBuf[], const int8 size, int16 count) {
// put the object name into the buffer as a default value
strncpy(nameBuf, objName(), size - 1);
- nameBuf[ size - 1 ] = NULL;
+ nameBuf[size - 1] = 0;
assert(strlen(objName()) < size - addTextSize);
@@ -567,8 +567,8 @@ void GameObject::objCursorText(char nameBuf[], const int8 size, int16 count) {
SkillProto *sProto = skillProtoFromID(thisID());
// determine if this is a skill icon
- manaColor = spellBook[ sProto->getSpellID() ].getManaType();
- manaCost = spellBook[ sProto->getSpellID() ].getManaAmt();
+ manaColor = spellBook[sProto->getSpellID()].getManaType();
+ manaCost = spellBook[sProto->getSpellID()].getManaAmt();
}
if (manaColor == sManaIDSkill) { // It's a skill
@@ -584,7 +584,7 @@ void GameObject::objCursorText(char nameBuf[], const int8 size, int16 count) {
brotherID == ActorBaseID + FTA_PHILIP ||
brotherID == ActorBaseID + FTA_KEVIN) {
// get base 0 level
- level = playerList[ brotherID - ActorBaseID ].getSkillLevel(sProto);
+ level = playerList[brotherID - ActorBaseID].getSkillLevel(sProto);
// normalize and output
sprintf(nameBuf, "%s-%d", objName(), ++level);
@@ -618,7 +618,7 @@ bool GameObject::isTrueSkill(void) {
SkillProto *sProto = skillProtoFromID(thisID());
// determine if this is a skill icon
- if (spellBook[ sProto->getSpellID() ].getManaType() == sManaIDSkill) {
+ if (spellBook[sProto->getSpellID()].getManaType() == sManaIDSkill) {
return TRUE;
}
}
@@ -654,8 +654,8 @@ GameWorld *GameObject::world(void) {
for (;;) {
id = obj->parentID;
- if (isWorld(id)) return &worldList[ id - WorldBaseID ];
- else if (id == Nothing) return NULL;
+ if (isWorld(id)) return &worldList[id - WorldBaseID];
+ else if (id == Nothing) return nullptr;
obj = objectAddress(id);
}
@@ -701,8 +701,8 @@ int32 GameObject::getSprOffset(int16 num) {
// Remove an object from a stack of objects
bool GameObject::unstack(void) {
GameObject *item,
- *base = NULL,
- *zero = NULL;
+ *base = nullptr,
+ *zero = nullptr;
int16 count = 0;
// If this is a world, or it's parent object is a world, or it is
@@ -712,7 +712,7 @@ bool GameObject::unstack(void) {
|| isWorld(parent())
|| IDParent() == Nothing
|| location.z == 1
- || prototype == NULL
+ || prototype == nullptr
|| (prototype->containmentSet() & ProtoObj::isIntangible)) return FALSE;
ContainerIterator iter(parent());
@@ -736,9 +736,9 @@ bool GameObject::unstack(void) {
//
// Else if this item is not the base item, then decrement the base
// item's count by setting it to all but one of the count of items.
- if (this == base && zero != NULL)
+ if (this == base && zero != nullptr)
zero->location.z = count - 1;
- else if (base != NULL) base->location.z = count - 1;
+ else if (base != nullptr) base->location.z = count - 1;
// Set this item's count to 1
location.z = 1;
@@ -948,7 +948,7 @@ void GameObject::updateImage(ObjectID oldParentID) {
a->rightHandObject = Nothing;
for (i = 0; i < ARMOR_COUNT; i++) {
- if (a->armorObjects[ i ] == id) {
+ if (a->armorObjects[i] == id) {
a->wear(Nothing, i);
break;
}
@@ -1048,10 +1048,10 @@ GameObject *GameObject::extractMerged(int16 num) {
// massCount should never go negitive
assert(massCount >= 0);
} else
- return NULL;
+ return nullptr;
} else {
// not a mergable object return unsuccess
- return NULL;
+ return nullptr;
}
return GameObject::objectAddress(extractedID);
@@ -1072,7 +1072,7 @@ void GameObject::moveRandom(const TilePoint &minLoc, const TilePoint &maxLoc) {
newLoc.v = GetRandomBetween(minLoc.v, maxLoc.v);
newLoc.z = location.z; //For Now Keep Z Coord Same
//If Flags == Collision Check
- if (objectCollision(this, world(), newLoc) == NULL) { //If No Collision
+ if (objectCollision(this, world(), newLoc) == nullptr) { //If No Collision
move(newLoc);//Move It Else Try Again
break;
}
@@ -1095,7 +1095,7 @@ ObjectID GameObject::copy(const Location &l) {
error("Actor copying not yet implemented.\n");
} else {
- if ((newObj = newObject()) == NULL) return Nothing;
+ if ((newObj = newObject()) == nullptr) return Nothing;
newObj->prototype = prototype;
newObj->nameIndex = nameIndex;
@@ -1127,7 +1127,7 @@ ObjectID GameObject::copy(const Location &l, int16 num) {
error("Actor copying not yet implemented.");
} else {
- if ((newObj = newObject()) == NULL) return Nothing;
+ if ((newObj = newObject()) == nullptr) return Nothing;
newObj->prototype = prototype;
@@ -1141,7 +1141,7 @@ ObjectID GameObject::copy(const Location &l, int16 num) {
// this did occur before any of the assignments
// but that caused a crash when the it tried to update
// the image during the move and tried to access the prototype
- // pointer field, which is set to NULL after a newObject()
+ // pointer field, which is set to nullptr after a newObject()
newObj->move(l);
}
@@ -1172,7 +1172,7 @@ GameObject *GameObject::newObject(void) { // get a newly created object
// Search object list for the first scavengable object we can find
for (i = ImportantLimbo + 1; i < objectCount; i++) {
- obj = &objectList[ i ];
+ obj = &objectList[i];
if (obj->isScavengable()
&& !obj->isActivated()
@@ -1183,14 +1183,14 @@ GameObject *GameObject::newObject(void) { // get a newly created object
// REM: If things start getting really tight, we can
// start recycling common objects...
- if (i >= objectCount) return NULL;
+ if (i >= objectCount) return nullptr;
} else {
objectLimboCount--;
obj = limbo->child();
}
obj->remove();
- obj->prototype = NULL;
+ obj->prototype = nullptr;
obj->nameIndex = 0;
obj->script = 0;
obj->objectFlags = 0;
@@ -1229,7 +1229,7 @@ void GameObject::deleteObject(void) {
removeAllSensors();
// Delete any container nodes for this object
- while ((cn = globalContainerList.find(dObj)) != NULL)
+ while ((cn = globalContainerList.find(dObj)) != nullptr)
delete cn;
if (isActor(parentID)) {
@@ -1241,7 +1241,7 @@ void GameObject::deleteObject(void) {
if (a->rightHandObject == id) a->rightHandObject = Nothing;
for (i = 0; i < elementsof(a->armorObjects); i++)
- if (a->armorObjects[ i ] == id)
+ if (a->armorObjects[i] == id)
a->wear(Nothing, i);
}
@@ -1309,11 +1309,11 @@ void GameObject::deleteObjectRecursive(void) {
*nextChildObj;
for (childObj = objectAddress(childID);
- childObj != NULL;
+ childObj != nullptr;
childObj = nextChildObj) {
nextChildObj = childObj->siblingID != Nothing
? objectAddress(childObj->siblingID)
- : NULL;
+ : nullptr;
childObj->deleteObjectRecursive();
}
}
@@ -1421,7 +1421,7 @@ void GameObject::updateState(void) {
int32 subTileTerrain =
- sti.surfaceTile != NULL
+ sti.surfaceTile != nullptr
? sti.surfaceTile->attrs.testTerrain(calcSubTileMask(subTile.u,
subTile.v))
: 0;
@@ -1461,11 +1461,11 @@ void GameObject::updateState(void) {
* ======================================================================= */
char *GameObject::nameText(uint16 index) {
- uint16 offset = (*nameList)[ index ];
+ uint16 offset = nameList[index];
if (index < 0 || index >= nameListCount) return "Bad Name Index";
- return (char *)(*nameList) + offset;
+ return (char *)nameList + offset;
}
#define INTANGIBLE_MASK (ProtoObj::isEnchantment|ProtoObj::isSpell|ProtoObj::isSkill)
@@ -1488,7 +1488,7 @@ TilePoint GameObject::getFirstEmptySlot(GameObject *obj) {
ContainerIterator iter(this);
//This Is The Largest The Row Column Can Be
- static bool slotTable[ maxRow ][ maxCol ];
+ static bool slotTable[maxRow][maxCol];
memset(&slotTable, '\0', sizeof(slotTable)); //Initialize Table To FALSE
@@ -1508,14 +1508,14 @@ TilePoint GameObject::getFirstEmptySlot(GameObject *obj) {
//Verify Not Writing Outside Array
if (temp.u >= 0 && temp.v >= 0 && temp.u < numRows && temp.v < numCols) {
- slotTable[ temp.u ][ temp.v ] = TRUE;
+ slotTable[temp.u][temp.v] = TRUE;
}
}
//Go Through Table Until Find A FALSE and Return That Value
for (int16 u = 0; u < numRows; u++) {
for (int16 v = 0; v < numCols; v++) {
- if (!slotTable[ u ][ v ]) {
+ if (!slotTable[u][v]) {
newLoc.v = v;
newLoc.u = u;
newLoc.z = 1;
@@ -1537,14 +1537,14 @@ bool GameObject::getAvailableSlot(
bool canMerge,
GameObject **mergeObj) {
assert(isObject(obj));
- assert(tp != NULL);
- assert(!canMerge || mergeObj != NULL);
+ assert(tp != nullptr);
+ assert(!canMerge || mergeObj != nullptr);
- if (prototype == NULL) return FALSE;
+ if (prototype == nullptr) return FALSE;
ProtoObj *objProto = obj->proto();
- if (canMerge) *mergeObj = NULL;
+ if (canMerge) *mergeObj = nullptr;
// Determine if the specified object is an intagible container
if ((objProto->containmentSet()
@@ -1606,7 +1606,7 @@ bool GameObject::placeObject(
*mergeObj;
if (getAvailableSlot(obj, &slot, canMerge, &mergeObj)) {
- if (canMerge && mergeObj != NULL)
+ if (canMerge && mergeObj != nullptr)
return obj->dropOn(enactor, mergeObj->thisID(), num);
else
return obj->drop(enactor, Location(slot, thisID()), num);
@@ -1638,7 +1638,7 @@ void GameObject::dropInventoryObject(GameObject *obj, int16 count) {
StandingTileInfo sti;
// Compute a location to place the object
- probeLoc = location + incDirTable[ dir ] * dist;
+ probeLoc = location + incDirTable[dir] * dist;
probeLoc.u += (rand() & 0x3) - 2;
probeLoc.v += (rand() & 0x3) - 2;
probeLoc.z = tileSlopeHeight(probeLoc, mapNum, obj, &sti);
@@ -1647,7 +1647,7 @@ void GameObject::dropInventoryObject(GameObject *obj, int16 count) {
if (checkBlocked(obj, mapNum, probeLoc) == blockageNone) {
// If we're dropping the object on a TAI, make sure
// we call the correct drop function
- if (sti.surfaceTAG == NULL) {
+ if (sti.surfaceTAG == nullptr) {
obj->drop(
thisID(),
Location(probeLoc, parentID),
@@ -1676,7 +1676,7 @@ void GameObject::protoAddressToOffset() {
ProtoObj *actorBase = &actorProtos[0];
int32 newProto, size = sizeof(ResourceObjectPrototype) + 4;//Add 4 for jump Table
- if (prototype == NULL) return;
+ if (prototype == nullptr) return;
warning("STUB: GameObject::protoAddressToOffset(): unsafe pointer arithmetics");
@@ -1702,7 +1702,7 @@ GameObject *GameObject::getIntangibleContainer(int containerType) {
}
- return NULL;
+ return nullptr;
}
//-----------------------------------------------------------------------
@@ -1788,13 +1788,13 @@ bool GameObject::addTimer(TimerID id, int16 frameInterval) {
*timerInList;
// Create the new timer
- if ((newTimer = new Timer(this, id, frameInterval)) == NULL)
+ if ((newTimer = new Timer(this, id, frameInterval)) == nullptr)
return FALSE;
// Fetch the existing timer list for this object or create a
// new one
- if ((timerList = fetchTimerList(this)) == NULL
- && (timerList = new TimerList(this)) == NULL) {
+ if ((timerList = fetchTimerList(this)) == nullptr
+ && (timerList = new TimerList(this)) == nullptr) {
delete newTimer;
return FALSE;
}
@@ -1804,7 +1804,7 @@ bool GameObject::addTimer(TimerID id, int16 frameInterval) {
// Search the list to see if there is already a timer with same
// ID as the new timer. If so, remove it and delete it.
for (timerInList = (Timer *)timerList->first();
- timerInList != NULL;
+ timerInList != nullptr;
timerInList = (Timer *)timerInList->next()) {
assert(timerInList->getObject() == this);
@@ -1829,12 +1829,12 @@ void GameObject::removeTimer(TimerID id) {
TimerList *timerList;
// Get this object's timer list
- if ((timerList = fetchTimerList(this)) != NULL) {
+ if ((timerList = fetchTimerList(this)) != nullptr) {
Timer *timer;
// Search the timer list for a timer with the specified ID
for (timer = (Timer *)timerList->first();
- timer != NULL;
+ timer != nullptr;
timer = (Timer *)timer->next()) {
if (timer->thisID() == id) {
// Remove the timer, then delete it
@@ -1857,13 +1857,13 @@ void GameObject::removeAllTimers(void) {
TimerList *timerList;
// Get this object's timer list
- if ((timerList = fetchTimerList(this)) != NULL) {
+ if ((timerList = fetchTimerList(this)) != nullptr) {
Timer *timer,
*nextTimer;
// Iterate through the timers
for (timer = (Timer *)timerList->first();
- timer != NULL;
+ timer != nullptr;
timer = nextTimer) {
// Save the pointer to the next timer
nextTimer = (Timer *)timer->next();
@@ -1889,8 +1889,8 @@ bool GameObject::addSensor(Sensor *newSensor) {
// Fetch the existing sensor list for this object or allocate a
// new one
- if ((sensorList = fetchSensorList(this)) == NULL
- && (sensorList = new SensorList(this)) == NULL)
+ if ((sensorList = fetchSensorList(this)) == nullptr
+ && (sensorList = new SensorList(this)) == nullptr)
return FALSE;
assert(sensorList->getObject() == this);
@@ -1898,7 +1898,7 @@ bool GameObject::addSensor(Sensor *newSensor) {
// Search the list to see if there is already a sensor with same
// ID as the new sensor. If so, remove it and delete it.
for (sensorInList = (Sensor *)sensorList->first();
- sensorInList != NULL;
+ sensorInList != nullptr;
sensorInList = (Sensor *)sensorInList->next()) {
assert(sensorInList->getObject() == this);
@@ -1924,7 +1924,7 @@ bool GameObject::addProtaganistSensor(SensorID id, int16 range) {
bool sensorAdded;
newSensor = new ProtaganistSensor(this, id, range);
- if (newSensor == NULL) return FALSE;
+ if (newSensor == nullptr) return FALSE;
sensorAdded = addSensor(newSensor);
if (!sensorAdded) delete newSensor;
@@ -1940,7 +1940,7 @@ bool GameObject::addSpecificActorSensor(SensorID id, int16 range, Actor *a) {
bool sensorAdded;
newSensor = new SpecificActorSensor(this, id, range, a);
- if (newSensor == NULL) return FALSE;
+ if (newSensor == nullptr) return FALSE;
sensorAdded = addSensor(newSensor);
if (!sensorAdded) delete newSensor;
@@ -1959,7 +1959,7 @@ bool GameObject::addSpecificObjectSensor(
bool sensorAdded;
newSensor = new SpecificObjectSensor(this, id, range, obj);
- if (newSensor == NULL) return FALSE;
+ if (newSensor == nullptr) return FALSE;
sensorAdded = addSensor(newSensor);
if (!sensorAdded) delete newSensor;
@@ -1978,7 +1978,7 @@ bool GameObject::addActorPropertySensor(
bool sensorAdded;
newSensor = new ActorPropertySensor(this, id, range, prop);
- if (newSensor == NULL) return FALSE;
+ if (newSensor == nullptr) return FALSE;
sensorAdded = addSensor(newSensor);
if (!sensorAdded) delete newSensor;
@@ -1997,7 +1997,7 @@ bool GameObject::addObjectPropertySensor(
bool sensorAdded;
newSensor = new ObjectPropertySensor(this, id, range, prop);
- if (newSensor == NULL) return FALSE;
+ if (newSensor == nullptr) return FALSE;
sensorAdded = addSensor(newSensor);
if (!sensorAdded) delete newSensor;
@@ -2016,7 +2016,7 @@ bool GameObject::addEventSensor(
bool sensorAdded;
newSensor = new EventSensor(this, id, range, eventType);
- if (newSensor == NULL) return FALSE;
+ if (newSensor == nullptr) return FALSE;
sensorAdded = addSensor(newSensor);
if (!sensorAdded) delete newSensor;
@@ -2031,12 +2031,12 @@ void GameObject::removeSensor(SensorID id) {
SensorList *sensorList;
// Get this object's sensor list
- if ((sensorList = fetchSensorList(this)) != NULL) {
+ if ((sensorList = fetchSensorList(this)) != nullptr) {
Sensor *sensor;
// Search the sensor list for a sensor with the specified ID
for (sensor = (Sensor *)sensorList->first();
- sensor != NULL;
+ sensor != nullptr;
sensor = (Sensor *)sensor->next()) {
if (sensor->thisID() == id) {
// Remove the sensor, then delete it
@@ -2059,13 +2059,13 @@ void GameObject::removeAllSensors(void) {
SensorList *sensorList;
// Get this object's sensor list
- if ((sensorList = fetchSensorList(this)) != NULL) {
+ if ((sensorList = fetchSensorList(this)) != nullptr) {
Sensor *sensor,
*nextSensor;
// Iterate through the sensors
for (sensor = (Sensor *)sensorList->first();
- sensor != NULL;
+ sensor != nullptr;
sensor = nextSensor) {
// Save the pointer to the next sensor
nextSensor = (Sensor *)sensor->next();
@@ -2176,12 +2176,12 @@ int32 GameObject::getProtoNum(void) {
void GameObject::setProtoNum(int32 nProto) {
if (isActor(this))
- prototype = &actorProtos[ nProto ];
+ prototype = &actorProtos[nProto];
else {
ObjectID oldParentID = parentID;
bool wasStacked = unstack(); // Unstack if it was in a stack
- prototype = &objectProtos[ nProto ];
+ prototype = &objectProtos[nProto];
if (wasStacked) {
ObjectID pos = possessor();
@@ -2368,18 +2368,16 @@ GameWorld::GameWorld(int16 map) {
size.v = size.u;
sectorArraySize = size.u / Saga2::sectorSize;
- sectorArray = (Sector **)RNewClearHandle(
- sectorArraySize * sectorArraySize * sizeof(Sector),
- NULL, "sector array");
+ sectorArray = new Sector[sectorArraySize * sectorArraySize]();
- if (sectorArray == NULL)
+ if (sectorArray == nullptr)
error("Unable to allocate world %d sector array", map);
mapNum = map;
} else {
size.u = size.v = 0;
sectorArraySize = 0;
- sectorArray = NULL;
+ sectorArray = nullptr;
mapNum = -1;
}
@@ -2400,20 +2398,17 @@ GameWorld::GameWorld(void **buf) {
sectorArraySize = size.u / Saga2::sectorSize;
sectorArrayBytes =
sectorArraySize * sectorArraySize * sizeof(Sector),
- sectorArray = (Sector **)RNewHandle(
- sectorArrayBytes,
- NULL,
- "sector array");
+ sectorArray = new Sector[sectorArrayBytes]();
- if (sectorArray == NULL)
+ if (sectorArray == nullptr)
error("Unable to allocate world %d sector array", mapNum);
- memcpy(*sectorArray, bufferPtr, sectorArrayBytes);
+ memcpy(sectorArray, bufferPtr, sectorArrayBytes);
bufferPtr = (int16 *)((int8 *)bufferPtr + sectorArrayBytes);
} else {
sectorArraySize = 0;
- sectorArray = NULL;
+ sectorArray = nullptr;
}
*buf = bufferPtr;
@@ -2442,7 +2437,7 @@ void *GameWorld::archive(void *buf) {
*bufferPtr++ = size.u;
*bufferPtr++ = mapNum;
- memcpy(bufferPtr, *sectorArray, sectorArrayBytes);
+ memcpy(bufferPtr, sectorArray, sectorArrayBytes);
warning("FIXME: Unsafe pointer arithmetics in GameWorld::archive()");
return (void *)(bufferPtr + sectorArrayBytes);
@@ -2452,9 +2447,9 @@ void *GameWorld::archive(void *buf) {
// Cleanup
void GameWorld::cleanup(void) {
- if (sectorArray != NULL) {
- RDisposeHandle((RHANDLE)sectorArray);
- sectorArray = NULL;
+ if (sectorArray != nullptr) {
+ delete[] sectorArray;
+ sectorArray = nullptr;
}
}
@@ -2470,8 +2465,8 @@ extern int enchantmentProto;
void initPrototypes(void) {
int i;
- nameList = (uint16 **)listRes->load(nameListID, "name list");
- nameListCount = listRes->size(nameListID) / sizeof nameList[ 0 ];
+ nameList = (uint16 *)listRes->loadResource(nameListID, "name list");
+ nameListCount = listRes->size(nameListID) / sizeof nameList[0];
// Load the Object prototype table
@@ -2481,10 +2476,7 @@ void initPrototypes(void) {
if (objectProtoCount < 1)
error("Unable to load Object Prototypes");
- objectProtos = (ProtoObj *)RNewPtr(
- objectProtoCount * sizeof(ProtoObj),
- NULL,
- "object prototypes");
+ objectProtos = (ProtoObj *)malloc(objectProtoCount * sizeof (ProtoObj));
if (listRes->seek(objProtoID) == 0)
error("Unable to load Object Prototypes");
@@ -2494,7 +2486,7 @@ void initPrototypes(void) {
for (i = 0; i < objectProtoCount; i++) {
ResourceObjectPrototype ro;
- ProtoObj *pr = &objectProtos[ i ];
+ ProtoObj *pr = &objectProtos[i];
listRes->read(&ro, sizeof(ResourceObjectPrototype));
@@ -2631,17 +2623,14 @@ void initPrototypes(void) {
if (actorProtoCount < 1)
error("Unable to load Actor Prototypes");
- actorProtos = (ActorProto *)RNewPtr(
- actorProtoCount * sizeof(ActorProto),
- NULL,
- "actor prototypes");
+ actorProtos = (ActorProto *)malloc(actorProtoCount * sizeof(ActorProto));
if (listRes->seek(actorProtoID) == 0)
error("Unable to load Actor Prototypes");
for (i = 0; i < actorProtoCount; i++) {
ResourceActorPrototype ra;
- ActorProto *pr = &actorProtos[ i ];
+ ActorProto *pr = &actorProtos[i];
listRes->read(&ra, sizeof(ResourceActorPrototype));
@@ -2655,14 +2644,14 @@ void initPrototypes(void) {
// Cleanup the prototype lists
void cleanupPrototypes(void) {
- if (actorProtos != NULL) {
- RDisposePtr(actorProtos);
- actorProtos = NULL;
+ if (actorProtos != nullptr) {
+ free(actorProtos);
+ actorProtos = nullptr;
}
- if (objectProtos != NULL) {
- RDisposePtr(objectProtos);
- objectProtos = NULL;
+ if (objectProtos != nullptr) {
+ free(objectProtos);
+ objectProtos = nullptr;
}
}
@@ -2675,7 +2664,7 @@ void initObjectSoundFXTable(void) {
itemRes = auxResFile->newContext(
MKTAG('I', 'T', 'E', 'M'),
"item resources");
- if (itemRes == NULL || !itemRes->_valid)
+ if (itemRes == nullptr || !itemRes->_valid)
error("Error accessing item resource group.\n");
objectSoundFXTable =
@@ -2684,7 +2673,7 @@ void initObjectSoundFXTable(void) {
MKTAG('S', 'N', 'D', 'T'),
"object sound effect table");
- if (objectSoundFXTable == NULL)
+ if (objectSoundFXTable == nullptr)
error("Unable to load object sound effects table");
auxResFile->disposeContext(itemRes);
@@ -2694,9 +2683,9 @@ void initObjectSoundFXTable(void) {
// Cleanup the sound effects table
void cleanupObjectSoundFXTable(void) {
- if (objectSoundFXTable != NULL) {
- RDisposePtr(objectSoundFXTable);
- objectSoundFXTable = NULL;
+ if (objectSoundFXTable != nullptr) {
+ free(objectSoundFXTable);
+ objectSoundFXTable = nullptr;
}
}
@@ -2707,12 +2696,9 @@ void initTempActorCount(void) {
uint16 i;
// Allocate and initialize the temp actor count array
- tempActorCount = (uint16 *)RNewPtr(
- actorProtoCount * sizeof(uint16),
- NULL,
- "temp actor count array");
+ tempActorCount = new uint16[actorProtoCount];
for (i = 0; i < actorProtoCount; i++)
- tempActorCount[ i ] = 0;
+ tempActorCount[i] = 0;
}
//-------------------------------------------------------------------
@@ -2728,10 +2714,7 @@ void saveTempActorCount(SaveFileConstructor &saveGame) {
// Load the array of temp actor counts
void loadTempActorCount(SaveFileReader &saveGame) {
- tempActorCount = (uint16 *)RNewPtr(
- saveGame.getChunkSize(),
- NULL,
- "temp actor count array");
+ tempActorCount = new uint16[saveGame.getChunkSize()];
saveGame.read(tempActorCount, saveGame.getChunkSize());
}
@@ -2739,9 +2722,9 @@ void loadTempActorCount(SaveFileReader &saveGame) {
// Cleanup the array to temp actor counts
void cleanupTempActorCount(void) {
- if (tempActorCount != NULL) {
- RDisposePtr(tempActorCount);
- tempActorCount = NULL;
+ if (tempActorCount != nullptr) {
+ delete[] tempActorCount;
+ tempActorCount = nullptr;
}
}
@@ -2749,21 +2732,21 @@ void cleanupTempActorCount(void) {
// Increment the temporary actor count for the specified prototype
void incTempActorCount(uint16 protoNum) {
- tempActorCount[ protoNum ]++;
+ tempActorCount[protoNum]++;
}
//-------------------------------------------------------------------
// Decrement the temporary actor count for the specified prototype
void decTempActorCount(uint16 protoNum) {
- tempActorCount[ protoNum ]--;
+ tempActorCount[protoNum]--;
}
//-------------------------------------------------------------------
// Return the number of temporary actors for the specified prototype
uint16 getTempActorCount(uint16 protoNum) {
- return tempActorCount[ protoNum ];
+ return tempActorCount[protoNum];
}
//-------------------------------------------------------------------
@@ -2775,17 +2758,17 @@ void initWorlds(void) {
// worldCount must be set by the map data initialization
worldListSize = worldCount * sizeof(GameWorld);
- worldList = (GameWorld *)RNewPtr(worldListSize, NULL, "world list");
- if (worldList == NULL)
+ worldList = new GameWorld[worldListSize]();
+ if (worldList == nullptr)
error("Unable to allocate world list");
for (i = 0; i < worldCount; i++) {
- GameWorld *gw = &worldList[ i ];
+ GameWorld *gw = &worldList[i];
new (gw) GameWorld(i);
}
- currentWorld = &worldList[ 0 ];
+ currentWorld = &worldList[0];
setCurrentMap(currentWorld->mapNum);
}
@@ -2804,10 +2787,10 @@ void saveWorlds(SaveFileConstructor &saveGame) {
archiveBufSize += sizeof(ObjectID);
for (i = 0; i < worldCount; i++)
- archiveBufSize += worldList[ i ].archiveSize();
+ archiveBufSize += worldList[i].archiveSize();
- archiveBuffer = RNewPtr(archiveBufSize, NULL, "archive buffer");
- if (archiveBuffer == NULL)
+ archiveBuffer = malloc(archiveBufSize);
+ if (archiveBuffer == nullptr)
error("Unable to allocate world archive buffer");
bufferPtr = archiveBuffer;
@@ -2818,7 +2801,7 @@ void saveWorlds(SaveFileConstructor &saveGame) {
// Store the world data in the archive buffer
for (i = 0; i < worldCount; i++)
- bufferPtr = worldList[ i ].archive(bufferPtr);
+ bufferPtr = worldList[i].archive(bufferPtr);
// Write the archive buffer to the save file
saveGame.writeChunk(
@@ -2826,7 +2809,7 @@ void saveWorlds(SaveFileConstructor &saveGame) {
archiveBuffer,
archiveBufSize);
- RDisposePtr(archiveBuffer);
+ free(archiveBuffer);
}
//-------------------------------------------------------------------
@@ -2841,15 +2824,12 @@ void loadWorlds(SaveFileReader &saveGame) {
// worldCount must be set by the map data initialization
worldListSize = worldCount * sizeof(GameWorld);
- worldList = (GameWorld *)RNewPtr(worldListSize, NULL, "world list");
- if (worldList == NULL)
+ worldList = new GameWorld[worldListSize]();
+ if (worldList == nullptr)
error("Unable to allocate world list");
- archiveBuffer = RNewPtr(
- saveGame.getChunkSize(),
- NULL,
- "archive buffer");
- if (archiveBuffer == NULL)
+ archiveBuffer = malloc(saveGame.getChunkSize());
+ if (archiveBuffer == nullptr)
error("Unable to allocate world data buffer");
saveGame.read(archiveBuffer, saveGame.getChunkSize());
@@ -2865,9 +2845,9 @@ void loadWorlds(SaveFileReader &saveGame) {
i < worldCount;
i++)
// Restore the world's data
- new (&worldList[ i ]) GameWorld(&bufferPtr);
+ new (&worldList[i]) GameWorld(&bufferPtr);
- RDisposePtr(archiveBuffer);
+ free(archiveBuffer);
// Reset the current world
currentWorld = (GameWorld *)GameObject::objectAddress(currentWorldID);
@@ -2879,12 +2859,12 @@ void loadWorlds(SaveFileReader &saveGame) {
void cleanupWorlds(void) {
for (int i = 0; i < worldCount; i++) {
- GameWorld *gw = &worldList[ i ];
+ GameWorld *gw = &worldList[i];
gw->cleanup();
}
- if (worldList != NULL) RDisposePtr(worldList);
+ if (worldList != nullptr) delete[] worldList;
}
//-------------------------------------------------------------------
@@ -2912,21 +2892,15 @@ void initObjects(void) {
// Allocate memory for the object list
objectListSize = objectCount * sizeof(GameObject);
- objectList = (GameObject *)RNewClearPtr(
- objectListSize,
- NULL,
- "object list");
+ objectList = new GameObject[objectCount]();
- if (objectList == NULL)
+ if (objectList == nullptr)
error("Unable to load Objects");
// Allocate memory for the resource objects
- resourceObjectList = (ResourceGameObject *)RNewClearPtr(
- resourceObjectCount
- * sizeof(ResourceGameObject),
- NULL, "res object list");
+ resourceObjectList = new ResourceGameObject[resourceObjectCount]();
- if (resourceObjectList == NULL || listRes->seek(objListID) == 0)
+ if (resourceObjectList == nullptr || listRes->seek(objListID) == 0)
error("Unable to load Objects");
// Read the resource Objects
@@ -2934,7 +2908,7 @@ void initObjects(void) {
sizeof(ResourceGameObject) * resourceObjectCount);
for (i = 0; i < resourceObjectCount; i++) {
- GameObject *obj = &objectList[ i ];
+ GameObject *obj = &objectList[i];
if (i < 4)
// First four object are limbos, so use the default
@@ -2942,23 +2916,23 @@ void initObjects(void) {
new (obj) GameObject;
else
// Initialize the objects with the resource data
- new (obj) GameObject(resourceObjectList[ i ]);
+ new (obj) GameObject(resourceObjectList[i]);
}
for (; i < objectCount; i++) {
- GameObject *obj = &objectList[ i ];
+ GameObject *obj = &objectList[i];
// Use the default constructor for the extra actors
new (obj) GameObject;
}
- RDisposePtr(resourceObjectList);
+ delete[] resourceObjectList;
// Go through the object list and initialize all objects.
//Add Object To World
for (i = 0; i < resourceObjectCount; i++) {
- GameObject *obj = &objectList[ i ],
+ GameObject *obj = &objectList[i],
*parent;
TilePoint slot;
@@ -2985,7 +2959,7 @@ void initObjects(void) {
}
for (; i < objectCount; i++) {
- GameObject *obj = &objectList[ i ];
+ GameObject *obj = &objectList[i];
obj->siblingID = obj->childID = Nothing;
obj->append(ObjectLimbo);
@@ -2996,7 +2970,7 @@ void initObjects(void) {
// Make a pass over the actor list appending each actor to their
// parent's child list
for (i = 0; i < actorCount; i++) {
- Actor *a = &actorList[ i ];
+ Actor *a = &actorList[i];
if (a->parentID == Nothing) {
a->append(ActorLimbo);
@@ -3025,8 +2999,8 @@ void saveObjects(SaveFileConstructor &saveGame) {
+ sizeof(importantLimboCount)
+ objectListSize;
- archiveBuffer = RNewPtr(archiveBufSize, NULL, "archive buffer");
- if (archiveBuffer == NULL)
+ archiveBuffer = malloc(archiveBufSize);
+ if (archiveBuffer == nullptr)
error("Cannot allocate object list archive buffer");
bufferPtr = archiveBuffer;
@@ -3045,7 +3019,7 @@ void saveObjects(SaveFileConstructor &saveGame) {
i < objectCount;
i++, currentObj++) {
*((int16 *)¤tObj->prototype) =
- currentObj->prototype != NULL
+ currentObj->prototype != nullptr
? currentObj->prototype - objectProtos
: -1;
}
@@ -3055,7 +3029,7 @@ void saveObjects(SaveFileConstructor &saveGame) {
archiveBuffer,
archiveBufSize);
- RDisposePtr(archiveBuffer);
+ free(archiveBuffer);
}
//-------------------------------------------------------------------
@@ -3074,8 +3048,8 @@ void loadObjects(SaveFileReader &saveGame) {
objectListSize = saveGame.bytesLeftInChunk();
objectCount = objectListSize / sizeof(GameObject);
- objectList = (GameObject *)RNewPtr(objectListSize, NULL, "object list");
- if (objectList == NULL)
+ objectList = new GameObject[objectCount]();
+ if (objectList == nullptr)
error("Unable to load Objects");
saveGame.read(objectList, objectListSize);
@@ -3086,8 +3060,8 @@ void loadObjects(SaveFileReader &saveGame) {
// convert prototype ID number to actual prototype address
obj->prototype =
*((int16 *)&obj->prototype) != -1
- ? &objectProtos[ *((int16 *)&obj->prototype) ]
- : NULL;
+ ? &objectProtos[*((int16 *)&obj->prototype)]
+ : nullptr;
}
}
@@ -3095,7 +3069,8 @@ void loadObjects(SaveFileReader &saveGame) {
// Cleanup object list
void cleanupObjects(void) {
- if (objectList != NULL) RDisposePtr(objectList);
+ if (objectList != nullptr)
+ delete[] objectList;
mainDisplayList.reset();
}
@@ -3124,7 +3099,7 @@ void getViewTrackPos(TilePoint &tp) {
GameObject *getViewCenterObject(void) {
return viewCenterObject != Nothing
? GameObject::objectAddress(viewCenterObject)
- : NULL;
+ : nullptr;
}
/* ======================================================================= *
@@ -3262,7 +3237,7 @@ void ActiveRegion::update(void) {
// Global active region array
-static ActiveRegion activeRegionList[ playerActors ];
+static ActiveRegion activeRegionList[playerActors];
//-------------------------------------------------------------------
// Iterate through the active regions, updating each
@@ -3271,28 +3246,28 @@ void updateActiveRegions(void) {
int16 i;
for (i = 0; i < elementsof(activeRegionList); i++)
- activeRegionList[ i ].update();
+ activeRegionList[i].update();
}
//-------------------------------------------------------------------
// Return a pointer to an active region given its PlayerActor's ID
ActiveRegion *getActiveRegion(PlayerActorID id) {
- return &activeRegionList[ id ];
+ return &activeRegionList[id];
}
//-------------------------------------------------------------------
// Initialize the state of the active regions
void initActiveRegions(void) {
- static PlayerActorID playerIDArray[ playerActors ] =
+ static PlayerActorID playerIDArray[playerActors] =
{ FTA_JULIAN, FTA_PHILIP, FTA_KEVIN };
int16 i;
for (i = 0; i < playerActors; i++) {
- ActiveRegion *reg = &activeRegionList[ i ];
- ObjectID actorID = getPlayerActorAddress(playerIDArray[ i ])->getActorID();
+ ActiveRegion *reg = &activeRegionList[i];
+ ObjectID actorID = getPlayerActorAddress(playerIDArray[i])->getActorID();
reg->anchor = actorID;
reg->anchorLoc = Nowhere;
@@ -3328,7 +3303,7 @@ void loadActiveRegions(SaveFileReader &saveGame) {
SectorRegionObjectIterator::SectorRegionObjectIterator(GameWorld *world) :
searchWorld(world) {
- assert(searchWorld != NULL);
+ assert(searchWorld != nullptr);
assert(isWorld(searchWorld));
minSector = TilePoint(0, 0, 0);
@@ -3341,7 +3316,7 @@ SectorRegionObjectIterator::SectorRegionObjectIterator(GameWorld *world) :
ObjectID SectorRegionObjectIterator::first(GameObject **obj) {
Sector *currentSector;
- currentObject = NULL;
+ currentObject = nullptr;
sectorCoords = minSector;
currentSector = searchWorld->getSector(sectorCoords.u, sectorCoords.v);
@@ -3349,7 +3324,7 @@ ObjectID SectorRegionObjectIterator::first(GameObject **obj) {
if (++sectorCoords.v >= maxSector.v) {
sectorCoords.v = minSector.v;
if (++sectorCoords.u >= maxSector.u) {
- if (obj != NULL) *obj = NULL;
+ if (obj != nullptr) *obj = nullptr;
return Nothing;
}
}
@@ -3361,7 +3336,7 @@ ObjectID SectorRegionObjectIterator::first(GameObject **obj) {
currentObject = GameObject::objectAddress(currentSector->childID);
- if (obj != NULL) *obj = currentObject;
+ if (obj != nullptr) *obj = currentObject;
return currentSector->childID;
}
@@ -3385,7 +3360,7 @@ ObjectID SectorRegionObjectIterator::next(GameObject **obj) {
if (++sectorCoords.v >= maxSector.v) {
sectorCoords.v = minSector.v;
if (++sectorCoords.u >= maxSector.u) {
- if (obj != NULL) *obj = NULL;
+ if (obj != nullptr) *obj = nullptr;
return Nothing;
}
}
@@ -3401,7 +3376,7 @@ ObjectID SectorRegionObjectIterator::next(GameObject **obj) {
currentObject = GameObject::objectAddress(currentObjectID);
- if (obj != NULL) *obj = currentObject;
+ if (obj != nullptr) *obj = currentObject;
return currentObjectID;
}
@@ -3455,8 +3430,8 @@ ObjectID RadialObjectIterator::first(GameObject **obj, int16 *dist) {
currentObjectID = SectorRegionObjectIterator::next(¤tObject);
}
- if (dist != NULL) *dist = currentDist;
- if (obj != NULL) *obj = currentObject;
+ if (dist != nullptr) *dist = currentDist;
+ if (obj != nullptr) *obj = currentObject;
return currentObjectID;
}
@@ -3475,8 +3450,8 @@ ObjectID RadialObjectIterator::next(GameObject **obj, int16 *dist) {
computeDist(currentObject->getLocation()))
> radius);
- if (dist != NULL) *dist = currentDist;
- if (obj != NULL) *obj = currentObject;
+ if (dist != nullptr) *dist = currentDist;
+ if (obj != nullptr) *obj = currentObject;
return currentObjectID;
}
@@ -3506,7 +3481,7 @@ ObjectID RingObjectIterator::first(GameObject **obj) {
currentObjectID = CircularObjectIterator::next(¤tObject);
}
- if (obj != NULL) *obj = currentObject;
+ if (obj != nullptr) *obj = currentObject;
return currentObjectID;
}
@@ -3520,7 +3495,7 @@ ObjectID RingObjectIterator::next(GameObject **obj) {
} while (currentObjectID != Nothing
&& computeDist(currentObject->getLocation()) < innerDist);
- if (obj != NULL) *obj = currentObject;
+ if (obj != nullptr) *obj = currentObject;
return currentObjectID;
}
@@ -3596,7 +3571,7 @@ ObjectID RegionalObjectIterator::first(GameObject **obj) {
currentObjectID = SectorRegionObjectIterator::next(¤tObject);
}
- if (obj != NULL) *obj = currentObject;
+ if (obj != nullptr) *obj = currentObject;
return currentObjectID;
}
@@ -3612,7 +3587,7 @@ ObjectID RegionalObjectIterator::next(GameObject **obj) {
} while (currentObjectID != Nothing
&& !inRegion(currentObject->getLocation()));
- if (obj != NULL) *obj = currentObject;
+ if (obj != nullptr) *obj = currentObject;
return currentObjectID;
}
@@ -3660,7 +3635,7 @@ ObjectID RectangularObjectIterator::first(GameObject **obj) {
currentObjectID = RegionalObjectIterator::next(¤tObject);
}
- if (obj != NULL) *obj = currentObject;
+ if (obj != nullptr) *obj = currentObject;
return currentObjectID;
}
@@ -3676,7 +3651,7 @@ ObjectID RectangularObjectIterator::next(GameObject **obj) {
} while (currentObjectID != Nothing
&& !inRegion(currentObject->getLocation()));
- if (obj != NULL) *obj = currentObject;
+ if (obj != nullptr) *obj = currentObject;
return currentObjectID;
}
@@ -3723,7 +3698,7 @@ ObjectID TriangularObjectIterator::first(GameObject **obj) {
currentObjectID = RegionalObjectIterator::next(¤tObject);
}
- if (obj != NULL) *obj = currentObject;
+ if (obj != nullptr) *obj = currentObject;
return currentObjectID;
}
@@ -3739,7 +3714,7 @@ ObjectID TriangularObjectIterator::next(GameObject **obj) {
} while (currentObjectID != Nothing
&& !inRegion(currentObject->getLocation()));
- if (obj != NULL) *obj = currentObject;
+ if (obj != nullptr) *obj = currentObject;
return currentObjectID;
}
@@ -3790,7 +3765,7 @@ bool ActiveRegionObjectIterator::nextActiveRegion(void) {
int16 prevRegionIndex;
- currentRegion = &activeRegionList[ activeRegionIndex ];
+ currentRegion = &activeRegionList[activeRegionIndex];
sectorBitMask = 0;
currentRegionSize.u = currentRegion->region.max.u
@@ -3804,7 +3779,7 @@ bool ActiveRegionObjectIterator::nextActiveRegion(void) {
prevRegionIndex++) {
ActiveRegion *prevRegion;
- prevRegion = &activeRegionList[ prevRegionIndex ];
+ prevRegion = &activeRegionList[prevRegionIndex];
// Determine if the current region and the previous region
// overlap.
@@ -3924,7 +3899,7 @@ bool ActiveRegionObjectIterator::nextSector(void) {
ObjectID ActiveRegionObjectIterator::first(GameObject **obj) {
ObjectID currentObjectID = Nothing;
- currentObject = NULL;
+ currentObject = nullptr;
if (firstSector()) {
Sector *currentSector;
@@ -3933,12 +3908,12 @@ ObjectID ActiveRegionObjectIterator::first(GameObject **obj) {
sectorCoords.u,
sectorCoords.v);
- assert(currentSector != NULL);
+ assert(currentSector != nullptr);
currentObjectID = currentSector->childID;
currentObject = currentObjectID != Nothing
? GameObject::objectAddress(currentObjectID)
- : NULL;
+ : nullptr;
while (currentObjectID == Nothing) {
if (!nextSector()) break;
@@ -3947,16 +3922,16 @@ ObjectID ActiveRegionObjectIterator::first(GameObject **obj) {
sectorCoords.u,
sectorCoords.v);
- assert(currentSector != NULL);
+ assert(currentSector != nullptr);
currentObjectID = currentSector->childID;
currentObject = currentObjectID != Nothing
? GameObject::objectAddress(currentObjectID)
- : NULL;
+ : nullptr;
}
}
- if (obj != NULL) *obj = currentObject;
+ if (obj != nullptr) *obj = currentObject;
return currentObjectID;
}
@@ -3972,7 +3947,7 @@ ObjectID ActiveRegionObjectIterator::next(GameObject **obj) {
currentObjectID = currentObject->IDNext();
currentObject = currentObjectID != Nothing
? GameObject::objectAddress(currentObjectID)
- : NULL;
+ : nullptr;
while (currentObjectID == Nothing) {
Sector *currentSector;
@@ -3983,15 +3958,15 @@ ObjectID ActiveRegionObjectIterator::next(GameObject **obj) {
sectorCoords.u,
sectorCoords.v);
- assert(currentSector != NULL);
+ assert(currentSector != nullptr);
currentObjectID = currentSector->childID;
currentObject = currentObjectID != Nothing
? GameObject::objectAddress(currentObjectID)
- : NULL;
+ : nullptr;
}
- if (obj != NULL) *obj = currentObject;
+ if (obj != nullptr) *obj = currentObject;
return currentObjectID;
}
@@ -4004,7 +3979,7 @@ ObjectID ActiveRegionObjectIterator::next(GameObject **obj) {
ContainerIterator::ContainerIterator(GameObject *container) {
// Get the ID of the 1st object in the sector list
nextID = &container->childID;
- object = NULL;
+ object = nullptr;
}
ObjectID ContainerIterator::next(GameObject **obj) {
@@ -4027,17 +4002,17 @@ ObjectID ContainerIterator::next(GameObject **obj) {
// This class iterates through every object within a container
RecursiveContainerIterator::~RecursiveContainerIterator(void) {
- if (subIter != NULL) delete subIter;
+ if (subIter != nullptr) delete subIter;
}
ObjectID RecursiveContainerIterator::first(GameObject **obj) {
- if (subIter != NULL) delete subIter;
+ if (subIter != nullptr) delete subIter;
id(container->IDChild()),
- if (obj != NULL)
- *obj = id != Nothing ? GameObject::objectAddress(id) : NULL;
+ if (obj != nullptr)
+ *obj = id != Nothing ? GameObject::objectAddress(id) : nullptr;
return id;
}
@@ -4054,7 +4029,7 @@ ObjectID RecursiveContainerIterator::next(GameObject **obj) {
}
delete subIter;
- subIter = NULL;
+ subIter = nullptr;
currentObj = GameObject::objectAddress(id);
} else {
currentObj = GameObject::objectAddress(id);
@@ -4067,8 +4042,8 @@ ObjectID RecursiveContainerIterator::next(GameObject **obj) {
}
id = currentObj->IDNext();
- if (obj != NULL)
- *obj = id != Nothing ? GameObject::objectAddress(id) : NULL;
+ if (obj != nullptr)
+ *obj = id != Nothing ? GameObject::objectAddress(id) : nullptr;
return id;
}
#endif
@@ -4084,8 +4059,8 @@ ObjectID RecursiveContainerIterator::first(GameObject **obj) {
id = rootObj->IDChild();
- if (obj != NULL)
- *obj = id != Nothing ? GameObject::objectAddress(id) : NULL;
+ if (obj != nullptr)
+ *obj = id != Nothing ? GameObject::objectAddress(id) : nullptr;
return id;
}
@@ -4095,14 +4070,14 @@ ObjectID RecursiveContainerIterator::next(GameObject **obj) {
// If this object has a child, then the next object (id) is the child.
// If it has no child, then check for sibling.
- if ((id = currentObj->IDChild()) == NULL) {
+ if ((id = currentObj->IDChild()) == 0) {
// If this object has a sibling, then the next object (id) is the sibling.
// If it has no sibling, then check for parent.
- while ((id = currentObj->IDNext()) == NULL) {
+ while ((id = currentObj->IDNext()) == 0) {
// If this object has a parent, then the get the parent.
- if ((id = currentObj->IDParent()) != NULL) {
+ if ((id = currentObj->IDParent()) != 0) {
// If the parent is the root, then we're done.
- if (id == Nothing || id == root) return NULL;
+ if (id == Nothing || id == root) return 0;
// Set the current object to the parent, and then
// Go around the loop once again and get the sibling of the parent.
@@ -4114,8 +4089,8 @@ ObjectID RecursiveContainerIterator::next(GameObject **obj) {
}
}
- if (obj != NULL)
- *obj = id != Nothing ? GameObject::objectAddress(id) : NULL;
+ if (obj != nullptr)
+ *obj = id != Nothing ? GameObject::objectAddress(id) : nullptr;
return id;
}
@@ -4143,7 +4118,7 @@ GameObject *objectCollision(GameObject *obj, GameWorld *world, const TilePoint &
CircularObjectIterator iter(world, loc, proto->crossSection + 32);
for (iter.first(&obstacle);
- obstacle != NULL;
+ obstacle != nullptr;
iter.next(&obstacle)) {
TilePoint tp = obstacle->getLocation();
ProtoObj *proto = obstacle->proto();
@@ -4162,7 +4137,7 @@ GameObject *objectCollision(GameObject *obj, GameWorld *world, const TilePoint &
return obstacle;
}
}
- return NULL;
+ return nullptr;
}
/* ======================================================================= *
@@ -4354,7 +4329,7 @@ APPFUNC(cmdBrain) {
}
} else if (ev.eventType == gEventMouseMove) {
if (ev.value == gCompImage::leave) {
- mouseInfo.setText(NULL);
+ mouseInfo.setText(nullptr);
} else { //if (ev.value == gCompImage::enter)
// set the text in the cursor
if (part == 0) mouseInfo.setText(IDEAS_INVENT);
@@ -4377,23 +4352,23 @@ void readyContainerSetup(void) {
indivReadyNode = CreateReadyContainerNode(0);
for (i = 0; i < kNumViews && i < playerActors ; i++) {
- playerList[ i ].readyNode = CreateReadyContainerNode(i);
+ playerList[i].readyNode = CreateReadyContainerNode(i);
- TrioCviews[ i ] = new ReadyContainerView(
+ TrioCviews[i] = new ReadyContainerView(
*trioControls,
- Rect16(trioReadyContInfo[ i ].xPos,
- trioReadyContInfo[ i ].yPos + 8,
- iconOriginX * 2 + iconWidth * trioReadyContInfo[ i ].cols + iconSpacingY * (trioReadyContInfo[ i ].cols - 1),
- iconOriginY + (iconOriginY * trioReadyContInfo[ i ].rows) + (trioReadyContInfo[ i ].rows * iconHeight) - 23),
- *playerList[ i ].readyNode,
+ Rect16(trioReadyContInfo[i].xPos,
+ trioReadyContInfo[i].yPos + 8,
+ iconOriginX * 2 + iconWidth * trioReadyContInfo[i].cols + iconSpacingY * (trioReadyContInfo[i].cols - 1),
+ iconOriginY + (iconOriginY * trioReadyContInfo[i].rows) + (trioReadyContInfo[i].rows * iconHeight) - 23),
+ *playerList[i].readyNode,
backImages,
numReadyContRes,
- trioReadyContInfo[ i ].rows,
- trioReadyContInfo[ i ].cols,
- trioReadyContInfo[ i ].rows,
+ trioReadyContInfo[i].rows,
+ trioReadyContInfo[i].cols,
+ trioReadyContInfo[i].rows,
0);
- TrioCviews[ i ]->draw();
+ TrioCviews[i]->draw();
}
indivCviewTop = new ReadyContainerView(*indivControls,
@@ -4444,27 +4419,27 @@ void cleanupReadyContainers(void) {
for (i = 0; i < kNumViews && i < playerActors ; i++) {
delete TrioCviews[i];
- TrioCviews[ i ] = NULL;
+ TrioCviews[i] = nullptr;
- delete playerList[ i ].readyNode;
- playerList[ i ].readyNode = NULL;
+ delete playerList[i].readyNode;
+ playerList[i].readyNode = nullptr;
}
delete indivReadyNode;
}
if (indivCviewTop) {
delete indivCviewTop;
- indivCviewTop = NULL;
+ indivCviewTop = nullptr;
}
if (indivCviewBot) {
delete indivCviewBot;
- indivCviewBot = NULL;
+ indivCviewBot = nullptr;
}
//
if (imageRes) resFile->disposeContext(imageRes);
- imageRes = NULL;
+ imageRes = nullptr;
}
#endif
@@ -4556,7 +4531,7 @@ void doBackgroundSimulation(void) {
while (objectUpdateCount--) {
GameObject *obj;
- obj = &objectList[ objectIndex++ ];
+ obj = &objectList[objectIndex++];
// Wrap the counter around to the beginning if needed
if (objectIndex >= objectCount) objectIndex = 0;
@@ -4587,7 +4562,7 @@ void doBackgroundSimulation(void) {
while (actorUpdateCount--) {
Actor *a;
- a = &actorList[ actorIndex++ ];
+ a = &actorList[actorIndex++];
// Wrap the counter around to the beginning if needed
if (actorIndex >= actorCount) actorIndex = 0;
@@ -4622,15 +4597,15 @@ void updateObjectStates(void) {
if (objectStatesPaused) return;
GameObject *obj,
- *last = &objectList[ objectCount ];
+ *last = &objectList[objectCount];
static int16 baseIndex = 0;
// baseIndex = (baseIndex + 1) & ~3;
baseIndex = 0;
-// for ( obj = &objectList[ baseIndex ]; obj < last; obj += 4 )
- for (obj = &objectList[ baseIndex ]; obj < last; obj++) {
+// for ( obj = &objectList[baseIndex]; obj < last; obj += 4 )
+ for (obj = &objectList[baseIndex]; obj < last; obj++) {
if (isWorld(obj->IDParent()) && obj->isActivated())
obj->updateState();
}
diff --git a/engines/saga2/objects.h b/engines/saga2/objects.h
index a26f9e2e96..6fba794c7f 100644
--- a/engines/saga2/objects.h
+++ b/engines/saga2/objects.h
@@ -758,7 +758,7 @@ class GameWorld : public GameObject {
TilePoint size; // size of world in U/V coords
int16 sectorArraySize; // size of sector array
- Sector **sectorArray; // array of sectors
+ Sector *sectorArray; // array of sectors
public:
int16 mapNum; // map number for this world.
@@ -777,7 +777,7 @@ public:
void cleanup(void);
Sector *getSector(int16 u, int16 v) {
- return &(*sectorArray)[ v * sectorArraySize + u ];
+ return &(sectorArray)[ v * sectorArraySize + u ];
}
TilePoint sectorSize(void) { // size of map in sectors
Commit: f74ed3eabb67d99ad4be5b3b8b45870b23edff8d
https://github.com/scummvm/scummvm/commit/f74ed3eabb67d99ad4be5b3b8b45870b23edff8d
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:58+02:00
Commit Message:
SAGA2: Fix objects.cpp more
Changed paths:
engines/saga2/objects.cpp
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 48b69fd5fe..c906bade97 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -483,11 +483,11 @@ bool GameObject::getWorldLocation(Location &loc) {
loc = obj->location;
loc.z += (obj->prototype->height - objHeight) / 2;
loc.context = id;
- return TRUE;
+ return true;
} else if (id == Nothing) {
loc = Nowhere;
loc.context = Nothing;
- return FALSE;
+ return false;
}
obj = objectAddress(id);
@@ -619,11 +619,11 @@ bool GameObject::isTrueSkill(void) {
// determine if this is a skill icon
if (spellBook[sProto->getSpellID()].getManaType() == sManaIDSkill) {
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
// Returns the location of an object within the world
@@ -713,7 +713,7 @@ bool GameObject::unstack(void) {
|| IDParent() == Nothing
|| location.z == 1
|| prototype == nullptr
- || (prototype->containmentSet() & ProtoObj::isIntangible)) return FALSE;
+ || (prototype->containmentSet() & ProtoObj::isIntangible)) return false;
ContainerIterator iter(parent());
@@ -742,7 +742,7 @@ bool GameObject::unstack(void) {
// Set this item's count to 1
location.z = 1;
- return TRUE;
+ return true;
}
// Move the object to a new location, and change context if needed.
@@ -853,13 +853,13 @@ bool GameObject::deductCharge(ActorManaID manaID, uint16 manaCost) {
ProtoObj *po = GameObject::protoAddress(thisID());
assert(po);
- // if this is not a chargeable item, then return FALSE
+ // if this is not a chargeable item, then return false
if (!getChargeType()) {
- return FALSE;
+ return false;
}
if (po->maxCharges == Permanent || bParam == Permanent) {
- return TRUE;
+ return true;
}
if (po->maxCharges == 0) {
@@ -872,27 +872,27 @@ bool GameObject::deductCharge(ActorManaID manaID, uint16 manaCost) {
if (bParam == 0) {
// not enough mana to use item
- return FALSE;
+ return false;
}
if (bParam > 0 && bParam < Permanent) {
bParam--;
}
- return TRUE;
+ return true;
}
bool GameObject::hasCharge(ActorManaID manaID, uint16 manaCost) {
ProtoObj *po = GameObject::protoAddress(thisID());
assert(po);
- // if this is not a chargeable item, then return FALSE
+ // if this is not a chargeable item, then return false
if (!getChargeType()) {
- return FALSE;
+ return false;
}
if (bParam == Permanent) {
- return TRUE;
+ return true;
}
if (po->maxCharges == 0) {
@@ -905,9 +905,9 @@ bool GameObject::hasCharge(ActorManaID manaID, uint16 manaCost) {
if (bParam == 0) {
// not enough mana to use item
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
@@ -985,9 +985,9 @@ void GameObject::updateImage(ObjectID oldParentID) {
bool GameObject::moveMerged(const Location &loc, int16 num) {
if (num < massCount
&& !extractMerged(Location(location, parentID), massCount - num))
- return FALSE;
+ return false;
move(loc);
- return TRUE;
+ return true;
}
@@ -1378,13 +1378,13 @@ bool GameObject::isContaining(GameObject *item) {
GameObject *containedObj;
while (iter.next(&containedObj) != Nothing) {
- if (containedObj == item) return TRUE;
+ if (containedObj == item) return true;
if (containedObj->childID != Nothing)
- if (containedObj->isContaining(item)) return TRUE;
+ if (containedObj->isContaining(item)) return true;
}
- return FALSE;
+ return false;
}
// Determine if an instance of the specified target is contained in this
@@ -1394,13 +1394,13 @@ bool GameObject::isContaining(ObjectTarget *objTarget) {
GameObject *containedObj;
while (iter.next(&containedObj) != Nothing) {
- if (objTarget->isTarget(containedObj)) return TRUE;
+ if (objTarget->isTarget(containedObj)) return true;
if (containedObj->childID != Nothing)
- if (containedObj->isContaining(objTarget)) return TRUE;
+ if (containedObj->isContaining(objTarget)) return true;
}
- return FALSE;
+ return false;
}
const int32 harmfulTerrain = terrainHot | terrainCold | terrainIce | terrainSlash | terrainBash;
@@ -1490,7 +1490,7 @@ TilePoint GameObject::getFirstEmptySlot(GameObject *obj) {
//This Is The Largest The Row Column Can Be
static bool slotTable[maxRow][maxCol];
- memset(&slotTable, '\0', sizeof(slotTable)); //Initialize Table To FALSE
+ memset(&slotTable, '\0', sizeof(slotTable)); //Initialize Table To false
// Iterate through all the objects in the container.
// Set The Filled Spots To True In Table
@@ -1508,11 +1508,11 @@ TilePoint GameObject::getFirstEmptySlot(GameObject *obj) {
//Verify Not Writing Outside Array
if (temp.u >= 0 && temp.v >= 0 && temp.u < numRows && temp.v < numCols) {
- slotTable[temp.u][temp.v] = TRUE;
+ slotTable[temp.u][temp.v] = true;
}
}
- //Go Through Table Until Find A FALSE and Return That Value
+ //Go Through Table Until Find A false and Return That Value
for (int16 u = 0; u < numRows; u++) {
for (int16 v = 0; v < numCols; v++) {
if (!slotTable[u][v]) {
@@ -1540,7 +1540,7 @@ bool GameObject::getAvailableSlot(
assert(tp != nullptr);
assert(!canMerge || mergeObj != nullptr);
- if (prototype == nullptr) return FALSE;
+ if (prototype == nullptr) return false;
ProtoObj *objProto = obj->proto();
@@ -1555,7 +1555,7 @@ bool GameObject::getAvailableSlot(
// Set intangible container locations to -1, -1.
tp->u = -1;
tp->v = -1;
- return TRUE;
+ return true;
}
// Only actors or containers may contain other objects
@@ -1573,7 +1573,7 @@ bool GameObject::getAvailableSlot(
!= cannotStackOrMerge) {
*tp = inventoryObj->getLocation();
*mergeObj = inventoryObj;
- return TRUE;
+ return true;
}
}
}
@@ -1581,11 +1581,11 @@ bool GameObject::getAvailableSlot(
// Nothing to merge with, so get an empty slot
if ((firstEmptySlot = getFirstEmptySlot(obj)) != Nowhere) {
*tp = firstEmptySlot;
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -1612,7 +1612,7 @@ bool GameObject::placeObject(
return obj->drop(enactor, Location(slot, thisID()), num);
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -1789,14 +1789,14 @@ bool GameObject::addTimer(TimerID id, int16 frameInterval) {
// Create the new timer
if ((newTimer = new Timer(this, id, frameInterval)) == nullptr)
- return FALSE;
+ return false;
// Fetch the existing timer list for this object or create a
// new one
if ((timerList = fetchTimerList(this)) == nullptr
&& (timerList = new TimerList(this)) == nullptr) {
delete newTimer;
- return FALSE;
+ return false;
}
assert(timerList->getObject() == this);
@@ -1819,7 +1819,7 @@ bool GameObject::addTimer(TimerID id, int16 frameInterval) {
// Put the new timer into the list
timerList->addTail(*newTimer);
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -1891,7 +1891,7 @@ bool GameObject::addSensor(Sensor *newSensor) {
// new one
if ((sensorList = fetchSensorList(this)) == nullptr
&& (sensorList = new SensorList(this)) == nullptr)
- return FALSE;
+ return false;
assert(sensorList->getObject() == this);
@@ -1913,7 +1913,7 @@ bool GameObject::addSensor(Sensor *newSensor) {
// Put the new sensor into the list
sensorList->addTail(*newSensor);
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -1924,7 +1924,7 @@ bool GameObject::addProtaganistSensor(SensorID id, int16 range) {
bool sensorAdded;
newSensor = new ProtaganistSensor(this, id, range);
- if (newSensor == nullptr) return FALSE;
+ if (newSensor == nullptr) return false;
sensorAdded = addSensor(newSensor);
if (!sensorAdded) delete newSensor;
@@ -1940,7 +1940,7 @@ bool GameObject::addSpecificActorSensor(SensorID id, int16 range, Actor *a) {
bool sensorAdded;
newSensor = new SpecificActorSensor(this, id, range, a);
- if (newSensor == nullptr) return FALSE;
+ if (newSensor == nullptr) return false;
sensorAdded = addSensor(newSensor);
if (!sensorAdded) delete newSensor;
@@ -1959,7 +1959,7 @@ bool GameObject::addSpecificObjectSensor(
bool sensorAdded;
newSensor = new SpecificObjectSensor(this, id, range, obj);
- if (newSensor == nullptr) return FALSE;
+ if (newSensor == nullptr) return false;
sensorAdded = addSensor(newSensor);
if (!sensorAdded) delete newSensor;
@@ -1978,7 +1978,7 @@ bool GameObject::addActorPropertySensor(
bool sensorAdded;
newSensor = new ActorPropertySensor(this, id, range, prop);
- if (newSensor == nullptr) return FALSE;
+ if (newSensor == nullptr) return false;
sensorAdded = addSensor(newSensor);
if (!sensorAdded) delete newSensor;
@@ -1997,7 +1997,7 @@ bool GameObject::addObjectPropertySensor(
bool sensorAdded;
newSensor = new ObjectPropertySensor(this, id, range, prop);
- if (newSensor == nullptr) return FALSE;
+ if (newSensor == nullptr) return false;
sensorAdded = addSensor(newSensor);
if (!sensorAdded) delete newSensor;
@@ -2016,7 +2016,7 @@ bool GameObject::addEventSensor(
bool sensorAdded;
newSensor = new EventSensor(this, id, range, eventType);
- if (newSensor == nullptr) return FALSE;
+ if (newSensor == nullptr) return false;
sensorAdded = addSensor(newSensor);
if (!sensorAdded) delete newSensor;
@@ -2276,10 +2276,10 @@ bool GameObject::merge(ObjectID enactor, ObjectID objToMergeID, int16 count) {
if (objToMerge->drop(enactor, loc, count)) {
if (!objToMerge->isMoving())
mergeWith(objToMerge, this, count);
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
bool GameObject::stack(ObjectID enactor, ObjectID objToStackID) {
@@ -2297,10 +2297,10 @@ bool GameObject::stack(ObjectID enactor, ObjectID objToStackID) {
globalContainerList.setUpdate(IDParent());
}
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
//-------------------------------------------------------------------
@@ -3761,7 +3761,7 @@ bool ActiveRegionObjectIterator::nextActiveRegion(void) {
do {
if (++activeRegionIndex >= elementsof(activeRegionList))
- return FALSE;
+ return false;
int16 prevRegionIndex;
@@ -3846,24 +3846,24 @@ bool ActiveRegionObjectIterator::nextActiveRegion(void) {
currentWorld = (GameWorld *)GameObject::objectAddress(
currentRegion->worldID);
- return TRUE;
+ return true;
}
//------------------------------------------------------------------------
bool ActiveRegionObjectIterator::firstSector(void) {
if (!firstActiveRegion())
- return FALSE;
+ return false;
sectorCoords.u = baseSectorCoords.u;
sectorCoords.v = baseSectorCoords.v;
if (sectorBitMask & 1) {
if (!nextSector())
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
//------------------------------------------------------------------------
@@ -3879,7 +3879,7 @@ bool ActiveRegionObjectIterator::nextSector(void) {
sectorCoords.u++;
if (sectorCoords.u >= baseSectorCoords.u + size.u) {
- if (!nextActiveRegion()) return FALSE;
+ if (!nextActiveRegion()) return false;
sectorCoords.u = baseSectorCoords.u;
sectorCoords.v = baseSectorCoords.v;
@@ -3890,7 +3890,7 @@ bool ActiveRegionObjectIterator::nextSector(void) {
v = sectorCoords.v - baseSectorCoords.v;
} while (sectorBitMask & (1 << (u * size.v + v)));
- return TRUE;
+ return true;
}
//------------------------------------------------------------------------
@@ -4171,17 +4171,17 @@ bool lineOfSight(GameObject *obj1, GameObject *obj2, uint32 terrainMask) {
// If the two objects are not in the same world, there is no line
// of sight
- if ((world = obj1->world()) != obj2->world()) return FALSE;
+ if ((world = obj1->world()) != obj2->world()) return false;
#if 0
if (isActor(obj1)) {
Actor *a1 = (Actor *) obj1;
if (!a1->hasEffect(actorSeeInvis)) {
if (!isActor(obj2) && obj2->isInvisible())
- return FALSE;
+ return false;
else if (isActor(obj2)) {
Actor *a2 = (Actor *) obj2;
if (a2->hasEffect(actorInvisible))
- return FALSE;
+ return false;
}
}
}
@@ -4256,7 +4256,7 @@ bool lineOfSight(
bool objObscured(GameObject *testObj) {
- bool obscured = FALSE;
+ bool obscured = false;
if (isObject(testObj)) {
Point16 drawPos,
@@ -4280,7 +4280,7 @@ bool objObscured(GameObject *testObj) {
drawPos,
testObj->getLocation(),
objRoofID(testObj)) <= 5)
- obscured = TRUE;
+ obscured = true;
}
return obscured;
@@ -4580,13 +4580,13 @@ void doBackgroundSimulation(void) {
// ------------------------------------------------------------------------
void pauseBackgroundSimulation(void) {
- backgroundSimulationPaused = TRUE;
+ backgroundSimulationPaused = true;
}
// ------------------------------------------------------------------------
void resumeBackgroundSimulation(void) {
- backgroundSimulationPaused = FALSE;
+ backgroundSimulationPaused = false;
}
//-------------------------------------------------------------------
@@ -4614,13 +4614,13 @@ void updateObjectStates(void) {
//-------------------------------------------------------------------
void pauseObjectStates(void) {
- objectStatesPaused = TRUE;
+ objectStatesPaused = true;
}
//-------------------------------------------------------------------
void resumeObjectStates(void) {
- objectStatesPaused = FALSE;
+ objectStatesPaused = false;
}
} // end of namespace Saga2
Commit: 72b159095fe401f939d28cfb2acaaaa43c74296f
https://github.com/scummvm/scummvm/commit/72b159095fe401f939d28cfb2acaaaa43c74296f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:58+02:00
Commit Message:
SAGA2: Turn loading from .exe into a data-driven
Changed paths:
engines/saga2/saga2.cpp
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index aead7a4445..a3175ac78a 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -176,6 +176,17 @@ static void loadFont(Common::File &file, gFont *font, uint32 offset) {
file.read(font->fontdata, size);
}
+struct dataChunks {
+ uint8 **ptr;
+ uint32 offset;
+ uint32 size;
+} chunks[] = {
+ { &loadingWindowPalette,0x004A2600, 1024 },
+ { &loadingWindowData, 0x004A2A00, 307200 },
+ { &ColorMapRanges, 0x004EDC20, 1584 },
+ { NULL, 0, 0 }
+};
+
void Saga2Engine::loadExeResources() {
Common::File exe;
const uint32 offset = 0x4F6D90 - 0xF4990;
@@ -193,17 +204,11 @@ void Saga2Engine::loadExeResources() {
loadFont(exe, &ThinFix8Font, 0x004FC210 - offset);
loadFont(exe, &Script10Font, 0x004FCD18 - offset);
- loadingWindowPalette = (uint8 *)malloc(1024);
- exe.seek(0x004A2600 - offset);
- exe.read(loadingWindowPalette, 1024);
-
- loadingWindowData = (uint8 *)malloc(307200);
- exe.seek(0x004A2A00 - offset);
- exe.read(loadingWindowData, 307200);
-
- ColorMapRanges = (uint8 *)malloc(1584);
- exe.seek(0x004EDC20 - offset);
- exe.read(ColorMapRanges, 1584);
+ for (int i = 0; chunks[i].ptr; i++) {
+ *chunks[i].ptr = (uint8 *)malloc(chunks[i].size);
+ exe.seek(chunks[i].offset - offset);
+ exe.read(*chunks[i].ptr, chunks[i].size);
+ }
exe.close();
}
Commit: ea35f4728e766d25aecac10ef5fa432794788ce4
https://github.com/scummvm/scummvm/commit/ea35f4728e766d25aecac10ef5fa432794788ce4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:58+02:00
Commit Message:
SAGA2: Load image cursors from .exe, delete images.*
Changed paths:
R engines/saga2/images.cpp
R engines/saga2/images.h
engines/saga2/dispnode.cpp
engines/saga2/document.cpp
engines/saga2/grabinfo.cpp
engines/saga2/grequest.cpp
engines/saga2/module.mk
engines/saga2/mouseimg.cpp
engines/saga2/mouseimg.h
engines/saga2/saga2.cpp
engines/saga2/tilemode.cpp
engines/saga2/towerfta.cpp
diff --git a/engines/saga2/dispnode.cpp b/engines/saga2/dispnode.cpp
index 2213ebe95b..2703231e8a 100644
--- a/engines/saga2/dispnode.cpp
+++ b/engines/saga2/dispnode.cpp
@@ -27,9 +27,9 @@
#include "saga2/std.h"
#include "saga2/blitters.h"
#include "saga2/spelshow.h"
-#include "saga2/images.h"
#include "saga2/player.h"
#include "saga2/sensor.h"
+#include "saga2/mouseimg.h"
namespace Saga2 {
@@ -808,7 +808,7 @@ void DisplayNode::drawObject(void) {
if (flags & displayIndicator) {
Point16 indicatorCoords;
- gPixelMap &indicator = CenterActorIndicatorImage;
+ gPixelMap &indicator = *mouseCursors[kMouseCenterActorIndicatorImage];
indicatorCoords.x = hitBox.x + fineScroll.x + (hitBox.width - indicator.size.x) / 2;
indicatorCoords.y = hitBox.y + fineScroll.y - indicator.size.y - 2;
diff --git a/engines/saga2/document.cpp b/engines/saga2/document.cpp
index 6f7148f58e..67fe3a3ef1 100644
--- a/engines/saga2/document.cpp
+++ b/engines/saga2/document.cpp
@@ -29,7 +29,6 @@
#include "saga2/script.h"
#include "saga2/intrface.h"
#include "saga2/grequest.h"
-#include "saga2/images.h"
#include "saga2/mouseimg.h"
#include "saga2/version.h"
#include "saga2/fontlib.h"
@@ -289,15 +288,15 @@ void CDocument::pointerMove(gPanelMessage &msg) {
if (msg.inPanel && Rect16(0, 0, extent.width, extent.height).ptInside(pos)) {
if (app.orientation == pageOrientVertical) {
// find out which end of the book we're on
- if (pos.y < extent.height / 2) setMouseImage(PgUpImage, -7, -7);
- else setMouseImage(PgDownImage, -7, -7);
+ if (pos.y < extent.height / 2) setMouseImage(kMousePgUpImage, -7, -7);
+ else setMouseImage(kMousePgDownImage, -7, -7);
} else {
// find out which side of the book we're on
- if (pos.x < extent.width / 2) setMouseImage(PgLeftImage, -7, -7);
- else setMouseImage(PgRightImage, -7, -7);
+ if (pos.x < extent.width / 2) setMouseImage(kMousePgLeftImage, -7, -7);
+ else setMouseImage(kMousePgRightImage, -7, -7);
}
} else if (msg.pointerLeave) {
- setMouseImage(ArrowImage, 0, 0);
+ setMouseImage(kMouseArrowImage, 0, 0);
}
notify(gEventMouseMove, 0);
@@ -335,7 +334,7 @@ bool CDocument::pointerHit(gPanelMessage &msg) {
ri->running = 0;
ri->result = id;
- setMouseImage(ArrowImage, 0, 0);
+ setMouseImage(kMouseArrowImage, 0, 0);
}
}
diff --git a/engines/saga2/grabinfo.cpp b/engines/saga2/grabinfo.cpp
index 245770ebc8..e0ce5f2141 100644
--- a/engines/saga2/grabinfo.cpp
+++ b/engines/saga2/grabinfo.cpp
@@ -26,7 +26,6 @@
#include "saga2/std.h"
#include "saga2/gdraw.h"
-#include "saga2/images.h"
#include "saga2/objects.h"
#include "saga2/contain.h"
#include "saga2/mouseimg.h"
@@ -235,30 +234,30 @@ void GrabInfo::setCursor(void) {
// pointer has already been hidden.
break;
case WalkTo:
- setMouseImage(ArrowImage, 0, 0);
+ setMouseImage(kMouseArrowImage, 0, 0);
break;
case Open:
- setMouseImage(ArrowImage, 0, 0);
+ setMouseImage(kMouseArrowImage, 0, 0);
break;
case PickUp:
- setMouseImage(GrabPtrImage, -7, -7);
+ setMouseImage(kMouseGrabPtrImage, -7, -7);
break;
case Drop:
setMouseImage(pointerMap, pointerOffset.x, pointerOffset.y);
break;
case Use:
- setMouseImage(UsePtrImage, -7, -7);
+ setMouseImage(kMouseUsePtrImage, -7, -7);
break;
case Attack:
- setMouseImage(AttakPtrImage, -11, -11);
+ setMouseImage(kMouseAttakPtrImage, -11, -11);
break;
case Cast:
- setMouseImage(AttakPtrImage, -11, -11);
+ setMouseImage(kMouseAttakPtrImage, -11, -11);
break;
}
} else {
// indicate current intention is not doable
- setMouseImage(XPointerImage, -7, -7);
+ setMouseImage(kMouseXPointerImage, -7, -7);
}
}
diff --git a/engines/saga2/grequest.cpp b/engines/saga2/grequest.cpp
index a2aaf64e7f..c7c0882511 100644
--- a/engines/saga2/grequest.cpp
+++ b/engines/saga2/grequest.cpp
@@ -27,7 +27,7 @@
#include "saga2/std.h"
#include "saga2/grequest.h"
#include "saga2/modal.h"
-#include "saga2/images.h"
+#include "saga2/mouseimg.h"
namespace Saga2 {
@@ -297,8 +297,8 @@ ModalRequestWindow::ModalRequestWindow(
r.height - fontHeight - 8,
width,
fontHeight + 6),
- CloseBx2Image,
- CloseBx1Image,
+ *mouseCursors[kMouseCloseBx2Image],
+ *mouseCursors[kMouseCloseBx1Image],
buttonStrings[ i ],
i,
handleRequestEvent);
diff --git a/engines/saga2/images.cpp b/engines/saga2/images.cpp
deleted file mode 100644
index a9acedb15f..0000000000
--- a/engines/saga2/images.cpp
+++ /dev/null
@@ -1,670 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#include "saga2/std.h"
-#include "saga2/gdraw.h"
-
-namespace Saga2 {
-
-static uint8 CloseBx1ImageData[] = {
- 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // Row 0
-
- 0x18, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x18, // Row 1
-
- 0x18, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x18, // Row 2
-
- 0x18, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x18, // Row 3
-
- 0x18, 0x0A, 0x0A, 0x0A, 0x18, 0x18, 0x18, 0x18, 0x0A, 0x0A, 0x0A, 0x18, // Row 4
-
- 0x18, 0x0A, 0x0A, 0x0A, 0x18, 0x18, 0x18, 0x18, 0x0A, 0x0A, 0x0A, 0x18, // Row 5
-
- 0x18, 0x0A, 0x0A, 0x0A, 0x18, 0x18, 0x18, 0x18, 0x0A, 0x0A, 0x0A, 0x18, // Row 6
-
- 0x18, 0x0A, 0x0A, 0x0A, 0x18, 0x18, 0x18, 0x18, 0x0A, 0x0A, 0x0A, 0x18, // Row 7
-
- 0x18, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x18, // Row 8
-
- 0x18, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x18, // Row 9
-
- 0x18, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x18, // Row 10
-
- 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // Row 11
-
-};
-
-gStaticImage CloseBx1Image(12, 12, CloseBx1ImageData);
-
-/* ===================================================================== *
- Created from CloseBx2.bbm
- Image Size: 12 Wide by 12 High.
- Converted by iff2c.
- * ===================================================================== */
-
-static uint8 CloseBx2ImageData[] = {
- 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // Row 0
-
- 0x18, 0x7B, 0x7B, 0x7B, 0x7B, 0x7B, 0x7B, 0x7B, 0x7B, 0x7B, 0x7B, 0x18, // Row 1
-
- 0x18, 0x7B, 0x82, 0x82, 0x7B, 0x7B, 0x7B, 0x7B, 0x82, 0x82, 0x7B, 0x18, // Row 2
-
- 0x18, 0x7B, 0x82, 0x82, 0x82, 0x7B, 0x7B, 0x82, 0x82, 0x82, 0x7B, 0x18, // Row 3
-
- 0x18, 0x7B, 0x7B, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x7B, 0x7B, 0x18, // Row 4
-
- 0x18, 0x7B, 0x7B, 0x7B, 0x82, 0x82, 0x82, 0x82, 0x7B, 0x7B, 0x7B, 0x18, // Row 5
-
- 0x18, 0x7B, 0x7B, 0x7B, 0x82, 0x82, 0x82, 0x82, 0x7B, 0x7B, 0x7B, 0x18, // Row 6
-
- 0x18, 0x7B, 0x7B, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x7B, 0x7B, 0x18, // Row 7
-
- 0x18, 0x7B, 0x82, 0x82, 0x82, 0x7B, 0x7B, 0x82, 0x82, 0x82, 0x7B, 0x18, // Row 8
-
- 0x18, 0x7B, 0x82, 0x82, 0x7B, 0x7B, 0x7B, 0x7B, 0x82, 0x82, 0x7B, 0x18, // Row 9
-
- 0x18, 0x7B, 0x7B, 0x7B, 0x7B, 0x7B, 0x7B, 0x7B, 0x7B, 0x7B, 0x7B, 0x18, // Row 10
-
- 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // Row 11
-
-};
-
-gStaticImage CloseBx2Image(12, 12, CloseBx2ImageData);
-
-/* ===================================================================== *
- Created from UsePtr.bbm
- Image Size: 15 Wide by 15 High.
- Converted by iff2c.
- * ===================================================================== */
-
-static uint8 UsePtrImageData[] = {
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, // Row 0
- 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x18, 0x00, // Row 1
- 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0A, 0x0A, 0x0A, 0x18, 0x00, 0x00, // Row 2
- 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0A, 0x18, 0x00, 0x00, 0x00, // Row 3
- 0x00, 0x00, 0x00,
-
- 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, // Row 4
- 0x00, 0x18, 0x18,
-
- 0x18, 0x0A, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Row 5
- 0x18, 0x0A, 0x18,
-
- 0x18, 0x0A, 0x0A, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, // Row 6
- 0x0A, 0x0A, 0x18,
-
- 0x18, 0x0A, 0x0A, 0x0A, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0A, // Row 7
- 0x0A, 0x0A, 0x18,
-
- 0x18, 0x0A, 0x0A, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, // Row 8
- 0x0A, 0x0A, 0x18,
-
- 0x18, 0x0A, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Row 9
- 0x18, 0x0A, 0x18,
-
- 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, // Row 10
- 0x00, 0x18, 0x18,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0A, 0x18, 0x00, 0x00, 0x00, // Row 11
- 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0A, 0x0A, 0x0A, 0x18, 0x00, 0x00, // Row 12
- 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x18, 0x00, // Row 13
- 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, // Row 14
- 0x00, 0x00, 0x00,
-};
-
-gStaticImage UsePtrImage(15, 15, UsePtrImageData);
-
-/* ===================================================================== *
- Created from XPointer.bbm
- Image Size: 15 Wide by 15 High.
- Converted by iff2c.
- * ===================================================================== */
-
-static uint8 XPointerImageData[] = {
- 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, // Row 0
- 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x18, 0x81, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x81, // Row 1
- 0x18, 0x00, 0x00,
-
- 0x00, 0x18, 0x81, 0x82, 0x81, 0x18, 0x00, 0x00, 0x00, 0x18, 0x81, 0x82, // Row 2
- 0x81, 0x18, 0x00,
-
- 0x18, 0x81, 0x82, 0x82, 0x82, 0x81, 0x18, 0x00, 0x18, 0x81, 0x82, 0x82, // Row 3
- 0x82, 0x81, 0x18,
-
- 0x00, 0x18, 0x84, 0x82, 0x82, 0x82, 0x81, 0x18, 0x81, 0x82, 0x82, 0x82, // Row 4
- 0x84, 0x18, 0x00,
-
- 0x00, 0x00, 0x18, 0x84, 0x82, 0x82, 0x82, 0x81, 0x82, 0x82, 0x82, 0x84, // Row 5
- 0x18, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x18, 0x84, 0x82, 0x82, 0x82, 0x82, 0x82, 0x84, 0x18, // Row 6
- 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x81, 0x82, 0x82, 0x82, 0x81, 0x18, 0x00, // Row 7
- 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x18, 0x81, 0x82, 0x82, 0x82, 0x82, 0x82, 0x81, 0x18, // Row 8
- 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x18, 0x81, 0x82, 0x82, 0x82, 0x84, 0x82, 0x82, 0x82, 0x81, // Row 9
- 0x18, 0x00, 0x00,
-
- 0x00, 0x18, 0x81, 0x82, 0x82, 0x82, 0x84, 0x18, 0x84, 0x82, 0x82, 0x82, // Row 10
- 0x81, 0x18, 0x00,
-
- 0x18, 0x81, 0x82, 0x82, 0x82, 0x84, 0x18, 0x00, 0x18, 0x84, 0x82, 0x82, // Row 11
- 0x82, 0x81, 0x18,
-
- 0x00, 0x18, 0x84, 0x82, 0x84, 0x18, 0x00, 0x00, 0x00, 0x18, 0x84, 0x82, // Row 12
- 0x84, 0x18, 0x00,
-
- 0x00, 0x00, 0x18, 0x84, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x84, // Row 13
- 0x18, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, // Row 14
- 0x00, 0x00, 0x00,
-};
-
-gStaticImage XPointerImage(15, 15, XPointerImageData);
-
-/* ===================================================================== *
- Created from Arrow.bbm
- Image Size: 11 Wide by 17 High.
- Converted by iff2c.
- * ===================================================================== */
-
-static uint8 ArrowImageData[] = {
- 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Row 0
- 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Row 1
- 0x18, 0x49, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Row 2
- 0x18, 0x4E, 0x49, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Row 3
- 0x18, 0x4E, 0x4C, 0x49, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Row 4
- 0x18, 0x4E, 0x4C, 0x4C, 0x49, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, // Row 5
- 0x18, 0x4E, 0x4C, 0x4C, 0x4C, 0x49, 0x18, 0x00, 0x00, 0x00, 0x00, // Row 6
- 0x18, 0x4E, 0x4C, 0x4C, 0x4C, 0x4C, 0x49, 0x18, 0x00, 0x00, 0x00, // Row 7
- 0x18, 0x4E, 0x4C, 0x4C, 0x4C, 0x4C, 0x4C, 0x49, 0x18, 0x00, 0x00, // Row 8
- 0x18, 0x4E, 0x4C, 0x4C, 0x4C, 0x4C, 0x4C, 0x4C, 0x49, 0x18, 0x00, // Row 9
- 0x18, 0x4E, 0x4C, 0x4E, 0x4C, 0x49, 0x18, 0x18, 0x18, 0x18, 0x18, // Row 10
- 0x18, 0x4E, 0x4E, 0x18, 0x4E, 0x49, 0x18, 0x00, 0x00, 0x00, 0x00, // Row 11
- 0x18, 0x4E, 0x18, 0x00, 0x18, 0x4E, 0x49, 0x18, 0x00, 0x00, 0x00, // Row 12
- 0x18, 0x18, 0x00, 0x00, 0x18, 0x4E, 0x49, 0x18, 0x00, 0x00, 0x00, // Row 13
- 0x18, 0x00, 0x00, 0x00, 0x00, 0x18, 0x4E, 0x49, 0x18, 0x00, 0x00, // Row 14
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x4E, 0x49, 0x18, 0x00, 0x00, // Row 15
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x00, 0x00, // Row 16
-};
-
-gStaticImage ArrowImage(11, 17, ArrowImageData);
-
-/* ===================================================================== *
- Created from GrabPtr.bbm
- Image Size: 16 Wide by 13 High.
- Converted by iff2c.
- * ===================================================================== */
-
-static uint8 GrabPtrImageData[] = {
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, // Row 0
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x18, 0x18, 0x40, 0x40, 0x3C, 0x40, 0x3B, 0x18, 0x00, 0x00, // Row 1
- 0x00, 0x00, 0x00, 0x00,
-
- 0x18, 0x18, 0x40, 0x40, 0x40, 0x3C, 0x40, 0x3C, 0x40, 0x3B, 0x18, 0x00, // Row 2
- 0x00, 0x00, 0x00, 0x00,
-
- 0x18, 0x3C, 0x3C, 0x3C, 0x3C, 0x40, 0x3C, 0x40, 0x3C, 0x3E, 0x3B, 0x18, // Row 3
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x18, 0x18, 0x18, 0x3D, 0x3C, 0x40, 0x3C, 0x3C, 0x3B, 0x3C, 0x3B, // Row 4
- 0x18, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x3D, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, // Row 5
- 0x3B, 0x18, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3D, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, // Row 6
- 0x3B, 0x18, 0x00, 0x00,
-
- 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x3D, 0x3D, 0x3C, 0x3C, 0x3C, 0x3C, // Row 7
- 0x3C, 0x3B, 0x18, 0x00,
-
- 0x18, 0x3E, 0x3D, 0x18, 0x18, 0x3D, 0x3D, 0x3D, 0x3D, 0x3C, 0x3C, 0x3C, // Row 8
- 0x3C, 0x3C, 0x3B, 0x18,
-
- 0x00, 0x18, 0x3E, 0x3D, 0x3D, 0x3E, 0x3E, 0x3E, 0x3D, 0x3D, 0x3C, 0x3C, // Row 9
- 0x3C, 0x3C, 0x18, 0x00,
-
- 0x00, 0x00, 0x18, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3D, 0x3D, 0x3C, // Row 10
- 0x3C, 0x18, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3E, 0x3D, 0x3D, // Row 11
- 0x18, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, // Row 12
- 0x00, 0x00, 0x00, 0x00,
-};
-
-gStaticImage GrabPtrImage(16, 13, GrabPtrImageData);
-
-/* ===================================================================== *
- Created from AttakPtr.bbm
- Image Size: 23 Wide by 23 High.
- Converted by iff2c.
- * ===================================================================== */
-
-static uint8 AttakPtrImageData[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, // Row 0
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x5A, // Row 1
- 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x5A, // Row 2
- 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x5A, // Row 3
- 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x5A, // Row 4
- 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x5A, 0x5A, 0x5A, // Row 5
- 0x5A, 0x5A, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x5A, 0x18, 0x18, 0x5A, // Row 6
- 0x18, 0x18, 0x5A, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x5A, 0x18, 0x00, 0x18, 0x5A, // Row 7
- 0x18, 0x00, 0x18, 0x5A, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x5A, 0x18, 0x00, 0x00, 0x00, 0x18, // Row 8
- 0x00, 0x00, 0x00, 0x18, 0x5A, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x5A, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, // Row 9
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x5A, 0x18, 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x18, 0x18, 0x18, 0x18, 0x5A, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, // Row 10
- 0x00, 0x00, 0x00, 0x18, 0x18, 0x5A, 0x18, 0x18, 0x18, 0x18, 0x00,
-
- 0x18, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x18, 0x00, 0x00, 0x00, // Row 11
- 0x00, 0x00, 0x18, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x18,
-
- 0x00, 0x18, 0x18, 0x18, 0x18, 0x5A, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, // Row 12
- 0x00, 0x00, 0x00, 0x18, 0x18, 0x5A, 0x18, 0x18, 0x18, 0x18, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x5A, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, // Row 13
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x5A, 0x18, 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x5A, 0x18, 0x00, 0x00, 0x00, 0x18, // Row 14
- 0x00, 0x00, 0x00, 0x18, 0x5A, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x5A, 0x18, 0x00, 0x18, 0x5A, // Row 15
- 0x18, 0x00, 0x18, 0x5A, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x5A, 0x18, 0x18, 0x5A, // Row 16
- 0x18, 0x18, 0x5A, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x5A, 0x5A, 0x5A, // Row 17
- 0x5A, 0x5A, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x5A, // Row 18
- 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x5A, // Row 19
- 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x5A, // Row 20
- 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x5A, // Row 21
- 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, // Row 22
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-};
-
-gStaticImage AttakPtrImage(23, 23, AttakPtrImageData);
-
-/* ===================================================================== *
- Created from turn.bbm
- Image Size: 9 Wide by 10 High.
- Converted by iff2c.
- * ===================================================================== */
-
-uint8 CenterActorIndicatorImageData[] = {
- 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // Row 0
- 0x18, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x18, // Row 1
- 0x18, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x18, // Row 2
- 0x00, 0x18, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x18, 0x00, // Row 3
- 0x00, 0x18, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x18, 0x00, // Row 4
- 0x00, 0x00, 0x18, 0x0a, 0x0a, 0x0a, 0x18, 0x00, 0x00, // Row 5
- 0x00, 0x00, 0x18, 0x0a, 0x0a, 0x0a, 0x18, 0x00, 0x00, // Row 6
- 0x00, 0x00, 0x00, 0x18, 0x0a, 0x18, 0x00, 0x00, 0x00, // Row 7
- 0x00, 0x00, 0x00, 0x18, 0x0a, 0x18, 0x00, 0x00, 0x00, // Row 8
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, // Row 9
-};
-
-gStaticImage CenterActorIndicatorImage(9, 9, CenterActorIndicatorImageData);
-
-/* ===================================================================== *
- Created from PgUp.bbm
- Image Size: 16 Wide by 16 High.
- Converted by iff2c.
- * ===================================================================== */
-
-static uint8 PgUpImageData[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, // Row 0
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x5a, 0x5b, 0x18, 0x00, 0x00, // Row 1
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x5a, 0x5d, 0x5d, 0x5b, 0x18, 0x00, // Row 2
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x5a, 0x5d, 0x18, 0x18, 0x5d, 0x5b, 0x18, // Row 3
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x18, 0x5a, 0x5d, 0x18, 0xc5, 0xc5, 0x18, 0x5d, 0x5b, // Row 4
- 0x18, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x18, 0x5a, 0x5d, 0x18, 0xc5, 0xc5, 0xc5, 0xc5, 0x18, 0x5d, // Row 5
- 0x5b, 0x18, 0x00, 0x00,
-
- 0x00, 0x18, 0x5a, 0x5d, 0x18, 0x18, 0x18, 0xc5, 0xc5, 0x18, 0x18, 0x18, // Row 6
- 0x5d, 0x5b, 0x18, 0x00,
-
- 0x18, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x18, 0xc5, 0xc5, 0x18, 0x25, 0x25, // Row 7
- 0x25, 0x25, 0x25, 0x18,
-
- 0x18, 0x18, 0x18, 0x18, 0x18, 0x5a, 0x18, 0xc5, 0xc5, 0x18, 0x25, 0x18, // Row 8
- 0x18, 0x18, 0x18, 0x18,
-
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x5a, 0x18, 0xc5, 0xc5, 0x18, 0x25, 0x18, // Row 9
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x5a, 0x18, 0xc5, 0xc5, 0x18, 0x25, 0x18, // Row 10
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x5a, 0x18, 0xc5, 0xc5, 0x18, 0x25, 0x18, // Row 11
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x5a, 0x18, 0xc5, 0xc5, 0x18, 0x25, 0x18, // Row 12
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x5a, 0x18, 0x18, 0x18, 0x18, 0x25, 0x18, // Row 13
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x5c, 0x25, 0x25, 0x25, 0x25, 0x25, 0x18, // Row 14
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // Row 15
- 0x00, 0x00, 0x00, 0x00,
-};
-
-gStaticImage PgUpImage(16, 16, PgUpImageData);
-
-/* ===================================================================== *
- Created from PgDown.bbm
- Image Size: 16 Wide by 16 High.
- Converted by iff2c.
- * ===================================================================== */
-
-static uint8 PgDownImageData[] = {
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // Row 0
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x59, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x18, // Row 1
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x5a, 0x18, 0x18, 0x18, 0x18, 0x25, 0x18, // Row 2
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x5a, 0x18, 0xc5, 0xc5, 0x18, 0x25, 0x18, // Row 3
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x5a, 0x18, 0xc5, 0xc5, 0x18, 0x25, 0x18, // Row 4
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x5a, 0x18, 0xc5, 0xc5, 0x18, 0x25, 0x18, // Row 5
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x5a, 0x18, 0xc5, 0xc5, 0x18, 0x25, 0x18, // Row 6
- 0x00, 0x00, 0x00, 0x00,
-
- 0x18, 0x18, 0x18, 0x18, 0x18, 0x5a, 0x18, 0xc5, 0xc5, 0x18, 0x25, 0x18, // Row 7
- 0x18, 0x18, 0x18, 0x18,
-
- 0x18, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x18, 0xc5, 0xc5, 0x18, 0x25, 0x23, // Row 8
- 0x23, 0x23, 0x23, 0x18,
-
- 0x00, 0x18, 0x5b, 0x5d, 0x18, 0x18, 0x18, 0xc5, 0xc5, 0x18, 0x18, 0x18, // Row 9
- 0x25, 0x23, 0x18, 0x00,
-
- 0x00, 0x00, 0x18, 0x5b, 0x5d, 0x18, 0xc5, 0xc5, 0xc5, 0xc5, 0x18, 0x25, // Row 10
- 0x23, 0x18, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x18, 0x5b, 0x5d, 0x18, 0xc5, 0xc5, 0x18, 0x25, 0x23, // Row 11
- 0x18, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x5b, 0x5d, 0x18, 0x18, 0x25, 0x23, 0x18, // Row 12
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x5b, 0x5d, 0x25, 0x23, 0x18, 0x00, // Row 13
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x5b, 0x23, 0x18, 0x00, 0x00, // Row 14
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, // Row 15
- 0x00, 0x00, 0x00, 0x00,
-};
-
-gStaticImage PgDownImage(16, 16, PgDownImageData);
-
-/* ===================================================================== *
- Created from PgLeft.bbm
- Image Size: 16 Wide by 16 High.
- Converted by iff2c.
- * ===================================================================== */
-
-static uint8 PgLeftImageData[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, // Row 0
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x5a, 0x18, 0x00, 0x00, 0x00, // Row 1
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x5a, 0x5a, 0x18, 0x00, 0x00, 0x00, // Row 2
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x5a, 0x5d, 0x5a, 0x18, 0x00, 0x00, 0x00, // Row 3
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x18, 0x5a, 0x5d, 0x18, 0x5a, 0x18, 0x18, 0x18, 0x18, // Row 4
- 0x18, 0x18, 0x18, 0x18,
-
- 0x00, 0x00, 0x18, 0x5a, 0x5d, 0x18, 0x18, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, // Row 5
- 0x5a, 0x5a, 0x5c, 0x18,
-
- 0x00, 0x18, 0x5a, 0x5d, 0x18, 0xc5, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // Row 6
- 0x18, 0x18, 0x25, 0x18,
-
- 0x18, 0x5a, 0x5d, 0x18, 0xc5, 0xc5, 0xc5, 0xc5, 0xc5, 0xc5, 0xc5, 0xc5, // Row 7
- 0xc5, 0x18, 0x25, 0x18,
-
- 0x18, 0x5b, 0x5d, 0x18, 0xc5, 0xc5, 0xc5, 0xc5, 0xc5, 0xc5, 0xc5, 0xc5, // Row 8
- 0xc5, 0x18, 0x25, 0x18,
-
- 0x00, 0x18, 0x5b, 0x5d, 0x18, 0xc5, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // Row 9
- 0x18, 0x18, 0x25, 0x18,
-
- 0x00, 0x00, 0x18, 0x5b, 0x5d, 0x18, 0x18, 0x25, 0x25, 0x25, 0x25, 0x25, // Row 10
- 0x25, 0x25, 0x25, 0x18,
-
- 0x00, 0x00, 0x00, 0x18, 0x5b, 0x5d, 0x18, 0x25, 0x18, 0x18, 0x18, 0x18, // Row 11
- 0x18, 0x18, 0x18, 0x18,
-
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x5b, 0x5d, 0x25, 0x18, 0x00, 0x00, 0x00, // Row 12
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x5b, 0x25, 0x18, 0x00, 0x00, 0x00, // Row 13
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x25, 0x18, 0x00, 0x00, 0x00, // Row 14
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, // Row 15
- 0x00, 0x00, 0x00, 0x00,
-};
-
-gStaticImage PgLeftImage(16, 16, PgLeftImageData);
-
-/* ===================================================================== *
- Created from PgRight.bbm
- Image Size: 16 Wide by 16 High.
- Converted by iff2c.
- * ===================================================================== */
-
-static uint8 PgRightImageData[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, // Row 0
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x5a, 0x18, 0x00, 0x00, // Row 1
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x5a, 0x5b, 0x18, 0x00, // Row 2
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x5a, 0x5d, 0x5b, 0x18, // Row 3
- 0x00, 0x00, 0x00, 0x00,
-
- 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x5a, 0x18, 0x5d, 0x5b, // Row 4
- 0x18, 0x00, 0x00, 0x00,
-
- 0x18, 0x59, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x18, 0x18, 0x5d, // Row 5
- 0x5b, 0x18, 0x00, 0x00,
-
- 0x18, 0x5a, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xc5, 0x18, // Row 6
- 0x5d, 0x5b, 0x18, 0x00,
-
- 0x18, 0x5a, 0x18, 0xc5, 0xc5, 0xc5, 0xc5, 0xc5, 0xc5, 0xc5, 0xc5, 0xc5, // Row 7
- 0x18, 0x5d, 0x5b, 0x18,
-
- 0x18, 0x5a, 0x18, 0xc5, 0xc5, 0xc5, 0xc5, 0xc5, 0xc5, 0xc5, 0xc5, 0xc5, // Row 8
- 0x18, 0x25, 0x23, 0x18,
-
- 0x18, 0x5a, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xc5, 0x18, // Row 9
- 0x25, 0x23, 0x18, 0x00,
-
- 0x18, 0x5c, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x18, 0x18, 0x25, // Row 10
- 0x23, 0x18, 0x00, 0x00,
-
- 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x23, 0x18, 0x25, 0x23, // Row 11
- 0x18, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x23, 0x25, 0x23, 0x18, // Row 12
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x23, 0x23, 0x18, 0x00, // Row 13
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x23, 0x18, 0x00, 0x00, // Row 14
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, // Row 15
- 0x00, 0x00, 0x00, 0x00,
-};
-
-gStaticImage PgRightImage(16, 16, PgRightImageData);
-
-/* ===================================================================== *
- Created from AutoWalk.bbm
- Image Size: 15 Wide by 15 High.
- Converted by iff2c.
- * ===================================================================== */
-
-static uint8 AutoWalkImageData[] = {
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, // Row 0
- 0x00, 0x00, 0x00,
-
- 0x00, 0x18, 0x18, 0x18, 0x18, 0xde, 0xde, 0xde, 0xde, 0xde, 0x18, 0x18, // Row 1
- 0x18, 0x18, 0x00,
-
- 0x00, 0x18, 0xe0, 0xe0, 0xe0, 0x18, 0xde, 0xde, 0xde, 0x18, 0xe0, 0xe0, // Row 2
- 0xe0, 0x18, 0x00,
-
- 0x00, 0x18, 0xe0, 0x18, 0x18, 0x18, 0x18, 0xde, 0x18, 0x18, 0x18, 0x18, // Row 3
- 0xe0, 0x18, 0x00,
-
- 0x18, 0x18, 0xe0, 0x18, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18, // Row 4
- 0xe0, 0x18, 0x18,
-
- 0x18, 0xde, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, // Row 5
- 0x18, 0xde, 0x18,
-
- 0x18, 0xde, 0xde, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, // Row 6
- 0xde, 0xde, 0x18,
-
- 0x18, 0xde, 0xde, 0xde, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0xde, // Row 7
- 0xde, 0xde, 0x18,
-
- 0x18, 0xde, 0xde, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, // Row 8
- 0xde, 0xde, 0x18,
-
- 0x18, 0xde, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, // Row 9
- 0x18, 0xde, 0x18,
-
- 0x18, 0x18, 0xe0, 0x18, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18, // Row 10
- 0xe0, 0x18, 0x18,
-
- 0x00, 0x18, 0xe0, 0x18, 0x18, 0x18, 0x18, 0xde, 0x18, 0x18, 0x18, 0x18, // Row 11
- 0xe0, 0x18, 0x00,
-
- 0x00, 0x18, 0xe0, 0xe0, 0xe0, 0x18, 0xde, 0xde, 0xde, 0x18, 0xe0, 0xe0, // Row 12
- 0xe0, 0x18, 0x00,
-
- 0x00, 0x18, 0x18, 0x18, 0x18, 0xde, 0xde, 0xde, 0xde, 0xde, 0x18, 0x18, // Row 13
- 0x18, 0x18, 0x00,
-
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, // Row 14
- 0x00, 0x00, 0x00,
-};
-
-gStaticImage AutoWalkImage(15, 15, AutoWalkImageData);
-
-} // end of namespace Saga2
diff --git a/engines/saga2/images.h b/engines/saga2/images.h
deleted file mode 100644
index 347981597e..0000000000
--- a/engines/saga2/images.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#ifndef SAGA2_IMAGES_H
-#define SAGA2_IMAGES_H
-
-namespace Saga2 {
-
-// unselected button image
-extern gStaticImage CloseBx1Image;
-
-// selected button image
-extern gStaticImage CloseBx2Image;
-
-// targeting mouse cursor image
-extern gStaticImage UsePtrImage;
-
-// red X mouse cursor image
-extern gStaticImage XPointerImage;
-
-// arrow mouse cursor image
-extern gStaticImage ArrowImage;
-
-// grab mouse cursor image
-extern gStaticImage GrabPtrImage;
-
-// attack mouse cursor image
-extern gStaticImage AttakPtrImage;
-
-// center actor combat turn indicator
-extern gStaticImage CenterActorIndicatorImage;
-
-// Auto-walk mousr cursor image
-extern gStaticImage AutoWalkImage;
-
-// Cursor images for turning book pages
-extern gStaticImage PgUpImage;
-extern gStaticImage PgLeftImage;
-extern gStaticImage PgDownImage;
-extern gStaticImage PgRightImage;
-
-} // end of namespace Saga2
-
-#endif
diff --git a/engines/saga2/module.mk b/engines/saga2/module.mk
index 884a7bdb71..5d9108a099 100644
--- a/engines/saga2/module.mk
+++ b/engines/saga2/module.mk
@@ -32,7 +32,6 @@ MODULE_OBJS := \
gtextbox.o \
hresmgr.o \
imagcach.o \
- images.o \
input.o \
interp.o \
intrface.o \
diff --git a/engines/saga2/mouseimg.cpp b/engines/saga2/mouseimg.cpp
index bb3d1c4c18..2d0268df96 100644
--- a/engines/saga2/mouseimg.cpp
+++ b/engines/saga2/mouseimg.cpp
@@ -28,7 +28,6 @@
#include "saga2/blitters.h"
#include "saga2/fta.h"
#include "saga2/mouseimg.h"
-#include "saga2/images.h"
#include "saga2/panel.h"
namespace Saga2 {
@@ -39,12 +38,24 @@ const int gaugeWidth = 46,
gaugeOneThird = gaugeWidth / 3,
gaugeTwoThirds = gaugeWidth * 2 / 3;
-/* ===================================================================== *
- Imports
- * ===================================================================== */
-
extern gFont *mainFont;
+extern uint8 *closeBx1ImageData;
+extern uint8 *closeBx2ImageData;
+extern uint8 *usePtrImageData;
+extern uint8 *xPointerImageData;
+extern uint8 *arrowImageData;
+extern uint8 *grabPtrImageData;
+extern uint8 *attakPtrImageData;
+extern uint8 *centerActorIndicatorImageData;
+extern uint8 *pgUpImageData;
+extern uint8 *pgDownImageData;
+extern uint8 *pgLeftImageData;
+extern uint8 *pgRightImageData;
+extern uint8 *autoWalkImageData;
+extern uint8 *gaugeImageData;
+
+
/* ===================================================================== *
Globals
* ===================================================================== */
@@ -55,7 +66,7 @@ static char mouseText[ maxMouseTextLen ] = { "" }; // Current mouse te
static Point16 mouseImageOffset; // Hotspot on mouse image
-static gPixelMap *mouseImage = &ArrowImage; // Current mouse cursor image
+static gPixelMap *mouseImage = mouseCursors[kMouseArrowImage]; // Current mouse cursor image
static gStaticImage textImage(0, 0, NULL), // Current mouse text image
combinedImage(0, 0, NULL); // Combine mouse text
@@ -77,42 +88,31 @@ static uint8 gaugeColorMapArray[ 3 ][ 7 ] = {
{ 0x00, 0x18, 0x83, 0x81, 0x86, 0x72, 0x39 }, // Red
};
-static uint8 gaugeImageData[ gaugeImageWidth * gaugeImageHeight ] = {
- 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, // Row 0
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00,
-
-
- 0x01, 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, // Row 1
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01,
-
-
- 0x01, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, // Row 2
- 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
- 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
- 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x06, 0x02, 0x01,
-
-
- 0x01, 0x05, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, // Row 3
- 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
- 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
- 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x01,
-
-
- 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, // Row 4
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00,
+static struct MouseCurosrs {
+ uint8 **data;
+ int w;
+ int h;
+} mouseCursorData[] = {
+ { &closeBx1ImageData, 12, 12 },
+ { &closeBx2ImageData, 12, 12 },
+ { &usePtrImageData, 15, 15 },
+ { &xPointerImageData, 15, 15 },
+ { &arrowImageData, 11, 17 },
+ { &grabPtrImageData, 16, 13 },
+ { &attakPtrImageData, 23, 23 },
+ { ¢erActorIndicatorImageData, 9, 9 },
+ { &pgUpImageData, 16, 16 },
+ { &pgDownImageData, 16, 16 },
+ { &pgLeftImageData, 16, 16 },
+ { &pgRightImageData, 16, 16 },
+ { &autoWalkImageData, 15, 15 },
+ { &gaugeImageData, gaugeImageWidth, gaugeImageHeight }
};
+gStaticImage *mouseCursors[kMouseMax];
+
static uint8 gaugeImageBuffer[ gaugeImageWidth * gaugeImageHeight ];
-static gStaticImage gaugeImage(
- gaugeImageWidth,
- gaugeImageHeight,
- gaugeImageBuffer);
+static gStaticImage gaugeImage(gaugeImageWidth, gaugeImageHeight, gaugeImageBuffer);
static bool showGauge = FALSE;
@@ -123,6 +123,17 @@ static bool showGauge = FALSE;
//-----------------------------------------------------------------------
// Create a new bitmap of several images stacked on top of each other
+void initCursors() {
+ for (int i = 0; i < kMouseMax; i++)
+ mouseCursors[i] = new gStaticImage(mouseCursorData[i].w, mouseCursorData[i].h, *mouseCursorData[i].data);
+}
+
+void freeCursors() {
+ for (int i = 0; i < kMouseMax; i++)
+ delete mouseCursors[i];
+}
+
+
void createStackedImage(
gPixelMap *newImage,
int *newImageCenter,
@@ -194,7 +205,8 @@ inline void disposeStackedImage(gPixelMap *image) {
// image.
void cleanupMousePointer(void) {
- if (combinedImage.data != NULL) disposeStackedImage(&combinedImage);
+ if (combinedImage.data != NULL)
+ disposeStackedImage(&combinedImage);
}
void setupMousePointer(void) {
@@ -242,6 +254,10 @@ void setupMousePointer(void) {
//-----------------------------------------------------------------------
// Setup a new mouse cursor image
+void setMouseImage(int id, int16 x, int16 y) {
+ setMouseImage(*mouseCursors[id], x, y);
+}
+
void setMouseImage(gPixelMap &img, int16 x, int16 y) {
if (mouseImage != &img
|| mouseImageOffset.x != x
@@ -393,7 +409,7 @@ void setMouseGauge(int numerator, int denominator) {
gaugeMap = x < gaugePos + 1 ? gaugeColorMap : gaugeGrayMap;
gaugeImageBuffer[ gaugeImageIndex ] =
- gaugeMap[ gaugeImageData[ gaugeImageIndex ] ];
+ gaugeMap[mouseCursors[kMouseGaugeImage]->data[gaugeImageIndex] ];
gaugeImageIndex++;
}
diff --git a/engines/saga2/mouseimg.h b/engines/saga2/mouseimg.h
index f9127d98e9..e3f97b8d59 100644
--- a/engines/saga2/mouseimg.h
+++ b/engines/saga2/mouseimg.h
@@ -29,6 +29,29 @@
namespace Saga2 {
+enum {
+ kMouseCloseBx1Image = 0,
+ kMouseCloseBx2Image,
+ kMouseUsePtrImage,
+ kMouseXPointerImage,
+ kMouseArrowImage,
+ kMouseGrabPtrImage,
+ kMouseAttakPtrImage,
+ kMouseCenterActorIndicatorImage,
+ kMousePgUpImage,
+ kMousePgDownImage,
+ kMousePgLeftImage,
+ kMousePgRightImage,
+ kMouseAutoWalkImage,
+ kMouseGaugeImage,
+ kMouseMax
+};
+
+extern gStaticImage *mouseCursors[kMouseMax];
+
+// Set a new image for the mouse pointer
+void setMouseImage(int id, int16 x, int16 y);
+
// Set a new image for the mouse pointer
void setMouseImage(gPixelMap &img, int16 x, int16 y);
@@ -42,6 +65,9 @@ void setMouseGauge(int numerator, int denominator);
// Turn off the gauge on the mouse pointer
void clearMouseGauge(void);
+void initCursors();
+void freeCursors();
+
} // end of namespace Saga2
#endif
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index a3175ac78a..3bc789fee6 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -36,6 +36,7 @@
#include "saga2/std.h"
#include "saga2/gdraw.h"
+#include "saga2/mouseimg.h"
namespace Saga2 {
@@ -155,6 +156,20 @@ uint8 *loadingWindowData;
uint8 *ColorMapRanges;
+uint8 *closeBx1ImageData;
+uint8 *closeBx2ImageData;
+uint8 *usePtrImageData;
+uint8 *xPointerImageData;
+uint8 *arrowImageData;
+uint8 *grabPtrImageData;
+uint8 *attakPtrImageData;
+uint8 *centerActorIndicatorImageData;
+uint8 *pgUpImageData;
+uint8 *pgDownImageData;
+uint8 *pgLeftImageData;
+uint8 *pgRightImageData;
+uint8 *autoWalkImageData;
+uint8 *gaugeImageData;
static void loadFont(Common::File &file, gFont *font, uint32 offset) {
file.seek(offset);
@@ -181,10 +196,30 @@ struct dataChunks {
uint32 offset;
uint32 size;
} chunks[] = {
- { &loadingWindowPalette,0x004A2600, 1024 },
- { &loadingWindowData, 0x004A2A00, 307200 },
- { &ColorMapRanges, 0x004EDC20, 1584 },
- { NULL, 0, 0 }
+ { (uint8 **)&Onyx10Font, 0x004F7258, 0 },
+ { (uint8 **)&Plate18Font, 0x004F7EE0, 0 },
+ { (uint8 **)&Helv11Font, 0x004F9F30, 0 },
+ { (uint8 **)&Amber13Font, 0x004FAC60, 0 },
+ { (uint8 **)&ThinFix8Font, 0x004FC210, 0 },
+ { (uint8 **)&Script10Font, 0x004FCD18, 0 },
+ { &loadingWindowPalette, 0x004A2600, 1024 },
+ { &loadingWindowData, 0x004A2A00, 307200 },
+ { &ColorMapRanges, 0x004EDC20, 1584 },
+ { &closeBx1ImageData, 0x004EE2B8, 144 },
+ { &closeBx2ImageData, 0x004EE348, 144 },
+ { &usePtrImageData, 0x004EE3D8, 232 },
+ { &xPointerImageData, 0x004EE4C0, 232 },
+ { &arrowImageData, 0x004EE5A8, 192 },
+ { &grabPtrImageData, 0x004EE668, 208 },
+ { &attakPtrImageData, 0x004EE738, 536 },
+ { ¢erActorIndicatorImageData,0x004EE950, 96 },
+ { &pgUpImageData, 0x004EE9B0, 256 },
+ { &pgDownImageData, 0x004EEAB0, 256 },
+ { &pgLeftImageData, 0x004EEBB0, 256 },
+ { &pgRightImageData, 0x004EECB0, 256 },
+ { &autoWalkImageData, 0x004EEDB0, 228 },
+ { &gaugeImageData, 0x004EF257, 241 },
+ { NULL, 0, 0 }
};
void Saga2Engine::loadExeResources() {
@@ -197,32 +232,29 @@ void Saga2Engine::loadExeResources() {
if (exe.size() != 1093120)
error("Incorrect FTA2WIN.EXE file size. Expected is 1093120");
- loadFont(exe, &Onyx10Font, 0x004F7258 - offset);
- loadFont(exe, &Plate18Font, 0x004F7EE0 - offset);
- loadFont(exe, &Helv11Font, 0x004F9F30 - offset);
- loadFont(exe, &Amber13Font, 0x004FAC60 - offset);
- loadFont(exe, &ThinFix8Font, 0x004FC210 - offset);
- loadFont(exe, &Script10Font, 0x004FCD18 - offset);
-
for (int i = 0; chunks[i].ptr; i++) {
- *chunks[i].ptr = (uint8 *)malloc(chunks[i].size);
- exe.seek(chunks[i].offset - offset);
- exe.read(*chunks[i].ptr, chunks[i].size);
+ if (chunks[i].size == 0) { // Font
+ loadFont(exe, (gFont *)chunks[i].ptr, chunks[i].offset - offset);
+ } else {
+ *chunks[i].ptr = (uint8 *)malloc(chunks[i].size);
+ exe.seek(chunks[i].offset - offset);
+ exe.read(*chunks[i].ptr, chunks[i].size);
+ }
}
+ initCursors();
+
exe.close();
}
void Saga2Engine::freeExeResources() {
- free(Onyx10Font.fontdata);
- free(Plate18Font.fontdata);
- free(Helv11Font.fontdata);
- free(Amber13Font.fontdata);
- free(ThinFix8Font.fontdata);
- free(Script10Font.fontdata);
-
- free(loadingWindowPalette);
- free(loadingWindowData);
+ for (int i = 0; chunks[i].ptr; i++)
+ if (chunks[i].size == 0) // Font
+ free(((gFont *)chunks[i].ptr)->fontdata);
+ else
+ free(*chunks[i].ptr);
+
+ freeCursors();
}
} // End of namespace Saga2
diff --git a/engines/saga2/tilemode.cpp b/engines/saga2/tilemode.cpp
index 2e492a5a0c..406f1351d4 100644
--- a/engines/saga2/tilemode.cpp
+++ b/engines/saga2/tilemode.cpp
@@ -42,7 +42,6 @@
#include "saga2/intrface.h"
#include "saga2/dispnode.h"
#include "saga2/uidialog.h"
-#include "saga2/images.h"
#include "saga2/config.h"
#include "saga2/contain.h"
#include "saga2/savefile.h"
@@ -503,7 +502,8 @@ static void evalMouseState(void) {
// the intention to walk to the mouse pointer
if (interruptable) {
mouseInfo.setIntent(GrabInfo::WalkTo);
- if (tileMapControl->isSticky()) setMouseImage(AutoWalkImage, -8, -8);
+ if (tileMapControl->isSticky())
+ setMouseImage(kMouseAutoWalkImage, -8, -8);
walkToPos = tilePickPos;
}
}
@@ -513,7 +513,8 @@ static void evalMouseState(void) {
// Set the intention to walk to the mouse
// pointer
mouseInfo.setIntent(GrabInfo::WalkTo);
- if (tileMapControl->isSticky()) setMouseImage(AutoWalkImage, -8, -8);
+ if (tileMapControl->isSticky())
+ setMouseImage(kMouseAutoWalkImage, -8, -8);
walkToPos = tilePickPos;
}
} else
@@ -568,7 +569,8 @@ static void evalMouseState(void) {
// Simply set the intention to walk to the mouse
// pointer
mouseInfo.setIntent(GrabInfo::WalkTo);
- if (tileMapControl->isSticky()) setMouseImage(AutoWalkImage, -8, -8);
+ if (tileMapControl->isSticky())
+ setMouseImage(kMouseAutoWalkImage, -8, -8);
walkToPos = tilePickPos;
}
}
@@ -965,7 +967,7 @@ void TileModeHandleKey(int16 key, int16 qual) {
if (tileMapControl->isSticky()) {
tileMapControl->setSticky(FALSE);
mousePressed = FALSE;
- setMouseImage(ArrowImage, 0, 0);
+ setMouseImage(kMouseArrowImage, 0, 0);
evalMouseState();
}
MotionTask::wait(*a);
@@ -1383,7 +1385,7 @@ static APPFUNC(cmdClickTileMap) {
MotionTask::useTAI(*a, *pickedTAI);
} else {
tileMapControl->setSticky(TRUE);
- setMouseImage(AutoWalkImage, -8, -8);
+ setMouseImage(kMouseAutoWalkImage, -8, -8);
mousePressed = TRUE;
}
break;
@@ -1506,7 +1508,7 @@ gStickyDragControl::gStickyDragControl(gPanelList &list, const Rect16 &box,
}
void gStickyDragControl::deactivate(void) {
- if (sticky) setMouseImage(ArrowImage, 0, 0);
+ if (sticky) setMouseImage(kMouseArrowImage, 0, 0);
sticky = FALSE;
gGenericControl::deactivate();
}
@@ -1517,7 +1519,7 @@ void gStickyDragControl::deactivate(void) {
//}
bool gStickyDragControl::pointerHit(gPanelMessage &msg) {
- if (sticky) setMouseImage(ArrowImage, 0, 0);
+ if (sticky) setMouseImage(kMouseArrowImage, 0, 0);
sticky = FALSE;
return gGenericControl::pointerHit(msg);
}
diff --git a/engines/saga2/towerfta.cpp b/engines/saga2/towerfta.cpp
index c2ec4d6e85..25b82b7f04 100644
--- a/engines/saga2/towerfta.cpp
+++ b/engines/saga2/towerfta.cpp
@@ -35,7 +35,6 @@
#include "saga2/palette.h"
#include "saga2/intrface.h"
#include "saga2/mouseimg.h"
-#include "saga2/images.h"
#include "saga2/patrol.h"
#include "saga2/weapons.h"
#include "saga2/loadsave.h"
@@ -332,7 +331,7 @@ TERMINATOR(termGUIMessagers) {
INITIALIZER(initMousePointer) {
//pointer.hide();
- setMouseImage(ArrowImage, 0, 0);
+ setMouseImage(kMouseArrowImage, 0, 0);
return pointer.init(640, 480);
}
Commit: b8cdec88bd6d47156c49f6cf7cbe1386ffbea3e5
https://github.com/scummvm/scummvm/commit/b8cdec88bd6d47156c49f6cf7cbe1386ffbea3e5
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:58+02:00
Commit Message:
SAGA2: Fix ResourceActor loading
Changed paths:
engines/saga2/actor.cpp
engines/saga2/hresmgr.cpp
engines/saga2/hresmgr.h
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 6e4b81a5d7..ef2dd56694 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -3331,15 +3331,49 @@ void setCombatBehavior(bool enabled) {
//-------------------------------------------------------------------
// Initialize the actor list
+static void readResourceActor(hResContext *con, ResourceActor &resourceActor) {
+ resourceActor.protoIndex = con->readS16LE();
+ resourceActor.location.u = con->readS16LE();
+ resourceActor.location.v = con->readS16LE();
+ resourceActor.location.z = con->readS16LE();
+ resourceActor.nameIndex = con->readU16LE();
+ resourceActor.parentID = con->readU16LE();
+ resourceActor.script = con->readU16LE();
+ resourceActor.objectFlags = con->readU16LE();
+ resourceActor.hitPoints = con->readByte();
+ resourceActor.misc = con->readU16LE();
+
+ resourceActor.faction = con->readByte();
+ resourceActor.colorScheme = con->readByte();
+ resourceActor.appearanceID = con->readS32BE();
+ resourceActor.attitude = con->readSByte();
+ resourceActor.mood = con->readSByte();
+ resourceActor.disposition = con->readByte();
+ resourceActor.currentFacing = con->readByte();
+ resourceActor.tetherLocU = con->readS16LE();
+ resourceActor.tetherLocV = con->readS16LE();
+ resourceActor.tetherDist = con->readS16LE();
+ resourceActor.leftHandObject = con->readU16LE();
+ resourceActor.rightHandObject = con->readU16LE();
+ for (int i = 0; i < 16; ++i) {
+ resourceActor.knowledge[i] = con->readU16LE();
+ }
+ resourceActor.schedule = con->readU16LE();
+ for (int i = 0; i < 18; ++i) { // padding bytes = not neccessary?
+ resourceActor.reserved[i] = con->readByte();
+ }
+}
+
void initActors(void) {
// Load actors
int i,
resourceActorCount;
ResourceActor *resourceActorList;
+ const int resourceActorSize = 92;
resourceActorCount = listRes->size(actorListID)
- / sizeof(ResourceActor);
+ / resourceActorSize;
if (resourceActorCount < 1)
error("Unable to load Actors");
@@ -3349,23 +3383,20 @@ void initActors(void) {
// Allocate memory for the actor list
actorListSize = actorCount * sizeof(Actor);
- actorList = (Actor *)RNewClearPtr(actorListSize, NULL, "actor list");
+ actorList = new Actor[actorCount]();
if (!actorList)
error("Unable to load Actors");
// Allocate memory for the resource actors
- resourceActorList =
- (ResourceActor *)RNewClearPtr(resourceActorCount
- * sizeof(ResourceActor),
- NULL, "res actor list");
+ resourceActorList = new ResourceActor[resourceActorCount]();
if (!resourceActorList || listRes->seek(actorListID) == 0)
error("Unable to load Actors");
// Read the resource actors
- listRes->read(resourceActorList,
- sizeof(ResourceActor) * resourceActorCount);
+ for (int k = 0; k < resourceActorCount; ++k)
+ readResourceActor(listRes, resourceActorList[k]);
for (i = 0; i < resourceActorCount; i++) {
Actor *a = &actorList[ i ];
@@ -3389,7 +3420,7 @@ void initActors(void) {
// Wait for the object initialization to append the actors to their
// parents' child lists
- RDisposePtr(resourceActorList);
+ delete[] resourceActorList;
}
//-------------------------------------------------------------------
@@ -3409,7 +3440,7 @@ void saveActors(SaveFileConstructor &saveGame) {
for (i = 0; i < actorCount; i++)
archiveBufSize += actorList[ i ].archiveSize();
- archiveBuffer = RNewPtr(archiveBufSize, NULL, "archive buffer");
+ archiveBuffer = malloc(archiveBufSize);
if (archiveBuffer == NULL)
error("Unable to allocate actor archive buffer");
@@ -3428,7 +3459,7 @@ void saveActors(SaveFileConstructor &saveGame) {
archiveBuffer,
archiveBufSize);
- RDisposePtr(archiveBuffer);
+ free(archiveBuffer);
}
//-------------------------------------------------------------------
@@ -3445,13 +3476,13 @@ void loadActors(SaveFileReader &saveGame) {
// Allocate the actor array
actorListSize = actorCount * sizeof(Actor);
- actorList = (Actor *)RNewPtr(actorListSize, NULL, "actor list");
+ actorList = new Actor[actorCount]();
if (actorList == NULL)
error("Unable to load Actors");
// Allocate memory for the archive buffer
archiveBufSize = saveGame.bytesLeftInChunk();
- archiveBuffer = RNewPtr(archiveBufSize, NULL, "archive buffer");
+ archiveBuffer = malloc(archiveBufSize);
if (archiveBuffer == NULL)
error("Unable to load Actors");
@@ -3466,7 +3497,7 @@ void loadActors(SaveFileReader &saveGame) {
assert(bufferPtr == &((char *)archiveBuffer)[ archiveBufSize ]);
// Deallocate the archive buffer
- RDisposePtr(archiveBuffer);
+ free(archiveBuffer);
}
//-------------------------------------------------------------------
@@ -3479,7 +3510,7 @@ void cleanupActors(void) {
for (i = 0; i < actorCount; i++)
actorList[ i ].~Actor();
- RDisposePtr(actorList);
+ delete[] actorList;
actorList = NULL;
}
}
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index c3c223dfea..d6d7796d3f 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -212,6 +212,76 @@ void hResContext::rest(void) {
}
}
+uint8 hResContext::readByte() {
+ if (!_handle)
+ return 0;
+
+ if (!_handle->isOpen())
+ return 0;
+
+ return _handle->readByte();
+}
+
+int8 hResContext::readSByte() {
+ if (!_handle)
+ return 0;
+
+ if (!_handle->isOpen())
+ return 0;
+
+ return _handle->readSByte();
+}
+
+uint16 hResContext::readU16LE() {
+ if (!_handle)
+ return 0;
+
+ if (!_handle->isOpen())
+ return 0;
+
+ return _handle->readUint16LE();
+}
+
+int16 hResContext::readS16LE() {
+ if (!_handle)
+ return 0;
+
+ if (!_handle->isOpen())
+ return 0;
+
+ return _handle->readSint16LE();
+}
+
+uint32 hResContext::readU32LE() {
+ if (!_handle)
+ return 0;
+
+ if (!_handle->isOpen())
+ return 0;
+
+ return _handle->readUint32LE();
+}
+
+int32 hResContext::readS32LE() {
+ if (!_handle)
+ return 0;
+
+ if (!_handle->isOpen())
+ return 0;
+
+ return _handle->readSint32LE();
+}
+
+int32 hResContext::readS32BE() {
+ if (!_handle)
+ return 0;
+
+ if (!_handle->isOpen())
+ return 0;
+
+ return _handle->readSint32BE();
+}
+
bool hResContext::read(void *buffer, uint32 size) {
assert(_handle);
if (!_valid) return false;
diff --git a/engines/saga2/hresmgr.h b/engines/saga2/hresmgr.h
index 7f2689f3db..08fd390bc3 100644
--- a/engines/saga2/hresmgr.h
+++ b/engines/saga2/hresmgr.h
@@ -157,6 +157,14 @@ public:
inline size_t bytesleft(void) {
return _bytecount;
}
+ uint8 readByte();
+ int8 readSByte();
+ uint16 readU16LE();
+ int16 readS16LE();
+ uint32 readU32LE();
+ int32 readS32LE();
+ int32 readS32BE();
+
bool read(void *buffer, uint32 size);
bool skip(uint32 amount);
bool get(hResID id, void *buffer, uint32 size);
Commit: d54d3a0dceba3782218ad5b10f8d6477fed1d849
https://github.com/scummvm/scummvm/commit/d54d3a0dceba3782218ad5b10f8d6477fed1d849
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:58+02:00
Commit Message:
SAGA2: Fix ResourceActor size
Changed paths:
engines/saga2/actor.cpp
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index ef2dd56694..fb9e9c53d2 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -3370,7 +3370,7 @@ void initActors(void) {
int i,
resourceActorCount;
ResourceActor *resourceActorList;
- const int resourceActorSize = 92;
+ const int resourceActorSize = 91; // size of the packed struct
resourceActorCount = listRes->size(actorListID)
/ resourceActorSize;
Commit: 9bde6969e1e699c8577731e0c4582470a7c127a6
https://github.com/scummvm/scummvm/commit/9bde6969e1e699c8577731e0c4582470a7c127a6
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:58+02:00
Commit Message:
SAGA2: Fix object prototype loading
Changed paths:
engines/saga2/objects.cpp
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index c906bade97..c0eff7b5a1 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -2462,8 +2462,81 @@ extern int enchantmentProto;
//-------------------------------------------------------------------
// Load and construct object and actor prototype arrays
+static void readObjectPrototype(hResContext *con, ResourceObjectPrototype &obj) {
+ obj.classType = con->readS16LE();
+ obj.script = con->readU16LE();
+ obj.nameIndex = con->readS16LE();
+ obj.iconSprite = con->readU16LE();
+ obj.groundSprite = con->readU16LE();
+
+ for (int i = 0; i < 4; ++i)
+ obj.colorMap[i] = con->readByte();
+
+ obj.mass = con->readByte();
+ obj.bulk = con->readByte();
+ obj.crossSection = con->readByte();
+ obj.height = con->readByte();
+ obj.toughness = con->readByte();
+ obj.breakType = con->readByte();
+ obj.maxCapacity = con->readU16LE();
+ obj.lockType = con->readByte();
+ obj.acceptableItems = con->readByte();
+ obj.weaponDamage = con->readByte();
+ obj.weaponFireRate = con->readByte();
+ obj.maximumRange = con->readByte();
+ obj.missileType = con->readByte();
+ obj.whereWearable = con->readByte();
+ obj.damageAbsorbtion = con->readSByte();
+ obj.damageDivider = con->readSByte();
+ obj.defenseBonus = con->readSByte();
+ obj.maxCharges = con->readByte();
+ obj.chargeType = con->readByte();
+ obj.flags = con->readS16LE();
+ obj.price = con->readS16LE();
+ obj.heldSpriteBase = con->readS16LE(); // union
+ obj.resistance = con->readS16LE();
+ obj.immunity = con->readS16LE();
+ obj.soundFXClass = con->readByte();
+
+ for (int i = 0; i < 7; ++i)
+ obj.reserved[i] = con->readByte();
+}
+
+static void readActorPrototype(hResContext *con, ResourceActorPrototype &act) {
+ readObjectPrototype(con, act.proto);
+
+ ActorAttributes *att = &act.ext.baseStats;
+ att->archery = con->readByte();
+ att->swordcraft = con->readByte();
+ att->shieldcraft = con->readByte();
+ att->bludgeon = con->readByte();
+ att->throwing = con->readByte();
+ att->spellcraft = con->readByte();
+ att->stealth = con->readByte();
+ att->agility = con->readByte();
+ att->brawn = con->readByte();
+ att->lockpick = con->readByte();
+ att->pilfer = con->readByte();
+ att->firstAid = con->readByte();
+ att->spotHidden = con->readByte();
+ att->pad = con->readSByte();
+ att->vitality = con->readS16LE();
+ att->redMana = con->readS16LE();
+ att->orangeMana = con->readS16LE();
+ att->yellowMana = con->readS16LE();
+ att->greenMana = con->readS16LE();
+ att->blueMana = con->readS16LE();
+ att->violetMana = con->readS16LE();
+
+ act.ext.combatBehavior = con->readByte();
+ act.ext.gruntStyle = con->readByte();
+ act.ext.baseEffectFlags = con->readU32LE();
+}
+
void initPrototypes(void) {
int i;
+ const int resourceObjProtoSize = 52;
+ const int resourceActProtoSize = 86;
nameList = (uint16 *)listRes->loadResource(nameListID, "name list");
nameListCount = listRes->size(nameListID) / sizeof nameList[0];
@@ -2471,7 +2544,7 @@ void initPrototypes(void) {
// Load the Object prototype table
objectProtoCount = listRes->size(objProtoID)
- / sizeof(ResourceObjectPrototype);
+ / resourceObjProtoSize;
if (objectProtoCount < 1)
error("Unable to load Object Prototypes");
@@ -2488,7 +2561,7 @@ void initPrototypes(void) {
ResourceObjectPrototype ro;
ProtoObj *pr = &objectProtos[i];
- listRes->read(&ro, sizeof(ResourceObjectPrototype));
+ readObjectPrototype(listRes, ro);
switch (ro.classType) {
case protoClassInventory:
@@ -2618,7 +2691,7 @@ void initPrototypes(void) {
// Load the Actor prototype table
actorProtoCount = listRes->size(actorProtoID)
- / sizeof(ResourceActorPrototype);
+ / resourceActProtoSize;
if (actorProtoCount < 1)
error("Unable to load Actor Prototypes");
@@ -2632,7 +2705,7 @@ void initPrototypes(void) {
ResourceActorPrototype ra;
ActorProto *pr = &actorProtos[i];
- listRes->read(&ra, sizeof(ResourceActorPrototype));
+ readActorPrototype(listRes, ra);
new (pr) ActorProto(ra);
}
Commit: c628f16be1c42844d79b7cdd182c3b9486cad4d8
https://github.com/scummvm/scummvm/commit/c628f16be1c42844d79b7cdd182c3b9486cad4d8
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:58+02:00
Commit Message:
SAGA2: Fix game object loading
Changed paths:
engines/saga2/objects.cpp
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index c0eff7b5a1..323bc7752e 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -2943,10 +2943,24 @@ void cleanupWorlds(void) {
//-------------------------------------------------------------------
// Initialize the Objects list
+static void readGameObject(hResContext *con, ResourceGameObject &obj) {
+ obj.protoIndex = con->readS16LE();
+ obj.location.u = con->readS16LE();
+ obj.location.v = con->readS16LE();
+ obj.location.z = con->readS16LE();
+ obj.nameIndex = con->readU16LE();
+ obj.parentID = con->readU16LE();
+ obj.script = con->readU16LE();
+ obj.objectFlags = con->readU16LE();
+ obj.hitPoints = con->readByte();
+ obj.misc = con->readU16LE();
+}
+
void initObjects(void) {
int16 i,
resourceObjectCount;
ResourceGameObject *resourceObjectList;
+ const int resourceGameObjSize = 19;
// Initialize the limbo counts
objectLimboCount = 0;
@@ -2954,7 +2968,7 @@ void initObjects(void) {
importantLimboCount = 0;
resourceObjectCount = listRes->size(objListID)
- / sizeof(ResourceGameObject);
+ / resourceGameObjSize;
if (resourceObjectCount < 4)
error("Unable to load Objects");
@@ -2977,8 +2991,8 @@ void initObjects(void) {
error("Unable to load Objects");
// Read the resource Objects
- listRes->read(resourceObjectList,
- sizeof(ResourceGameObject) * resourceObjectCount);
+ for (int k = 0; k < resourceObjectCount; ++k)
+ readGameObject(listRes, resourceObjectList[k]);
for (i = 0; i < resourceObjectCount; i++) {
GameObject *obj = &objectList[i];
Commit: 4e605d24f84a3da6564e52a1ce97ceab7ae7fd82
https://github.com/scummvm/scummvm/commit/4e605d24f84a3da6564e52a1ce97ceab7ae7fd82
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:58+02:00
Commit Message:
SAGA2: Fix ActiveItemStates initialization
Changed paths:
engines/saga2/tile.cpp
engines/saga2/tile.h
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 0d0fc2d21d..ce93eead63 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -195,7 +195,7 @@ static RipTable ripTableList[25];
WorldMapData *mapList; // master map data array
-UByteHandle *stateArray; // Array of active item instance
+byte **stateArray; // Array of active item instance
// state arrays
CyclePtr cycleList; // list of tile cycling info
@@ -811,19 +811,14 @@ TilePoint getClosestPointOnTAI(ActiveItem *TAI, GameObject *obj) {
void initActiveItemStates(void) {
int16 i;
- stateArray = (UByteHandle *)RNewPtr(
- worldCount * sizeof(UByteHandle),
- nullptr,
- "active item state array array");
+ stateArray = new byte *[worldCount]();
if (stateArray == nullptr)
error("Unable to allocate the active item state array array");
for (i = 0; i < worldCount; i++) {
- stateArray[i] = (UByteHandle)LoadResourceToHandle(
- tileRes,
- tagStateID + MKTAG(0, 0, 0, uint8(i)),
- "active item state array");
+ stateArray[i] = (byte *)LoadResource(tileRes, tagStateID + MKTAG(0, 0, 0, uint8(i)),
+ "active item state array");
if (stateArray[i] == nullptr)
error("Unable to load active item state array");
@@ -841,12 +836,13 @@ void saveActiveItemStates(SaveFileConstructor &saveGame) {
void *bufferPtr;
for (i = 0; i < worldCount; i++) {
+ int32 size = tileRes->size(tagStateID + MKTAG(0, 0, 0, uint8(i)));
archiveBufSize += sizeof(int16);
if (stateArray[i] != nullptr)
- archiveBufSize += RPtrSize(*stateArray[i]);
+ archiveBufSize += size;
}
- archiveBuffer = RNewPtr(archiveBufSize, nullptr, "archive buffer");
+ archiveBuffer = malloc(archiveBufSize);
if (archiveBuffer == nullptr)
error("Unable to allocate a state array archive buffer");
@@ -858,7 +854,7 @@ void saveActiveItemStates(SaveFileConstructor &saveGame) {
ActiveItemPtr activeItemList = mapData->activeItemList;
int16 activeItemCount = mapData->activeCount,
j;
- int32 arraySize = RPtrSize(*stateArray[i]);
+ int32 arraySize = tileRes->size(tagStateID + MKTAG(0, 0, 0, uint8(i)));
uint8 *bufferedStateArray;
// Save the size of the state array
@@ -866,7 +862,7 @@ void saveActiveItemStates(SaveFileConstructor &saveGame) {
bufferPtr = (int16 *)bufferPtr + 1;
// Copy the state data to the archive buffer
- memcpy(bufferPtr, *stateArray[i], arraySize);
+ memcpy(bufferPtr, stateArray[i], arraySize);
// Save a pointer to the buffered data
bufferedStateArray = (uint8 *)bufferPtr;
bufferPtr = (uint8 *)bufferPtr + arraySize;
@@ -901,7 +897,7 @@ void saveActiveItemStates(SaveFileConstructor &saveGame) {
archiveBuffer,
archiveBufSize);
- RDisposePtr(archiveBuffer);
+ free(archiveBuffer);
}
//-----------------------------------------------------------------------
@@ -913,18 +909,12 @@ void loadActiveItemStates(SaveFileReader &saveGame) {
void *archiveBuffer;
void *bufferPtr;
- stateArray = (UByteHandle *)RNewPtr(
- worldCount * sizeof(UByteHandle),
- nullptr,
- "active item state array array");
+ stateArray = new byte *[worldCount]();
if (stateArray == nullptr)
error("Unable to allocate the active item state array array");
- archiveBuffer = RNewPtr(
- saveGame.getChunkSize(),
- nullptr,
- "archive buffer");
+ archiveBuffer = malloc(saveGame.getChunkSize());
if (archiveBuffer == nullptr)
error("Unable to allocate state array archive buffer");
@@ -966,20 +956,17 @@ void loadActiveItemStates(SaveFileReader &saveGame) {
*statePtr &= ~(1 << 7);
}
- stateArray[i] = (UByteHandle)RNewHandle(
- arraySize,
- nullptr,
- "active item state array");
+ stateArray[i] = (byte *)malloc(arraySize);
if (stateArray[i] == nullptr)
error("Unable to allocate active item state array");
- memcpy(*stateArray[i], bufferPtr, arraySize);
+ memcpy(stateArray[i], bufferPtr, arraySize);
bufferPtr = (uint8 *)bufferPtr + arraySize;
} else
stateArray[i] = nullptr;
}
- RDisposePtr(archiveBuffer);
+ free(archiveBuffer);
}
//-----------------------------------------------------------------------
@@ -990,10 +977,10 @@ void cleanupActiveItemStates(void) {
for (i = 0; i < worldCount; i++) {
if (stateArray[i] != nullptr)
- RDisposeHandle((RHANDLE)stateArray[i]);
+ free(stateArray[i]);
}
- RDisposePtr(stateArray);
+ delete[] stateArray;
}
/* ===================================================================== *
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index 84e5c00e5e..68ab5b3466 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -391,7 +391,7 @@ enum ActiveItemTypes {
};
// A pointer to the array of active item state arrays
-extern UByteHandle *stateArray;
+extern byte **stateArray;
class ActiveItem {
public:
@@ -465,12 +465,12 @@ public:
// Return the state number of this active item instance
uint8 getInstanceState(int16 mapNum) {
- return (*stateArray[ mapNum ])[ instance.stateIndex ];
+ return stateArray[mapNum][instance.stateIndex];
}
// Set the state number of this active item instance
void setInstanceState(int16 mapNum, uint8 state) {
- (*stateArray[ mapNum ])[ instance.stateIndex ] = state;
+ stateArray[mapNum][instance.stateIndex] = state;
}
uint8 builtInBehavior(void) {
Commit: 98a454470e5fafb776246fe3850de028313d25dc
https://github.com/scummvm/scummvm/commit/98a454470e5fafb776246fe3850de028313d25dc
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:59+02:00
Commit Message:
SAGA2: Replace memory management methods in tile.cpp
Changed paths:
engines/saga2/tile.cpp
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index ce93eead63..20a5f2d983 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -1353,7 +1353,7 @@ void saveTileTasks(SaveFileConstructor &saveGame) {
archiveBufSize = aTaskList.archiveSize();
- archiveBuffer = RNewPtr(archiveBufSize, nullptr, "archive buffer");
+ archiveBuffer = malloc(archiveBufSize);
if (archiveBuffer == nullptr)
error("Unable to allocate tile activity task archive buffer");
@@ -1364,7 +1364,7 @@ void saveTileTasks(SaveFileConstructor &saveGame) {
archiveBuffer,
archiveBufSize);
- RDisposePtr(archiveBuffer);
+ free(archiveBuffer);
}
//-----------------------------------------------------------------------
@@ -1380,10 +1380,7 @@ void loadTileTasks(SaveFileReader &saveGame) {
void *archiveBuffer;
void *bufferPtr;
- archiveBuffer = RNewPtr(
- saveGame.getChunkSize(),
- nullptr,
- "archive buffer");
+ archiveBuffer = malloc(saveGame.getChunkSize());
if (archiveBuffer == nullptr)
error("Unable to allocate tile activity task archive buffer");
@@ -1395,7 +1392,7 @@ void loadTileTasks(SaveFileReader &saveGame) {
// Reconstruct aTaskList from archived data
new (&aTaskList) TileActivityTaskList(&bufferPtr);
- RDisposePtr(archiveBuffer);
+ free(archiveBuffer);
}
@@ -1634,7 +1631,7 @@ void saveAutoMap(SaveFileConstructor &saveGame) {
// for each map metatile slot
archiveBufSize = (totalMapSize + 7) >> 3;
- archiveBuffer = (uint8 *)RNewPtr(archiveBufSize, nullptr, "archive buffer");
+ archiveBuffer = (uint8 *)malloc(archiveBufSize);
if (archiveBuffer == nullptr)
error("Unable to allocate auto map archive buffer");
@@ -1669,7 +1666,7 @@ void saveAutoMap(SaveFileConstructor &saveGame) {
archiveBuffer,
archiveBufSize);
- RDisposePtr(archiveBuffer);
+ free(archiveBuffer);
}
//-----------------------------------------------------------------------
@@ -1684,7 +1681,7 @@ void loadAutoMap(SaveFileReader &saveGame) {
archiveBufSize = saveGame.getChunkSize();
- archiveBuffer = (uint8 *)RNewPtr(archiveBufSize, nullptr, "archive buffer");
+ archiveBuffer = (uint8 *)malloc(archiveBufSize);
if (archiveBuffer == nullptr)
error("Unable to allocate auto map archive buffer");
@@ -1716,7 +1713,7 @@ void loadAutoMap(SaveFileReader &saveGame) {
}
}
- RDisposePtr(archiveBuffer);
+ free(archiveBuffer);
}
/* ===================================================================== *
@@ -4293,10 +4290,7 @@ void saveTileCyclingStates(SaveFileConstructor &saveGame) {
TileCycleArchive *archiveBuffer;
int16 i;
- archiveBuffer = (TileCycleArchive *)RNewPtr(
- sizeof(TileCycleArchive) * cycleCount,
- nullptr,
- "archive buffer");
+ archiveBuffer = new TileCycleArchive[cycleCount]();
if (archiveBuffer == nullptr)
error("Unable to allocate tile cycle data archive buffer");
@@ -4310,7 +4304,7 @@ void saveTileCyclingStates(SaveFileConstructor &saveGame) {
archiveBuffer,
sizeof(TileCycleArchive) * cycleCount);
- RDisposePtr(archiveBuffer);
+ delete[] archiveBuffer;
}
//-----------------------------------------------------------------------
@@ -4324,10 +4318,7 @@ void loadTileCyclingStates(SaveFileReader &saveGame) {
assert(saveGame.getChunkSize() == sizeof(TileCycleArchive) * cycleCount);
- archiveBuffer = (TileCycleArchive *)RNewPtr(
- sizeof(TileCycleArchive) * cycleCount,
- nullptr,
- "archive buffer");
+ archiveBuffer = new TileCycleArchive[cycleCount]();
if (archiveBuffer == nullptr)
error("Unable to allocate tile cycle data archive buffer");
@@ -4338,7 +4329,7 @@ void loadTileCyclingStates(SaveFileReader &saveGame) {
cycleList[i].currentState = archiveBuffer[i].currentState;
}
- RDisposePtr(archiveBuffer);
+ delete[] archiveBuffer;
}
//-----------------------------------------------------------------------
Commit: 9ac480ef361b96b7594a289731fc2cc4ac5dc736
https://github.com/scummvm/scummvm/commit/9ac480ef361b96b7594a289731fc2cc4ac5dc736
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:59+02:00
Commit Message:
SAGA2: Increase maxSensorSize
Changed paths:
engines/saga2/sensor.h
diff --git a/engines/saga2/sensor.h b/engines/saga2/sensor.h
index e4a0157233..e27f3631a0 100644
--- a/engines/saga2/sensor.h
+++ b/engines/saga2/sensor.h
@@ -31,7 +31,8 @@ namespace Saga2 {
const uint32 nonActorSenseFlags = actorSeeInvis;
-const size_t maxSensorSize = 24;
+//const size_t maxSensorSize = 24;
+const size_t maxSensorSize = 48;
// This constant represents the maximum sense range for an object.
// Zero means an infinite range.
Commit: 6a96f6d87cfb6b455c6df9052884753663d0c1ff
https://github.com/scummvm/scummvm/commit/6a96f6d87cfb6b455c6df9052884753663d0c1ff
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:59+02:00
Commit Message:
SAGA2: Fix sprite banks loading
Changed paths:
engines/saga2/sprite.cpp
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index bff7711bee..4fb98d70c4 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -611,26 +611,10 @@ void ActorAppearance::loadSpriteBanks(int16 banksNeeded) {
appearanceLRU.addTail(*this);
// Load in additional sprite banks if requested...
- for (bank = 0; bank < elementsof(spriteBanks); bank++) {
- // Wash the sprite banks...i.e. clear out dead handles
- // which have been purged.
- washHandle((RHANDLE &)(spriteBanks[bank]));
-
+ for (bank = 0; bank < (long)elementsof(spriteBanks); bank++) {
// Load the sprite handle...
- if (spriteBanks[bank] == nullptr && (banksNeeded & (1 << bank))) {
- spriteBanks[bank] = (SpriteSet **)spriteRes->load(id + MKTAG(0, 0, 0, bank), "sprite bank", FALSE);
-
-#if DEBUG
- if (spriteBanks[bank] == nullptr)
- fatal("Sprite '%s' bank %d failed to load!\n",
- idname(id),
- bank);
-#endif
-
- // Since the sprites are so big, we'll keep them unlocked
- // so that they can be purged as needed.
- RUnlockHandle((RHANDLE) spriteBanks[bank]);
- }
+ if (spriteBanks[bank] == nullptr && (banksNeeded & (1 << bank)))
+ spriteBanks[bank] = (SpriteSet **)spriteRes->loadResource(id + MKTAG(0, 0, 0, bank), "sprite bank");
}
}
@@ -674,16 +658,18 @@ ActorAppearance *LoadActorAppearance(uint32 id, int16 banksNeeded) {
}
// Dump the sprites being stored
- for (bank = 0; bank < elementsof(aa->spriteBanks); bank++) {
+ for (bank = 0; bank < (long)elementsof(aa->spriteBanks); bank++) {
if (aa->spriteBanks[bank])
- spriteRes->release((RHANDLE) aa->spriteBanks[bank]);
+ free(aa->spriteBanks[bank]);
aa->spriteBanks[bank] = nullptr;
}
- if (aa->poseList) poseRes->release((RHANDLE) aa->poseList);
+ if (aa->poseList)
+ free(aa->poseList);
aa->poseList = nullptr;
- if (aa->schemeList) schemeRes->release((RHANDLE) aa->schemeList);
+ if (aa->schemeList)
+ free(aa->schemeList);
aa->schemeList = nullptr;
// Set ID and use count
@@ -692,17 +678,8 @@ ActorAppearance *LoadActorAppearance(uint32 id, int16 banksNeeded) {
// Load in new frame lists and sprite banks
aa->loadSpriteBanks(banksNeeded);
- aa->poseList = (ActorAnimSet **)poseRes->load(id, "pose list", FALSE, FALSE);
-// I just added these - dispnode may have to lock & unlock the handle now - EO
- if (aa->poseList) RUnlockHandle((RHANDLE) aa->poseList);
-#if DEBUG
- if (aa->poseList == nullptr)
- fatal("PoseList '%s' failed to load!\n", idname(id));
-#endif
- // REM: It's OK if schemelist fails to load...
- aa->schemeList = (ColorScheme **)schemeRes->load(id, "scheme list", FALSE, FALSE);
-// I just added these - dispnode may have to lock & unlock the handle now - EO
- if (aa->schemeList) RUnlockHandle((RHANDLE) aa->schemeList);
+ aa->poseList = (ActorAnimSet **)poseRes->loadResource(id, "pose list");
+ aa->schemeList = (ColorScheme **)schemeRes->loadResource(id, "scheme list");
return aa;
}
Commit: 05c3ed6ea0ddd688bfb19e51bb8ff5e80dcd205b
https://github.com/scummvm/scummvm/commit/05c3ed6ea0ddd688bfb19e51bb8ff5e80dcd205b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:59+02:00
Commit Message:
SAGA2: Implement keyboard/mouse event handling
Changed paths:
engines/saga2/fta.h
engines/saga2/main.cpp
engines/saga2/mainmap.h
engines/saga2/panel.cpp
engines/saga2/panel.h
engines/saga2/tile.cpp
engines/saga2/tromode.cpp
diff --git a/engines/saga2/fta.h b/engines/saga2/fta.h
index 2e789b438a..584003afd1 100644
--- a/engines/saga2/fta.h
+++ b/engines/saga2/fta.h
@@ -157,10 +157,6 @@ public:
void WriteStatusF(int16 lin, const char *msg, ...);
-// Mouse polling
-
-void PollMouse(void);
-
// File loading
void *LoadFile(char *filename); // load file into buffer
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 62d4efa1af..9861e3f7ff 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -27,6 +27,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "common/debug.h"
+#include "common/events.h"
#include "saga2/std.h"
#include "saga2/setup.h"
@@ -174,8 +175,6 @@ void EventLoop(bool &running, bool modal); // handles input and distri
void SystemEventLoop(void);
void ClearMessageQueue(void);
-void SystemMouseHandler(void);
-void SystemKeyHandler(short, short);
void waitForVideoFile(char *fileName);
void memtest(void);
@@ -191,7 +190,6 @@ void cleanupGame(void); // auto-cleanup function
void RShowMem(void);
void parseCommandLine(int argc, char *argv[]);
char *getExeFromCommandLine(int argc, char *argv[]);
-void updateMouse(void);
void WriteStatusF2(int16 line, const char *msg, ...);
bool initUserDialog(void);
void cleanupUserDialog(void);
@@ -337,14 +335,26 @@ void processEventLoop(bool updateScreen) {
if (GameMode::newmodeFlag)
GameMode::update();
- debugC(1, kDebugEventLoop, "EventLoop: mouse update");
- updateMouse();
-
- debugC(1, kDebugEventLoop, "EventLoop: keyboard update");
- if (ReadKeyboard(key, qual)) {
- G_BASE.handleKeyStroke(key, qual);
+ Common::Event event;
+ while (g_vm->getEventManager()->pollEvent(event)) {
+ switch (event.type) {
+ case Common::EVENT_LBUTTONDOWN:
+ case Common::EVENT_RBUTTONDOWN:
+ case Common::EVENT_LBUTTONUP:
+ case Common::EVENT_RBUTTONUP:
+ case Common::EVENT_MOUSEMOVE:
+ G_BASE.handleMouse(event, g_system->getMillis());
+ break;
+ case Common::EVENT_KEYDOWN:
+ G_BASE.handleKeyStroke(event);
+ break;
+ case Common::EVENT_QUIT:
+ gameRunning = false;
+ break;
+ default:
+ break;
+ }
}
-
//if(!running) return; // This Is No Tasks Are Done After Saving Game
debugC(1, kDebugEventLoop, "EventLoop: timer update");
@@ -420,12 +430,18 @@ void SystemEventLoop(void) {
if (handlingMessages())
return;
- // check mouse
- SystemMouseHandler();
-
- // check keyboard
- if (ReadKeyboard(key, qual)) {
- SystemKeyHandler(key, qual);
+ Common::Event event;
+ while (g_vm->getEventManager()->pollEvent(event)) {
+ switch (event.type) {
+ case Common::EVENT_LBUTTONUP:
+ case Common::EVENT_RBUTTONUP:
+ case Common::EVENT_KEYDOWN:
+ case Common::EVENT_QUIT:
+ TroModeExternEvent();
+ break;
+ default:
+ break;
+ }
}
displayEventLoop();
@@ -478,103 +494,14 @@ void ClearMessageQueue(void) {
// ------------------------------------------------------------------------
// clears any queued input (mouse AND keyboard)
-
void resetInputDevices(void) {
int key, qual;
ClearMessageQueue();
- while (ReadKeyboard(key, qual)) ;
- PollMouse();
- Forbid(); // shut of tasking while we check the queue
- while (queueOut != queueIn)
- queueOut = BUMP(queueOut);
- Permit(); // turn on tasking again
-}
-
-//-----------------------------------------------------------------------
-void updateMouse(void) {
- Point16 moveto = Point16(-1, -1);
-
- PollMouse();
-
- // Empty the mouse queue of mouse events, and feed them
- // to the panel system.
- Forbid(); // shut of tasking while we check the queue
- while (queueOut != queueIn) {
- int16 queueIndex = queueOut;
-
- queueOut = BUMP(queueOut);
- Permit(); // turn on tasking while handling message
- moveto = mouseQueue[ queueIndex ].st.pos;
- G_BASE.handleMouse(mouseQueue[ queueIndex ].st, mouseQueue[ queueIndex ].time);
- Forbid(); // turn off tasking again
- }
- Permit(); // turn on tasking again
- //if ( moveto.x>-1 )
- // pointer.move( moveto );
-}
-
-
-//-----------------------------------------------------------------------
-// Function to poll the mouse pointer when engine is busy, so that
-// we can properly detect a double-click.
-
-void PollMouse(void) {
- mousePoll();
+ Common::Event event;
+ while (g_vm->getEventManager()->pollEvent(event));
}
-void AddMouseEvent(const gMouseState &mouseState) {
- // Read the current mouse position.
- if (memcmp(&mouseState, &prevState, sizeof mouseState) == 0)
- return;
-
- if (displayEnabled())
- pointer.move(mouseState.pos);
- //else
- // TroModeExternEvent();
-
- // only add a new entry into the queue if the mouse buttons
- // changed state.
-
- Forbid(); // Turn off tasking while adding event
- if (BUMP(queueIn) != queueOut) {
- prevState = mouseState;
- mouseQueue[ queueIn ].st = mouseState;
- mouseQueue[ queueIn ].time = ReadTimer();
- queueIn = BUMP(queueIn);
- }
- Permit(); // Re-enable tasking
-}
-
-// ------------------------------------------------------------------------
-// keystroke code
-
-void SystemKeyHandler(short, short) {
- TroModeExternEvent();
-}
-
-// ------------------------------------------------------------------------
-// abbreviated mouse handler
-
-
-void SystemMouseHandler(void) {
- PollMouse();
-
- // Empty the mouse queue of mouse events, and feed them
- // to the panel system.
- Forbid(); // shut of tasking while we check the queue
- while (queueOut != queueIn) {
- int16 queueIndex = queueOut;
-
- queueOut = BUMP(queueOut);
- gMouseState &gms = mouseQueue[ queueIndex ].st;
- if (gms.left || gms.right)
- TroModeExternEvent();
- }
- Permit(); // turn on tasking again
-}
-
-
/********************************************************************/
/* */
/* RESOURCE MANAGEMENT CODE */
diff --git a/engines/saga2/mainmap.h b/engines/saga2/mainmap.h
index 06513a35c3..470789c569 100644
--- a/engines/saga2/mainmap.h
+++ b/engines/saga2/mainmap.h
@@ -99,13 +99,6 @@ void initBreakHandler(void);
void cleanupBreakHandler(void);
void breakEventLoop(void);
-/* ===================================================================== *
- other prototypes
- * ===================================================================== */
-
-void AddKeyEvent(int16 keyVal);
-void AddMouseEvent(const gMouseState &mouseState);
-
} // end of namespace Saga2
#endif
diff --git a/engines/saga2/panel.cpp b/engines/saga2/panel.cpp
index e93f57adf4..65c90b4371 100644
--- a/engines/saga2/panel.cpp
+++ b/engines/saga2/panel.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#include "common/events.h"
+
#include "saga2/std.h"
#include "saga2/panel.h"
#include "saga2/fontlib.h"
@@ -726,7 +728,7 @@ void gToolBase::setActive(gPanel *ctl) {
if (ctl == NULL || ctl->activate(gEventNone)) activePanel = ctl;
}
-void gToolBase::handleMouse(gMouseState &ms, int32 time) {
+void gToolBase::handleMouse(Common::Event &event, uint32 time) {
gWindow *w = activeWindow;
gPanel *ctl,
*pickPanel = NULL;
@@ -734,53 +736,78 @@ void gToolBase::handleMouse(gMouseState &ms, int32 time) {
static int32 lastClickTime = 0x8000;
static Point16 lastClickPos;
+
+ // Emulate mouse state for now
+ switch (event.type) {
+ case Common::EVENT_LBUTTONDOWN:
+ _curMouseState.left = true;
+ break;
+ case Common::EVENT_RBUTTONDOWN:
+ _curMouseState.right = true;
+ break;
+ case Common::EVENT_LBUTTONUP:
+ _curMouseState.left = false;
+ break;
+ case Common::EVENT_RBUTTONUP:
+ _curMouseState.right = false;
+ break;
+ case Common::EVENT_MOUSEMOVE:
+ _curMouseState.pos.x = event.mouse.x;
+ _curMouseState.pos.y = event.mouse.y;
+ break;
+ default:
+ break;
+ }
+
// Do nothing if UI locked.
- if (lockUINest > 0) return;
+ if (lockUINest > 0)
+ return;
#if CURSOR_CYCLING
- if (ms.right) {
+ if (_curMouseState.right) {
cycleCursor();
return;
}
#endif
// Code for "Tool tip delay"
- if (prevState.pos != ms.pos
- && prevState.left != ms.left
- && prevState.right != ms.right) {
+ if (prevState.pos != _curMouseState.pos
+ && prevState.left != _curMouseState.left
+ && prevState.right != _curMouseState.right) {
lastMouseMoveTime = msg.timeStamp;
- if (mouseHintSet) setMouseTextF(NULL);
+ if (mouseHintSet)
+ setMouseTextF(NULL);
}
// If there is no active window, then do nothing.
if (w == NULL) {
- prevState = ms;
+ prevState = _curMouseState;
return;
}
// Set up the pick position relative to the window
if (activePanel) {
- pickPos.x = ms.pos.x - activePanel->window.extent.x;
- pickPos.y = ms.pos.y - activePanel->window.extent.y;
+ pickPos.x = _curMouseState.pos.x - activePanel->window.extent.x;
+ pickPos.y = _curMouseState.pos.y - activePanel->window.extent.y;
} else {
- pickPos.x = ms.pos.x - w->extent.x;
- pickPos.y = ms.pos.y - w->extent.y;
+ pickPos.x = _curMouseState.pos.x - w->extent.x;
+ pickPos.y = _curMouseState.pos.y - w->extent.y;
}
// Fill in the message to be sent to the various panels
msg.pickAbsPos = pickPos;
- msg.leftButton = ms.left ? 1 : 0;
- msg.rightButton = ms.right ? 1 : 0;
+ msg.leftButton = _curMouseState.left ? 1 : 0;
+ msg.rightButton = _curMouseState.right ? 1 : 0;
msg.pointerEnter = 0;
msg.pointerLeave = 0;
msg.doubleClick = 0;
msg.timeStamp = time;
- if (((ms.left && !leftDrag) // if left button hit
- || (ms.right && !rightDrag)) // or right button hit
+ if (((_curMouseState.left && !leftDrag) // if left button hit
+ || (_curMouseState.right && !rightDrag)) // or right button hit
&& activePanel != NULL) { // and a panel is active
// Then we have a button hit event. If the button hit
// is occuring outside the panel, then it should be
@@ -790,7 +817,7 @@ void gToolBase::handleMouse(gMouseState &ms, int32 time) {
activePanel->deactivate();
}
- if (prevState.pos == ms.pos) ; // don't do anything if same pos
+ if (prevState.pos == _curMouseState.pos) ; // don't do anything if same pos
else if (activePanel) { // if control active
mousePanel = activePanel; // assume mouse over active panel
@@ -809,11 +836,11 @@ void gToolBase::handleMouse(gMouseState &ms, int32 time) {
for (w = (gWindow *)windowList.first();
w;
w = (gWindow *)w->next()) {
- if (w->extent.ptInside(ms.pos) || w->isModal()) {
+ if (w->extent.ptInside(_curMouseState.pos) || w->isModal()) {
// Set up the pick position relative to the window
- pickPos.x = ms.pos.x - w->extent.x;
- pickPos.y = ms.pos.y - w->extent.y;
+ pickPos.x = _curMouseState.pos.x - w->extent.x;
+ pickPos.y = _curMouseState.pos.y - w->extent.y;
if ((ctl = w->hitTest(pickPos)) != NULL)
pickPanel = ctl;
@@ -825,7 +852,7 @@ void gToolBase::handleMouse(gMouseState &ms, int32 time) {
}
if (w == NULL) {
- prevState = ms;
+ prevState = _curMouseState;
return;
}
@@ -837,13 +864,13 @@ void gToolBase::handleMouse(gMouseState &ms, int32 time) {
if (&mousePanel->window != w) {
// Temporarily adjust pickPos to be relative to the old panel's window
// instead of the new panel's window.
- pickPos.x = ms.pos.x - mousePanel->window.extent.x;
- pickPos.y = ms.pos.y - mousePanel->window.extent.y;
+ pickPos.x = _curMouseState.pos.x - mousePanel->window.extent.x;
+ pickPos.y = _curMouseState.pos.y - mousePanel->window.extent.y;
setMsgQ(msg, mousePanel); // set up gPanelMessage
- pickPos.x = ms.pos.x - w->extent.x;
- pickPos.y = ms.pos.y - w->extent.y;
+ pickPos.x = _curMouseState.pos.x - w->extent.x;
+ pickPos.y = _curMouseState.pos.y - w->extent.y;
} else {
setMsgQ(msg, mousePanel); // set up gPanelMessage
}
@@ -864,14 +891,15 @@ void gToolBase::handleMouse(gMouseState &ms, int32 time) {
setMsg(msg, pickPanel); // set up gPanelMessage
// msg.pickPos.x = pickPos.x - pickPanel->extent.x;
// msg.pickPos.y = pickPos.y - pickPanel->extent.y;
- msg.leftButton = ms.left ? 1 : 0;
+ msg.leftButton = _curMouseState.left ? 1 : 0;
// msg.inPanel = pickPanel->extent.ptInside(pickPos);
msg.pointerEnter = (mousePanel == pickPanel) ? 0 : 1;
msg.pointerLeave = 0;
mousePanel = pickPanel;
mousePanel->pointerMove(msg);
- } else mousePanel = NULL;
+ } else
+ mousePanel = NULL;
}
// Fix up flags because earlier code may have changed them
@@ -881,8 +909,8 @@ void gToolBase::handleMouse(gMouseState &ms, int32 time) {
// Send appropriate button-press messages to the panels
- if (prevState.left != ms.left // if buttons changed state
- || prevState.right != ms.right) {
+ if (prevState.left != _curMouseState.left // if buttons changed state
+ || prevState.right != _curMouseState.right) {
// If both buttons were previously up, then a mouse
// hit must have occured.
@@ -896,9 +924,9 @@ void gToolBase::handleMouse(gMouseState &ms, int32 time) {
if (((uint32)(msg.timeStamp - lastClickTime)
< (ticksPerSecond * 2 / 3))
- || ms.left > 1
- || ms.right > 1) {
- Point16 diff = lastClickPos - ms.pos;
+ || _curMouseState.left > 1
+ || _curMouseState.right > 1) {
+ Point16 diff = lastClickPos - _curMouseState.pos;
if (abs(diff.x) + abs(diff.y) < 6)
msg.doubleClick = 1;
@@ -908,7 +936,7 @@ void gToolBase::handleMouse(gMouseState &ms, int32 time) {
// future double-click checks.
lastClickTime = msg.timeStamp;
- lastClickPos = ms.pos;
+ lastClickPos = _curMouseState.pos;
if (mousePanel) { // if over a control
setMsgQ(msg, mousePanel); // set up gPanelMessage
@@ -930,12 +958,14 @@ void gToolBase::handleMouse(gMouseState &ms, int32 time) {
// send it a hit message
if (mousePanel->pointerHit(msg)) {
activePanel = mousePanel;
- if (ms.left) leftDrag = TRUE;
- else rightDrag = TRUE;
+ if (_curMouseState.left)
+ leftDrag = TRUE;
+ else
+ rightDrag = TRUE;
}
}
- } else if ((leftDrag && ms.left == FALSE) // check for release
- || (rightDrag && ms.right == FALSE)) {
+ } else if ((leftDrag && _curMouseState.left == FALSE) // check for release
+ || (rightDrag && _curMouseState.right == FALSE)) {
if (activePanel && mousePanel) { // if a control is active
setMsg(msg, mousePanel); // send it a release message
mousePanel->pointerRelease(msg);
@@ -944,7 +974,7 @@ void gToolBase::handleMouse(gMouseState &ms, int32 time) {
}
}
- prevState = ms;
+ prevState = _curMouseState;
}
void gToolBase::leavePanel(void) {
@@ -962,22 +992,33 @@ void gToolBase::leavePanel(void) {
if (activePanel) activePanel->deactivate();
}
-void gToolBase::handleKeyStroke(uint16 key, uint16 qual) {
+void gToolBase::handleKeyStroke(Common::Event &event) {
gWindow *w = activeWindow;
gControl *ctl;
+ uint16 key = event.kbd.ascii; // FIXME
+ uint16 qualifier = 0;
+
+ if (event.kbd.flags & Common::KBD_SHIFT)
+ qualifier |= qualifierShift;
+
+ if (event.kbd.flags & Common::KBD_CTRL)
+ qualifier |= qualifierControl;
+
+ if (event.kbd.flags & Common::KBD_ALT)
+ qualifier |= qualifierAlt;
+
msg.pickAbsPos = pickPos;
-// msg.leftButton = ms.left ? 1 : 0;
-// msg.rightButton = ms.right ? 1 : 0;
msg.pointerEnter = 0;
msg.pointerLeave = 0;
msg.key = ((key & 0xFF) != 0) ? key & 0xff : (key >> 8) + 0x80;
- msg.qualifier = qual;
+ msg.qualifier = qualifier;
msg.timeStamp = ReadTimer();
if (activePanel) { // send keystroke to active panel
setMsg(msg, activePanel); // set up gPanelMessage
- if (activePanel->keyStroke(msg)) return;
+ if (activePanel->keyStroke(msg))
+ return;
}
// Now, search the contents of the window for a control with
@@ -1006,8 +1047,9 @@ void gToolBase::handleKeyStroke(uint16 key, uint16 qual) {
// else send the message to the app.
- if (key & 0xff) key &= 0xff;
- w->notify(gEventKeyDown, (qual << 16) | key);
+ if (key & 0xff)
+ key &= 0xff;
+ w->notify(gEventKeyDown, (qualifier << 16) | key);
}
}
@@ -1040,34 +1082,6 @@ void HandleTimerTick(long tick) {
}
}
-/*
-void EventLoop( bool &running )
-{
- static gMouseState mouseState;
- extern void ApplicationTask( void );
-
- // Our typical main loop
-
- while( running )
- {
- int key, qual;
-
- // Poll user input
-
- ReadMouse( mouseState );
- pointer.move( mouseState.pos );
- G_BASE.handleMouse( mouseState );
- HandleTimerTick( ReadTimer() );
- if (ReadKeyboard( key, qual ))
- G_BASE.handleKeyStroke( key, qual );
-
-// if (mouseState.right) running = FALSE;
-
- ApplicationTask();
- }
-}
-*/
-
/* ===================================================================== *
Code to initialize the panel system
* ===================================================================== */
diff --git a/engines/saga2/panel.h b/engines/saga2/panel.h
index 9543f6bd5d..f777a35a9e 100644
--- a/engines/saga2/panel.h
+++ b/engines/saga2/panel.h
@@ -31,6 +31,10 @@
#include "saga2/input.h"
#include "saga2/vdraw.h"
+namespace Common {
+struct Event;
+}
+
namespace Saga2 {
// Fix problem with DOS's encroachment on name space that should
// rightfully belong to the application programmer.
@@ -473,6 +477,9 @@ class gToolBase {
gPanelMessage msg; // message that we send out
int32 lastMouseMoveTime; // time of last mouse move
+
+ gMouseState _curMouseState;
+
public:
bool mouseHintSet; // true if mouse hint is up.
@@ -499,8 +506,8 @@ public:
void setActive(gPanel *newActive);
void leavePanel(void); // we're changing windows
public:
- void handleMouse(gMouseState &ms, int32 time);
- void handleKeyStroke(uint16 key, uint16 qual);
+ void handleMouse(Common::Event &event, uint32 time);
+ void handleKeyStroke(Common::Event &event);
void handleTimerTick(int32 tick);
gWindow *topWindow(void) {
return (gWindow *)windowList.first();
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 20a5f2d983..513c564761 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -2569,7 +2569,8 @@ inline void drawMetaRow(TilePoint coords, Point16 pos) {
int16 layerLimit;
// Poll the mouse so that we can detect double-clicks
- PollMouse();
+ //PollMouse();
+ warning("STUB: Check if we need to poll mouse here");
for (;
diff --git a/engines/saga2/tromode.cpp b/engines/saga2/tromode.cpp
index 40f25fd7c3..aeafe349af 100644
--- a/engines/saga2/tromode.cpp
+++ b/engines/saga2/tromode.cpp
@@ -66,7 +66,6 @@ int16 OptionsDialog(bool disableSaveResume = FALSE);
void SystemEventLoop(void);
void ClearMessageQueue(void);
void freeAllTileBanks(void);
-void PollMouse(void);
void resetInputDevices(void);
void blackOut(void);
void quickSavePalette(void);
Commit: 6c9e092973fbd9c55b55ccacfc598d823c9ace55
https://github.com/scummvm/scummvm/commit/6c9e092973fbd9c55b55ccacfc598d823c9ace55
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:59+02:00
Commit Message:
SAGA2: Implement breakEventLoop()
Changed paths:
engines/saga2/main.cpp
engines/saga2/mainmap.cpp
engines/saga2/mainmap.h
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 9861e3f7ff..4014d853c7 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -312,8 +312,6 @@ void processEventLoop(bool updateScreen) {
debugC(1, kDebugEventLoop, "EventLoop: starting event loop");
irate.updateFrameCount();
- debugC(1, kDebugEventLoop, "EventLoop: checking user abort");
- breakEventLoop();
if (checkExit && verifyUserExit()) {
//gameRunning=false;
endGame();
@@ -349,7 +347,8 @@ void processEventLoop(bool updateScreen) {
G_BASE.handleKeyStroke(event);
break;
case Common::EVENT_QUIT:
- gameRunning = false;
+ if (verifyUserExit())
+ endGame();
break;
default:
break;
@@ -417,8 +416,6 @@ void displayUpdate(void) {
void SystemEventLoop(void) {
int key, qual;
- //make sure the user hasn't quit on us
- breakEventLoop();
if (
#ifdef DO_OUTRO_IN_CLEANUP
whichOutro == -1 &&
@@ -1039,21 +1036,4 @@ RHANDLE mustAllocHandle(uint32 size, const char desc[]) {
return ptr;
}
-
-/********************************************************************/
-/* */
-/* HOOK FOR CTRL-BREAK HANDLER */
-/* */
-/********************************************************************/
-
-extern "C" {
-
- void breakEventKludge(void) {
- if (verifyUserExit())
- endGame();
- //gameRunning=false;
- }
-
-}
-
} // end of namespace Saga2
diff --git a/engines/saga2/mainmap.cpp b/engines/saga2/mainmap.cpp
index c47073b22e..44e25bc5c7 100644
--- a/engines/saga2/mainmap.cpp
+++ b/engines/saga2/mainmap.cpp
@@ -97,8 +97,4 @@ void cleanupBreakHandler() {
warning("STUB: cleanupBreakHandler()");
}
-void breakEventLoop() {
- warning("STUB: breakEventLoop()");
-}
-
} // end of namespace Saga2
diff --git a/engines/saga2/mainmap.h b/engines/saga2/mainmap.h
index 470789c569..7213ca794f 100644
--- a/engines/saga2/mainmap.h
+++ b/engines/saga2/mainmap.h
@@ -97,7 +97,6 @@ void cleanupPalettes(void);
void initBreakHandler(void);
void cleanupBreakHandler(void);
-void breakEventLoop(void);
} // end of namespace Saga2
Commit: 982f6f87252a415a9e3ebfb64862daece8010cc2
https://github.com/scummvm/scummvm/commit/982f6f87252a415a9e3ebfb64862daece8010cc2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:59+02:00
Commit Message:
SAGA2: Cleanup event-related stubs
Changed paths:
engines/saga2/main.cpp
engines/saga2/mainmap.cpp
engines/saga2/mainmap.h
engines/saga2/tromode.cpp
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 4014d853c7..5e00727bbf 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -174,10 +174,6 @@ APPFUNC(cmdWindowFunc); // main window event handler
void EventLoop(bool &running, bool modal); // handles input and distributes
void SystemEventLoop(void);
-void ClearMessageQueue(void);
-void waitForVideoFile(char *fileName);
-
-void memtest(void);
void runPathFinder(void);
bool setupGame(void);
@@ -318,10 +314,6 @@ void processEventLoop(bool updateScreen) {
return;
}
- debugC(1, kDebugEventLoop, "EventLoop: handle win messages");
- if (handlingMessages())
- return;
-
debugC(1, kDebugEventLoop, "EventLoop: check for game suspend");
if (gameSuspended())
return;
@@ -388,8 +380,8 @@ void displayUpdate(void) {
debugC(1, kDebugEventLoop, "EventLoop: Interface indicator updates");
updateIndicators();
- debugC(1, kDebugEventLoop, "EventLoop: OS specific display routines");
- displayEventLoop();
+ g_system->updateScreen();
+
if (delayReDraw)
reDrawScreen();
// Call asynchronous resource loader
@@ -423,10 +415,6 @@ void SystemEventLoop(void) {
!gameRunning)
TroModeExternEvent();
- // check for messages
- if (handlingMessages())
- return;
-
Common::Event event;
while (g_vm->getEventManager()->pollEvent(event)) {
switch (event.type) {
@@ -441,7 +429,7 @@ void SystemEventLoop(void) {
}
}
- displayEventLoop();
+ g_system->updateScreen();
}
/********************************************************************/
@@ -485,16 +473,9 @@ inline int BUMP(int x) {
return (x + 1) & 63;
}
-void ClearMessageQueue(void) {
- while (handlingMessages());
-}
-
// ------------------------------------------------------------------------
// clears any queued input (mouse AND keyboard)
void resetInputDevices(void) {
- int key, qual;
- ClearMessageQueue();
-
Common::Event event;
while (g_vm->getEventManager()->pollEvent(event));
}
diff --git a/engines/saga2/mainmap.cpp b/engines/saga2/mainmap.cpp
index 44e25bc5c7..54f9d6c0da 100644
--- a/engines/saga2/mainmap.cpp
+++ b/engines/saga2/mainmap.cpp
@@ -76,19 +76,6 @@ void cleanupPaletteData() {
warning("STUB: cleanupPaletteData()");
}
-void mousePoll() {
- warning("STUB: mousePoll()");
-}
-
-bool handlingMessages() {
- warning("STUB: handlingMessages()");
- return false;
-}
-
-void displayEventLoop() {
- warning("STUB: displayEventLoop()");
-}
-
void initBreakHandler() {
warning("STUB: initBreakHandler()");
}
diff --git a/engines/saga2/mainmap.h b/engines/saga2/mainmap.h
index 7213ca794f..5cfcdf13d4 100644
--- a/engines/saga2/mainmap.h
+++ b/engines/saga2/mainmap.h
@@ -85,11 +85,6 @@ void cleanupSystemTimer(void);
void cleanupSystemTasks(void);
void cleanupPaletteData(void);
-// message handling
-void mousePoll(void);
-bool handlingMessages(void);
-void displayEventLoop(void);
-
// major parts of main that are actually in main.cpp
void cleanupGame(void); // auto-cleanup function
bool setupGame(void);
diff --git a/engines/saga2/tromode.cpp b/engines/saga2/tromode.cpp
index aeafe349af..34c42795e5 100644
--- a/engines/saga2/tromode.cpp
+++ b/engines/saga2/tromode.cpp
@@ -64,7 +64,6 @@ extern int16 queueIn,
int16 OptionsDialog(bool disableSaveResume = FALSE);
void SystemEventLoop(void);
-void ClearMessageQueue(void);
void freeAllTileBanks(void);
void resetInputDevices(void);
void blackOut(void);
@@ -179,7 +178,6 @@ static void TroModeSetup(void) {
blackOut();
displayDisable(PlayingVideo);
pushVidState();
- ClearMessageQueue();
resetInputDevices();
abortFlag = FALSE;
}
Commit: 1c41a3098a5868f0951dc7b3e027e925de21f8d1
https://github.com/scummvm/scummvm/commit/1c41a3098a5868f0951dc7b3e027e925de21f8d1
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:36:59+02:00
Commit Message:
SAGA2: Fix MetaTile loading
Changed paths:
engines/saga2/tile.cpp
engines/saga2/tile.h
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 513c564761..193e0d4933 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -1411,8 +1411,20 @@ void cleanupTileTasks(void) {
//-----------------------------------------------------------------------
// Initialize map data
+static void readMetaTile(hResContext *con, MetaTile &til) {
+ til.highestPixel = con->readU16LE();
+ til.banksNeeded.b[0] = con->readU32LE();
+ til.banksNeeded.b[1] = con->readU32LE();
+
+ for (int i = 0; i < maxPlatforms; ++i)
+ til.stack[i] = con->readU16LE();
+
+ til.properties = con->readU32LE();
+}
+
void initMaps(void) {
int16 i;
+ const int metaTileSize = 30;
// Load all of the tile terrain banks
for (i = 0; i < maxBanks; i++) {
@@ -1449,10 +1461,11 @@ void initMaps(void) {
error("Unable to load map");
debugC(3, kDebugTiles, "map: size = %d, mapData = %p", mapData->map->size, (void*)mapData->map->mapData);
- // Load the meta tile list
- mapData->metaList = (MetaTilePtr)LoadResource(tileRes,
- metaID + MKTAG(0, 0, 0, (uint8)i),
- "meta tile list");
+ int metaTileCount = tileRes->size(metaID + MKTAG(0, 0, 0, (uint8)i)) / metaTileSize;
+ mapData->metaList = new MetaTile[metaTileCount]();
+ for (int k = 0; k < metaTileCount; ++k)
+ readMetaTile(tileRes, mapData->metaList[k]);
+
if (mapData->metaList == nullptr)
error("Unable to load meta tile list");
@@ -1534,7 +1547,7 @@ void cleanupMaps(void) {
free(mapData->map);
// Dump the meta tile list
- free(mapData->metaList);
+ delete[] mapData->metaList;
// If there is active item data, dump it
if (mapData->activeItemData != nullptr)
@@ -2249,9 +2262,7 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
}
error("Unable to read Platform %d of map %d", plIndex, mapNum);
-#ifdef _WIN32
return nullptr;
-#endif
}
}
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index 68ab5b3466..71254ecd10 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -806,7 +806,7 @@ typedef uint16 metaTileNoise;
struct MetaTile {
uint16 highestPixel; // more drawing optimization
BankBits banksNeeded; // which banks are needed
- uint16 stack[ maxPlatforms ]; // pointer to platforms
+ uint16 stack[maxPlatforms]; // pointer to platforms
uint32 properties; // more drawing optimization
// Return a pointer to a meta tile given its ID
Commit: 6f21e5f7cce7ed7021e8779ffaa4cb5f36726d3d
https://github.com/scummvm/scummvm/commit/6f21e5f7cce7ed7021e8779ffaa4cb5f36726d3d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:59+02:00
Commit Message:
SAGA2: Implement palette setting
Changed paths:
engines/saga2/blitters.cpp
engines/saga2/palette.h
engines/saga2/vpal.cpp
diff --git a/engines/saga2/blitters.cpp b/engines/saga2/blitters.cpp
index 76b3af5c79..79ef5f3c33 100644
--- a/engines/saga2/blitters.cpp
+++ b/engines/saga2/blitters.cpp
@@ -315,10 +315,6 @@ void compositePixelsRvs(gPixelMap *compMap, gPixelMap *sprMap, int32 xpos, int32
warning("STUB: compositePixelsRvs()");
}
-void _LoadPalette(uint8 *rgbArray, uint32 startColor, uint32 numColors) {
- warning("STUB: _LoadPalette()");
-}
-
bool initGraphics(void) {
warning("STUB: initGraphics()");
return false;
diff --git a/engines/saga2/palette.h b/engines/saga2/palette.h
index bfd4356c7d..8ca858e19a 100644
--- a/engines/saga2/palette.h
+++ b/engines/saga2/palette.h
@@ -83,11 +83,6 @@ void loadPaletteState(SaveFileReader &saveGame);
// Cleanup the palette
inline void cleanupPaletteState(void) { /* do nothing */ }
-// Assembly-language function to copy pixel to SVGA
-
-extern void _LoadPalette(uint8 *rgbArray,
- uint32 startColor,
- uint32 numColors);
void dialogSavePalette(void);
void dialogRestorePalette(void);
diff --git a/engines/saga2/vpal.cpp b/engines/saga2/vpal.cpp
index 84fffed28f..c0e0d1e4ed 100644
--- a/engines/saga2/vpal.cpp
+++ b/engines/saga2/vpal.cpp
@@ -26,6 +26,8 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+#include "graphics/palette.h"
+
#include "saga2/std.h"
#include "saga2/fta.h"
#include "saga2/vpal.h"
@@ -91,7 +93,7 @@ static PaletteStateArchive archive; // Used for loading and saving
void assertCurrentPalette(void) {
if (paletteChangesEnabled())
- _LoadPalette((uint8 *)¤tPalette, 0, 256);
+ g_system->getPaletteManager()->setPalette((uint8 *)¤tPalette, 0, 256);
}
Commit: 6edd3ae7b500a6d9108827565b22ffa49bbfc4f3
https://github.com/scummvm/scummvm/commit/6edd3ae7b500a6d9108827565b22ffa49bbfc4f3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:36:59+02:00
Commit Message:
SAGA2: Fix warnings
Changed paths:
engines/saga2/intrface.h
engines/saga2/palette.h
engines/saga2/uidialog.cpp
engines/saga2/uidialog.h
engines/saga2/vpal.cpp
diff --git a/engines/saga2/intrface.h b/engines/saga2/intrface.h
index ad6299fa3b..de61c92847 100644
--- a/engines/saga2/intrface.h
+++ b/engines/saga2/intrface.h
@@ -265,7 +265,7 @@ enum PortraitType {
sick,
wounded,
asleep,
- dead,
+ dead
};
class CPortrait {
diff --git a/engines/saga2/palette.h b/engines/saga2/palette.h
index 8ca858e19a..327ae20493 100644
--- a/engines/saga2/palette.h
+++ b/engines/saga2/palette.h
@@ -83,9 +83,6 @@ void loadPaletteState(SaveFileReader &saveGame);
// Cleanup the palette
inline void cleanupPaletteState(void) { /* do nothing */ }
-void dialogSavePalette(void);
-void dialogRestorePalette(void);
-
} // end of namespace Saga2
#endif
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index 39624d18f4..2b5c0201cd 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -1098,8 +1098,6 @@ int16 userDialog(const char *title, const char *msg, const char *bMsg1,
udrInfo.result = -1;
udrInfo.running = TRUE;
- dialogSavePalette();
-
gCompButton *t;
// button one
@@ -1144,7 +1142,6 @@ int16 userDialog(const char *title, const char *msg, const char *bMsg1,
mainWindow->invalidate(messageWindowRect);
// return the result code
- dialogRestorePalette();
return (udrInfo.result % 10);
}
@@ -1205,9 +1202,8 @@ int16 userDialog(const char *title, const char *msg, const char *bMsg1,
rInfo.result = -1;
rInfo.running = TRUE;
- if (!fullInitialized) return -1;
-
- dialogSavePalette();
+ if (!fullInitialized)
+ return -1;
// init the resource context handle
decRes = resFile->newContext(dialogGroupID, "dialog resources");
@@ -1278,7 +1274,6 @@ int16 userDialog(const char *title, const char *msg, const char *bMsg1,
mainWindow->invalidate(messageWindowRect);
// return the result code
- dialogRestorePalette();
return rInfo.result % 10;
}
diff --git a/engines/saga2/uidialog.h b/engines/saga2/uidialog.h
index 81b5095e70..96406b84b0 100644
--- a/engines/saga2/uidialog.h
+++ b/engines/saga2/uidialog.h
@@ -29,7 +29,7 @@
namespace Saga2 {
-class SaveFileHeader;
+struct SaveFileHeader;
// constants
const uint32 dialogGroupID = MKTAG('D', 'I', 'A', 'L');
diff --git a/engines/saga2/vpal.cpp b/engines/saga2/vpal.cpp
index c0e0d1e4ed..809022bac9 100644
--- a/engines/saga2/vpal.cpp
+++ b/engines/saga2/vpal.cpp
@@ -78,8 +78,7 @@ static gPalette currentPalette; // Currently loaded palette
// Fade up/down data
static gPalette oldPalette, // Palette at start of fade
destPalette, // Destination palette of fade
- quickPalette,
- dialogPalette; // Temporary mem for quick save/restore
+ quickPalette;
static int32 startTime, // Time index of start of fade
totalTime; // Total fade duration
@@ -234,11 +233,11 @@ void createPalette(
gPalettePtr srcP,
gPalettePtr dstP,
int32 elapsedTime,
- int32 totalTime) {
- assert(totalTime != 0);
+ int32 totalTime_) {
+ assert(totalTime_ != 0);
int i;
- uint32 fadeProgress = (elapsedTime << 8) / totalTime;
+ uint32 fadeProgress = (elapsedTime << 8) / totalTime_;
for (i = 0; i < elementsof(newP->entry); i++) {
gPaletteEntry *srcPal = &srcP->entry[i];
@@ -315,18 +314,6 @@ void quickRestorePalette(void) {
}
-//----------------------------------------------------------------------
-// routines to suspend & restore a palette state (during videos)
-
-static int dpalSaves = 0;
-
-void dialogSavePalette(void) {
-}
-
-void dialogRestorePalette(void) {
-}
-
-
//----------------------------------------------------------------------
// Save the current state of the current palette and fade up/down in
// a save file.
Commit: e916e99d5f0b3ae94fb415fdd606595f8012a373
https://github.com/scummvm/scummvm/commit/e916e99d5f0b3ae94fb415fdd606595f8012a373
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:00+02:00
Commit Message:
SAGA2: Fix warnings
Changed paths:
engines/saga2/button.h
engines/saga2/dispnode.cpp
engines/saga2/effects.cpp
engines/saga2/intrface.cpp
engines/saga2/intrface.h
diff --git a/engines/saga2/button.h b/engines/saga2/button.h
index cbf74ec939..0aca0dbb67 100644
--- a/engines/saga2/button.h
+++ b/engines/saga2/button.h
@@ -35,7 +35,7 @@
namespace Saga2 {
-class Sprite;
+struct Sprite;
class hResContext;
/* ======================================================================= *
diff --git a/engines/saga2/dispnode.cpp b/engines/saga2/dispnode.cpp
index 2703231e8a..899a6eab41 100644
--- a/engines/saga2/dispnode.cpp
+++ b/engines/saga2/dispnode.cpp
@@ -289,11 +289,11 @@ void DisplayNodeList::buildObjects(bool fromScratch) {
for (i = 0; i < sortCount; i++) {
DisplayNode *dn = &displayList[ i ];
- GameObject *obj = sortList[ i ];
+ GameObject *ob = sortList[ i ];
DisplayNode **search;
- TilePoint oLoc = obj->getLocation();
+ TilePoint oLoc = ob->getLocation();
dn->nextDisplayed = NULL;
- dn->object = obj;
+ dn->object = ob;
dn->type = nodeTypeObject;
@@ -715,17 +715,17 @@ void DisplayNode::drawObject(void) {
// If we were carrying something in the left hand,
// then fill in the component structure for it.
if (leftIndex >= 0) {
- GameObject *obj;
+ GameObject *ob;
ProtoObj *proto;
- obj = GameObject::objectAddress(a->leftHandObject);
- proto = obj->proto();
+ ob = GameObject::objectAddress(a->leftHandObject);
+ proto = ob->proto();
- obj->getColorTranslation(leftColors);
+ ob->getColorTranslation(leftColors);
sc = &scList[ leftIndex ];
sc->sp = proto->getOrientedSprite(
- obj,
+ ob,
a->poseInfo.leftObjectIndex);
assert(sc->sp != NULL);
sc->offset = a->poseInfo.leftObjectOffset;
@@ -740,17 +740,17 @@ void DisplayNode::drawObject(void) {
// If we were carrying something in the right hand,
// then fill in the component structure for it.
if (rightIndex >= 0) {
- GameObject *obj;
+ GameObject *ob;
ProtoObj *proto;
- obj = GameObject::objectAddress(a->rightHandObject);
- proto = obj->proto();
+ ob = GameObject::objectAddress(a->rightHandObject);
+ proto = ob->proto();
- obj->getColorTranslation(rightColors);
+ ob->getColorTranslation(rightColors);
sc = &scList[ rightIndex ];
sc->sp = proto->getOrientedSprite(
- obj,
+ ob,
a->poseInfo.rightObjectIndex);
assert(sc->sp != NULL);
assert(sc->sp->size.x > 0);
diff --git a/engines/saga2/effects.cpp b/engines/saga2/effects.cpp
index 78a1c7596d..eb3febea3d 100644
--- a/engines/saga2/effects.cpp
+++ b/engines/saga2/effects.cpp
@@ -134,24 +134,28 @@ void ProtoDrainage::drainLevel(GameObject *cst, Actor *a, effectDrainsTypes edt,
case drainsManaYellow:
case drainsManaGreen:
case drainsManaBlue:
- case drainsManaViolet: {
- ActorManaID aType = (ActorManaID)(edt + (manaIDRed - drainsManaRed));
- (&a->effectiveStats.redMana)[aType] =
- clamp(
- 0,
- (&a->effectiveStats.redMana)[aType] - amt,
- (&(a->getBaseStats())->redMana)[aType]);
- }
- break;
- case drainsLifeLevel: {
- int16 &maxVit = (a->getBaseStats())->vitality;
- maxVit = clamp(0, maxVit - amt, absoluteMaximumVitality);
- a->acceptDamage(cst->thisID(), amt > 0 ? 1 : -1, damageOther);
- }
- break;
+ case drainsManaViolet:
+ {
+ ActorManaID aType = (ActorManaID)(edt + (manaIDRed - drainsManaRed));
+ (&a->effectiveStats.redMana)[aType] =
+ clamp(
+ 0,
+ (&a->effectiveStats.redMana)[aType] - amt,
+ (&(a->getBaseStats())->redMana)[aType]);
+ }
+ break;
+ case drainsLifeLevel:
+ {
+ int16 &maxVit = (a->getBaseStats())->vitality;
+ maxVit = clamp(0, maxVit - amt, absoluteMaximumVitality);
+ a->acceptDamage(cst->thisID(), amt > 0 ? 1 : -1, damageOther);
+ }
+ break;
case drainsVitality:
a->acceptDamage(cst->thisID(), amt, damageOther);
break;
+ default:
+ break;
}
updateIndicators();
}
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index bcb8da7a22..4b7b963d00 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -134,7 +134,7 @@ enum enchantmentIcons {
iconCount
};
-char *enchantmentNames[] = {
+const char *enchantmentNames[] = {
"Invisible",
"Detect Poison",
"Soul Sight",
@@ -3108,7 +3108,7 @@ bool isBrotherDead(PlayerActorID brotherID) {
return (getPlayerActorAddress(brotherID)->getActor()->isDead());
}
-void StatusMsg(char *msg, ...) { // frametime def
+void StatusMsg(const char *msg, ...) { // frametime def
va_list argptr;
char buffer[128];
diff --git a/engines/saga2/intrface.h b/engines/saga2/intrface.h
index de61c92847..8525e9a074 100644
--- a/engines/saga2/intrface.h
+++ b/engines/saga2/intrface.h
@@ -94,7 +94,7 @@ void loadUIState(SaveFileReader &saveGame);
void cleanupUIState(void);
// Varargs function to write to the status line.
-void StatusMsg(char *msg, ...); // frametime def
+void StatusMsg(const char *msg, ...); // frametime def
const uint32 faceGroupID = MKTAG('F', 'A', 'C', 'E');
Commit: 96bebe4853a50f9ce83b246ac561e4c574bfd1e8
https://github.com/scummvm/scummvm/commit/96bebe4853a50f9ce83b246ac561e4c574bfd1e8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:00+02:00
Commit Message:
SAGA2: Fix warnings
Changed paths:
engines/saga2/terrain.cpp
engines/saga2/tilemode.cpp
diff --git a/engines/saga2/terrain.cpp b/engines/saga2/terrain.cpp
index bcfc1e0118..a32fe8c2d2 100644
--- a/engines/saga2/terrain.cpp
+++ b/engines/saga2/terrain.cpp
@@ -373,7 +373,7 @@ uint32 lineTerrain(
uint16 errorTerm = 0;
- uint16 subTileMask = 0;
+ uint16 subTileMask_ = 0;
int16 tileStartZ,
*minZ,
@@ -446,18 +446,18 @@ uint32 lineTerrain(
terrain |= tileTerrain(
mapNum,
tilePt,
- subTileMask,
+ subTileMask_,
*minZ,
*maxZ + 1);
if (terrain & opaqueTerrain) return terrain;
tilePt.u = curSubTile.u >> tileSubShift;
tileStartZ = curSubTile.z;
- subTileMask = 0;
+ subTileMask_ = 0;
}
- subTileMask |= (uMask[curSubTile.u & subTileMask] &
- vMask[curSubTile.v & subTileMask]);
+ subTileMask_ |= (uMask[curSubTile.u & subTileMask_] &
+ vMask[curSubTile.v & subTileMask_]);
#if DEBUG && VISUAL2
tempPoint.u = curSubTile.u << tileSubShift;
tempPoint.v = curSubTile.v << tileSubShift;
@@ -477,18 +477,18 @@ uint32 lineTerrain(
terrain |= tileTerrain(
mapNum,
tilePt,
- subTileMask,
+ subTileMask_,
*minZ,
*maxZ + 1);
if (terrain & opaqueTerrain) return terrain;
tilePt.v = curSubTile.v >> tileSubShift;
tileStartZ = curSubTile.z;
- subTileMask = 0;
+ subTileMask_ = 0;
}
- subTileMask |= (uMask[curSubTile.u & subTileMask] &
- vMask[curSubTile.v & subTileMask]);
+ subTileMask_ |= (uMask[curSubTile.u & subTileMask_] &
+ vMask[curSubTile.v & subTileMask_]);
#if DEBUG && VISUAL2
tempPoint.u = curSubTile.u << tileSubShift;
tempPoint.v = curSubTile.v << tileSubShift;
@@ -515,18 +515,18 @@ uint32 lineTerrain(
terrain |= tileTerrain(
mapNum,
tilePt,
- subTileMask,
+ subTileMask_,
*minZ,
*maxZ + 1);
if (terrain & opaqueTerrain) return terrain;
tilePt.v = curSubTile.v >> tileSubShift;
tileStartZ = curSubTile.z;
- subTileMask = 0;
+ subTileMask_ = 0;
}
- subTileMask |= (uMask[curSubTile.u & subTileMask] &
- vMask[curSubTile.v & subTileMask]);
+ subTileMask_ |= (uMask[curSubTile.u & subTileMask_] &
+ vMask[curSubTile.v & subTileMask_]);
#if DEBUG && VISUAL2
tempPoint.u = curSubTile.u << tileSubShift;
@@ -547,18 +547,18 @@ uint32 lineTerrain(
terrain |= tileTerrain(
mapNum,
tilePt,
- subTileMask,
+ subTileMask_,
*minZ,
*maxZ + 1);
if (terrain & opaqueTerrain) return terrain;
tilePt.u = curSubTile.u >> tileSubShift;
tileStartZ = curSubTile.z;
- subTileMask = 0;
+ subTileMask_ = 0;
}
- subTileMask |= (uMask[curSubTile.u & subTileMask] &
- vMask[curSubTile.v & subTileMask]);
+ subTileMask_ |= (uMask[curSubTile.u & subTileMask_] &
+ vMask[curSubTile.v & subTileMask_]);
#if DEBUG && VISUAL2
tempPoint.u = curSubTile.u << tileSubShift;
tempPoint.v = curSubTile.v << tileSubShift;
@@ -576,7 +576,7 @@ uint32 lineTerrain(
terrain |= tileTerrain(
mapNum,
tilePt,
- subTileMask,
+ subTileMask_,
*minZ,
*maxZ);
diff --git a/engines/saga2/tilemode.cpp b/engines/saga2/tilemode.cpp
index 406f1351d4..607cefb869 100644
--- a/engines/saga2/tilemode.cpp
+++ b/engines/saga2/tilemode.cpp
@@ -92,8 +92,6 @@ private:
extern int16 speechButtonCount; // count of speech buttons
extern void abortSpeech(void);
-const uint32 tileGroupID = MKTAG('T', 'I', 'L', 'E');
-
extern const uint32 imageGroupID = MKTAG('I', 'M', 'A', 'G');
extern hResContext *tileRes; // tile resource handle
@@ -682,10 +680,6 @@ void TileModeSetup(void) {
//Enable Tile Mode Specific Controls
tileControls->enable(TRUE);
-// tileRes = resFile->newContext( tileGroupID );
-
-// initPalette();
-
initTileBanks();
lastUpdateTime = gameTime;
Commit: 99d0035d61749de8a87b00cd20b57db6131246c5
https://github.com/scummvm/scummvm/commit/99d0035d61749de8a87b00cd20b57db6131246c5
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:00+02:00
Commit Message:
SAGA2: Fix pose/colorscheme loading
Changed paths:
engines/saga2/actor.cpp
engines/saga2/dispnode.cpp
engines/saga2/speech.cpp
engines/saga2/sprite.cpp
engines/saga2/sprite.h
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index fb9e9c53d2..76e27dc843 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -1903,10 +1903,9 @@ void Actor::getColorTranslation(ColorTable map) {
// If actor has color table loaded, then calculate the
// translation table.
if (appearance
- && appearance->schemeList
- && *appearance->schemeList) {
+ && appearance->schemeList) {
buildColorTable(map,
- (*appearance->schemeList)[ colorScheme ].bank,
+ (appearance->schemeList)[ colorScheme ].bank,
11);
} else memcpy(map, identityColors, 256);
}
@@ -1928,7 +1927,7 @@ int16 Actor::setAction(int16 newState, int16 flags) {
if (appearance == NULL) return 0;
// If this animation has no frames, then return FALSE
- anim = (*appearance->poseList)->animation(newState);
+ anim = appearance->poseList->animation(newState);
numPoses = anim->count[ currentFacing ];
if (numPoses <= 0) return 0;
@@ -1961,7 +1960,7 @@ bool Actor::isActionAvailable(int16 newState, bool anyDir) {
if (appearance == NULL) return FALSE;
// If this animation has no frames, then return FALSE
- anim = (*appearance->poseList)->animation(newState);
+ anim = appearance->poseList->animation(newState);
if (anyDir) {
for (int i = 0; i < numPoseFacings; i++) {
@@ -1983,7 +1982,7 @@ int16 Actor::animationFrames(int16 actionType, Direction dir) {
ActorAnimation *anim;
- anim = (*appearance->poseList)->animation(actionType);
+ anim = appearance->poseList->animation(actionType);
return anim->count[ dir ];
}
@@ -2013,7 +2012,7 @@ bool Actor::nextAnimationFrame(void) {
} else animationFlags &= ~animateOnHold;
// Get the number of frames in the animation
- anim = (*appearance->poseList)->animation(currentAnimation);
+ anim = appearance->poseList->animation(currentAnimation);
numPoses = anim->count[ currentFacing ];
if (numPoses <= 0) {
animationFlags |= animateFinished;
diff --git a/engines/saga2/dispnode.cpp b/engines/saga2/dispnode.cpp
index 899a6eab41..a36905b3ad 100644
--- a/engines/saga2/dispnode.cpp
+++ b/engines/saga2/dispnode.cpp
@@ -171,7 +171,7 @@ void DisplayNodeList::draw(void) {
objectSet = objectSprites;
if (objectSet == NULL)
error("Object sprites have been dumped!\n");
- spellSet = (SpriteSet *)lockResource((RHANDLE) spellSprites);
+ spellSet = *spellSprites;
if (spellSet == NULL)
error("Spell sprites have been dumped!\n");
@@ -575,8 +575,8 @@ void DisplayNode::drawObject(void) {
// Fetch the animation series, and determine which
// pose in the series is the current one.
- anim = (*aa->poseList)->animation(a->currentAnimation);
- pose = (*aa->poseList)->pose(anim,
+ anim = aa->poseList->animation(a->currentAnimation);
+ pose = aa->poseList->pose(anim,
a->currentFacing,
a->currentPose);
diff --git a/engines/saga2/speech.cpp b/engines/saga2/speech.cpp
index 6de9cab1f0..d5bf8dddb2 100644
--- a/engines/saga2/speech.cpp
+++ b/engines/saga2/speech.cpp
@@ -1192,10 +1192,9 @@ Speech *SpeechTaskList::newTask(ObjectID id, uint16 flags) {
// default color.
if (a == getCenterActor()) sp->penColor = 3 + 9 /* 1 */;
else if (a->appearance
- && a->appearance->schemeList
- && *a->appearance->schemeList) {
+ && a->appearance->schemeList) {
sp->penColor =
- (*a->appearance->schemeList)[ a->colorScheme ].speechColor + 9;
+ a->appearance->schemeList[a->colorScheme].speechColor + 9;
} else sp->penColor = 4 + 9;
} else {
sp->penColor = 4 + 9;
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index 4fb98d70c4..2869be2c7b 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -618,13 +618,28 @@ void ActorAppearance::loadSpriteBanks(int16 banksNeeded) {
}
}
+static void readActorAnimSet(hResContext *con, ActorAnimSet &ani) {
+ ani.numAnimations = con->readU32LE();
+ ani.poseOffset = con->readU32LE();
+}
+
+static void readColorScheme(hResContext *con, ColorScheme &col) {
+ for (int i = 0; i < 11; ++i)
+ col.bank[i] = con->readByte();
+
+ col.speechColor = con->readByte();
+
+ for (int i = 0; i < 32; ++i)
+ col.name[i] = con->readSByte();
+}
+
ActorAppearance *LoadActorAppearance(uint32 id, int16 banksNeeded) {
ActorAppearance *aa;
int16 bank;
-
-#if DEBUG
- WriteStatusF(2, "Load App: %s", idname(id));
-#endif
+ const int actorAnimSetSize = 8;
+ const int colorSchemeSize = 44;
+ int poseListSize;
+ int schemeListSize;
// Search the table for either a matching appearance,
// or for an empty one.
@@ -665,11 +680,11 @@ ActorAppearance *LoadActorAppearance(uint32 id, int16 banksNeeded) {
}
if (aa->poseList)
- free(aa->poseList);
+ delete[] aa->poseList;
aa->poseList = nullptr;
if (aa->schemeList)
- free(aa->schemeList);
+ delete[] aa->schemeList;
aa->schemeList = nullptr;
// Set ID and use count
@@ -678,8 +693,22 @@ ActorAppearance *LoadActorAppearance(uint32 id, int16 banksNeeded) {
// Load in new frame lists and sprite banks
aa->loadSpriteBanks(banksNeeded);
- aa->poseList = (ActorAnimSet **)poseRes->loadResource(id, "pose list");
- aa->schemeList = (ColorScheme **)schemeRes->loadResource(id, "scheme list");
+
+ if(poseRes->seek(id) == 0)
+ error("Could not load pose list");
+
+ poseListSize = poseRes->size(id) / actorAnimSetSize;
+ aa->poseList = new ActorAnimSet[poseListSize];
+ for (int i = 0; i < poseListSize; ++i)
+ readActorAnimSet(poseRes, aa->poseList[i]);
+
+ if(schemeRes->seek(id) == 0)
+ error("Could not load scheme list");
+
+ schemeListSize = schemeRes->size(id) / colorSchemeSize;
+ aa->schemeList = new ColorScheme[schemeListSize];
+ for (int i = 0; i < schemeListSize; ++i)
+ readColorScheme(schemeRes, aa->schemeList[i]);
return aa;
}
@@ -699,6 +728,11 @@ void ReleaseActorAppearance(ActorAppearance *aa) {
Sprite initialization routines
* ===================================================================== */
+static void readSpriteResource(hResContext *con, SpriteSet &spr) {
+ spr.count = con->readU32LE();
+ spr.offsets[0] = con->readU32LE();
+}
+
void initSprites(void) {
int i;
@@ -717,6 +751,10 @@ void initSprites(void) {
// object sprites
objectSprites = (SpriteSet *)spriteRes->loadResource(objectSpriteID, "object sprites");
+ //if (spriteRes->seek(objectSpriteID) == 0)
+ // error("Unable to load object sprites");
+
+ //readSpriteResource(spriteRes, *objectSprites)
assert(objectSprites);
// intagible object sprites
diff --git a/engines/saga2/sprite.h b/engines/saga2/sprite.h
index 3f3a00bd9e..24ec1ceec9 100644
--- a/engines/saga2/sprite.h
+++ b/engines/saga2/sprite.h
@@ -146,6 +146,7 @@ struct ActorAnimSet {
uint32 numAnimations, // number of animations
poseOffset; // offset to poses table
+ // FIXME: Pointer Arithmetic
ActorAnimation *animation(int num) {
return (ActorAnimation *)(this + 1) + num;
}
@@ -255,8 +256,8 @@ public:
int16 useCount; // how many actors using this
uint32 id;
- ActorAnimSet **poseList; // list of action sequences
- ColorScheme **schemeList; // color remapping info
+ ActorAnimSet *poseList; // list of action sequences
+ ColorScheme *schemeList; // color remapping info
// Table of sprite sets. Each entry in the table
// represents a different "bank" of sprites
Commit: 91d47cb48058336ccff2027bfee8f1f7e3c2c905
https://github.com/scummvm/scummvm/commit/91d47cb48058336ccff2027bfee8f1f7e3c2c905
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:00+02:00
Commit Message:
SAGA2: Cleanup handles in drawObject
Changed paths:
engines/saga2/dispnode.cpp
engines/saga2/sprite.cpp
engines/saga2/sprite.h
diff --git a/engines/saga2/dispnode.cpp b/engines/saga2/dispnode.cpp
index a36905b3ad..7459cf00e9 100644
--- a/engines/saga2/dispnode.cpp
+++ b/engines/saga2/dispnode.cpp
@@ -372,8 +372,8 @@ void DisplayNode::drawObject(void) {
Point16 drawPos;
SpriteSet *ss;
Sprite *bodySprite;
- ActorAppearance *aa = NULL;
- SpriteSet **sprHandle = NULL;
+ ActorAppearance *aa = nullptr;
+ SpriteSet *sprPtr = nullptr;
TilePoint objCoords = obj->getLocation(),
tCoords,
@@ -692,9 +692,10 @@ void DisplayNode::drawObject(void) {
// REM: Locking bug...
// ss = (SpriteSet *)RLockHandle( aa->sprites );
- sprHandle = aa->spriteBanks[ a->poseInfo.actorFrameBank ];
- ss = (SpriteSet *)lockResource((RHANDLE) sprHandle);
- if (ss == NULL) return;
+ sprPtr = aa->spriteBanks[ a->poseInfo.actorFrameBank ];
+ ss = sprPtr;
+ if (ss == nullptr)
+ return;
// Fill in the SpriteComponent structure for body
sc = &scList[ bodyIndex ];
@@ -815,8 +816,6 @@ void DisplayNode::drawObject(void) {
TBlit(backPort.map, &indicator, indicatorCoords.x, indicatorCoords.y);
}
-
- if (sprHandle) unlockResource((RHANDLE) sprHandle);
}
//-----------------------------------------------------------------------
@@ -844,9 +843,9 @@ ObjectID pickObject(const Point16 &mouse, TilePoint &objPos) {
Point16 testPoint;
SpriteSet *ss;
Sprite *spr;
- ActorAppearance *aa = NULL;
- SpriteSet **sprHandle = NULL;
- bool flipped = TRUE;
+ ActorAppearance *aa = nullptr;
+ SpriteSet *sprPtr = nullptr;
+ bool flipped = true;
testPoint.x = mouse.x - dn->hitBox.x;
testPoint.y = mouse.y - dn->hitBox.y;
@@ -866,9 +865,10 @@ ObjectID pickObject(const Point16 &mouse, TilePoint &objPos) {
if (aa == NULL) continue;
- sprHandle = aa->spriteBanks[ a->poseInfo.actorFrameBank ];
- ss = (SpriteSet *)lockResource((RHANDLE) sprHandle);
- if (ss == NULL) continue;
+ sprPtr = aa->spriteBanks[ a->poseInfo.actorFrameBank ];
+ ss = sprPtr;
+ if (ss == nullptr)
+ continue;
spr = ss->sprite(a->poseInfo.actorFrameIndex);
flipped =
@@ -903,8 +903,6 @@ ObjectID pickObject(const Point16 &mouse, TilePoint &objPos) {
}
}
}
-
- if (sprHandle) unlockResource((RHANDLE) sprHandle);
}
}
}
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index 2869be2c7b..75d9f974b3 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -572,7 +572,7 @@ void buildColorTable(
dst = (uint32 *)(colorTable + sizeof fixedColors);
while (numOptions--) {
- src = (uint32 *)ColorMapRanges[*colorOptions * 8];
+ src = (uint32 *)&ColorMapRanges[*colorOptions * 8];
colorOptions++;
*dst++ = *src++;
*dst++ = *src++;
@@ -614,7 +614,7 @@ void ActorAppearance::loadSpriteBanks(int16 banksNeeded) {
for (bank = 0; bank < (long)elementsof(spriteBanks); bank++) {
// Load the sprite handle...
if (spriteBanks[bank] == nullptr && (banksNeeded & (1 << bank)))
- spriteBanks[bank] = (SpriteSet **)spriteRes->loadResource(id + MKTAG(0, 0, 0, bank), "sprite bank");
+ spriteBanks[bank] = (SpriteSet *)spriteRes->loadResource(id + MKTAG(0, 0, 0, bank), "sprite bank");
}
}
diff --git a/engines/saga2/sprite.h b/engines/saga2/sprite.h
index 24ec1ceec9..478133614b 100644
--- a/engines/saga2/sprite.h
+++ b/engines/saga2/sprite.h
@@ -264,20 +264,20 @@ public:
// REM: How do we determine what frames are NEEDED in the
// near future?
- SpriteSet **spriteBanks[ sprBankCount ];
+ SpriteSet *spriteBanks[ sprBankCount ];
// Member functions:
void loadSpriteBanks(int16 banksNeeded);
// Determine if this bank is loaded
bool isBankLoaded(int16 bank) {
- return RHandleLoaded((RHANDLE)(spriteBanks[ bank ]));
+ return spriteBanks[bank] != nullptr;
}
// A request to load a bank.
void requestBank(int16 bank) {
// Initiate a load of the sprite bank needed.
- if (!RHandleLoading((RHANDLE)(spriteBanks[ bank ])))
+ if (!isBankLoaded(bank))
loadSpriteBanks((int16)(1 << bank));
}
Commit: 1fd59c37599dea5574d12e3cbdac6c943f6cf557
https://github.com/scummvm/scummvm/commit/1fd59c37599dea5574d12e3cbdac6c943f6cf557
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:00+02:00
Commit Message:
SAGA2: Fix warnings
Changed paths:
engines/saga2/automap.cpp
engines/saga2/band.cpp
engines/saga2/band.h
diff --git a/engines/saga2/automap.cpp b/engines/saga2/automap.cpp
index 98d68d914b..957cc639f5 100644
--- a/engines/saga2/automap.cpp
+++ b/engines/saga2/automap.cpp
@@ -164,7 +164,7 @@ CAutoMap::CAutoMap(const Rect16 box,
summaryData = summary;
// init the temporary blit surface port
- if (!NewTempPort(tPort, sumMapArea.width, sumMapArea.height) == errOK) {
+ if (NewTempPort(tPort, sumMapArea.width, sumMapArea.height) != errOK) {
return;
}
@@ -420,7 +420,6 @@ void CAutoMap::draw(void) { // redraw the window
// create a summary map on the tPort gPixelMap buffer
void CAutoMap::createSmallMap(void) {
- gPort &port = window.windowPort;
WorldMapData *wMap = &mapList[ currentWorld->mapNum ];
uint16 *mapData = wMap->map->mapData;
@@ -530,7 +529,6 @@ int16 openAutoMap() {
uint16 closeButtonResID = 0;
uint16 scrollButtonResID = 2;
- uint16 numBtnImages = 2;
extern int16 currentMapNum;
diff --git a/engines/saga2/band.cpp b/engines/saga2/band.cpp
index 935d542a50..7ec299e94c 100644
--- a/engines/saga2/band.cpp
+++ b/engines/saga2/band.cpp
@@ -37,14 +37,14 @@ namespace Saga2 {
BandList class
* ===================================================================== */
-const int numBands = 32;
+const int numBands = 32;
// Manages the memory used for the Band's. There will only be one
// global instantiation of this class
class BandList {
struct BandPlaceHolder : public DNode {
- uint8 buf[ sizeof(Band) ];
+ uint8 buf[sizeof(Band)];
Band *getBand(void) {
return (Band *)&buf;
@@ -54,7 +54,7 @@ class BandList {
DList list, // allocated Bands
free; // unallocated Bands
- BandPlaceHolder array[ numBands ];
+ BandPlaceHolder array[numBands];
public:
// Constructor -- initial construction
@@ -85,16 +85,15 @@ public:
BandID getBandID(Band *b) {
BandPlaceHolder *bp;
- bp = ((BandPlaceHolder *)(
- (uint8 *)b
- - offsetof(BandPlaceHolder, buf)));
+ warning("BandPlaceHolder: unsafe pointer arithmetics");
+ bp = ((BandPlaceHolder *)((uint8 *)b - offsetof(BandPlaceHolder, buf)));
return bp - array;
}
// Return a pointer to a Band given a BandID
Band *getBandAddress(BandID id) {
assert(id >= 0 && id < numBands);
- return array[ id ].getBand();
+ return array[id].getBand();
}
};
@@ -106,7 +105,7 @@ BandList::BandList(void) {
int i;
for (i = 0; i < elementsof(array); i++)
- free.addTail(array[ i ]);
+ free.addTail(array[i]);
}
//----------------------------------------------------------------------
@@ -145,7 +144,7 @@ void *BandList::restore(void *buf) {
id = *((BandID *)buf);
buf = (BandID *)buf + 1;
- new (id) Band(&buf);
+ new (id)Band(&buf);
}
return buf;
@@ -227,7 +226,7 @@ void *BandList::newBand(BandID id) {
BandPlaceHolder *bp;
// Grab the band place holder from the inactive list
- bp = (BandPlaceHolder *)&array[ id ];
+ bp = (BandPlaceHolder *)&array[id];
bp->remove();
// Place the place holder into the active list
@@ -243,11 +242,11 @@ void *BandList::newBand(BandID id) {
void BandList::deleteBand(void *p) {
BandPlaceHolder *bp;
+ warning("BandList: unsafe pointer arithmetics");
+
// Convert the pointer to the Band to a pointer to the
// BandPlaceHolder
- bp = (BandPlaceHolder *)(
- (uint8 *)p
- - offsetof(BandPlaceHolder, buf));
+ bp = (BandPlaceHolder *)((uint8 *)p - offsetof(BandPlaceHolder, buf));
// Remove the band place holder from the active list
bp->remove();
@@ -268,7 +267,7 @@ void BandList::deleteBand(void *p) {
// pointer to the bandListBuffer in order to construct the BandList in
// place.
-static uint8 bandListBuffer[ sizeof(BandList) ];
+static uint8 bandListBuffer[sizeof(BandList)];
static BandList &bandList = *((BandList *)bandListBuffer);
@@ -402,7 +401,7 @@ Band::Band(void **buf) {
// Restore the member pointers
for (i = 0; i < memberCount; i++) {
assert(isActor(*((ObjectID *)bufferPtr)));
- members[ i ] = (Actor *)GameObject::objectAddress(
+ members[i] = (Actor *)GameObject::objectAddress(
*((ObjectID *)bufferPtr));
bufferPtr = (ObjectID *)bufferPtr + 1;
}
@@ -436,7 +435,7 @@ void *Band::archive(void *buf) {
// Store the members' ID's
for (i = 0; i < memberCount; i++) {
- *((ObjectID *)buf) = members[ i ]->thisID();
+ *((ObjectID *)buf) = members[i]->thisID();
buf = (ObjectID *)buf + 1;
}
diff --git a/engines/saga2/band.h b/engines/saga2/band.h
index 6c1dce4659..9bf5adfbcf 100644
--- a/engines/saga2/band.h
+++ b/engines/saga2/band.h
@@ -109,11 +109,11 @@ public:
int i;
for (i = 0; i < memberCount; i++) {
- if (members[ i ] == member) {
+ if (members[i] == member) {
memberCount--;
for (; i < memberCount; i++)
- members[ i ] = members[ i + 1 ];
+ members[i] = members[i + 1];
break;
}
@@ -128,14 +128,14 @@ public:
memberCount--;
for (i = index; i < memberCount; i++)
- members[ i ] = members[ i + 1 ];
+ members[i] = members[i + 1];
}
int size(void) {
return memberCount;
}
Actor *const &operator [](int index) {
- return members[ index ];
+ return members[index];
}
};
Commit: 8f19630dedaee4d1c443ae44d91537b36ff9c1e1
https://github.com/scummvm/scummvm/commit/8f19630dedaee4d1c443ae44d91537b36ff9c1e1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:00+02:00
Commit Message:
SAGA2: JANITORIAL: Fix code formatting
Changed paths:
engines/saga2/actor.cpp
engines/saga2/assign.cpp
engines/saga2/automap.cpp
engines/saga2/band.h
engines/saga2/bitarray.h
engines/saga2/button.cpp
engines/saga2/button.h
engines/saga2/config.cpp
engines/saga2/contain.cpp
engines/saga2/contain.h
engines/saga2/dispnode.cpp
engines/saga2/document.cpp
engines/saga2/document.h
engines/saga2/enchant.cpp
engines/saga2/floating.cpp
engines/saga2/gbevel.h
engines/saga2/gdraw.cpp
engines/saga2/gdraw.h
engines/saga2/grabinfo.cpp
engines/saga2/grabinfo.h
engines/saga2/grequest.cpp
engines/saga2/gtext.cpp
engines/saga2/gtextbox.cpp
engines/saga2/gtextbox.h
engines/saga2/hresmgr.cpp
engines/saga2/idtypes.h
engines/saga2/imagcach.cpp
engines/saga2/interp.cpp
engines/saga2/intrface.h
engines/saga2/keybored.cpp
engines/saga2/main.cpp
engines/saga2/mapfeatr.cpp
engines/saga2/messager.cpp
engines/saga2/mission.cpp
engines/saga2/mission.h
engines/saga2/modal.h
engines/saga2/motion.cpp
engines/saga2/motion.h
engines/saga2/mouseimg.cpp
engines/saga2/msgbox.cpp
engines/saga2/msgbox.h
engines/saga2/objects.h
engines/saga2/objproto.cpp
engines/saga2/objproto.h
engines/saga2/oncall.h
engines/saga2/patrol.h
engines/saga2/player.cpp
engines/saga2/player.h
engines/saga2/playmode.cpp
engines/saga2/priqueue.h
engines/saga2/property.cpp
engines/saga2/property.h
engines/saga2/pt2angle.cpp
engines/saga2/rmem.cpp
engines/saga2/rmembase.h
engines/saga2/sagafunc.cpp
engines/saga2/savefile.cpp
engines/saga2/savefile.h
engines/saga2/script.h
engines/saga2/sensor.cpp
engines/saga2/speech.cpp
engines/saga2/speech.h
engines/saga2/spelcast.cpp
engines/saga2/spelshow.h
engines/saga2/sprite.h
engines/saga2/target.cpp
engines/saga2/target.h
engines/saga2/task.cpp
engines/saga2/task.h
engines/saga2/terrain.cpp
engines/saga2/tile.h
engines/saga2/tileload.h
engines/saga2/tilemode.cpp
engines/saga2/timers.cpp
engines/saga2/transit.cpp
engines/saga2/uidialog.cpp
engines/saga2/uidialog.h
engines/saga2/videobox.cpp
engines/saga2/videobox.h
engines/saga2/vpal.h
engines/saga2/vwdraw.cpp
engines/saga2/vwpage.cpp
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 76e27dc843..57fc4ea295 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -92,7 +92,7 @@ extern bool massAndBulkCount;
Globals -- might as well stick it here as anywhere.
* ===================================================================== */
-int16 factionTable[ maxFactions ][ factionNumColumns ];
+int16 factionTable[maxFactions][factionNumColumns];
// Indicates wether actor states should be paused
bool actorStatesPaused;
@@ -234,7 +234,7 @@ bool ActorProto::strikeAction(
if (itemPtr->acceptStrike(enactor, dObj, effStats->getSkillLevel(skillIDBludgeon)))
return TRUE;
- soundFXs = &objectSoundFXTable[ soundFXClass ];
+ soundFXs = &objectSoundFXTable[soundFXClass];
makeCombatSound(soundFXs->soundFXMissed, al);
return FALSE;
@@ -256,7 +256,7 @@ bool ActorProto::damageAction(
Location al = Location(a->getLocation(), a->IDParent());
damageSoundID = targetPtr->proto()->getDamageSound(
- objectSoundFXTable[ soundFXClass ]);
+ objectSoundFXTable[soundFXClass]);
if (damageSoundID != 0)
@@ -697,7 +697,7 @@ bool ActorProto::acceptInsertionAtAction(
inUseType = notInUse;
for (i = 0; i < ARMOR_COUNT; i++) {
- if (a->armorObjects[ i ] == item) {
+ if (a->armorObjects[i] == item) {
inUseType = worn;
wornWhere = i;
break;
@@ -812,15 +812,15 @@ void ActorProto::doBackgroundUpdate(GameObject *obj) {
switch (actorID) {
case ActorBaseID + FTA_JULIAN:
- playerList[ FTA_JULIAN ].recoveryUpdate();
+ playerList[FTA_JULIAN].recoveryUpdate();
break;
case ActorBaseID + FTA_PHILIP:
- playerList[ FTA_PHILIP ].recoveryUpdate();
+ playerList[FTA_PHILIP].recoveryUpdate();
break;
case ActorBaseID + FTA_KEVIN:
- playerList[ FTA_KEVIN ].recoveryUpdate();
+ playerList[FTA_KEVIN].recoveryUpdate();
break;
default:
@@ -944,9 +944,9 @@ struct ActorArchive {
int16 tetherDist;
ObjectID leftHandObject,
rightHandObject;
- uint16 knowledge[ 16 ];
+ uint16 knowledge[16];
uint16 schedule;
- uint8 conversationMemory[ 4 ];
+ uint8 conversationMemory[4];
uint8 currentAnimation,
currentPose,
animationFlags;
@@ -965,9 +965,9 @@ struct ActorArchive {
int16 currentRecoveryPoints;
ObjectID leaderID;
BandID followersID;
- ObjectID armorObjects[ ARMOR_COUNT ];
+ ObjectID armorObjects[ARMOR_COUNT];
ObjectID currentTargetID;
- int16 scriptVar[ actorScriptVars ];
+ int16 scriptVar[actorScriptVars];
};
/* ===================================================================== *
@@ -988,7 +988,7 @@ void Actor::init(
int i;
// Fixup the prototype pointer to point to an actor prototype
- prototype = (ProtoObj *)&actorProtos[ protoIndex ];
+ prototype = (ProtoObj *)&actorProtos[protoIndex];
// Initialize object fields
// nameIndex = 0;
@@ -1049,10 +1049,10 @@ void Actor::init(
leader = NULL;
followers = NULL;
for (i = 0; i < ARMOR_COUNT; i++)
- armorObjects[ i ] = Nothing;
+ armorObjects[i] = Nothing;
currentTarget = NULL;
for (i = 0; i < actorScriptVars; i++)
- scriptVar[ i ] = 0;
+ scriptVar[i] = 0;
evalActorEnchantments(this);
}
@@ -1066,7 +1066,7 @@ Actor::Actor(const ResourceActor &res) : GameObject(res) {
// Fixup the prototype pointer to point to an actor prototype
prototype = prototype != NULL
- ? (ProtoObj *)&actorProtos[ prototype - objectProtos ]
+ ? (ProtoObj *)&actorProtos[prototype - objectProtos]
: NULL;
// Copy the resource fields
@@ -1116,10 +1116,10 @@ Actor::Actor(const ResourceActor &res) : GameObject(res) {
leader = NULL;
followers = NULL;
for (i = 0; i < ARMOR_COUNT; i++)
- armorObjects[ i ] = Nothing;
+ armorObjects[i] = Nothing;
currentTarget = NULL;
for (i = 0; i < actorScriptVars; i++)
- scriptVar[ i ] = 0;
+ scriptVar[i] = 0;
evalActorEnchantments(this);
}
@@ -1133,7 +1133,7 @@ Actor::Actor(void **buf) : GameObject(buf) {
// Fixup the prototype pointer to point to an actor prototype
prototype = prototype != NULL
- ? (ProtoObj *)&actorProtos[ prototype - objectProtos ]
+ ? (ProtoObj *)&actorProtos[prototype - objectProtos]
: NULL;
ActorArchive *a = (ActorArchive *)bufferPtr;
@@ -1177,14 +1177,14 @@ Actor::Actor(void **buf) : GameObject(buf) {
? getBandAddress(a->followersID)
: NULL;
for (i = 0; i < ARMOR_COUNT; i++)
- armorObjects[ i ] = a->armorObjects[ i ];
+ armorObjects[i] = a->armorObjects[i];
currentTarget = a->currentTargetID != Nothing
? GameObject::objectAddress(a->currentTargetID)
: NULL;
for (i = 0; i < actorScriptVars; i++)
- scriptVar[ i ] = a->scriptVar[ i ];
+ scriptVar[i] = a->scriptVar[i];
- bufferPtr = &a[ 1 ];
+ bufferPtr = &a[1];
if (flags & hasAssignment) {
freeAssignment();
@@ -1235,7 +1235,7 @@ void *Actor::archive(void *buf) {
// Modify the protoype temporarily so the GameObject::archive()
// will store the index correctly
if (prototype != NULL)
- prototype = &objectProtos[(ActorProto *)prototype - actorProtos ];
+ prototype = &objectProtos[(ActorProto *)prototype - actorProtos];
// Let the base class archive its data
buf = GameObject::archive(buf);
@@ -1280,12 +1280,12 @@ void *Actor::archive(void *buf) {
a->leaderID = leader != NULL ? leader->thisID() : Nothing;
a->followersID = followers != NULL ? getBandID(followers) : NoBand;
for (i = 0; i < elementsof(a->armorObjects); i++)
- a->armorObjects[ i ] = armorObjects[ i ];
+ a->armorObjects[i] = armorObjects[i];
a->currentTargetID = currentTarget != NULL ? currentTarget->thisID() : Nothing;
for (i = 0; i < actorScriptVars; i++)
- a->scriptVar[ i ] = scriptVar[ i ];
+ a->scriptVar[i] = scriptVar[i];
- buf = &a[ 1 ];
+ buf = &a[1];
if (flags & hasAssignment)
buf = archiveAssignment(this, buf);
@@ -1312,7 +1312,7 @@ Actor *Actor::newActor(
// Search actor list for first scavangable actor
for (i = playerActors; i < actorCount; i++) {
- a = &actorList[ i ];
+ a = &actorList[i];
if ((a->flags & temporary)
&& !a->isActivated()
@@ -1378,7 +1378,7 @@ void Actor::deleteActor(void) {
int16 i;
for (i = 0; i < followers->size(); i++) {
- Actor *follower = (*followers)[ i ];
+ Actor *follower = (*followers)[i];
follower->leader = NULL;
follower->evaluateNeeds();
@@ -1606,7 +1606,7 @@ ActorAttributes *Actor::getBaseStats(void) {
if (disposition < dispositionPlayer)
return &((ActorProto *)prototype)->baseStats;
else
- return &playerList[ disposition - dispositionPlayer ].baseStats;
+ return &playerList[disposition - dispositionPlayer].baseStats;
}
//-----------------------------------------------------------------------
@@ -1772,8 +1772,8 @@ void Actor::totalArmorAttributes(ArmorAttributes &armorAttribs) {
// Accumulate values for all armor objects
for (i = 0; i < ARMOR_COUNT; i++) {
- if (armorObjects[ i ] != Nothing) {
- ProtoObj *armorProto = GameObject::protoAddress(armorObjects[ i ]);
+ if (armorObjects[i] != Nothing) {
+ ProtoObj *armorProto = GameObject::protoAddress(armorObjects[i]);
assert(armorProto != NULL);
@@ -1905,7 +1905,7 @@ void Actor::getColorTranslation(ColorTable map) {
if (appearance
&& appearance->schemeList) {
buildColorTable(map,
- (appearance->schemeList)[ colorScheme ].bank,
+ (appearance->schemeList)[colorScheme].bank,
11);
} else memcpy(map, identityColors, 256);
}
@@ -1928,7 +1928,7 @@ int16 Actor::setAction(int16 newState, int16 flags) {
// If this animation has no frames, then return FALSE
anim = appearance->poseList->animation(newState);
- numPoses = anim->count[ currentFacing ];
+ numPoses = anim->count[currentFacing];
if (numPoses <= 0) return 0;
// Set up the animation
@@ -1964,10 +1964,10 @@ bool Actor::isActionAvailable(int16 newState, bool anyDir) {
if (anyDir) {
for (int i = 0; i < numPoseFacings; i++) {
- if (anim->count[ i ] > 0) return TRUE;
+ if (anim->count[i] > 0) return TRUE;
}
} else {
- if (anim->count[ currentFacing ] > 0) return TRUE;
+ if (anim->count[currentFacing] > 0) return TRUE;
}
return FALSE;
@@ -1984,7 +1984,7 @@ int16 Actor::animationFrames(int16 actionType, Direction dir) {
anim = appearance->poseList->animation(actionType);
- return anim->count[ dir ];
+ return anim->count[dir];
}
//-----------------------------------------------------------------------
@@ -2013,7 +2013,7 @@ bool Actor::nextAnimationFrame(void) {
// Get the number of frames in the animation
anim = appearance->poseList->animation(currentAnimation);
- numPoses = anim->count[ currentFacing ];
+ numPoses = anim->count[currentFacing];
if (numPoses <= 0) {
animationFlags |= animateFinished;
return TRUE; // no poses, return DONE
@@ -2141,7 +2141,7 @@ void Actor::wear(ObjectID objID, uint8 where) {
}
#endif
- armorObjects[ where ] = objID;
+ armorObjects[where] = objID;
if (isPlayerActor(this)) globalContainerList.setUpdate(thisID());
evalActorEnchantments(this);
@@ -2718,7 +2718,7 @@ void Actor::handleSuccessfulKill(Actor *target) {
player->vitalityAdvance(points / ratio);
aStr = target->getNameIndex() == 0
- ? strchr(vowels, toupper(monsterName[ 0 ])) == NULL
+ ? strchr(vowels, toupper(monsterName[0])) == NULL
? "a "
: "an "
: "";
@@ -2737,7 +2737,7 @@ bool Actor::canBlockWith(GameObject *defenseObj, Direction relativeDir) {
// Assuming that the actor may increment or decrement their facing
// to block, these masks represent the possible relative facings
// based upon the current relative facing
- static uint8 dirMaskArray[ 8 ] = {
+ static uint8 dirMaskArray[8] = {
0x83, // 10000011
0x07, // 00000111
0x0E, // 00001110
@@ -2749,7 +2749,7 @@ bool Actor::canBlockWith(GameObject *defenseObj, Direction relativeDir) {
};
return (defenseObj->proto()->defenseDirMask()
- & dirMaskArray[ relativeDir ])
+ & dirMaskArray[relativeDir])
!= 0;
}
@@ -2831,18 +2831,18 @@ void Actor::bandWith(Actor *newLeader) {
} else {
int16 i,
oldFollowerCount = followers->size();
- Actor **oldFollowers = new Actor * [ oldFollowerCount ];
+ Actor **oldFollowers = new Actor * [oldFollowerCount];
if (oldFollowers != NULL) {
// Copy the list followers
for (i = 0; i < oldFollowerCount; i++) {
- oldFollowers[ i ] = (*followers)[ i ];
- assert(oldFollowers[ i ]->leader == this);
+ oldFollowers[i] = (*followers)[i];
+ assert(oldFollowers[i]->leader == this);
}
// Disband all of the old followers
for (i = 0; i < oldFollowerCount; i++)
- oldFollowers[ i ]->disband();
+ oldFollowers[i]->disband();
assert(followers == NULL);
@@ -2852,7 +2852,7 @@ void Actor::bandWith(Actor *newLeader) {
leader = newLeader;
for (i = 0; i < oldFollowerCount; i++)
- oldFollowers[ i ]->bandWith(newLeader);
+ oldFollowers[i]->bandWith(newLeader);
}
delete [] oldFollowers;
@@ -2875,7 +2875,7 @@ void Actor::disband(void) {
int16 i;
for (i = 0; i < followers->size(); i++) {
- Actor *follower = (*followers)[ i ];
+ Actor *follower = (*followers)[i];
follower->leader = NULL;
follower->evaluateNeeds();
@@ -2922,7 +2922,7 @@ void Actor::removeFollower(Actor *bandMember) {
moraleBonus += ((1 << 16) - moraleBonus) >> 4;
for (i = 0; i < followers->size(); i++) {
- Actor *follower = (*followers)[ i ];
+ Actor *follower = (*followers)[i];
ActorProto *proto = (ActorProto *)follower->prototype;
uint8 combatBehavior = proto->combatBehavior;
@@ -2996,12 +2996,12 @@ void showObjectTerrain(GameObject *obj) {
StandingTileInfo sti;
uint32 terrain = objectTerrain(obj, sti);
char terrLetters[] = "NERWSHWFRSL0000";
- char str[ 33 ];
+ char str[33];
for (int i = 0; i < 32; i++) {
- str[ i ] = terrain & (1 << i) ? terrLetters[ i ] : '-';
+ str[i] = terrain & (1 << i) ? terrLetters[i] : '-';
}
- str[ 32 ] = '\0';
+ str[32] = '\0';
// WriteStatusF( 4, str );
}
@@ -3020,8 +3020,8 @@ bool Actor::pathFindState(void) {
bool Actor::addKnowledge(uint16 kID) {
for (int i = 0; i < elementsof(knowledge); i++) {
- if (knowledge[ i ] == 0) {
- knowledge[ i ] = kID;
+ if (knowledge[i] == 0) {
+ knowledge[i] = kID;
return TRUE;
}
}
@@ -3033,8 +3033,8 @@ bool Actor::addKnowledge(uint16 kID) {
bool Actor::removeKnowledge(uint16 kID) {
for (int i = 0; i < elementsof(knowledge); i++) {
- if (knowledge[ i ] == kID) {
- knowledge[ i ] = 0;
+ if (knowledge[i] == kID) {
+ knowledge[i] = 0;
return TRUE;
}
}
@@ -3046,7 +3046,7 @@ bool Actor::removeKnowledge(uint16 kID) {
void Actor::clearKnowledge(void) {
for (int i = 0; i < elementsof(knowledge); i++) {
- knowledge[ i ] = 0;
+ knowledge[i] = 0;
}
}
@@ -3061,13 +3061,13 @@ void Actor::useKnowledge(scriptCallFrame &scf) {
// First, search for the class with the best response
for (int i = 0; i < elementsof(knowledge); i++) {
- if (knowledge[ i ]) {
+ if (knowledge[i]) {
scriptResult res;
// Run the script to eval the response of this
// knowledge package
- res = runMethod(knowledge[ i ],
+ res = runMethod(knowledge[i],
builtinAbstract,
0,
Method_KnowledgePackage_evalResponse,
@@ -3089,7 +3089,7 @@ void Actor::useKnowledge(scriptCallFrame &scf) {
if (pri > bestResponsePri) {
bestResponsePri = pri;
- bestResponseClass = knowledge[ i ];
+ bestResponseClass = knowledge[i];
bestResponseCode = response;
}
}
@@ -3124,7 +3124,7 @@ bool Actor::canSenseProtaganistIndirectly(SenseInfo &info, int16 range) {
int i;
for (i = 0; i < followers->size(); i++) {
- if ((*followers)[ i ]->canSenseProtaganist(info, range))
+ if ((*followers)[i]->canSenseProtaganist(info, range))
return TRUE;
}
}
@@ -3144,7 +3144,7 @@ bool Actor::canSenseSpecificActorIndirectly(
int i;
for (i = 0; i < followers->size(); i++) {
- if ((*followers)[ i ]->canSenseSpecificActor(info, range, a))
+ if ((*followers)[i]->canSenseSpecificActor(info, range, a))
return TRUE;
}
}
@@ -3164,7 +3164,7 @@ bool Actor::canSenseSpecificObjectIndirectly(
int i;
for (i = 0; i < followers->size(); i++) {
- if ((*followers)[ i ]->canSenseSpecificObject(info, range, obj))
+ if ((*followers)[i]->canSenseSpecificObject(info, range, obj))
return TRUE;
}
}
@@ -3184,7 +3184,7 @@ bool Actor::canSenseActorPropertyIndirectly(
int i;
for (i = 0; i < followers->size(); i++) {
- if ((*followers)[ i ]->canSenseActorProperty(info, range, prop))
+ if ((*followers)[i]->canSenseActorProperty(info, range, prop))
return TRUE;
}
}
@@ -3204,7 +3204,7 @@ bool Actor::canSenseObjectPropertyIndirectly(
int i;
for (i = 0; i < followers->size(); i++) {
- if ((*followers)[ i ]->canSenseObjectProperty(info, range, prop))
+ if ((*followers)[i]->canSenseObjectProperty(info, range, prop))
return TRUE;
}
}
@@ -3281,7 +3281,7 @@ void updateActorStates(void) {
actorIndex = baseActorIndex = (baseActorIndex + 1) & evalRateMask;
while (actorIndex < actorCount) {
- Actor *a = &actorList[ actorIndex ];
+ Actor *a = &actorList[actorIndex];
if (isWorld(a->IDParent()))
a->evaluateNeeds();
@@ -3291,7 +3291,7 @@ void updateActorStates(void) {
updatesViaScript = 0;
for (actorIndex = 0; actorIndex < actorCount; actorIndex++) {
- Actor *a = &actorList[ actorIndex ];
+ Actor *a = &actorList[actorIndex];
if (isWorld(a->IDParent()) && a->isActivated())
a->updateState();
@@ -3398,22 +3398,22 @@ void initActors(void) {
readResourceActor(listRes, resourceActorList[k]);
for (i = 0; i < resourceActorCount; i++) {
- Actor *a = &actorList[ i ];
+ Actor *a = &actorList[i];
// Initialize the actors with the resource data
- new (a) Actor(resourceActorList[ i ]);
+ new (a) Actor(resourceActorList[i]);
}
// Place all of the extra actors in actor limbo
for (; i < actorCount; i++) {
- Actor *a = &actorList[ i ];
+ Actor *a = &actorList[i];
new (a) Actor;
}
- actorList[ 0 ].disposition = dispositionPlayer + 0;
- actorList[ 1 ].disposition = dispositionPlayer + 1;
- actorList[ 2 ].disposition = dispositionPlayer + 2;
+ actorList[0].disposition = dispositionPlayer + 0;
+ actorList[1].disposition = dispositionPlayer + 1;
+ actorList[2].disposition = dispositionPlayer + 2;
// Wait for the object initialization to append the actors to their
@@ -3437,7 +3437,7 @@ void saveActors(SaveFileConstructor &saveGame) {
archiveBufSize += sizeof(int16);
for (i = 0; i < actorCount; i++)
- archiveBufSize += actorList[ i ].archiveSize();
+ archiveBufSize += actorList[i].archiveSize();
archiveBuffer = malloc(archiveBufSize);
if (archiveBuffer == NULL)
@@ -3450,7 +3450,7 @@ void saveActors(SaveFileConstructor &saveGame) {
// Store the actor data in the archive buffer
for (i = 0; i < actorCount; i++)
- bufferPtr = (int16 *)actorList[ i ].archive(bufferPtr);
+ bufferPtr = (int16 *)actorList[i].archive(bufferPtr);
// Write the archive buffer to the save file
saveGame.writeChunk(
@@ -3491,9 +3491,9 @@ void loadActors(SaveFileReader &saveGame) {
i < actorCount;
i++)
// Initilize actors with archive data
- new (&actorList[ i ]) Actor(&bufferPtr);
+ new (&actorList[i]) Actor(&bufferPtr);
- assert(bufferPtr == &((char *)archiveBuffer)[ archiveBufSize ]);
+ assert(bufferPtr == &((char *)archiveBuffer)[archiveBufSize]);
// Deallocate the archive buffer
free(archiveBuffer);
@@ -3507,7 +3507,7 @@ void cleanupActors(void) {
int16 i;
for (i = 0; i < actorCount; i++)
- actorList[ i ].~Actor();
+ actorList[i].~Actor();
delete[] actorList;
actorList = NULL;
@@ -3529,23 +3529,23 @@ int16 AddFactionTally(int faction, enum factionTallyTypes act, int amt) {
/*
// If faction attitude counts get to big then down-scale all of them
// in proportion.
- if ( factionTable[ faction ][ act ] + amt > maxint16 )
+ if ( factionTable[faction][act] + amt > maxint16 )
{
for (int i = 0; i < factionNumColumns; i++)
- factionTable[ faction ][ i ] >>= 1;
+ factionTable[faction][i] >>= 1;
}
// Otherwise, if it doesn;t underflow, then add it in.
- if ( factionTable[ faction ][ act ] + amt > minint16 )
+ if ( factionTable[faction][act] + amt > minint16 )
{
- factionTable[ faction ][ act ] += amt;
+ factionTable[faction][act] += amt;
}
*/
- factionTable[ faction ][ act ] = clamp(minint16,
- factionTable[ faction ][ act ] + amt,
+ factionTable[faction][act] = clamp(minint16,
+ factionTable[faction][act] + amt,
maxint16);
- return factionTable[ faction ][ act ];
+ return factionTable[faction][act];
}
// Get the attitude a particular faction has for a char.
@@ -3558,7 +3558,7 @@ int16 GetFactionTally(int faction, enum factionTallyTypes act) {
assert(act < factionNumColumns);
#endif
- return factionTable[ faction ][ act ];
+ return factionTable[faction][act];
}
//-------------------------------------------------------------------
diff --git a/engines/saga2/assign.cpp b/engines/saga2/assign.cpp
index 4ba28b614b..679632551e 100644
--- a/engines/saga2/assign.cpp
+++ b/engines/saga2/assign.cpp
@@ -305,11 +305,11 @@ Task *PatrolRouteAssignment::getTask(TaskStack *ts) {
if (startPoint == -1) {
int16 i;
uint16 bestDist = maxuint16;
- const PatrolRoute &route = patrolRouteList[ mapNum ][ routeNo ];
+ const PatrolRoute &route = patrolRouteList[mapNum][routeNo];
TilePoint actorLoc = getActor()->getLocation();
for (i = 0; i < route.vertices(); i++) {
- uint16 dist = lineDist(route[ i ], route[(i + 1) % route.vertices() ], actorLoc);
+ uint16 dist = lineDist(route[i], route[(i + 1) % route.vertices()], actorLoc);
if (dist < bestDist) {
bestDist = dist;
diff --git a/engines/saga2/automap.cpp b/engines/saga2/automap.cpp
index 957cc639f5..9f4e55b672 100644
--- a/engines/saga2/automap.cpp
+++ b/engines/saga2/automap.cpp
@@ -113,7 +113,7 @@ Rect16 autoMapBotPanelRect(autoMapBoxX,
autoMapBTHeight);
-Rect16 autoMapPanelRects[ numAutoMapPanels ] = { { autoMapTopPanelRect },
+Rect16 autoMapPanelRects[numAutoMapPanels] = { { autoMapTopPanelRect },
{ autoMapMidPanelRect },
{ autoMapBotPanelRect }
};
@@ -127,10 +127,10 @@ Rect16 closeAutoMapBtnRect(-1, 276, 42, 41);
Rect16 scrollBtnRect(493, 275, scrollBtnWidth, scrollBtnHeight);
-WindowDecoration autoMapDecorations[ numAutoMapPanels ] = {
- { WindowDecoration(autoMapPanelRects[ 0 ], autoMapTopPanelResID) },
- { WindowDecoration(autoMapPanelRects[ 1 ], autoMapMidPanelResID) },
- { WindowDecoration(autoMapPanelRects[ 2 ], autoMapBotPanelResID) }
+WindowDecoration autoMapDecorations[numAutoMapPanels] = {
+ { WindowDecoration(autoMapPanelRects[0], autoMapTopPanelResID) },
+ { WindowDecoration(autoMapPanelRects[1], autoMapMidPanelResID) },
+ { WindowDecoration(autoMapPanelRects[2], autoMapBotPanelResID) }
};
@@ -190,7 +190,7 @@ void CAutoMap::locateRegion(void) {
struct TileRect {
int16 uMin, vMin, uMax, vMax;
} *tr;
- WorldMapData *wMap = &mapList[ currentWorld->mapNum ];
+ WorldMapData *wMap = &mapList[currentWorld->mapNum];
int i;
areaRes = auxResFile->newContext(MKTAG('A', 'M', 'A', 'P'), "AreaList");
@@ -420,7 +420,7 @@ void CAutoMap::draw(void) { // redraw the window
// create a summary map on the tPort gPixelMap buffer
void CAutoMap::createSmallMap(void) {
- WorldMapData *wMap = &mapList[ currentWorld->mapNum ];
+ WorldMapData *wMap = &mapList[currentWorld->mapNum];
uint16 *mapData = wMap->map->mapData;
uint16 *mapRow;
@@ -460,7 +460,7 @@ void CAutoMap::createSmallMap(void) {
xBase = (topPt.u - topPt.v) * tileSumWidthHalved + 261;
yBase = 255 - (topPt.u + topPt.v) * 2;
- mapRow = &mapData[ viewRegion.max.u * wMap->mapSize ];
+ mapRow = &mapData[viewRegion.max.u * wMap->mapSize];
for (u = viewRegion.max.u, x0 = xBase, y0 = yBase;
u >= viewRegion.min.u;
@@ -468,7 +468,7 @@ void CAutoMap::createSmallMap(void) {
for (v = viewRegion.max.v, x = x0, y = y0;
v >= viewRegion.min.v;
v--, x += tileSumWidthHalved, y += 2) {
- uint16 mtile = mapRow[ v ];
+ uint16 mtile = mapRow[v];
if (mtile & metaTileVisited)
if (
@@ -477,7 +477,7 @@ void CAutoMap::createSmallMap(void) {
#endif
(mtile & metaTileVisited)) {
// get the tile data
- map.data = &summaryData[(mtile & ~metaTileVisited) << 6 ];
+ map.data = &summaryData[(mtile & ~metaTileVisited) << 6];
// blit this tile onto the temp surface
TBlit(tPort.map,
diff --git a/engines/saga2/band.h b/engines/saga2/band.h
index 9bf5adfbcf..86aece1125 100644
--- a/engines/saga2/band.h
+++ b/engines/saga2/band.h
@@ -66,7 +66,7 @@ class Band {
Actor *leader;
int16 memberCount;
- Actor *members[ maxBandMembers ];
+ Actor *members[maxBandMembers];
public:
// Constructor -- initial construction
@@ -99,7 +99,7 @@ public:
bool add(Actor *newMember) {
if (memberCount < elementsof(members)) {
- members[ memberCount++ ] = newMember;
+ members[memberCount++] = newMember;
return TRUE;
} else
return FALSE;
diff --git a/engines/saga2/bitarray.h b/engines/saga2/bitarray.h
index a1bcbc489e..7e134c2ec8 100644
--- a/engines/saga2/bitarray.h
+++ b/engines/saga2/bitarray.h
@@ -136,7 +136,7 @@ public:
}
bool isSet(int i) {
- return b[ i >> 5 ] & ((uint32) 1 << (i & 31));
+ return b[i >> 5] & ((uint32) 1 << (i & 31));
}
void SetBit(int16 i) {
diff --git a/engines/saga2/button.cpp b/engines/saga2/button.cpp
index 0a7a101b32..7e15a15bf1 100644
--- a/engines/saga2/button.cpp
+++ b/engines/saga2/button.cpp
@@ -49,7 +49,7 @@ void gCompImage::init(void) {
internalAlloc = FALSE;
currentImage = 0;
numPtrAlloc = 0;
-// imageText[ 0 ] = NULL;
+// imageText[0] = NULL;
}
gCompImage::gCompImage(gPanelList &list, const Rect16 &box, void *image, uint16 ident,
@@ -60,7 +60,7 @@ gCompImage::gCompImage(gPanelList &list, const Rect16 &box, void *image, uint16
if (image) {
compImages = (void **)malloc(sizeof(pVOID) * 1); // allocate room for one pointer
- compImages[ 0 ] = image;
+ compImages[0] = image;
internalAlloc = FALSE;
numPtrAlloc = 1;
}
@@ -84,7 +84,7 @@ gCompImage::gCompImage(gPanelList &list,
compImages = (void **)malloc(sizeof(void *)*numImages); // allocate room for numImages pointers
for (i = 0, rNum = resNum; i < numImages; i++, rNum++) {
- compImages[ i ] = LoadResource(resContext,
+ compImages[i] = LoadResource(resContext,
MKTAG(a, b, c, rNum),
" gCompImage ");
}
@@ -107,7 +107,7 @@ gCompImage::gCompImage(gPanelList &list, const Rect16 &box, void *image, const c
compImages = (void **)malloc(sizeof(void *) * 1); // allocate room for one pointer
- compImages[ 0 ] = image;
+ compImages[0] = image;
max = 0;
numPtrAlloc = 1;
title = text;
@@ -121,7 +121,7 @@ compImages = (void **)malloc(sizeof(void *) * 1); // allocate room for one point
strncpy(imageText, text, textSize);
// cap it, in case of overflow
- imageText[ textSize - 1 ] = NULL;
+ imageText[textSize - 1] = NULL;
// setup the text pallete and font type
textPal = pal;
@@ -170,7 +170,7 @@ gCompImage::gCompImage(gPanelList &list, const Rect16 &box, void **images,
strncpy(imageText, text, textSize);
// cap it, in case of overflow
- imageText[ textSize - 1 ] = NULL;
+ imageText[textSize - 1] = NULL;
textPal = pal;
textFont = &Onyx10Font; // >>> this should be dynamic
} else {
@@ -189,7 +189,7 @@ gCompImage::~gCompImage(void) {
// if we LoadRes'ed image internally RDispose those
if (internalAlloc) {
for (int16 i = 0; i < numPtrAlloc; i++) {
- RDisposePtr(compImages[ i ]);
+ RDisposePtr(compImages[i]);
}
}
@@ -228,7 +228,7 @@ void gCompImage::draw(void) {
void *gCompImage::getCurrentCompImage(void) {
if (compImages) {
- return compImages[ currentImage ]; // return the image pointed to by compImage
+ return compImages[currentImage]; // return the image pointed to by compImage
} else {
return NULL;
}
@@ -243,7 +243,7 @@ void gCompImage::setImages(void **images) {
void gCompImage::setImage(void *image) {
if (image) {
- compImages[ 0 ] = image;
+ compImages[0] = image;
max = 0;
currentImage = 0;
}
@@ -405,9 +405,9 @@ gCompButton::gCompButton(gPanelList &list, const Rect16 &box, hResContext *con,
gCompButton::gCompButton(gPanelList &list, const Rect16 &box, void **images, int16 numRes, uint16 ident,
AppFunc *cmd) : gCompImage(list, box, NULL, ident, cmd) {
- if (images[ 0 ] && images[ 1 ] && numRes == 2) {
- forImage = images[ 0 ];
- resImage = images[ 1 ];
+ if (images[0] && images[1] && numRes == 2) {
+ forImage = images[0];
+ resImage = images[1];
dimImage = NULL;
} else {
forImage = NULL;
@@ -422,9 +422,9 @@ gCompButton::gCompButton(gPanelList &list, const Rect16 &box, void **images, int
gCompButton::gCompButton(gPanelList &list, const Rect16 &box, void **images, int16 numRes, const char *text, textPallete &pal, uint16 ident,
AppFunc *cmd) : gCompImage(list, box, NULL, 0, 0, text, pal, ident, cmd) {
- if (images[ 0 ] && images[ 1 ] && numRes == 2) {
- forImage = images[ 0 ];
- resImage = images[ 1 ];
+ if (images[0] && images[1] && numRes == 2) {
+ forImage = images[0];
+ resImage = images[1];
dimImage = NULL;
} else {
forImage = NULL;
@@ -439,9 +439,9 @@ gCompButton::gCompButton(gPanelList &list, const Rect16 &box, void **images, int
gCompButton::gCompButton(gPanelList &list, const Rect16 &box, void **images, int16 numRes, void *newDimImage, bool dimNess, uint16 ident,
AppFunc *cmd) : gCompImage(list, box, NULL, ident, cmd) {
- if (images[ 0 ] && images[ 1 ] && numRes == 2) {
- forImage = images[ 0 ];
- resImage = images[ 1 ];
+ if (images[0] && images[1] && numRes == 2) {
+ forImage = images[0];
+ resImage = images[1];
} else {
forImage = NULL;
resImage = NULL;
@@ -689,9 +689,9 @@ gMultCompButton::gMultCompButton(gPanelList &list, const Rect16 &box, hResContex
images = (void **)malloc(sizeof(void *)*numRes);
for (i = 0, k = resStart; i < numRes; i++, k++) {
- images[ i ] = LoadResource(con, MKTAG(a, b, c, k), "Multi btn image");
+ images[i] = LoadResource(con, MKTAG(a, b, c, k), "Multi btn image");
- checkAlloc(images[ i ]);
+ checkAlloc(images[i]);
}
response = TRUE;
@@ -751,8 +751,8 @@ gMultCompButton::~gMultCompButton(void) {
if (images && internalAlloc) {
for (i = 0; i <= max; i++) {
- if (images[ i ]) {
- RDisposePtr(images[ i ]);
+ if (images[i]) {
+ RDisposePtr(images[i]);
}
}
@@ -783,7 +783,7 @@ bool gMultCompButton::pointerHit(gPanelMessage &) {
}
void *gMultCompButton::getCurrentCompImage(void) {
- return images[ current ];
+ return images[current];
}
/* ===================================================================== *
@@ -824,7 +824,7 @@ void *gSlider::getCurrentCompImage(void) {
index = clamp(0, index, max);
- return images[ index ];
+ return images[index];
}
int16 gSlider::getSliderLenVal(void) {
diff --git a/engines/saga2/button.h b/engines/saga2/button.h
index 0aca0dbb67..67e19fbd04 100644
--- a/engines/saga2/button.h
+++ b/engines/saga2/button.h
@@ -91,7 +91,7 @@ protected:
uint16 max, min; // min max of the index
textPallete textPal; // contains info about coloring for multi-depth text rendering
gFont *textFont; // pointer to font for this button
-// char imageText[ textSize ]; // text to render on button
+// char imageText[textSize]; // text to render on button
protected:
virtual void *getCurrentCompImage(void); // get the current image
diff --git a/engines/saga2/config.cpp b/engines/saga2/config.cpp
index 60ff621ab0..f901bef618 100644
--- a/engines/saga2/config.cpp
+++ b/engines/saga2/config.cpp
@@ -32,7 +32,7 @@ namespace Saga2 {
char iniFile[] = "FTA2.INI";
configuration globalConfig;
-static char originalDir[ PATH_STR_SIZE ];
+static char originalDir[PATH_STR_SIZE];
//-----------------------------------------------------------------------
// This doesn't belong here, oh well...
diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index f938d6cf0a..0be38bc9c4 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -59,7 +59,7 @@ static void *selImage;
Imports
* ===================================================================== */
-extern ReadyContainerView *TrioCviews[ kNumViews ];
+extern ReadyContainerView *TrioCviews[kNumViews];
extern ReadyContainerView *indivCviewTop, *indivCviewBot;
extern SpellStuff spellBook[];
extern SpriteSet *objectSprites; // object sprites
@@ -104,7 +104,7 @@ static bool alreadyDone;
ObjectID ContainerView::lastPickedObjectID = Nothing;
int32 ContainerView::lastPickedObjectQuantity = - 1;
bool ContainerView::objTextAlarm = FALSE;
-char ContainerView::mouseText[ ContainerView::bufSize ] = { "" };
+char ContainerView::mouseText[ContainerView::bufSize] = { "" };
bool ContainerView::mouseInView = FALSE;
uint16 ContainerView::numPicked = 1;
GameObject *ContainerView::objToGet;
@@ -475,7 +475,7 @@ void ContainerView::drawClipped(
void ContainerView::drawSelector(gPort &port, Point16 &pos) {
const int bufSize = 20;
- char buf[ bufSize ];
+ char buf[bufSize];
uint8 num;
SAVE_GPORT_STATE(port);
@@ -511,7 +511,7 @@ void ContainerView::drawQuantity(
if (quantity > 1) {
SAVE_GPORT_STATE(port);
- char buf[ 8 ];
+ char buf[8];
// draw the number of items selected thus far
sprintf(buf, "%d", quantity);
@@ -617,7 +617,7 @@ void ContainerView::pointerMove(gPanelMessage &msg) {
lastPickedObjectID = Nothing;
lastPickedObjectQuantity = -1;
mouseInfo.setText(NULL);
- mouseText[ 0 ] = NULL;
+ mouseText[0] = NULL;
// static bool that tells if the mouse cursor
// is in a panel
@@ -764,7 +764,7 @@ void ContainerView::clickOn(
// activate multi-object get interface if a mergeable object
getMerged(cObj);
mouseInfo.setText(NULL);
- mouseText[ 0 ] = NULL;
+ mouseText[0] = NULL;
}
} else {
// just get the object into the cursor
@@ -899,7 +899,7 @@ void ContainerView::updateMouseText(Point16 &pickPos) {
if (slotID == Nothing) {
// clear out the mouse text
mouseInfo.setText(NULL);
- mouseText[ 0 ] = NULL;
+ mouseText[0] = NULL;
// reset the last picked thingy
lastPickedObjectID = Nothing;
@@ -923,7 +923,7 @@ void ContainerView::updateMouseText(Point16 &pickPos) {
// clear out the mouse text
mouseInfo.setText(NULL);
- mouseText[ 0 ] = NULL;
+ mouseText[0] = NULL;
// reset the alarm flag
objTextAlarm = FALSE;
@@ -943,7 +943,7 @@ void ContainerView::setCursorText(GameObject *obj) {
assert(obj);
const bufSize = 40;
- char cursorText[ bufSize ];
+ char cursorText[bufSize];
// put the normalized text into cursorText
obj->objCursorText(cursorText, bufSize);
@@ -954,7 +954,7 @@ void ContainerView::setCursorText(GameObject *obj) {
void ContainerView::setDelayedCursorText(GameObject *obj) {
// clear out the mouse text
mouseInfo.setText(NULL);
- mouseText[ 0 ] = NULL;
+ mouseText[0] = NULL;
// reset the alarm flag
objTextAlarm = FALSE;
@@ -1078,8 +1078,8 @@ void ReadyContainerView::drawClipped(
i++, col++, x += iconSpacing.x + iconWidth) {
Point16 pos(x, y);
- if (isGhosted()) drawCompressedImageGhosted(port, pos, backImages[ i % numIm ]);
- else drawCompressedImage(port, pos, backImages[ i % numIm ]);
+ if (isGhosted()) drawCompressedImageGhosted(port, pos, backImages[i % numIm]);
+ else drawCompressedImage(port, pos, backImages[i % numIm]);
}
}
@@ -1142,7 +1142,7 @@ void ReadyContainerView::drawClipped(
// Draw the "in use" indicator.
if (backImages && proto->isObjectBeingUsed(item)) {
drawCompressedImage(port,
- Point16(x - 4, y - 4), backImages[ 3 ]);
+ Point16(x - 4, y - 4), backImages[3]);
}
// Build the color table.
@@ -1188,8 +1188,8 @@ ContainerWindow::ContainerWindow(ContainerNode &nd,
*this,
app.closeRect, // rect for button
containerRes, // resource context
- app.closeResID[ 0 ],
- app.closeResID[ 1 ],
+ app.closeResID[0],
+ app.closeResID[1],
0,
cmdCloseButtonFunc); // mind app func
}
@@ -1215,8 +1215,8 @@ ScrollableContainerWindow::ScrollableContainerWindow(
*this,
app.scrollRect, // rect for button
containerRes, // resource context
- app.scrollResID[ 0 ], // resource handle name
- app.scrollResID[ 1 ],
+ app.scrollResID[0], // resource handle name
+ app.scrollResID[1],
0,
cmdScrollFunc); // mind app func
@@ -1261,7 +1261,7 @@ TangibleContainerWindow::TangibleContainerWindow(
setContainerSprite(); // show at the top of the box
// set the decorations for this window
- setDecorations(winDecs[ bgndType ],
+ setDecorations(winDecs[bgndType],
elementsof(brassDecorations), // brass was arb, all should have same
containerRes, 'F', 'R', 'M');
@@ -1369,8 +1369,8 @@ EnchantmentContainerWindow::EnchantmentContainerWindow(
*this,
app.scrollRect, // rect for button
containerRes, // resource context
- app.scrollResID[ 0 ], // resource handle name
- app.scrollResID[ 1 ],
+ app.scrollResID[0], // resource handle name
+ app.scrollResID[1],
0,
cmdScrollFunc); // mind app func
@@ -1467,7 +1467,7 @@ void *ContainerNode::restore(void *buf) {
// If this container was shown, re-show it
if (a->shown) markForShow();
- return &a[ 1 ];
+ return &a[1];
}
// Store the state of this ContainerNode into archive buffer
@@ -1482,7 +1482,7 @@ void *ContainerNode::archive(void *buf) {
a->mindType = mindType;
a->shown = window != NULL;
- return &a[ 1 ];
+ return &a[1];
}
// Close the container window, but leave the node.
@@ -1538,7 +1538,7 @@ void ContainerNode::show(void) {
void ContainerNode::update(void) {
if (type == readyType) {
// Update ready containers if they are enabled
- if (TrioCviews[ owner ]->getEnabled()) TrioCviews[ owner ]->invalidate();
+ if (TrioCviews[owner]->getEnabled()) TrioCviews[owner]->invalidate();
if (indivCviewTop->getEnabled()) indivCviewTop->invalidate();
if (indivCviewBot->getEnabled()) indivCviewBot->invalidate();
@@ -1938,7 +1938,7 @@ void setMindContainer(int index, IntangibleContainerWindow &cw) {
assert(index >= 0);
assert(index < elementsof(classTable));
- int containerClass = classTable[ index ];
+ int containerClass = classTable[index];
cw.mindSelectorCompButton->setCurrent(index);
cw.mindSelectorCompButton->invalidate();
@@ -1981,7 +1981,7 @@ APPFUNC(cmdMindContainerFunc) {
const int BUF_SIZE = 64;
- char textBuffer[ BUF_SIZE ];
+ char textBuffer[BUF_SIZE];
int mindType = -1;
diff --git a/engines/saga2/contain.h b/engines/saga2/contain.h
index f0cb88cfbd..380b26bf45 100644
--- a/engines/saga2/contain.h
+++ b/engines/saga2/contain.h
@@ -122,7 +122,7 @@ public:
static bool objTextAlarm;
// buffer for the mouse text
- static char mouseText[ bufSize ];
+ static char mouseText[bufSize];
// determines if the cursor is in *A* container view
static bool mouseInView;
@@ -371,8 +371,8 @@ struct ContainerAppearanceDef {
scrollRect, // position of scrolling button
iconRect, // position of container icon
massRect; // position of mass & bulk indicator
- hResID closeResID[ 2 ], // resource ID's for close box
- scrollResID[ 2 ]; // resource ID's for scroll indicator
+ hResID closeResID[2], // resource ID's for close box
+ scrollResID[2]; // resource ID's for scroll indicator
Point16 iconOrigin,
iconSpacing;
uint16 rows,
@@ -406,10 +406,10 @@ struct ContainerAppearanceDef {
rows(_rows),
cols(_cols),
totRows(_totRows) {
- closeResID[ 0 ] = _closeResID_0;
- closeResID[ 1 ] = _closeResID_1;
- scrollResID[ 0 ] = _scrollResID_0;
- scrollResID[ 1 ] = _scrollResID_1;
+ closeResID[0] = _closeResID_0;
+ closeResID[1] = _closeResID_1;
+ scrollResID[0] = _scrollResID_0;
+ scrollResID[1] = _scrollResID_1;
}
};
diff --git a/engines/saga2/dispnode.cpp b/engines/saga2/dispnode.cpp
index 7459cf00e9..c809fd9f0b 100644
--- a/engines/saga2/dispnode.cpp
+++ b/engines/saga2/dispnode.cpp
@@ -188,8 +188,8 @@ void DisplayNodeList::draw(void) {
// objects or actors which are closest to the center view point.
void DisplayNodeList::buildObjects(bool fromScratch) {
- GameObject *sortList[ maxDisplayed + 1 ];
- int16 distList[ maxDisplayed + 1 ];
+ GameObject *sortList[maxDisplayed + 1];
+ int16 distList[maxDisplayed + 1];
int16 sortCount = 0;
int16 i;
int16 viewSize = tileRect.height;
@@ -202,7 +202,7 @@ void DisplayNodeList::buildObjects(bool fromScratch) {
// view region.
for (i = 0; i < count; i++) {
- DisplayNode *dn = &displayList[ i ];
+ DisplayNode *dn = &displayList[i];
GameObject *obj = dn->object;
TilePoint objLoc = obj->getLocation();
int16 dist;
@@ -268,15 +268,15 @@ void DisplayNodeList::buildObjects(bool fromScratch) {
// An insertion sort which has been clamped
// to a limited number of items.
for (i = sortCount; i > 0;) {
- if (dist >= distList[ i - 1 ]) break;
+ if (dist >= distList[i - 1]) break;
i--;
- distList[ i + 1 ] = distList[ i ];
- sortList[ i + 1 ] = sortList[ i ];
+ distList[i + 1] = distList[i];
+ sortList[i + 1] = sortList[i];
}
if (i < maxDisplayed) {
- distList[ i ] = dist;
- sortList[ i ] = obj;
+ distList[i] = dist;
+ sortList[i] = obj;
if (sortCount < maxDisplayed) sortCount++;
}
@@ -288,8 +288,8 @@ void DisplayNodeList::buildObjects(bool fromScratch) {
count = sortCount;
for (i = 0; i < sortCount; i++) {
- DisplayNode *dn = &displayList[ i ];
- GameObject *ob = sortList[ i ];
+ DisplayNode *dn = &displayList[i];
+ GameObject *ob = sortList[i];
DisplayNode **search;
TilePoint oLoc = ob->getLocation();
dn->nextDisplayed = NULL;
@@ -360,7 +360,7 @@ void DisplayNode::drawObject(void) {
ColorTable mainColors, // colors for object
leftColors, // colors for left-hand object
rightColors; // colors for right-hand object
- SpriteComponent scList[ 3 ],
+ SpriteComponent scList[3],
*sc;
int16 bodyIndex, // drawing order of body
leftIndex, // drawing order of left
@@ -388,9 +388,9 @@ void DisplayNode::drawObject(void) {
mCoords.z = 0;
// Do not display objects that are on a ripped roof
- if ((mt = mapList[ currentMapNum ].lookupMeta(mCoords)) != NULL) {
+ if ((mt = mapList[currentMapNum].lookupMeta(mCoords)) != NULL) {
if ((rt = mt->ripTable(currentMapNum)) != NULL) {
- if (objCoords.z >= rt->zTable[ tCoords.u ][ tCoords.v ]) {
+ if (objCoords.z >= rt->zTable[tCoords.u][tCoords.v]) {
// Disable hit-test on the object's box
hitBox.width = -1;
hitBox.height = -1;
@@ -462,7 +462,7 @@ void DisplayNode::drawObject(void) {
obj->getColorTranslation(mainColors);
// Fill in the SpriteComponent structure
- sc = &scList[ 0 ];
+ sc = &scList[0];
sc->sp = sprInfo.sp;
sc->offset.x = scList->offset.y = 0;
sc->colorTable = mainColors;
@@ -506,7 +506,7 @@ void DisplayNode::drawObject(void) {
if (a->kludgeCount < 0 || ++a->kludgeCount >= bubbleSpriteCount)
a->kludgeCount = 0;
- sc = &scList[ 0 ];
+ sc = &scList[0];
sc->sp = (*spellSprites)->sprite(
baseBubbleSpriteIndex + a->kludgeCount);
sc->offset.x = scList->offset.y = 0;
@@ -580,12 +580,12 @@ void DisplayNode::drawObject(void) {
a->currentFacing,
a->currentPose);
- assert(anim->start[ 0 ] >= 0);
- assert(anim->start[ 0 ] < 10000);
- assert(anim->start[ 1 ] >= 0);
- assert(anim->start[ 1 ] < 10000);
- assert(anim->start[ 2 ] >= 0);
- assert(anim->start[ 2 ] < 10000);
+ assert(anim->start[0] >= 0);
+ assert(anim->start[0] < 10000);
+ assert(anim->start[1] >= 0);
+ assert(anim->start[1] < 10000);
+ assert(anim->start[2] >= 0);
+ assert(anim->start[2] < 10000);
assert(pose->rightObjectOffset.x < 1000);
assert(pose->rightObjectOffset.x > -1000);
@@ -597,7 +597,7 @@ void DisplayNode::drawObject(void) {
assert(pose->leftObjectOffset.y < 1000);
assert(pose->leftObjectOffset.y > -1000);
- // washHandle( aa->spriteBanks[ pose->actorFrameBank ] );
+ // washHandle( aa->spriteBanks[pose->actorFrameBank] );
// If the new sprite is loaded, then we can go
// ahead and show it. If it's not, then we can
@@ -612,7 +612,7 @@ void DisplayNode::drawObject(void) {
// Initiate a load of the sprite bank needed.
/* if (!RHandleLoading(
- (RHANDLE)(aa->spriteBanks[ pose->actorFrameBank ]) ))
+ (RHANDLE)(aa->spriteBanks[pose->actorFrameBank]) ))
{
aa->loadSpriteBanks( (1<<pose->actorFrameBank) );
} */
@@ -630,7 +630,7 @@ void DisplayNode::drawObject(void) {
// Initiate a load of the sprite bank needed.
/* if (!RHandleLoading(
- (RHANDLE)(aa->spriteBanks[ pose->actorFrameBank ]) ))
+ (RHANDLE)(aa->spriteBanks[pose->actorFrameBank]) ))
{
aa->loadSpriteBanks( (1<<pose->actorFrameBank) );
}
@@ -692,13 +692,13 @@ void DisplayNode::drawObject(void) {
// REM: Locking bug...
// ss = (SpriteSet *)RLockHandle( aa->sprites );
- sprPtr = aa->spriteBanks[ a->poseInfo.actorFrameBank ];
+ sprPtr = aa->spriteBanks[a->poseInfo.actorFrameBank];
ss = sprPtr;
if (ss == nullptr)
return;
// Fill in the SpriteComponent structure for body
- sc = &scList[ bodyIndex ];
+ sc = &scList[bodyIndex];
assert(a->poseInfo.actorFrameIndex < ss->count);
sc->sp = ss->sprite(a->poseInfo.actorFrameIndex);
sc->offset.x = sc->offset.y = 0;
@@ -724,7 +724,7 @@ void DisplayNode::drawObject(void) {
ob->getColorTranslation(leftColors);
- sc = &scList[ leftIndex ];
+ sc = &scList[leftIndex];
sc->sp = proto->getOrientedSprite(
ob,
a->poseInfo.leftObjectIndex);
@@ -749,7 +749,7 @@ void DisplayNode::drawObject(void) {
ob->getColorTranslation(rightColors);
- sc = &scList[ rightIndex ];
+ sc = &scList[rightIndex];
sc->sp = proto->getOrientedSprite(
ob,
a->poseInfo.rightObjectIndex);
@@ -797,9 +797,9 @@ void DisplayNode::drawObject(void) {
// Record the extent box that the sprite was drawn
// at, in order to facilitate mouse picking functions
// later on in the event loop.
- bodySprite = scList[ bodyIndex ].sp;
+ bodySprite = scList[bodyIndex].sp;
hitBox.x = drawPos.x
- + (scList[ bodyIndex ].flipped
+ + (scList[bodyIndex].flipped
? -bodySprite->size.x - bodySprite->offset.x
: bodySprite->offset.x)
- fineScroll.x;
@@ -865,7 +865,7 @@ ObjectID pickObject(const Point16 &mouse, TilePoint &objPos) {
if (aa == NULL) continue;
- sprPtr = aa->spriteBanks[ a->poseInfo.actorFrameBank ];
+ sprPtr = aa->spriteBanks[a->poseInfo.actorFrameBank];
ss = sprPtr;
if (ss == nullptr)
continue;
@@ -973,7 +973,7 @@ void Effectron::drawEffect(void) {
bool obscured = FALSE;
Point16 drawPos;
TilePoint objCoords = SpellPos();
- SpriteComponent scList[ 3 ],
+ SpriteComponent scList[3],
*sc;
if (isHidden() || isDead())
@@ -995,7 +995,7 @@ void Effectron::drawEffect(void) {
TileToScreenCoords(objCoords, screenCoords);
- sc = &scList[ 0 ];
+ sc = &scList[0];
//sc->sp = (*spellSprites)->sprite( spriteID() );
sc->sp = (*spellSprites)->sprite(spriteID()); //tempSpellSpriteIDs[rand()%39] );
sc->offset.x = scList->offset.y = 0;
diff --git a/engines/saga2/document.cpp b/engines/saga2/document.cpp
index 67fe3a3ef1..fa171e3793 100644
--- a/engines/saga2/document.cpp
+++ b/engines/saga2/document.cpp
@@ -160,22 +160,22 @@ CDocument::CDocument(CDocumentAppearance &dApp,
// set the original text pointer
//origText = ( char * )RNewPtr( textSize + 1, NULL, "book original text buffer" );
- origText = new char[ textSize + 1 ];
+ origText = new char[textSize + 1];
// and fill it
strcpy(origText, buffer);
// make a working buffer
//text = ( char * )RNewPtr( textSize + 1, NULL, "book work text buffer" );
- text = new char[ textSize + 1 ];
+ text = new char[textSize + 1];
// and fill it
strcpy(text, origText);
textFont = font;
textHeight = (textFont ? textFont->height : 0);
- lineWidth = dApp.pageRect[ 0 ].width;
- pageHeight = dApp.pageRect[ 0 ].height;
+ lineWidth = dApp.pageRect[0].width;
+ pageHeight = dApp.pageRect[0].height;
currentPage = 0;
totalLines = 0;
totalPages = 0;
@@ -183,7 +183,7 @@ CDocument::CDocument(CDocumentAppearance &dApp,
// null out the image pointer array
for (int16 i = 0; i < maxPages; i++) {
- images[ i ] = NULL;
+ images[i] = NULL;
}
makePages();
@@ -204,8 +204,8 @@ CDocument::~CDocument(void) {
int16 i;
for (i = 0; i < maxPages; i++) {
- if (images[ i ]) {
- RDisposePtr(images[ i ]);
+ if (images[i]) {
+ RDisposePtr(images[i]);
}
}
@@ -366,8 +366,8 @@ void CDocument::setText(char * /* string */) {
int16 i;
for (i = 0; i < maxPages; i++) {
- if (images[ i ]) {
- RDisposePtr(images[ i ]);
+ if (images[i]) {
+ RDisposePtr(images[i]);
}
}
@@ -398,7 +398,7 @@ void CDocument::setText(char * /* string */) {
strncpy(text, origText, textSize);
// make sure it's null terminated
- text[ textSize ] = NULL;
+ text[textSize] = NULL;
// repage the book
makePages();
@@ -420,13 +420,13 @@ void CDocument::appendText(char * /* string */) {
int16 expandedLen;
for (i = 0; i < maxPages; i++) {
- memset(lineLen[ i ], 0, maxLines);
+ memset(lineLen[i], 0, maxLines);
}
// free up the images
for (i = 0; i < maxPages; i++) {
- if (images[ i ]) {
- RDisposePtr(images[ i ]);
+ if (images[i]) {
+ RDisposePtr(images[i]);
}
}
@@ -453,8 +453,8 @@ void CDocument::appendText(char * /* string */) {
// make space for the old text
//expandedBuf = ( char * )RNewPtr( expandedLen + 1, NULL, "book expaned text buffer" );
- expandedBuf = new char[ expandedLen + 1 ];
- expandedTextBuf = new char[ expandedLen + 1 ];
+ expandedBuf = new char[expandedLen + 1];
+ expandedTextBuf = new char[expandedLen + 1];
// save the old text
strcpy(expandedBuf, origText);
@@ -469,7 +469,7 @@ void CDocument::appendText(char * /* string */) {
// copy the old text into the larger buffer
strcpy( origText, oldText );
- origText[ oldTextLen + newTextLen ] = NULL;
+ origText[oldTextLen + newTextLen] = NULL;
// add the appending text to the original text buffer replacment
strcat( origText, string );
@@ -486,7 +486,7 @@ void CDocument::appendText(char * /* string */) {
// copy from the original text buffer to the working text buffer
strcpy( text, origText );
- text[ oldTextLen + newTextLen ] = NULL;
+ text[oldTextLen + newTextLen] = NULL;
*/
// get rid of the old origText buffer
@@ -517,14 +517,14 @@ bool CDocument::checkForPageBreak(char *string, uint16 index, int32 &offset) {
char *strIndex = string + index;
// page break detected
- if (strIndex[ 1 ] == dPageBreak[ 0 ] &&
- strIndex[ 2 ] == dPageBreak[ 1 ]) {
+ if (strIndex[1] == dPageBreak[0] &&
+ strIndex[2] == dPageBreak[1]) {
// eat the page breaks chars
// tie off the end
- strIndex[ 0 ] = NULL;
+ strIndex[0] = NULL;
// string them together
- strcat(&strIndex[ 0 ], &strIndex[ 2 + 1 ]);
+ strcat(&strIndex[0], &strIndex[2 + 1]);
// take the offset to the end of this line
offset = index;
@@ -553,10 +553,10 @@ bool CDocument::checkForImage(char *string,
// image detected marker
- if (strIndex[ 1 ] == dImage[ 0 ] &&
- strIndex[ 2 ] == dImage[ 1 ]) {
+ if (strIndex[1] == dImage[0] &&
+ strIndex[2] == dImage[1]) {
int16 numEat; // number of characters to eat
- char *argv = &strIndex[ 2 + 1 ]; // array to first element
+ char *argv = &strIndex[2 + 1]; // array to first element
// delete context
if (illustrationCon) resFile->disposeContext(illustrationCon);
@@ -569,13 +569,13 @@ bool CDocument::checkForImage(char *string,
// if the last entry is defined as a number
if (argv[7] == ':') {
// convert the text into a number
- char numSt[ 2 ] = { argv[ 8 ], NULL };
+ char numSt[2] = { argv[8], NULL };
uint8 num = atoi(numSt);
- if (!images[ offPageIndex ]) {
+ if (!images[offPageIndex]) {
// get the image
- images[ offPageIndex ] = LoadResource(illustrationCon,
+ images[offPageIndex] = LoadResource(illustrationCon,
MKTAG(argv[4], argv[5], argv[6], num),
"book internal image");
}
@@ -583,7 +583,7 @@ bool CDocument::checkForImage(char *string,
// number of chars to eat
numEat = 9;
} else {
- images[ offPageIndex ] = LoadResource(illustrationCon,
+ images[offPageIndex] = LoadResource(illustrationCon,
MKTAG(argv[4], argv[5], argv[6], argv[7]),
"book internal image");
numEat = 8;
@@ -591,21 +591,21 @@ bool CDocument::checkForImage(char *string,
}
// get the size of the image
- imageSizes[ offPageIndex ] =
- ((ImageHeader *)images[ offPageIndex ])->size;
+ imageSizes[offPageIndex] =
+ ((ImageHeader *)images[offPageIndex])->size;
// tie off the end
- strIndex[ 0 ] = NULL;
+ strIndex[0] = NULL;
// and string them together
- strcat(&strIndex[ 0 ], &strIndex[ 2 + 1 + numEat ]);
+ strcat(&strIndex[0], &strIndex[2 + 1 + numEat]);
// set new line length
offset = index;
// set the line offset
- lineOffset[ offPageIndex ] =
- imageSizes[ offPageIndex ].y / (textHeight + 1) +
+ lineOffset[offPageIndex] =
+ imageSizes[offPageIndex].y / (textHeight + 1) +
textPictureOffset;
// set the new page flag
@@ -640,7 +640,7 @@ void CDocument::makePages(void) {
// check for page breaks and images
for (i = 0; i <= offset; i++) {
// we hit a diliminator
- if (str[ i ] == deliminator) {
+ if (str[i] == deliminator) {
// page break check
if (checkForPageBreak(str, i, offset)) {
// if a break did not just occur
@@ -666,7 +666,7 @@ void CDocument::makePages(void) {
pageBreakSet = FALSE;
}
- lineIndex = lineOffset[ pageIndex ];
+ lineIndex = lineOffset[pageIndex];
}
}
@@ -677,10 +677,10 @@ void CDocument::makePages(void) {
// set the length of this line
if (offset >= 0) {
// number of characters on this line
- lineLen[ pageIndex ][ lineIndex ] = offset;
+ lineLen[pageIndex][lineIndex] = offset;
} else {
// remaining number of characters in string
- lineLen[ pageIndex ][ lineIndex ] = strlen(str);
+ lineLen[pageIndex][lineIndex] = strlen(str);
}
@@ -689,13 +689,13 @@ void CDocument::makePages(void) {
lineIndex++;
}
- numLines[ pageIndex ] = lineIndex;
+ numLines[pageIndex] = lineIndex;
pageIndex++;
newPage = FALSE;
/* debug
WriteStatusF( 5, "page#:%d", pageIndex );
- char buf[ 80 ];
+ char buf[80];
strncpy( buf, str, 75 );
@@ -705,10 +705,10 @@ void CDocument::makePages(void) {
// check to see if there is an image; and make allowences if
// there is.
/*
- if( images[ pageIndex ] )
+ if( images[pageIndex] )
{
// set the next text line to the lineOffset
- lineIndex = lineOffset[ pageIndex ];
+ lineIndex = lineOffset[pageIndex];
}
else
{
@@ -753,21 +753,21 @@ void CDocument::renderText(void) {
tPort.setFont(textFont); // setup the string pointer
for (pageIndex = 0; pageIndex < currentPage; pageIndex++) {
- if (images[ pageIndex ]) {
- lineIndex = lineOffset[ pageIndex ];
+ if (images[pageIndex]) {
+ lineIndex = lineOffset[pageIndex];
assert(lineIndex < linesPerPage);
} else {
lineIndex = 0;
}
- for (; lineIndex < numLines[ pageIndex ]; lineIndex++) {
- int16 temp = lineLen[ pageIndex ][ lineIndex ];
+ for (; lineIndex < numLines[pageIndex]; lineIndex++) {
+ int16 temp = lineLen[pageIndex][lineIndex];
assert(pageIndex < maxPages);
assert(temp < 35);
- str += lineLen[ pageIndex ][ lineIndex ];
+ str += lineLen[pageIndex][lineIndex];
}
}
@@ -775,35 +775,35 @@ void CDocument::renderText(void) {
for (pageIndex = currentPage;
pageIndex - currentPage < app.numPages && pageIndex < pages;
pageIndex++) {
- Rect16 *pageRect = &app.pageRect[ pageIndex % app.numPages ];
+ Rect16 *pageRect = &app.pageRect[pageIndex % app.numPages];
// if there is an image on this page
- if (images[ pageIndex ]) {
+ if (images[pageIndex]) {
Point16 pos;
- pos.x = pageRect->x + (pageRect->width - imageSizes[ pageIndex ].x) / 2;
+ pos.x = pageRect->x + (pageRect->width - imageSizes[pageIndex].x) / 2;
pos.y = pageRect->y;
- drawCompressedImage(tPort, pos, images[ pageIndex ]);
+ drawCompressedImage(tPort, pos, images[pageIndex]);
- lineIndex = lineOffset[ pageIndex ];
+ lineIndex = lineOffset[pageIndex];
} else {
lineIndex = 0;
}
- for (; lineIndex < numLines[ pageIndex ]; lineIndex++) {
+ for (; lineIndex < numLines[pageIndex]; lineIndex++) {
assert(pageIndex <= maxPages && pageIndex >= 0);
tPort.moveTo(pageRect->x, pageRect->y + (textHeight * lineIndex) + 1);
- tPort.setColor(app.textColors[ lineIndex ]);
- tPort.drawText(str, lineLen[ pageIndex ][ lineIndex ]);
+ tPort.setColor(app.textColors[lineIndex]);
+ tPort.drawText(str, lineLen[pageIndex][lineIndex]);
// grab the next text offset
- int16 temp = lineLen[ pageIndex ][ lineIndex ];
+ int16 temp = lineLen[pageIndex][lineIndex];
assert(temp < 35);
- str += lineLen[ pageIndex ][ lineIndex ];
+ str += lineLen[pageIndex][lineIndex];
}
}
@@ -856,12 +856,12 @@ void CDocument::draw(void) { // redraw the window
* ===================================================================== */
const int textSize = 4096;
-char bookText[ textSize ] = { "" };
+char bookText[textSize] = { "" };
void appendBookText(char *string) {
if (string) {
strncat(bookText, string, textSize - 1);
- bookText[ textSize - 1] = NULL;
+ bookText[textSize - 1] = NULL;
}
}
@@ -874,7 +874,7 @@ void buildText(uint16 textScript) {
// clear out the scroll text
strcpy(bookText, "");
- if (textScript == resImports->reserved[ 0 ]) {
+ if (textScript == resImports->reserved[0]) {
strcpy(bookText, PROGRAM_ABOUT);
}
diff --git a/engines/saga2/document.h b/engines/saga2/document.h
index 2813326d58..e800d0101b 100644
--- a/engines/saga2/document.h
+++ b/engines/saga2/document.h
@@ -63,7 +63,7 @@ public:
int16 numPages; // Number of visible pages
int16 orientation; // Orientation of pages
uint8 *textColors; // Text color array
- Rect16 pageRect[ maxVisiblePages ];// Array of visible page rects
+ Rect16 pageRect[maxVisiblePages];// Array of visible page rects
Rect16 closeRect; // Close-box rectangle
WindowDecoration *decoList; // List of decorator panels
int16 numDecos; // Number of decorator panels
@@ -91,8 +91,8 @@ public:
numDecos(_numDecos),
groupID(_groupID),
decoID(_decoID) {
- pageRect[ 0 ] = _pageRect_0;
- pageRect[ 1 ] = _pageRect_1;
+ pageRect[0] = _pageRect_0;
+ pageRect[1] = _pageRect_1;
}
};
@@ -114,13 +114,13 @@ private:
struct ImageHeader {
Point16 size;
int16 compress;
- int8 data[ 2 ];
+ int8 data[2];
};
CDocumentAppearance &app;
// image poiner array
- void *images[ maxPages ];
+ void *images[maxPages];
uint16 currentPage,
lineWidth,
@@ -131,10 +131,10 @@ private:
gFont *textFont;
uint16 textHeight;
uint16 pages;
- uint16 numLines[ maxPages];
- uint16 lineLen[ maxPages ][ maxLines ];
- uint16 lineOffset[ maxPages ];
- Extent16 imageSizes[ maxPages ];
+ uint16 numLines[maxPages];
+ uint16 lineLen[maxPages][maxLines];
+ uint16 lineOffset[maxPages];
+ Extent16 imageSizes[maxPages];
bool pageBreakSet;
char *scan; // for parsing book text.
diff --git a/engines/saga2/enchant.cpp b/engines/saga2/enchant.cpp
index 14b8edf705..855ba642e9 100644
--- a/engines/saga2/enchant.cpp
+++ b/engines/saga2/enchant.cpp
@@ -55,7 +55,7 @@ ObjectID EnchantObject(
assert(enchantmentProto >= 0);
assert(enchantmentProto < objectProtoCount);
- enchProto = &objectProtos[ enchantmentProto ];
+ enchProto = &objectProtos[enchantmentProto];
ench = GameObject::newObject(); //Create Enchantment
if (ench == NULL) return Nothing;
diff --git a/engines/saga2/floating.cpp b/engines/saga2/floating.cpp
index 77029fb218..70ff9953e4 100644
--- a/engines/saga2/floating.cpp
+++ b/engines/saga2/floating.cpp
@@ -399,7 +399,7 @@ LabeledButton::LabeledButton(gPanelList &list,
const char *underscore;
if ((underscore = strchr(title, '_')) != NULL)
- accelKey = toupper(underscore[ 1 ]);
+ accelKey = toupper(underscore[1]);
}
void LabeledButton::drawClipped(
diff --git a/engines/saga2/gbevel.h b/engines/saga2/gbevel.h
index e0451e2947..465e6a4d00 100644
--- a/engines/saga2/gbevel.h
+++ b/engines/saga2/gbevel.h
@@ -68,47 +68,47 @@ enum bevelPens {
extern gPen mainPens[]; // the array of pens
#if 0
-#define transpPen mainPens[ 0 ] // transparent pen for mouse
+#define transpPen mainPens[0] // transparent pen for mouse
// color pens
-#define blackPen mainPens[ 1 ] // black
-#define whitePen mainPens[ 2 ] // white
+#define blackPen mainPens[1] // black
+#define whitePen mainPens[2] // white
// Background pens
-#define backPen mainPens[ 3 ] // background fill
-#define backLtPen mainPens[ 4 ] // background highlight
-#define backDkPen mainPens[ 5 ] // background shadow
+#define backPen mainPens[3] // background fill
+#define backLtPen mainPens[4] // background highlight
+#define backDkPen mainPens[5] // background shadow
// Button pens
-#define buttonPen mainPens[ 6 ] // button fill color
-#define buttonLtPen mainPens[ 7 ] // button highlight
-#define buttonDkPen mainPens[ 8 ] // button shadow
+#define buttonPen mainPens[6] // button fill color
+#define buttonLtPen mainPens[7] // button highlight
+#define buttonDkPen mainPens[8] // button shadow
-#define transpPen mainPens[ 0 ] // transparent pen for mouse
+#define transpPen mainPens[0] // transparent pen for mouse
// color pens
-#define blackPen mainPens[ 1 ] // black
-#define whitePen mainPens[ 2 ] // white
+#define blackPen mainPens[1] // black
+#define whitePen mainPens[2] // white
// Background pens
-#define backPen mainPens[ 3 ] // background fill
-#define backLtPen mainPens[ 4 ] // background highlight
-#define backDkPen mainPens[ 5 ] // background shadow
+#define backPen mainPens[3] // background fill
+#define backLtPen mainPens[4] // background highlight
+#define backDkPen mainPens[5] // background shadow
// Button pens
-#define buttonPen mainPens[ 6 ] // button fill color
-#define buttonLtPen mainPens[ 7 ] // button highlight
-#define buttonDkPen mainPens[ 8 ] // button shadow
+#define buttonPen mainPens[6] // button fill color
+#define buttonLtPen mainPens[7] // button highlight
+#define buttonDkPen mainPens[8] // button shadow
// Text pens
-#define hilitePen mainPens[ 9 ] // text highlight color
+#define hilitePen mainPens[9] // text highlight color
#endif
/* ===================================================================== *
diff --git a/engines/saga2/gdraw.cpp b/engines/saga2/gdraw.cpp
index f176ca14d1..3f17c73fce 100644
--- a/engines/saga2/gdraw.cpp
+++ b/engines/saga2/gdraw.cpp
@@ -941,7 +941,7 @@ void mapImage(gPixelMap &from, gPixelMap &to, gPen map[]) {
uint8 *get = from.data,
*put = to.data;
- while (bytes--) *put++ = map[ *get++ ];
+ while (bytes--) *put++ = map[*get++];
}
void mapImage(gPort &from, gPort &to, gPen map[]) {
diff --git a/engines/saga2/gdraw.h b/engines/saga2/gdraw.h
index f6bdacb310..7f2d6e7699 100644
--- a/engines/saga2/gdraw.h
+++ b/engines/saga2/gdraw.h
@@ -102,11 +102,11 @@ struct gFont {
uint16 baseLine; // baseline of the font
uint16 rowMod; // row modulus for char data
- uint16 charXOffset[ 256 ]; // offset of each char in data
+ uint16 charXOffset[256]; // offset of each char in data
- int8 charWidth[ 256 ], // width of character in pixels
- charKern[ 256 ], // character kern value
- charSpace[ 256 ]; // character space value
+ int8 charWidth[256], // width of character in pixels
+ charKern[256], // character kern value
+ charSpace[256]; // character space value
// followed by (row_mod * height) bytes of character data
byte *fontdata;
@@ -227,16 +227,16 @@ public:
penMap = pmap;
}
void setIndirectColor(uint8 color) {
- fgPen = penMap[ color ];
+ fgPen = penMap[color];
}
void setIndirectBgColor(uint8 color) {
- bgPen = penMap[ color ];
+ bgPen = penMap[color];
}
void setIndirectShColor(uint8 color) {
- shPen = penMap[ color ];
+ shPen = penMap[color];
}
void setIndirectOLColor(uint8 color) {
- olPen = penMap[ color ];
+ olPen = penMap[color];
}
// modes & styles
@@ -300,7 +300,7 @@ public:
virtual void setPixel(int16 x, int16 y, gPen color) {
if (x >= clip.x && x < clip.x + clip.width
&& y >= clip.y && y < clip.y + clip.height) {
- baseRow[(y + origin.y) * rowMod + x + origin.x ] = color;
+ baseRow[(y + origin.y) * rowMod + x + origin.x] = color;
}
}
void setPixel(int16 x, int16 y) {
@@ -316,10 +316,10 @@ public:
// pixel query functions
virtual gPen getPixel(int16 x, int16 y) {
- return baseRow[(y + origin.y) * rowMod + x + origin.x ];
+ return baseRow[(y + origin.y) * rowMod + x + origin.x];
}
virtual gPen getPixel(Point16 p) {
- return baseRow[(p.y + origin.y) * rowMod + p.x + origin.x ];
+ return baseRow[(p.y + origin.y) * rowMod + p.x + origin.x];
}
// Rectangle fill functions
diff --git a/engines/saga2/grabinfo.cpp b/engines/saga2/grabinfo.cpp
index e0ce5f2141..4ab565a829 100644
--- a/engines/saga2/grabinfo.cpp
+++ b/engines/saga2/grabinfo.cpp
@@ -51,7 +51,7 @@ GrabInfo::GrabInfo() {
intentDoable = TRUE;
intention = WalkTo;
- textBuf[ 0 ] = '\0';
+ textBuf[0] = '\0';
displayGauge = FALSE;
}
@@ -81,7 +81,7 @@ void GrabInfo::grabObject(ObjectID objid, Intent in, int16 count) {
// Make the object pointer into the mouse pointer
void GrabInfo::grabObject(GameObject *obj, Intent in, int16 count) {
- char objText[ bufSize ];
+ char objText[bufSize];
assert(!obj->isMoving());
@@ -126,7 +126,7 @@ void GrabInfo::copyObject(ObjectID objid, Intent in, int16 count) {
// it does not actually copy it
// Make the object pointer into the mouse pointer
void GrabInfo::copyObject(GameObject *obj, Intent in, int16 count) {
- char objText[ bufSize ];
+ char objText[bufSize];
// set the number of items
setMoveCount(count);
@@ -272,7 +272,7 @@ void GrabInfo::placeObject(const Location &loc) {
clearIcon();
// Display the saved text
- setMouseText(textBuf[ 0 ] != '\0' ? textBuf : NULL);
+ setMouseText(textBuf[0] != '\0' ? textBuf : NULL);
// Display the saved gauge data
if (displayGauge)
@@ -307,7 +307,7 @@ void GrabInfo::replaceObject(void) {
clearIcon();
// Display the saved text
- setMouseText(textBuf[ 0 ] != '\0' ? textBuf : NULL);
+ setMouseText(textBuf[0] != '\0' ? textBuf : NULL);
// Display the saved gauge data
if (displayGauge)
@@ -323,11 +323,11 @@ void GrabInfo::replaceObject(void) {
void GrabInfo::setText(const char *txt) {
if ((txt != NULL) && strlen(txt)) {
strncpy(textBuf, txt, bufSize);
- textBuf[ bufSize - 1 ] = '\0';
+ textBuf[bufSize - 1] = '\0';
if (grabObj == NULL)
setMouseText(textBuf);
} else {
- textBuf[ 0 ] = '\0';
+ textBuf[0] = '\0';
if (grabObj == NULL)
setMouseText(NULL);
}
diff --git a/engines/saga2/grabinfo.h b/engines/saga2/grabinfo.h
index 66cf0aa074..e46494cc09 100644
--- a/engines/saga2/grabinfo.h
+++ b/engines/saga2/grabinfo.h
@@ -76,7 +76,7 @@ protected:
int16 moveCount; // number of items being moved in cursor
- char textBuf[ bufSize ];
+ char textBuf[bufSize];
// internal grab commonality
void setIcon(void);
diff --git a/engines/saga2/grequest.cpp b/engines/saga2/grequest.cpp
index c7c0882511..52db9a8199 100644
--- a/engines/saga2/grequest.cpp
+++ b/engines/saga2/grequest.cpp
@@ -54,7 +54,7 @@ int16 SplitString(
int16 count;
for (count = 0; count < maxStrings;) {
- textStart[ count++ ] = text;
+ textStart[count++] = text;
if ((text = strchr(text, delimiter)) == NULL) break;
*text++ = '\0';
}
@@ -84,9 +84,9 @@ static void handleRequestEvent(gEvent &ev) {
class ModalDialogWindow : public ModalWindow {
int16 titleCount;
- Point16 titlePos[ maxLines ];
- char *titleStrings[ maxLines ];
- char titleBuf[ maxText ];
+ Point16 titlePos[maxLines];
+ char *titleStrings[maxLines];
+ char titleBuf[maxText];
void positionText(
char *windowText,
@@ -137,11 +137,11 @@ void ModalDialogWindow::positionText(
for (i = 0; i < titleCount; i++, yPos += fontHeight) {
if (yPos < maxY) {
- titlePos[ i ].y = yPos;
- titlePos[ i ].x =
+ titlePos[i].y = yPos;
+ titlePos[i].x =
textArea.x +
((textArea.width -
- TextWidth(mainFont, titleStrings[ i ], -1, 0))
+ TextWidth(mainFont, titleStrings[i], -1, 0))
>> 1);
} else titleCount = i;
}
@@ -199,17 +199,17 @@ void ModalDialogWindow::drawClipped(
port.setFont(textFont);
for (i = 0; i < titleCount; i++) {
- Point16 textPos = origin + titlePos[ i ];
+ Point16 textPos = origin + titlePos[i];
port.moveTo(textPos + Point16(-1, -1));
port.setColor(2);
- port.drawText(titleStrings[ i ], -1);
+ port.drawText(titleStrings[i], -1);
port.moveTo(textPos + Point16(1, 1));
port.setColor(14);
- port.drawText(titleStrings[ i ], -1);
+ port.drawText(titleStrings[i], -1);
port.moveTo(textPos);
port.setColor(8);
- port.drawText(titleStrings[ i ], -1);
+ port.drawText(titleStrings[i], -1);
}
ModalWindow::drawClipped(port, offset, r);
@@ -220,7 +220,7 @@ void ModalDialogWindow::drawClipped(
* ===================================================================== */
class ModalRequestWindow : public ModalDialogWindow {
- char buttonBuf[ maxButtonText ];
+ char buttonBuf[maxButtonText];
static Rect16 getTextArea(const Rect16 &r) {
return Rect16(2, 2, r.width - 4, r.height - mainFont->height - 12);
@@ -252,7 +252,7 @@ ModalRequestWindow::ModalRequestWindow(
intervals;
int16 buttonCount;
- char *buttonStrings[ maxButtons ];
+ char *buttonStrings[maxButtons];
int16 fontHeight = mainFont->height;
@@ -299,7 +299,7 @@ ModalRequestWindow::ModalRequestWindow(
fontHeight + 6),
*mouseCursors[kMouseCloseBx2Image],
*mouseCursors[kMouseCloseBx1Image],
- buttonStrings[ i ],
+ buttonStrings[i],
i,
handleRequestEvent);
diff --git a/engines/saga2/gtext.cpp b/engines/saga2/gtext.cpp
index d2f4dc4656..888b36bd0f 100644
--- a/engines/saga2/gtext.cpp
+++ b/engines/saga2/gtext.cpp
@@ -132,11 +132,11 @@ static void DrawChar(
// point to the first byte of the first scanline of the
// source char
- chardata = (uint8 *)(font + 1) + font->charXOffset[ drawchar ];
+ chardata = (uint8 *)(font + 1) + font->charXOffset[drawchar];
// get the width of the character in pixels
- charwidth = font->charWidth[ drawchar ];
+ charwidth = font->charWidth[drawchar];
// point to the first byte of where we want to place the character
@@ -292,10 +292,10 @@ void DrawChar3x3Outline(gFont *font, int drawchar, int xpos, uint8 *baseline,
unsigned short txt1, txt2, txt3;
// point to the first byte of the first scanline of the source char
- chardata = (uint8 *)(font + 1) + font->charXOffset[ drawchar ];
+ chardata = (uint8 *)(font + 1) + font->charXOffset[drawchar];
// get the width of the character in pixels
- charwidth = font->charWidth[ drawchar ];
+ charwidth = font->charWidth[drawchar];
// point to the first byte of where we want to place the character
baseline += xpos - 1;
@@ -349,13 +349,13 @@ void DrawChar5x5Outline(gFont *font, int drawchar, int xpos, uint8 *baseline,
uint8 *src, *dst;
unsigned short s0, s1;
- unsigned short txt[ 5 ];
+ unsigned short txt[5];
// point to the first byte of the first scanline of the source char
- chardata = (uint8 *)(font + 1) + font->charXOffset[ drawchar ];
+ chardata = (uint8 *)(font + 1) + font->charXOffset[drawchar];
// get the width of the character in pixels
- charwidth = font->charWidth[ drawchar ];
+ charwidth = font->charWidth[drawchar];
// point to the first byte of where we want to place the character
baseline += xpos - 2;
@@ -367,19 +367,19 @@ void DrawChar5x5Outline(gFont *font, int drawchar, int xpos, uint8 *baseline,
src = chardata;
dst = baseline;
- txt[ 0 ] = txt[ 1 ] = txt[ 2 ] = txt[ 3 ] = txt[ 4 ] = 0;
+ txt[0] = txt[1] = txt[2] = txt[3 ] = txt[ 4 ] = 0;
for (h = font->height + 4; h; h--) {
d = dst;
- txt[ 4 ] = txt[ 3 ];
- txt[ 3 ] = txt[ 2 ];
- txt[ 2 ] = txt[ 1 ];
- txt[ 1 ] = txt[ 0 ];
- txt[ 0 ] = h > 4 ? *src : 0;
+ txt[4] = txt[3];
+ txt[3] = txt[2];
+ txt[2] = txt[1];
+ txt[1] = txt[0];
+ txt[0] = h > 4 ? *src : 0;
- s0 = txt[ 1 ] | txt[ 2 ] | txt[ 3 ];
- s1 = s0 | txt[ 0 ] | txt[ 4 ];
+ s0 = txt[1] | txt[2] | txt[3];
+ s1 = s0 | txt[0] | txt[4];
s0 = s0 | (s0 << 1) | (s0 << 2) | (s0 << 3) | (s0 << 4);
s0 |= (s1 << 1) | (s1 << 2) | (s1 << 3);
@@ -423,11 +423,11 @@ static void DrawChar3x3Outline(
// point to the first byte of the first scanline of the source char
- chardata = (uint8 *)(font + 1) + font->charXOffset[ drawchar ];
+ chardata = (uint8 *)(font + 1) + font->charXOffset[drawchar];
// get the width of the character in pixels
- charwidth = font->charWidth[ drawchar ];
+ charwidth = font->charWidth[drawchar];
// point to the first byte of where we want to place the character
@@ -633,24 +633,24 @@ void gPort::drawStringChars(
if (textStyles & textStyleOutline) { // if outlining
for (i = 0; i < len; i++) {
drawchar = *s++; // draw thick drop shadow
- x += font->charKern[ drawchar ];
+ x += font->charKern[drawchar];
DrawChar3x3Outline(font, drawchar, x, buffer, shPen, rowMod);
- x += font->charSpace[ drawchar ] + textSpacing;
+ x += font->charSpace[drawchar] + textSpacing;
}
} else if (textStyles & textStyleThickOutline) { // if outlining
for (i = 0; i < len; i++) {
drawchar = *s++; // draw thick drop shadow
- x += font->charKern[ drawchar ];
+ x += font->charKern[drawchar];
DrawChar5x5Outline(font, drawchar, x, buffer, shPen, rowMod);
- x += font->charSpace[ drawchar ] + textSpacing;
+ x += font->charSpace[drawchar] + textSpacing;
}
} else {
for (i = 0; i < len; i++) {
drawchar = *s++; // draw thick drop shadow
- x += font->charKern[ drawchar ];
+ x += font->charKern[drawchar];
DrawChar(font, drawchar, x, buffer + rowMod,
shPen, rowMod);
- x += font->charSpace[ drawchar ] + textSpacing;
+ x += font->charSpace[drawchar] + textSpacing;
}
}
}
@@ -663,10 +663,10 @@ void gPort::drawStringChars(
for (i = 0; i < len; i++) {
drawchar = *s++; // draw thick text
- x += font->charKern[ drawchar ];
+ x += font->charKern[drawchar];
DrawChar3x3Outline(font, drawchar, x, buffer - rowMod,
olPen, rowMod);
- x += font->charSpace[ drawchar ] + textSpacing;
+ x += font->charSpace[drawchar] + textSpacing;
}
} else if (textStyles & textStyleThickOutline) { // if thick outlining
x = xpos;
@@ -674,10 +674,10 @@ void gPort::drawStringChars(
for (i = 0; i < len; i++) {
drawchar = *s++; // draw extra thick text
- x += font->charKern[ drawchar ];
+ x += font->charKern[drawchar];
DrawChar5x5Outline(font, drawchar, x, buffer - rowMod * 2,
olPen, rowMod);
- x += font->charSpace[ drawchar ] + textSpacing;
+ x += font->charSpace[drawchar] + textSpacing;
}
}
@@ -698,9 +698,9 @@ void gPort::drawStringChars(
if (textStyles & textStyleUnderBar) underscore = TRUE;
if (textStyles & textStyleHiLiteBar) color = bgPen;
}
- x += font->charKern[ drawchar ];
+ x += font->charKern[drawchar];
DrawChar(font, drawchar, x, buffer, color, rowMod);
- x += font->charSpace[ drawchar ] + textSpacing;
+ x += font->charSpace[drawchar] + textSpacing;
if (underscore) { // draw underscore
uint8 *put = uBuffer + last_x;
@@ -739,15 +739,15 @@ int16 gPort::drawClippedString(
charwidth;
if (drawchar == '_' && underbar) {
- drawchar = s[ 1 ];
- charwidth = font->charKern[ drawchar ]
- + font->charSpace[ drawchar ] + textSpacing;
+ drawchar = s[1];
+ charwidth = font->charKern[drawchar]
+ + font->charSpace[drawchar] + textSpacing;
if (xpos + charwidth >= clip.x) break;
s++;
} else {
- charwidth = font->charKern[ drawchar ]
- + font->charSpace[ drawchar ] + textSpacing;
+ charwidth = font->charKern[drawchar]
+ + font->charSpace[drawchar] + textSpacing;
if (xpos + charwidth >= clip.x) break;
}
@@ -763,20 +763,20 @@ int16 gPort::drawClippedString(
// the right edge of the clip.
for (clipLen = 0; clipLen < len; clipLen++) {
- int16 drawchar = s[ clipLen ];
+ int16 drawchar = s[clipLen];
if (drawchar == '_' && underbar) continue;
- clipWidth += font->charKern[ drawchar ]
- + font->charSpace[ drawchar ] + textSpacing;
+ clipWidth += font->charKern[drawchar]
+ + font->charSpace[drawchar] + textSpacing;
if (xpos > clip.x + clip.width) break;
}
// Handle special case of negative kern value of 1st character
- if (font->charKern[ s[ 0 ] ] < 0) {
- int16 kern = - font->charKern[ s[ 0 ] ];
+ if (font->charKern[s[0]] < 0) {
+ int16 kern = - font->charKern[s[0]];
clipWidth += kern; // increase size of map to render
xoff += kern; // offset text into map right
@@ -886,12 +886,12 @@ int16 gPort::drawClippedString(
// penMove += clipWidth;
for (clipLen = 0; clipLen < len; clipLen++) {
- int16 drawchar = s[ clipLen ];
+ int16 drawchar = s[clipLen];
if (drawchar == '_' && underbar) continue;
- penMove += font->charKern[ drawchar ]
- + font->charSpace[ drawchar ] + textSpacing;
+ penMove += font->charKern[drawchar]
+ + font->charSpace[drawchar] + textSpacing;
}
return penMove;
@@ -1078,7 +1078,7 @@ int16 TextWidth(gFont *font, const char *s, int16 length, int16 styles) {
if (chr == '_' && (styles & textStyleBar)) continue;
- count += font->charKern[ chr ] + font->charSpace[ chr ];
+ count += font->charKern[chr] + font->charSpace[chr];
}
if (styles & textStyleItalics) {
@@ -1131,7 +1131,7 @@ int16 WhichChar(gFont *font, uint8 *s, int16 length, int16 maxLen) {
for (count = 0; count < maxLen; count++) {
uint8 chr = *s++;
- length -= font->charKern[ chr ] + font->charSpace[ chr ];
+ length -= font->charKern[chr] + font->charSpace[chr];
if (length < 0) break;
}
return count;
@@ -1181,7 +1181,7 @@ int16 WhichIChar(gFont *font, uint8 *s, int16 length, int16 maxLen) {
uint8 chr = *s++;
int16 width;
- width = font->charKern[ chr ] + font->charSpace[ chr ];
+ width = font->charKern[chr] + font->charSpace[chr];
if (length < width / 2) break;
length -= width;
@@ -1292,7 +1292,7 @@ int16 X_TextWrap(
pixel_len, // pixel length of line
line_count = 0; // number of lines
- lines[ line_count ] = text;
+ lines[line_count] = text;
last_space = -1;
line_start = 0;
pixel_len = 0;
@@ -1300,17 +1300,17 @@ int16 X_TextWrap(
// For each character in the string, check for word wrap
for (i = 0; ; i++) {
- uint8 c = text[ i ];
+ uint8 c = text[i];
if (c == '\n' || c == '\r' || c == '\0') { // if deliberate end of line
- line_chars[ line_count ] = i - line_start; //
- line_pixels[ line_count ] = pixel_len;
+ line_chars[line_count] = i - line_start; //
+ line_pixels[line_count] = pixel_len;
line_start = i + 1;
if (c == '\0') {
line_count++;
break;
}
- lines[ ++line_count ] = &text[ line_start ];
+ lines[++line_count] = &text[line_start];
last_space = -1;
pixel_len = 0;
continue;
@@ -1320,13 +1320,13 @@ int16 X_TextWrap(
}
pixel_len +=
- font->char_kern[ c ] + font->char_space[ c ];
+ font->char_kern[c] + font->char_space[c];
if (pixel_len > width - 2 && last_space > 0) {
- line_chars[ line_count ] = last_space - line_start;
- line_pixels[ line_count ] = last_space_pixels;
+ line_chars[line_count] = last_space - line_start;
+ line_pixels[line_count] = last_space_pixels;
line_start = last_space + 1;
- lines[ ++line_count ] = &text[ line_start ];
+ lines[++line_count] = &text[line_start];
last_space = -1;
pixel_len = 0;
@@ -1347,10 +1347,10 @@ void XS_DrawTextWrapped(
int16 i, // loop counter
line_count = 0; // number of lines
- char *lines[ 10 ]; // pointer to each line
+ char *lines[10]; // pointer to each line
- int16 line_chars[ 10 ], // # of chars in line
- line_pixels[ 10 ], // # of pixels in line
+ int16 line_chars[10], // # of chars in line
+ line_pixels[10], // # of pixels in line
ypos = box->Top, // top of box
row_height;
int16 save_flags = x_DrawFlags;
@@ -1371,8 +1371,8 @@ void XS_DrawTextWrapped(
for (i = 0; i < line_count; i++) {
DrawFixedString(dest,
- lines[ i ], line_chars[ i ],
- box->Left + (box->Width - line_pixels[ i ]) / 2 + 1,
+ lines[i], line_chars[i],
+ box->Left + (box->Width - line_pixels[i]) / 2 + 1,
ypos,
text_color, outline_color, 0);
@@ -1391,10 +1391,10 @@ int16 X_WrappedTextHeight(
) {
int16 line_count = 0; // number of lines
- char *lines[ 10 ]; // pointer to each line
+ char *lines[10]; // pointer to each line
- int16 line_chars[ 10 ], // # of chars in line
- line_pixels[ 10 ], // # of pixels in line
+ int16 line_chars[10], // # of chars in line
+ line_pixels[10], // # of pixels in line
row_height;
line_count = X_TextWrap(lines, line_chars, line_pixels,
diff --git a/engines/saga2/gtextbox.cpp b/engines/saga2/gtextbox.cpp
index e847a182ab..aeb39db208 100644
--- a/engines/saga2/gtextbox.cpp
+++ b/engines/saga2/gtextbox.cpp
@@ -179,7 +179,7 @@ gTextBox::gTextBox(
index = 0; // index into string array ( which string )
maxLen = length;
flags = flg;
- currentLen[ index ] = buffer ? strlen(buffer) : 0;
+ currentLen[index] = buffer ? strlen(buffer) : 0;
cursorPos = anchorPos = scrollPixels = 0;
undoBuffer = (char *)malloc(sizeof(char) * (maxLen + 1));
textFont = font;
@@ -213,7 +213,7 @@ gTextBox::gTextBox(
for (i = 0; i < numEditLines; i++) {
exists[i] = ((stringBufs[i][0] & 0x80) == 0);
stringBufs[i][0] &= 0x7F;
- currentLen[ i ] = MIN<int>(editLen, strlen(stringBufs[ i ]));
+ currentLen[i] = MIN<int>(editLen, strlen(stringBufs[i]));
}
internalBuffer = FALSE;
@@ -222,7 +222,7 @@ gTextBox::gTextBox(
enSelect(0);
if (!displayOnly) {
cursorPos = 0;
- anchorPos = currentLen[ index ];
+ anchorPos = currentLen[index];
}
fullRedraw = TRUE;
}
@@ -273,28 +273,28 @@ bool gTextBox::insertText(char *newText, int length) {
// If inserting the text would make the string too long,
// then don't insert it.
- if (currentLen[ index ] - selWidth + length >= maxLen) return FALSE;
+ if (currentLen[index] - selWidth + length >= maxLen) return FALSE;
// Move the text after the selection to where it will be
// after the insertion.
- if (selEnd < currentLen[ index ]) {
- memmove(fieldStrings[ index ] + selStart + length,
- fieldStrings[ index ] + selEnd,
- currentLen[ index ] - selEnd);
+ if (selEnd < currentLen[index]) {
+ memmove(fieldStrings[index] + selStart + length,
+ fieldStrings[index] + selEnd,
+ currentLen[index] - selEnd);
}
// Move the inserted text, if any, to the opening
if (length > 0) {
- memmove(fieldStrings[ index ] + selStart, newText, length);
+ memmove(fieldStrings[index] + selStart, newText, length);
}
// Set the insertion point to the end of the new text.
cursorPos = anchorPos = selStart + length;
- currentLen[ index ] += (length - selWidth);
- fieldStrings[ index ][ currentLen[ index ] ] = '\0';
+ currentLen[index] += (length - selWidth);
+ fieldStrings[index][currentLen[index]] = '\0';
RMemIntegrity();
@@ -328,7 +328,7 @@ void gTextBox::setText(char *newText) {
int16 len = MIN((int)(strlen(newText)), (int)(maxLen - 1));
cursorPos = 0;
- anchorPos = currentLen[ index ];
+ anchorPos = currentLen[index];
insertText(newText, len);
cursorPos = anchorPos = 0;
@@ -382,8 +382,8 @@ void gTextBox::deactivate(void) {
void gTextBox::prepareEdit(int which) {
if (!displayOnly) {
- if (undoBuffer) memcpy(undoBuffer, fieldStrings[ which ], currentLen[ which ] + 1);
- undoLen = currentLen[ which ];
+ if (undoBuffer) memcpy(undoBuffer, fieldStrings[which], currentLen[which] + 1);
+ undoLen = currentLen[which];
}
}
@@ -391,7 +391,7 @@ void gTextBox::prepareEdit(int which) {
bool gTextBox::changed(void) {
if (undoBuffer && editing) {
- return memcmp(undoBuffer, fieldStrings[ index ], currentLen[ index ] + 1);
+ return memcmp(undoBuffer, fieldStrings[index], currentLen[index] + 1);
}
return FALSE;
}
@@ -400,9 +400,9 @@ bool gTextBox::changed(void) {
void gTextBox::commitEdit(void) {
if (undoBuffer && changed()) {
- memcpy(undoBuffer, fieldStrings[ index ], currentLen[ index ] + 1);
- undoLen = currentLen[ index ];
- cursorPos = anchorPos = currentLen[ index ];
+ memcpy(undoBuffer, fieldStrings[index], currentLen[index] + 1);
+ undoLen = currentLen[index];
+ cursorPos = anchorPos = currentLen[index];
notify(gEventNewValue, 1); // tell app about new value
}
}
@@ -412,8 +412,8 @@ void gTextBox::commitEdit(void) {
void gTextBox::revertEdit(void) {
if (undoBuffer && changed()) {
- cursorPos = anchorPos = currentLen[ index ] = undoLen;
- memcpy(fieldStrings[ index ], undoBuffer, currentLen[ index ] + 1);
+ cursorPos = anchorPos = currentLen[index] = undoLen;
+ memcpy(fieldStrings[index], undoBuffer, currentLen[index] + 1);
notify(gEventNewValue, 0); // tell app about new value
}
}
@@ -490,7 +490,7 @@ void gTextBox::enSelect(int which) {
prepareEdit(which);
editing = TRUE;
cursorPos = 0;
- anchorPos = currentLen[ index ];
+ anchorPos = currentLen[index];
} else {
hilit = TRUE;
}
@@ -540,7 +540,7 @@ void gTextBox::selectionMove(int howMany) {
reSelect(newIndex);
if (!displayOnly) {
cursorPos = 0;
- anchorPos = currentLen[ index ];
+ anchorPos = currentLen[index];
}
draw();
@@ -582,9 +582,9 @@ bool gTextBox::pointerHit(gPanelMessage &msg) {
reSelect(newIndex);
if (editing) {
if (textFont) {
- newPos = WhichIChar(textFont, (uint8 *)fieldStrings[ index ], msg.pickPos.x - 3, currentLen[ index ]);
+ newPos = WhichIChar(textFont, (uint8 *)fieldStrings[index], msg.pickPos.x - 3, currentLen[index]);
} else {
- newPos = WhichIChar(mainFont, (uint8 *)fieldStrings[ index ], msg.pickPos.x - 3, currentLen[ index ]);
+ newPos = WhichIChar(mainFont, (uint8 *)fieldStrings[index], msg.pickPos.x - 3, currentLen[index]);
}
if (msg.leftButton) {
if (cursorPos != newPos || anchorPos != newPos) {
@@ -612,9 +612,9 @@ void gTextBox::pointerDrag(gPanelMessage &msg) {
if (msg.leftButton) {
if (textFont) {
- newPos = WhichIChar(textFont, (uint8 *)fieldStrings[ index ], msg.pickPos.x - 3, currentLen[ index ]);
+ newPos = WhichIChar(textFont, (uint8 *)fieldStrings[index], msg.pickPos.x - 3, currentLen[index]);
} else {
- newPos = WhichIChar(mainFont, (uint8 *)fieldStrings[ index ], msg.pickPos.x - 3, currentLen[ index ]);
+ newPos = WhichIChar(mainFont, (uint8 *)fieldStrings[index], msg.pickPos.x - 3, currentLen[index]);
}
inDrag = TRUE;
if (cursorPos != newPos) {
@@ -687,7 +687,7 @@ bool gTextBox::keyStroke(gPanelMessage &msg) {
case SpecialKey(rightArrowKey):
- if (anchorPos < currentLen[ index ]) anchorPos++;
+ if (anchorPos < currentLen[index]) anchorPos++;
if (!(msg.qualifier & qualifierShift)) cursorPos = anchorPos;
break;
@@ -697,33 +697,33 @@ bool gTextBox::keyStroke(gPanelMessage &msg) {
break;
case SpecialKey(endKey):
- cursorPos = currentLen[ index ];
- anchorPos = currentLen[ index ];
+ cursorPos = currentLen[index];
+ anchorPos = currentLen[index];
break;
case SpecialKey(deleteKey): // DELETE character
if (selWidth == 0) { // if insertion point
// don't delete if at end
- if (selStart >= currentLen[ index ]) return FALSE;
+ if (selStart >= currentLen[index]) return FALSE;
selWidth = 1; // delete 1 char
}
// Delete N chars
- memmove(fieldStrings[ index ] + selStart,
- fieldStrings[ index ] + selStart + selWidth,
- currentLen[ index ] - (selStart + selWidth));
+ memmove(fieldStrings[index] + selStart,
+ fieldStrings[index] + selStart + selWidth,
+ currentLen[index] - (selStart + selWidth));
cursorPos = anchorPos = selStart;// adjust cursor pos
- currentLen[ index ] -= selWidth; // adjust str len
+ currentLen[index] -= selWidth; // adjust str len
notify(gEventAltValue, 0); // tell app about new value
break;
case SpecialKey(0x2c00): // Alt-Z
if (undoBuffer) {
- cursorPos = anchorPos = currentLen[ index ] = undoLen;
- memcpy(fieldStrings[ index ], undoBuffer, currentLen[ index ] + 1);
+ cursorPos = anchorPos = currentLen[index] = undoLen;
+ memcpy(fieldStrings[index], undoBuffer, currentLen[index] + 1);
notify(gEventAltValue, 0); // tell app about new value
}
break;
@@ -772,32 +772,32 @@ bool gTextBox::keyStroke(gPanelMessage &msg) {
// Delete N chars
- memmove(fieldStrings[ index ] + selStart,
- fieldStrings[ index ] + selStart + selWidth,
- currentLen[ index ] - (selStart + selWidth));
+ memmove(fieldStrings[index] + selStart,
+ fieldStrings[index] + selStart + selWidth,
+ currentLen[index] - (selStart + selWidth));
cursorPos = anchorPos = selStart; // adjust cursor pos
- currentLen[ index ] -= selWidth; // adjust str len
+ currentLen[index] -= selWidth; // adjust str len
notify(gEventAltValue, 0); // tell app about new value
} else if (key == SpecialKey(deleteKey) && editing) { // DELETE character
if (selWidth == 0) { // if insertion point
// don't delete if at end
- if (selStart >= currentLen[ index ]) return FALSE;
+ if (selStart >= currentLen[index]) return FALSE;
selWidth = 1; // delete 1 char
}
// Delete N chars
- memmove(fieldStrings[ index ] + selStart,
- fieldStrings[ index ] + selStart + selWidth,
- currentLen[ index ] - (selStart + selWidth));
+ memmove(fieldStrings[index] + selStart,
+ fieldStrings[index] + selStart + selWidth,
+ currentLen[index] - (selStart + selWidth));
cursorPos = anchorPos = selStart; // adjust cursor pos
- currentLen[ index ] -= selWidth; // adjust str len
+ currentLen[index] -= selWidth; // adjust str len
notify(gEventAltValue, 0); // tell app about new value
} else if (key == '\t' && editing) return FALSE; // reprocess keystroke
else if (key == 26 && editing) { // control-z
if (undoBuffer) {
- cursorPos = anchorPos = currentLen[ index ] = undoLen;
- memcpy(fieldStrings[ index ], undoBuffer, currentLen[ index ] + 1);
+ cursorPos = anchorPos = currentLen[index] = undoLen;
+ memcpy(fieldStrings[index], undoBuffer, currentLen[index] + 1);
notify(gEventAltValue, 0); // tell app about new value
}
} else if (editing) {
@@ -808,7 +808,7 @@ bool gTextBox::keyStroke(gPanelMessage &msg) {
}
if (editing) {
- fieldStrings[ index ][ currentLen[ index ] ] = '\0';
+ fieldStrings[index][currentLen[index]] = '\0';
// Now, redraw the contents.
@@ -839,14 +839,14 @@ bool gTextBox::tabSelect(void) {
char *gTextBox::getLine(int8 stringIndex) {
// return the save name
- return fieldStrings[ stringIndex ];
+ return fieldStrings[stringIndex];
}
//-----------------------------------------------------------------------
char *gTextBox::selectedText(int &length) {
length = abs(cursorPos - anchorPos);
- return fieldStrings[ index ] + MIN(cursorPos, anchorPos);
+ return fieldStrings[index] + MIN(cursorPos, anchorPos);
}
//-----------------------------------------------------------------------
@@ -931,19 +931,19 @@ void gTextBox::drawContents(void) {
if (cPos == aPos) {
// If it's an insertion point, then make the cursor
// 1 pixel wide. (And blink it...)
- cursorX = TextWidth(textFont, fieldStrings[ index ], cPos, 0);
+ cursorX = TextWidth(textFont, fieldStrings[index], cPos, 0);
anchorX = cursorX + 1;
} else {
if (cPos == 0) {
cursorX = 0;
} else {
- cursorX = TextWidth(textFont, fieldStrings[ index ], cPos, 0) + 1;
+ cursorX = TextWidth(textFont, fieldStrings[index], cPos, 0) + 1;
}
if (aPos == 0) {
anchorX = 0;
} else {
- anchorX = TextWidth(textFont, fieldStrings[ index ], aPos, 0) + 1;
+ anchorX = TextWidth(textFont, fieldStrings[index], aPos, 0) + 1;
}
}
@@ -966,8 +966,8 @@ void gTextBox::drawContents(void) {
// the end in the highlight.
if (cPos != aPos) {
- if (cPos == currentLen[ index ]) cursorX = editRect.width;
- if (aPos == currentLen[ index ]) anchorX = editRect.width;
+ if (cPos == currentLen[index]) cursorX = editRect.width;
+ if (aPos == currentLen[index]) anchorX = editRect.width;
}
#endif
hiliteX = MIN(cursorX, anchorX);
@@ -983,7 +983,7 @@ void gTextBox::drawContents(void) {
tPort.setColor(fontColorHilite);
tPort.moveTo(-scrollPixels, (editRect.height - textHeight + 1) / 2);
- tPort.drawText(fieldStrings[ index ], currentLen[ index ]);
+ tPort.drawText(fieldStrings[index], currentLen[index]);
// Blit the pixelmap to the main screen
@@ -1091,7 +1091,7 @@ void gTextBox::drawAll(gPort &port,
tempPort.setColor(((i != index) && exists[i]) ? fontColorFore : textDisable);
// draw the text
- tempPort.drawText(fieldStrings[ i ]);
+ tempPort.drawText(fieldStrings[i]);
//increment the position
workRect.y += fontOffset;
diff --git a/engines/saga2/gtextbox.h b/engines/saga2/gtextbox.h
index 1159fab1f7..497b2eb09d 100644
--- a/engines/saga2/gtextbox.h
+++ b/engines/saga2/gtextbox.h
@@ -71,8 +71,8 @@ private:
// editor values
uint16 maxLen,
- currentLen[ numEditLines ],
- exists[ numEditLines ],
+ currentLen[numEditLines],
+ exists[numEditLines],
undoLen,
cursorPos,
anchorPos,
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index d6d7796d3f..2f28d15ee9 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -462,7 +462,7 @@ RHANDLE hResContext::loadIndex(int16 index, const char desc[], bool cacheable) {
_bytecount = 0;
_bytepos = 0;
- entry = &_base[ index ];
+ entry = &_base[index];
if (*capture != nullptr && **capture != nullptr) {
entry->use();
diff --git a/engines/saga2/idtypes.h b/engines/saga2/idtypes.h
index 438f81cf0f..c611c21a39 100644
--- a/engines/saga2/idtypes.h
+++ b/engines/saga2/idtypes.h
@@ -225,7 +225,7 @@ typedef uint16 weaponID;
typedef uint32 hResID;
-typedef uint8 ColorTable[ 256 ];
+typedef uint8 ColorTable[256];
// number of containers
const int kNumViews = 3;
diff --git a/engines/saga2/imagcach.cpp b/engines/saga2/imagcach.cpp
index e5626ba2e6..6e899b1b03 100644
--- a/engines/saga2/imagcach.cpp
+++ b/engines/saga2/imagcach.cpp
@@ -39,7 +39,7 @@ extern char *idname(long s);
CImageNode::CImageNode(hResContext *con, uint32 resID) {
if (con) {
#if DEBUG
- char descr[ 32 ];
+ char descr[32];
sprintf(descr, "CImage '%s'", idname(resID));
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index ae585c21a8..50423d3efc 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -281,10 +281,10 @@ uint8 *byteAddress(Thread *th, uint8 **pcPtr) {
IMMED_WORD(offset);
arg = (uint16 *)(th->stackBase + th->framePtr + 8);
*pcPtr = pc;
- if (arg[ 0 ] == dataSegIndex)
- return &dataSegment[arg[ 1 ] + offset];
- return segmentArrayAddress(arg[ 0 ],
- arg[ 1 ]) + offset;
+ if (arg[0] == dataSegIndex)
+ return &dataSegment[arg[1] + offset];
+ return segmentArrayAddress(arg[0],
+ arg[1]) + offset;
case addr_deref:
@@ -349,8 +349,8 @@ uint8 *objectAddress(
case addr_this:
IMMED_WORD(offset);
arg = (uint16 *)(th->stackBase + th->framePtr + 8);
- seg = arg[ 0 ];
- index = arg[ 1 ];
+ seg = arg[0];
+ index = arg[1];
if (seg == dataSegIndex)
return &dataSegment[index + offset];
addr = segmentArrayAddress(seg, index) + offset;
@@ -508,12 +508,12 @@ int16 RRandom(int16 c, int16 s, int16 id) {
* ============================================================================ */
void print_script_name(uint8 *codePtr, char *descr = NULL) {
- char scriptName[ 32 ];
+ char scriptName[32];
uint8 *sym = codePtr - 1;
uint8 length = MIN<uint>(*sym, sizeof scriptName - 1);
memcpy(scriptName, sym - *sym, length);
- scriptName[ length ] = '\0';
+ scriptName[length] = '\0';
if (descr)
debugC(1, kDebugScripts, "Scripts: %d op_enter: [%s].%s ", lastExport, descr, scriptName);
@@ -522,7 +522,7 @@ void print_script_name(uint8 *codePtr, char *descr = NULL) {
}
char *objectName(int16 segNum, uint16 segOff) {
- //static nameBuf[ 64 ];
+ //static nameBuf[64];
uint8 *objAddr;
if (segNum >= 0)
@@ -571,7 +571,7 @@ bool Thread::interpret(void) {
// break;
case op_dup:
- *--stack = stack[ 0 ]; // duplicate value on stack
+ *--stack = stack[0]; // duplicate value on stack
break;
case op_drop: // drop word on stack
@@ -747,7 +747,7 @@ bool Thread::interpret(void) {
if (w < 0 || w >= globalCFuncs.numEntries)
error("Invalid function number");
- cfunc = globalCFuncs.table[ w ];
+ cfunc = globalCFuncs.table[w];
argCount = n;
returnVal = cfunc(stack); // call the function
@@ -790,15 +790,15 @@ bool Thread::interpret(void) {
if ((int16)seg < 0) {
vtable = builtinVTableAddress((int16)seg, addr, &callTab);
} else {
- vtable = (uint16 *)segmentAddress(((int16 *)addr)[ 0 ],
- ((int16 *)addr)[ 1 ]);
+ vtable = (uint16 *)segmentAddress(((int16 *)addr)[0],
+ ((int16 *)addr)[1]);
}
vtableEntry = vtable + (w * 2);
if (vtable == NULL) {
// Do nothing...
- } else if (vtableEntry[ 0 ] != 0xffff) { // It's a SAGA func
+ } else if (vtableEntry[0] != 0xffff) { // It's a SAGA func
programCounter.offset = (pc - codeSeg);
// Push the address of the object
@@ -814,24 +814,24 @@ bool Thread::interpret(void) {
// Get the segment of the member function, and
// determine it's real address (save segment number
// into thread).
- w = vtableEntry[ 0 ];
+ w = vtableEntry[0];
programCounter.segment = w;
//RUnlockHandle((RHANDLE)codeSeg);
codeSeg = scriptRes->loadIndexResource(w, "saga code segment");
// store pc-offset into pc
- programCounter.offset = vtableEntry[ 1 ];
+ programCounter.offset = vtableEntry[1];
// calculate PC address
pc = (codeSeg) + programCounter.offset;
print_script_name(pc, objectName(seg, offset));
break;
- } else if (vtableEntry[ 1 ] != 0xffff) { // It's a C func
+ } else if (vtableEntry[1] != 0xffff) { // It's a C func
// Save the ID of the invoked object
ObjectID saveID = threadArgs.invokedObject;
// Get the function number
- w = vtableEntry[ 1 ];
+ w = vtableEntry[1];
if (w < 0 || w >= callTab->numEntries)
error("Invalid member function number");
@@ -841,7 +841,7 @@ bool Thread::interpret(void) {
threadArgs.invokedObject = offset;
// Get address of function and call it.
- cfunc = callTab->table[ w ];
+ cfunc = callTab->table[w];
returnVal = cfunc(stack); // call the function
// Restore object ID from thread args
@@ -998,79 +998,79 @@ bool Thread::interpret(void) {
// dropped variable.
case op_add:
- w = (stack[ 1 ] + stack [ 0 ]);
+ w = (stack[1] + stack [0]);
*++stack = w;
break;
case op_sub:
- w = (stack[ 1 ] - stack [ 0 ]);
+ w = (stack[1] - stack [0]);
*++stack = w;
break;
case op_mul:
- w = (stack[ 1 ] * stack [ 0 ]);
+ w = (stack[1] * stack [0]);
*++stack = w;
break;
case op_div:
- w = (stack[ 1 ] / stack [ 0 ]);
+ w = (stack[1] / stack [0]);
*++stack = w;
break;
case op_mod:
- w = (stack[ 1 ] % stack [ 0 ]);
+ w = (stack[1] % stack [0]);
*++stack = w;
break;
case op_eq:
- w = (stack[ 1 ] == stack [ 0 ]);
+ w = (stack[1] == stack [0]);
*++stack = w;
break;
case op_ne:
- w = (stack[ 1 ] != stack [ 0 ]);
+ w = (stack[1] != stack [0]);
*++stack = w;
break;
case op_gt:
- w = (stack[ 1 ] > stack [ 0 ]);
+ w = (stack[1] > stack [0]);
*++stack = w;
break;
case op_lt:
- w = (stack[ 1 ] < stack [ 0 ]);
+ w = (stack[1] < stack [0]);
*++stack = w;
break;
case op_ge:
- w = (stack[ 1 ] >= stack [ 0 ]);
+ w = (stack[1] >= stack [0]);
*++stack = w;
break;
case op_le:
- w = (stack[ 1 ] <= stack [ 0 ]);
+ w = (stack[1] <= stack [0]);
*++stack = w;
break;
case op_rsh:
- w = (stack[ 1 ] >> stack [ 0 ]);
+ w = (stack[1] >> stack [0]);
*++stack = w;
break;
case op_lsh:
- w = (stack[ 1 ] << stack [ 0 ]);
+ w = (stack[1] << stack [0]);
*++stack = w;
break;
case op_and:
- w = (stack[ 1 ] & stack [ 0 ]);
+ w = (stack[1] & stack [0]);
*++stack = w;
break;
case op_or:
- w = (stack[ 1 ] | stack [ 0 ]);
+ w = (stack[1] | stack [0]);
*++stack = w;
break;
case op_xor:
- w = (stack[ 1 ] ^ stack [ 0 ]);
+ w = (stack[1] ^ stack [0]);
*++stack = w;
break;
case op_land:
- w = (stack[ 1 ] && stack [ 0 ]);
+ w = (stack[1] && stack [0]);
*++stack = w;
break;
case op_lor:
- w = (stack[ 1 ] || stack [ 0 ]);
+ w = (stack[1] || stack [0]);
*++stack = w;
break;
case op_lxor:
- w = (stack[ 1 ] && !stack [ 0 ]) || (!stack[ 1 ] && stack[ 0 ]);
+ w = (stack[1] && !stack [0]) || (!stack[1] && stack[0 ]);
*++stack = w;
break;
@@ -1113,7 +1113,7 @@ bool Thread::interpret(void) {
class ThreadList {
struct ThreadPlaceHolder : public DNode {
- uint8 buf[ sizeof(Thread) ];
+ uint8 buf[sizeof(Thread)];
Thread *getThread(void) {
return (Thread *)&buf;
@@ -1123,7 +1123,7 @@ class ThreadList {
DList list, // List of active Threads
free; // List of available Threads
- ThreadPlaceHolder array[ 32 ]; // Memory buffer for thread
+ ThreadPlaceHolder array[32]; // Memory buffer for thread
// instantiation
public:
@@ -1163,7 +1163,7 @@ public:
// Return a pointer to a thread, given an ID
Thread *getThreadAddress(ThreadID id) {
assert(id >= 0 && id < elementsof(array));
- return array[ id ].getThread();
+ return array[id].getThread();
}
// Return a pointer to the first active thread
@@ -1180,7 +1180,7 @@ ThreadList::ThreadList(void) {
int i;
for (i = 0; i < elementsof(array); i++)
- free.addTail(array[ i ]);
+ free.addTail(array[i]);
}
//-------------------------------------------------------------------
@@ -1302,7 +1302,7 @@ void *ThreadList::newThread(ThreadID id) {
ThreadPlaceHolder *tp;
// Grab the thread place holder from the inactive list
- tp = (ThreadPlaceHolder *)&array[ id ];
+ tp = (ThreadPlaceHolder *)&array[id];
tp->remove();
// Place the place holder into the active list
@@ -1364,7 +1364,7 @@ Thread *ThreadList::next(Thread *thread) {
// constructor from being called until it is explicitly called with
// the overloaded new operator.
-static uint8 threadListBuffer[ sizeof(ThreadList) ];
+static uint8 threadListBuffer[sizeof(ThreadList)];
static ThreadList &threadList = *((ThreadList *)threadListBuffer);
/* ============================================================================ *
@@ -1496,17 +1496,17 @@ Thread::Thread(uint16 segNum, uint16 segOff, scriptCallFrame &args) {
threadArgs = args;
stackBase = (UBytePtr)malloc(stackSize);
stackPtr = stackBase + stackSize - initialStackFrameSize;
- ((uint16 *)stackPtr)[ 0 ] = 0; // 0 args
- ((uint16 *)stackPtr)[ 1 ] = 0; // dummy return address
- ((uint16 *)stackPtr)[ 2 ] = 0; // dummy return address
+ ((uint16 *)stackPtr)[0] = 0; // 0 args
+ ((uint16 *)stackPtr)[1] = 0; // dummy return address
+ ((uint16 *)stackPtr)[2] = 0; // dummy return address
framePtr = stackSize;
_valid = true;
- if ((codeSeg)[ programCounter.offset ] != op_enter) {
+ if ((codeSeg)[programCounter.offset] != op_enter) {
//warning("SAGA failure: Invalid script entry point (export=%d) [segment=%d:%d]\n", lastExport, segNum, segOff);
_valid = false;
}
-// assert ((codeSeg)[ programCounter.offset ] == op_enter);
+// assert ((codeSeg)[programCounter.offset] == op_enter);
}
//-----------------------------------------------------------------------
@@ -1901,21 +1901,21 @@ scriptResult runMethod(
vTable = (uint16 *)
segmentAddress(segNum, segOff + methodNum * sizeof(uint32));
- segNum = vTable[ 0 ];
- segOff = vTable[ 1 ];
+ segNum = vTable[0];
+ segOff = vTable[1];
if (segNum == 0xffff) { // it's a CFUNC or NULL func
if (segOff == 0xffff) { // it's a NULL function
return scriptResultNoScript;
} else { // It's a C function
int16 funcNum = segOff; // function number
- int16 stack[ 1 ]; // dummy stack argument
+ int16 stack[1]; // dummy stack argument
C_Call *cfunc;
// Make sure the C function number is OK
assert(funcNum >= 0);
assert(funcNum < globalCFuncs.numEntries);
- cfunc = globalCFuncs.table[ funcNum ];
+ cfunc = globalCFuncs.table[funcNum];
// Build a temporary dummy thread
th = new Thread(0, 0, args);
@@ -1942,8 +1942,8 @@ scriptResult runMethod(
print_script_name((th->codeSeg) + th->programCounter.offset, objectName(bType, index));
// Put the object segment and ID onto the dummy stack frame
- ((uint16 *)th->stackPtr)[ 3 ] = bType;
- ((uint16 *)th->stackPtr)[ 4 ] = index;
+ ((uint16 *)th->stackPtr)[3] = bType;
+ ((uint16 *)th->stackPtr)[4] = index;
// Run the thread to completion
result = th->run();
diff --git a/engines/saga2/intrface.h b/engines/saga2/intrface.h
index 8525e9a074..3e5fcc1adf 100644
--- a/engines/saga2/intrface.h
+++ b/engines/saga2/intrface.h
@@ -192,7 +192,7 @@ protected:
};
- char lineBuf[ bufSize ]; // text to render on button
+ char lineBuf[bufSize]; // text to render on button
textPallete textFacePal; // contains info about coloring for multi-depth text rendering
Rect16 textRect; // rect for the text
int16 textPosition;
@@ -231,7 +231,7 @@ private:
struct {
char *text;
uint32 frameTime;
- } lineQueue[ 12 ];
+ } lineQueue[12];
uint8 queueHead,
queueTail;
@@ -270,7 +270,7 @@ enum PortraitType {
class CPortrait {
private:
- PortraitType currentState[ kNumViews + 1 ];
+ PortraitType currentState[kNumViews + 1];
uint16 numButtons;
uint16 _numViews;
gMultCompButton **buttons;
@@ -285,7 +285,7 @@ public:
void ORset(uint16, PortraitType type);
void set(uint16 brotherID, PortraitType type);
PortraitType getCurrentState(uint16 brotherID) {
- return currentState[ brotherID ];
+ return currentState[brotherID];
}
void getStateString(char buf[], int8 size, uint16 brotherID);
};
@@ -509,17 +509,17 @@ private:
gPixelMap savedMap;
// array of manaLine infos for blitting
- manaLineInfo manaLines[ numManaTypes ];
+ manaLineInfo manaLines[numManaTypes];
// array of ring and star end positions
// this is initialized via constructor
- Point16 starRingEndPos[ numManaTypes ];
+ Point16 starRingEndPos[numManaTypes];
- Point16 starSizes[ numStars ];
- Point16 ringSizes[ numRings ];
+ Point16 starSizes[numStars];
+ Point16 ringSizes[numRings];
// these are checks against redundent updates
- int32 currentMana[ numManaTypes ], currentBaseMana[ numManaTypes ];
+ int32 currentMana[numManaTypes], currentBaseMana[numManaTypes];
protected:
// these do line and position calculations
@@ -590,7 +590,7 @@ private:
hResContext *healthRes;
// buttons
- gCompImage *starBtns[ numControls ];
+ gCompImage *starBtns[numControls];
gCompImage *indivStarBtn;
// array of pointer to the star imagery
@@ -602,8 +602,8 @@ private:
void updateStar(gCompImage *starCtl, int32 bro, int32 baseVitality, int32 curVitality);
public:
- uint16 starIDs[ 3 ];
- int16 imageIndexMemory[ 4 ];
+ uint16 starIDs[3];
+ int16 imageIndexMemory[4];
public:
diff --git a/engines/saga2/keybored.cpp b/engines/saga2/keybored.cpp
index 1f7ddb8dd9..e3672f8c41 100644
--- a/engines/saga2/keybored.cpp
+++ b/engines/saga2/keybored.cpp
@@ -354,7 +354,7 @@ void TileModeHandleKey(int16 key, int16 /* qual */) {
//writeStatusFX = 468;
//mapSizeU++;
//sumNum++;
- playerList[ 0 ].skillAdvance(eBrawn, 200);
+ playerList[0].skillAdvance(eBrawn, 200);
break;
case '=':
@@ -363,7 +363,7 @@ void TileModeHandleKey(int16 key, int16 /* qual */) {
case '`':
//StatusLine->setLine( "Goblins, and Ogres, and Giants, oh my!" );
- playerList[ 0 ].skillAdvance(eBrawn, 1);
+ playerList[0].skillAdvance(eBrawn, 1);
break;
@@ -372,15 +372,15 @@ void TileModeHandleKey(int16 key, int16 /* qual */) {
//( ( Actor * )GameObject::objectAddress( 32768 ) )->effectiveStats.redMana -= 10;
//( ( Actor * )GameObject::objectAddress( 32768 ) )->effectiveStats.vitality -= 10;
//( ( Actor * )GameObject::objectAddress( 32768 ) )->effectiveStats.brawn -= 10;
- playerList[ 0 ].setTestBrawn();
+ playerList[0].setTestBrawn();
break;
case 'y':
- playerList[ 0 ].recBrawnSome();
+ playerList[0].recBrawnSome();
break;
case 'c':
- playerList[ 0 ].decBrawnSome();
+ playerList[0].decBrawnSome();
break;
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 5e00727bbf..aad26514bc 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -464,7 +464,7 @@ bool readCommandLine(int argc, char *argv[]) {
// Mouse handling
gMouseState prevState;
-MouseExtState mouseQueue[ 64 ];
+MouseExtState mouseQueue[64];
int16 queueIn = 0,
queueOut = 0;
@@ -523,12 +523,12 @@ void *LoadFile(char *filename, const char desc[]) {
// Loads a resource into a buffer and returns a pointer
void *LoadResource(hResContext *con, uint32 id, const char desc[]) {
- uint32 idString[ 2 ];
+ uint32 idString[2];
int32 size;
uint8 *buffer; // allocated buffer
- idString[ 0 ] = id;
- idString[ 1 ] = 0;
+ idString[0] = id;
+ idString[1] = 0;
debugC(3, kDebugResources, "Loading resource %d (%s, %s)", id, tag2str(id), desc);
size = con->size(id);
@@ -548,12 +548,12 @@ void *LoadResource(hResContext *con, uint32 id, const char desc[]) {
// Loads a resource into a relocatable buffer and returns a handle
RHANDLE LoadResourceToHandle(hResContext *con, uint32 id, const char desc[]) {
- uint32 idString[ 2 ];
+ uint32 idString[2];
int32 size;
RHANDLE buffer; // allocated buffer
- idString[ 0 ] = id;
- idString[ 1 ] = 0;
+ idString[0] = id;
+ idString[1] = 0;
size = con->size(id);
if (size <= 0 || !con->seek(id)) {
diff --git a/engines/saga2/mapfeatr.cpp b/engines/saga2/mapfeatr.cpp
index 98466ce68b..423a3a0156 100644
--- a/engines/saga2/mapfeatr.cpp
+++ b/engines/saga2/mapfeatr.cpp
@@ -244,15 +244,15 @@ void initMapFeatures(void) {
void updateMapFeatures(int16 cWorld) {
extern WorldMapData *mapList;
extern GameWorld *currentWorld;
- WorldMapData *wMap = &mapList[ currentWorld->mapNum ];
+ WorldMapData *wMap = &mapList[currentWorld->mapNum];
uint16 *mapData = wMap->map->mapData;
for (int i = 0; i < mapFeatureCount; i++) {
if (mapFeatures[i]->getWorld() == cWorld) {
uint16 *mapRow;
- mapRow = &mapData[(mapFeatures[i]->getU() >> (tileUVShift + platShift)) * wMap->mapSize ];
- uint16 mtile = mapRow[(mapFeatures[i]->getV() >> (tileUVShift + platShift)) ];
+ mapRow = &mapData[(mapFeatures[i]->getU() >> (tileUVShift + platShift)) * wMap->mapSize];
+ uint16 mtile = mapRow[(mapFeatures[i]->getV() >> (tileUVShift + platShift))];
mapFeatures[i]->expose(mtile & metaTileVisited);
}
}
diff --git a/engines/saga2/messager.cpp b/engines/saga2/messager.cpp
index c1ac41c15b..437f048fab 100644
--- a/engines/saga2/messager.cpp
+++ b/engines/saga2/messager.cpp
@@ -32,7 +32,7 @@ namespace Saga2 {
size_t Messager::va(const char *format, va_list argptr) {
if (enabled) {
- char tempBuf[ 256 ];
+ char tempBuf[256];
size_t size;
size = vsprintf((char *) tempBuf, format, argptr);
diff --git a/engines/saga2/mission.cpp b/engines/saga2/mission.cpp
index 19447f5a52..88528a792a 100644
--- a/engines/saga2/mission.cpp
+++ b/engines/saga2/mission.cpp
@@ -33,7 +33,7 @@
namespace Saga2 {
-ActiveMission activeMissions[ 32 ];
+ActiveMission activeMissions[32];
//-----------------------------------------------------------------------
// Active mission creator
@@ -43,8 +43,8 @@ ActiveMission *ActiveMission::newMission(ObjectID genID, uint16 script) {
ActiveMission *ms = NULL;
for (i = 0; i < elementsof(activeMissions); i++) {
- if (!(activeMissions[ i ].missionFlags & inUse)) {
- ms = &activeMissions[ i ];
+ if (!(activeMissions[i].missionFlags & inUse)) {
+ ms = &activeMissions[i];
break;
}
}
@@ -72,8 +72,8 @@ int ActiveMission::findMission(ObjectID genID) {
int i;
for (i = 0; i < elementsof(activeMissions); i++) {
- if (activeMissions[ i ].missionFlags & inUse
- && activeMissions[ i ].generatorID == genID) {
+ if (activeMissions[i].missionFlags & inUse
+ && activeMissions[i].generatorID == genID) {
return i;
}
}
@@ -85,7 +85,7 @@ ActiveMission *ActiveMission::missionAddress(int index) {
assert(index >= 0);
assert(index < elementsof(activeMissions));
- return &activeMissions[ index ];
+ return &activeMissions[index];
}
//-----------------------------------------------------------------------
@@ -93,7 +93,7 @@ ActiveMission *ActiveMission::missionAddress(int index) {
bool ActiveMission::addObjectID(ObjectID objID) {
if (numObjectIDs < elementsof(missionObjectList)) {
- missionObjectList[ numObjectIDs++ ] = objID;
+ missionObjectList[numObjectIDs++] = objID;
return TRUE;
}
return FALSE;
@@ -107,9 +107,9 @@ bool ActiveMission::removeObjectID(ObjectID objID) {
for (int i = 0; i < numObjectIDs; i++) {
if (found) {
- missionObjectList[ i - 1 ] = missionObjectList[ i ];
+ missionObjectList[i - 1] = missionObjectList[i];
} else {
- if (missionObjectList[ i ] == objID) found = TRUE;
+ if (missionObjectList[i] == objID) found = TRUE;
}
}
@@ -129,8 +129,8 @@ bool ActiveMission::addKnowledgeID(ObjectID actor, uint16 knowledgeID) {
if (!a->addKnowledge(knowledgeID)) return FALSE;
- missionKnowledgeList[ numKnowledgeIDs ].id = actor;
- missionKnowledgeList[ numKnowledgeIDs++ ].kID = knowledgeID;
+ missionKnowledgeList[numKnowledgeIDs].id = actor;
+ missionKnowledgeList[numKnowledgeIDs++].kID = knowledgeID;
return TRUE;
}
return FALSE;
@@ -144,10 +144,10 @@ bool ActiveMission::removeKnowledgeID(ObjectID actor, uint16 knowledgeID) {
for (int i = 0; i < numKnowledgeIDs; i++) {
if (found) {
- missionKnowledgeList[ i - 1 ] = missionKnowledgeList[ i ];
+ missionKnowledgeList[i - 1] = missionKnowledgeList[i];
} else {
- if (missionKnowledgeList[ i ].id == actor
- && missionKnowledgeList[ i ].kID == knowledgeID) {
+ if (missionKnowledgeList[i].id == actor
+ && missionKnowledgeList[i].kID == knowledgeID) {
found = TRUE;
}
}
@@ -167,15 +167,15 @@ void ActiveMission::cleanup(void) {
for (i = 0; i < numKnowledgeIDs; i++) {
Actor *a;
- a = (Actor *)GameObject::objectAddress(missionKnowledgeList[ i ].id);
+ a = (Actor *)GameObject::objectAddress(missionKnowledgeList[i].id);
- a->removeKnowledge(missionKnowledgeList[ i ].kID);
+ a->removeKnowledge(missionKnowledgeList[i].kID);
}
for (i = 0; i < numObjectIDs; i++) {
GameObject *obj;
- obj = GameObject::objectAddress(missionObjectList[ i ]);
+ obj = GameObject::objectAddress(missionObjectList[i]);
obj->deleteObjectRecursive();
}
@@ -191,7 +191,7 @@ void initMissions(void) {
int i;
for (i = 0; i < elementsof(activeMissions); i++)
- activeMissions[ i ].missionFlags &= ~ActiveMission::inUse;
+ activeMissions[i].missionFlags &= ~ActiveMission::inUse;
}
//-----------------------------------------------------------------------
diff --git a/engines/saga2/mission.h b/engines/saga2/mission.h
index 0cee63c447..bc49413ee0 100644
--- a/engines/saga2/mission.h
+++ b/engines/saga2/mission.h
@@ -62,11 +62,11 @@ private:
// Specific variables relating to the mission which can
// be defined by the script writer.
- uint8 missionVars[ 32 ];
+ uint8 missionVars[32];
// Record what resources were created for this mission
- ObjectID missionObjectList[ 32 ];
- KnowledgeID missionKnowledgeList[ 32 ];
+ ObjectID missionObjectList[32];
+ KnowledgeID missionKnowledgeList[32];
uint16 numObjectIDs,
numKnowledgeIDs;
diff --git a/engines/saga2/modal.h b/engines/saga2/modal.h
index 4697759665..a07c3504e4 100644
--- a/engines/saga2/modal.h
+++ b/engines/saga2/modal.h
@@ -45,7 +45,7 @@ extern GameMode ModalMode;
* ===================================================================== */
class ModalWindow : public DecoratedWindow {
- GameMode *prevModeStackPtr[ Max_Modes ];
+ GameMode *prevModeStackPtr[Max_Modes];
int prevModeStackCtr;
public:
diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp
index dc35f454a7..fa71c6e9f7 100644
--- a/engines/saga2/motion.cpp
+++ b/engines/saga2/motion.cpp
@@ -116,7 +116,7 @@ x Single
Motion Constants
* ===================================================================== */
-TilePoint dirTable[ 8 ] = {
+TilePoint dirTable[8] = {
TilePoint(2, 2, 0),
TilePoint(0, 3, 0),
TilePoint(-2, 2, 0),
@@ -128,7 +128,7 @@ TilePoint dirTable[ 8 ] = {
};
// Incremental direction table
-TilePoint incDirTable[ 8 ] = {
+TilePoint incDirTable[8] = {
TilePoint(1, 1, 0),
TilePoint(0, 1, 0),
TilePoint(-1, 1, 0),
@@ -139,10 +139,10 @@ TilePoint incDirTable[ 8 ] = {
TilePoint(1, 0, 0)
};
-extern uint16 uMaxMasks[ 4 ],
- uMinMasks[ 4 ],
- vMaxMasks[ 4 ],
- vMinMasks[ 4 ];
+extern uint16 uMaxMasks[4],
+ uMinMasks[4],
+ vMaxMasks[4],
+ vMinMasks[4];
extern SpellStuff spellBook[];
void fallingDamage(GameObject *obj, int16 speed);
@@ -316,7 +316,7 @@ bool unstickObject(GameObject *obj) {
height = 8 * (up ? level >> 1 : -1 - (level >> 1));
for (dir = 0; dir < 8; dir++) {
- pos = obj->getLocation() + (dirTable[ dir ] * dist);
+ pos = obj->getLocation() + (dirTable[dir] * dist);
pos.z += height;
if (outside == (objRoofID(obj, mapNum, pos) == 0)
@@ -360,7 +360,7 @@ uint8 computeTurnFrames(Direction fromDir, Direction toDir) {
//-----------------------------------------------------------------------
// The list of active motion tasks for all actors
-static uint8 mTaskListBuffer[ sizeof(MotionTaskList) ];
+static uint8 mTaskListBuffer[sizeof(MotionTaskList)];
static MotionTaskList &mTaskList = *((MotionTaskList *)mTaskListBuffer);
@@ -369,7 +369,7 @@ static MotionTaskList &mTaskList = *((MotionTaskList *)mTaskListBuffer);
MotionTaskList::MotionTaskList(void) {
for (int i = 0; i < elementsof(array); i++) {
- free.addTail(array[ i ]);
+ free.addTail(array[i]);
}
}
@@ -383,7 +383,7 @@ MotionTaskList::MotionTaskList(void **buf) {
motionTaskCount;
for (i = 0; i < elementsof(array); i++) {
- free.addTail(array[ i ]);
+ free.addTail(array[i]);
}
// Retrieve the motion task count
@@ -581,7 +581,7 @@ void *MotionTask::restore(void *buf) {
int16 wayPointIndex = pathIndex;
while (wayPointIndex < pathCount) {
- pathList[ wayPointIndex ] = *((TilePoint *)buf);
+ pathList[wayPointIndex] = *((TilePoint *)buf);
buf = (TilePoint *)buf + 1;
wayPointIndex++;
@@ -993,7 +993,7 @@ void *MotionTask::archive(void *buf) {
int16 wayPointIndex = pathIndex;
while (wayPointIndex < pathCount) {
- *((TilePoint *)buf) = pathList[ wayPointIndex ];
+ *((TilePoint *)buf) = pathList[wayPointIndex];
buf = (TilePoint *)buf + 1;
wayPointIndex++;
@@ -1253,7 +1253,7 @@ TilePoint MotionTask::getImmediateTarget(void) {
dir = ((Actor *)object)->currentFacing;
return object->location
- + incDirTable[ dir ] * tileUVSize;
+ + incDirTable[dir] * tileUVSize;
}
//-----------------------------------------------------------------------
@@ -2147,7 +2147,7 @@ void MotionTask::finishWalk(void) {
// Simply set actor's target location to "here".
finalTarget = immediateLocation = object->getLocation();
- pathList[ 0 ] = finalTarget;
+ pathList[0] = finalTarget;
flags = reset;
pathCount = 0;
pathIndex = 0;*/
@@ -2450,7 +2450,7 @@ bool MotionTask::nextWayPoint(void) {
if (wayPointVector.quickHDistance() == 0)
// Next vertex in path polyline
- immediateLocation = pathList[ pathIndex++ ];
+ immediateLocation = pathList[pathIndex++];
else
return FALSE;
} else {
@@ -2498,7 +2498,7 @@ bool MotionTask::checkWalk(
// Check the terrain in various directions.
// Check in the forward direction first, at various heights
- newPos = object->location + (dirTable[ direction ] * speed) / 2;
+ newPos = object->location + (dirTable[direction] * speed) / 2;
newPos.z = object->location.z + stepUp;
if (checkWalkable(object, newPos)) return FALSE;
@@ -2670,7 +2670,7 @@ void MotionTask::walkAction(void) {
TPLine(pt1, pt2);
curPt = wayPt;
- wayPt = pathList[ ++i ];
+ wayPt = pathList[++i];
}
ShowObjectSection(a);
@@ -2906,11 +2906,11 @@ void MotionTask::walkAction(void) {
cornerHeight = sti.surfaceTile->attrs.cornerHeight;
- if (cornerHeight[ 0 ] == 0 && cornerHeight[ 1 ] == 0)
+ if (cornerHeight[0] == 0 && cornerHeight[1] == 0)
stairsDir = 1;
- else if (cornerHeight[ 1 ] == 0 && cornerHeight[ 2 ] == 0)
+ else if (cornerHeight[1] == 0 && cornerHeight[2] == 0)
stairsDir = 3;
- else if (cornerHeight[ 2 ] == 0 && cornerHeight[ 3 ] == 0)
+ else if (cornerHeight[2] == 0 && cornerHeight[3] == 0)
stairsDir = 5;
else
stairsDir = 7;
@@ -3042,19 +3042,19 @@ void MotionTask::upLadderAction(void) {
if (actorSubTileReg.min.u >= subTileLoc.u)
footPrintMask &=
- uMinMasks[ actorSubTileReg.min.u - subTileLoc.u ];
+ uMinMasks[actorSubTileReg.min.u - subTileLoc.u];
if (actorSubTileReg.min.v >= subTileLoc.v)
footPrintMask &=
- vMinMasks[ actorSubTileReg.min.v - subTileLoc.v ];
+ vMinMasks[actorSubTileReg.min.v - subTileLoc.v];
if (actorSubTileReg.max.u < subTileLoc.u + tileSubSize)
footPrintMask &=
- uMaxMasks[ actorSubTileReg.max.u - subTileLoc.u ];
+ uMaxMasks[actorSubTileReg.max.u - subTileLoc.u];
if (actorSubTileReg.max.v < subTileLoc.v + tileSubSize)
footPrintMask &=
- vMaxMasks[ actorSubTileReg.max.v - subTileLoc.v ];
+ vMaxMasks[actorSubTileReg.max.v - subTileLoc.v];
ladderMask = ti->attrs.fgdTerrain == terrNumLadder
? ti->attrs.terrainMask
@@ -3069,14 +3069,14 @@ void MotionTask::upLadderAction(void) {
TilePoint newLoc;
- newLoc = loc + incDirTable[ a->currentFacing ] * crossSection * 2;
+ newLoc = loc + incDirTable[a->currentFacing] * crossSection * 2;
newLoc.z = tileSlopeHeight(newLoc, a);
if (!checkBlocked(a, newLoc))
a->move(newLoc);
else {
newLoc = loc
- + incDirTable[(a->currentFacing - 2) & 7 ]
+ + incDirTable[(a->currentFacing - 2) & 7]
* crossSection * 2;
newLoc.z = tileSlopeHeight(newLoc, a);
@@ -3084,7 +3084,7 @@ void MotionTask::upLadderAction(void) {
a->move(newLoc);
else {
newLoc = loc
- + incDirTable[(a->currentFacing + 2) & 7 ]
+ + incDirTable[(a->currentFacing + 2) & 7]
* crossSection * 2;
newLoc.z = tileSlopeHeight(newLoc, a);
@@ -3092,7 +3092,7 @@ void MotionTask::upLadderAction(void) {
a->move(newLoc);
else {
newLoc = loc
- + incDirTable[ a->currentFacing ]
+ + incDirTable[a->currentFacing]
* crossSection * 2;
newLoc.z = tileSlopeHeight(newLoc, a);
a->move(newLoc);
@@ -3164,19 +3164,19 @@ void MotionTask::downLadderAction(void) {
if (actorSubTileReg.min.u >= subTileLoc.u)
footPrintMask &=
- uMinMasks[ actorSubTileReg.min.u - subTileLoc.u ];
+ uMinMasks[actorSubTileReg.min.u - subTileLoc.u];
if (actorSubTileReg.min.v >= subTileLoc.v)
footPrintMask &=
- vMinMasks[ actorSubTileReg.min.v - subTileLoc.v ];
+ vMinMasks[actorSubTileReg.min.v - subTileLoc.v];
if (actorSubTileReg.max.u < subTileLoc.u + tileSubSize)
footPrintMask &=
- uMaxMasks[ actorSubTileReg.max.u - subTileLoc.u ];
+ uMaxMasks[actorSubTileReg.max.u - subTileLoc.u];
if (actorSubTileReg.max.v < subTileLoc.v + tileSubSize)
footPrintMask &=
- vMaxMasks[ actorSubTileReg.max.v - subTileLoc.v ];
+ vMaxMasks[actorSubTileReg.max.v - subTileLoc.v];
ladderMask = ti->attrs.fgdTerrain == terrNumLadder
? ti->attrs.terrainMask
@@ -3191,14 +3191,14 @@ void MotionTask::downLadderAction(void) {
TilePoint newLoc;
- newLoc = loc - incDirTable[ a->currentFacing ] * tileUVSize;
+ newLoc = loc - incDirTable[a->currentFacing] * tileUVSize;
newLoc.z = tileSlopeHeight(newLoc, a);
if (!checkBlocked(a, newLoc))
a->move(newLoc);
else {
newLoc = loc
- - incDirTable[(a->currentFacing - 2) & 7 ]
+ - incDirTable[(a->currentFacing - 2) & 7]
* tileUVSize;
newLoc.z = tileSlopeHeight(newLoc, a);
@@ -3206,7 +3206,7 @@ void MotionTask::downLadderAction(void) {
a->move(newLoc);
else {
newLoc = loc
- - incDirTable[(a->currentFacing + 2) & 7 ]
+ - incDirTable[(a->currentFacing + 2) & 7]
* tileUVSize;
newLoc.z = tileSlopeHeight(newLoc, a);
@@ -3214,7 +3214,7 @@ void MotionTask::downLadderAction(void) {
a->move(newLoc);
else {
newLoc = loc
- - incDirTable[ a->currentFacing ]
+ - incDirTable[a->currentFacing]
* tileUVSize;
newLoc.z = tileSlopeHeight(newLoc, a);
a->move(newLoc);
@@ -3272,7 +3272,7 @@ struct CombatMotionSet {
// Select randome element from the array
uint8 selectRandom(void) const {
- return list[ rand() % listSize ];
+ return list[rand() % listSize];
}
};
@@ -3369,7 +3369,7 @@ void MotionTask::twoHandedSwingAction(void) {
// Randomly select a combat motion type from the available set
combatMotionType = availableSet->selectRandom();
- actorAnimation = animationTypeArray[ combatMotionType ];
+ actorAnimation = animationTypeArray[combatMotionType];
if (a->appearance != NULL
&& a->isActionAvailable(actorAnimation)) {
@@ -3486,7 +3486,7 @@ void MotionTask::oneHandedSwingAction(void) {
}
else*/
{
- actorAnimation = animationTypeArray[ combatMotionType ];
+ actorAnimation = animationTypeArray[combatMotionType];
if (a->appearance != NULL
&& a->isActionAvailable(actorAnimation)) {
// Compute the number of frames in the animation before the
@@ -3617,9 +3617,9 @@ void MotionTask::fireBowAction(void) {
projCrossSection = proj->proto()->crossSection;
ObjectID projID;
- actorLoc.u += incDirTable[ a->currentFacing ].u
+ actorLoc.u += incDirTable[a->currentFacing].u
* (actorCrossSection + projCrossSection);
- actorLoc.v += incDirTable[ a->currentFacing ].v
+ actorLoc.v += incDirTable[a->currentFacing].v
* (actorCrossSection + projCrossSection);
actorLoc.z += a->proto()->height * 7 / 8;
@@ -3955,7 +3955,7 @@ void MotionTask::acceptHitAction(void) {
if (rand() & 0x1) {
// Calculate the new position to knock the actor back to
- newLoc += dirTable[(a->currentFacing - 4) & 0x7 ];
+ newLoc += dirTable[(a->currentFacing - 4) & 0x7];
// If the actor is not blocked, move him back
if (!checkBlocked(a, newLoc)) {
@@ -4015,7 +4015,7 @@ void MotionTask::fallDownAction(void) {
if (rand() & 0x1) {
// Calculate the new position to knock the actor back to
- newLoc += dirTable[(a->currentFacing - 4) & 0x7 ];
+ newLoc += dirTable[(a->currentFacing - 4) & 0x7];
newLoc.z = tileSlopeHeight(newLoc, a, &sti);
// If the actor is not blocked, move him back
@@ -4887,19 +4887,19 @@ bool checkLadder(Actor *a, const TilePoint &loc) {
if (actorSubTileReg.min.u >= subTileLoc.u)
footPrintMask &=
- uMinMasks[ actorSubTileReg.min.u - subTileLoc.u ];
+ uMinMasks[actorSubTileReg.min.u - subTileLoc.u];
if (actorSubTileReg.min.v >= subTileLoc.v)
footPrintMask &=
- vMinMasks[ actorSubTileReg.min.v - subTileLoc.v ];
+ vMinMasks[actorSubTileReg.min.v - subTileLoc.v];
if (actorSubTileReg.max.u < subTileLoc.u + tileSubSize)
footPrintMask &=
- uMaxMasks[ actorSubTileReg.max.u - subTileLoc.u ];
+ uMaxMasks[actorSubTileReg.max.u - subTileLoc.u];
if (actorSubTileReg.max.v < subTileLoc.v + tileSubSize)
footPrintMask &=
- vMaxMasks[ actorSubTileReg.max.v - subTileLoc.v ];
+ vMaxMasks[actorSubTileReg.max.v - subTileLoc.v];
ladderMask = ti->attrs.fgdTerrain == terrNumLadder
? ti->attrs.terrainMask
diff --git a/engines/saga2/motion.h b/engines/saga2/motion.h
index 44431e95e2..977db74acf 100644
--- a/engines/saga2/motion.h
+++ b/engines/saga2/motion.h
@@ -135,7 +135,7 @@ class MotionTask : private DNode {
};
Direction direction; // direction of movement
- TilePoint pathList[ 16 ]; // intermediate motion targets
+ TilePoint pathList[16]; // intermediate motion targets
int16 pathCount, // number of points in path
pathIndex, // number of points so far
runCount; // used for run requests.
@@ -540,7 +540,7 @@ class MotionTaskList {
DList list,
free;
- MotionTask array[ 48 ];
+ MotionTask array[48];
public:
// Default constructor
diff --git a/engines/saga2/mouseimg.cpp b/engines/saga2/mouseimg.cpp
index 2d0268df96..5b26980a48 100644
--- a/engines/saga2/mouseimg.cpp
+++ b/engines/saga2/mouseimg.cpp
@@ -62,7 +62,7 @@ extern uint8 *gaugeImageData;
const int maxMouseTextLen = 80;
-static char mouseText[ maxMouseTextLen ] = { "" }; // Current mouse text string
+static char mouseText[maxMouseTextLen] = { "" }; // Current mouse text string
static Point16 mouseImageOffset; // Hotspot on mouse image
@@ -79,10 +79,10 @@ static int textImageCenteredCol; // The pixel column in the text
static int gaugeNumerator, // Current mouse gauge values
gaugeDenominator;
-static uint8 gaugeGrayMap[ 7 ] =
+static uint8 gaugeGrayMap[7] =
{ 0x00, 0x18, 0x14, 0x12, 0x16, 0x17, 0x0E }; // Gray
-static uint8 gaugeColorMapArray[ 3 ][ 7 ] = {
+static uint8 gaugeColorMapArray[3][7] = {
{ 0x00, 0x18, 0xE2, 0xD1, 0xE5, 0xE7, 0xC9 }, // Green
{ 0x00, 0x18, 0x5C, 0x5A, 0x5E, 0x60, 0x49 }, // Yellow
{ 0x00, 0x18, 0x83, 0x81, 0x86, 0x72, 0x39 }, // Red
@@ -111,7 +111,7 @@ static struct MouseCurosrs {
gStaticImage *mouseCursors[kMouseMax];
-static uint8 gaugeImageBuffer[ gaugeImageWidth * gaugeImageHeight ];
+static uint8 gaugeImageBuffer[gaugeImageWidth * gaugeImageHeight];
static gStaticImage gaugeImage(gaugeImageWidth, gaugeImageHeight, gaugeImageBuffer);
static bool showGauge = FALSE;
@@ -152,18 +152,18 @@ void createStackedImage(
*newImageCenter = 0;
for (i = 0; i < images; i++) {
- if (imageCenterArray[ i ] > *newImageCenter)
- *newImageCenter = imageCenterArray[ i ];
+ if (imageCenterArray[i] > *newImageCenter)
+ *newImageCenter = imageCenterArray[i];
}
for (i = 0; i < images; i++) {
int16 rightImageBoundary;
- newImage->size.y += imageArray[ i ]->size.y;
+ newImage->size.y += imageArray[i]->size.y;
rightImageBoundary = *newImageCenter
- + (imageArray[ i ]->size.x
- - imageCenterArray[ i ]);
+ + (imageArray[i]->size.x
+ - imageCenterArray[i]);
if (rightImageBoundary > newImage->size.x)
newImage->size.x = rightImageBoundary;
}
@@ -177,12 +177,12 @@ void createStackedImage(
newImageRow = 0;
for (i = 0; i < images; i++) {
- gPixelMap *currentImage = imageArray[ i ];
+ gPixelMap *currentImage = imageArray[i];
TBlit(
newImage,
currentImage,
- *newImageCenter - imageCenterArray[ i ],
+ *newImageCenter - imageCenterArray[i],
newImageRow);
newImageRow += currentImage->size.y + 1;
@@ -211,21 +211,21 @@ void cleanupMousePointer(void) {
void setupMousePointer(void) {
int imageIndex = 1;
- gPixelMap *imageArray[ 3 ];
- int imageCenterArray[ 3 ];
+ gPixelMap *imageArray[3];
+ int imageCenterArray[3];
Point16 imageOffset; // mouse image offset
int combinedImageCenter;
- imageArray[ 0 ] = mouseImage;
- imageCenterArray[ 0 ] = mouseImage->size.x / 2;
- if (mouseText[ 0 ] != '\0') {
- imageArray[ imageIndex ] = &textImage;
- imageCenterArray[ imageIndex ] = textImageCenteredCol;
+ imageArray[0] = mouseImage;
+ imageCenterArray[0] = mouseImage->size.x / 2;
+ if (mouseText[0] != '\0') {
+ imageArray[imageIndex] = &textImage;
+ imageCenterArray[imageIndex] = textImageCenteredCol;
imageIndex++;
}
if (showGauge) {
- imageArray[ imageIndex ] = &gaugeImage;
- imageCenterArray[ imageIndex ] = gaugeImage.size.x / 2;
+ imageArray[imageIndex] = &gaugeImage;
+ imageCenterArray[imageIndex] = gaugeImage.size.x / 2;
imageIndex++;
}
@@ -274,7 +274,7 @@ void setMouseImage(gPixelMap &img, int16 x, int16 y) {
// Dispose of old text
inline void disposeText(void) {
- mouseText[ 0 ] = '\0';
+ mouseText[0] = '\0';
// Free the memory previously allocated to hold the text image
// bitmap
@@ -297,7 +297,7 @@ void setNewText(char *text) {
disposeText();
strncpy(mouseText, text, maxMouseTextLen - 1);
- mouseText[ maxMouseTextLen - 1 ] = NULL;
+ mouseText[maxMouseTextLen - 1] = NULL;
// Compute the size of the text bitmap
textImage.size.y = mainFont->height + 2;
@@ -345,7 +345,7 @@ void setMouseText(char *text) {
setNewText(text);
setupMousePointer();
- } else if (mouseText[ 0 ] != NULL) {
+ } else if (mouseText[0] != NULL) {
disposeText();
setupMousePointer();
}
@@ -360,7 +360,7 @@ void setMouseTextF(char *format, ...) {
setMouseText(NULL);
G_BASE.mouseHintSet = TRUE;
} else {
- char lineBuf[ 128 ];
+ char lineBuf[128];
va_list argptr;
va_start(argptr, format);
@@ -396,11 +396,11 @@ void setMouseGauge(int numerator, int denominator) {
gaugePos = (numerator * gaugeWidth + denominator - 1) / denominator;
if (gaugePos <= gaugeOneThird)
- gaugeColorMap = gaugeColorMapArray[ 2 ];
+ gaugeColorMap = gaugeColorMapArray[2];
else if (gaugePos <= gaugeTwoThirds)
- gaugeColorMap = gaugeColorMapArray[ 1 ];
+ gaugeColorMap = gaugeColorMapArray[1];
else
- gaugeColorMap = gaugeColorMapArray[ 0 ];
+ gaugeColorMap = gaugeColorMapArray[0];
for (y = 0; y < gaugeImageHeight; y++) {
for (x = 0; x < gaugeImageWidth; x++) {
@@ -408,8 +408,8 @@ void setMouseGauge(int numerator, int denominator) {
gaugeMap = x < gaugePos + 1 ? gaugeColorMap : gaugeGrayMap;
- gaugeImageBuffer[ gaugeImageIndex ] =
- gaugeMap[mouseCursors[kMouseGaugeImage]->data[gaugeImageIndex] ];
+ gaugeImageBuffer[gaugeImageIndex] =
+ gaugeMap[mouseCursors[kMouseGaugeImage]->data[gaugeImageIndex]];
gaugeImageIndex++;
}
diff --git a/engines/saga2/msgbox.cpp b/engines/saga2/msgbox.cpp
index b3d2a11b5e..d4b757161e 100644
--- a/engines/saga2/msgbox.cpp
+++ b/engines/saga2/msgbox.cpp
@@ -44,7 +44,7 @@ Rect16 mbWindowRect(70, 170, 500, 140);
const Rect16 mbOkBtnRect(100, 100, 100, 25);
const Rect16 mbCancelBtnRect(300, 100, 100, 25);
const Rect16 mbOneBtnRect(200, 100, 100, 25);
-const Rect16 mbButtonRects[ numMessageBtns ] = { { mbOkBtnRect },
+const Rect16 mbButtonRects[numMessageBtns] = { { mbOkBtnRect },
{ mbCancelBtnRect }
};
static gFont *mbButtonFont = &ThinFix8Font;
@@ -289,8 +289,8 @@ void SimpleWindow::writeWrappedPlaqText(gPort &port,
textPallete &pal,
bool hiLite,
const char *msg, ...) {
- char textBuf[ 256 ];
- char lineBuf[ 128 ];
+ char textBuf[256];
+ char lineBuf[128];
va_list argptr;
int16 tPos = 0;
Rect16 r2 = r;
diff --git a/engines/saga2/msgbox.h b/engines/saga2/msgbox.h
index 36871a0fa2..bf5a7730ca 100644
--- a/engines/saga2/msgbox.h
+++ b/engines/saga2/msgbox.h
@@ -48,7 +48,7 @@ extern GameMode ModalMode;
class SimpleWindow : public gWindow {
- GameMode *prevModeStackPtr[ Max_Modes ];
+ GameMode *prevModeStackPtr[Max_Modes];
int prevModeStackCtr;
public:
diff --git a/engines/saga2/objects.h b/engines/saga2/objects.h
index 6fba794c7f..564c9b1cac 100644
--- a/engines/saga2/objects.h
+++ b/engines/saga2/objects.h
@@ -169,7 +169,7 @@ public:
ActiveItemID currentTAG; // ActiveItem object is on
uint8 sightCtr; // Line of sight counter
- uint8 reserved[ 2 ];
+ uint8 reserved[2];
// Default constructor
GameObject(void);
@@ -777,7 +777,7 @@ public:
void cleanup(void);
Sector *getSector(int16 u, int16 v) {
- return &(sectorArray)[ v * sectorArraySize + u ];
+ return &(sectorArray)[v * sectorArraySize + u];
}
TilePoint sectorSize(void) { // size of map in sectors
diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp
index d441a2beec..3c472f97fc 100644
--- a/engines/saga2/objproto.cpp
+++ b/engines/saga2/objproto.cpp
@@ -1105,8 +1105,8 @@ bool InventoryProto::dropAction(
TilePoint testPt;
Direction testDir;
- testDir = (vectorDir + dirOffsetTable[ i ]) & 0x7;
- testPt = enactorLoc + incDirTable[ testDir ] * offsetDist;
+ testDir = (vectorDir + dirOffsetTable[i]) & 0x7;
+ testPt = enactorLoc + incDirTable[testDir] * offsetDist;
testPt.z += enactorProto->height >> 1;
if (checkBlocked(dObjPtr, mapNum, testPt) == blockageNone) {
startPt = testPt;
@@ -1521,7 +1521,7 @@ uint16 WeaponProto::containmentSet(void) {
// return the address of the sprite when held in hand
Sprite *WeaponProto::getOrientedSprite(GameObject *obj, int16 offset) {
- return weaponSprites[ heldSpriteBase ]->sprite(offset);
+ return weaponSprites[heldSpriteBase]->sprite(offset);
}
//-----------------------------------------------------------------------
@@ -1602,7 +1602,7 @@ bool MeleeWeaponProto::strikeAction(
if (itemPtr->acceptStrike(enactor, dObj, getSkillValue(enactor)))
return TRUE;
- soundFXs = &objectSoundFXTable[ soundFXClass ];
+ soundFXs = &objectSoundFXTable[soundFXClass];
makeCombatSound(soundFXs->soundFXMissed, ol);
return FALSE;
@@ -1624,7 +1624,7 @@ bool MeleeWeaponProto::damageAction(
Location ol = Location(a->getWorldLocation(), a->IDParent());
damageSoundID = targetPtr->proto()->getDamageSound(
- objectSoundFXTable[ soundFXClass ]);
+ objectSoundFXTable[soundFXClass]);
if (damageSoundID != 0)
makeCombatSound(damageSoundID, ol);
@@ -2048,7 +2048,7 @@ uint8 WeaponWandProto::weaponRating(
if (weapon->IDChild() != Nothing) {
SkillProto *spellProto = (SkillProto *)GameObject::protoAddress(weapon->IDChild());
- SpellStuff *spellStuff = &spellBook[ spellProto->getSpellID() ];
+ SpellStuff *spellStuff = &spellBook[spellProto->getSpellID()];
ActorManaID manaType = (ActorManaID)spellStuff->getManaType();
uint16 manaAmount = spellStuff->getManaAmt();
@@ -2147,7 +2147,7 @@ bool ArrowProto::damageAction(
Location al = Location(a->getLocation(), a->IDParent());
damageSoundID = targetPtr->proto()->getDamageSound(
- objectSoundFXTable[ soundFXClass ]);
+ objectSoundFXTable[soundFXClass]);
if (damageSoundID != 0)
makeCombatSound(damageSoundID, al);
@@ -2212,7 +2212,7 @@ bool ArmorProto::isObjectBeingUsed(GameObject *obj) {
ObjectID id = obj->thisID();
for (int i = 0; i < ARMOR_COUNT; i++) {
- if (a->armorObjects[ i ] == id) return TRUE;
+ if (a->armorObjects[i] == id) return TRUE;
}
}
return FALSE;
@@ -2226,7 +2226,7 @@ bool ArmorProto::useSlotAvailable(GameObject *obj, Actor *a) {
assert(isObject(obj) || obj->proto() == this);
assert(isActor(a));
- return a->armorObjects[ whereWearable ] == Nothing;
+ return a->armorObjects[whereWearable] == Nothing;
}
//-----------------------------------------------------------------------
@@ -2246,7 +2246,7 @@ bool ArmorProto::useAction(ObjectID dObj, ObjectID enactor) {
int16 slot = whereWearable;
- if (a->armorObjects[ slot ] == dObj)
+ if (a->armorObjects[slot] == dObj)
a->wear(Nothing, slot);
else
a->wear(dObj, slot);
@@ -2578,7 +2578,7 @@ void IntangibleObjProto::getColorTranslation(ColorTable map) {
uint8 color = 0;
do {
- map[ color ] = color;
+ map[color] = color;
} while ( ++color != 0 );
*/
}
diff --git a/engines/saga2/objproto.h b/engines/saga2/objproto.h
index 8e5b75fdd3..2f54f2849c 100644
--- a/engines/saga2/objproto.h
+++ b/engines/saga2/objproto.h
@@ -168,7 +168,7 @@ struct ResourceObjectPrototype {
uint16 iconSprite, // sprite # in inventory
groundSprite; // sprite # when on ground
- uint8 colorMap[ 4 ]; // indirect color map
+ uint8 colorMap[4]; // indirect color map
// Physical properties
@@ -240,7 +240,7 @@ struct ResourceObjectPrototype {
uint8 soundFXClass; // index into sound effects table
- uint8 reserved[ 7 ];
+ uint8 reserved[7];
// Default constructor -- do nothing
ResourceObjectPrototype(void) {}
diff --git a/engines/saga2/oncall.h b/engines/saga2/oncall.h
index 89fbd0982f..5f003bd9d3 100644
--- a/engines/saga2/oncall.h
+++ b/engines/saga2/oncall.h
@@ -122,16 +122,16 @@ public:
template <class RESTYPE> RESTYPE LoadOnCall<RESTYPE>::rLoad(uint16 ind, bool asynch) {
RESTYPE t;
- if (isValidPtr(handle[ ind ]) && locked[ind]) {
- RLockHandle((RHANDLE) handle[ ind ]);
+ if (isValidPtr(handle[ind]) && locked[ind]) {
+ RLockHandle((RHANDLE) handle[ind]);
locked.Bit(ind, TRUE);
wanted.Bit(ind, FALSE);
recent.Bit(ind, TRUE);
- return handle[ ind ];
+ return handle[ind];
}
- if (isValidPtr(handle[ ind ]) && wanted[ind]) {
+ if (isValidPtr(handle[ind]) && wanted[ind]) {
// wait for handle
- RLockHandle((RHANDLE) handle[ ind ]);
+ RLockHandle((RHANDLE) handle[ind]);
locked.Bit(ind, TRUE);
wanted.Bit(ind, FALSE);
recent.Bit(ind, TRUE);
@@ -146,19 +146,19 @@ template <class RESTYPE> RESTYPE LoadOnCall<RESTYPE>::rLoad(uint16 ind, bool asy
recent.Bit(ind, TRUE);
if (asynch) {
- handle[ ind ] = (RESTYPE) NULL;
+ handle[ind] = (RESTYPE) NULL;
} else {
if (t == NULL) {
error("Resource %d could not load (Tile bank)", ind);
}
- handle[ ind ] = t;
+ handle[ind] = t;
}
return t;
}
template <class RESTYPE> void LoadOnCall<RESTYPE>::rFree(uint16 ind) {
- if (isValidPtr(handle[ ind ])) {
- RUnlockHandle((RHANDLE) handle[ ind ]);
+ if (isValidPtr(handle[ind])) {
+ RUnlockHandle((RHANDLE) handle[ind]);
locked.Bit(ind, FALSE);
//recent.Bit(ind,FALSE);
// washHandle(handle[ind]);
@@ -167,11 +167,11 @@ template <class RESTYPE> void LoadOnCall<RESTYPE>::rFree(uint16 ind) {
template <class RESTYPE> void LoadOnCall<RESTYPE>::rInit(uint16 ind) {
RESTYPE t;
- if (!isValidPtr(handle[ ind ])) {
+ if (!isValidPtr(handle[ind])) {
t = (RESTYPE) loader(tileID + MKTAG(0, 0, 0, ind), FALSE);
- handle[ ind ] = t;
+ handle[ind] = t;
locked.Bit(ind, TRUE);
- RUnlockHandle((RHANDLE) handle[ ind ]);
+ RUnlockHandle((RHANDLE) handle[ind]);
locked.Bit(ind, FALSE);
recent.Bit(ind, FALSE);
}
diff --git a/engines/saga2/patrol.h b/engines/saga2/patrol.h
index 260f0716b5..db195b1bde 100644
--- a/engines/saga2/patrol.h
+++ b/engines/saga2/patrol.h
@@ -103,7 +103,7 @@ public:
// FIXME: This is evil
warning("PartolRoute[]: dangerous pointer arithmetic, this will not work");
return *((PatrolRoute *)(routeData
- + offsetArray[ index ]));
+ + offsetArray[index]));
}
};
@@ -146,10 +146,10 @@ public:
// Copy constructor
PatrolRouteIterator(const PatrolRouteIterator &iter) {
// Copy first four bytes
- ((int32 *)this)[ 0 ] = ((int32 *)&iter)[ 0 ];
+ ((int32 *)this)[0] = ((int32 *)&iter)[0];
// Copy next two bytes
- *((int16 *) & ((int32 *)this)[ 1 ]) =
- *((int16 *) & ((int32 *)&iter)[ 1 ]);
+ *((int16 *) & ((int32 *)this)[1]) =
+ *((int16 *) & ((int32 *)&iter)[1]);
}
// Constructors
@@ -163,10 +163,10 @@ public:
// Overloaded assignment operator
PatrolRouteIterator operator = (const PatrolRouteIterator &iter) {
// Copy first four bytes
- ((int32 *)this)[ 0 ] = ((int32 *)&iter)[ 0 ];
+ ((int32 *)this)[0] = ((int32 *)&iter)[0];
// Copy next two bytes
- *((int16 *) & ((int32 *)this)[ 1 ]) =
- *((int16 *) & ((int32 *)&iter)[ 1 ]);
+ *((int16 *) & ((int32 *)this)[1]) =
+ *((int16 *) & ((int32 *)&iter)[1]);
return *this;
}
diff --git a/engines/saga2/player.cpp b/engines/saga2/player.cpp
index 95820810b2..cc05d1f098 100644
--- a/engines/saga2/player.cpp
+++ b/engines/saga2/player.cpp
@@ -71,7 +71,7 @@ static PlayerActorID centerActor; // Index of the current center
bool brotherBandingEnabled;
// Master list of all playerActor structures
-PlayerActor playerList[ playerActors ] = {
+PlayerActor playerList[playerActors] = {
PlayerActor(ActorBaseID + 0), // Julian
PlayerActor(ActorBaseID + 1), // Philip
PlayerActor(ActorBaseID + 2), // Kevin
@@ -149,8 +149,8 @@ void PlayerActor::AttribUpdate(void) {
for (int16 i = 0; i < numSkills; i++) {
// go through each skill and update as needed
- stdAttribUpdate(effStats->allSkills[ i ],
- baseStats.allSkills[ i ],
+ stdAttribUpdate(effStats->allSkills[i],
+ baseStats.allSkills[i],
i);
}
}
@@ -170,12 +170,12 @@ void PlayerActor::stdAttribUpdate(uint8 &stat, uint8 baseStat, int16 index) {
fractionRecover = attribPointsPerUpdate % attribPointsPerValue;
// if there is an overrun
- if (attribRecPools[ index ] + fractionRecover > attribPointsPerValue) {
+ if (attribRecPools[index] + fractionRecover > attribPointsPerValue) {
// add the overrun to the whole number
recover++;
- attribRecPools[ index ] = (attribRecPools[ index ] + fractionRecover) - attribPointsPerValue;
+ attribRecPools[index] = (attribRecPools[index] + fractionRecover) - attribPointsPerValue;
} else {
- attribRecPools[ index ] += fractionRecover;
+ attribRecPools[index] += fractionRecover;
}
@@ -195,7 +195,7 @@ void PlayerActor::manaUpdate(void) {
Actor *actor = getActor();
// get indirections for each of the effective mana types
- int16 *effectiveMana[ numManas ] = { &actor->effectiveStats.redMana,
+ int16 *effectiveMana[numManas] = { &actor->effectiveStats.redMana,
&actor->effectiveStats.orangeMana,
&actor->effectiveStats.yellowMana,
&actor->effectiveStats.greenMana,
@@ -204,7 +204,7 @@ void PlayerActor::manaUpdate(void) {
};
// get indirections for each of the base mana types
- int16 *baseMana[ numManas ] = { &baseStats.redMana,
+ int16 *baseMana[numManas] = { &baseStats.redMana,
&baseStats.orangeMana,
&baseStats.yellowMana,
&baseStats.greenMana,
@@ -220,53 +220,53 @@ void PlayerActor::manaUpdate(void) {
int recRate;
// if baseMana has gone to zero, force it to 1
- if (*baseMana[ i ] <= 0) *baseMana[ i ] = 1;
+ if (*baseMana[i] <= 0) *baseMana[i] = 1;
// Make mana harder to increase as it goes up.
- if (*baseMana[ i ] >= 100) levelBump = 40;
- else if (*baseMana[ i ] >= 40) levelBump = 20;
+ if (*baseMana[i] >= 100) levelBump = 40;
+ else if (*baseMana[i] >= 40) levelBump = 20;
else levelBump = 10;
// is their current mana less then their maximum
- if (*effectiveMana[ i ] < *baseMana[ i ]) {
- diff = *effectiveMana[ i ];
+ if (*effectiveMana[i] < *baseMana[i]) {
+ diff = *effectiveMana[i];
recRate = 1;
- if (*baseMana[ i ] >= 120) recRate = 3;
- else if (*baseMana[ i ] >= 80) recRate = 2;
- else if (*baseMana[ i ] >= 40) {
+ if (*baseMana[i] >= 120) recRate = 3;
+ else if (*baseMana[i] >= 80) recRate = 2;
+ else if (*baseMana[i] >= 40) {
// This effectively causes recRate to be 1.5, i.e.
// hald of the time its 1 and the other half its 2.
- if (*effectiveMana[ i ] % 3 == 0) recRate = 2;
+ if (*effectiveMana[i] % 3 == 0) recRate = 2;
}
// recover mana at specified rate
- *effectiveMana[ i ] = clamp(minMana,
- *effectiveMana[ i ] += recRate,
- *baseMana[ i ]);
+ *effectiveMana[i] = clamp(minMana,
+ *effectiveMana[i] += recRate,
+ *baseMana[i]);
// get the difference between the manas
- diff = *effectiveMana[ i ] - diff;
+ diff = *effectiveMana[i] - diff;
// find out if we're recovering from below one third
- if (*effectiveMana[ i ] < *baseMana[ i ] / 3) {
+ if (*effectiveMana[i] < *baseMana[i] / 3) {
// add the diff
// Deleted at request of Client.
-// manaMemory[ i ] -= diff;
+// manaMemory[i] -= diff;
} else {
- manaMemory[ i ] += diff;
+ manaMemory[i] += diff;
}
// if we bumped passed the ( +/- ) levelBump mark
// decrement the base mana
- *baseMana[ i ] += (manaMemory[ i ] / levelBump);
+ *baseMana[i] += (manaMemory[i] / levelBump);
// get the fraction back to memory
- manaMemory[ i ] = manaMemory[ i ] % levelBump;
+ manaMemory[i] = manaMemory[i] % levelBump;
- //WriteStatusF( 4, " mana: %d", *effectiveMana[ i ] );
+ //WriteStatusF( 4, " mana: %d", *effectiveMana[i] );
}
}
}
@@ -315,14 +315,14 @@ void PlayerActor::skillAdvance(uint8 stat,
int16 oldValue = baseStats.skill(stat) / ActorAttributes::skillFracPointsPerLevel;
// success, now apply the multiplyer
- attribMemPools[ stat ] += points * useMult;
+ attribMemPools[stat] += points * useMult;
// get the amout of whole increase points
- increase = attribMemPools[ stat ] / ActorAttributes::skillFracPointsPerLevel;
+ increase = attribMemPools[stat] / ActorAttributes::skillFracPointsPerLevel;
// now set the pool with the fraction
- attribMemPools[ stat ] =
- attribMemPools[ stat ]
+ attribMemPools[stat] =
+ attribMemPools[stat]
- increase
* ActorAttributes::skillFracPointsPerLevel;
@@ -345,14 +345,14 @@ void PlayerActor::skillAdvance(uint8 stat,
BRAWN_SKILL
};
- StatusMsg(SKILL_STATUS, getActor()->objName(), skillNames[ stat ]);
+ StatusMsg(SKILL_STATUS, getActor()->objName(), skillNames[stat]);
}
- //WriteStatusF( 6, "frac: %d inc: %d, base: %d", attribMemPools[ stat ], increase, baseStats.allSkills[ stat ] );
+ //WriteStatusF( 6, "frac: %d inc: %d, base: %d", attribMemPools[stat], increase, baseStats.allSkills[stat] );
}
}
void PlayerActor::vitalityAdvance(uint8 points) {
- char buffer[ 64 ];
+ char buffer[64];
while (points-- > 0) {
if (rand() % ActorAttributes::vitalityLimit > baseStats.vitality) {
@@ -516,7 +516,7 @@ void PlayerActor::handleAttacked(void) {
PlayerActor *getPlayerActorAddress(PlayerActorID id) {
assert(id >= 0 && id < elementsof(playerList));
- return &playerList[ id ];
+ return &playerList[id];
}
//-----------------------------------------------------------------------
@@ -530,14 +530,14 @@ PlayerActorID getPlayerActorID(PlayerActor *p) {
// Return a pointer the center actor's Actor structure
Actor *getCenterActor(void) {
- return playerList[ centerActor ].getActor();
+ return playerList[centerActor].getActor();
}
//-----------------------------------------------------------------------
// Return the center actor's object ID
ObjectID getCenterActorID(void) {
- return playerList[ centerActor ].getActorID();
+ return playerList[centerActor].getActorID();
}
//-----------------------------------------------------------------------
@@ -555,7 +555,7 @@ void setCenterActor(PlayerActorID newCenter) {
assert(newCenter < playerActors);
- Actor *a = playerList[ newCenter ].getActor();
+ Actor *a = playerList[newCenter].getActor();
PlayerActorIterator iter;
PlayerActor *player;
@@ -571,7 +571,7 @@ void setCenterActor(PlayerActorID newCenter) {
}
centerActor = newCenter;
- viewCenterObject = playerList[ centerActor ].getActorID();
+ viewCenterObject = playerList[centerActor].getActorID();
indivReadyNode->changeOwner(newCenter);
globalContainerList.setPlayerNum(newCenter);
@@ -584,7 +584,7 @@ void setCenterActor(PlayerActorID newCenter) {
}
// Set the new centers fight stance based upon his aggression state
- a->setFightStance(playerList[ newCenter ].isAggressive());
+ a->setFightStance(playerList[newCenter].isAggressive());
// band actors to new center if banding button set
for (player = iter.first(); player != NULL; player = iter.next()) {
@@ -607,7 +607,7 @@ void setCenterActor(Actor *newCenter) {
// Set a new center actor based upon a PlayerActor address
void setCenterActor(PlayerActor *newCenter) {
- assert(newCenter >= playerList && newCenter < &playerList[ playerActors ]);
+ assert(newCenter >= playerList && newCenter < &playerList[playerActors]);
setCenterActor(newCenter - playerList);
}
@@ -617,7 +617,7 @@ void setCenterActor(PlayerActor *newCenter) {
TilePoint centerActorCoords(void) {
Actor *a;
- a = playerList[ centerActor ].getActor();
+ a = playerList[centerActor].getActor();
return a->getLocation();
}
@@ -628,14 +628,14 @@ TilePoint centerActorCoords(void) {
void setAggression(PlayerActorID player, bool aggression) {
assert(player >= 0 && player < playerActors);
- Actor *a = playerList[ player ].getActor();
+ Actor *a = playerList[player].getActor();
if (a->isDead()) return;
if (aggression)
- playerList[ player ].setAggression();
+ playerList[player].setAggression();
else
- playerList[ player ].clearAggression();
+ playerList[player].clearAggression();
if (player == centerActor)
a->setFightStance(aggression);
@@ -650,7 +650,7 @@ void setAggression(PlayerActorID player, bool aggression) {
bool isAggressive(PlayerActorID player) {
assert(player >= 0 && player < playerActors);
- return playerList[ player ].isAggressive();
+ return playerList[player].isAggressive();
}
//-----------------------------------------------------------------------
@@ -664,7 +664,7 @@ void autoAdjustAggression(void) {
for (i = 0; i < playerActors; i++) {
if (i == centerActor || isBanded(i)) {
bool enemiesPresent = FALSE;
- Actor *actor = playerList[ i ].getActor();
+ Actor *actor = playerList[i].getActor();
if (actor->getStats()->vitality >= minAutoAggressionVitality) {
GameObject *obj;
@@ -703,14 +703,14 @@ void autoAdjustAggression(void) {
void setBanded(PlayerActorID player, bool banded) {
assert(player >= 0 && player < playerActors);
- if (playerList[ player ].getActor()->isDead()) return;
+ if (playerList[player].getActor()->isDead()) return;
if (banded)
- playerList[ player ].setBanded();
+ playerList[player].setBanded();
else
- playerList[ player ].clearBanded();
+ playerList[player].clearBanded();
- playerList[ player ].resolveBanding();
+ playerList[player].resolveBanding();
updateBrotherBandingButton(player, banded);
}
@@ -720,7 +720,7 @@ void setBanded(PlayerActorID player, bool banded) {
bool isBanded(PlayerActorID player) {
assert(player >= 0 && player < playerActors);
- return playerList[ player ].isBanded();
+ return playerList[player].isBanded();
}
//-----------------------------------------------------------------------
@@ -801,7 +801,7 @@ void handlePlayerActorDeath(PlayerActorID id) {
allPlayerActorsDead = TRUE;
}
- PlayerActor *player = &playerList[ id ];
+ PlayerActor *player = &playerList[id];
player->clearAggression();
player->clearBanded();
@@ -879,7 +879,7 @@ void handleEndOfCombat(void) {
// Iterate through all player actors
for (i = 0; i < playerActors; i++)
- playerList[ i ].resetAttackNotification();
+ playerList[i].resetAttackNotification();
}
/* ======================================================================= *
@@ -893,9 +893,9 @@ struct PlayerActorArchive {
int16 portraitType;
uint16 flags;
ActorAttributes baseStats;
- int16 manaMemory[ numManas ];
- uint8 attribRecPools[ numSkills ];
- uint8 attribMemPools[ numSkills ];
+ int16 manaMemory[numManas];
+ uint8 attribRecPools[numSkills];
+ uint8 attribMemPools[numSkills];
uint8 vitalityMemory;
bool notifiedOfAttack;
};
@@ -908,7 +908,7 @@ void initPlayerActors(void) {
PlayerActorID i;
for (i = 0; i < playerActors; i++) {
- PlayerActor *p = &playerList[ i ];
+ PlayerActor *p = &playerList[i];
Actor *a = p->getActor();
ActorProto *proto = (ActorProto *)a->proto();
@@ -947,11 +947,11 @@ void initPlayerActors(void) {
void savePlayerActors(SaveFileConstructor &saveGame) {
int16 i;
- PlayerActorArchive archiveBuffer[ playerActors ];
+ PlayerActorArchive archiveBuffer[playerActors];
for (i = 0; i < playerActors; i++) {
- PlayerActor *p = &playerList[ i ];
- PlayerActorArchive *a = &archiveBuffer[ i ];
+ PlayerActor *p = &playerList[i];
+ PlayerActorArchive *a = &archiveBuffer[i];
// Store the portrait type
a->portraitType = p->portraitType;
@@ -995,13 +995,13 @@ void savePlayerActors(SaveFileConstructor &saveGame) {
void loadPlayerActors(SaveFileReader &saveGame) {
int16 i;
- PlayerActorArchive archiveBuffer[ playerActors ];
+ PlayerActorArchive archiveBuffer[playerActors];
saveGame.read(archiveBuffer, sizeof(archiveBuffer));
for (i = 0; i < playerActors; i++) {
- PlayerActor *p = &playerList[ i ];
- PlayerActorArchive *a = &archiveBuffer[ i ];
+ PlayerActor *p = &playerList[i];
+ PlayerActorArchive *a = &archiveBuffer[i];
// Restore the portrait type
p->portraitType = a->portraitType;
@@ -1059,7 +1059,7 @@ struct CenterActorArchive {
void initCenterActor(void) {
centerActor = FTA_JULIAN;
- viewCenterObject = playerList[ centerActor ].getActorID();
+ viewCenterObject = playerList[centerActor].getActorID();
// clear the last center actor's button state
updateBrotherRadioButtons(FTA_JULIAN);
@@ -1096,11 +1096,11 @@ void loadCenterActor(SaveFileReader &saveGame) {
PlayerActor *PlayerActorIterator::first(void) {
index = 0;
- return &playerList[ index++ ];
+ return &playerList[index++];
}
PlayerActor *PlayerActorIterator::next(void) {
- return (index < playerActors) ? &playerList[ index++ ] : NULL;
+ return (index < playerActors) ? &playerList[index++] : NULL;
}
//-----------------------------------------------------------------------
@@ -1112,14 +1112,14 @@ PlayerActor *LivingPlayerActorIterator::first(void) {
}
PlayerActor *LivingPlayerActorIterator::next(void) {
- Actor *a = playerList[ index ].getActor();
+ Actor *a = playerList[index].getActor();
while (a == NULL || a->isDead()) {
if (++index >= playerActors) break;
- a = playerList[ index ].getActor();
+ a = playerList[index].getActor();
}
- return (index < playerActors) ? &playerList[ index++ ] : NULL;
+ return (index < playerActors) ? &playerList[index++] : NULL;
}
} // end of namespace Saga2
diff --git a/engines/saga2/player.h b/engines/saga2/player.h
index 08ad59692b..54abe64ace 100644
--- a/engines/saga2/player.h
+++ b/engines/saga2/player.h
@@ -84,13 +84,13 @@ public:
ContainerNode *readyNode;
// mana 'experience' pool
- int16 manaMemory[ numManas ];
+ int16 manaMemory[numManas];
// attrib recovery pools
- uint8 attribRecPools[ numSkills ];
+ uint8 attribRecPools[numSkills];
// skills 'expericene' pool
- uint8 attribMemPools[ numSkills ];
+ uint8 attribMemPools[numSkills];
// vitality pool
uint8 vitalityMemory;
@@ -113,11 +113,11 @@ public:
memset(&baseStats, 0, sizeof(baseStats));
for (i = 0; i < numManas; i++)
- manaMemory[ i ] = 0;
+ manaMemory[i] = 0;
for (i = 0; i < numSkills; i++) {
- attribRecPools[ i ] = 0;
- attribMemPools[ i ] = 0;
+ attribRecPools[i] = 0;
+ attribMemPools[i] = 0;
}
}
diff --git a/engines/saga2/playmode.cpp b/engines/saga2/playmode.cpp
index a88ce26b89..7cebbd4add 100644
--- a/engines/saga2/playmode.cpp
+++ b/engines/saga2/playmode.cpp
@@ -316,7 +316,7 @@ extern void unpackImage(gPixelMap *map,
typedef struct {
Point16 size;
int16 compress;
- int8 data[ 2 ];
+ int8 data[2];
} ImageHeader;
void drawCompressedImage(gPort &port, const Point16 pos, void *image) {
@@ -368,7 +368,7 @@ void drawCompressedImageGhosted(gPort &port, const Point16 pos, void *image) {
memcpy(map.data, hdr->data, map.bytes());
for (y = 0, row = map.data; y < map.size.y; y++, row += map.size.x) {
- for (x = (y & 1); x < map.size.x; x += 2) row[ x ] = 0;
+ for (x = (y & 1); x < map.size.x; x += 2) row[x] = 0;
}
port.setMode(drawModeMatte);
diff --git a/engines/saga2/priqueue.h b/engines/saga2/priqueue.h
index 16f815aa49..178fd50449 100644
--- a/engines/saga2/priqueue.h
+++ b/engines/saga2/priqueue.h
@@ -32,7 +32,7 @@ namespace Saga2 {
template <class ITEM, int size>
class PriorityQueue {
int16 tail; // end index of queue
- ITEM queue[ size + 1 ];
+ ITEM queue[size + 1];
static int16 parentIndex(int16 index) {
return index >> 1;
@@ -71,11 +71,11 @@ bool PriorityQueue<ITEM, size>::insert(ITEM &newItem) {
if (tail >= size + 1) return FALSE;
- for (index = tail, qi = &queue[ index ];
+ for (index = tail, qi = &queue[index];
index > 1;
index = parentIndex, qi = parentItem) {
parentIndex = PriorityQueue::parentIndex(index);
- parentItem = &queue[ parentIndex ];
+ parentItem = &queue[parentIndex];
if ((int)*parentItem <= newVal) break;
*qi = *parentItem;
@@ -90,7 +90,7 @@ bool PriorityQueue<ITEM, size>::insert(ITEM &newItem) {
template <class ITEM, int size>
bool PriorityQueue<ITEM, size>::remove(ITEM &result) {
- ITEM *item = &queue[ 1 ],
+ ITEM *item = &queue[1],
*child;
int16 itemNum = 1,
childNum,
@@ -100,17 +100,17 @@ bool PriorityQueue<ITEM, size>::remove(ITEM &result) {
result = *item;
tail--;
- tailVal = (int)queue[ tail ];
+ tailVal = (int)queue[tail];
for (;;) {
childNum = child1Index(itemNum);
if (childNum >= tail) break;
- child = &queue[ childNum ];
+ child = &queue[childNum];
// Select the lowest of the two children
if (childNum + 1 < tail
- && (int)child[ 0 ] > (int)child[ 1 ]) {
+ && (int)child[0] > (int)child[1]) {
childNum++;
child++;
}
@@ -122,7 +122,7 @@ bool PriorityQueue<ITEM, size>::remove(ITEM &result) {
}
if (itemNum != tail) {
- *item = queue[ tail ];
+ *item = queue[tail];
}
return TRUE;
}
diff --git a/engines/saga2/property.cpp b/engines/saga2/property.cpp
index b370d46814..3eacbdbd86 100644
--- a/engines/saga2/property.cpp
+++ b/engines/saga2/property.cpp
@@ -83,7 +83,7 @@ const SimpleObjectProperty objPropKey(objIsKey);
const SimpleObjectProperty objPropPlayerActor(objIsPlayerActor);
const SimpleObjectProperty objPropEnemy(objIsEnemy);
-const ObjectProperty *objPropArray[ objPropIDCount ] = {
+const ObjectProperty *objPropArray[objPropIDCount] = {
&objPropObject,
&objPropActor,
&objPropWorld,
@@ -127,7 +127,7 @@ const SimpleActorProperty actorPropCenterActor(actorIsCenterActor);
const SimpleActorProperty actorPropPlayerActor(actorIsPlayerActor);
const SimpleActorProperty actorPropEnemy(actorIsEnemy);
-const ActorProperty *actorPropArray[ actorPropIDCount ] = {
+const ActorProperty *actorPropArray[actorPropIDCount] = {
#ifdef FTA
&actorPropDead,
#endif
@@ -147,7 +147,7 @@ static bool tileHasWater(TileInfo *ti) {
const SimpleTileProperty tilePropHasWater(tileHasWater);
-const TileProperty *tilePropArray[ tilePropIDCount ] = {
+const TileProperty *tilePropArray[tilePropIDCount] = {
&tilePropHasWater,
};
@@ -205,7 +205,7 @@ bool MetaTilePropertyAnd::operator()(
// Iterate through each element in the array and if any evaluate to
// FALSE, return FALSE immediately.
for (i = 0; i < arraySize; i++)
- if ((*propertyArray[ i ])(mt, mapNum, tp) == FALSE) return FALSE;
+ if ((*propertyArray[i])(mt, mapNum, tp) == FALSE) return FALSE;
return TRUE;
}
@@ -223,7 +223,7 @@ bool MetaTilePropertyOr::operator()(
// Iterate through each element in the array and if any evaluate to
// TRUE, return TRUE immediately.
for (i = 0; i < arraySize; i++)
- if ((*propertyArray[ i ])(mt, mapNum, tp)) return TRUE;
+ if ((*propertyArray[i])(mt, mapNum, tp)) return TRUE;
return FALSE;
}
@@ -266,7 +266,7 @@ static bool metaTileHasWater(
const SimpleMetaTileProperty metaTilePropHasWater(metaTileHasWater);
-const MetaTileProperty *metaTilePropArray[ metaTilePropIDCount ] = {
+const MetaTileProperty *metaTilePropArray[metaTilePropIDCount] = {
&metaTilePropHasWater,
};
diff --git a/engines/saga2/property.h b/engines/saga2/property.h
index 213e36444c..356de3735d 100644
--- a/engines/saga2/property.h
+++ b/engines/saga2/property.h
@@ -157,7 +157,7 @@ bool PropertyAnd< T >::operator()(T *obj) const {
// Iterate through each element in the array and if any evaluate to
// FALSE, return FALSE immediately.
for (i = 0; i < arraySize; i++)
- if ((*propertyArray[ i ])(obj) == FALSE) return FALSE;
+ if ((*propertyArray[i])(obj) == FALSE) return FALSE;
#endif
warning("STUB: PropertyAnd");
@@ -191,7 +191,7 @@ bool PropertyOr< T >::operator()(T *obj) const {
// Iterate through each element in the array and if any evaluate to
// TRUE, return TRUE immediately.
for (i = 0; i < arraySize; i++)
- if ((*propertyArray[ i ])(obj)) return TRUE;
+ if ((*propertyArray[i])(obj)) return TRUE;
#endif
warning("STUB: PropertyOr");
@@ -224,10 +224,10 @@ enum {
objPropIDCount,
};
-extern const ObjectProperty *objPropArray[ objPropIDCount ];
+extern const ObjectProperty *objPropArray[objPropIDCount];
inline const ObjectProperty *getObjProp(ObjectPropertyID id) {
- return objPropArray[ id ];
+ return objPropArray[id];
}
/* ===================================================================== *
@@ -254,10 +254,10 @@ enum {
actorPropIDCount,
};
-extern const ActorProperty *actorPropArray[ actorPropIDCount ];
+extern const ActorProperty *actorPropArray[actorPropIDCount];
inline const ActorProperty *getActorProp(ActorPropertyID id) {
- return actorPropArray[ id ];
+ return actorPropArray[id];
}
/* ===================================================================== *
@@ -279,10 +279,10 @@ enum {
tilePropIDCount,
};
-extern const TileProperty *tilePropArray[ tilePropIDCount ];
+extern const TileProperty *tilePropArray[tilePropIDCount];
inline const TileProperty *getTileProp(TilePropertyID id) {
- return tilePropArray[ id ];
+ return tilePropArray[id];
}
/* ===================================================================== *
@@ -394,10 +394,10 @@ enum {
metaTilePropIDCount,
};
-extern const MetaTileProperty *metaTilePropArray[ metaTilePropIDCount ];
+extern const MetaTileProperty *metaTilePropArray[metaTilePropIDCount];
inline const MetaTileProperty *getMetaTileProp(MetaTilePropertyID id) {
- return metaTilePropArray[ id ];
+ return metaTilePropArray[id];
}
} // end of namespace Saga2
diff --git a/engines/saga2/pt2angle.cpp b/engines/saga2/pt2angle.cpp
index 11f12b9d20..b038e44f2b 100644
--- a/engines/saga2/pt2angle.cpp
+++ b/engines/saga2/pt2angle.cpp
@@ -28,7 +28,7 @@
namespace Saga2 {
-static int16 arcTanTable[ 257 ] = {
+static int16 arcTanTable[257] = {
0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5,
5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7,
@@ -48,7 +48,7 @@ static int16 arcTanTable[ 257 ] = {
32
};
-static int16 invCosTable[ 257 ] = {
+static int16 invCosTable[257] = {
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129,
129, 129, 129, 129, 129, 129, 129, 129, 130, 130, 130, 130, 130, 130, 130, 130,
@@ -134,18 +134,18 @@ int16 ptToAngle(int16 dx, int16 dy, int16 *dist) {
}
if (dx == dy) {
- if (dist) *dist = (invCosTable[ 256 ] * dx) >> 7;
+ if (dist) *dist = (invCosTable[256] * dx) >> 7;
return angle + 32; // avoids division by zero...
} else if (dx >= dy) {
int16 i = (dy << 8) / dx;
- if (dist) *dist = (invCosTable[ i ] * dx) >> 7;
- return angle + arcTanTable[ i ];
+ if (dist) *dist = (invCosTable[i] * dx) >> 7;
+ return angle + arcTanTable[i];
} else {
int16 i = (dx << 8) / dy;
- if (dist) *dist = (invCosTable[ i ] * dy) >> 7;
- return angle + 64 - arcTanTable[ i ];
+ if (dist) *dist = (invCosTable[i] * dy) >> 7;
+ return angle + 64 - arcTanTable[i];
}
}
diff --git a/engines/saga2/rmem.cpp b/engines/saga2/rmem.cpp
index e9f0d95335..21ce64caec 100644
--- a/engines/saga2/rmem.cpp
+++ b/engines/saga2/rmem.cpp
@@ -963,7 +963,7 @@ static RHandleBlock *NewHandleBlock(RHeapPtr heap, const char desc[]) {
// Initialize each of the handles in the block.
for (i = 0; i < HANDLES_PER_BLOCK; i++) { // link each handle into chain
- RHandle *rh = &hBlock->handles[ i ];
+ RHandle *rh = &hBlock->handles[i];
// rh->data = NULL;
RLinkHandle(rh, (RHandle *)&hBlock->freeHandles);
@@ -1022,8 +1022,8 @@ static void FreeHandle(RHeap *heap, RHandle *handle) {
// Search for a handle in an existing block that's already free
for (hBlock = heap->handleBlocks; hBlock; hBlock = hBlock->next) {
- if (handle >= &hBlock->handles[ 0 ]
- && handle < &hBlock->handles[ HANDLES_PER_BLOCK ]) {
+ if (handle >= &hBlock->handles[0]
+ && handle < &hBlock->handles[HANDLES_PER_BLOCK]) {
RDelinkHandle(handle);
handle->data = NULL;
diff --git a/engines/saga2/rmembase.h b/engines/saga2/rmembase.h
index 70d53cc50b..3440140f5d 100644
--- a/engines/saga2/rmembase.h
+++ b/engines/saga2/rmembase.h
@@ -140,7 +140,7 @@ struct RHandleBlock {
uint16 freeHandleCount; // number of handles in use
RHandle *freeHandles; // the first free handle in block
- RHandle handles[ HANDLES_PER_BLOCK ]; // array of handles
+ RHandle handles[HANDLES_PER_BLOCK]; // array of handles
};
// An "RMemFreeBlock" keeps track of which areas are unused.
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index b8082f3a91..6fbe80dfe1 100644
--- a/engines/saga2/sagafunc.cpp
+++ b/engines/saga2/sagafunc.cpp
@@ -82,14 +82,14 @@ inline char *STRING(int strNum) {
int stringf(char *buffer, long maxlen, int formatStr, int16 *args) {
char *fmt = STRING(formatStr);
char *bufEnd = buffer + maxlen - 1;
- char dbuf[ 16 ], // temp buffer for digits
+ char dbuf[16], // temp buffer for digits
*dptr;
// While there is room in the buffer
while (buffer < bufEnd && *fmt != '\0') {
// Format string character
if (*fmt == '%') {
- if (fmt[ 1 ] == 'd') { // If it's %d
+ if (fmt[1] == 'd') { // If it's %d
// Convert numeric argument to string
snprintf(dbuf, 15, "%d", *args++);
@@ -97,7 +97,7 @@ int stringf(char *buffer, long maxlen, int formatStr, int16 *args) {
for (dptr = dbuf; *dptr && buffer < bufEnd;) {
*buffer++ = *dptr++;
}
- } else if (fmt[ 1 ] == 'x') { // If it's %x
+ } else if (fmt[1] == 'x') { // If it's %x
// Convert numeric argument to string
snprintf(dbuf, 15, "%x", *args++);
@@ -105,12 +105,12 @@ int stringf(char *buffer, long maxlen, int formatStr, int16 *args) {
for (dptr = dbuf; *dptr && buffer < bufEnd;) {
*buffer++ = *dptr++;
}
- } else if (fmt[ 1 ] == 's') { // If it's %s
+ } else if (fmt[1] == 's') { // If it's %s
// Obtain SAGA string, copy to buffer (if it fits)
for (dptr = STRING(*args++); *dptr && buffer < bufEnd;) {
*buffer++ = *dptr++;
}
- } else if (fmt[ 1 ] == 'n') { // If it's %n (object name)
+ } else if (fmt[1] == 'n') { // If it's %n (object name)
GameObject *obj = GameObject::objectAddress(*args++);
// Obtain SAGA string, copy to buffer (if it fits)
@@ -119,7 +119,7 @@ int stringf(char *buffer, long maxlen, int formatStr, int16 *args) {
}
} else {
// Write the character after the '%' to the buffer
- *buffer++ = fmt[ 1 ];
+ *buffer++ = fmt[1];
}
fmt += 2;
} else *buffer++ = *fmt++;
@@ -180,13 +180,13 @@ int16 scriptActorMove(int16 *args) {
GameObject *obj = (GameObject *)thisThread->thisObject;
// Move the object to a new location
- obj->move(TilePoint(args[ 0 ], args[ 1 ], args[ 2 ]));
+ obj->move(TilePoint(args[0], args[1], args[2]));
// If optional 4th parameter is present, then set actor facing
if (thisThread->argCount > 3 && isActor(obj)) {
Actor *a = (Actor *)obj;
- a->currentFacing = args[ 3 ];
+ a->currentFacing = args[3];
}
return 0;
@@ -197,12 +197,12 @@ int16 scriptActorMove(int16 *args) {
// parameter is for actor facing, only used by actors)
// void "c" moveRel( GameObject id baseObj, int angle, int distance, ... );
-extern TilePoint dirTable[ 8 ];
+extern TilePoint dirTable[8];
int16 scriptActorMoveRel(int16 *args) {
OBJLOG(MoveRel);
GameObject *obj = (GameObject *)thisThread->thisObject,
- *baseObj = GameObject::objectAddress(args[ 0 ]);
+ *baseObj = GameObject::objectAddress(args[0]);
Location l;
TilePoint tp;
@@ -210,7 +210,7 @@ int16 scriptActorMoveRel(int16 *args) {
tp = baseObj->getLocation();
// Add offset for angle and distance
- tp += (dirTable[ args[ 1 ] & 7 ] * args[ 2 ]) / 3;
+ tp += (dirTable[args[1] & 7] * args[2]) / 3;
// Move the object to a new location
*(TilePoint *)&l = tp;
@@ -220,7 +220,7 @@ int16 scriptActorMoveRel(int16 *args) {
if (thisThread->argCount > 3 && isActor(obj)) {
Actor *a = (Actor *)obj;
- a->currentFacing = args[ 3 ];
+ a->currentFacing = args[3];
}
return 0;
@@ -236,11 +236,11 @@ int16 scriptActorTransfer(int16 *args) {
GameObject *obj = (GameObject *)thisThread->thisObject;
// Move the object to a new location
- if ((isObject(args[ 0 ])
- && (GameObject::protoAddress(args[ 0 ])->containmentSet()
+ if ((isObject(args[0])
+ && (GameObject::protoAddress(args[0])->containmentSet()
& ProtoObj::isContainer))
- || isActor(args[ 0 ])) {
- ObjectID targetID = args[ 0 ];
+ || isActor(args[0])) {
+ ObjectID targetID = args[0];
GameObject *target = GameObject::objectAddress(targetID);
TilePoint targetSlot;
@@ -255,14 +255,14 @@ int16 scriptActorTransfer(int16 *args) {
globalContainerList.setUpdate(targetID);
}
} else {
- obj->move(Location(args[ 1 ], args[ 2 ], args[ 3 ], args[ 0 ]));
+ obj->move(Location(args[1], args[2], args[3], args[0 ]));
}
// If optional 5th parameter is present, then set actor facing
if (thisThread->argCount > 4 && isActor(obj)) {
Actor *a = (Actor *)obj;
- a->currentFacing = args[ 4 ];
+ a->currentFacing = args[4];
}
return 0;
@@ -276,14 +276,14 @@ int16 scriptMoveRandom(int16 *args) {
OBJLOG(MoveRandom);
GameObject *obj = (GameObject *)thisThread->thisObject;
TilePoint tpMin, tpMax;
- int16 distance = args[ 3 ];
+ int16 distance = args[3];
- tpMin.u = args[ 0 ] - distance;
- tpMin.v = args[ 1 ] - distance;
+ tpMin.u = args[0] - distance;
+ tpMin.v = args[1] - distance;
tpMin.z = 0;
- tpMax.u = args[ 0 ] + distance;
- tpMax.v = args[ 1 ] + distance;
+ tpMax.u = args[0] + distance;
+ tpMax.v = args[1] + distance;
tpMax.z = 100;
obj->moveRandom(tpMin, tpMax);
@@ -311,7 +311,7 @@ int16 scriptActorSetName(int16 *args) {
GameObject *obj = (GameObject *)thisThread->thisObject;
int16 oldName = obj->getNameIndex();
- obj->setNameIndex(args[ 0 ]);
+ obj->setNameIndex(args[0]);
return oldName;
}
@@ -337,10 +337,10 @@ int16 scriptActorSetProto(int16 *args) {
if (isActor(obj) && (((Actor *)obj)->flags & Actor::temporary)) {
decTempActorCount(oldProto);
- incTempActorCount(args[ 0 ]);
+ incTempActorCount(args[0]);
}
- obj->setProtoNum(args[ 0 ]);
+ obj->setProtoNum(args[0]);
return oldProto;
}
@@ -376,7 +376,7 @@ int16 scriptActorSetScript(int16 *args) {
GameObject *obj = (GameObject *)thisThread->thisObject;
int16 oldScript = obj->getScript();
- obj->setScript(args[ 0 ]);
+ obj->setScript(args[0]);
return oldScript;
}
@@ -389,7 +389,7 @@ int16 scriptGameObjectUse(int16 *args) {
OBJLOG(Use);
GameObject *obj = (GameObject *)thisThread->thisObject;
- return obj->use(args[ 0 ]);
+ return obj->use(args[0]);
}
//-----------------------------------------------------------------------
@@ -400,7 +400,7 @@ int16 scriptGameObjectUseOn(int16 *args) {
OBJLOG(UseOn);
GameObject *obj = (GameObject *)thisThread->thisObject;
- return obj->useOn(args[ 0 ], args[ 1 ]);
+ return obj->useOn(args[0], args[1]);
}
//-----------------------------------------------------------------------
@@ -411,7 +411,7 @@ int16 scriptGameObjectUseOnTAI(int16 *args) {
OBJLOG(UseOnTAI);
GameObject *obj = (GameObject *)thisThread->thisObject;
- return obj->useOn(args[ 0 ], ActiveItem::activeItemAddress(args[ 1 ]));
+ return obj->useOn(args[0], ActiveItem::activeItemAddress(args[1]));
}
//-----------------------------------------------------------------------
@@ -428,8 +428,8 @@ int16 scriptGameObjectDrop(int16 *args) {
GameObject *obj = (GameObject *)thisThread->thisObject;
return obj->drop(
- args[ 0 ],
- Location(args[ 2 ], args[ 3 ], args[ 4 ], args[ 1 ]));
+ args[0],
+ Location(args[2], args[3], args[4], args[1 ]));
}
//-----------------------------------------------------------------------
@@ -440,7 +440,7 @@ int16 scriptGameObjectDropOn(int16 *args) {
OBJLOG(DropOn);
GameObject *obj = (GameObject *)thisThread->thisObject;
- return obj->dropOn(args[ 0 ], args[ 1 ]);
+ return obj->dropOn(args[0], args[1]);
}
//-----------------------------------------------------------------------
@@ -454,7 +454,7 @@ int16 scriptGameObjectDropMergeableOn(int16 *args) {
OBJLOG(DropMergeableOn);
GameObject *obj = (GameObject *)thisThread->thisObject;
- return obj->dropOn(args[ 0 ], args[ 1 ], args[ 2 ]);
+ return obj->dropOn(args[0], args[1], args[2]);
}
//-----------------------------------------------------------------------
@@ -472,9 +472,9 @@ int16 scriptGameObjectDropOnTAI(int16 *args) {
GameObject *obj = (GameObject *)thisThread->thisObject;
return obj->dropOn(
- args[ 0 ],
- ActiveItem::activeItemAddress(args[ 1 ]),
- Location(args[ 3 ], args[ 4 ], args[ 5 ], args[ 2 ]));
+ args[0],
+ ActiveItem::activeItemAddress(args[1]),
+ Location(args[3], args[4], args[5], args[2 ]));
}
//-----------------------------------------------------------------------
@@ -494,7 +494,7 @@ int16 scriptActorSay(int16 *args) {
// 'obj' is the actor doing the speaking.
GameObject *obj = (GameObject *)thisThread->thisObject;
- uint16 flags = args[ 0 ];
+ uint16 flags = args[0];
Speech *sp;
if (isActor(obj)) {
@@ -521,8 +521,8 @@ int16 scriptActorSay(int16 *args) {
// Loop through each of the arguments.
// REM: Might want to do some range checking on the arguments.
for (int i = 1; i < thisThread->argCount; i += 2) {
- uint16 sampleNum = args[ i ];
- char *speechText = STRING(args[ i + 1 ]);
+ uint16 sampleNum = args[i];
+ char *speechText = STRING(args[i + 1]);
sp->append(speechText, sampleNum);
}
@@ -552,14 +552,14 @@ int16 scriptActorSayText(int16 *args) {
// 'obj' is the actor doing the speaking.
GameObject *obj = (GameObject *)thisThread->thisObject;
Speech *sp;
- char buffer[ 256 ];
+ char buffer[256];
// Determine if a speech record is being built for this actor.
// If so, then retrieve it. If not, then fail.
sp = speechList.findSpeech(obj->thisID());
if (sp == NULL) return 0;
- stringf(buffer, sizeof buffer, args[ 0 ], &args[ 1 ]);
+ stringf(buffer, sizeof buffer, args[0], &args[1]);
sp->append(buffer, 0);
return 1;
}
@@ -623,7 +623,7 @@ int16 scriptActorGetScavengable(int16 *) {
int16 scriptActorSetOpen( int16 *args )
{
((GameObject *)thisThread->thisObject)->setFlags(
- args[0 ] ? 0xffff : 0,
+ args[0] ? 0xffff : 0,
objectOpen );
return 0;
}
@@ -631,7 +631,7 @@ int16 scriptActorSetOpen( int16 *args )
int16 scriptActorSetLocked( int16 *args )
{
((GameObject *)thisThread->thisObject)->setFlags(
- args[0 ] ? 0xffff : 0,
+ args[0] ? 0xffff : 0,
objectLocked );
return 0;
}
@@ -640,7 +640,7 @@ int16 scriptActorSetLocked( int16 *args )
int16 scriptActorSetImportant(int16 *args) {
OBJLOG(SetImportant);
((GameObject *)thisThread->thisObject)->setFlags(
- args[0 ] ? (int16) 0xffff : (int16) 0,
+ args[0] ? (int16) 0xffff : (int16) 0,
objectImportant);
return 0;
}
@@ -648,7 +648,7 @@ int16 scriptActorSetImportant(int16 *args) {
int16 scriptActorSetScavengable(int16 *args) {
OBJLOG(SetScavengable);
((GameObject *)thisThread->thisObject)->setFlags(
- args[0 ] ? (int16) 0xffff : (int16) 0,
+ args[0] ? (int16) 0xffff : (int16) 0,
objectScavengable);
return 0;
}
@@ -661,7 +661,7 @@ int16 scriptGameObjectAddTimer(int16 *args) {
OBJLOG(AddTimer);
GameObject *obj = (GameObject *)thisThread->thisObject;
- return obj->addTimer(args[ 0 ], args[ 1 ]);
+ return obj->addTimer(args[0], args[1]);
}
//-----------------------------------------------------------------------
@@ -673,7 +673,7 @@ int16 scriptGameObjectAddStdTimer(int16 *args) {
OBJLOG(AddStdTimer);
GameObject *obj = (GameObject *)thisThread->thisObject;
- return obj->addTimer(args[ 0 ]);
+ return obj->addTimer(args[0]);
}
//-----------------------------------------------------------------------
@@ -684,7 +684,7 @@ int16 scriptGameObjectRemoveTimer(int16 *args) {
OBJLOG(RemoveTimer);
GameObject *obj = (GameObject *)thisThread->thisObject;
- obj->removeTimer(args[ 0 ]);
+ obj->removeTimer(args[0]);
return 0;
}
@@ -711,7 +711,7 @@ int16 scriptGameObjectAddProtaganistSensor(int16 *args) {
OBJLOG(AddProtaganistSensor);
GameObject *obj = (GameObject *)thisThread->thisObject;
- return obj->addProtaganistSensor(args[ 0 ], args[ 1 ]);
+ return obj->addProtaganistSensor(args[0], args[1]);
}
//-----------------------------------------------------------------------
@@ -724,14 +724,14 @@ int16 scriptGameObjectAddProtaganistSensor(int16 *args) {
int16 scriptGameObjectAddSpecificActorSensor(int16 *args) {
OBJLOG(AddSpecificActorSensor);
- assert(isActor(args[ 2 ]));
+ assert(isActor(args[2]));
GameObject *obj = (GameObject *)thisThread->thisObject;
return obj->addSpecificActorSensor(
- args[ 0 ],
- args[ 1 ],
- (Actor *)GameObject::objectAddress(args[ 2 ]));
+ args[0],
+ args[1],
+ (Actor *)GameObject::objectAddress(args[2]));
}
//-----------------------------------------------------------------------
@@ -744,11 +744,11 @@ int16 scriptGameObjectAddSpecificActorSensor(int16 *args) {
int16 scriptGameObjectAddSpecificObjectSensor(int16 *args) {
OBJLOG(AddSpecificObjectSensor);
- assert(isObject(args[ 2 ]) || isActor(args[ 2 ]));
+ assert(isObject(args[2]) || isActor(args[2]));
GameObject *obj = (GameObject *)thisThread->thisObject;
- return obj->addSpecificObjectSensor(args[ 0 ], args[ 1 ], args[ 2 ]);
+ return obj->addSpecificObjectSensor(args[0], args[1], args[2]);
}
//-----------------------------------------------------------------------
@@ -763,7 +763,7 @@ int16 scriptGameObjectAddActorPropertySensor(int16 *args) {
OBJLOG(AddActorPropertySensor);
GameObject *obj = (GameObject *)thisThread->thisObject;
- return obj->addActorPropertySensor(args[ 0 ], args[ 1 ], args[ 2 ]);
+ return obj->addActorPropertySensor(args[0], args[1], args[2]);
}
//-----------------------------------------------------------------------
@@ -778,7 +778,7 @@ int16 scriptGameObjectAddObjectPropertySensor(int16 *args) {
OBJLOG(AddObjectPropertySensor);
GameObject *obj = (GameObject *)thisThread->thisObject;
- return obj->addObjectPropertySensor(args[ 0 ], args[ 1 ], args[ 2 ]);
+ return obj->addObjectPropertySensor(args[0], args[1], args[2]);
}
//-----------------------------------------------------------------------
@@ -791,9 +791,9 @@ int16 scriptGameObjectAddEventSensor(int16 *args) {
GameObject *obj = (GameObject *)thisThread->thisObject;
return obj->addEventSensor(
- args[ 0 ],
- args[ 1 ],
- args[ 2 ]);
+ args[0],
+ args[1],
+ args[2]);
}
//-----------------------------------------------------------------------
@@ -804,7 +804,7 @@ int16 scriptGameObjectRemoveSensor(int16 *args) {
OBJLOG(RemoveSensor);
GameObject *obj = (GameObject *)thisThread->thisObject;
- obj->removeSensor(args[ 0 ]);
+ obj->removeSensor(args[0]);
return 0;
}
@@ -831,7 +831,7 @@ int16 scriptGameObjectCanSenseProtaganist(int16 *args) {
GameObject *obj = (GameObject *)thisThread->thisObject;
SenseInfo info;
- if (obj->canSenseProtaganist(info, args[ 0 ])) {
+ if (obj->canSenseProtaganist(info, args[0])) {
scriptCallFrame &scf = thisThread->threadArgs;
scf.enactor = obj->thisID();
@@ -850,15 +850,15 @@ int16 scriptGameObjectCanSenseProtaganist(int16 *args) {
int16 scriptGameObjectCanSenseSpecificActor(int16 *args) {
OBJLOG(CanSenseSpecificActor);
- assert(isActor(args[ 1 ]));
+ assert(isActor(args[1]));
GameObject *obj = (GameObject *)thisThread->thisObject;
SenseInfo info;
if (obj->canSenseSpecificActor(
info,
- args[ 0 ],
- (Actor *)GameObject::objectAddress(args[ 1 ]))) {
+ args[0],
+ (Actor *)GameObject::objectAddress(args[1]))) {
scriptCallFrame &scf = thisThread->threadArgs;
scf.enactor = obj->thisID();
@@ -877,12 +877,12 @@ int16 scriptGameObjectCanSenseSpecificActor(int16 *args) {
int16 scriptGameObjectCanSenseSpecificObject(int16 *args) {
OBJLOG(CanSenseSpecificObject);
- assert(isObject(args[ 1 ]) || isActor(args[ 1 ]));
+ assert(isObject(args[1]) || isActor(args[1]));
GameObject *obj = (GameObject *)thisThread->thisObject;
SenseInfo info;
- if (obj->canSenseSpecificObject(info, args[ 0 ], args[ 1 ])) {
+ if (obj->canSenseSpecificObject(info, args[0], args[1])) {
scriptCallFrame &scf = thisThread->threadArgs;
scf.enactor = obj->thisID();
@@ -904,7 +904,7 @@ int16 scriptGameObjectCanSenseActorProperty(int16 *args) {
GameObject *obj = (GameObject *)thisThread->thisObject;
SenseInfo info;
- if (obj->canSenseActorProperty(info, args[ 0 ], args[ 1 ])) {
+ if (obj->canSenseActorProperty(info, args[0], args[1])) {
scriptCallFrame &scf = thisThread->threadArgs;
scf.enactor = obj->thisID();
@@ -926,7 +926,7 @@ int16 scriptGameObjectCanSenseObjectProperty(int16 *args) {
GameObject *obj = (GameObject *)thisThread->thisObject;
SenseInfo info;
- if (obj->canSenseObjectProperty(info, args[ 0 ], args[ 1 ])) {
+ if (obj->canSenseObjectProperty(info, args[0], args[1])) {
scriptCallFrame &scf = thisThread->threadArgs;
scf.enactor = obj->thisID();
@@ -984,11 +984,11 @@ int16 scriptGameObjectSetMass(int16 *args) {
OBJLOG(SetMass);
GameObject *obj = (GameObject *)thisThread->thisObject;
-// assert( args[ 0 ] > 0 );
- assert(args[ 0 ] < maxuint16);
+// assert( args[0] > 0 );
+ assert(args[0] < maxuint16);
if (obj->proto()->flags & ResourceObjectPrototype::objPropMergeable) {
- obj->setExtra(args[ 0 ]);
+ obj->setExtra(args[0]);
if (obj->proto()->flags & ResourceObjectPrototype::objPropMergeable) {
globalContainerList.setUpdate(obj->IDParent());
}
@@ -1015,7 +1015,7 @@ int16 scriptGameObjectSetExtra(int16 *args) {
OBJLOG(SetExtra);
GameObject *obj = (GameObject *)thisThread->thisObject;
- obj->setExtra(args[ 0 ]);
+ obj->setExtra(args[0]);
return 0;
}
@@ -1050,7 +1050,7 @@ int16 deepCopy(GameObject *src, ObjectID parentID, TilePoint tp) {
int16 scriptGameObjectDeepCopy(int16 *args) {
OBJLOG(DeepCopy);
- ObjectID newParentID = args[ 0 ];
+ ObjectID newParentID = args[0];
GameObject *obj = (GameObject *)thisThread->thisObject,
*newParent = GameObject::objectAddress(newParentID),
*newObj;
@@ -1081,8 +1081,8 @@ int16 scriptGameObjectAddEnchantment(int16 *args) {
GameObject *obj = (GameObject *)thisThread->thisObject;
return EnchantObject(obj->thisID(),
- makeEnchantmentID(args[ 0 ], args[ 1 ], args[ 2 ]),
- args[ 3 ]);
+ makeEnchantmentID(args[0], args[1], args[2]),
+ args[3]);
}
//-----------------------------------------------------------------------
@@ -1094,7 +1094,7 @@ int16 scriptGameObjectRemoveEnchantment(int16 *args) {
GameObject *obj = (GameObject *)thisThread->thisObject;
return DispelObjectEnchantment(obj->thisID(),
- makeEnchantmentID(args[ 0 ], args[ 1 ], 0));
+ makeEnchantmentID(args[0], args[1], 0));
}
//-----------------------------------------------------------------------
@@ -1106,7 +1106,7 @@ int16 scriptGameObjectFindEnchantment(int16 *args) {
GameObject *obj = (GameObject *)thisThread->thisObject;
return FindObjectEnchantment(obj->thisID(),
- makeEnchantmentID(args[ 0 ], args[ 1 ], 0));
+ makeEnchantmentID(args[0], args[1], 0));
}
//-----------------------------------------------------------------------
@@ -1129,7 +1129,7 @@ int16 scriptActorGetScratchVar(int16 *args) {
if (isActor((GameObject *)thisThread->thisObject)) {
Actor *a = (Actor *)thisThread->thisObject;
- return a->scriptVar[ args[ 0 ] ];
+ return a->scriptVar[args[0]];
}
return 0;
@@ -1143,9 +1143,9 @@ int16 scriptActorSetScratchVar(int16 *args) {
OBJLOG(SetScratchVar);
if (isActor((GameObject *)thisThread->thisObject)) {
Actor *a = (Actor *)thisThread->thisObject;
- int16 oldVal = a->scriptVar[ args[ 0 ] ];
+ int16 oldVal = a->scriptVar[args[0]];
- a->scriptVar[ args[ 0 ] ] = args[ 1 ];
+ a->scriptVar[args[0]] = args[1];
return oldVal;
}
@@ -1177,7 +1177,7 @@ int16 scriptActorSetDisposition(int16 *args) {
if (isActor((GameObject *)thisThread->thisObject)) {
Actor *a = (Actor *)thisThread->thisObject;
- return a->setDisposition(args[ 0 ]);
+ return a->setDisposition(args[0]);
}
return 0;
@@ -1192,7 +1192,7 @@ int16 scriptActorGetSkill(int16 *args) {
if (isActor((GameObject *)thisThread->thisObject)) {
Actor *a = (Actor *)thisThread->thisObject;
- return a->getStats()->skill(args[ 0 ]);
+ return a->getStats()->skill(args[0]);
}
return 0;
@@ -1206,10 +1206,10 @@ int16 scriptActorSetSkill(int16 *args) {
OBJLOG(SetSkill);
if (isActor((GameObject *)thisThread->thisObject)) {
Actor *a = (Actor *)thisThread->thisObject;
- uint8 &skillRef = a->getStats()->skill(args[ 0 ]);
+ uint8 &skillRef = a->getStats()->skill(args[0]);
uint8 oldVal = skillRef;
- skillRef = args[ 1 ];
+ skillRef = args[1];
return oldVal;
}
@@ -1226,7 +1226,7 @@ int16 scriptActorGetBaseSkill(int16 *args) {
if (isActor((GameObject *)thisThread->thisObject)) {
Actor *a = (Actor *)thisThread->thisObject;
- return a->getBaseStats()->skill(args[ 0 ]);
+ return a->getBaseStats()->skill(args[0]);
}
return 0;
@@ -1240,12 +1240,12 @@ int16 scriptActorSetBaseSkill(int16 *args) {
OBJLOG(SetBaseSkill);
if (isActor((GameObject *)thisThread->thisObject)) {
Actor *a = (Actor *)thisThread->thisObject;
- uint8 &skillRef = a->getBaseStats()->skill(args[ 0 ]);
+ uint8 &skillRef = a->getBaseStats()->skill(args[0]);
uint8 oldVal = skillRef;
// If not a player actor, do nothing
- if (isPlayerActor(a)) skillRef = args[ 1 ];
+ if (isPlayerActor(a)) skillRef = args[1];
return oldVal;
}
@@ -1280,7 +1280,7 @@ int16 scriptActorSetVitality(int16 *args) {
int16 oldVal = vitalityRef;
PlayerActorID pID;
- vitalityRef = args[ 0 ];
+ vitalityRef = args[0];
if (actorToPlayerID(a, pID)) updateBrotherControls(pID);
return oldVal;
@@ -1318,7 +1318,7 @@ int16 scriptActorSetBaseVitality(int16 *args) {
// If not a player actor, do nothing
if (actorToPlayerID(a, pID)) {
- vitalityRef = args[ 0 ];
+ vitalityRef = args[0];
updateBrotherControls(pID);
}
@@ -1337,7 +1337,7 @@ int16 scriptActorGetMana(int16 *args) {
if (isActor((GameObject *)thisThread->thisObject)) {
Actor *a = (Actor *)thisThread->thisObject;
- return a->getStats()->mana(args[ 0 ]);
+ return a->getStats()->mana(args[0]);
}
return 0;
@@ -1351,11 +1351,11 @@ int16 scriptActorSetMana(int16 *args) {
OBJLOG(SetMana);
if (isActor((GameObject *)thisThread->thisObject)) {
Actor *a = (Actor *)thisThread->thisObject;
- int16 &manaRef = a->getStats()->mana(args[ 0 ]);
+ int16 &manaRef = a->getStats()->mana(args[0]);
int16 oldVal = manaRef;
PlayerActorID pID;
- manaRef = args[ 1 ];
+ manaRef = args[1];
if (actorToPlayerID(a, pID)) updateBrotherControls(pID);
return oldVal;
@@ -1373,7 +1373,7 @@ int16 scriptActorGetBaseMana(int16 *args) {
if (isActor((GameObject *)thisThread->thisObject)) {
Actor *a = (Actor *)thisThread->thisObject;
- return a->getBaseStats()->mana(args[ 0 ]);
+ return a->getBaseStats()->mana(args[0]);
}
return 0;
@@ -1387,12 +1387,12 @@ int16 scriptActorSetBaseMana(int16 *args) {
OBJLOG(SetBaseMana);
if (isActor((GameObject *)thisThread->thisObject)) {
Actor *a = (Actor *)thisThread->thisObject;
- int16 &manaRef = a->getBaseStats()->mana(args[ 0 ]);
+ int16 &manaRef = a->getBaseStats()->mana(args[0]);
int16 oldVal = manaRef;
PlayerActorID pID;
// If not a player actor, do nothing
- if (isPlayerActor(a)) manaRef = args[ 1 ];
+ if (isPlayerActor(a)) manaRef = args[1];
if (actorToPlayerID(a, pID)) updateBrotherControls(pID);
return oldVal;
@@ -1426,7 +1426,7 @@ int16 scriptActorSetSchedule(int16 *args) {
Actor *a = (Actor *)thisThread->thisObject;
uint16 oldSchedule = a->schedule;
- a->schedule = (uint16)args[ 0 ];
+ a->schedule = (uint16)args[0];
if (a->getAssignment() != NULL)
delete a->getAssignment();
@@ -1476,7 +1476,7 @@ int16 scriptActorIsActionAvailable(int16 *args) {
if (isActor((GameObject *)thisThread->thisObject)) {
Actor *a = (Actor *)thisThread->thisObject;
- return a->isActionAvailable(args[ 0 ], args[ 1 ]);
+ return a->isActionAvailable(args[0], args[1]);
}
return 0;
@@ -1493,7 +1493,7 @@ int16 scriptActorSetAction(int16 *args) {
if (isActor((GameObject *)thisThread->thisObject)) {
Actor *a = (Actor *)thisThread->thisObject;
- return a->setAction(args[ 0 ], args[ 1 ]);
+ return a->setAction(args[0], args[1]);
}
return 0;
@@ -1509,7 +1509,7 @@ int16 scriptActorAnimationFrames(int16 *args) {
if (isActor((GameObject *)thisThread->thisObject)) {
Actor *a = (Actor *)thisThread->thisObject;
- return a->animationFrames(args[ 0 ], args[ 1 ]);
+ return a->animationFrames(args[0], args[1]);
}
return 0;
@@ -1545,7 +1545,7 @@ int16 scriptActorFace(int16 *args) {
oldFacing = a->currentFacing;
- a->currentFacing = args[ 0 ] & 7;
+ a->currentFacing = args[0] & 7;
}
return oldFacing;
@@ -1561,14 +1561,14 @@ int16 scriptActorFaceTowards(int16 *args) {
int16 oldFacing = 0;
if (isActor((GameObject *)thisThread->thisObject)) {
- assert(isObject(args[ 0 ]) || isActor(args[ 0 ]));
+ assert(isObject(args[0]) || isActor(args[0]));
Actor *a = (Actor *)thisThread->thisObject;
oldFacing = a->currentFacing;
a->currentFacing =
- (GameObject::objectAddress(args[ 0 ])->getLocation()
+ (GameObject::objectAddress(args[0])->getLocation()
- a->getLocation()).quickDir();
}
@@ -1586,13 +1586,13 @@ int16 scriptActorTurn(int16 *args) {
if (a->isDead()) return 0;
- uint16 flags = args[ 1 ];
+ uint16 flags = args[1];
if (flags & moveWait) {
thisThread->waitForEvent(Thread::waitOther, 0);
- MotionTask::turn(getThreadID(thisThread), *a, args[ 0 ] & 7);
+ MotionTask::turn(getThreadID(thisThread), *a, args[0] & 7);
} else {
- MotionTask::turn(*a, args[ 0 ] & 7);
+ MotionTask::turn(*a, args[0] & 7);
return motionStarted;
}
}
@@ -1607,16 +1607,16 @@ int16 scriptActorTurn(int16 *args) {
int16 scriptActorTurnTowards(int16 *args) {
OBJLOG(TurnTowards);
if (isActor((GameObject *)thisThread->thisObject)) {
- assert(isObject(args[ 0 ]) || isActor(args[ 0 ]));
+ assert(isObject(args[0]) || isActor(args[0]));
Actor *a = (Actor *)thisThread->thisObject;
if (a->isDead()) return 0;
- uint16 flags = args[ 1 ];
+ uint16 flags = args[1];
Direction dir;
- dir = (GameObject::objectAddress(args[ 0 ])->getLocation()
+ dir = (GameObject::objectAddress(args[0])->getLocation()
- a->getLocation()).quickDir();
if (flags & moveWait) {
@@ -1641,8 +1641,8 @@ int16 scriptActorWalk(int16 *args) {
if (a->isDead()) return 0;
- TilePoint dest(args[ 0 ], args[ 1 ], args[ 2 ]);
- uint16 flags = args[ 3 ];
+ TilePoint dest(args[0], args[1], args[2]);
+ uint16 flags = args[3];
if (flags & moveWait) {
thisThread->waitForEvent(Thread::waitOther, 0);
@@ -1675,12 +1675,12 @@ int16 scriptActorAssignPatrolRoute(int16 *args) {
if (a->getAssignment() != NULL) delete a->getAssignment();
if (new (a) PatrolRouteAssignment(
- (uint16)args[ 0 ]
+ (uint16)args[0]
* CalenderTime::framesPerHour,
- args[ 1 ],
- (uint8)args[ 2 ],
+ args[1],
+ (uint8)args[2],
thisThread->argCount >= 4
- ? args[ 3 ]
+ ? args[3]
: -1)
!= NULL)
return TRUE;
@@ -1707,12 +1707,12 @@ int16 scriptActorAssignPartialPatrolRoute(int16 *args) {
if (a->getAssignment() != NULL) delete a->getAssignment();
if (new (a) PatrolRouteAssignment(
- (uint16)args[ 0 ]
+ (uint16)args[0]
* CalenderTime::framesPerHour,
- args[ 1 ],
- (uint8)args[ 2 ],
- args[ 3 ],
- args[ 4 ])
+ args[1],
+ (uint8)args[2],
+ args[3],
+ args[4])
!= NULL)
return TRUE;
}
@@ -1734,15 +1734,15 @@ int16 scriptActorAssignBeNearLocation(int16 *args) {
OBJLOG(AssignBeNearLocation);
if (isActor((GameObject *)thisThread->thisObject)) {
Actor *a = (Actor *)thisThread->thisObject;
- TilePoint targetLoc = TilePoint(args[ 1 ], args[ 2 ], args[ 3 ]);
+ TilePoint targetLoc = TilePoint(args[1], args[2], args[3]);
// Delete the actor's current assignment
if (a->getAssignment() != NULL) delete a->getAssignment();
if (new (a) HuntToBeNearLocationAssignment(
- args[ 0 ],
+ args[0],
targetLoc,
- args[ 4 ])
+ args[4])
!= NULL)
return TRUE;
}
@@ -1762,21 +1762,21 @@ int16 scriptActorAssignBeNearLocation(int16 *args) {
int16 scriptActorAssignBeNearActor(int16 *args) {
OBJLOG(AssignBeNearActor);
if (isActor((GameObject *)thisThread->thisObject)) {
- assert(isActor(args[ 1 ]));
+ assert(isActor(args[1]));
Actor *a = (Actor *)thisThread->thisObject,
*targetActor;
- targetActor = (Actor *)GameObject::objectAddress(args[ 1 ]);
+ targetActor = (Actor *)GameObject::objectAddress(args[1]);
// Delete the actor's current assignment
if (a->getAssignment() != NULL) delete a->getAssignment();
if (new (a) HuntToBeNearActorAssignment(
- args[ 0 ],
+ args[0],
targetActor,
- args[ 2 ],
- args[ 3 ])
+ args[2],
+ args[3])
!= NULL)
return TRUE;
}
@@ -1791,20 +1791,20 @@ int16 scriptActorAssignBeNearActor(int16 *args) {
int16 scriptActorAssignKillActor(int16 *args) {
OBJLOG(AssignKillActor);
if (isActor((GameObject *)thisThread->thisObject)) {
- assert(isActor(args[ 1 ]));
+ assert(isActor(args[1]));
Actor *a = (Actor *)thisThread->thisObject,
*targetActor;
- targetActor = (Actor *)GameObject::objectAddress(args[ 1 ]);
+ targetActor = (Actor *)GameObject::objectAddress(args[1]);
// Delete the actor's current assignment
if (a->getAssignment() != NULL) delete a->getAssignment();
if (new (a) HuntToKillAssignment(
- args[ 0 ],
+ args[0],
targetActor,
- args[ 2 ])
+ args[2])
!= NULL)
return TRUE;
}
@@ -1830,10 +1830,10 @@ int16 scriptActorAssignTetheredWander(int16 *args) {
if (a->getAssignment() != NULL) delete a->getAssignment();
TileRegion tetherReg;
- int16 &minU = args[ 1 ],
- &minV = args[ 2 ],
- &maxU = args[ 3 ],
- &maxV = args[ 4 ];
+ int16 &minU = args[1],
+ &minV = args[2],
+ &maxU = args[3],
+ &maxV = args[4];
// Normalize the coordinates
if (maxU < minU) {
@@ -1851,7 +1851,7 @@ int16 scriptActorAssignTetheredWander(int16 *args) {
tetherReg.max = TilePoint(maxU, maxV, 0);
if (new (a) TetheredWanderAssignment(
- (uint16)args[ 0 ]
+ (uint16)args[0]
* CalenderTime::framesPerHour,
tetherReg)
!= NULL)
@@ -1875,9 +1875,9 @@ int16 scriptActorAssignAttend(int16 *args) {
if (new (a) AttendAssignment(
(calender.frameInDay()
- + (uint16)args[ 0 ])
+ + (uint16)args[0])
% CalenderTime::framesPerDay,
- GameObject::objectAddress(args[ 1 ]))
+ GameObject::objectAddress(args[1]))
!= NULL)
return TRUE;
}
@@ -1909,9 +1909,9 @@ int16 scriptActorBandWith(int16 *args) {
if (isActor((GameObject *)thisThread->thisObject)) {
Actor *a = (Actor *)thisThread->thisObject;
- assert(isActor(args[ 0 ]));
+ assert(isActor(args[0]));
- a->bandWith((Actor *)GameObject::objectAddress(args[ 0 ]));
+ a->bandWith((Actor *)GameObject::objectAddress(args[0]));
}
return 0;
@@ -1972,9 +1972,9 @@ int16 scriptActorGetFollower(int16 *args) {
Actor *a = (Actor *)thisThread->thisObject;
assert(a->followers != NULL);
- assert(args[ 0 ] < a->followers->size());
+ assert(args[0] < a->followers->size());
- return (*a->followers)[ args[ 0 ] ]->thisID();
+ return (*a->followers)[args[0]]->thisID();
}
return 0;
@@ -2005,7 +2005,7 @@ int16 scriptActorAddKnowledge(int16 *args) {
if (isActor((GameObject *)thisThread->thisObject)) {
Actor *a = (Actor *)thisThread->thisObject;
- a->addKnowledge(args[ 0 ]);
+ a->addKnowledge(args[0]);
}
return 0;
@@ -2020,8 +2020,8 @@ int16 scriptActorDeleteKnowledge(int16 *args) {
if (isActor((GameObject *)thisThread->thisObject)) {
Actor *a = (Actor *)thisThread->thisObject;
- if (args[ 0 ] == 0) a->clearKnowledge();
- else a->removeKnowledge(args[ 0 ]);
+ if (args[0] == 0) a->clearKnowledge();
+ else a->removeKnowledge(args[0]);
}
return 0;
@@ -2034,10 +2034,10 @@ int16 scriptActorDeleteKnowledge(int16 *args) {
int16 scriptActorAddMissionKnowledge(int16 *args) {
OBJLOG(AddMissionKnowledge);
GameObject *obj = (GameObject *)thisThread->thisObject;
- ActiveMission *am = ActiveMission::missionAddress(args[ 0 ]);
+ ActiveMission *am = ActiveMission::missionAddress(args[0]);
if (isActor(obj)) {
- return am->addKnowledgeID(obj->thisID(), args[ 1 ]);
+ return am->addKnowledgeID(obj->thisID(), args[1]);
}
return 0;
}
@@ -2049,10 +2049,10 @@ int16 scriptActorAddMissionKnowledge(int16 *args) {
int16 scriptActorDeleteMissionKnowledge(int16 *args) {
OBJLOG(DeleteMissionKnowledge);
GameObject *obj = (GameObject *)thisThread->thisObject;
- ActiveMission *am = ActiveMission::missionAddress(args[ 0 ]);
+ ActiveMission *am = ActiveMission::missionAddress(args[0]);
if (isActor(obj)) {
- return am->removeKnowledgeID(obj->thisID(), args[ 1 ]);
+ return am->removeKnowledgeID(obj->thisID(), args[1]);
}
return 0;
}
@@ -2066,8 +2066,8 @@ int16 scriptActorDeductPayment(int16 *args) {
Actor *a = (Actor *)thisThread->thisObject;
extern ProtoObj *objectProtos;
- ProtoObj *currencyProto = &objectProtos[ args[ 0 ] ];
- int32 paymentAmount = args[ 1 ];
+ ProtoObj *currencyProto = &objectProtos[args[0]];
+ int32 paymentAmount = args[1];
int32 paymentFound = 0;
GameObject *obj, *delObj = NULL;
ObjectID id;
@@ -2145,7 +2145,7 @@ int16 scriptActorCountPayment(int16 *args) {
Actor *a = (Actor *)thisThread->thisObject;
extern ProtoObj *objectProtos;
- ProtoObj *currencyProto = &objectProtos[ args[ 0 ] ];
+ ProtoObj *currencyProto = &objectProtos[args[0]];
int32 paymentFound = 0;
GameObject *obj;
ObjectID id;
@@ -2172,7 +2172,7 @@ int16 scriptActorAcceptHealing(int16 *args) {
OBJLOG(acceptHealing);
GameObject *obj = (GameObject *)thisThread->thisObject;
- obj->acceptHealing(obj->thisID(), args[ 0 ]);
+ obj->acceptHealing(obj->thisID(), args[0]);
return 0;
}
@@ -2184,7 +2184,7 @@ int16 scriptActorAcceptDamage(int16 *args) {
OBJLOG(acceptHealing);
GameObject *obj = (GameObject *)thisThread->thisObject;
- obj->acceptDamage(args[ 0 ], args[ 1 ], (enum effectDamageTypes)args[ 2 ]);
+ obj->acceptDamage(args[0], args[1], (enum effectDamageTypes)args[2]);
return 0;
}
@@ -2377,7 +2377,7 @@ int16 scriptTagSetState(int16 *args) {
MONOLOG(TAG::SetState);
ActiveItem *ai = (ActiveItem *)thisThread->thisObject;
- ai->setInstanceState(ai->getMapNum(), args[ 0 ]);
+ ai->setInstanceState(ai->getMapNum(), args[0]);
return 0;
}
@@ -2402,8 +2402,8 @@ int16 scriptTagAssoc(int16 *args) {
ActiveItem *ai = (ActiveItem *)thisThread->thisObject;
int mapNum = ai->getMapNum();
- assert(args[ 0 ] >= 0);
- assert(args[ 0 ] < ai->numAssociations);
+ assert(args[0] >= 0);
+ assert(args[0] < ai->numAssociations);
assert(mapNum >= 0);
assert(mapNum < 8);
@@ -2474,7 +2474,7 @@ int16 scriptTagSetLocked(int16 *args) {
MONOLOG(TAG::SetLocked);
ActiveItem *ai = (ActiveItem *)thisThread->thisObject;
- ai->setLocked(args[ 0 ]);
+ ai->setLocked(args[0]);
return 0;
}
@@ -2498,7 +2498,7 @@ int16 scriptTagUse(int16 *args) {
MONOLOG(TAG::Use);
ActiveItem *tai = (ActiveItem *)thisThread->thisObject;
- return tai->use(args[ 0 ]);
+ return tai->use(args[0]);
}
//-----------------------------------------------------------------------
@@ -2515,7 +2515,7 @@ int16 scriptTagSetAnimation(int16 *args) {
ActiveItem *ai = (ActiveItem *)thisThread->thisObject;
Actor *a = getCenterActor();
//TilePoint tagLoc;
- int32 soundID = parse_res_id(STRING(args[ 2 ]));
+ int32 soundID = parse_res_id(STRING(args[2]));
Location ail = ai->getInstanceLocation();
#if 0
tagLoc.u = ai->instance.u - a->getLocation().u;
@@ -2523,22 +2523,22 @@ int16 scriptTagSetAnimation(int16 *args) {
tagLoc.z = ai->instance.h * 8 - a->getLocation().z;
#endif
// Assert that the state is valid
- assert(args[ 1 ] >= 0);
- assert(args[ 1 ] < ai->getGroup()->group.numStates);
+ assert(args[1] >= 0);
+ assert(args[1] < ai->getGroup()->group.numStates);
// If soundID is not NULL, then play the sound
if (soundID) playSoundAt(soundID, ail);
// If we want to wait until finished
- if (args[ 0 ] & tileAnimateWait) {
+ if (args[0] & tileAnimateWait) {
// Wait for the animation
thisThread->waitForEvent(Thread::waitOther, 0);
// And start the tile animation
- TileActivityTask::doScript(*ai, args[ 1 ], getThreadID(thisThread));
+ TileActivityTask::doScript(*ai, args[1], getThreadID(thisThread));
} else {
// Else just start the tile animation
- TileActivityTask::doScript(*ai, args[ 1 ], NoThread);
+ TileActivityTask::doScript(*ai, args[1], NoThread);
}
return ai->lockType();
@@ -2684,7 +2684,7 @@ int16 scriptMissionMakeActor(int16 *args) {
// Call the regular make-actor function. Add in the "permanent"
// flag, since actor will be deleted at mission end.
- args[ 6 ] |= actorPermanent;
+ args[6] |= actorPermanent;
id = scriptMakeActor(args);
// And record it in the mission object
@@ -2711,11 +2711,11 @@ CallTable missionCFuncs = { missionCFuncList, elementsof(missionCFuncList), 0
int16 scriptWriteMessage(int16 *args) {
MONOLOG(WriteMessage);
- char buffer[ 256 ];
+ char buffer[256];
- stringf(buffer, sizeof buffer, args[ 1 ], &args[ 2 ]);
+ stringf(buffer, sizeof buffer, args[1], &args[2]);
- WriteStatusF(args[ 0 ], buffer);
+ WriteStatusF(args[0], buffer);
return 0;
}
@@ -2725,9 +2725,9 @@ int16 scriptWriteMessage(int16 *args) {
int16 scriptStatus(int16 *args) {
MONOLOG(Status);
- char buffer[ 256 ];
+ char buffer[256];
- stringf(buffer, sizeof buffer, args[ 0 ], &args[ 1 ]);
+ stringf(buffer, sizeof buffer, args[0], &args[1]);
StatusMsg(buffer);
return 0;
@@ -2787,9 +2787,9 @@ void writeObject(char *str) {
int16 scriptWriteLog(int16 *args) {
MONOLOG(WriteLog);
- char buffer[ 256 ];
+ char buffer[256];
#if DEBUG
- stringf(buffer, sizeof buffer, args[ 0 ], &args[ 1 ]);
+ stringf(buffer, sizeof buffer, args[0], &args[1]);
writeLog(buffer);
#endif
return 0;
@@ -2797,9 +2797,9 @@ int16 scriptWriteLog(int16 *args) {
int16 scriptWriteObject(int16 *args) {
MONOLOG(WriteObject);
- char buffer[ 256 ];
+ char buffer[256];
- stringf(buffer, sizeof buffer, args[ 0 ], &args[ 1 ]);
+ stringf(buffer, sizeof buffer, args[0], &args[1]);
writeObject(buffer);
return 0;
}
@@ -2809,9 +2809,9 @@ int16 scriptWriteObject(int16 *args) {
int16 scriptErrorDialog(int16 *args) {
MONOLOG(ErrorDialog);
- char buffer[ 512 ];
+ char buffer[512];
- stringf(buffer, sizeof buffer, args[ 1 ], &args[ 2 ]);
+ stringf(buffer, sizeof buffer, args[1], &args[2]);
// WriteStatusF( 1, buffer );
return 0;
@@ -2823,11 +2823,11 @@ int16 scriptErrorDialog(int16 *args) {
int16 scriptMessageDialog(int16 *args) {
MONOLOG(MessageDialog);
- //stringf( buffer, sizeof buffer, args[ 1 ], &args[ 2 ] );
+ //stringf( buffer, sizeof buffer, args[1], &args[2] );
- userDialog(STRING(args[ 0 ]),
- STRING(args[ 1 ]),
- args[ 2 ] ? STRING(args[ 2 ]) : NULL,
+ userDialog(STRING(args[0]),
+ STRING(args[1]),
+ args[2] ? STRING(args[2]) : NULL,
NULL,
NULL);
@@ -2841,13 +2841,13 @@ int16 scriptMessageDialog(int16 *args) {
int16 scriptChoiceDialog(int16 *args) {
MONOLOG(ChoiceDialog);
- //stringf( buffer, sizeof buffer, args[ 1 ], &args[ 2 ] );
+ //stringf( buffer, sizeof buffer, args[1], &args[2] );
- userDialog(STRING(args[ 0 ]),
- STRING(args[ 1 ]),
- args[ 2 ] ? STRING(args[ 2 ]) : NULL,
- args[ 3 ] ? STRING(args[ 3 ]) : NULL,
- args[ 4 ] ? STRING(args[ 4 ]) : NULL);
+ userDialog(STRING(args[0]),
+ STRING(args[1]),
+ args[2] ? STRING(args[2]) : NULL,
+ args[3] ? STRING(args[3]) : NULL,
+ args[4] ? STRING(args[4]) : NULL);
// WriteStatusF( 1, buffer );
return 0;
@@ -2866,11 +2866,11 @@ int16 scriptChoiceDialog(int16 *args) {
int16 scriptPlacard(int16 *args) {
MONOLOG(Placard);
- char buffer[ 256 ];
+ char buffer[256];
- stringf(buffer, sizeof buffer, args[ 1 ], &args[ 2 ]);
+ stringf(buffer, sizeof buffer, args[1], &args[2]);
- placardWindow(args[ 0 ], buffer); // plaq type, text
+ placardWindow(args[0], buffer); // plaq type, text
//GameDisplay( buffer, 0 );
return 0;
@@ -2882,7 +2882,7 @@ int16 scriptPlacard(int16 *args) {
int16 scriptLockDisplay(int16 *args) {
MONOLOG(LockDisplay);
-// WriteStatusF( args[ 0 ], STRING( args[ 1 ] ) );
+// WriteStatusF( args[0], STRING( args[1] ) );
return 0;
}
@@ -2893,7 +2893,7 @@ int16 scriptLockDisplay(int16 *args) {
int16 scriptSetGameMode(int16 *args) {
MONOLOG(SetGameMode);
// Mode zero is "game not running".
- if (args[ 0 ] == 0)
+ if (args[0] == 0)
endGame();
//gameRunning = FALSE;
@@ -2908,7 +2908,7 @@ int16 scriptSetGameMode(int16 *args) {
int16 scriptWait(int16 *args) {
MONOLOG(Wait);
- thisThread->waitAlarm.set(args[ 0 ]);
+ thisThread->waitAlarm.set(args[0]);
thisThread->waitForEvent(Thread::waitDelay, 0);
thisThread->setExtended();
return 0;
@@ -2916,7 +2916,7 @@ int16 scriptWait(int16 *args) {
int16 scriptWaitFrames(int16 *args) {
MONOLOG(WaitFrames);
- thisThread->waitFrameAlarm.set(args[ 0 ]);
+ thisThread->waitFrameAlarm.set(args[0]);
thisThread->waitForEvent(Thread::waitFrameDelay, 0);
thisThread->setExtended();
return 0;
@@ -2928,7 +2928,7 @@ int16 scriptWaitFrames(int16 *args) {
int16 scriptPlaySong(int16 *args) {
MONOLOG(PlaySong);
-// WriteStatusF( args[ 0 ], STRING( args[ 1 ] ) );
+// WriteStatusF( args[0], STRING( args[1] ) );
return 0;
}
@@ -2938,7 +2938,7 @@ int16 scriptPlaySong(int16 *args) {
int16 scriptPlayFX(int16 *args) {
MONOLOG(PlayFX);
-// WriteStatusF( args[ 0 ], STRING( args[ 1 ] ) );
+// WriteStatusF( args[0], STRING( args[1] ) );
return 0;
}
@@ -2948,7 +2948,7 @@ int16 scriptPlayFX(int16 *args) {
int16 scriptObject2Actor(int16 *args) {
MONOLOG(Object2Actor);
- return isActor(args[ 0 ]) ? args[ 0 ] : Nothing;
+ return isActor(args[0]) ? args[0] : Nothing;
}
//-----------------------------------------------------------------------
@@ -2956,7 +2956,7 @@ int16 scriptObject2Actor(int16 *args) {
int16 scriptGenericCast(int16 *args) {
MONOLOG(genericCast);
- return args[ 0 ];
+ return args[0];
}
//-----------------------------------------------------------------------
@@ -2975,9 +2975,9 @@ int16 scriptMakeObject(int16 *args) {
return 0;
}
- obj->setProtoNum(args[ 0 ]);
- obj->setNameIndex(args[ 1 ]);
- obj->setScript(args[ 2 ]);
+ obj->setProtoNum(args[0]);
+ obj->setNameIndex(args[1]);
+ obj->setScript(args[2]);
// If it's a mergeable object, have it's mass count default to 1.
if (obj->proto()->flags & ResourceObjectPrototype::objPropMergeable)
@@ -2992,7 +2992,7 @@ int16 scriptMakeObject(int16 *args) {
int16 scriptDeleteObject(int16 *args) {
MONOLOG(DeleteObject);
- GameObject *obj = GameObject::objectAddress(args[ 0 ]);
+ GameObject *obj = GameObject::objectAddress(args[0]);
ObjectID oldParentID;
assert(obj);
@@ -3012,7 +3012,7 @@ int16 scriptDeleteObject(int16 *args) {
int16 scriptMakeActor(int16 *args) {
MONOLOG(MakeActor);
- char *actorAppearanceName = STRING(args[ 3 ]);
+ char *actorAppearanceName = STRING(args[3]);
int32 actorAppearanceNum;
Actor *a;
@@ -3020,13 +3020,13 @@ int16 scriptMakeActor(int16 *args) {
memcpy(&actorAppearanceNum, actorAppearanceName, 4);
a = Actor::newActor(
- args[ 0 ],
- args[ 1 ],
- args[ 2 ],
+ args[0],
+ args[1],
+ args[2],
actorAppearanceNum,
- args[ 4 ],
- args[ 5 ],
- args[ 6 ]);
+ args[4],
+ args[5],
+ args[6]);
// REM: We need to throw some kind of SAGA exception...?
// (We don't have SAGA exceptions, only the C kind...)
@@ -3194,12 +3194,12 @@ int16 scriptResID(int16 *args) {
int16 scriptWorldNum2Object(int16 *args) {
MONOLOG(WorldNum2Object);
- assert(args[ 0 ] >= 0);
+ assert(args[0] >= 0);
// REM: I can't seem to find a symbolic constant for the
// maximum number of worlds. I know that it's currently 8.
- assert(args[ 0 ] < 8);
+ assert(args[0] < 8);
- return args[ 0 ] + WorldBaseID;
+ return args[0] + WorldBaseID;
}
//-----------------------------------------------------------------------
@@ -3210,7 +3210,7 @@ int16 scriptAppendBookText(int16 *args) {
MONOLOG(AppendBookText);
// If optional 4th parameter is present, then set actor facing
for (int i = 0; i < thisThread->argCount; i++) {
- char *bookText = STRING(args[ i ]);
+ char *bookText = STRING(args[i]);
appendBookText(bookText);
}
@@ -3224,9 +3224,9 @@ int16 scriptAppendBookText(int16 *args) {
int16 scriptAppendScrollTextF(int16 *args) {
MONOLOG(AppendScrollTextF);
- char buffer[ 256 ];
+ char buffer[256];
- stringf(buffer, sizeof buffer, args[ 0 ], &args[ 1 ]);
+ stringf(buffer, sizeof buffer, args[0], &args[1]);
appendBookText(buffer);
@@ -3241,7 +3241,7 @@ int16 scriptAppendScrollText(int16 *args) {
MONOLOG(AppendScrollText);
// If optional 4th parameter is present, then set actor facing
for (int i = 0; i < thisThread->argCount; i++) {
- char *ScrollText = STRING(args[ i ]);
+ char *ScrollText = STRING(args[i]);
appendBookText(ScrollText);
}
@@ -3255,9 +3255,9 @@ int16 scriptAppendScrollText(int16 *args) {
int16 scriptAppendBookTextF(int16 *args) {
MONOLOG(AppendBookTextF);
- char buffer[ 256 ];
+ char buffer[256];
- stringf(buffer, sizeof buffer, args[ 0 ], &args[ 1 ]);
+ stringf(buffer, sizeof buffer, args[0], &args[1]);
appendBookText(buffer);
@@ -3276,15 +3276,15 @@ int16 scriptAssertEvent(int16 *args) {
MONOLOG(AssertEvent);
GameEvent ev;
- assert(isObject(args[ 1 ]) || isActor(args[ 1 ]));
- assert(args[ 2 ] == Nothing
- || isObject(args[ 2 ])
- || isActor(args[ 2 ]));
+ assert(isObject(args[1]) || isActor(args[1]));
+ assert(args[2] == Nothing
+ || isObject(args[2])
+ || isActor(args[2]));
- ev.type = args[ 0 ];
- ev.directObject = GameObject::objectAddress(args[ 1 ]);
- ev.indirectObject = args[ 2 ] != Nothing
- ? GameObject::objectAddress(args[ 2 ])
+ ev.type = args[0];
+ ev.directObject = GameObject::objectAddress(args[1]);
+ ev.indirectObject = args[2] != Nothing
+ ? GameObject::objectAddress(args[2])
: NULL;
assertEvent(ev);
@@ -3410,11 +3410,11 @@ int16 scriptSelectNearbySite(int16 *args) {
TilePoint tp;
Actor *center = getCenterActor();
- tp = selectNearbySite(args[ 3 ],
- TilePoint(args[ 0 ], args[ 1 ], args[ 2 ]),
- args[ 4 ],
- args[ 5 ],
- args[ 6 ]);
+ tp = selectNearbySite(args[3],
+ TilePoint(args[0], args[1], args[2]),
+ args[4],
+ args[5],
+ args[6]);
if (tp == Nowhere) return 0;
scriptCallFrame &scf = thisThread->threadArgs;
@@ -3433,8 +3433,8 @@ int16 scriptPickRandomLivingActor(int16 *args) {
i;
for (i = 0; i < thisThread->argCount; i++) {
- if (isActor(args[ i ])) {
- Actor *a = (Actor *)GameObject::objectAddress(args[ i ]);
+ if (isActor(args[i])) {
+ Actor *a = (Actor *)GameObject::objectAddress(args[i]);
if (!a->isDead()) livingCount++;
}
@@ -3445,11 +3445,11 @@ int16 scriptPickRandomLivingActor(int16 *args) {
livingCount = rand() % livingCount;
for (i = 0; i < thisThread->argCount; i++) {
- if (isActor(args[ i ])) {
- Actor *a = (Actor *)GameObject::objectAddress(args[ i ]);
+ if (isActor(args[i])) {
+ Actor *a = (Actor *)GameObject::objectAddress(args[i]);
if (!a->isDead()) {
- if (livingCount == 0) return args[ i ];
+ if (livingCount == 0) return args[i];
livingCount--;
}
}
@@ -3464,7 +3464,7 @@ int16 scriptPickRandomLivingActor(int16 *args) {
int16 scriptNewMission(int16 *args) {
MONOLOG(NewMission);
- ActiveMission *am = ActiveMission::newMission(args[ 0 ], args[ 1 ]);
+ ActiveMission *am = ActiveMission::newMission(args[0], args[1]);
return am ? am->getMissionID() : -1;
}
@@ -3475,7 +3475,7 @@ int16 scriptNewMission(int16 *args) {
int16 scriptFindMission(int16 *args) {
MONOLOG(FindMission);
- return ActiveMission::findMission(args[ 0 ]);
+ return ActiveMission::findMission(args[0]);
}
//-----------------------------------------------------------------------
@@ -3486,9 +3486,9 @@ int16 scriptSetTileCycleSpeed(int16 *args) {
MONOLOG(SetTileCycleSpeed);
extern CycleHandle cycleList; // list of tile cycling info
- TileCycleData &tcd = (*cycleList)[ args[ 0 ] ];
+ TileCycleData &tcd = (*cycleList)[args[0]];
- tcd.cycleSpeed = args[ 1 ];
+ tcd.cycleSpeed = args[1];
return 0;
}
@@ -3501,9 +3501,9 @@ int16 scriptSetTileCycleState(int16 *args) {
MONOLOG(SetTileCycleState);
extern CycleHandle cycleList; // list of tile cycling info
- TileCycleData &tcd = (*cycleList)[ args[ 0 ] ];
+ TileCycleData &tcd = (*cycleList)[args[0]];
- tcd.currentState = args[ 1 ];
+ tcd.currentState = args[1];
tcd.counter = 0;
return 0;
@@ -3525,15 +3525,15 @@ int16 scriptSearchRegion(int16 *args) {
maxP;
// Get a pointer to the world
- assert(isWorld(args[ 0 ]));
- worldPtr = (GameWorld *)GameObject::objectAddress(args[ 0 ]);
+ assert(isWorld(args[0]));
+ worldPtr = (GameWorld *)GameObject::objectAddress(args[0]);
assert(worldPtr != NULL);
- minP.u = MIN(args[ 1 ], args[ 3 ]);
- minP.v = MIN(args[ 2 ], args[ 4 ]);
+ minP.u = MIN(args[1], args[3]);
+ minP.v = MIN(args[2], args[4]);
minP.z = -128;
- maxP.u = MAX(args[ 1 ], args[ 3 ]);
- maxP.v = MAX(args[ 2 ], args[ 4 ]);
+ maxP.u = MAX(args[1], args[3]);
+ maxP.v = MAX(args[2], args[4]);
maxP.z = 127;
// Set up an iterator
@@ -3546,7 +3546,7 @@ int16 scriptSearchRegion(int16 *args) {
// Starting from the 5th argument, until we reach argCount,
// see if the iterated object matches one in the arg list
for (int i = 5; i < thisThread->argCount; i++) {
- if (args[ i ] == searchObj) {
+ if (args[i] == searchObj) {
count++;
break;
}
@@ -3608,8 +3608,8 @@ void listObjectsInRegion(
int16 scriptSwapRegions(int16 *args) {
MONOLOG(SwapRegions);
- ObjectID worldID1 = args[ 0 ],
- worldID2 = args[ 3 ];
+ ObjectID worldID1 = args[0],
+ worldID2 = args[3];
GameWorld *worldPtr1,
*worldPtr2;
ObjectID searchObj;
@@ -3630,18 +3630,18 @@ int16 scriptSwapRegions(int16 *args) {
assert(worldPtr1 != NULL);
assert(worldPtr2 != NULL);
- region1.min.u = args[ 1 ];
- region1.min.v = args[ 2 ];
+ region1.min.u = args[1];
+ region1.min.v = args[2];
region1.min.z = -128;
- region1.max.u = args[ 1 ] + abs(args[ 6 ]);
- region1.max.v = args[ 2 ] + abs(args[ 7 ]);
+ region1.max.u = args[1] + abs(args[6]);
+ region1.max.v = args[2] + abs(args[7]);
region1.max.z = 127;
- region2.min.u = args[ 4 ];
- region2.min.v = args[ 5 ];
+ region2.min.u = args[4];
+ region2.min.v = args[5];
region2.min.z = -128;
- region2.max.u = args[ 4 ] + abs(args[ 6 ]);
- region2.max.v = args[ 5 ] + abs(args[ 7 ]);
+ region2.max.u = args[4] + abs(args[6]);
+ region2.max.v = args[5] + abs(args[7]);
region2.max.z = 127;
// Count how many objects are in each region
@@ -3649,9 +3649,9 @@ int16 scriptSwapRegions(int16 *args) {
objCount2 = countObjectsInRegion(worldPtr2, region2);
// Allocate an array to hold object ID's for each region
- objArray1 = new ObjectID[ objCount1 ];
+ objArray1 = new ObjectID[objCount1];
assert(objArray1);
- objArray2 = new ObjectID[ objCount2 ];
+ objArray2 = new ObjectID[objCount2];
assert(objArray2);
// Get a list of the objects in each region
@@ -3662,7 +3662,7 @@ int16 scriptSwapRegions(int16 *args) {
// Move all the objects in the first list to region 2
for (i = 0; i < objCount1; i++) {
- GameObject *obj = GameObject::objectAddress(objArray1[ i ]);
+ GameObject *obj = GameObject::objectAddress(objArray1[i]);
Location loc;
TilePoint tp;
@@ -3678,7 +3678,7 @@ int16 scriptSwapRegions(int16 *args) {
// Move all the objects in the second list to region 1
for (i = 0; i < objCount2; i++) {
- GameObject *obj = GameObject::objectAddress(objArray2[ i ]);
+ GameObject *obj = GameObject::objectAddress(objArray2[i]);
Location loc;
TilePoint tp;
@@ -3706,7 +3706,7 @@ extern bool tileLockFlag;
int16 scriptLockTiles(int16 *args) {
MONOLOG(LockTiles);
- if (args[ 0 ] == FALSE) tileLockFlag = FALSE;
+ if (args[0] == FALSE) tileLockFlag = FALSE;
else tileLockFlag = TRUE;
return 0;
@@ -3718,7 +3718,7 @@ int16 scriptLockTiles(int16 *args) {
int16 scriptGetFactionTally(int16 *args) {
MONOLOG(GetFactionTally);
- return GetFactionTally(args[ 0 ], (enum factionTallyTypes)args[ 1 ]);
+ return GetFactionTally(args[0], (enum factionTallyTypes)args[1]);
}
//-----------------------------------------------------------------------
@@ -3727,7 +3727,7 @@ int16 scriptGetFactionTally(int16 *args) {
int16 scriptAddFactionTally(int16 *args) {
MONOLOG(AddFactionTally);
- return AddFactionTally(args[ 0 ], (enum factionTallyTypes)args[ 1 ], args[ 2 ]);
+ return AddFactionTally(args[0], (enum factionTallyTypes)args[1], args[2]);
}
//-----------------------------------------------------------------------
@@ -3740,10 +3740,10 @@ extern int16 objectProtoCount;
int16 scriptNumTempActors(int16 *args) {
MONOLOG(NumTempActors);
- assert(args[ 0 ] >= 0);
- assert(args[ 0 ] < actorProtoCount);
+ assert(args[0] >= 0);
+ assert(args[0] < actorProtoCount);
- return getTempActorCount(args[ 0 ]);
+ return getTempActorCount(args[0]);
}
//-----------------------------------------------------------------------
@@ -3754,10 +3754,10 @@ int16 scriptGetObjectBasePrice(int16 *args) {
MONOLOG(GetBaseObjectPrice);
extern ProtoObj *objectProtos;
- assert(args[ 0 ] >= 0);
- assert(args[ 0 ] < objectProtoCount);
+ assert(args[0] >= 0);
+ assert(args[0] < objectProtoCount);
- return objectProtos[ args[ 0 ] ].price;
+ return objectProtos[args[0]].price;
}
//-----------------------------------------------------------------------
@@ -3766,7 +3766,7 @@ int16 scriptGetObjectBasePrice(int16 *args) {
int16 scriptGotoWinMode(int16 *args) {
MONOLOG(gotoWinMode);
- int16 winType = args[ 0 ];
+ int16 winType = args[0];
setWintroMode(winType);
return 0;
}
@@ -3803,11 +3803,11 @@ int16 scriptPlayVideo(int16 *args) {
int16 scriptDistanceBetween(int16 *args) {
MONOLOG(distanceBetween);
- assert((isObject(args[ 0 ]) || isActor(args[ 0 ]))
- && (isObject(args[ 1 ]) || isActor(args[ 1 ])));
+ assert((isObject(args[0]) || isActor(args[0]))
+ && (isObject(args[1]) || isActor(args[1])));
- GameObject *obj1 = GameObject::objectAddress(args[ 0 ]),
- *obj2 = GameObject::objectAddress(args[ 1 ]);
+ GameObject *obj1 = GameObject::objectAddress(args[0]),
+ *obj2 = GameObject::objectAddress(args[1]);
return (obj1->getLocation() - obj2->getLocation()).quickHDistance();
}
@@ -3820,9 +3820,9 @@ int16 scriptDistanceBetween(int16 *args) {
int16 scriptTransportCenterBand(int16 *args) {
MONOLOG(transportCenterBand);
- assert(isWorld(args[ 0 ]));
+ assert(isWorld(args[0]));
- transportCenterBand(Location(args[ 1 ], args[ 2 ], args[ 3 ], args[ 0 ]));
+ transportCenterBand(Location(args[1], args[2], args[3], args[0 ]));
return 0;
}
@@ -3838,7 +3838,7 @@ int16 scriptLockUI(int16 *args) {
MONOLOG(lockUI);
noStickyMap();
- LockUI(args[ 0 ]);
+ LockUI(args[0]);
return 0;
}
@@ -3895,7 +3895,7 @@ int16 scriptSetSynchronous(int16 *args) {
int16 oldVal = (thisThread->flags & Thread::synchronous) != 0;
- if (args[ 0 ])
+ if (args[0])
thisThread->flags |= Thread::synchronous;
else
thisThread->flags &= ~Thread::synchronous;
@@ -3910,10 +3910,10 @@ int16 scriptSetSynchronous(int16 *args) {
int16 scriptBigMul(int16 *args) {
MONOLOG(BigMul);
- long result = (long)args[ 0 ] * (long)args[ 1 ];
+ long result = (long)args[0] * (long)args[1];
- if (args[ 2 ] == 0) result = 0;
- else result /= args[ 2 ];
+ if (args[2] == 0) result = 0;
+ else result /= args[2];
result = clamp((short)minint16, (long)result, (short)maxint16);
diff --git a/engines/saga2/savefile.cpp b/engines/saga2/savefile.cpp
index 5b0066a6d0..01731835b2 100644
--- a/engines/saga2/savefile.cpp
+++ b/engines/saga2/savefile.cpp
@@ -52,7 +52,7 @@ void getSaveFileName(int16 saveNo, char *fileName) {
// Constructor
SaveFileConstructor::SaveFileConstructor(int16 saveNo, char *saveName) {
- char fileName[ fileNameSize ];
+ char fileName[fileNameSize];
// Construct the file name string
getSaveFileName(saveNo, fileName);
@@ -169,7 +169,7 @@ bool SaveFileConstructor::writeChunk(ChunkID id, void *buf, int32 size) {
// Constructor
SaveFileReader::SaveFileReader(int16 saveNo) {
- char fileName[ fileNameSize ];
+ char fileName[fileNameSize];
// Construct the file name based on the save number
getSaveFileName(saveNo, fileName);
diff --git a/engines/saga2/savefile.h b/engines/saga2/savefile.h
index 970192c651..1b0db2d157 100644
--- a/engines/saga2/savefile.h
+++ b/engines/saga2/savefile.h
@@ -51,9 +51,9 @@ const ChunkID gameID = MKTAG('D', 'I', 'N', 'O');
struct SaveFileHeader {
ChunkID gameID; // ID of game (FTA2 of DINO).
- char saveName[ saveNameSize ]; // The long name of the saved
+ char saveName[saveNameSize]; // The long name of the saved
// game state.
- int8 reserved[ 84 ]; // Room for expansion.
+ int8 reserved[84]; // Room for expansion.
}; // 128 bytes
/* ===================================================================== *
diff --git a/engines/saga2/script.h b/engines/saga2/script.h
index 2de231c633..89fc4bffc9 100644
--- a/engines/saga2/script.h
+++ b/engines/saga2/script.h
@@ -344,7 +344,7 @@ scriptResult runTagMethod(
struct ResImportTable {
int16 deadActorProto,
- reserved[ 2 ];
+ reserved[2];
int16 EXP_spellEffect_CreateFireWisp,
EXP_spellEffect_CreateWindWisp,
EXP_spellEffect_CreateWraith,
diff --git a/engines/saga2/sensor.cpp b/engines/saga2/sensor.cpp
index d418fa5b1a..68eaf9b3eb 100644
--- a/engines/saga2/sensor.cpp
+++ b/engines/saga2/sensor.cpp
@@ -37,7 +37,7 @@
namespace Saga2 {
struct SensorListHolder : public DNode {
- uint8 sensorListBuffer[ sizeof(SensorList) ];
+ uint8 sensorListBuffer[sizeof(SensorList)];
SensorList *getSensorList(void) {
return (SensorList *)&sensorListBuffer;
@@ -50,7 +50,7 @@ struct SensorListHolder : public DNode {
struct SensorHolder : public DNode {
int16 checkCtr;
- uint8 sensorBuffer[ maxSensorSize ];
+ uint8 sensorBuffer[maxSensorSize];
Sensor *getSensor(void) {
return (Sensor *)&sensorBuffer;
@@ -377,7 +377,7 @@ void saveSensors(SaveFileConstructor &saveGame) {
bufferPtr = archiveSensor(sensorHolder->getSensor(), bufferPtr);
}
- assert(bufferPtr == &((uint8 *)archiveBuffer)[ archiveBufSize ]);
+ assert(bufferPtr == &((uint8 *)archiveBuffer)[archiveBufSize]);
// Write the data to the save file
saveGame.writeChunk(
@@ -428,7 +428,7 @@ void loadSensors(SaveFileReader &saveGame) {
bufferPtr = constructSensor(ctr, bufferPtr);
}
- assert(bufferPtr == &((uint8 *)archiveBuffer)[ saveGame.getChunkSize() ]);
+ assert(bufferPtr == &((uint8 *)archiveBuffer)[saveGame.getChunkSize()]);
RDisposePtr(archiveBuffer);
}
@@ -600,7 +600,7 @@ bool ProtaganistSensor::check(SenseInfo &info, uint32 senseFlags) {
for (i = 0; i < elementsof(playerActorIDs); i++) {
Actor *protag =
- getPlayerActorAddress(playerActorIDs[ i ])->getActor();
+ getPlayerActorAddress(playerActorIDs[i])->getActor();
assert(isActor(protag));
diff --git a/engines/saga2/speech.cpp b/engines/saga2/speech.cpp
index d5bf8dddb2..9d5615e3be 100644
--- a/engines/saga2/speech.cpp
+++ b/engines/saga2/speech.cpp
@@ -93,11 +93,11 @@ Alarm speechFinished;
// The list of active and non-active speech tasks for all actors
-uint8 speechListBuffer[ sizeof(SpeechTaskList) ];
+uint8 speechListBuffer[sizeof(SpeechTaskList)];
SpeechTaskList &speechList = *((SpeechTaskList *)speechListBuffer);
-static TextSpan speechLineList[ 64 ], // list of speech lines
- speechButtonList[ 64 ]; // list of speech buttons
+static TextSpan speechLineList[64], // list of speech lines
+ speechButtonList[64]; // list of speech buttons
int16 speechLineCount, // count of speech lines
speechButtonCount; // count of speech buttons
@@ -187,14 +187,14 @@ void *Speech::restore(void *buf) {
// Restore the sample ID's
for (i = 0; i < sampleCount; i++) {
- sampleID[ i ] = *((uint32 *)buf);
+ sampleID[i] = *((uint32 *)buf);
buf = (uint32 *)buf + 1;
}
// Restore the text
memcpy(speechBuffer, buf, charCount);
buf = (char *)buf + charCount;
- speechBuffer[ charCount ] = '\0';
+ speechBuffer[charCount] = '\0';
// Requeue the speech if needed
if (speechFlags & spQueued) {
@@ -256,7 +256,7 @@ void *Speech::archive(void *buf) {
buf = (int16 *)buf + 1;
for (i = 0; i < sampleCount; i++) {
- *((uint32 *)buf) = sampleID[ i ];
+ *((uint32 *)buf) = sampleID[i];
buf = (uint32 *)buf + 1;
}
@@ -278,14 +278,14 @@ bool Speech::append(char *text, int32 sampID) {
|| sampleCount >= MAX_SAMPLES) return FALSE;
// Copy text to end of text in buffer, including '\0'
- memcpy(&speechBuffer[ charCount ], text, len + 1);
+ memcpy(&speechBuffer[charCount], text, len + 1);
charCount += len;
// Append sample ID to list of samples.
// REM: We should translate sample ID's from index to resource
// number here.
if (sampID)
- sampleID[ sampleCount++ ] = extendID(sampID);
+ sampleID[sampleCount++] = extendID(sampID);
return TRUE;
}
@@ -372,13 +372,13 @@ bool Speech::setupActive(void) {
tempTextPort.setMap(&speechImage);
y = outlineWidth; // Plus 2 for Outlines
- buttonChars = speechButtonList[ buttonNum ].charWidth;
+ buttonChars = speechButtonList[buttonNum].charWidth;
for (int i = 0; i < speechLineCount; i++) {
- int16 lineChars = speechLineList[ i ].charWidth;
- char *lineText = speechLineList[ i ].text;
+ int16 lineChars = speechLineList[i].charWidth;
+ char *lineText = speechLineList[i].text;
- x = (bounds.width - speechLineList[ i ].pixelWidth) / 2
+ x = (bounds.width - speechLineList[i].pixelWidth) / 2
+ outlineWidth;
tempTextPort.moveTo(x, y);
@@ -396,7 +396,7 @@ bool Speech::setupActive(void) {
// Fer death awaits with nasty, pointy teeth...!
if (buttonNum > speechButtonCount) break;
- buttonChars = speechButtonList[ buttonNum ].charWidth;
+ buttonChars = speechButtonList[buttonNum].charWidth;
tempTextPort.setColor(1 + 9);
// Blit the little bullet symbol
@@ -452,8 +452,8 @@ bool Speech::setupActive(void) {
//This Function Sets Up Width And Height For A Speech
void Speech::setWidth() {
- TextSpan speechLineList[ 32 ], // list of speech lines
- speechButtonList[ 32 ]; // list of speech buttons
+ TextSpan speechLineList[32], // list of speech lines
+ speechButtonList[32]; // list of speech buttons
int16 speechLineCount, // count of speech lines
speechButtonCount; // count of speech buttons
@@ -483,7 +483,7 @@ void Speech::setWidth() {
bounds.width = 0;
for (int i = 0; i < speechLineCount; i++) {
- bounds.width = MAX(bounds.width, speechLineList[ i ].pixelWidth);
+ bounds.width = MAX(bounds.width, speechLineList[i].pixelWidth);
}
bounds.width += outlineWidth * 2 + 4; // Some padding just in case.
}
@@ -727,7 +727,7 @@ int16 TextWrap(
pixel_len, // pixel length of line
line_count = 0; // number of lines
- lines[ line_count ] = text;
+ lines[line_count] = text;
last_space = -1;
line_start = 0;
pixel_len = 0;
@@ -735,20 +735,20 @@ int16 TextWrap(
// For each character in the string, check for word wrap
for (i = 0; ; i++) {
- uint8 c = text[ i ];
+ uint8 c = text[i];
// REM: Translate from foreign character set if needed...
// c = TranslationTable[c];
if (c == '\n' || c == '\r' || c == '\0') { // if deliberate end of line
- line_chars[ line_count ] = i - line_start; //
- line_pixels[ line_count ] = pixel_len;
+ line_chars[line_count] = i - line_start; //
+ line_pixels[line_count] = pixel_len;
line_start = i + 1;
if (c == '\0') {
line_count++;
break;
}
- lines[ ++line_count ] = &text[ line_start ];
+ lines[++line_count] = &text[line_start];
last_space = -1;
pixel_len = 0;
continue;
@@ -758,13 +758,13 @@ int16 TextWrap(
}
pixel_len +=
- tempTextPort.font->charKern[ c ] + tempTextPort.font->charSpace[ c ];
+ tempTextPort.font->charKern[c] + tempTextPort.font->charSpace[c];
if (pixel_len > width - 2 && last_space > 0) {
- line_chars[ line_count ] = last_space - line_start;
- line_pixels[ line_count ] = last_space_pixels;
+ line_chars[line_count] = last_space - line_start;
+ line_pixels[line_count] = last_space_pixels;
line_start = last_space + 1;
- lines[ ++line_count ] = &text[ line_start ];
+ lines[++line_count] = &text[line_start];
last_space = -1;
pixel_len = 0;
@@ -813,7 +813,7 @@ int16 buttonWrap(
// For each character in the string, check for word wrap
for (i = 0; ; i++) {
- uint8 c = text[ i ];
+ uint8 c = text[i];
// REM: Translate from foreign character set if needed...
// c = TranslationTable[c];
@@ -829,7 +829,7 @@ int16 buttonWrap(
if (c == '\0') break;
- lineList->text = &text[ line_start ];
+ lineList->text = &text[line_start];
last_space = -1;
linePixels = 0;
@@ -847,8 +847,8 @@ int16 buttonWrap(
// Add to pixel length
charPixels
- = tempTextPort.font->charKern[ c ]
- + tempTextPort.font->charSpace[ c ];
+ = tempTextPort.font->charKern[c]
+ + tempTextPort.font->charSpace[c];
}
linePixels += charPixels;
@@ -862,7 +862,7 @@ int16 buttonWrap(
line_start = last_space + 1;
- lineList->text = &text[ line_start ];
+ lineList->text = &text[line_start];
last_space = -1;
linePixels = 0;
@@ -881,7 +881,7 @@ int16 buttonWrap(
for (int l = 0; l < lineCount; l++, lineList++) {
for (i = 0; i < lineList->charWidth; i++) {
- uint8 c = lineList->text[ i ];
+ uint8 c = lineList->text[i];
// REM: Translate from foreign character set if needed...
// c = TranslationTable[c];
@@ -903,8 +903,8 @@ int16 buttonWrap(
} else { // Any other character
// Add to pixel length
charPixels
- = tempTextPort.font->charKern[ c ]
- + tempTextPort.font->charSpace[ c ];
+ = tempTextPort.font->charKern[c]
+ + tempTextPort.font->charSpace[c];
}
buttonPixels += charPixels;
@@ -960,22 +960,22 @@ int16 pickButton(
// for centering.
for (int i = 0; i < pickLine; i++) {
- pickPixels += lineList[ i ].pixelWidth;
+ pickPixels += lineList[i].pixelWidth;
}
- centerWidth = (width - lineList[ pickLine ].pixelWidth) / 2;
+ centerWidth = (width - lineList[pickLine].pixelWidth) / 2;
// Return 0 if mouse off left or right edge of text.
if (pt.x < centerWidth || pt.x > width - centerWidth) return 0;
- pickPixels += pt.x - (width - lineList[ pickLine ].pixelWidth) / 2;
+ pickPixels += pt.x - (width - lineList[pickLine].pixelWidth) / 2;
// Now, we lay all the buttons end to end in a similar fashion,
// and determine which button the pick point fell into, in a
// simple 1-d comparison.
for (int j = 0; j <= buttonCount; j++) {
- pickPixels -= buttonList[ j ].pixelWidth;
+ pickPixels -= buttonList[j].pixelWidth;
if (pickPixels < 0) return j;
}
@@ -1021,7 +1021,7 @@ SpeechTaskList::SpeechTaskList(void) {
lockFlag = FALSE;
for (int i = 0; i < elementsof(array); i++) {
- free.addTail(array[ i ]);
+ free.addTail(array[i]);
}
}
@@ -1038,7 +1038,7 @@ SpeechTaskList::SpeechTaskList(void **buf) {
// Initialize the free list
for (i = 0; i < elementsof(array); i++) {
- free.addTail(array[ i ]);
+ free.addTail(array[i]);
}
// Get the speech count
diff --git a/engines/saga2/speech.h b/engines/saga2/speech.h
index 4fd4a30f44..ac7dd43eaa 100644
--- a/engines/saga2/speech.h
+++ b/engines/saga2/speech.h
@@ -103,8 +103,8 @@ private:
ThreadID thread; // SAGA thread to wake up when done
int16 speechFlags; // flags from speaking
- uint32 sampleID[ MAX_SAMPLES ];// voice sound sample ID
- char speechBuffer[ 512 ];// longest possible speech
+ uint32 sampleID[MAX_SAMPLES];// voice sound sample ID
+ char speechBuffer[512];// longest possible speech
public:
int16 selectedButton; // which button was hit
@@ -173,7 +173,7 @@ class SpeechTaskList {
DList activeList,
nonActiveList,
free;
- Speech array[ MAX_SPEECH_PTRS ];
+ Speech array[MAX_SPEECH_PTRS];
int8 lockFlag;
diff --git a/engines/saga2/spelcast.cpp b/engines/saga2/spelcast.cpp
index 1db14b14b4..5a918bc814 100644
--- a/engines/saga2/spelcast.cpp
+++ b/engines/saga2/spelcast.cpp
@@ -918,7 +918,7 @@ int16 tileNopeHeight(
{
// Look up the metatile on the map.
- metaPtr = prevMeta = mapList[ mapNum ].lookupMeta(metaCoords);
+ metaPtr = prevMeta = mapList[mapNum].lookupMeta(metaCoords);
prevMapNum = mapNum;
prevCoords = metaCoords;
}
diff --git a/engines/saga2/spelshow.h b/engines/saga2/spelshow.h
index 4753471135..ddbd7a8b91 100644
--- a/engines/saga2/spelshow.h
+++ b/engines/saga2/spelshow.h
@@ -256,7 +256,7 @@ public:
uint8 secondarySpriteNo; // sprites available
//uint8 effCount; // effectrons to allocate
- uint8 colorMap[ 4 ]; // indirect color map
+ uint8 colorMap[4]; // indirect color map
// full init
SpellDisplayPrototype(
EffectID, int32, int32, int32, int32, effectDirectionInit,
diff --git a/engines/saga2/sprite.h b/engines/saga2/sprite.h
index 478133614b..7c2e1097bb 100644
--- a/engines/saga2/sprite.h
+++ b/engines/saga2/sprite.h
@@ -57,18 +57,18 @@ struct Sprite {
struct SpriteSet {
uint32 count; // number of images in the range
- uint32 offsets[ 1 ]; // offsets into sprite list
+ uint32 offsets[1]; // offsets into sprite list
// (variable-length array)
// sprite structures follow table
// Member function to return a sprite from the set
Sprite *sprite(int16 index) {
- return (Sprite *)((uint8 *)this + offsets[ index ]);
+ return (Sprite *)((uint8 *)this + offsets[index]);
}
// Sprite &operator[]( int32 index )
// {
-// return (Sprite *)( (uint8 *)this + offsets[ index ] );
+// return (Sprite *)( (uint8 *)this + offsets[index] );
// }
};
@@ -138,8 +138,8 @@ struct ActorAnimation {
// table of poses for that sequence, and the number of poses
// in the sequence.
- uint16 start[ numPoseFacings ],
- count[ numPoseFacings ];
+ uint16 start[numPoseFacings],
+ count[numPoseFacings];
};
struct ActorAnimSet {
@@ -152,8 +152,8 @@ struct ActorAnimSet {
}
ActorPose *pose(ActorAnimation *anim, int dir, int num) {
- if (num < 0 || num >= anim->count[ dir ]) num = 0;
- num += anim->start[ dir ];
+ if (num < 0 || num >= anim->count[dir]) num = 0;
+ num += anim->start[dir];
return (ActorPose *)((uint8 *)this + poseOffset) + num;
}
};
@@ -162,13 +162,13 @@ struct ActorAnimSet {
Sprite color lookup tables
* ===================================================================== */
-typedef uint8 ColorTable[ 256 ];
+typedef uint8 ColorTable[256];
// List of color schemes for sprites
struct ColorScheme {
- uint8 bank[ 11 ];
+ uint8 bank[11];
uint8 speechColor;
- char name[ 32 ];
+ char name[32];
};
/* ===================================================================== *
@@ -264,7 +264,7 @@ public:
// REM: How do we determine what frames are NEEDED in the
// near future?
- SpriteSet *spriteBanks[ sprBankCount ];
+ SpriteSet *spriteBanks[sprBankCount];
// Member functions:
void loadSpriteBanks(int16 banksNeeded);
diff --git a/engines/saga2/target.cpp b/engines/saga2/target.cpp
index 4cd4c9b628..d24247dd0b 100644
--- a/engines/saga2/target.cpp
+++ b/engines/saga2/target.cpp
@@ -115,29 +115,29 @@ void insertLocation(
// the first element
if (i == 0) {
tla.locs = 1;
- tla.locArray[ 0 ] = tp;
- tla.distArray[ 0 ] = dist;
+ tla.locArray[0] = tp;
+ tla.distArray[0] = dist;
} else {
// Search for a position to place the location
- if (dist < tla.distArray[ i - 1 ]) {
+ if (dist < tla.distArray[i - 1]) {
if (i < tla.size) {
- tla.locArray[ i ] = tla.locArray[ i - 1 ];
- tla.distArray[ i ] = tla.distArray[ i - 1 ];
+ tla.locArray[i] = tla.locArray[i - 1];
+ tla.distArray[i] = tla.distArray[i - 1];
}
i--;
}
- while (i > 0 && dist < tla.distArray[ i - 1 ]) {
- tla.locArray[ i ] = tla.locArray[ i - 1 ];
- tla.distArray[ i ] = tla.distArray[ i - 1 ];
+ while (i > 0 && dist < tla.distArray[i - 1]) {
+ tla.locArray[i] = tla.locArray[i - 1];
+ tla.distArray[i] = tla.distArray[i - 1];
i--;
}
if (i < tla.size) {
// Place the location in the array
if (tla.locs < tla.size) tla.locs++;
- tla.locArray[ i ] = tp;
- tla.distArray[ i ] = dist;
+ tla.locArray[i] = tp;
+ tla.distArray[i] = dist;
}
}
}
@@ -166,7 +166,7 @@ LocationTarget::LocationTarget(void **buf) {
// Restore the targe location
loc = *bufferPtr;
- *buf = &bufferPtr[ 1 ];
+ *buf = &bufferPtr[1];
}
//----------------------------------------------------------------------
@@ -229,8 +229,8 @@ int16 LocationTarget::where(
TargetLocationArray &tla) const {
// Place the target location in the first element of the
// array
- tla.locArray[ 0 ] = loc;
- tla.distArray[ 0 ] = (tp - loc).quickHDistance();
+ tla.locArray[0] = loc;
+ tla.distArray[0] = (tp - loc).quickHDistance();
tla.locs = 1;
return 1;
}
@@ -430,7 +430,7 @@ TilePropertyTarget::TilePropertyTarget(void **buf) {
// Restore the TilePropertyID
tileProp = *bufferPtr;
- *buf = &bufferPtr[ 1 ];
+ *buf = &bufferPtr[1];
}
//----------------------------------------------------------------------
@@ -609,7 +609,7 @@ SpecificMetaTileTarget::SpecificMetaTileTarget(void **buf) {
meta.map = bufferPtr->map;
meta.index = bufferPtr->index;
- *buf = &bufferPtr[ 1 ];
+ *buf = &bufferPtr[1];
}
//----------------------------------------------------------------------
@@ -630,7 +630,7 @@ void *SpecificMetaTileTarget::archive(void *buf) const {
bufferPtr->map = meta.map;
bufferPtr->index = meta.index;
- return &bufferPtr[ 1 ];
+ return &bufferPtr[1];
}
//----------------------------------------------------------------------
@@ -685,7 +685,7 @@ MetaTilePropertyTarget::MetaTilePropertyTarget(void **buf) {
// Restore the MetaTilePropertyID
metaProp = *bufferPtr;
- *buf = &bufferPtr[ 1 ];
+ *buf = &bufferPtr[1];
}
//----------------------------------------------------------------------
@@ -764,29 +764,29 @@ void ObjectTarget::searchObject(
// the first element
if (i == 0) {
toa.objs = 1;
- toa.objArray[ 0 ] = objPtr;
- toa.distArray[ 0 ] = dist;
+ toa.objArray[0] = objPtr;
+ toa.distArray[0] = dist;
} else {
// Search for a position to place the object
- if (dist < toa.distArray[ i - 1 ]) {
+ if (dist < toa.distArray[i - 1]) {
if (i < toa.size) {
- toa.objArray[ i ] = toa.objArray[ i - 1 ];
- toa.distArray[ i ] = toa.distArray[ i - 1 ];
+ toa.objArray[i] = toa.objArray[i - 1];
+ toa.distArray[i] = toa.distArray[i - 1];
}
i--;
}
- while (i > 0 && dist < toa.distArray[ i - 1 ]) {
- toa.objArray[ i ] = toa.objArray[ i - 1 ];
- toa.distArray[ i ] = toa.distArray[ i - 1 ];
+ while (i > 0 && dist < toa.distArray[i - 1]) {
+ toa.objArray[i] = toa.objArray[i - 1];
+ toa.distArray[i] = toa.distArray[i - 1];
i--;
}
if (i < toa.size) {
// Place the object in the array
if (toa.objs < toa.size) toa.objs++;
- toa.objArray[ i ] = objPtr;
- toa.distArray[ i ] = dist;
+ toa.objArray[i] = objPtr;
+ toa.distArray[i] = dist;
}
}
}
@@ -970,7 +970,7 @@ SpecificObjectTarget::SpecificObjectTarget(void **buf) {
// Restore the ObjectID
obj = *bufferPtr;
- *buf = &bufferPtr[ 1 ];
+ *buf = &bufferPtr[1];
}
//----------------------------------------------------------------------
@@ -1066,8 +1066,8 @@ int16 SpecificObjectTarget::where(
if (dist < maxObjDist) {
tla.locs = 1;
- tla.locArray[ 0 ] = objLoc;
- tla.distArray[ 0 ] = dist;
+ tla.locArray[0] = objLoc;
+ tla.distArray[0] = dist;
return 1;
}
@@ -1108,8 +1108,8 @@ int16 SpecificObjectTarget::object(
if (dist < maxObjDist) {
toa.objs = 1;
- toa.objArray[ 0 ] = o;
- toa.distArray[ 0 ] = dist;
+ toa.objArray[0] = o;
+ toa.distArray[0] = dist;
return 1;
}
@@ -1131,7 +1131,7 @@ ObjectPropertyTarget::ObjectPropertyTarget(void **buf) {
// Restore the ObjectPropertyID
objProp = *bufferPtr;
- *buf = &bufferPtr[ 1 ];
+ *buf = &bufferPtr[1];
}
//----------------------------------------------------------------------
@@ -1334,8 +1334,8 @@ int16 SpecificActorTarget::where(
if (dist < maxObjDist) {
tla.locs = 1;
- tla.locArray[ 0 ] = actorLoc;
- tla.distArray[ 0 ] = dist;
+ tla.locArray[0] = actorLoc;
+ tla.distArray[0] = dist;
return 1;
}
@@ -1372,8 +1372,8 @@ int16 SpecificActorTarget::object(
if (dist < maxObjDist) {
toa.objs = 1;
- toa.objArray[ 0 ] = a;
- toa.distArray[ 0 ] = dist;
+ toa.objArray[0] = a;
+ toa.distArray[0] = dist;
return 1;
}
@@ -1410,8 +1410,8 @@ int16 SpecificActorTarget::actor(
if (dist < maxObjDist) {
taa.actors = 1;
- taa.actorArray[ 0 ] = a;
- taa.distArray[ 0 ] = dist;
+ taa.actorArray[0] = a;
+ taa.distArray[0] = dist;
return 1;
}
@@ -1433,7 +1433,7 @@ ActorPropertyTarget::ActorPropertyTarget(void **buf) {
// Restore the ActorPropertyID
actorProp = *bufferPtr;
- *buf = &bufferPtr[ 1 ];
+ *buf = &bufferPtr[1];
}
//----------------------------------------------------------------------
diff --git a/engines/saga2/target.h b/engines/saga2/target.h
index d13830b497..d9ad22db7d 100644
--- a/engines/saga2/target.h
+++ b/engines/saga2/target.h
@@ -669,7 +669,7 @@ public:
const size_t targetBytes = sizeof(LocationTarget);
-typedef uint8 TargetPlaceHolder[ targetBytes ];
+typedef uint8 TargetPlaceHolder[targetBytes];
} // end of namespace Saga2
diff --git a/engines/saga2/task.cpp b/engines/saga2/task.cpp
index b539d483e1..4c0350c34f 100644
--- a/engines/saga2/task.cpp
+++ b/engines/saga2/task.cpp
@@ -80,16 +80,16 @@ TilePoint computeRepulsionVector(
int16 repulsorWeight,
repulsorDist;
- repulsorDist = repulsorVectorArray[ i ].quickHDistance()
- + abs(repulsorVectorArray[ i ].z);
+ repulsorDist = repulsorVectorArray[i].quickHDistance()
+ + abs(repulsorVectorArray[i].z);
repulsorWeight =
repulsorDist != 0
? 64 * 64 / (repulsorDist * repulsorDist)
: 64 * 64;
repulsionVector +=
- (-repulsorVectorArray[ i ]
- * repulsorStrengthArray[ i ]
+ (-repulsorVectorArray[i]
+ * repulsorStrengthArray[i]
* repulsorWeight)
/ 16;
}
@@ -111,7 +111,7 @@ class TaskStackList {
#endif
struct TaskStackPlaceHolder : public DNode {
- uint8 buf[ sizeof(TaskStack) ];
+ uint8 buf[sizeof(TaskStack)];
TaskStackPlaceHolder *nextDeletion; // Pointer to next in lazy deletion list
bool deleted; // Deletion indicator
@@ -124,7 +124,7 @@ class TaskStackList {
DList list, // active TaskStacks
free; // inactive TaskStacks
- TaskStackPlaceHolder array[ numTaskStacks ];
+ TaskStackPlaceHolder array[numTaskStacks];
bool lazyDelete; // Flag indicating lazy deletion mode
TaskStackPlaceHolder *deletionList; // Singly linked list of all task stack
@@ -168,7 +168,7 @@ public:
// Return a pointer to a TaskStack given a TaskStackID
TaskStack *getTaskStackAddress(TaskStackID id) {
assert(id >= 0 && id < numTaskStacks);
- return array[ id ].getTaskStack();
+ return array[id].getTaskStack();
}
// Run through the TaskStacks in the active list and update
@@ -184,8 +184,8 @@ TaskStackList::TaskStackList(void) {
int i;
for (i = 0; i < elementsof(array); i++) {
- array[ i ].deleted = FALSE;
- free.addTail(array[ i ]);
+ array[i].deleted = FALSE;
+ free.addTail(array[i]);
}
lazyDelete = FALSE;
@@ -316,7 +316,7 @@ void *TaskStackList::newTaskStack(TaskStackID id) {
TaskStackPlaceHolder *tsp;
// Grab the stack place holder from the inactive list
- tsp = (TaskStackPlaceHolder *)&array[ id ];
+ tsp = (TaskStackPlaceHolder *)&array[id];
tsp->remove();
// Place the stack place holder into the active list
@@ -411,7 +411,7 @@ void TaskStackList::updateTaskStacks(void) {
// call will simply return a pointer to the stackListBuffer in order
// to construct the TaskStackList in place.
-static uint8 stackListBuffer[ sizeof(TaskStackList) ];
+static uint8 stackListBuffer[sizeof(TaskStackList)];
static TaskStackList &stackList = *((TaskStackList *)stackListBuffer);
@@ -529,7 +529,7 @@ void loadTaskStacks(SaveFileReader &saveGame) {
new (&stackList) TaskStackList;
bufferPtr = stackList.restore(bufferPtr);
- assert(bufferPtr == &((char *)archiveBuffer)[ archiveBufSize ]);
+ assert(bufferPtr == &((char *)archiveBuffer)[archiveBufSize]);
RDisposePtr(archiveBuffer);
}
@@ -558,7 +558,7 @@ class TaskList {
int lineNo;
bool marked;
#endif
- uint8 buf[ maxTaskSize ];
+ uint8 buf[maxTaskSize];
Task *getTask(void) {
return (Task *)&buf;
@@ -568,7 +568,7 @@ class TaskList {
DList list, // active Tasks
free; // inactive Tasks
- TaskPlaceHolder array[ numTasks ];
+ TaskPlaceHolder array[numTasks];
public:
// Constructor -- initial construction
@@ -615,7 +615,7 @@ public:
// Return a pointer to a Task given a TaskID
Task *getTaskAddress(TaskID id) {
assert(id >= 0 && id < numTasks);
- return array[ id ].getTask();
+ return array[id].getTask();
}
#if DEBUG
@@ -645,7 +645,7 @@ TaskList::TaskList(void) {
int i;
for (i = 0; i < elementsof(array); i++)
- free.addTail(array[ i ]);
+ free.addTail(array[i]);
}
//----------------------------------------------------------------------
@@ -790,7 +790,7 @@ void *TaskList::newTask(TaskID id)
TaskPlaceHolder *tp;
// Grab the task place holder from the inactive list
- tp = (TaskPlaceHolder *)&array[ id ];
+ tp = (TaskPlaceHolder *)&array[id];
tp->remove();
#if DEBUG
@@ -867,7 +867,7 @@ void TaskList::clearMarks(void) {
// pointer to the taskListBuffer in order to construct the TaskList in
// place.
-static uint8 taskListBuffer[ sizeof(TaskList) ];
+static uint8 taskListBuffer[sizeof(TaskList)];
static TaskList &taskList = *((TaskList *)taskListBuffer);
@@ -985,7 +985,7 @@ void loadTasks(SaveFileReader &saveGame) {
new (&taskList) TaskList;
bufferPtr = taskList.restore(bufferPtr);
- assert(bufferPtr == &((char *)archiveBuffer)[ archiveBufSize ]);
+ assert(bufferPtr == &((char *)archiveBuffer)[archiveBufSize]);
RDisposePtr(archiveBuffer);
}
@@ -2321,7 +2321,7 @@ TaskResult GoAwayFromTask::update(void) {
dest.v = actorLoc.v + ((int32)repulsionVector.v * 64 / repulsionDist);
dest.z = actorLoc.z;
} else
- dest = actorLoc + dirTable[ a->currentFacing ];
+ dest = actorLoc + dirTable[a->currentFacing];
if (goTask != NULL) {
if (goTask->getTarget() != dest)
@@ -2494,10 +2494,10 @@ TilePoint GoAwayFromActorTask::getRepulsionVector(void) {
TilePoint actorLoc = a->getLocation(),
repulsionVector;
int16 i;
- TilePoint locArray[ 6 ];
- int16 strengthArray[ elementsof(locArray) ] =
+ TilePoint locArray[6];
+ int16 strengthArray[elementsof(locArray)] =
{ 1, 1, 1, 1, 1, 1 };
- int16 distArray[ elementsof(locArray) ];
+ int16 distArray[elementsof(locArray)];
TargetLocationArray tla(
elementsof(locArray),
locArray,
@@ -2508,13 +2508,13 @@ TilePoint GoAwayFromActorTask::getRepulsionVector(void) {
if (tla.locs == 0) return TilePoint(0, 0, 0);
for (i = 0; i < tla.locs; i++)
- locArray[ i ] -= actorLoc;
+ locArray[i] -= actorLoc;
repulsionVector = computeRepulsionVector(locArray, strengthArray, tla.locs);
return repulsionVector.quickHDistance() > 0
? repulsionVector
- : -locArray[ 0 ];
+ : -locArray[0];
}
/* ===================================================================== *
@@ -3053,8 +3053,8 @@ void HuntToBeNearObjectTask::evaluateTarget(void) {
if (targetEvaluateCtr == 0) {
Actor *a = stack->getActor();
int16 i;
- GameObject *objArray[ 16 ];
- int16 distArray[ elementsof(objArray) ];
+ GameObject *objArray[16];
+ int16 distArray[elementsof(objArray)];
TargetObjectArray toa(
elementsof(objArray),
objArray,
@@ -3067,7 +3067,7 @@ void HuntToBeNearObjectTask::evaluateTarget(void) {
// Iterate through each object in the array and determine if
// there is a line of sight to that object
for (i = 0; i < toa.objs; i++) {
- ObjectID objID = objArray[ i ]->thisID();
+ ObjectID objID = objArray[i]->thisID();
if (a->canSenseSpecificObject(
info,
@@ -3077,7 +3077,7 @@ void HuntToBeNearObjectTask::evaluateTarget(void) {
info,
maxSenseRange,
objID)) {
- currentTarget = objArray[ i ];
+ currentTarget = objArray[i];
break;
}
}
@@ -3192,8 +3192,8 @@ void HuntToPossessTask::evaluateTarget(void) {
if (targetEvaluateCtr == 0) {
Actor *a = stack->getActor();
int16 i;
- GameObject *objArray[ 16 ];
- int16 distArray[ elementsof(objArray) ];
+ GameObject *objArray[16];
+ int16 distArray[elementsof(objArray)];
TargetObjectArray toa(
elementsof(objArray),
objArray,
@@ -3206,7 +3206,7 @@ void HuntToPossessTask::evaluateTarget(void) {
// Iterate through each object in the array and determine if
// there is a line of sight to that object
for (i = 0; i < toa.objs; i++) {
- ObjectID objID = objArray[ i ]->thisID();
+ ObjectID objID = objArray[i]->thisID();
if (a->canSenseSpecificObject(
info,
@@ -3216,7 +3216,7 @@ void HuntToPossessTask::evaluateTarget(void) {
info,
maxSenseRange,
objID)) {
- currentTarget = objArray[ i ];
+ currentTarget = objArray[i];
break;
}
}
@@ -3491,8 +3491,8 @@ void HuntToBeNearActorTask::evaluateTarget(void) {
if (targetEvaluateCtr == 0) {
Actor *a = stack->getActor();
int16 i;
- Actor *actorArray[ 16 ];
- int16 distArray[ elementsof(actorArray) ];
+ Actor *actorArray[16];
+ int16 distArray[elementsof(actorArray)];
TargetActorArray taa(
elementsof(actorArray),
actorArray,
@@ -3509,14 +3509,14 @@ void HuntToBeNearActorTask::evaluateTarget(void) {
|| a->canSenseSpecificActor(
info,
maxSenseRange,
- actorArray[ i ])
+ actorArray[i])
|| a->canSenseSpecificActorIndirectly(
info,
maxSenseRange,
- actorArray[ i ])) {
- if (currentTarget != actorArray[ i ]) {
+ actorArray[i])) {
+ if (currentTarget != actorArray[i]) {
if (atTarget()) atTargetabortTask();
- currentTarget = actorArray[ i ];
+ currentTarget = actorArray[i];
}
break;
@@ -3736,8 +3736,8 @@ void HuntToKillTask::evaluateTarget(void) {
Actor *bestTarget = NULL;
ActorProto *proto = (ActorProto *)a->proto();
int16 i;
- Actor *actorArray[ 16 ];
- int16 distArray[ elementsof(actorArray) ];
+ Actor *actorArray[16];
+ int16 distArray[elementsof(actorArray)];
TargetActorArray taa(
elementsof(actorArray),
actorArray,
@@ -3752,18 +3752,18 @@ void HuntToKillTask::evaluateTarget(void) {
// Iterate through each actor in the array and determine if
// there is a line of sight to that actor
for (i = 0; i < taa.actors; i++) {
- if (actorArray[ i ]->isDead()) continue;
+ if (actorArray[i]->isDead()) continue;
if (tracking()
|| a->canSenseSpecificActor(
info,
maxSenseRange,
- actorArray[ i ])
+ actorArray[i])
|| a->canSenseSpecificActorIndirectly(
info,
maxSenseRange,
- actorArray[ i ])) {
- bestTarget = actorArray[ i ];
+ actorArray[i])) {
+ bestTarget = actorArray[i];
break;
}
}
@@ -3773,25 +3773,25 @@ void HuntToKillTask::evaluateTarget(void) {
int16 bestScore = 0;
for (i = 0; i < taa.actors; i++) {
- if (actorArray[ i ]->isDead()) continue;
+ if (actorArray[i]->isDead()) continue;
if (tracking()
|| a->canSenseSpecificActor(
info,
maxSenseRange,
- actorArray[ i ])
+ actorArray[i])
|| a->canSenseSpecificActorIndirectly(
info,
maxSenseRange,
- actorArray[ i ])) {
+ actorArray[i])) {
int16 score;
- score = closenessScore(distArray[ i ]) * 16
- / actorArray[ i ]->defenseScore();
+ score = closenessScore(distArray[i]) * 16
+ / actorArray[i]->defenseScore();
if (score > bestScore || bestTarget == NULL) {
bestScore = score;
- bestTarget = actorArray[ i ];
+ bestTarget = actorArray[i];
}
}
}
@@ -3802,25 +3802,25 @@ void HuntToKillTask::evaluateTarget(void) {
int16 bestScore = 0;
for (i = 0; i < taa.actors; i++) {
- if (actorArray[ i ]->isDead()) continue;
+ if (actorArray[i]->isDead()) continue;
if (tracking()
|| a->canSenseSpecificActor(
info,
maxSenseRange,
- actorArray[ i ])
+ actorArray[i])
|| a->canSenseSpecificActorIndirectly(
info,
maxSenseRange,
- actorArray[ i ])) {
+ actorArray[i])) {
int16 score;
- score = closenessScore(distArray[ i ])
- * actorArray[ i ]->offenseScore();
+ score = closenessScore(distArray[i])
+ * actorArray[i]->offenseScore();
if (score > bestScore || bestTarget == NULL) {
bestScore = score;
- bestTarget = actorArray[ i ];
+ bestTarget = actorArray[i];
}
}
}
@@ -3831,26 +3831,26 @@ void HuntToKillTask::evaluateTarget(void) {
int16 bestScore = 0;
for (i = 0; i < taa.actors; i++) {
- if (actorArray[ i ]->isDead()) continue;
+ if (actorArray[i]->isDead()) continue;
if (tracking()
|| a->canSenseSpecificActor(
info,
maxSenseRange,
- actorArray[ i ])
+ actorArray[i])
|| a->canSenseSpecificActorIndirectly(
info,
maxSenseRange,
- actorArray[ i ])) {
+ actorArray[i])) {
int16 score;
- score = closenessScore(distArray[ i ])
- * actorArray[ i ]->offenseScore()
- / actorArray[ i ]->defenseScore();
+ score = closenessScore(distArray[i])
+ * actorArray[i]->offenseScore()
+ / actorArray[i]->defenseScore();
if (score > bestScore || bestTarget == NULL) {
bestScore = score;
- bestTarget = actorArray[ i ];
+ bestTarget = actorArray[i];
}
}
}
@@ -4102,7 +4102,7 @@ bool BandTask::BandingRepulsorIterator::first(
bandIndex = 0;
while (bandIndex < band->size()) {
- Actor *bandMember = (*band)[ bandIndex ];
+ Actor *bandMember = (*band)[bandIndex];
if (bandMember != a) {
repulsorVector = bandMember->getLocation() - a->getLocation();
@@ -4128,7 +4128,7 @@ bool BandTask::BandingRepulsorIterator::next(
bandIndex++;
while (bandIndex < band->size()) {
- Actor *bandMember = (*band)[ bandIndex ];
+ Actor *bandMember = (*band)[bandIndex];
if (bandMember != a) {
repulsorVector = bandMember->getLocation() - a->getLocation();
@@ -4246,9 +4246,9 @@ void BandTask::evaluateTarget(void) {
movementVector;
TilePoint repulsorVector;
int16 repulsorStrength;
- TilePoint repulsorVectorArray[ 6 ];
- int16 repulsorStrengthArray[ elementsof(repulsorVectorArray) ];
- int16 repulsorDistArray[ elementsof(repulsorVectorArray) ];
+ TilePoint repulsorVectorArray[6];
+ int16 repulsorStrengthArray[elementsof(repulsorVectorArray)];
+ int16 repulsorDistArray[elementsof(repulsorVectorArray)];
int16 repulsorCount;
bool repulsorFlag;
@@ -4258,9 +4258,9 @@ void BandTask::evaluateTarget(void) {
// Count the leader as two band members to double his
// repulsion
- repulsorVectorArray[ 0 ] = leader->getLocation() - actorLoc;
- repulsorStrengthArray[ 0 ] = 3;
- repulsorDistArray[ 0 ] = repulsorVectorArray[ 0 ].quickHDistance();
+ repulsorVectorArray[0] = leader->getLocation() - actorLoc;
+ repulsorStrengthArray[0] = 3;
+ repulsorDistArray[0] = repulsorVectorArray[0].quickHDistance();
repulsorCount = 1;
// Iterate through the band members, adding their locations
@@ -4275,28 +4275,28 @@ void BandTask::evaluateTarget(void) {
int16 repulsorDist = repulsorVector.quickHDistance();
int16 j = repulsorCount;
- if (repulsorDist < repulsorDistArray[ j - 1 ]) {
+ if (repulsorDist < repulsorDistArray[j - 1]) {
if (repulsorCount < elementsof(repulsorVectorArray)) {
- repulsorDistArray[ j ] = repulsorDistArray[ j - 1 ];
- repulsorVectorArray[ j ] = repulsorVectorArray[ j - 1 ];
- repulsorStrengthArray[ j ] = repulsorStrengthArray[ j - 1 ];
+ repulsorDistArray[j] = repulsorDistArray[j - 1];
+ repulsorVectorArray[j] = repulsorVectorArray[j - 1];
+ repulsorStrengthArray[j] = repulsorStrengthArray[j - 1];
}
j--;
}
- while (j > 0 && repulsorDist < repulsorDistArray[ j - 1 ]) {
- repulsorDistArray[ j ] = repulsorDistArray[ j - 1 ];
- repulsorVectorArray[ j ] = repulsorVectorArray[ j - 1 ];
- repulsorStrengthArray[ j ] = repulsorStrengthArray[ j - 1 ];
+ while (j > 0 && repulsorDist < repulsorDistArray[j - 1]) {
+ repulsorDistArray[j] = repulsorDistArray[j - 1];
+ repulsorVectorArray[j] = repulsorVectorArray[j - 1];
+ repulsorStrengthArray[j] = repulsorStrengthArray[j - 1];
j--;
}
if (j < elementsof(repulsorVectorArray)) {
if (repulsorCount < elementsof(repulsorVectorArray))
repulsorCount++;
- repulsorDistArray[ j ] = repulsorDist;
- repulsorVectorArray[ j ] = repulsorVector;
- repulsorStrengthArray[ j ] = repulsorStrength;
+ repulsorDistArray[j] = repulsorDist;
+ repulsorVectorArray[j] = repulsorVector;
+ repulsorStrengthArray[j] = repulsorStrength;
}
}
@@ -4425,7 +4425,7 @@ bool BandTask::BandAndAvoidEnemiesRepulsorIterator::firstEnemyRepulsor(
int16 &repulsorStrength) {
assert(iteratingThruEnemies);
- int16 actorDistArray[ elementsof(actorArray) ];
+ int16 actorDistArray[elementsof(actorArray)];
TargetActorArray taa(elementsof(actorArray), actorArray, actorDistArray);
ActorPropertyTarget target(actorPropIDEnemy);
@@ -4437,7 +4437,7 @@ bool BandTask::BandAndAvoidEnemiesRepulsorIterator::firstEnemyRepulsor(
if (actorIndex < numActors) {
repulsorVector =
- actorArray[ actorIndex ]->getLocation() - a->getLocation();
+ actorArray[actorIndex]->getLocation() - a->getLocation();
repulsorStrength = 6;
return TRUE;
@@ -4458,7 +4458,7 @@ bool BandTask::BandAndAvoidEnemiesRepulsorIterator::nextEnemyRepulsor(
if (actorIndex < numActors) {
repulsorVector =
- actorArray[ actorIndex ]->getLocation() - a->getLocation();
+ actorArray[actorIndex]->getLocation() - a->getLocation();
repulsorStrength = 6;
return TRUE;
diff --git a/engines/saga2/task.h b/engines/saga2/task.h
index 2a0801c1c7..4f335df57e 100644
--- a/engines/saga2/task.h
+++ b/engines/saga2/task.h
@@ -1312,7 +1312,7 @@ public:
// even though it is explicitly declared protected and not private.
// Watcom C++, however, works correctly.
class BandAndAvoidEnemiesRepulsorIterator : public BandingRepulsorIterator {
- Actor *actorArray[ 6 ];
+ Actor *actorArray[6];
int numActors,
actorIndex;
bool iteratingThruEnemies;
@@ -1401,7 +1401,7 @@ protected:
// I had to move this nested class up to the BandTask class because
// Visual C++ is lame.
/* class BandAndAvoidEnemiesRepulsorIterator : public BandingRepulsorIterator {
- Actor *actorArray[ 6 ];
+ Actor *actorArray[6];
int numActors,
actorIndex;
bool iteratingThruEnemies;
diff --git a/engines/saga2/terrain.cpp b/engines/saga2/terrain.cpp
index a32fe8c2d2..a46cf3692d 100644
--- a/engines/saga2/terrain.cpp
+++ b/engines/saga2/terrain.cpp
@@ -113,7 +113,7 @@ uint32 tileTerrain(
int16 mask,
int16 minZ,
int16 maxZ) {
- WorldMapData *map = &mapList[ mapNum ];
+ WorldMapData *map = &mapList[mapNum];
TilePoint metaCoords = pt >> platShift,
origin = metaCoords << platShift,
@@ -211,10 +211,10 @@ uint32 tileTerrain(
Function to get the terrain infor for a rectilinear volume
* ===================================================================== */
-uint16 uMaxMasks[ 4 ] = { 0x0000, 0x000F, 0x00FF, 0x0FFF },
- uMinMasks[ 4 ] = { 0xFFFF, 0xFFF0, 0xFF00, 0xF000 },
- vMaxMasks[ 4 ] = { 0x0000, 0x1111, 0x3333, 0x7777 },
- vMinMasks[ 4 ] = { 0xFFFF, 0xEEEE, 0xCCCC, 0x8888 };
+uint16 uMaxMasks[4] = { 0x0000, 0x000F, 0x00FF, 0x0FFF },
+ uMinMasks[4] = { 0xFFFF, 0xFFF0, 0xFF00, 0xF000 },
+ vMaxMasks[4] = { 0x0000, 0x1111, 0x3333, 0x7777 },
+ vMinMasks[4] = { 0xFFFF, 0xEEEE, 0xCCCC, 0x8888 };
uint32 volumeTerrain(int16 mapNum, const TileRegion &vol) {
uint32 terrain = 0; // accumulated terrain
@@ -251,10 +251,10 @@ uint32 volumeTerrain(int16 mapNum, const TileRegion &vol) {
uint16 vSectionMask = 0xFFFF;
if (tilePt.v == footprint.min.v)
- vSectionMask &= vMinMasks[ subPos.min.v ];
+ vSectionMask &= vMinMasks[subPos.min.v];
if (tilePt.v == footprint.max.v)
- vSectionMask &= vMaxMasks[ subPos.max.v ];
+ vSectionMask &= vMaxMasks[subPos.max.v];
for (tilePt.u = footprint.min.u;
tilePt.u <= footprint.max.u;
@@ -262,10 +262,10 @@ uint32 volumeTerrain(int16 mapNum, const TileRegion &vol) {
uint16 uSectionMask = vSectionMask;
if (tilePt.u == footprint.min.u)
- uSectionMask &= uMinMasks[ subPos.min.u ];
+ uSectionMask &= uMinMasks[subPos.min.u];
if (tilePt.u == footprint.max.u)
- uSectionMask &= uMaxMasks[ subPos.max.u ];
+ uSectionMask &= uMaxMasks[subPos.max.u];
terrain |= tileTerrain(
mapNum,
@@ -351,8 +351,8 @@ uint32 volumeTerrain(
Function to get the terrain info for linear area
* ===================================================================== */
-uint16 uMask[ 4 ] = { 0x000F, 0x00F0, 0x0F00, 0xF000 },
- vMask[ 4 ] = { 0x1111, 0x2222, 0x4444, 0x8888 };
+uint16 uMask[4] = { 0x000F, 0x00F0, 0x0F00, 0xF000 },
+ vMask[4] = { 0x1111, 0x2222, 0x4444, 0x8888 };
uint32 lineTerrain(
int16 mapNum,
@@ -624,7 +624,7 @@ int16 tileSlopeHeight(
lowestSupportPlatform = 0;
// Look up the metatile on the map.
- metaPtr = prevMeta = mapList[ mapNum ].lookupMeta(metaCoords);
+ metaPtr = prevMeta = mapList[mapNum].lookupMeta(metaCoords);
prevMapNum = mapNum;
prevCoords = metaCoords;
@@ -825,7 +825,7 @@ int16 checkBlocked(
}
// See if object collided with an object
- world = (GameWorld *)GameObject::objectAddress(mapList[ mapNum ].worldID);
+ world = (GameWorld *)GameObject::objectAddress(mapList[mapNum].worldID);
blockObj = objectCollision(obj, world, loc);
if (blockObj) {
if (blockResultObj) *blockResultObj = blockObj;
@@ -907,7 +907,7 @@ int16 checkContact(
return blockageTerrain;
// See if object collided with an object
- world = (GameWorld *)GameObject::objectAddress(mapList[ mapNum ].worldID);
+ world = (GameWorld *)GameObject::objectAddress(mapList[mapNum].worldID);
blockObj = objectCollision(obj, world, loc);
if (blockObj) {
if (blockResultObj) *blockResultObj = blockObj;
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index 71254ecd10..4095a73b88 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -137,7 +137,7 @@ struct TileAttrs {
bgdTerrain;
// Reserved bytes
- uint8 reserved0[ 8 ]; // auto-terrain data
+ uint8 reserved0[8]; // auto-terrain data
// Masking information
@@ -146,7 +146,7 @@ struct TileAttrs {
// Altitude information
- uint8 cornerHeight[ 4 ];
+ uint8 cornerHeight[4];
// Animation information
@@ -312,10 +312,10 @@ struct TileInfo {
class TileBank {
public:
uint32 numTiles; // number of tiles in list
- TileInfo tileArray[ 1 ]; // variable-sized array
+ TileInfo tileArray[1]; // variable-sized array
TileInfo *tile(uint16 index) {
- return &tileArray[ index ];
+ return &tileArray[index];
}
};
@@ -371,7 +371,7 @@ public:
currentState, // current state of animation
cycleSpeed; // speed of cycling (0=none)
- TileID cycleList[ 16 ]; // array of tiles
+ TileID cycleList[16]; // array of tiles
};
typedef TileCycleData
@@ -397,7 +397,7 @@ class ActiveItem {
public:
ActiveItem *nextHash; // next item in hash chain
-// char name[ 32 ]; // name of this group
+// char name[32]; // name of this group
// uint16 flags; // various flags
// TileGroupID itemID; // unique # of this item
@@ -630,7 +630,7 @@ class TileActivityTaskList {
DList list,
free;
- TileActivityTask array[ 32 ];
+ TileActivityTask array[32];
public:
// Constructor -- initial construction
@@ -677,14 +677,14 @@ struct Platform {
uint16 height, // height above ground
highestPixel; // tallest tile upper extent
uint16 flags; // platform flags
- TileRef tiles[ platformWidth ][ platformWidth ];
+ TileRef tiles[platformWidth][platformWidth];
TileRef &getTileRef(const TilePoint p) {
- return tiles[ p.u ][ p.v ];
+ return tiles[p.u][p.v];
}
TileRef &getTileRef(int16 u, int16 v) {
- return tiles[ u ][ v ];
+ return tiles[u][v];
}
// fetch the REAL tile terrain info
@@ -779,7 +779,7 @@ typedef int16 RipTableID;
struct RipTable {
MetaTileID metaID;
uint16 ripID;
- int16 zTable[ platformWidth ][ platformWidth ];
+ int16 zTable[platformWidth][platformWidth];
// Constructor
RipTable(void) : metaID(NoMetaTile) {}
@@ -845,7 +845,7 @@ typedef MetaTile *MetaTilePtr,
struct MapHeader {
int16 size; // size of map
int16 edgeType; // edge type of map
- uint16 mapData[ 1 ]; // start of map array
+ uint16 mapData[1]; // start of map array
};
enum mapEdgeTypes {
@@ -875,7 +875,7 @@ struct WorldMapData {
UWordPtr assocList; // Associations
RipTableIDPtr ripTableIDList; // MetaTile object ripping
- ActiveItem *instHash[ 513 ]; // ActiveItem hash table
+ ActiveItem *instHash[513]; // ActiveItem hash table
int16 metaCount, // Number of MetaTiles
activeCount; // Number of ActiveItems
diff --git a/engines/saga2/tileload.h b/engines/saga2/tileload.h
index 50903007d6..a3feba3bf8 100644
--- a/engines/saga2/tileload.h
+++ b/engines/saga2/tileload.h
@@ -44,9 +44,9 @@ const int maxBanks = 64; // 64 banks maximum
// to render.
/*
struct BankBits {
- uint32 b[ maxBanks / 32 ];
+ uint32 b[maxBanks / 32];
- bool isSet( int i ) { return b[ i >> 5 ] & (1 << (i & 31)); }
+ bool isSet( int i ) { return b[i >> 5] & (1 << (i & 31)); }
};
*/
@@ -108,7 +108,7 @@ public:
}
bool isSet(uint16 i) {
- return (bool)(b[ i >> 5 ] & ((uint32) 1 << (i & 31)));
+ return (bool)(b[i >> 5] & ((uint32) 1 << (i & 31)));
}
void SetBit(int16 i) {
@@ -161,7 +161,7 @@ private:
return (1 << (n & 31));
}
- uint32 b[ lWords ];
+ uint32 b[lWords];
void clear(void) {
memset(&b, 0, sizeof b);
@@ -198,7 +198,7 @@ public:
FixedBitArray t;
for (uint16 i = 0; i < lWords; i++)
- t.b[ i ] = c.b[ i ] & d.b[ i ];
+ t.b[i] = c.b[i] & d.b[i];
return t;
}
@@ -206,19 +206,19 @@ public:
FixedBitArray t;
for (uint16 i = 0; i < lWords; i++)
- t.b[ i ] = c.b[ i ] | d.b[ i ];
+ t.b[i] = c.b[i] | d.b[i];
return t;
}
friend FixedBitArray &operator|= (FixedBitArray c, FixedBitArray d) {
for (uint16 i = 0; i < lWords; i++)
- c.b[ i ] |= d.b[ i ];
+ c.b[i] |= d.b[i];
return c;
}
friend bool operator!= (FixedBitArray c, FixedBitArray d) {
for (uint16 i = 0; i < lWords; i++)
- if (c.b[ i ] != d.b[ i ]) return TRUE;
+ if (c.b[i] != d.b[i]) return TRUE;
return FALSE;
}
@@ -226,7 +226,7 @@ public:
FixedBitArray t;
for (uint16 i = 0; i < lWords; i++)
- t.b[ i ] = c.b[ i ] ^ d.b[ i ];
+ t.b[i] = c.b[i] ^ d.b[i];
return t;
}
@@ -261,7 +261,7 @@ public:
return t;
}
bool isSet(int i) {
- return b[ i >> 5 ] & ((uint32) 1 << (i & 31));
+ return b[i >> 5] & ((uint32) 1 << (i & 31));
}
void SetBit(int16 i) {
@@ -323,18 +323,18 @@ template <class RES> RES *loadOnCall<RES>::loadRes( uint16 i )
{
RES h;
- if (handle[ i ])
+ if (handle[i])
{
loaded.SetBit(i);
- RLockHandle( (RHANDLE) handle[ i ] );
- return handle[ i ];
+ RLockHandle( (RHANDLE) handle[i] );
+ return handle[i];
}
h = (RES) tileRes->load( tileID + RES_ID( 0,0,0,i ) );
loaded.SetBit(i);
- handle[ i ] = h;
+ handle[i] = h;
return h;
}
@@ -342,20 +342,20 @@ template <class RES> RES *loadOnCall<RES>::initRes( uint16 i )
{
RES h;
- if (!handle[ i ])
+ if (!handle[i])
{
h = (RES) tileRes->load( tileID + RES_ID( 0,0,0,i ) );
loaded.SetBit(i);
- handle[ i ] = h;
+ handle[i] = h;
return h;
}
}
template <class RES> void loadOnCall<RES>::freeRes( uint16 i )
{
- if (handle[ i ])
+ if (handle[i])
{
- RUnlockHandle((RHANDLE) handles[ i ]);
+ RUnlockHandle((RHANDLE) handles[i]);
loaded.NotBit(i);
}
}
diff --git a/engines/saga2/tilemode.cpp b/engines/saga2/tilemode.cpp
index 607cefb869..623df7cc7e 100644
--- a/engines/saga2/tilemode.cpp
+++ b/engines/saga2/tilemode.cpp
@@ -863,7 +863,7 @@ void TileModeHandleTask(void) {
// object at which the mouse is pointing
if (dispObjNameAlarm.check()) {
const int bufSize = 40;
- char cursorText[ bufSize ];
+ char cursorText[bufSize];
// get the object text into the buffer
item->objCursorText(cursorText, bufSize);
@@ -1075,12 +1075,12 @@ void TileModeHandleKey(int16 key, int16 qual) {
// A debugging function to show the queue of recent mouse events.
#if DEBUG
-static char mouseHistory[ 33 ];
+static char mouseHistory[33];
void showMouseEvent(char eventType) {
memmove(mouseHistory + 1, mouseHistory, 31);
- mouseHistory[ 0 ] = eventType;
- mouseHistory[ 32 ] = '\0';
+ mouseHistory[0] = eventType;
+ mouseHistory[32] = '\0';
WriteStatusF(5, mouseHistory);
}
#endif
diff --git a/engines/saga2/timers.cpp b/engines/saga2/timers.cpp
index ceaf899bc9..61135de48b 100644
--- a/engines/saga2/timers.cpp
+++ b/engines/saga2/timers.cpp
@@ -35,7 +35,7 @@
namespace Saga2 {
struct TimerListHolder : public DNode {
- uint8 timerListBuffer[ sizeof(TimerList) ];
+ uint8 timerListBuffer[sizeof(TimerList)];
TimerList *getTimerList(void) {
return (TimerList *)&timerListBuffer;
@@ -47,7 +47,7 @@ struct TimerListHolder : public DNode {
* ===================================================================== */
struct TimerHolder : public DNode {
- uint8 timerBuffer[ sizeof(Timer) ];
+ uint8 timerBuffer[sizeof(Timer)];
Timer *getTimer(void) {
return (Timer *)&timerBuffer;
@@ -240,7 +240,7 @@ void saveTimers(SaveFileConstructor &saveGame) {
timerHolder = (TimerHolder *)timerHolder->next())
bufferPtr = timerHolder->getTimer()->archive(bufferPtr);
- assert(bufferPtr == &((uint8 *)archiveBuffer)[ archiveBufSize ]);
+ assert(bufferPtr == &((uint8 *)archiveBuffer)[archiveBufSize]);
// Write the data to the save file
saveGame.writeChunk(
@@ -299,7 +299,7 @@ void loadTimers(SaveFileReader &saveGame) {
timerList->addTail(*timer);
}
- assert(bufferPtr == &((uint8 *)archiveBuffer)[ saveGame.getChunkSize() ]);
+ assert(bufferPtr == &((uint8 *)archiveBuffer)[saveGame.getChunkSize()]);
RDisposePtr(archiveBuffer);
}
diff --git a/engines/saga2/transit.cpp b/engines/saga2/transit.cpp
index 00645ed667..8d9bbe258a 100644
--- a/engines/saga2/transit.cpp
+++ b/engines/saga2/transit.cpp
@@ -55,7 +55,7 @@ bool isModalMode(void) {
// go through each stacked mode
// and if modal mode is one of them,
// then set the modal flag
- if (GameMode::modeStackPtr[ i ] == &ModalMode) {
+ if (GameMode::modeStackPtr[i] == &ModalMode) {
modalFlag = TRUE;
}
}
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index 2b5c0201cd..ac13972d00 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -210,28 +210,28 @@ Rect16 saveLoadWindowRect = Rect16(SLDBoxX,
// indirections
-Rect16 saveLoadPanelRects[ numSaveLoadPanels ] = { { SLTopPanel },
+Rect16 saveLoadPanelRects[numSaveLoadPanels] = { { SLTopPanel },
{ SLMidPanel },
{ SLBotPanel }
};
-Rect16 saveLoadButtonRects[ numSaveLoadBtns ] = { { SLQuitBtnRect },
+Rect16 saveLoadButtonRects[numSaveLoadBtns] = { { SLQuitBtnRect },
{ SLBtnRect },
{ SLUpArrowBtnRect },
{ SLDnArrowBtnRect }
};
-Rect16 saveLoadTextRects[ numSaveLoadTexts ] = { { SLTitleRect } };
+Rect16 saveLoadTextRects[numSaveLoadTexts] = { { SLTitleRect } };
// save/load dialog window decorations
-WindowDecoration saveWindowDecorations[ numSaveLoadPanels ] =
+WindowDecoration saveWindowDecorations[numSaveLoadPanels] =
-{ { WindowDecoration(saveLoadPanelRects[ 0 ], SLTopPanelResID) },
- { WindowDecoration(saveLoadPanelRects[ 1 ], SLMidPanelResID) },
- { WindowDecoration(saveLoadPanelRects[ 2 ], SLBotPanelResID) }
+{ { WindowDecoration(saveLoadPanelRects[0], SLTopPanelResID) },
+ { WindowDecoration(saveLoadPanelRects[1], SLMidPanelResID) },
+ { WindowDecoration(saveLoadPanelRects[2], SLBotPanelResID) }
};
@@ -417,7 +417,7 @@ Rect16 optionsWindowRect = Rect16(optBoxX,
// indirections
-Rect16 optionsPanelRects[ numOptionsPanels ] = { { optTopPanel },
+Rect16 optionsPanelRects[numOptionsPanels] = { { optTopPanel },
{ optMidPanel },
{ optBotPanel }
};
@@ -446,11 +446,11 @@ Rect16 optionsTextRects[] = { { optTitleText },
// options dialog window decorations
-WindowDecoration optionsDecorations[ numOptionsPanels ] =
+WindowDecoration optionsDecorations[numOptionsPanels] =
-{ { WindowDecoration(optionsPanelRects[ 0 ], optTopPanelResID) },
- { WindowDecoration(optionsPanelRects[ 1 ], optMidPanelResID) },
- { WindowDecoration(optionsPanelRects[ 2 ], optBotPanelResID) }
+{ { WindowDecoration(optionsPanelRects[0], optTopPanelResID) },
+ { WindowDecoration(optionsPanelRects[1], optMidPanelResID) },
+ { WindowDecoration(optionsPanelRects[2], optBotPanelResID) }
};
@@ -509,12 +509,12 @@ Rect16 messageRect(0,
-Rect16 messageTextRects[ numMessageTexts ] = { { mesTitleRect },
+Rect16 messageTextRects[numMessageTexts] = { { mesTitleRect },
{ messageRect }
};
-Rect16 messageButtonRects[ numMessageBtns ] = { { mesOkBtnRect },
+Rect16 messageButtonRects[numMessageBtns] = { { mesOkBtnRect },
{ mesCancelBtnRect },
{ mesBtn3Rect }
};
@@ -531,7 +531,7 @@ Rect16 messageWindowRect = Rect16(mesBoxX,
// message dialog window decorations
-WindowDecoration messageDecorations[ numMessagePanels ] =
+WindowDecoration messageDecorations[numMessagePanels] =
{ { WindowDecoration(messagePanel, mesPanelResID) } };
@@ -562,20 +562,20 @@ char **initFileFields(void) {
uint16 i;
SaveFileHeader header; // The save file header.
- char **strings = new (char *[ numEditLines ]);
+ char **strings = new (char *[numEditLines]);
for (i = 0; i < numEditLines; i++) {
- strings[ i ] = new char[ editLen + 1 ];
+ strings[i] = new char[editLen + 1];
if (getSaveName(i, header)) {
- strncpy(strings[ i ], header.saveName, editLen);
+ strncpy(strings[i], header.saveName, editLen);
} else {
- strncpy(strings[ i ], FILE_DIALOG_NONAME, editLen);
+ strncpy(strings[i], FILE_DIALOG_NONAME, editLen);
strings[i][0] |= 0x80;
}
// make sure this thing is caped
- strings[ i ][ editLen ] = '\0';
+ strings[i][editLen] = '\0';
}
return strings;
@@ -593,7 +593,7 @@ void destroyFileFields(char **strings) {
uint16 i;
for (i = 0; i < numEditLines; i++) {
- if (strings[i]) delete strings[ i ];
+ if (strings[i]) delete strings[i];
strings[i] = NULL;
}
@@ -602,7 +602,7 @@ void destroyFileFields(char **strings) {
bool getSaveName(int8 saveNo, SaveFileHeader &header) {
FILE *fileHandle; // A standard C file handle
- char fileName[ fileNameSize + 1 ];
+ char fileName[fileNameSize + 1];
// Construct the file name based on the save number
getSaveFileName(saveNo, fileName);
@@ -708,25 +708,25 @@ int16 FileDialog(int16 fileProcess) {
gCompButton *t;
// make the quit button
- checkAlloc(t = new gCompButton(*win, saveLoadButtonRects[ 0 ],
- pushBtnIm, numBtnImages, btnStrings[ stringIndex ][ 0 ], pal, 0, cmdDialogQuit));
+ checkAlloc(t = new gCompButton(*win, saveLoadButtonRects[0],
+ pushBtnIm, numBtnImages, btnStrings[stringIndex][0], pal, 0, cmdDialogQuit));
//t->accelKey=0x1B;
// make the Save/Load button
- checkAlloc(t = new gCompButton(*win, saveLoadButtonRects[ 1 ],
- pushBtnIm, numBtnImages, btnStrings[ stringIndex ][ 1 ], pal, fileProcess, fileCommands[ fileProcess ]));
+ checkAlloc(t = new gCompButton(*win, saveLoadButtonRects[1],
+ pushBtnIm, numBtnImages, btnStrings[stringIndex][1], pal, fileProcess, fileCommands[fileProcess]));
//t->accelKey=0x0D;
// make the up arrow
- checkAlloc(t = new gCompButton(*win, saveLoadButtonRects[ 2 ],
+ checkAlloc(t = new gCompButton(*win, saveLoadButtonRects[2],
arrowUpIm, numBtnImages, 0, cmdSaveDialogUp));
//t->accelKey=33+0x80;
// make the down arrow
- checkAlloc(t = new gCompButton(*win, saveLoadButtonRects[ 3 ],
+ checkAlloc(t = new gCompButton(*win, saveLoadButtonRects[3],
arrowDnIm, numBtnImages, 0, cmdSaveDialogDown));
//t->accelKey=34+0x80;
// attach the title
- checkAlloc(new CPlaqText(*win, saveLoadTextRects[ 0 ],
- textStrings[ stringIndex ][ 0 ], &Plate18Font, NULL, pal, 0, NULL));
+ checkAlloc(new CPlaqText(*win, saveLoadTextRects[0],
+ textStrings[stringIndex][0], &Plate18Font, NULL, pal, 0, NULL));
@@ -864,44 +864,44 @@ int16 OptionsDialog(bool disableSaveResume) {
// buttons
if (!disableSaveResume) {
- checkAlloc(t = new gCompButton(*win, optionsButtonRects[ 0 ],
- dialogPushImag, numBtnImages, btnStrings[ 0 ], pal, 0, cmdDialogQuit));
+ checkAlloc(t = new gCompButton(*win, optionsButtonRects[0],
+ dialogPushImag, numBtnImages, btnStrings[0], pal, 0, cmdDialogQuit));
t->accelKey = 0x1B;
- checkAlloc(t = new gCompButton(*win, optionsButtonRects[ 1 ],
- dialogPushImag, numBtnImages, btnStrings[ 1 ], pal, 0, cmdOptionsSaveGame)); // make the quit button
+ checkAlloc(t = new gCompButton(*win, optionsButtonRects[1],
+ dialogPushImag, numBtnImages, btnStrings[1], pal, 0, cmdOptionsSaveGame)); // make the quit button
t->accelKey = 'S';
} else {
- checkAlloc(t = new gCompButton(*win, optionsButtonRects[ 1 ],
+ checkAlloc(t = new gCompButton(*win, optionsButtonRects[1],
dialogPushImag, numBtnImages, OPTN_DIALOG_BUTTON6, pal, 0, cmdOptionsNewGame));
t->accelKey = 'N';
}
- checkAlloc(t = new gCompButton(*win, optionsButtonRects[ 2 ],
- dialogPushImag, numBtnImages, btnStrings[ 2 ], pal, 0, cmdOptionsLoadGame)); // make the quit button
+ checkAlloc(t = new gCompButton(*win, optionsButtonRects[2],
+ dialogPushImag, numBtnImages, btnStrings[2], pal, 0, cmdOptionsLoadGame)); // make the quit button
t->accelKey = 'L';
- checkAlloc(t = new gCompButton(*win, optionsButtonRects[ 3 ],
- dialogPushImag, numBtnImages, btnStrings[ 3 ], pal, 0, cmdQuitGame));
+ checkAlloc(t = new gCompButton(*win, optionsButtonRects[3],
+ dialogPushImag, numBtnImages, btnStrings[3], pal, 0, cmdQuitGame));
t->accelKey = 'Q';
- checkAlloc(t = new gCompButton(*win, optionsButtonRects[ 4 ],
- dialogPushImag, numBtnImages, btnStrings[ 4 ], pal, 0, cmdCredits));
+ checkAlloc(t = new gCompButton(*win, optionsButtonRects[4],
+ dialogPushImag, numBtnImages, btnStrings[4], pal, 0, cmdCredits));
t->accelKey = 'C';
- checkAlloc(autoAggressBtn = new gOwnerSelCompButton(*win, optionsButtonRects[ 5 ],
+ checkAlloc(autoAggressBtn = new gOwnerSelCompButton(*win, optionsButtonRects[5],
checkImag, numBtnImages, 0, cmdAutoAggression));
autoAggressBtn->select(isAutoAggressionSet());
- checkAlloc(autoWeaponBtn = new gOwnerSelCompButton(*win, optionsButtonRects[ 6 ],
+ checkAlloc(autoWeaponBtn = new gOwnerSelCompButton(*win, optionsButtonRects[6],
checkImag, numBtnImages, 0, cmdAutoWeapon));
autoWeaponBtn->select(isAutoWeaponSet());
- checkAlloc(speechTextBtn = new gOwnerSelCompButton(*win, optionsButtonRects[ 7 ],
+ checkAlloc(speechTextBtn = new gOwnerSelCompButton(*win, optionsButtonRects[7],
checkImag, numBtnImages, 0, cmdSpeechText));
speechTextBtn->select(globalConfig.speechText);
- checkAlloc(nightBtn = new gOwnerSelCompButton(*win, optionsButtonRects[ 8 ],
+ checkAlloc(nightBtn = new gOwnerSelCompButton(*win, optionsButtonRects[8],
checkImag, numBtnImages, 0, cmdNight));
nightBtn->select(globalConfig.showNight);
@@ -917,12 +917,12 @@ int16 OptionsDialog(bool disableSaveResume) {
127, slideFaceImag, numSlideFace, globalConfig.musicVolume,
0, cmdSetMIDIVolume));
- checkAlloc(new CPlaqText(*win, optionsTextRects[ 0 ],
- textStrings[ 0 ], &Plate18Font, 0, pal, 0, NULL));
+ checkAlloc(new CPlaqText(*win, optionsTextRects[0],
+ textStrings[0], &Plate18Font, 0, pal, 0, NULL));
for (int i = 1; i < numOptionsTexts; i++) {
- checkAlloc(new CPlaqText(*win, optionsTextRects[ i ],
- textStrings[ i ], &SmallFont, textPosLeft, pal, 0, NULL));
+ checkAlloc(new CPlaqText(*win, optionsTextRects[i],
+ textStrings[i], &SmallFont, textPosLeft, pal, 0, NULL));
}
win->setDecorations(optionsDecorations,
@@ -1001,7 +1001,7 @@ char stripAccel(char *t, const char *s) {
strcpy(t, s);
if ((underscore = strchr(t, '_')) != NULL) {
- accel = toupper(underscore[ 1 ]);
+ accel = toupper(underscore[1]);
strcpy(underscore, s + (underscore - t) + 1);
}
return accel;
@@ -1102,31 +1102,31 @@ int16 userDialog(const char *title, const char *msg, const char *bMsg1,
// button one
if (numBtns >= 1) {
- checkAlloc(t = new gCompButton(*udWin, messageButtonRects[ 0 ],
+ checkAlloc(t = new gCompButton(*udWin, messageButtonRects[0],
udDialogPushImag, numBtnImages, btnMsg1, pal, 10, cmdDialogQuit));
t->accel = k1;
}
// button two
if (numBtns >= 2) {
- checkAlloc(t = new gCompButton(*udWin, messageButtonRects[ 1 ],
+ checkAlloc(t = new gCompButton(*udWin, messageButtonRects[1],
udDialogPushImag, numBtnImages, btnMsg2, pal, 11, cmdDialogQuit));
t->accel = k2;
}
// button three
if (numBtns >= 3) {
- checkAlloc(t = new gCompButton(*udWin, messageButtonRects[ 2 ],
+ checkAlloc(t = new gCompButton(*udWin, messageButtonRects[2],
udDialogPushImag, numBtnImages, btnMsg3, pal, 12, cmdDialogQuit));
t->accel = k3;
}
// title for the box
- checkAlloc(new CPlaqText(*udWin, messageTextRects[ 0 ],
+ checkAlloc(new CPlaqText(*udWin, messageTextRects[0],
title, &Plate18Font, NULL, pal, 0, NULL));
// message for box
- checkAlloc(new CPlacardPanel(*udWin, messageTextRects[ 1 ],
+ checkAlloc(new CPlacardPanel(*udWin, messageTextRects[1],
msg, &Onyx10Font, NULL, pal, 0, NULL));
@@ -1221,31 +1221,31 @@ int16 userDialog(const char *title, const char *msg, const char *bMsg1,
// button one
if (numBtns >= 1) {
- checkAlloc(t = new gCompButton(*win, messageButtonRects[ 0 ],
+ checkAlloc(t = new gCompButton(*win, messageButtonRects[0],
dialogPushImag, numBtnImages, btnMsg1, pal, 10, cmdDialogQuit));
t->accelKey = k1;
}
// button two
if (numBtns >= 2) {
- checkAlloc(t = new gCompButton(*win, messageButtonRects[ 1 ],
+ checkAlloc(t = new gCompButton(*win, messageButtonRects[1],
dialogPushImag, numBtnImages, btnMsg2, pal, 11, cmdDialogQuit));
t->accelKey = k2;
}
// button three
if (numBtns >= 3) {
- checkAlloc(t = new gCompButton(*win, messageButtonRects[ 2 ],
+ checkAlloc(t = new gCompButton(*win, messageButtonRects[2],
dialogPushImag, numBtnImages, btnMsg3, pal, 12, cmdDialogQuit));
t->accelKey = k3;
}
// title for the box
- checkAlloc(new CPlaqText(*win, messageTextRects[ 0 ],
+ checkAlloc(new CPlaqText(*win, messageTextRects[0],
title, &Plate18Font, NULL, pal, 0, NULL));
// message for box
- checkAlloc(new CPlacardPanel(*win, messageTextRects[ 1 ],
+ checkAlloc(new CPlacardPanel(*win, messageTextRects[1],
msg, &Onyx10Font, NULL, pal, 0, NULL));
win->setDecorations(messageDecorations,
@@ -1321,11 +1321,11 @@ void CPlacardWindow::positionText(
for (i = 0; i < titleCount; i++, yPos += fontHeight) {
if (yPos < maxY) {
- titlePos[ i ].y = yPos;
- titlePos[ i ].x =
+ titlePos[i].y = yPos;
+ titlePos[i].x =
textArea.x +
((textArea.width -
- TextWidth(textFont, titleStrings[ i ], -1, 0))
+ TextWidth(textFont, titleStrings[i], -1, 0))
>> 1);
} else titleCount = i;
}
@@ -1340,7 +1340,7 @@ int16 CPlacardWindow:: SplitString(
int16 count;
for (count = 0; count < maxStrings;) {
- textStart[ count++ ] = text;
+ textStart[count++] = text;
if ((text = strchr(text, delimiter)) == NULL) break;
*text++ = '\0';
}
@@ -1389,7 +1389,7 @@ void CPlacardWindow::drawClipped(
rect.height = extent.height;
for (i = 0; i < titleCount; i++) {
- Point16 textPos = origin + titlePos[ i ];
+ Point16 textPos = origin + titlePos[i];
writePlaqTextPos(port,
textPos,
@@ -1397,7 +1397,7 @@ void CPlacardWindow::drawClipped(
0,
textPal,
FALSE,
- titleStrings[ i ]);
+ titleStrings[i]);
}
}
@@ -1432,11 +1432,11 @@ void CPlacardPanel::positionText(const char *windowText, const Rect16 &textArea)
for (i = 0; i < titleCount; i++, yPos += fontHeight) {
if (yPos < maxY) {
- titlePos[ i ].y = yPos;
- titlePos[ i ].x =
+ titlePos[i].y = yPos;
+ titlePos[i].x =
textArea.x +
((textArea.width -
- TextWidth(buttonFont, titleStrings[ i ], -1, 0))
+ TextWidth(buttonFont, titleStrings[i], -1, 0))
>> 1);
} else titleCount = i;
}
@@ -1451,7 +1451,7 @@ int16 CPlacardPanel:: SplitString(
int16 count;
for (count = 0; count < maxStrings;) {
- textStart[ count++ ] = text;
+ textStart[count++] = text;
if ((text = strchr(text, delimiter)) == NULL) break;
*text++ = '\0';
}
@@ -1480,7 +1480,7 @@ void CPlacardPanel::drawClipped(
rect.height = extent.height;
for (i = 0; i < titleCount; i++) {
- Point16 textPos = origin + titlePos[ i ];
+ Point16 textPos = origin + titlePos[i];
writePlaqTextPos(port,
textPos,
@@ -1488,7 +1488,7 @@ void CPlacardPanel::drawClipped(
0,
textFacePal,
FALSE,
- titleStrings[ i ]);
+ titleStrings[i]);
}
}
@@ -1511,13 +1511,13 @@ void placardWindow(int8 type, char *text) {
145);
// decoration information
- WindowDecoration plaqDecWood[ 1 ] =
+ WindowDecoration plaqDecWood[1] =
{ { WindowDecoration(plaqRectWood, 0) } };
- WindowDecoration plaqDecStone[ 1 ] =
+ WindowDecoration plaqDecStone[1] =
{ { WindowDecoration(plaqRectStone, 1) } };
- WindowDecoration plaqDecBrass[ 2 ] =
+ WindowDecoration plaqDecBrass[2] =
{ { WindowDecoration(plaqRectBrass, 2) } };
// used to hold the coloration of the text for a give type
@@ -1796,7 +1796,7 @@ inline int16 quantizedVolume(uint16 trueVolume) {
APPFUNC(cmdCredits) {
if (ev.panel && isUserAction(ev) && ev.value) {
//reDrawScreen();
- openBook(resImports->reserved[ 0 ]);
+ openBook(resImports->reserved[0]);
}
}
diff --git a/engines/saga2/uidialog.h b/engines/saga2/uidialog.h
index 96406b84b0..db9f506ea6 100644
--- a/engines/saga2/uidialog.h
+++ b/engines/saga2/uidialog.h
@@ -83,9 +83,9 @@ private:
};
int16 titleCount;
- Point16 titlePos[ maxLines ];
- char *titleStrings[ maxLines ];
- char titleBuf[ maxText ];
+ Point16 titlePos[maxLines];
+ char *titleStrings[maxLines];
+ char titleBuf[maxText];
textPallete textPal;
gFont *textFont;
@@ -124,9 +124,9 @@ class CPlacardPanel : public CPlaqText {
};
int16 titleCount;
- Point16 titlePos[ maxLines ];
- char *titleStrings[ maxLines ];
- char titleBuf[ maxText ];
+ Point16 titlePos[maxLines];
+ char *titleStrings[maxLines];
+ char titleBuf[maxText];
void positionText(const char *windowText, const Rect16 &textArea);
diff --git a/engines/saga2/videobox.cpp b/engines/saga2/videobox.cpp
index fd4889029e..0a73e66c9d 100644
--- a/engines/saga2/videobox.cpp
+++ b/engines/saga2/videobox.cpp
@@ -41,12 +41,12 @@ CVideoBox::CVideoBox(const Rect16 &box,
uint16 ident,
AppFunc *cmd) : ModalWindow(box, ident, cmd) {
// set the size of the window panes
- vidPanRects[ 0 ] = Rect16(x, y, xBrushSize, yBrushSize);
- vidPanRects[ 1 ] = Rect16(x, y + yBrushSize, xBrushSize, yBrushSize);
+ vidPanRects[0] = Rect16(x, y, xBrushSize, yBrushSize);
+ vidPanRects[1] = Rect16(x, y + yBrushSize, xBrushSize, yBrushSize);
// options dialog window decorations
- vidDec[ 0 ].set(vidPanRects[ 0 ], vidPan1ResID);
- vidDec[ 1 ].set(vidPanRects[ 1 ], vidPan2ResID);
+ vidDec[0].set(vidPanRects[0], vidPan1ResID);
+ vidDec[1].set(vidPanRects[1], vidPan2ResID);
// null out the decRes pointer
decRes = NULL;
diff --git a/engines/saga2/videobox.h b/engines/saga2/videobox.h
index 36e1fab394..207875d74e 100644
--- a/engines/saga2/videobox.h
+++ b/engines/saga2/videobox.h
@@ -70,11 +70,11 @@ public:
Rect16 vidBoxRect;
// rect for the window panes
- Rect16 vidPanRects[ numBrushes ];
+ Rect16 vidPanRects[numBrushes];
public:
// decoration declarations
- WindowDecoration vidDec[ numBrushes ];
+ WindowDecoration vidDec[numBrushes];
protected:
diff --git a/engines/saga2/vpal.h b/engines/saga2/vpal.h
index 095d7091d7..f61f9d1777 100644
--- a/engines/saga2/vpal.h
+++ b/engines/saga2/vpal.h
@@ -42,7 +42,7 @@ struct gPaletteEntry {
// An entire palette of 256 colors
struct gPalette {
- gPaletteEntry entry[ 256 ];
+ gPaletteEntry entry[256];
};
/* ===================================================================== *
diff --git a/engines/saga2/vwdraw.cpp b/engines/saga2/vwdraw.cpp
index 2792e53dee..e6c426af95 100644
--- a/engines/saga2/vwdraw.cpp
+++ b/engines/saga2/vwdraw.cpp
@@ -295,9 +295,9 @@ void gDisplayPort::line(int16 x1, int16 y1, int16 x2, int16 y2) {
}
if (drawMode == drawModeComplement) {
- svgaWriteAddr[ offset ]
- = svgaReadAddr[ offset ] ^ fgPen;
- } else svgaWriteAddr[ offset ] = fgPen;
+ svgaWriteAddr[offset]
+ = svgaReadAddr[offset] ^ fgPen;
+ } else svgaWriteAddr[offset] = fgPen;
if (errTerm >= 0) {
y1 += yDir;
@@ -329,9 +329,9 @@ void gDisplayPort::line(int16 x1, int16 y1, int16 x2, int16 y2) {
}
if (drawMode == drawModeComplement) {
- svgaWriteAddr[ offset ]
- = svgaReadAddr[ offset ] ^ fgPen;
- } else svgaWriteAddr[ offset ] = fgPen;
+ svgaWriteAddr[offset]
+ = svgaReadAddr[offset] ^ fgPen;
+ } else svgaWriteAddr[offset] = fgPen;
if (errTerm >= 0) {
x1 += xDir;
@@ -370,9 +370,9 @@ void gDisplayPort::line(int16 x1, int16 y1, int16 x2, int16 y2) {
for (i = xAbs + 1; i > 0; i--) {
if (drawMode == drawModeComplement) {
- svgaWriteAddr[ offset ]
- = svgaReadAddr[ offset ] ^ fgPen;
- } else svgaWriteAddr[ offset ] = fgPen;
+ svgaWriteAddr[offset]
+ = svgaReadAddr[offset] ^ fgPen;
+ } else svgaWriteAddr[offset] = fgPen;
if (errTerm >= 0) {
y1 += yDir;
@@ -401,9 +401,9 @@ void gDisplayPort::line(int16 x1, int16 y1, int16 x2, int16 y2) {
for (i = yAbs + 1; i > 0; i--) {
if (drawMode == drawModeComplement) {
- svgaWriteAddr[ offset ]
- = svgaReadAddr[ offset ] ^ fgPen;
- } else svgaWriteAddr[ offset ] = fgPen;
+ svgaWriteAddr[offset]
+ = svgaReadAddr[offset] ^ fgPen;
+ } else svgaWriteAddr[offset] = fgPen;
if (errTerm >= 0) {
x1 += xDir;
diff --git a/engines/saga2/vwpage.cpp b/engines/saga2/vwpage.cpp
index 07fab694db..8bdda45547 100644
--- a/engines/saga2/vwpage.cpp
+++ b/engines/saga2/vwpage.cpp
@@ -84,7 +84,7 @@ static bool displayEnabled(void) {
Globals
* ===================================================================== */
-vWDisplayPage displayPageList[ 2 ],
+vWDisplayPage displayPageList[2],
*displayPage,
protoPage;
@@ -150,17 +150,17 @@ void initDDGraphics(gDisplayPort &mainPort, CDDWindow *displayWin) {
displayPageCount = 1;
currentDisplayPage = 0;
- displayPageList[ 0 ] = displayPageList[ 1 ] = protoPage;
+ displayPageList[0] = displayPageList[1] = protoPage;
- displayPage = &displayPageList[ 0 ];
+ displayPage = &displayPageList[0];
drawPage = (vDisplayPage *)displayPage;
// Set the size of the display page in pixels
// gDisplaySize = Point16( mib->XResolution, mib->YResolution );
gDisplaySize = Point16(640, 480);
- displayPageList[ 0 ].size = gDisplaySize;
- displayPageList[ 1 ].size = gDisplaySize;
+ displayPageList[0].size = gDisplaySize;
+ displayPageList[1].size = gDisplaySize;
mainPort.setDisplayPage(drawPage); // set up display page
}
@@ -366,7 +366,7 @@ void vWDisplayPage::setPixel(int x, int y, uint8 color) {
}
- dstptr [(y * ddWindow->lPitch) + x ] = color;
+ dstptr [(y * ddWindow->lPitch) + x] = color;
ddWindow->UnlockBackBuffer(dstptr);
#endif
@@ -388,7 +388,7 @@ uint8 vWDisplayPage::getPixel(int x, int y) {
return 0;
}
- retValue = dstPtr[(y * ddWindow->lPitch) + x ];
+ retValue = dstPtr[(y * ddWindow->lPitch) + x];
ddWindow->UnlockBackBuffer(dstPtr);
return retValue;
Commit: 653998e4f1a4e304675a611cd31c0f784e91166a
https://github.com/scummvm/scummvm/commit/653998e4f1a4e304675a611cd31c0f784e91166a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:00+02:00
Commit Message:
SAGA2: Cleanup unneeded stubs
Changed paths:
engines/saga2/mainmap.cpp
engines/saga2/mainmap.h
engines/saga2/towerfta.cpp
engines/saga2/towerfta.h
diff --git a/engines/saga2/mainmap.cpp b/engines/saga2/mainmap.cpp
index 54f9d6c0da..876c2e0470 100644
--- a/engines/saga2/mainmap.cpp
+++ b/engines/saga2/mainmap.cpp
@@ -43,14 +43,6 @@ uint32 pickHeapSize(uint32 minHeap) {
void initCleanup() {
warning("STUB: initCleanup()");
}
-bool initErrorHandlers() {
- warning("STUB: initErrorHandlers()");
- return false;
-}
-void cleanupErrorHandlers() {
- warning("STUB: cleanupErrorHandlers()");
-}
-
bool initializeGame() {
if (setupGame())
return TRUE;
@@ -76,12 +68,4 @@ void cleanupPaletteData() {
warning("STUB: cleanupPaletteData()");
}
-void initBreakHandler() {
- warning("STUB: initBreakHandler()");
-}
-
-void cleanupBreakHandler() {
- warning("STUB: cleanupBreakHandler()");
-}
-
} // end of namespace Saga2
diff --git a/engines/saga2/mainmap.h b/engines/saga2/mainmap.h
index 5cfcdf13d4..b116d11266 100644
--- a/engines/saga2/mainmap.h
+++ b/engines/saga2/mainmap.h
@@ -73,8 +73,6 @@ uint32 pickHeapSize(uint32 minHeap);
// initialization & cleanup
void initCleanup(void);
-bool initErrorHandlers(void);
-void cleanupErrorHandlers(void);
bool initializeGame(void);
void shutdownGame(void);
@@ -90,9 +88,6 @@ void cleanupGame(void); // auto-cleanup function
bool setupGame(void);
void cleanupPalettes(void);
-void initBreakHandler(void);
-void cleanupBreakHandler(void);
-
} // end of namespace Saga2
#endif
diff --git a/engines/saga2/towerfta.cpp b/engines/saga2/towerfta.cpp
index 25b82b7f04..b990899237 100644
--- a/engines/saga2/towerfta.cpp
+++ b/engines/saga2/towerfta.cpp
@@ -53,8 +53,6 @@ TowerLayer tower[fullyInitialized] = {
{ errHandlersInitialized, &initErrorManagers, &termErrorManagers },
{ delayedErrInitialized, &initDelayedErrors, &termDelayedErrors },
{ activeErrInitialized, &initActiveErrors, &termActiveErrors },
- { errLoggersInitialized, &initErrorLoggers, &termErrorLoggers },
- { breakHandlerInitialized, &initCtlBreakTrap, &termCtlBreakTrap },
{ configTestInitialized, &initSystemConfig, &termTowerBase },
{ memoryInitialized, &initMemPool, &termMemPool },
{ introInitialized, &initPlayIntro, &termPlayOutro },
@@ -123,30 +121,6 @@ extern gPanelList *indivControls;
* ===================================================================== */
-// ------------------------------------------------------------------------
-
-INITIALIZER(initErrorLoggers) {
- initErrorHandlers();
- return TRUE;
-}
-
-TERMINATOR(termErrorLoggers) {
- cleanupErrorHandlers();
-}
-
-
-// ------------------------------------------------------------------------
-
-INITIALIZER(initCtlBreakTrap) {
- initBreakHandler();
- return TRUE;
-}
-
-TERMINATOR(termCtlBreakTrap) {
- cleanupBreakHandler();
-}
-
-
// ------------------------------------------------------------------------
INITIALIZER(initSystemConfig) {
diff --git a/engines/saga2/towerfta.h b/engines/saga2/towerfta.h
index 0d25d9b4ab..6b9b191ed6 100644
--- a/engines/saga2/towerfta.h
+++ b/engines/saga2/towerfta.h
@@ -31,12 +31,6 @@
namespace Saga2 {
-INITIALIZER(initErrorLoggers);
-TERMINATOR(termErrorLoggers);
-
-INITIALIZER(initCtlBreakTrap);
-TERMINATOR(termCtlBreakTrap);
-
INITIALIZER(initSystemConfig);
// uses null cleanup
Commit: 4520b3ffa38a951b0fcaea02f34061ef20f8c5c7
https://github.com/scummvm/scummvm/commit/4520b3ffa38a951b0fcaea02f34061ef20f8c5c7
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:00+02:00
Commit Message:
SAGA2: Fix assocList reading
Changed paths:
engines/saga2/tile.cpp
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 193e0d4933..4bd1105354 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -1425,6 +1425,7 @@ static void readMetaTile(hResContext *con, MetaTile &til) {
void initMaps(void) {
int16 i;
const int metaTileSize = 30;
+ const int assocSize = 2;
// Load all of the tile terrain banks
for (i = 0; i < maxBanks; i++) {
@@ -1481,12 +1482,13 @@ void initMaps(void) {
// If there is an association list, load it
if (tileRes->size(assocID + MKTAG(0, 0, 0, (uint8)i)) > 0) {
- mapData->assocList =
- (UWordPtr)LoadResource(tileRes,
- assocID + MKTAG(0, 0, 0, (uint8)i),
- "association list");
+ int assocCount = tileRes->size(assocID + MKTAG(0, 0, 0, (uint8)i)) / assocSize;
+ mapData->assocList = new uint16[assocCount];
if (mapData->assocList == nullptr)
error("Unable to load association list");
+
+ for (int k = 0; k < assocCount; ++k)
+ mapData->assocList[k] = tileRes->readU16LE();
} else
mapData->assocList = nullptr;
Commit: d6caa2199202051a0a2d678f7353b291aa07a12a
https://github.com/scummvm/scummvm/commit/d6caa2199202051a0a2d678f7353b291aa07a12a
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:01+02:00
Commit Message:
SAGA2: Fix activeItemData loading
Changed paths:
engines/saga2/tile.cpp
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 4bd1105354..660b4e4582 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -1425,6 +1425,7 @@ static void readMetaTile(hResContext *con, MetaTile &til) {
void initMaps(void) {
int16 i;
const int metaTileSize = 30;
+ const int tileRefSize = 4;
const int assocSize = 2;
// Load all of the tile terrain banks
@@ -1472,18 +1473,23 @@ void initMaps(void) {
// If there is tag data, load it
if (tileRes->size(tagDataID + MKTAG(0, 0, 0, (uint8)i)) > 0) {
- mapData->activeItemData = (TileRefPtr)LoadResource(tileRes,
- tagDataID + MKTAG(0, 0, 0, (uint8)i),
- "active item data");
+ int tileRefCount = tileRes->size(tagDataID + MKTAG(0, 0, 0, (uint8)i)) / tileRefSize;
+ mapData->activeItemData = new TileRef[tileRefCount]();
if (mapData->activeItemData == nullptr)
error("Unable to load active item data");
+
+ for (int k = 0; k < tileRefCount; ++k) {
+ mapData->activeItemData[k].tile = tileRes->readU16LE();
+ mapData->activeItemData[k].flags = tileRes->readByte();
+ mapData->activeItemData[k].tileHeight = tileRes->readByte();
+ }
} else
mapData->activeItemData = nullptr;
// If there is an association list, load it
if (tileRes->size(assocID + MKTAG(0, 0, 0, (uint8)i)) > 0) {
int assocCount = tileRes->size(assocID + MKTAG(0, 0, 0, (uint8)i)) / assocSize;
- mapData->assocList = new uint16[assocCount];
+ mapData->assocList = new uint16[assocCount]();
if (mapData->assocList == nullptr)
error("Unable to load association list");
@@ -1504,8 +1510,7 @@ void initMaps(void) {
mapData->activeItemList = nullptr;
// Compute the number of meta tiles in list
- mapData->metaCount = tileRes->size(metaID + MKTAG(0, 0, 0, (uint8)i))
- / sizeof(MetaTile); // 2 + 8 + 2 + 4 = 16
+ mapData->metaCount = metaTileCount;
// Compute the number of active items in list
mapData->activeCount = tileRes->size(tagID + MKTAG(0, 0, 0, (uint8)i))
@@ -1553,11 +1558,11 @@ void cleanupMaps(void) {
// If there is active item data, dump it
if (mapData->activeItemData != nullptr)
- free(mapData->activeItemData);
+ delete[] mapData->activeItemData;
// If there is an association list, dump it
if (mapData->assocList != nullptr)
- free(mapData->assocList);
+ delete[] mapData->assocList;
// If there is an active item list, dump it
if (mapData->activeItemList != nullptr)
Commit: 36d672189e374e4726a4d5c5bdb65e4b145985cc
https://github.com/scummvm/scummvm/commit/36d672189e374e4726a4d5c5bdb65e4b145985cc
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:01+02:00
Commit Message:
SAGA2: Fix global buffer overflow in terrain.cpp
Changed paths:
engines/saga2/objects.cpp
engines/saga2/sprite.cpp
engines/saga2/terrain.cpp
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 323bc7752e..f47ddb3282 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -2363,7 +2363,7 @@ GameWorld::GameWorld(int16 map) {
if (tileRes->seek(MKTAG('M', 'A', 'P', (char)map))) {
int16 mapSize; // Size of map in MetaTiles
- tileRes->read(&mapSize, sizeof(mapSize));
+ mapSize = tileRes->readU16LE();
size.u = (mapSize << platShift) << tileUVShift;
size.v = size.u;
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index 75d9f974b3..bf18196a26 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -583,24 +583,6 @@ void buildColorTable(
Load actor appearance
* ===================================================================== */
-#if DEBUG
-char *idname(long s) {
- static char t[8];
- char *p = (char *)&s;
-
- t[0] = *p++;
- t[1] = *p++;
- t[2] = *p++;
- if (*p > ' ') {
- t[3] = *p;
- t[4] = 0;
- } else {
- sprintf(&t[3], ":%d", *p);
- }
- return t;
-}
-#endif
-
void ActorAppearance::loadSpriteBanks(int16 banksNeeded) {
int16 bank;
diff --git a/engines/saga2/terrain.cpp b/engines/saga2/terrain.cpp
index a46cf3692d..eb668433d8 100644
--- a/engines/saga2/terrain.cpp
+++ b/engines/saga2/terrain.cpp
@@ -456,8 +456,8 @@ uint32 lineTerrain(
subTileMask_ = 0;
}
- subTileMask_ |= (uMask[curSubTile.u & subTileMask_] &
- vMask[curSubTile.v & subTileMask_]);
+ subTileMask_ |= (uMask[curSubTile.u & subTileMask] &
+ vMask[curSubTile.v & subTileMask]);
#if DEBUG && VISUAL2
tempPoint.u = curSubTile.u << tileSubShift;
tempPoint.v = curSubTile.v << tileSubShift;
@@ -487,8 +487,8 @@ uint32 lineTerrain(
subTileMask_ = 0;
}
- subTileMask_ |= (uMask[curSubTile.u & subTileMask_] &
- vMask[curSubTile.v & subTileMask_]);
+ subTileMask_ |= (uMask[curSubTile.u & subTileMask] &
+ vMask[curSubTile.v & subTileMask]);
#if DEBUG && VISUAL2
tempPoint.u = curSubTile.u << tileSubShift;
tempPoint.v = curSubTile.v << tileSubShift;
@@ -525,8 +525,8 @@ uint32 lineTerrain(
subTileMask_ = 0;
}
- subTileMask_ |= (uMask[curSubTile.u & subTileMask_] &
- vMask[curSubTile.v & subTileMask_]);
+ subTileMask_ |= (uMask[curSubTile.u & subTileMask] &
+ vMask[curSubTile.v & subTileMask]);
#if DEBUG && VISUAL2
tempPoint.u = curSubTile.u << tileSubShift;
@@ -557,8 +557,8 @@ uint32 lineTerrain(
subTileMask_ = 0;
}
- subTileMask_ |= (uMask[curSubTile.u & subTileMask_] &
- vMask[curSubTile.v & subTileMask_]);
+ subTileMask_ |= (uMask[curSubTile.u & subTileMask] &
+ vMask[curSubTile.v & subTileMask]);
#if DEBUG && VISUAL2
tempPoint.u = curSubTile.u << tileSubShift;
tempPoint.v = curSubTile.v << tileSubShift;
Commit: 201743952caf6421d7b7bd6140009660be8c8dff
https://github.com/scummvm/scummvm/commit/201743952caf6421d7b7bd6140009660be8c8dff
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:01+02:00
Commit Message:
JANITORIAL: Code formatting
Changed paths:
engines/saga2/patrol.cpp
diff --git a/engines/saga2/patrol.cpp b/engines/saga2/patrol.cpp
index 5cff6038ed..d454a03700 100644
--- a/engines/saga2/patrol.cpp
+++ b/engines/saga2/patrol.cpp
@@ -231,7 +231,7 @@ const TilePoint &PatrolRouteIterator::operator * (void) const {
//-----------------------------------------------------------------------
// Iterate
-const PatrolRouteIterator &PatrolRouteIterator::operator ++ (void) {
+const PatrolRouteIterator &PatrolRouteIterator::operator++ (void) {
const PatrolRoute &route = patrolRouteList[mapNum][routeNo];
if (vertexNo >= 0 & vertexNo < route.vertices()) {
@@ -267,15 +267,12 @@ void initPatrolRoutes(void) {
hResContext *patrolRouteRes;
// Get patrol route resource context
- patrolRouteRes = auxResFile->newContext(
- MKTAG('P', 'T', 'R', 'L'),
- "patrol route resource");
+ patrolRouteRes = auxResFile->newContext(MKTAG('P', 'T', 'R', 'L'), "patrol route resource");
if (patrolRouteRes == nullptr || !patrolRouteRes->_valid)
error("Error accessing patrol route resource group.");
// Allocate the patrol route list array
- patrolRouteList =
- new PatrolRouteList[worldCount];
+ patrolRouteList = new PatrolRouteList[worldCount];
if (patrolRouteList == nullptr)
error("Unable to allocate the patrol route list");
@@ -292,13 +289,8 @@ void initPatrolRoutes(void) {
patrolRouteList[i].offsetArray = nullptr;
// Load this worlds's patrol routes
- if (patrolRouteRes->size(
- MKTAG('R', 'T', 'E', i)) > 0) {
- patrolRouteData[i] =
- (PatrolRouteData *)LoadResource(
- patrolRouteRes,
- MKTAG('R', 'T', 'E', i),
- "patrol route data");
+ if (patrolRouteRes->size(MKTAG('R', 'T', 'E', i)) > 0) {
+ patrolRouteData[i] = (PatrolRouteData *)LoadResource(patrolRouteRes, MKTAG('R', 'T', 'E', i), "patrol route data");
if (patrolRouteData[i] == nullptr)
error("Unable to load the patrol route data");
@@ -317,7 +309,7 @@ void initPatrolRoutes(void) {
// Cleanup the patrol routes
void cleanupPatrolRoutes(void) {
- int16 i;
+ int16 i;
// Cleanup the patrol route list
for (i = 0; i < worldCount; i++) {
Commit: 9642a17a0bfe6b0079ef613f048f01574ea07990
https://github.com/scummvm/scummvm/commit/9642a17a0bfe6b0079ef613f048f01574ea07990
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:01+02:00
Commit Message:
SAGA2: Fix drawPage initialization
Changed paths:
engines/saga2/towerfta.cpp
engines/saga2/towerfta.h
engines/saga2/vdraw.h
diff --git a/engines/saga2/towerfta.cpp b/engines/saga2/towerfta.cpp
index b990899237..537f86eca3 100644
--- a/engines/saga2/towerfta.cpp
+++ b/engines/saga2/towerfta.cpp
@@ -318,6 +318,8 @@ TERMINATOR(termMousePointer) {
INITIALIZER(initDisplay) {
mainPort.setColor(0); // fill screen with color
+ drawPage = &mainPort.protoPage;
+ mainPort.setDisplayPage(drawPage);
//lightsOut();
//mainPort.fillRect( Rect16( 0, 0, screenWidth, screenHeight ) );
@@ -448,7 +450,8 @@ TERMINATOR(termDynamicGameData) {
// ------------------------------------------------------------------------
INITIALIZER(initGameMode) {
- GameMode::SetStack(&PlayMode, &TileMode, End_List);
+ GameMode *gameModes[] = {&PlayMode, &TileMode};
+ GameMode::SetStack(gameModes, 2);
if (GameMode::newmodeFlag)
GameMode::update();
return TRUE;
diff --git a/engines/saga2/towerfta.h b/engines/saga2/towerfta.h
index 6b9b191ed6..a17e026d36 100644
--- a/engines/saga2/towerfta.h
+++ b/engines/saga2/towerfta.h
@@ -37,9 +37,6 @@ INITIALIZER(initSystemConfig);
INITIALIZER(initMemPool);
TERMINATOR(termMemPool);
-INITIALIZER(initGraphicsSystem);
-TERMINATOR(termGraphicsSystem);
-
INITIALIZER(initPlayIntro);
TERMINATOR(termPlayOutro);
diff --git a/engines/saga2/vdraw.h b/engines/saga2/vdraw.h
index 5dd5e2d4c2..94f00e1170 100644
--- a/engines/saga2/vdraw.h
+++ b/engines/saga2/vdraw.h
@@ -35,6 +35,7 @@ class gDisplayPort : public gPort {
public:
virtual ~gDisplayPort() {}
+ vDisplayPage protoPage;
vDisplayPage *displayPage; // page to draw to
virtual void setDisplayPage(vDisplayPage *dPage) {
Commit: 943df6181e981cedae455de93c610fa4d075b090
https://github.com/scummvm/scummvm/commit/943df6181e981cedae455de93c610fa4d075b090
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:01+02:00
Commit Message:
SAGA2: Fix mouseimg alloc-dealloc problem
Changed paths:
engines/saga2/mouseimg.cpp
diff --git a/engines/saga2/mouseimg.cpp b/engines/saga2/mouseimg.cpp
index 5b26980a48..3cd04578bc 100644
--- a/engines/saga2/mouseimg.cpp
+++ b/engines/saga2/mouseimg.cpp
@@ -193,10 +193,10 @@ void createStackedImage(
// Dispose of an image created with createStackedImage
inline void disposeStackedImage(gPixelMap *image) {
- assert(image->data != NULL);
+ assert(image->data != nullptr);
- delete [] image->data;
- image->data = NULL;
+ free(image->data);
+ image->data = nullptr;
}
//-----------------------------------------------------------------------
Commit: d57f807e5514f7288d7221447ce8cfca7707e1e7
https://github.com/scummvm/scummvm/commit/d57f807e5514f7288d7221447ce8cfca7707e1e7
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:01+02:00
Commit Message:
SAGA2: Insert osystem draw functions
Changed paths:
engines/saga2/blitters.cpp
engines/saga2/vpal.cpp
engines/saga2/vwpage.cpp
diff --git a/engines/saga2/blitters.cpp b/engines/saga2/blitters.cpp
index 79ef5f3c33..e8de0570d9 100644
--- a/engines/saga2/blitters.cpp
+++ b/engines/saga2/blitters.cpp
@@ -25,6 +25,7 @@
*/
#include "common/debug.h"
+#include "graphics/surface.h"
#include "saga2/std.h"
#include "saga2/gdraw.h"
@@ -291,6 +292,16 @@ void drawTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData) {
int rectX2 = MIN<int>(drawPoint.x + SAGA_ISOTILE_WIDTH, map->size.x);
int rectY2 = lowBound;
debugC(3, kDebugTiles, "Rect = (%d,%d,%d,%d)", rectX, rectY, rectX2, rectY2);
+
+ // FIXME: Debug purposes-code for displaying things on the screen
+ // updateScreen should not be called here
+ warning("FIXME: drawTile");
+ Graphics::Surface sur;
+ sur.create(map->size.x, map->size.y, Graphics::PixelFormat::createFormatCLUT8());
+ sur.setPixels(map->data);
+ //sur.debugPrint();
+ g_system->copyRectToScreen(sur.getPixels(), sur.pitch, 0, 0, sur.w, sur.h);
+ g_system->updateScreen();
//g_vm->_render->addDirtyRect(Common::Rect(rectX, rectY, rectX2, rectY2));
}
diff --git a/engines/saga2/vpal.cpp b/engines/saga2/vpal.cpp
index 809022bac9..45b2dd6a25 100644
--- a/engines/saga2/vpal.cpp
+++ b/engines/saga2/vpal.cpp
@@ -26,6 +26,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+#include "common/debug.h"
#include "graphics/palette.h"
#include "saga2/std.h"
@@ -176,7 +177,7 @@ void cleanupPalettes(void) {
// Begin fade up/down
void beginFade(gPalettePtr newPalette, int32 fadeDuration) {
- startTime = gameTime;
+ startTime = g_system->getMillis();
totalTime = fadeDuration;
// Save the current palette for interpolation
@@ -192,7 +193,7 @@ void beginFade(gPalettePtr newPalette, int32 fadeDuration) {
bool updatePalette() {
int32 elapsedTime;
- elapsedTime = gameTime - startTime;
+ elapsedTime = g_system->getMillis() - startTime;
if (totalTime == 0)
return false;
@@ -205,7 +206,7 @@ bool updatePalette() {
} else {
gPalette tempPalette;
- WriteStatusF(1, "Fade: %d/%d", elapsedTime, totalTime);
+ debug(1, "Fade: %d/%d", elapsedTime, totalTime);
createPalette(
&tempPalette,
@@ -215,7 +216,7 @@ bool updatePalette() {
totalTime);
if (memcmp(&tempPalette, ¤tPalette, sizeof(gPalette)) != 0) {
- WriteStatusF(2, "Fade:*%d/%d", elapsedTime, totalTime);
+ debug(2, "Fade:*%d/%d", elapsedTime, totalTime);
memcpy(¤tPalette, &tempPalette, sizeof(gPalette));
assertCurrentPalette();
diff --git a/engines/saga2/vwpage.cpp b/engines/saga2/vwpage.cpp
index 8bdda45547..f9a415f7f0 100644
--- a/engines/saga2/vwpage.cpp
+++ b/engines/saga2/vwpage.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#include "common/rect.h"
+#include "graphics/surface.h"
#include "saga2/std.h"
#include "saga2/vdraw.h"
#include "saga2/vwpage.h"
@@ -470,62 +472,26 @@ void vWDisplayPage::vLine(int16 x, int16 y, int16 height, uint8 color) {
// -- we'll want to use this when we figure out why bltDDRect doesnt work here
//#define USE_RECT
-#ifndef USE_RECT
-
-static bool easyblit = TRUE;
-
-void setBlitter(bool isEasy) {
- easyblit = isEasy;
-}
-
-
-void vWDisplayPage::writePixels(Rect16 &r, uint8 *pixPtr, uint16 pixMod) {
-#if 0
- if (easyblit) {
- uint8 *dstPtr;
-
- if (!displayEnabled()) //ddWindow || !ddWindow->bIsActive )
- return;
-
- dstPtr = (uint8 *)ddWindow->LockBackBuffer(NULL);
- if (!dstPtr) {
- gError::warn("Failed buffer lock");
- return;
- }
-
- _BltPixels(pixPtr, pixMod,
- dstPtr + (r.y * ddWindow->lPitch) + r.x, ddWindow->lPitch,
- r.width, r.height);
-
- ddWindow->UnlockBackBuffer(dstPtr);
- } else
- BltDDRect(r, pixPtr, FALSE, pixMod, TRUE);
-#endif
- warning("STUB: writePixels");
-}
-#else // use rect
void vWDisplayPage::writePixels(Rect16 &r, uint8 *pixPtr, uint16 pixMod) {
- RECT wRect;
- uint8 *dstPtr;
-
- if (!displayEnabled()) //ddWindow || !ddWindow->bIsActive )
- return;
+ Common::Rect wRect;
wRect.left = r.x;
wRect.top = r.y;
wRect.right = r.x + r.width;
wRect.bottom = r.y + r.height;
- dstPtr = (uint8 *)ddWindow->LockBackBuffer(&wRect);
- if (!dstPtr) {
- gError::warn("Failed buffer lock");
- return;
- }
-
- _BltPixels(pixPtr, pixMod, dstPtr, ddWindow->lPitch, r.width, r.height);
- ddWindow->UnlockBackBuffer(dstPtr);
+ // FIXME: Debug purposes-code for displaying things on the screen
+ // updateScreen should not be called here
+ warning("FIXME: writePixels");
+ Graphics::Surface sur;
+ sur.create(r.width, r.height, Graphics::PixelFormat::createFormatCLUT8());
+ sur.setPixels(pixPtr);
+ //sur.debugPrint();
+ g_system->copyRectToScreen(sur.getPixels(), sur.pitch, r.x, r.y, sur.w, sur.h);
+ g_system->updateScreen();
+
+ //_BltPixels(pixPtr, pixMod, dstPtr, ddWindow->lPitch, r.width, r.height);
}
-#endif
#ifndef USE_RECT
void vWDisplayPage::writeTransPixels(Rect16 &r, uint8 *pixPtr, uint16 pixMod) {
Commit: cb9004e2a048ed1923d38130bccdee4156603ef9
https://github.com/scummvm/scummvm/commit/cb9004e2a048ed1923d38130bccdee4156603ef9
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:01+02:00
Commit Message:
SAGA2: Add debug channel for palettes
Changed paths:
engines/saga2/detection.cpp
engines/saga2/saga2.h
engines/saga2/vpal.cpp
diff --git a/engines/saga2/detection.cpp b/engines/saga2/detection.cpp
index 14b5ffacec..740f0dd185 100644
--- a/engines/saga2/detection.cpp
+++ b/engines/saga2/detection.cpp
@@ -32,7 +32,8 @@ static const DebugChannelDef debugFlagList[] = {
{Saga2::kDebugScripts, "scripts", "Debug the scripts"},
{Saga2::kDebugEventLoop, "eventloop", "Debug the event loop"},
{Saga2::kDebugInit, "init", "Debug the initialization process"},
- {Saga2::kDebugTiles, "tiles", "Debug the tiles"},
+ {Saga2::kDebugTiles, "tiles", "Debug the tiles"},
+ {Saga2::kDebugPalettes, "palettes", "Debug the palettes"},
DEBUG_CHANNEL_END
};
diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h
index 862df22831..a4b77e2c52 100644
--- a/engines/saga2/saga2.h
+++ b/engines/saga2/saga2.h
@@ -42,7 +42,8 @@ enum {
kDebugScripts = 1 << 2,
kDebugEventLoop = 1 << 3,
kDebugInit = 1 << 4,
- kDebugTiles = 1 << 5
+ kDebugTiles = 1 << 5,
+ kDebugPalettes = 1 << 6
};
#define TICKSPERSECOND (728L/10L)
diff --git a/engines/saga2/vpal.cpp b/engines/saga2/vpal.cpp
index 45b2dd6a25..92e93fa713 100644
--- a/engines/saga2/vpal.cpp
+++ b/engines/saga2/vpal.cpp
@@ -206,7 +206,7 @@ bool updatePalette() {
} else {
gPalette tempPalette;
- debug(1, "Fade: %d/%d", elapsedTime, totalTime);
+ debugC(2, kDebugPalettes, "Fade: %d/%d", elapsedTime, totalTime);
createPalette(
&tempPalette,
@@ -216,7 +216,7 @@ bool updatePalette() {
totalTime);
if (memcmp(&tempPalette, ¤tPalette, sizeof(gPalette)) != 0) {
- debug(2, "Fade:*%d/%d", elapsedTime, totalTime);
+ debugC(2, kDebugPalettes, "Fade:*%d/%d", elapsedTime, totalTime);
memcpy(¤tPalette, &tempPalette, sizeof(gPalette));
assertCurrentPalette();
Commit: f53042a224a0a0dd0334bc305bb9e44d698f1cb4
https://github.com/scummvm/scummvm/commit/f53042a224a0a0dd0334bc305bb9e44d698f1cb4
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:01+02:00
Commit Message:
SAGA2: Stub checkRestartGame
Changed paths:
engines/saga2/loadsave.cpp
engines/saga2/loadsave.h
engines/saga2/main.cpp
diff --git a/engines/saga2/loadsave.cpp b/engines/saga2/loadsave.cpp
index 3eee9b5f5e..dbb6a823b1 100644
--- a/engines/saga2/loadsave.cpp
+++ b/engines/saga2/loadsave.cpp
@@ -492,25 +492,16 @@ void cleanupGameState(void) {
#include <time.h>
#endif
-void checkRestartGame(char *exeName) {
-#ifdef DEBUG_FILETIME
- int32 d1, d2;
- char datebuf[64];
-#endif
+void checkRestartGame(const char *exeName) {
+#if 0
char saveRestart[260];
getSaveFileName(999, saveRestart);
-#ifdef DEBUG_FILETIME
- d1 = getFileDate(exeName);
- d2 = getFileDate(saveRestart);
- strftime(datebuf, 64, "%c", localtime(&d1));
- WriteStatusF(12, "Date:%s File %s", datebuf, exeName);
- strftime(datebuf, 64, "%c", localtime(&d2));
- WriteStatusF(13, "Date:%s File %s", datebuf, saveRestart);
-#endif
if (!fileExists(saveRestart) ||
(getFileDate(exeName) > getFileDate(saveRestart)))
saveGameState(999, saveRestart);
+#endif
+ warning("STUB: checkRestartGame()");
}
diff --git a/engines/saga2/loadsave.h b/engines/saga2/loadsave.h
index e8a1e4b222..4e52fd2297 100644
--- a/engines/saga2/loadsave.h
+++ b/engines/saga2/loadsave.h
@@ -41,7 +41,7 @@ void loadSavedGameState(int16 saveNo);
// Cleanup the game state
void cleanupGameState(void);
-void checkRestartGame(char *exeName);
+void checkRestartGame(const char *exeName);
void loadRestartGame(void);
void getSaveFileName(int16 saveNo, char *fileName);
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index aad26514bc..022afd3e82 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -185,7 +185,7 @@ void lightsOut(void);
void cleanupGame(void); // auto-cleanup function
void RShowMem(void);
void parseCommandLine(int argc, char *argv[]);
-char *getExeFromCommandLine(int argc, char *argv[]);
+const char *getExeFromCommandLine(int argc, char *argv[]);
void WriteStatusF2(int16 line, const char *msg, ...);
bool initUserDialog(void);
void cleanupUserDialog(void);
@@ -241,7 +241,7 @@ void main_saga2() {
void updateActiveRegions(void);
static void mainLoop(bool &cleanExit, int argc, char *argv[]) {
- char *exeFile = getExeFromCommandLine(argc, argv);
+ const char *exeFile = getExeFromCommandLine(argc, argv);
if (displayEnabled())
displayUpdate();
checkRestartGame(exeFile);
@@ -441,7 +441,9 @@ void SystemEventLoop(void) {
// ------------------------------------------------------------------------
// Determines the EXE file executed from command line info
-char *getExeFromCommandLine(int argc, char *argv[]) {
+const char *getExeFromCommandLine(int argc, char *argv[]) {
+ if (argv == nullptr)
+ return "scummvm";
return argv[0];
}
Commit: 26cd3528723a4275ba11ecd8e8d1ac0c5b04ac30
https://github.com/scummvm/scummvm/commit/26cd3528723a4275ba11ecd8e8d1ac0c5b04ac30
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:02+02:00
Commit Message:
SAGA2: Fix memory allocation in floating.cpp
Changed paths:
engines/saga2/floating.cpp
engines/saga2/playmode.cpp
diff --git a/engines/saga2/floating.cpp b/engines/saga2/floating.cpp
index 70ff9953e4..b73249e919 100644
--- a/engines/saga2/floating.cpp
+++ b/engines/saga2/floating.cpp
@@ -540,7 +540,9 @@ void updateWindowSection(const Rect16 &r) {
Point16 animOffset(tileRect.x - fineScroll.x, tileRect.y);
// Detects that program is shutting down and aborts the blit
- if (tileDrawMap.data == NULL) return;
+ if (tileDrawMap.data == nullptr)
+ return;
+
if (!checkTileAreaPort()) return;
// Since the floating windows can be dragged partly offscreen
@@ -552,8 +554,10 @@ void updateWindowSection(const Rect16 &r) {
tempMap.size.x = clip.width;
tempMap.size.y = clip.height;
- tempMap.data = (uint8 *)RNewClearPtr(tempMap.bytes(), NULL, "window section");
- if (tempMap.data == NULL) return;
+ tempMap.data = new uint8[tempMap.bytes()]();
+ if (tempMap.data == nullptr)
+ return;
+
tempPort.setMap(&tempMap);
tempPort.setMode(drawModeReplace);
@@ -611,7 +615,7 @@ void updateWindowSection(const Rect16 &r) {
clip.x, clip.y, clip.width, clip.height);
pointer.show(mainPort, clip);
mainPort.setMode(drawModeMatte);
- RDisposePtr(tempMap.data);
+ delete[] tempMap.data;
}
void drawFloatingWindows(gPort &port, const Point16 &offset, const Rect16 &clip) {
diff --git a/engines/saga2/playmode.cpp b/engines/saga2/playmode.cpp
index 7cebbd4add..d1eb3d7e8f 100644
--- a/engines/saga2/playmode.cpp
+++ b/engines/saga2/playmode.cpp
@@ -155,7 +155,7 @@ bool checkTileAreaPort(void) {
// Allocate back buffer for tile rendering
tileDrawMap.size.x = (tileRect.width + tileWidth - 1) & ~tileDXMask;
tileDrawMap.size.y = (tileRect.height + tileWidth - 1) & ~tileDXMask;
- tileDrawMap.data = new uint8[tileDrawMap.bytes()];
+ tileDrawMap.data = new uint8[tileDrawMap.bytes()]();
}
return tileDrawMap.data != nullptr;
Commit: e87ff7034477a54fc87b5047f7bf552e4f38fc99
https://github.com/scummvm/scummvm/commit/e87ff7034477a54fc87b5047f7bf552e4f38fc99
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:02+02:00
Commit Message:
SAGA2: Fix font data reading in gtext.cpp
Changed paths:
engines/saga2/gtext.cpp
diff --git a/engines/saga2/gtext.cpp b/engines/saga2/gtext.cpp
index 888b36bd0f..82eaf6d2b6 100644
--- a/engines/saga2/gtext.cpp
+++ b/engines/saga2/gtext.cpp
@@ -83,7 +83,8 @@ void DrawChar(gFont *font, int drawchar, int xpos, uint8 *baseline, uint8 color,
*/
font_mod = font->rowMod;
- src = font->fontdata + font->charXOffset[drawchar];
+ uint16 offset = font->charXOffset[drawchar];
+ src = &font->fontdata[offset];
dst = baseline + xpos;
for (w = font->charWidth[drawchar]; w > 0; w -= 8) {
@@ -292,7 +293,8 @@ void DrawChar3x3Outline(gFont *font, int drawchar, int xpos, uint8 *baseline,
unsigned short txt1, txt2, txt3;
// point to the first byte of the first scanline of the source char
- chardata = (uint8 *)(font + 1) + font->charXOffset[drawchar];
+ uint16 offset = font->charXOffset[drawchar];
+ chardata = &font->fontdata[offset];
// get the width of the character in pixels
charwidth = font->charWidth[drawchar];
@@ -352,7 +354,8 @@ void DrawChar5x5Outline(gFont *font, int drawchar, int xpos, uint8 *baseline,
unsigned short txt[5];
// point to the first byte of the first scanline of the source char
- chardata = (uint8 *)(font + 1) + font->charXOffset[drawchar];
+ uint16 offset = font->charXOffset[drawchar];
+ chardata = &font->fontdata[offset];
// get the width of the character in pixels
charwidth = font->charWidth[drawchar];
Commit: 1c157566a0c7c395641bfb6d237df55af643decf
https://github.com/scummvm/scummvm/commit/1c157566a0c7c395641bfb6d237df55af643decf
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:02+02:00
Commit Message:
SAGA2: Fix textImage.data freeing in mouseimg.cpp
Changed paths:
engines/saga2/mouseimg.cpp
diff --git a/engines/saga2/mouseimg.cpp b/engines/saga2/mouseimg.cpp
index 3cd04578bc..a46b528022 100644
--- a/engines/saga2/mouseimg.cpp
+++ b/engines/saga2/mouseimg.cpp
@@ -278,9 +278,9 @@ inline void disposeText(void) {
// Free the memory previously allocated to hold the text image
// bitmap
- if (textImage.data != NULL) {
- delete [] textImage.data;
- textImage.data = NULL;
+ if (textImage.data != nullptr) {
+ free(textImage.data);
+ textImage.data = nullptr;
}
textImage.size.x = textImage.size.y = 0;
}
Commit: 8d862027ba7dad07744ef5bbe3de015f2e15d1c6
https://github.com/scummvm/scummvm/commit/8d862027ba7dad07744ef5bbe3de015f2e15d1c6
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:02+02:00
Commit Message:
SAGA2: Fix warnings in mouseimg.cpp
Changed paths:
engines/saga2/mouseimg.cpp
diff --git a/engines/saga2/mouseimg.cpp b/engines/saga2/mouseimg.cpp
index a46b528022..1a4032fbe8 100644
--- a/engines/saga2/mouseimg.cpp
+++ b/engines/saga2/mouseimg.cpp
@@ -68,8 +68,8 @@ static Point16 mouseImageOffset; // Hotspot on mouse image
static gPixelMap *mouseImage = mouseCursors[kMouseArrowImage]; // Current mouse cursor image
-static gStaticImage textImage(0, 0, NULL), // Current mouse text image
- combinedImage(0, 0, NULL); // Combine mouse text
+static gStaticImage textImage(0, 0, nullptr), // Current mouse text image
+ combinedImage(0, 0, nullptr); // Combine mouse text
// and image
static int textImageCenteredCol; // The pixel column in the text
@@ -141,7 +141,7 @@ void createStackedImage(
int *imageCenterArray,
int images) {
assert(images != 0);
- assert(newImage->data == NULL);
+ assert(newImage->data == nullptr);
int i;
int newImageBytes,
@@ -205,7 +205,7 @@ inline void disposeStackedImage(gPixelMap *image) {
// image.
void cleanupMousePointer(void) {
- if (combinedImage.data != NULL)
+ if (combinedImage.data != nullptr)
disposeStackedImage(&combinedImage);
}
@@ -229,7 +229,7 @@ void setupMousePointer(void) {
imageIndex++;
}
- if (combinedImage.data != NULL)
+ if (combinedImage.data != nullptr)
disposeStackedImage(&combinedImage);
createStackedImage(
@@ -297,7 +297,7 @@ void setNewText(char *text) {
disposeText();
strncpy(mouseText, text, maxMouseTextLen - 1);
- mouseText[maxMouseTextLen - 1] = NULL;
+ mouseText[maxMouseTextLen - 1] = '\0';
// Compute the size of the text bitmap
textImage.size.y = mainFont->height + 2;
@@ -340,12 +340,12 @@ void setNewText(char *text) {
// Setup a new text string to display on the mouse cursor
void setMouseText(char *text) {
- if (text != NULL) {
+ if (text != nullptr) {
if (strcmp(text, mouseText) == 0) return;
setNewText(text);
setupMousePointer();
- } else if (mouseText[0] != NULL) {
+ } else if (mouseText[0] != '\0') {
disposeText();
setupMousePointer();
}
@@ -356,8 +356,8 @@ void setMouseText(char *text) {
void setMouseTextF(char *format, ...) {
extern gToolBase G_BASE;
- if (format == NULL) {
- setMouseText(NULL);
+ if (format == nullptr) {
+ setMouseText(nullptr);
G_BASE.mouseHintSet = TRUE;
} else {
char lineBuf[128];
Commit: f9fe364f145b2203995c85686cdd367be39cd0c7
https://github.com/scummvm/scummvm/commit/f9fe364f145b2203995c85686cdd367be39cd0c7
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:02+02:00
Commit Message:
SAGA2: Fix memory-related errors on exit
Changed paths:
engines/saga2/intrface.cpp
engines/saga2/panel.cpp
engines/saga2/playmode.cpp
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index 4b7b963d00..16212fbe88 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -1633,7 +1633,7 @@ void unloadImageRes(void **images, int16 numRes) {
ImageCache.releaseImage(images[i]);
}
- delete images;
+ free(images);
}
}
diff --git a/engines/saga2/panel.cpp b/engines/saga2/panel.cpp
index 65c90b4371..2436be004c 100644
--- a/engines/saga2/panel.cpp
+++ b/engines/saga2/panel.cpp
@@ -264,7 +264,7 @@ void gPanelList::removeControls(void) {
gControl *ctl;
// Delete all sub-panels.
- while ((ctl = (gControl *)contents.first()) != NULL)
+ while ((ctl = (gControl *)contents.first()) != nullptr)
delete ctl;
}
diff --git a/engines/saga2/playmode.cpp b/engines/saga2/playmode.cpp
index d1eb3d7e8f..51af4e683e 100644
--- a/engines/saga2/playmode.cpp
+++ b/engines/saga2/playmode.cpp
@@ -262,10 +262,11 @@ void PlayModeSetup(void) {
void PlayModeCleanup(void) {
closeAllFloatingWindows();
if (playControls) {
+ if (StatusLine)
+ delete StatusLine;
+ StatusLine = nullptr;
delete playControls;
playControls = nullptr;
- delete StatusLine;
- StatusLine = nullptr;
}
if (speakButtonControls) {
delete speakButtonControls;
Commit: 6f18b7b25dc60712fe865dc20938b81aec085b42
https://github.com/scummvm/scummvm/commit/6f18b7b25dc60712fe865dc20938b81aec085b42
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:02+02:00
Commit Message:
SAGA2: Disable audio interface temporarily
Changed paths:
engines/saga2/audio.cpp
engines/saga2/beegee.cpp
engines/saga2/gamerate.h
engines/saga2/main.cpp
diff --git a/engines/saga2/audio.cpp b/engines/saga2/audio.cpp
index 3059bcb072..c8ea910f48 100644
--- a/engines/saga2/audio.cpp
+++ b/engines/saga2/audio.cpp
@@ -85,6 +85,7 @@ void audioInterface::resumeGameClock(void) {
bool audioInterface::playFlag(void) {
warning("STUB: audioInterface::playFlag()");
+ return false;
}
void audioInterface::playMe(void) {
warning("STUB: audioInterface::PlayMe()");
diff --git a/engines/saga2/beegee.cpp b/engines/saga2/beegee.cpp
index 172ab4c312..914cab45e0 100644
--- a/engines/saga2/beegee.cpp
+++ b/engines/saga2/beegee.cpp
@@ -280,8 +280,8 @@ void audioEnvironmentUseSet(int16 audioSet, int32 auxID, Point32 relPos) {
void audioEnvironmentCheck(void) {
- uint32 delta = gameTime - lastGameTime;
- lastGameTime = gameTime;
+ uint32 delta = g_system->getMillis() - lastGameTime;
+ lastGameTime = g_system->getMillis();
if (currentTheme) {
elapsedGameTime += delta;
if (elapsedGameTime > checkGameTime) {
diff --git a/engines/saga2/gamerate.h b/engines/saga2/gamerate.h
index 9153d4b470..20d90b537e 100644
--- a/engines/saga2/gamerate.h
+++ b/engines/saga2/gamerate.h
@@ -52,8 +52,8 @@ public:
~frameCounter() {}
virtual void updateFrameCount(void) {
- int32 frameTime = gameTime - lastTime;
- lastTime = gameTime;
+ int32 frameTime = g_system->getMillis() - lastTime;
+ lastTime = g_system->getMillis();
frames++;
instantFrameCount = frameTime ? ticksPerSecond / frameTime : 100;
}
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 022afd3e82..d050caef7c 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -319,7 +319,8 @@ void processEventLoop(bool updateScreen) {
return;
debugC(1, kDebugEventLoop, "EventLoop: audio event loop");
- audioEventLoop();
+ //FIXME: Disabled for debug purposes. Enable and implement later.
+ //audioEventLoop();
debugC(1, kDebugEventLoop, "EventLoop: game mode update");
if (GameMode::newmodeFlag)
@@ -373,8 +374,8 @@ void displayUpdate(void) {
GameMode::modeStackPtr[GameMode::modeStackCtr - 1]->handleTask();
lrate.updateFrameCount();
loops++;
- elapsed += (gameTime - lastGameTime);
- lastGameTime = gameTime;
+ elapsed += (g_system->getMillis() - lastGameTime);
+ lastGameTime = g_system->getMillis();
debugC(1, kDebugEventLoop, "EventLoop: Interface indicator updates");
@@ -388,7 +389,8 @@ void displayUpdate(void) {
debugC(1, kDebugEventLoop, "EventLoop: resource update");
loadAsyncResources();
- audioEventLoop();
+ //FIXME: Disabled for debug purposes. Enable and implement later.
+ //audioEventLoop();
// Call the asynchronous path finder
debugC(1, kDebugEventLoop, "EventLoop: pathfinder update");
Commit: 1d1712df0a70ce18ed03ac1c9ad904c4e2fd66e2
https://github.com/scummvm/scummvm/commit/1d1712df0a70ce18ed03ac1c9ad904c4e2fd66e2
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:02+02:00
Commit Message:
SAGA2: Fix displayUpdate condition
Changed paths:
engines/saga2/display.cpp
diff --git a/engines/saga2/display.cpp b/engines/saga2/display.cpp
index d82286dcf1..24f0c27ec0 100644
--- a/engines/saga2/display.cpp
+++ b/engines/saga2/display.cpp
@@ -215,11 +215,7 @@ void displayEnable(DisplayDisabledBecause reason, bool onOff) {
// This is a check to see if blitting is enabled
bool displayEnabled(uint32 mask) {
-#ifdef _WIN32
- if (pWindow == NULL || (!pWindow->canBlit()))
- return FALSE;
-#endif
- return ((displayStatus & mask) == 0);
+ return true;
}
bool displayOkay(void) {
Commit: 98e7e8fab0239438da63c980a6057e48281bf7f2
https://github.com/scummvm/scummvm/commit/98e7e8fab0239438da63c980a6057e48281bf7f2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:02+02:00
Commit Message:
SAGA2: Remove unused method
Changed paths:
engines/saga2/interp.cpp
engines/saga2/script.h
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 50423d3efc..16db0ecec4 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -1145,7 +1145,6 @@ public:
// Place a new thread into the active list and return its pointer
void *newThread(void);
- void *newThread(ThreadID id);
// Place a thread back into the inactive list
void deleteThread(void *p);
@@ -1190,6 +1189,8 @@ void *ThreadList::restore(void *buf) {
int16 i,
threadCount;
+ assert(0);
+
// Get the count of threads and increment the buffer pointer
threadCount = *((int16 *)buf);
buf = (int16 *)buf + 1;
@@ -1293,24 +1294,6 @@ void *ThreadList::newThread(void) {
return NULL;
}
-//-------------------------------------------------------------------
-// Place a new thread into the active list and return its pointer
-
-void *ThreadList::newThread(ThreadID id) {
- assert(id >= 0 && id < elementsof(array));
-
- ThreadPlaceHolder *tp;
-
- // Grab the thread place holder from the inactive list
- tp = (ThreadPlaceHolder *)&array[id];
- tp->remove();
-
- // Place the place holder into the active list
- list.addTail(*tp);
-
- return tp->buf;
-}
-
//-------------------------------------------------------------------
// Place a thread back into the inactive list
@@ -1449,13 +1432,6 @@ void *newThread(void) {
return threadList.newThread();
}
-//-------------------------------------------------------------------
-// Get a specific SAGA thread from the global thread list
-
-void *newThread(ThreadID id) {
- return threadList.newThread(id);
-}
-
//-------------------------------------------------------------------
// Dispose of an active SAGA thread
diff --git a/engines/saga2/script.h b/engines/saga2/script.h
index 89fc4bffc9..8a4ab6bd10 100644
--- a/engines/saga2/script.h
+++ b/engines/saga2/script.h
@@ -159,9 +159,6 @@ void cleanupSAGAThreads(void);
// Get a new SAGA thread from the global thread list
void *newThread(void);
-// Get a specific SAGA thread from the global thread list
-void *newThread(ThreadID id);
-
// Dispose of an active SAGA thread
void deleteThread(void *p);
Commit: bc34ccb8a37f0f69ea5dac31a0f8d4f52f0b2e99
https://github.com/scummvm/scummvm/commit/bc34ccb8a37f0f69ea5dac31a0f8d4f52f0b2e99
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:03+02:00
Commit Message:
SAGA2: Rewrite ThreadList for using conventional array
Changed paths:
engines/saga2/interp.cpp
engines/saga2/script.h
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 16db0ecec4..b1899e3462 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -1111,24 +1111,18 @@ bool Thread::interpret(void) {
* ============================================================================ */
class ThreadList {
-
- struct ThreadPlaceHolder : public DNode {
- uint8 buf[sizeof(Thread)];
-
- Thread *getThread(void) {
- return (Thread *)&buf;
- }
+ enum {
+ kNumThreads = 25
};
- DList list, // List of active Threads
- free; // List of available Threads
-
- ThreadPlaceHolder array[32]; // Memory buffer for thread
- // instantiation
+ Thread *_list[kNumThreads];
public:
// Constructor
- ThreadList(void);
+ ThreadList(void) {
+ for (uint i = 0; i < kNumThreads; i++)
+ _list[i] = nullptr;
+ }
// Reconstruct from archive buffer
void *restore(void *buf);
@@ -1143,54 +1137,42 @@ public:
// Cleanup the active threads
void cleanup(void);
- // Place a new thread into the active list and return its pointer
- void *newThread(void);
-
// Place a thread back into the inactive list
- void deleteThread(void *p);
+ void deleteThread(Thread *p);
+
+ void newThread(Thread *p);
// Return the specified thread's ID
ThreadID getThreadID(Thread *thread) {
- ThreadPlaceHolder *tp;
+ for (uint i = 0; i < kNumThreads; i++) {
+ if (_list[i] == thread)
+ return i;
+ }
- tp = ((ThreadPlaceHolder *)(
- (uint8 *)thread
- - offsetof(ThreadPlaceHolder, buf)));
- return tp - array;
+ error("Unknown thread address: %p", (void *)thread);
}
// Return a pointer to a thread, given an ID
Thread *getThreadAddress(ThreadID id) {
- assert(id >= 0 && id < elementsof(array));
- return array[id].getThread();
+ return _list[id];
}
// Return a pointer to the first active thread
Thread *first(void);
- // Return a pointer to the next active thread
Thread *next(Thread *thread);
};
-//-------------------------------------------------------------------
-// Constructor
-
-ThreadList::ThreadList(void) {
- int i;
-
- for (i = 0; i < elementsof(array); i++)
- free.addTail(array[i]);
-}
-
//-------------------------------------------------------------------
// Reconstruct from archive buffer
void *ThreadList::restore(void *buf) {
+ warning("STUB: hreadList::restore()");
+
+#if 0
int16 i,
threadCount;
- assert(0);
-
// Get the count of threads and increment the buffer pointer
threadCount = *((int16 *)buf);
buf = (int16 *)buf + 1;
@@ -1205,22 +1187,17 @@ void *ThreadList::restore(void *buf) {
new Thread(&buf);
}
-
+#endif
return buf;
}
-//-------------------------------------------------------------------
-// Return the number of bytes needed to archive this thead list
-// in an archive buffer
-
int32 ThreadList::archiveSize(void) {
- int32 size = sizeof(int16);
- ThreadPlaceHolder *tp;
+ int32 size = sizeof(int16);
- for (tp = (ThreadPlaceHolder *)list.first();
- tp != NULL;
- tp = (ThreadPlaceHolder *)tp->next())
- size += sizeof(ThreadID) + tp->getThread()->archiveSize();
+ for (uint i = 0; i < kNumThreads; i++) {
+ if (_list[i])
+ size += sizeof(ThreadID) + _list[i]->archiveSize();
+ }
return size;
}
@@ -1229,6 +1206,9 @@ int32 ThreadList::archiveSize(void) {
// Create an archive of this thread list in an archive buffer
void *ThreadList::archive(void *buf) {
+ warning("STUB: hreadList::archive()");
+
+#if 0
int16 threadCount = 0;
ThreadPlaceHolder *tp;
@@ -1254,6 +1234,7 @@ void *ThreadList::archive(void *buf) {
buf = thread->archive(buf);
}
+#endif
return buf;
}
@@ -1262,83 +1243,63 @@ void *ThreadList::archive(void *buf) {
// Cleanup the active threads
void ThreadList::cleanup(void) {
- ThreadPlaceHolder *tp;
- ThreadPlaceHolder *nextTP;
-
- for (tp = (ThreadPlaceHolder *)list.first();
- tp != NULL;
- tp = nextTP) {
- // Save the address of the next in the list
- nextTP = (ThreadPlaceHolder *)tp->next();
-
- delete tp->getThread();
+ for (uint i = 0; i < kNumThreads; i++) {
+ delete _list[i];
+ _list[i] = nullptr;
}
}
//-------------------------------------------------------------------
-// Place a new thread into the active list and return its pointer
-
-void *ThreadList::newThread(void) {
- ThreadPlaceHolder *tp;
-
- // Grab a thread place holder from the inactive list
- tp = (ThreadPlaceHolder *)free.remHead();
-
- if (tp != NULL) {
- // Place the place holder into the active list
- list.addTail(*tp);
+// Place a thread back into the inactive list
- return tp->buf;
+void ThreadList::deleteThread(Thread *p) {
+ for (uint i = 0; i < kNumThreads; i++) {
+ if (_list[i] == p) {
+ delete _list[i];
+ _list[i] = nullptr;
+ }
}
-
- return NULL;
}
-//-------------------------------------------------------------------
-// Place a thread back into the inactive list
-
-void ThreadList::deleteThread(void *p) {
- ThreadPlaceHolder *tp;
-
- // Convert the pointer to the Thread to a pointer to the
- // ThreadPlaceHolder
- tp = (ThreadPlaceHolder *)(
- (uint8 *)p
- - offsetof(ThreadPlaceHolder, buf));
-
- // Remove the thread place holder from the active list
- tp->remove();
+void ThreadList::newThread(Thread *p) {
+ for (uint i = 0; i < kNumThreads; i++) {
+ if (!_list[i]) {
+ _list[i] = p;
+ return;
+ }
+ }
- // Place it into the inactive list
- free.addTail(*tp);
+ error("ThreadList::newThread(): Too many threads");
}
//-------------------------------------------------------------------
// Return a pointer to the first active thread
Thread *ThreadList::first(void) {
- ThreadPlaceHolder *tp = (ThreadPlaceHolder *)list.first();
+ for (uint i = 0; i < kNumThreads; i++)
+ if (_list[i])
+ return _list[i];
- return tp != NULL ? tp->getThread() : NULL;
+ return nullptr;
}
-//-------------------------------------------------------------------
-// Return a pointer to the next active thread
-
Thread *ThreadList::next(Thread *thread) {
- ThreadPlaceHolder *tp;
+ uint i;
+ for (i = 0; i < kNumThreads; i++)
+ if (_list[i] == thread)
+ break;
- // Convert the pointer to the Thread to a pointer to the
- // ThreadPlaceHolder
- tp = (ThreadPlaceHolder *)(
- (uint8 *)thread
- - offsetof(ThreadPlaceHolder, buf));
+ if (i == kNumThreads)
+ return nullptr;
- tp = (ThreadPlaceHolder *)tp->next();
+ for (; i < kNumThreads; i++)
+ if (_list[i])
+ return _list[i];
- return tp != NULL ? tp->getThread() : NULL;
+ return nullptr;
}
+
/* ===================================================================== *
Global thread list instantiation
* ===================================================================== */
@@ -1411,8 +1372,7 @@ void loadSAGAThreads(SaveFileReader &saveGame) {
new ThreadList;
bufferPtr = threadList.restore(bufferPtr);
- assert((char *)bufferPtr == (char *)archiveBuffer
- + saveGame.getChunkSize());
+ assert((char *)bufferPtr == (char *)archiveBuffer + saveGame.getChunkSize());
free(archiveBuffer);
}
@@ -1425,20 +1385,17 @@ void cleanupSAGAThreads(void) {
threadList.cleanup();
}
-//-------------------------------------------------------------------
-// Get a new SAGA thread from the global thread list
-
-void *newThread(void) {
- return threadList.newThread();
-}
-
//-------------------------------------------------------------------
// Dispose of an active SAGA thread
-void deleteThread(void *thread) {
+void deleteThread(Thread *thread) {
threadList.deleteThread(thread);
}
+void newThread(Thread *thread) {
+ threadList.newThread(thread);
+}
+
//-------------------------------------------------------------------
// Return the ID of the specified SAGA thread
@@ -1482,6 +1439,8 @@ Thread::Thread(uint16 segNum, uint16 segOff, scriptCallFrame &args) {
//warning("SAGA failure: Invalid script entry point (export=%d) [segment=%d:%d]\n", lastExport, segNum, segOff);
_valid = false;
}
+
+ newThread(this);
// assert ((codeSeg)[programCounter.offset] == op_enter);
}
@@ -1518,6 +1477,8 @@ Thread::Thread(void **buf) {
bufferPtr = (uint8 *)bufferPtr + stackOffset;
*buf = bufferPtr;
+
+ newThread(this);
}
//-----------------------------------------------------------------------
@@ -1532,6 +1493,8 @@ Thread::~Thread() {
// Deallocate the thread stack
free(stackBase);
+
+ deleteThread(this);
}
//-----------------------------------------------------------------------
diff --git a/engines/saga2/script.h b/engines/saga2/script.h
index 8a4ab6bd10..764fa8c657 100644
--- a/engines/saga2/script.h
+++ b/engines/saga2/script.h
@@ -155,13 +155,10 @@ void loadSAGAThreads(SaveFileReader &saveGame);
// Dispose of the active SAGA threads
void cleanupSAGAThreads(void);
-
-// Get a new SAGA thread from the global thread list
-void *newThread(void);
-
// Dispose of an active SAGA thread
-void deleteThread(void *p);
+void deleteThread(Thread *p);
+void newThread(Thread *p);
// Return the ID of the specified SAGA thread
ThreadID getThreadID(Thread *thread);
Commit: 269a21cdef59c8f56df3428800a35823f5830a58
https://github.com/scummvm/scummvm/commit/269a21cdef59c8f56df3428800a35823f5830a58
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:03+02:00
Commit Message:
SAGA2: Stub loading async resources
Changed paths:
engines/saga2/rserver.cpp
diff --git a/engines/saga2/rserver.cpp b/engines/saga2/rserver.cpp
index 5c42c999df..72128422bd 100644
--- a/engines/saga2/rserver.cpp
+++ b/engines/saga2/rserver.cpp
@@ -192,7 +192,11 @@ void cleanupServers(void) {
}
void loadAsyncResources(void) {
+ warning("STUB: loadAsyncResources()");
+
+#if 0
resourceServer->service();
+#endif
}
void syncResources(void) {
Commit: a6ec2a77de11af17d8100082b7c392b18d66aa44
https://github.com/scummvm/scummvm/commit/a6ec2a77de11af17d8100082b7c392b18d66aa44
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:03+02:00
Commit Message:
SAGA2: Implement few low level drawing routines
Changed paths:
engines/saga2/blitters.cpp
engines/saga2/playmode.cpp
engines/saga2/vwpage.cpp
diff --git a/engines/saga2/blitters.cpp b/engines/saga2/blitters.cpp
index e8de0570d9..7b2ea5b10e 100644
--- a/engines/saga2/blitters.cpp
+++ b/engines/saga2/blitters.cpp
@@ -310,20 +310,110 @@ void maskTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData) {
warning("STUB: maskTile()");
}
-void TBlit(gPixelMap *d, gPixelMap *s, int32 x, int32 y) {
- warning("STUB: TBlit()");
+void TBlit(gPixelMap *dstMap, gPixelMap *srcMap, int xpos, int ypos) {
+ byte *srcPtr,
+ *dstPtr;
+ int16 srcMod,
+ dstMod;
+ int16 x, y, w, h;
+ int32 offset = 0;
+
+ w = srcMap->size.x;
+ h = srcMap->size.y;
+
+ if (ypos < 0) {
+ h += ypos;
+ offset -= (ypos * w);
+ ypos = 0;
+ }
+
+ if (xpos < 0) {
+ w += xpos;
+ offset -= xpos;
+ xpos = 0;
+ }
+
+ if (w > dstMap->size.x - xpos)
+ w = dstMap->size.x - xpos;
+ if (h > dstMap->size.y - ypos)
+ h = dstMap->size.y - ypos;
+ if (w < 0 || h < 0)
+ return;
+
+ dstMod = dstMap->size.x - w;
+ srcMod = srcMap->size.x - w;
+
+ srcPtr = srcMap->data + offset;
+ dstPtr = dstMap->data + xpos + ypos * dstMap->size.x;
+
+ for (y = 0; y < h; y++) {
+ for (x = 0; x < w; x++) {
+ byte c = *srcPtr++;
+
+ if (c == 0)
+ dstPtr++;
+ else
+ *dstPtr++ = c;
+ }
+ dstPtr += dstMod;
+ srcPtr += srcMod;
+ }
}
void TBlit4(gPixelMap *d, gPixelMap *s, int32 x, int32 y) {
- warning("STUB: TBlit4()");
+ TBlit(d, s, x, y);
}
-void compositePixels(gPixelMap *compMap, gPixelMap *sprMap, int32 xpos, int32 ypos, uint8 *lookup) {
- warning("STUB: compositePixels()");
+void compositePixels(gPixelMap *compMap, gPixelMap *sprMap, int xpos, int ypos, byte *lookup) {
+ byte *srcPtr,
+ *dstPtr;
+ int16 rowMod;
+ int16 x, y;
+
+ // Blit the temp map onto the composite map
+
+ srcPtr = sprMap->data;
+ dstPtr = compMap->data + xpos + ypos * compMap->size.x;
+ rowMod = compMap->size.x - sprMap->size.x;
+
+ for (y = 0; y < sprMap->size.y; y++) {
+ for (x = 0; x < sprMap->size.x; x++) {
+ byte c = *srcPtr++;
+
+ if (c == 0)
+ dstPtr++;
+ else
+ *dstPtr++ = lookup[ c ];
+ }
+ dstPtr += rowMod;
+ }
}
-void compositePixelsRvs(gPixelMap *compMap, gPixelMap *sprMap, int32 xpos, int32 ypos, uint8 *lookup) {
- warning("STUB: compositePixelsRvs()");
+void compositePixelsRvs(gPixelMap *compMap, gPixelMap *sprMap, int xpos, int ypos, byte *lookup) {
+ byte *srcPtr,
+ *dstPtr;
+ int16 rowMod;
+ int16 x, y;
+
+ // Blit the temp map onto the composite map
+
+ srcPtr = sprMap->data + sprMap->bytes();
+ dstPtr = compMap->data + xpos + (ypos + sprMap->size.y) * compMap->size.x;
+
+ rowMod = compMap->size.x + sprMap->size.x;
+
+ for (y = 0; y < sprMap->size.y; y++) {
+ dstPtr -= rowMod;
+
+ for (x = 0; x < sprMap->size.x; x++) {
+ byte c = *--srcPtr;
+
+ if (c == 0)
+ dstPtr++;
+ else
+ *dstPtr++ = lookup[ c ];
+ }
+ }
}
bool initGraphics(void) {
diff --git a/engines/saga2/playmode.cpp b/engines/saga2/playmode.cpp
index 51af4e683e..ec6bdaebc3 100644
--- a/engines/saga2/playmode.cpp
+++ b/engines/saga2/playmode.cpp
@@ -337,8 +337,11 @@ void drawCompressedImage(gPort &port, const Point16 pos, void *image) {
Graphics::Surface sur;
sur.create(map.size.x, map.size.y, Graphics::PixelFormat::createFormatCLUT8());
sur.setPixels(map.data);
+
+#if 0
sur.debugPrint();
g_system->copyRectToScreen(sur.getPixels(), sur.pitch, 0, 0, sur.w, sur.h);
+#endif
} else
map.data = (uint8 *)hdr->data;
diff --git a/engines/saga2/vwpage.cpp b/engines/saga2/vwpage.cpp
index f9a415f7f0..fa5fa57895 100644
--- a/engines/saga2/vwpage.cpp
+++ b/engines/saga2/vwpage.cpp
@@ -470,7 +470,7 @@ void vWDisplayPage::vLine(int16 x, int16 y, int16 height, uint8 color) {
#define USE_BLTDDRECT
// -- we'll want to use this when we figure out why bltDDRect doesnt work here
-//#define USE_RECT
+#define USE_RECT
void vWDisplayPage::writePixels(Rect16 &r, uint8 *pixPtr, uint16 pixMod) {
Common::Rect wRect;
@@ -499,27 +499,11 @@ void vWDisplayPage::writeTransPixels(Rect16 &r, uint8 *pixPtr, uint16 pixMod) {
}
#else
void vWDisplayPage::writeTransPixels(Rect16 &r, uint8 *pixPtr, uint16 pixMod) {
- uint8 *dstPtr;
- RECT wRect;
-
if (!displayEnabled()) //ddWindow || !ddWindow->bIsActive )
return;
- wRect.left = r.x;
- wRect.top = r.y;
- wRect.right = r.x + r.width;
- wRect.bottom = r.y + r.height;
-
- dstPtr = (uint8 *)ddWindow->LockBackBuffer(&wRect);
-
- if (!dstPtr) {
- gError::warn("Failed buffer lock");
- return;
- }
-
- _BltPixelsT(pixPtr, pixMod, dstPtr, ddWindow->lPitch, r.width, r.height);
-
- ddWindow->UnlockBackBuffer(dstPtr);
+ warning("STUB: writeTransPixels, transparency is ignored");
+ g_system->copyRectToScreen(pixPtr, pixMod, r.x, r.y, r.width, r.height);
}
#endif
Commit: 6916f47f95c7702371abae215a9b61d1210055c2
https://github.com/scummvm/scummvm/commit/6916f47f95c7702371abae215a9b61d1210055c2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:03+02:00
Commit Message:
SAGA2: Hid noisy warning
Changed paths:
engines/saga2/rserver.cpp
diff --git a/engines/saga2/rserver.cpp b/engines/saga2/rserver.cpp
index 72128422bd..4e3c0673fc 100644
--- a/engines/saga2/rserver.cpp
+++ b/engines/saga2/rserver.cpp
@@ -26,12 +26,13 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+#include "common/debug.h"
+
#include "saga2/std.h"
#include "saga2/dlist.h"
#include "saga2/ioerrors.h"
#include "saga2/hresmgr.h"
-
namespace Saga2 {
class ResourceRequest;
@@ -192,7 +193,7 @@ void cleanupServers(void) {
}
void loadAsyncResources(void) {
- warning("STUB: loadAsyncResources()");
+ debug(3, "STUB: loadAsyncResources()");
#if 0
resourceServer->service();
Commit: c7c4db7c385d14c2b39f324ce3e347f9cac37205
https://github.com/scummvm/scummvm/commit/c7c4db7c385d14c2b39f324ce3e347f9cac37205
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:03+02:00
Commit Message:
SAGA2: More low-level drawing code
Changed paths:
engines/saga2/blitters.cpp
engines/saga2/gdraw.cpp
diff --git a/engines/saga2/blitters.cpp b/engines/saga2/blitters.cpp
index 7b2ea5b10e..29b0105582 100644
--- a/engines/saga2/blitters.cpp
+++ b/engines/saga2/blitters.cpp
@@ -33,11 +33,30 @@
namespace Saga2 {
void _BltPixels(uint8 *srcPtr, uint32 srcMod, uint8 *dstPtr, uint32 dstMod, uint32 width, uint32 height) {
- warning("STUB: _BltPixels()");
+ uint8 *src, *dst;
+ for (uint y = 0; y < height; y++) {
+ src = srcPtr + srcMod * y;
+ dst = dstPtr + dstMod * y;
+ for (uint x = 0; x < width; x++) {
+ *dst++ = *src++;
+ }
+ }
}
void _BltPixelsT(uint8 *srcPtr, uint32 srcMod, uint8 *dstPtr, uint32 dstMod, uint32 width, uint32 height) {
- warning("STUB: _BltPixelsT()");
+ uint8 *src, *dst;
+ for (uint y = 0; y < height; y++) {
+ src = srcPtr + srcMod * y;
+ dst = dstPtr + dstMod * y;
+ for (uint x = 0; x < width; x++) {
+ byte c = *src++;
+
+ if (c == 0)
+ dst++;
+ else
+ *dst++ = c;
+ }
+ }
}
void _FillRect(uint8 *dstPtr, uint32 dstMod, uint32 width, uint32 height, uint32 color) {
diff --git a/engines/saga2/gdraw.cpp b/engines/saga2/gdraw.cpp
index 3f17c73fce..ff4559780b 100644
--- a/engines/saga2/gdraw.cpp
+++ b/engines/saga2/gdraw.cpp
@@ -622,30 +622,17 @@ void gPort::bltPixels(
+ sect.x + origin.x;
if (drawMode == drawModeMatte) { // Matte drawing mode
- // Uses transparency
- _BltPixelsT(src_line, src.size.x,
- dst_line, rowMod,
- sect.width, sect.height);
+ for (int h = sect.height; h > 0; h--, src_line += src.size.x, dst_line += rowMod) {
+ uint8 *src_ptr = src_line,
+ *dst_ptr = dst_line;
- /*
- for (int h = sect.height;
- h > 0;
- h--,
- src_line += src.size.x,
- dst_line += rowMod )
- {
- uint8 *src_ptr = src_line,
- *dst_ptr = dst_line;
-
- for (int w = sect.width;
- w > 0;
- w--)
- {
- if (*src_ptr) *dst_ptr++ = *src_ptr++;
- else dst_ptr++, src_ptr++;
- }
- }
- */
+ for (int w = sect.width; w > 0; w--) {
+ if (*src_ptr)
+ *dst_ptr++ = *src_ptr++;
+ else
+ dst_ptr++, src_ptr++;
+ }
+ }
} else if (drawMode == drawModeColor) { // Color drawing mode
// Draws single color, except where
for (int h = sect.height; // src pixels are transparent
@@ -659,25 +646,16 @@ void gPort::bltPixels(
for (int w = sect.width;
w > 0;
w--) {
- if (*src_ptr++) *dst_ptr++ = fgPen;
- else dst_ptr++;
+ if (*src_ptr++)
+ *dst_ptr++ = fgPen;
+ else
+ dst_ptr++;
}
}
} else if (drawMode == drawModeReplace) { // Replacement drawing mode
- // Does not use transparency
- _BltPixels(src_line, src.size.x,
- dst_line, rowMod,
- sect.width, sect.height);
- /*
- for (int h = sect.height;
- h > 0;
- h--,
- src_line += src.size.x,
- dst_line += rowMod)
- {
- memcpy( dst_line, src_line, sect.width );
- }
- */
+ for (int h = sect.height; h > 0; h--, src_line += src.size.x, dst_line += rowMod) {
+ memcpy(dst_line, src_line, sect.width);
+ }
} else if (drawMode == drawModeComplement) { // Complement drawing mode
// Inverts pixels, except where
for (int h = sect.height; // src is transparent
Commit: 9f38ff10cd07b09cf6fba4c6d8e035af5b03de32
https://github.com/scummvm/scummvm/commit/9f38ff10cd07b09cf6fba4c6d8e035af5b03de32
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:03+02:00
Commit Message:
SAGA2: Fix unitialized variable
Changed paths:
engines/saga2/gdraw.h
diff --git a/engines/saga2/gdraw.h b/engines/saga2/gdraw.h
index 7f2d6e7699..fca71a91bb 100644
--- a/engines/saga2/gdraw.h
+++ b/engines/saga2/gdraw.h
@@ -193,6 +193,7 @@ public:
baseRow = nullptr;
rowMod = 0;
+ origin = Point16(0, 0);
penMap = nullptr;
drawMode = drawModeMatte;
font = nullptr;
Commit: a76d3ff76023ce08395ae17f12a9ee0844c01261
https://github.com/scummvm/scummvm/commit/a76d3ff76023ce08395ae17f12a9ee0844c01261
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:03+02:00
Commit Message:
SAGA2: Show cursror
Changed paths:
engines/saga2/gpointer.cpp
diff --git a/engines/saga2/gpointer.cpp b/engines/saga2/gpointer.cpp
index 649e2e7e77..a4c7e7b847 100644
--- a/engines/saga2/gpointer.cpp
+++ b/engines/saga2/gpointer.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#include "graphics/cursorman.h"
+
#include "saga2/std.h"
#include "saga2/gpointer.h"
@@ -131,10 +133,6 @@ void gMousePointer::show(void) {
assert(hideCount > 0);
if (--hideCount == 0) {
-#if defined( USEWINDOWS )
- WinResumeTransfer();
-#endif
-
draw();
}
}
@@ -142,9 +140,6 @@ void gMousePointer::show(void) {
// Makes the mouse pointer invisible
void gMousePointer::hide(void) {
if (hideCount++ == 0) {
-#if defined( USEWINDOWS )
- WinPauseTransfer();
-#endif
restore();
}
}
@@ -156,16 +151,12 @@ void gMousePointer::show(gPort &port, Rect16 r) {
r.x += org.x;
r.y += org.y;
-#if defined( USEWINDOWS )
- // KMY NOTE:
- // In this case, (special), just in case saveExtent.overlap(r) is not always true in matching
- // pairs, we pause/resume regardless. Maybe I'm being anal, but it's safer and not really any
- // performance hit.
- WinResumeTransfer();
-#endif
-
if (saveExtent.overlap(r)) {
- if (--hideCount == 0) draw();
+ if (--hideCount == 0) {
+ draw();
+ CursorMan.showMouse(true);
+ }
+
}
}
@@ -180,7 +171,8 @@ int gMousePointer::manditoryShow(void) {
hide();
rv--;
}
- if (!shown) draw();
+ if (!shown)
+ draw();
return rv;
}
@@ -192,16 +184,11 @@ void gMousePointer::hide(gPort &port, Rect16 r) {
r.x += org.x;
r.y += org.y;
-#if defined( USEWINDOWS )
- // KMY NOTE:
- // In this case, (special), just in case saveExtent.overlap(r) is not always true in matching
- // pairs, we pause/resume regardless. Maybe I'm being anal, but it's safer and not really any
- // performance hit.
- WinPauseTransfer();
-#endif
-
if (saveExtent.overlap(r)) {
- if (hideCount++ == 0) restore();
+ if (hideCount++ == 0) {
+ restore();
+ CursorMan.showMouse(false);
+ }
}
}
@@ -231,15 +218,15 @@ void gMousePointer::setImage(
offsetPosition.y = y;
hide();
- if (saveMap.data) free(saveMap.data);
+ if (saveMap.data)
+ free(saveMap.data);
saveMap.size = img.size;
saveMap.data = (uint8 *)malloc(img.bytes());
pointerImage = &img;
currentPosition = pos + offsetPosition;
-#if defined( USEWINDOWS )
- if (useWinCursor)
- SetWinCursor(img, x, y);
-#endif
+
+ CursorMan.replaceCursor(img.data, img.size.x, img.size.y, x, y, 0);
+ CursorMan.showMouse(true);
show();
}
}
Commit: d53bc7074cc575c58a986e44c4ba08bf63e45e0a
https://github.com/scummvm/scummvm/commit/d53bc7074cc575c58a986e44c4ba08bf63e45e0a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:03+02:00
Commit Message:
SAGA2: Correctly initialize Points and Rectangles
Changed paths:
engines/saga2/rect.h
diff --git a/engines/saga2/rect.h b/engines/saga2/rect.h
index b06e4389fd..7f1a302575 100644
--- a/engines/saga2/rect.h
+++ b/engines/saga2/rect.h
@@ -34,7 +34,7 @@ public:
int16 x, y;
// constructors
- Point16() {}
+ Point16() { x = y = 0; }
Point16(int16 nx, int16 ny) {
x = nx;
y = ny;
@@ -138,7 +138,7 @@ public:
int32 x, y;
// constructors
- Point32() {}
+ Point32() { x = y = 0; }
Point32(int32 nx, int32 ny) {
x = nx;
y = ny;
@@ -250,7 +250,7 @@ public:
width, height;
// constructors
- Rect16() {}
+ Rect16() { x = y = width = height = 0; }
Rect16(int16 nx, int16 ny, int16 nw, int16 nh) {
x = nx;
y = ny;
@@ -371,7 +371,7 @@ public:
width, height;
// constructors
- Rect32() {}
+ Rect32() { x = y = width = height = 0; }
Rect32(int32 nx, int32 ny, int32 nw, int32 nh) {
x = nx;
y = ny;
Commit: 20d3131c16f1e24bc8bbee3ad7992fc053ed7485
https://github.com/scummvm/scummvm/commit/20d3131c16f1e24bc8bbee3ad7992fc053ed7485
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:04+02:00
Commit Message:
Revert "SAGA2: Fix unitialized variable"
This reverts commit a8308dd1cbc79fd672e288a323788622f679ab94.
The real issue is in the unitialized class variables which were fixed.
Changed paths:
engines/saga2/gdraw.h
diff --git a/engines/saga2/gdraw.h b/engines/saga2/gdraw.h
index fca71a91bb..7f2d6e7699 100644
--- a/engines/saga2/gdraw.h
+++ b/engines/saga2/gdraw.h
@@ -193,7 +193,6 @@ public:
baseRow = nullptr;
rowMod = 0;
- origin = Point16(0, 0);
penMap = nullptr;
drawMode = drawModeMatte;
font = nullptr;
Commit: 716d3148c36c9b83f1a503c2c3352db16939c806
https://github.com/scummvm/scummvm/commit/716d3148c36c9b83f1a503c2c3352db16939c806
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:04+02:00
Commit Message:
SAGA2: Initialize mainPort and blit its contents
Changed paths:
engines/saga2/playmode.cpp
engines/saga2/vdraw.h
diff --git a/engines/saga2/playmode.cpp b/engines/saga2/playmode.cpp
index ec6bdaebc3..e7c3e950a8 100644
--- a/engines/saga2/playmode.cpp
+++ b/engines/saga2/playmode.cpp
@@ -333,23 +333,28 @@ void drawCompressedImage(gPort &port, const Point16 pos, void *image) {
return;
unpackImage(&map, map.size.x, map.size.y, hdr->data);
-
- Graphics::Surface sur;
- sur.create(map.size.x, map.size.y, Graphics::PixelFormat::createFormatCLUT8());
- sur.setPixels(map.data);
-
-#if 0
- sur.debugPrint();
- g_system->copyRectToScreen(sur.getPixels(), sur.pitch, 0, 0, sur.w, sur.h);
-#endif
} else
map.data = (uint8 *)hdr->data;
port.setMode(drawModeMatte);
+ if (port.map == nullptr) {
+ gPixelMap *tmap = new gPixelMap;
+ tmap->size = map.size;
+ tmap->data = new uint8[map.bytes()];
+ port.setMap(tmap);
+ }
+
port.bltPixels(map, 0, 0,
pos.x, pos.y,
map.size.x, map.size.y);
+ Graphics::Surface sur;
+ sur.create(port.map->size.x, port.map->size.y, Graphics::PixelFormat::createFormatCLUT8());
+ sur.setPixels(port.map->data);
+
+ //sur.debugPrint();
+ g_system->copyRectToScreen(sur.getPixels(), sur.pitch, 0, 0, sur.w, sur.h);
+
if (hdr->compress)
delete[] map.data;
}
diff --git a/engines/saga2/vdraw.h b/engines/saga2/vdraw.h
index 94f00e1170..2220136efe 100644
--- a/engines/saga2/vdraw.h
+++ b/engines/saga2/vdraw.h
@@ -43,8 +43,6 @@ public:
clip = Rect16(0, 0, dPage->size.x, dPage->size.y);
}
- void setMap(gPixelMap *, bool = FALSE) {}
-
void setPixel(int16 x, int16 y, gPen color) {
if (x >= clip.x && x < clip.x + clip.width
&& y >= clip.y && y < clip.y + clip.height) {
Commit: b4acb68254cba2c0b0947571bc0b975b2c24a5de
https://github.com/scummvm/scummvm/commit/b4acb68254cba2c0b0947571bc0b975b2c24a5de
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:04+02:00
Commit Message:
SAGA2: Shift palette
Changed paths:
engines/saga2/vpal.cpp
diff --git a/engines/saga2/vpal.cpp b/engines/saga2/vpal.cpp
index 92e93fa713..432cb874b5 100644
--- a/engines/saga2/vpal.cpp
+++ b/engines/saga2/vpal.cpp
@@ -92,8 +92,15 @@ static PaletteStateArchive archive; // Used for loading and saving
* ===================================================================== */
void assertCurrentPalette(void) {
- if (paletteChangesEnabled())
- g_system->getPaletteManager()->setPalette((uint8 *)¤tPalette, 0, 256);
+ if (paletteChangesEnabled()) {
+ byte palette[256 * 3];
+ for (int i = 0; i < 256; i++) {
+ palette[i * 3 + 0] = ((byte *)¤tPalette)[i * 3 + 0] << 2;
+ palette[i * 3 + 1] = ((byte *)¤tPalette)[i * 3 + 1] << 2;
+ palette[i * 3 + 2] = ((byte *)¤tPalette)[i * 3 + 2] << 2;
+ }
+ g_system->getPaletteManager()->setPalette(palette, 0, 256);
+ }
}
Commit: 271a27dbdbb4a515c0aca702f1b66b2c9e946b8a
https://github.com/scummvm/scummvm/commit/271a27dbdbb4a515c0aca702f1b66b2c9e946b8a
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:04+02:00
Commit Message:
SAGA2: Fix some initialization steps
Changed paths:
engines/saga2/keybored.cpp
engines/saga2/modal.cpp
engines/saga2/msgbox.cpp
diff --git a/engines/saga2/keybored.cpp b/engines/saga2/keybored.cpp
index e3672f8c41..53cac4ddfa 100644
--- a/engines/saga2/keybored.cpp
+++ b/engines/saga2/keybored.cpp
@@ -222,7 +222,9 @@ void TileModeHandleKey(int16 key, int16 /* qual */) {
#ifdef GENE
case '~':
WriteStatusF(2, "Switching to Trice");
- GameMode::SetStack(&PlayMode, &TriceMode, End_List);
+
+ GameMode *gameModes[] = {&PlayMode, &TriceMode};
+ GameMode::SetStack(gameModes, 2);
GameMode::update();
break;
#endif
diff --git a/engines/saga2/modal.cpp b/engines/saga2/modal.cpp
index 9b6e9ad271..d39b1a0439 100644
--- a/engines/saga2/modal.cpp
+++ b/engines/saga2/modal.cpp
@@ -86,7 +86,9 @@ bool ModalWindow::open(void) {
mouseInfo.setIntent(GrabInfo::WalkTo);
prevModeStackCtr = GameMode::getStack(prevModeStackPtr);
- GameMode::SetStack(&PlayMode, &TileMode, &ModalMode, End_List);
+
+ GameMode *gameModes[] = {&PlayMode, &TileMode, &ModalMode};
+ GameMode::SetStack(gameModes, 3);
current = this;
diff --git a/engines/saga2/msgbox.cpp b/engines/saga2/msgbox.cpp
index d4b757161e..82dc0b4641 100644
--- a/engines/saga2/msgbox.cpp
+++ b/engines/saga2/msgbox.cpp
@@ -229,7 +229,9 @@ SimpleWindow::SimpleWindow(const Rect16 &r,
AppFunc *cmd)
: gWindow(r, ident, "", cmd) {
prevModeStackCtr = GameMode::getStack(prevModeStackPtr);
- GameMode::SetStack(&PlayMode, &TileMode, &SimpleMode, End_List);
+
+ GameMode *gameModes[] = {&PlayMode, &TileMode, &SimpleMode};
+ GameMode::SetStack(gameModes, 3);
title = stitle;
}
Commit: 1357f1bade69f0f7e8a74a8cf638b77791064a6f
https://github.com/scummvm/scummvm/commit/1357f1bade69f0f7e8a74a8cf638b77791064a6f
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:04+02:00
Commit Message:
SAGA2: Increase noisy message's debug level
Changed paths:
engines/saga2/rserver.cpp
diff --git a/engines/saga2/rserver.cpp b/engines/saga2/rserver.cpp
index 4e3c0673fc..e2b465a3ee 100644
--- a/engines/saga2/rserver.cpp
+++ b/engines/saga2/rserver.cpp
@@ -193,7 +193,7 @@ void cleanupServers(void) {
}
void loadAsyncResources(void) {
- debug(3, "STUB: loadAsyncResources()");
+ debug(6, "STUB: loadAsyncResources()");
#if 0
resourceServer->service();
Commit: 512f1268d7a1f4c001b58043ece32db022a59a85
https://github.com/scummvm/scummvm/commit/512f1268d7a1f4c001b58043ece32db022a59a85
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:04+02:00
Commit Message:
JANITORIAL: Fix formatting
Changed paths:
engines/saga2/patrol.cpp
diff --git a/engines/saga2/patrol.cpp b/engines/saga2/patrol.cpp
index d454a03700..031088d2d7 100644
--- a/engines/saga2/patrol.cpp
+++ b/engines/saga2/patrol.cpp
@@ -94,16 +94,11 @@ void PatrolRouteList::setRouteData(PatrolRouteData *data) {
error("Cannot allocate patrol route list offset array.");
// Iterate through each patrol route a compute its offset
- for (i = 0, currentRoute = (PatrolRoute *)&routeData[1];
- i < noRoutes;
- i++,
- currentRoute =
- (PatrolRoute *) & (*currentRoute)[currentRoute->vertices()]) {
-#if DEBUG
- assert(currentRoute->vertices() > 1);
-#endif
+ for (i = 0, currentRoute = (PatrolRoute *)&routeData[1]; i < noRoutes; i++) {
warning("STUB: PatrolRouteList::setRouteData: unsafe arithmetics");
offsetArray[i] = 0; // FIXME: It was "currentRoute - routeData";
+
+ currentRoute = (PatrolRoute *)&(*currentRoute)[currentRoute->vertices()];
}
}
@@ -191,8 +186,7 @@ void PatrolRouteIterator::altIncrement(void) {
vertexNo++;
- if (vertexNo >= route.vertices()
- && (flags & patrolRouteRepeat)) {
+ if (vertexNo >= route.vertices() && (flags & patrolRouteRepeat)) {
// If repeating, initialize for iteration in the standard
// direction, and reset the waypoint index
flags &= ~patrolRouteInAlternate;
@@ -208,8 +202,7 @@ void PatrolRouteIterator::altDecrement(void) {
vertexNo--;
- if (vertexNo < 0
- && (flags & patrolRouteRepeat)) {
+ if (vertexNo < 0 && (flags & patrolRouteRepeat)) {
// If repeating, initialize for iteration in the standard
// direction, and reset the waypoint index
flags &= ~patrolRouteInAlternate;
Commit: 7d929d67a7471e1bb191c9f89223d8b14f5ef182
https://github.com/scummvm/scummvm/commit/7d929d67a7471e1bb191c9f89223d8b14f5ef182
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:04+02:00
Commit Message:
SAGA2: Initial code cleanup for PatrolRoutes
Changed paths:
engines/saga2/patrol.cpp
engines/saga2/patrol.h
diff --git a/engines/saga2/patrol.cpp b/engines/saga2/patrol.cpp
index 031088d2d7..3b294fc7dd 100644
--- a/engines/saga2/patrol.cpp
+++ b/engines/saga2/patrol.cpp
@@ -35,22 +35,14 @@ namespace Saga2 {
typedef PatrolRouteData *PatrolRouteDataPtr;
-extern int16 worldCount; // Number of worlds
+extern int16 worldCount; // Number of worlds
-/* ===================================================================== *
- Exports
- * ===================================================================== */
+PatrolRouteList *patrolRouteList = nullptr; // Global patrol route array
-PatrolRouteList *patrolRouteList = nullptr; // Global patrol route array
+static PatrolRouteData **patrolRouteData; // Data for patrol routes
-/* ===================================================================== *
- Globals
- * ===================================================================== */
-static PatrolRouteData **patrolRouteData; // Data for patrol routes
-
-
-// Returns a const reference to a specified way point
+// Returns a const reference to a specified way point
const TilePoint &PatrolRoute::operator [](int16 index) const {
return *((TilePoint *)&this[1] + index);
}
@@ -59,44 +51,37 @@ const TilePoint &PatrolRoute::operator [](int16 index) const {
/* ===================================================================== *
PatrolRouteList member functions
* ===================================================================== */
-
-//-----------------------------------------------------------------------
-// Clear the current patrol route data
-
void PatrolRouteList::clearRouteData(void) {
- // If there is an offset array deallocated it.
- if (offsetArray) {
- delete[] offsetArray;
- offsetArray = nullptr;
+ if (_offsetArray) {
+ delete[] _offsetArray;
+ _offsetArray = nullptr;
}
- routeData = nullptr;
+ _routeData = nullptr;
}
//-----------------------------------------------------------------------
// Set up and initialize new patrol route data
-
void PatrolRouteList::setRouteData(PatrolRouteData *data) {
- int16 i,
- noRoutes = data->routes;
+ int16 i, noRoutes = data->routes;
PatrolRoute *currentRoute;
- // If routeData is nullptr simply return
- if ((routeData = data) == nullptr) {
- offsetArray = nullptr;
+ // If routeData is nullptr simply return
+ if ((_routeData = data) == nullptr) {
+ _offsetArray = nullptr;
return;
}
- // Allocate a new offsetArray
- offsetArray = new int32[noRoutes]();
+ // Allocate a new offsetArray
+ _offsetArray = new int32[noRoutes]();
- if (offsetArray == nullptr)
+ if (_offsetArray == nullptr)
error("Cannot allocate patrol route list offset array.");
- // Iterate through each patrol route a compute its offset
- for (i = 0, currentRoute = (PatrolRoute *)&routeData[1]; i < noRoutes; i++) {
+ // Iterate through each patrol route a compute its offset
+ for (i = 0, currentRoute = (PatrolRoute *)&_routeData[1]; i < noRoutes; i++) {
warning("STUB: PatrolRouteList::setRouteData: unsafe arithmetics");
- offsetArray[i] = 0; // FIXME: It was "currentRoute - routeData";
+ _offsetArray[i] = 0; // FIXME: It was "currentRoute - routeData";
currentRoute = (PatrolRoute *)&(*currentRoute)[currentRoute->vertices()];
}
@@ -106,215 +91,182 @@ void PatrolRouteList::setRouteData(PatrolRouteData *data) {
PatrolRouteIterator member functions
* ===================================================================== */
-//-----------------------------------------------------------------------
-// Constructors
-
PatrolRouteIterator::PatrolRouteIterator(uint8 map, int16 rte, uint8 type) :
- mapNum(map),
- routeNo(rte),
- flags(type & 0xF) {
- const PatrolRoute &route = patrolRouteList[mapNum][routeNo];
+ _mapNum(map), _routeNo(rte), _flags(type & 0xF) {
+ const PatrolRoute &route = patrolRouteList[_mapNum][_routeNo];
- if (flags & patrolRouteRandom)
- vertexNo = g_vm->_rnd->getRandomNumber(route.vertices() - 1);
+ if (_flags & patrolRouteRandom)
+ _vertexNo = g_vm->_rnd->getRandomNumber(route.vertices() - 1);
else {
- if (flags & patrolRouteReverse)
- vertexNo = route.vertices() - 1;
+ if (_flags & patrolRouteReverse)
+ _vertexNo = route.vertices() - 1;
else
- vertexNo = 0;
+ _vertexNo = 0;
}
}
-PatrolRouteIterator::PatrolRouteIterator(
- uint8 map,
- int16 rte,
- uint8 type,
- int16 startingPoint) :
- mapNum(map),
- routeNo(rte),
- flags(type & 0xF) {
- const PatrolRoute &route = patrolRouteList[mapNum][routeNo];
-
- vertexNo = clamp(0, startingPoint, route.vertices() - 1);
+PatrolRouteIterator::PatrolRouteIterator(uint8 map, int16 rte, uint8 type, int16 startingPoint) :
+ _mapNum(map), _routeNo(rte), _flags(type & 0xF) {
+ const PatrolRoute &route = patrolRouteList[_mapNum][_routeNo];
+
+ _vertexNo = clamp(0, startingPoint, route.vertices() - 1);
}
//-----------------------------------------------------------------------
// Increment the waypoint index
-
void PatrolRouteIterator::increment(void) {
- const PatrolRoute &route = patrolRouteList[mapNum][routeNo];
-
- vertexNo++;
-
- if (vertexNo >= route.vertices()) {
- if (flags & patrolRouteAlternate) {
- // If alternating, initialize for iteration in the alternate
- // direction
- flags |= patrolRouteInAlternate;
- vertexNo = MAX(route.vertices() - 2, 0);
- } else if (flags & patrolRouteRepeat)
- // If repeating, reset the waypoint index
- vertexNo = 0;
+ const PatrolRoute &route = patrolRouteList[_mapNum][_routeNo];
+
+ _vertexNo++;
+
+ if (_vertexNo >= route.vertices()) {
+ if (_flags & patrolRouteAlternate) {
+ // If alternating, initialize for iteration in the alternate
+ // direction
+ _flags |= patrolRouteInAlternate;
+ _vertexNo = MAX(route.vertices() - 2, 0);
+ } else if (_flags & patrolRouteRepeat)
+ // If repeating, reset the waypoint index
+ _vertexNo = 0;
}
}
//-----------------------------------------------------------------------
// Decrement the waypoint index
-
void PatrolRouteIterator::decrement(void) {
- const PatrolRoute &route = patrolRouteList[mapNum][routeNo];
-
- vertexNo--;
-
- if (vertexNo < 0) {
- if (flags & patrolRouteAlternate) {
- // If alternating, initialize for iteration in the alternate
- // direction
- flags |= patrolRouteInAlternate;
- vertexNo = MIN(1, route.vertices() - 1);
- } else if (flags & patrolRouteRepeat)
- // If repeating, reset the waypoint index
- vertexNo = route.vertices() - 1;
+ const PatrolRoute &route = patrolRouteList[_mapNum][_routeNo];
+
+ _vertexNo--;
+
+ if (_vertexNo < 0) {
+ if (_flags & patrolRouteAlternate) {
+ // If alternating, initialize for iteration in the alternate
+ // direction
+ _flags |= patrolRouteInAlternate;
+ _vertexNo = MIN(1, route.vertices() - 1);
+ } else if (_flags & patrolRouteRepeat)
+ // If repeating, reset the waypoint index
+ _vertexNo = route.vertices() - 1;
}
}
//-----------------------------------------------------------------------
// Increment the waypoint index in the alternate direction
-
void PatrolRouteIterator::altIncrement(void) {
- const PatrolRoute &route = patrolRouteList[mapNum][routeNo];
+ const PatrolRoute &route = patrolRouteList[_mapNum][_routeNo];
- vertexNo++;
+ _vertexNo++;
- if (vertexNo >= route.vertices() && (flags & patrolRouteRepeat)) {
- // If repeating, initialize for iteration in the standard
- // direction, and reset the waypoint index
- flags &= ~patrolRouteInAlternate;
- vertexNo = MAX(route.vertices() - 2, 0);
+ if (_vertexNo >= route.vertices() && (_flags & patrolRouteRepeat)) {
+ // If repeating, initialize for iteration in the standard
+ // direction, and reset the waypoint index
+ _flags &= ~patrolRouteInAlternate;
+ _vertexNo = MAX(route.vertices() - 2, 0);
}
}
//-----------------------------------------------------------------------
// Decrement the waypoint index in the alternate direction
-
void PatrolRouteIterator::altDecrement(void) {
- const PatrolRoute &route = patrolRouteList[mapNum][routeNo];
+ const PatrolRoute &route = patrolRouteList[_mapNum][_routeNo];
- vertexNo--;
+ _vertexNo--;
- if (vertexNo < 0 && (flags & patrolRouteRepeat)) {
- // If repeating, initialize for iteration in the standard
- // direction, and reset the waypoint index
- flags &= ~patrolRouteInAlternate;
- vertexNo = MIN(1, route.vertices() - 1);
+ if (_vertexNo < 0 && (_flags & patrolRouteRepeat)) {
+ // If repeating, initialize for iteration in the standard
+ // direction, and reset the waypoint index
+ _flags &= ~patrolRouteInAlternate;
+ _vertexNo = MIN(1, route.vertices() - 1);
}
}
//-----------------------------------------------------------------------
// Return the coordinates of the current waypoint
+const TilePoint &PatrolRouteIterator::operator*(void) const {
+ const PatrolRoute &route = patrolRouteList[_mapNum][_routeNo];
-const TilePoint &PatrolRouteIterator::operator * (void) const {
- const PatrolRoute &route = patrolRouteList[mapNum][routeNo];
-
- return vertexNo >= 0 && vertexNo < route.vertices()
- ? route[vertexNo]
- : Nowhere;
+ return _vertexNo >= 0 && _vertexNo < route.vertices() ? route[_vertexNo] : Nowhere;
}
-//-----------------------------------------------------------------------
-// Iterate
-
-const PatrolRouteIterator &PatrolRouteIterator::operator++ (void) {
- const PatrolRoute &route = patrolRouteList[mapNum][routeNo];
+const PatrolRouteIterator &PatrolRouteIterator::operator++(void) {
+ const PatrolRoute &route = patrolRouteList[_mapNum][_routeNo];
- if (vertexNo >= 0 & vertexNo < route.vertices()) {
- if (!(flags & patrolRouteRandom)) {
- if (!(flags & patrolRouteInAlternate)) {
- if (!(flags & patrolRouteReverse))
+ if (_vertexNo >= 0 & _vertexNo < route.vertices()) {
+ if (!(_flags & patrolRouteRandom)) {
+ if (!(_flags & patrolRouteInAlternate)) {
+ if (!(_flags & patrolRouteReverse))
increment();
else
decrement();
} else {
- if (!(flags & patrolRouteReverse))
+ if (!(_flags & patrolRouteReverse))
altDecrement();
else
altIncrement();
}
} else {
- vertexNo = g_vm->_rnd->getRandomNumber(route.vertices() - 1);
+ _vertexNo = g_vm->_rnd->getRandomNumber(route.vertices() - 1);
}
}
return *this;
}
-/* ===================================================================== *
- PatrolRoute list management functions
- * ===================================================================== */
-
//-----------------------------------------------------------------------
// Load the patrol routes from the resource file
-
void initPatrolRoutes(void) {
- int16 i;
- hResContext *patrolRouteRes;
+ int16 i;
+ hResContext *patrolRouteRes;
- // Get patrol route resource context
- patrolRouteRes = auxResFile->newContext(MKTAG('P', 'T', 'R', 'L'), "patrol route resource");
+ // Get patrol route resource context
+ patrolRouteRes = auxResFile->newContext(MKTAG('P', 'T', 'R', 'L'), "patrol route resource");
if (patrolRouteRes == nullptr || !patrolRouteRes->_valid)
error("Error accessing patrol route resource group.");
- // Allocate the patrol route list array
+ // Allocate the patrol route list array
patrolRouteList = new PatrolRouteList[worldCount];
if (patrolRouteList == nullptr)
error("Unable to allocate the patrol route list");
- // Allocate the patrol route data pointer array
+ // Allocate the patrol route data pointer array
patrolRouteData = new PatrolRouteDataPtr[worldCount];
if (patrolRouteData == nullptr)
error("Unable to allocate the patrol route data pointers");
for (i = 0; i < worldCount; i++) {
- // Initialize the patrol route data members
- patrolRouteList[i].routeData = nullptr;
- patrolRouteList[i].offsetArray = nullptr;
+ // Initialize the patrol route data members
+ patrolRouteList[i]._routeData = nullptr;
+ patrolRouteList[i]._offsetArray = nullptr;
- // Load this worlds's patrol routes
+ // Load this worlds's patrol routes
if (patrolRouteRes->size(MKTAG('R', 'T', 'E', i)) > 0) {
patrolRouteData[i] = (PatrolRouteData *)LoadResource(patrolRouteRes, MKTAG('R', 'T', 'E', i), "patrol route data");
if (patrolRouteData[i] == nullptr)
error("Unable to load the patrol route data");
- // Initialize the PatrolRouteList with the resource data
+ // Initialize the PatrolRouteList with the resource data
patrolRouteList[i].setRouteData(patrolRouteData[i]);
} else
patrolRouteData[i] = nullptr;
}
- // Dispose of the patrol route resource context
+ // Dispose of the patrol route resource context
auxResFile->disposeContext(patrolRouteRes);
}
-//-----------------------------------------------------------------------
-// Cleanup the patrol routes
-
void cleanupPatrolRoutes(void) {
int16 i;
- // Cleanup the patrol route list
for (i = 0; i < worldCount; i++) {
patrolRouteList[i].clearRouteData();
if (patrolRouteData[i])
free(patrolRouteData[i]);
}
- // Deallocate the patrol route data pointer list
delete[] patrolRouteData;
-
- // Deallocate the patrol route list
delete[] patrolRouteList;
}
diff --git a/engines/saga2/patrol.h b/engines/saga2/patrol.h
index db195b1bde..0fb8b5c788 100644
--- a/engines/saga2/patrol.h
+++ b/engines/saga2/patrol.h
@@ -31,7 +31,7 @@ namespace Saga2 {
class TilePoint;
class PatrolRouteList;
-extern PatrolRouteList *patrolRouteList; // Global patrol route array
+extern PatrolRouteList *patrolRouteList; // Global patrol route array
/* ===================================================================== *
PatrolRoute class
@@ -43,16 +43,16 @@ extern PatrolRouteList *patrolRouteList; // Global patrol route array
// the coordinates of the patrol routes.
class PatrolRoute {
- int16 wayPoints; // The number of way points in this patrol route
+ int16 _wayPoints; // The number of way points in this patrol route
public:
- // Return the number of way points
+ // Return the number of way points
int16 vertices(void) const {
- return wayPoints;
+ return _wayPoints;
}
- // Returns a const reference to a specified way point
- const TilePoint &operator [](int16 index) const;
+ // Returns a const reference to a specified way point
+ const TilePoint &operator[](int16 index) const;
};
/* ===================================================================== *
@@ -64,7 +64,7 @@ public:
// the number of patrol routes, followed by the actual patrol route data.
struct PatrolRouteData {
- int16 routes; // The number of routes in this data
+ int16 routes; // The number of routes in this data
};
/* ===================================================================== *
@@ -78,32 +78,30 @@ struct PatrolRouteData {
// beginning of the patrol route data.
class PatrolRouteList {
-
friend void initPatrolRoutes(void);
friend void cleanupPatrolRoutes(void);
- PatrolRouteData *routeData; // A pointer to the raw patrol route
- // data.
- int32 *offsetArray; // A pointer to a dynaically
- // allocated array of 32-bit offsets.
+ PatrolRouteData *_routeData; // A pointer to the raw patrol route
+ // data.
+ int32 *_offsetArray; // A pointer to a dynaically
+ // allocated array of 32-bit offsets.
public:
- // Remove current patrol route data
+ // Remove current patrol route data
void clearRouteData(void);
- // Set up an initialize new patrol route data
+ // Set up an initialize new patrol route data
void setRouteData(PatrolRouteData *data);
- // Returns the number of patrol routes in the list
+ // Returns the number of patrol routes in the list
int16 routes(void) {
- return routeData ? routeData->routes : 0;
+ return _routeData ? _routeData->routes : 0;
}
- // Returns a reference to the specified patrol route
+ // Returns a reference to the specified patrol route
PatrolRoute &operator [](int16 index) {
// FIXME: This is evil
warning("PartolRoute[]: dangerous pointer arithmetic, this will not work");
- return *((PatrolRoute *)(routeData
- + offsetArray[index]));
+ return *((PatrolRoute *)(_routeData + _offsetArray[index]));
}
};
@@ -117,87 +115,56 @@ public:
enum PatrolRouteIteratorFlags {
- // These flags define the type of iterator, and are only initialized
- // when the iterator is constructed.
- patrolRouteReverse = (1 << 0), // Iterate in reverse
- patrolRouteAlternate = (1 << 1), // Iterate back and forth
- patrolRouteRepeat = (1 << 2), // Iterate repeatedly
- patrolRouteRandom = (1 << 3), // Iterate randomly
+ // These flags define the type of iterator, and are only initialized
+ // when the iterator is constructed.
+ patrolRouteReverse = (1 << 0), // Iterate in reverse
+ patrolRouteAlternate = (1 << 1), // Iterate back and forth
+ patrolRouteRepeat = (1 << 2), // Iterate repeatedly
+ patrolRouteRandom = (1 << 3), // Iterate randomly
- // These flags define the current state of the iterator.
- patrolRouteInAlternate = (1 << 4), // Iterator is currently going in
- // the alternate direction
+ // These flags define the current state of the iterator.
+ patrolRouteInAlternate = (1 << 4) // Iterator is currently going in
+ // the alternate direction
};
class PatrolRouteIterator {
- int16 routeNo, // Index of the patrol route
- vertexNo; // Current waypoint index
-
- uint8 mapNum; // Map in which this route exists
-
- uint8 flags; // various flags
-
- // 6 bytes
+ int16 _routeNo; // Index of the patrol route
+ int16 _vertexNo; // Current waypoint index
+ byte _mapNum; // Map in which this route exists
+ byte _flags; // various flags
public:
- // Default constructor -- do nothing
- PatrolRouteIterator(void) {}
-
- // Copy constructor
- PatrolRouteIterator(const PatrolRouteIterator &iter) {
- // Copy first four bytes
- ((int32 *)this)[0] = ((int32 *)&iter)[0];
- // Copy next two bytes
- *((int16 *) & ((int32 *)this)[1]) =
- *((int16 *) & ((int32 *)&iter)[1]);
- }
-
- // Constructors
+ PatrolRouteIterator() { _routeNo = _vertexNo = 0; _mapNum = _flags = 0;}
PatrolRouteIterator(uint8 map, int16 rte, uint8 type);
- PatrolRouteIterator(
- uint8 map,
- int16 rte,
- uint8 type,
- int16 startingPoint);
-
- // Overloaded assignment operator
- PatrolRouteIterator operator = (const PatrolRouteIterator &iter) {
- // Copy first four bytes
- ((int32 *)this)[0] = ((int32 *)&iter)[0];
- // Copy next two bytes
- *((int16 *) & ((int32 *)this)[1]) =
- *((int16 *) & ((int32 *)&iter)[1]);
-
- return *this;
- }
+ PatrolRouteIterator(uint8 map, int16 rte, uint8 type, int16 startingPoint);
private:
- void increment(void); // Increment waypoint index
- void decrement(void); // Decrement waypoint index
- void altIncrement(void); // Increment in alternate direction
- void altDecrement(void); // Decrement in alternate direction
+ void increment(void); // Increment waypoint index
+ void decrement(void); // Decrement waypoint index
+ void altIncrement(void); // Increment in alternate direction
+ void altDecrement(void); // Decrement in alternate direction
public:
- // Determine if the iterator will repeat infinitely
+ // Determine if the iterator will repeat infinitely
bool isRepeating(void) const {
- return flags & (patrolRouteRepeat | patrolRouteRandom);
+ return _flags & (patrolRouteRepeat | patrolRouteRandom);
}
- // Return the current way point number
+ // Return the current way point number
int16 wayPointNum(void) const {
- return vertexNo;
+ return _vertexNo;
}
- // Return the coordinates of the current waypoint
- const TilePoint &operator * (void) const;
+ // Return the coordinates of the current waypoint
+ const TilePoint &operator*(void) const;
- // Iterate
- const PatrolRouteIterator &operator ++ (void);
+ // Iterate
+ const PatrolRouteIterator &operator++(void);
- // Determine if this iterator is equivalent to the specified iterator
- bool operator == (const PatrolRouteIterator &iter) const {
- return routeNo == iter.routeNo && vertexNo == iter.vertexNo
- && mapNum == iter.mapNum && flags == iter.flags;
+ // Determine if this iterator is equivalent to the specified iterator
+ bool operator==(const PatrolRouteIterator &iter) const {
+ return _routeNo == iter._routeNo && _vertexNo == iter._vertexNo
+ && _mapNum == iter._mapNum && _flags == iter._flags;
}
};
@@ -205,10 +172,10 @@ public:
PatrolRoute list management function prototypes
* ===================================================================== */
-// Load the patrol routes from the resource file
+// Load the patrol routes from the resource file
void initPatrolRoutes(void);
-// Cleanup the patrol routes
+// Cleanup the patrol routes
void cleanupPatrolRoutes(void);
} // end of namespace Saga2
Commit: 26798e29eb74e541a0fb91fed3e811a6c8119226
https://github.com/scummvm/scummvm/commit/26798e29eb74e541a0fb91fed3e811a6c8119226
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:04+02:00
Commit Message:
SAGA2: Rewrote PatrolRoute to Common::Stream and portability fixes
Changed paths:
engines/saga2/assign.cpp
engines/saga2/fta.h
engines/saga2/main.cpp
engines/saga2/patrol.cpp
engines/saga2/patrol.h
engines/saga2/tcoords.h
engines/saga2/tile.cpp
diff --git a/engines/saga2/assign.cpp b/engines/saga2/assign.cpp
index 679632551e..3b661834e9 100644
--- a/engines/saga2/assign.cpp
+++ b/engines/saga2/assign.cpp
@@ -305,7 +305,7 @@ Task *PatrolRouteAssignment::getTask(TaskStack *ts) {
if (startPoint == -1) {
int16 i;
uint16 bestDist = maxuint16;
- const PatrolRoute &route = patrolRouteList[mapNum][routeNo];
+ const PatrolRoute &route = patrolRouteList[mapNum]->getRoute(routeNo);
TilePoint actorLoc = getActor()->getLocation();
for (i = 0; i < route.vertices(); i++) {
diff --git a/engines/saga2/fta.h b/engines/saga2/fta.h
index 584003afd1..956bfa7054 100644
--- a/engines/saga2/fta.h
+++ b/engines/saga2/fta.h
@@ -166,6 +166,7 @@ RHANDLE LoadFileToHandle(char *filename); // load file into relocatable buf
void *LoadResource(hResContext *con, uint32 id, const char desc[]);
RHANDLE LoadResourceToHandle(hResContext *con, uint32 id, const char desc[]);
+Common::SeekableReadStream *loadResourceToStream(hResContext *con, uint32 id, const char desc[]);
// Asynchronous resource loading
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index d050caef7c..9795821639 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -28,6 +28,7 @@
#include "common/debug.h"
#include "common/events.h"
+#include "common/memstream.h"
#include "saga2/std.h"
#include "saga2/setup.h"
@@ -548,6 +549,28 @@ void *LoadResource(hResContext *con, uint32 id, const char desc[]) {
return buffer;
}
+Common::SeekableReadStream *loadResourceToStream(hResContext *con, uint32 id, const char desc[]) {
+ uint32 idString[2];
+ int32 size;
+ uint8 *buffer; // allocated buffer
+
+ idString[0] = id;
+ idString[1] = 0;
+ debugC(3, kDebugResources, "Loading resource %d (%s, %s)", id, tag2str(id), desc);
+
+ size = con->size(id);
+ if (size <= 0 || !con->seek(id)) {
+ error("Error reading resource ID '%s'.", &idString);
+ }
+
+ // Allocate the buffer
+ buffer = (uint8 *)malloc(size);
+ con->read(buffer, size);
+ con->rest();
+
+ return new Common::MemoryReadStream(buffer, size, DisposeAfterUse::YES);
+}
+
//-----------------------------------------------------------------------
// Loads a resource into a relocatable buffer and returns a handle
diff --git a/engines/saga2/patrol.cpp b/engines/saga2/patrol.cpp
index 3b294fc7dd..c4bdb2ac82 100644
--- a/engines/saga2/patrol.cpp
+++ b/engines/saga2/patrol.cpp
@@ -33,58 +33,49 @@
namespace Saga2 {
-typedef PatrolRouteData *PatrolRouteDataPtr;
-
extern int16 worldCount; // Number of worlds
-PatrolRouteList *patrolRouteList = nullptr; // Global patrol route array
+PatrolRouteList **patrolRouteList = nullptr; // Global patrol route array
+
+PatrolRoute::PatrolRoute(Common::SeekableReadStream *stream) {
+ _wayPoints = stream->readSint16LE();
+
+ _route = (TilePoint **)malloc(sizeof(TilePoint *) * _wayPoints);
-static PatrolRouteData **patrolRouteData; // Data for patrol routes
+ for (int i = 0; i < _wayPoints; i++)
+ _route[i] = new TilePoint(stream);
+}
+
+PatrolRoute::~PatrolRoute() {
+ for (int i = 0; i < _wayPoints; i++)
+ delete _route[i];
+ free(_route);
+}
// Returns a const reference to a specified way point
const TilePoint &PatrolRoute::operator [](int16 index) const {
- return *((TilePoint *)&this[1] + index);
+ return *_route[index];
}
/* ===================================================================== *
PatrolRouteList member functions
* ===================================================================== */
-void PatrolRouteList::clearRouteData(void) {
- if (_offsetArray) {
- delete[] _offsetArray;
- _offsetArray = nullptr;
- }
-
- _routeData = nullptr;
-}
+PatrolRouteList::PatrolRouteList(Common::SeekableReadStream *stream) {
+ _numRoutes = stream->readSint16LE();
-//-----------------------------------------------------------------------
-// Set up and initialize new patrol route data
-void PatrolRouteList::setRouteData(PatrolRouteData *data) {
- int16 i, noRoutes = data->routes;
- PatrolRoute *currentRoute;
-
- // If routeData is nullptr simply return
- if ((_routeData = data) == nullptr) {
- _offsetArray = nullptr;
- return;
- }
+ _routes = (PatrolRoute **)malloc(sizeof(PatrolRoute *) * _numRoutes);
- // Allocate a new offsetArray
- _offsetArray = new int32[noRoutes]();
-
- if (_offsetArray == nullptr)
- error("Cannot allocate patrol route list offset array.");
+ for (int i = 0; i < _numRoutes; i++)
+ _routes[i] = new PatrolRoute(stream);
+}
- // Iterate through each patrol route a compute its offset
- for (i = 0, currentRoute = (PatrolRoute *)&_routeData[1]; i < noRoutes; i++) {
- warning("STUB: PatrolRouteList::setRouteData: unsafe arithmetics");
- _offsetArray[i] = 0; // FIXME: It was "currentRoute - routeData";
+PatrolRouteList::~PatrolRouteList() {
+ for (int i = 0; i < _numRoutes; i++)
+ delete _routes[i];
- currentRoute = (PatrolRoute *)&(*currentRoute)[currentRoute->vertices()];
- }
+ free(_routes);
}
/* ===================================================================== *
@@ -93,7 +84,7 @@ void PatrolRouteList::setRouteData(PatrolRouteData *data) {
PatrolRouteIterator::PatrolRouteIterator(uint8 map, int16 rte, uint8 type) :
_mapNum(map), _routeNo(rte), _flags(type & 0xF) {
- const PatrolRoute &route = patrolRouteList[_mapNum][_routeNo];
+ const PatrolRoute &route = patrolRouteList[_mapNum]->getRoute(_routeNo);
if (_flags & patrolRouteRandom)
_vertexNo = g_vm->_rnd->getRandomNumber(route.vertices() - 1);
@@ -107,7 +98,7 @@ PatrolRouteIterator::PatrolRouteIterator(uint8 map, int16 rte, uint8 type) :
PatrolRouteIterator::PatrolRouteIterator(uint8 map, int16 rte, uint8 type, int16 startingPoint) :
_mapNum(map), _routeNo(rte), _flags(type & 0xF) {
- const PatrolRoute &route = patrolRouteList[_mapNum][_routeNo];
+ const PatrolRoute &route = patrolRouteList[_mapNum]->getRoute(_routeNo);
_vertexNo = clamp(0, startingPoint, route.vertices() - 1);
}
@@ -115,7 +106,7 @@ PatrolRouteIterator::PatrolRouteIterator(uint8 map, int16 rte, uint8 type, int16
//-----------------------------------------------------------------------
// Increment the waypoint index
void PatrolRouteIterator::increment(void) {
- const PatrolRoute &route = patrolRouteList[_mapNum][_routeNo];
+ const PatrolRoute &route = patrolRouteList[_mapNum]->getRoute(_routeNo);
_vertexNo++;
@@ -134,7 +125,7 @@ void PatrolRouteIterator::increment(void) {
//-----------------------------------------------------------------------
// Decrement the waypoint index
void PatrolRouteIterator::decrement(void) {
- const PatrolRoute &route = patrolRouteList[_mapNum][_routeNo];
+ const PatrolRoute &route = patrolRouteList[_mapNum]->getRoute(_routeNo);
_vertexNo--;
@@ -153,7 +144,7 @@ void PatrolRouteIterator::decrement(void) {
//-----------------------------------------------------------------------
// Increment the waypoint index in the alternate direction
void PatrolRouteIterator::altIncrement(void) {
- const PatrolRoute &route = patrolRouteList[_mapNum][_routeNo];
+ const PatrolRoute &route = patrolRouteList[_mapNum]->getRoute(_routeNo);
_vertexNo++;
@@ -168,7 +159,7 @@ void PatrolRouteIterator::altIncrement(void) {
//-----------------------------------------------------------------------
// Decrement the waypoint index in the alternate direction
void PatrolRouteIterator::altDecrement(void) {
- const PatrolRoute &route = patrolRouteList[_mapNum][_routeNo];
+ const PatrolRoute &route = patrolRouteList[_mapNum]->getRoute(_routeNo);
_vertexNo--;
@@ -183,13 +174,13 @@ void PatrolRouteIterator::altDecrement(void) {
//-----------------------------------------------------------------------
// Return the coordinates of the current waypoint
const TilePoint &PatrolRouteIterator::operator*(void) const {
- const PatrolRoute &route = patrolRouteList[_mapNum][_routeNo];
+ const PatrolRoute &route = patrolRouteList[_mapNum]->getRoute(_routeNo);
return _vertexNo >= 0 && _vertexNo < route.vertices() ? route[_vertexNo] : Nowhere;
}
const PatrolRouteIterator &PatrolRouteIterator::operator++(void) {
- const PatrolRoute &route = patrolRouteList[_mapNum][_routeNo];
+ const PatrolRoute &route = patrolRouteList[_mapNum]->getRoute(_routeNo);
if (_vertexNo >= 0 & _vertexNo < route.vertices()) {
if (!(_flags & patrolRouteRandom)) {
@@ -215,42 +206,26 @@ const PatrolRouteIterator &PatrolRouteIterator::operator++(void) {
//-----------------------------------------------------------------------
// Load the patrol routes from the resource file
void initPatrolRoutes(void) {
- int16 i;
- hResContext *patrolRouteRes;
-
// Get patrol route resource context
- patrolRouteRes = auxResFile->newContext(MKTAG('P', 'T', 'R', 'L'), "patrol route resource");
+ hResContext *patrolRouteRes = auxResFile->newContext(MKTAG('P', 'T', 'R', 'L'), "patrol route resource");
if (patrolRouteRes == nullptr || !patrolRouteRes->_valid)
error("Error accessing patrol route resource group.");
// Allocate the patrol route list array
- patrolRouteList = new PatrolRouteList[worldCount];
+ patrolRouteList = (PatrolRouteList **)malloc(sizeof(PatrolRouteList *) * worldCount);
if (patrolRouteList == nullptr)
error("Unable to allocate the patrol route list");
- // Allocate the patrol route data pointer array
- patrolRouteData = new PatrolRouteDataPtr[worldCount];
-
- if (patrolRouteData == nullptr)
- error("Unable to allocate the patrol route data pointers");
-
- for (i = 0; i < worldCount; i++) {
- // Initialize the patrol route data members
- patrolRouteList[i]._routeData = nullptr;
- patrolRouteList[i]._offsetArray = nullptr;
+ for (int16 i = 0; i < worldCount; i++) {
+ patrolRouteList[i] = nullptr;
// Load this worlds's patrol routes
if (patrolRouteRes->size(MKTAG('R', 'T', 'E', i)) > 0) {
- patrolRouteData[i] = (PatrolRouteData *)LoadResource(patrolRouteRes, MKTAG('R', 'T', 'E', i), "patrol route data");
+ Common::SeekableReadStream *stream = loadResourceToStream(patrolRouteRes, MKTAG('R', 'T', 'E', i), "patrol route data");
- if (patrolRouteData[i] == nullptr)
- error("Unable to load the patrol route data");
-
- // Initialize the PatrolRouteList with the resource data
- patrolRouteList[i].setRouteData(patrolRouteData[i]);
- } else
- patrolRouteData[i] = nullptr;
+ patrolRouteList[i] = new PatrolRouteList(stream);
+ }
}
// Dispose of the patrol route resource context
@@ -258,16 +233,15 @@ void initPatrolRoutes(void) {
}
void cleanupPatrolRoutes(void) {
- int16 i;
+ if (!patrolRouteList)
+ return;
- for (i = 0; i < worldCount; i++) {
- patrolRouteList[i].clearRouteData();
- if (patrolRouteData[i])
- free(patrolRouteData[i]);
- }
+ for (int16 i = 0; i < worldCount; i++)
+ delete patrolRouteList[i];
+
+ free(patrolRouteList);
- delete[] patrolRouteData;
- delete[] patrolRouteList;
+ patrolRouteList = nullptr;
}
} // end of namespace Saga2
diff --git a/engines/saga2/patrol.h b/engines/saga2/patrol.h
index 0fb8b5c788..a3e5aeedca 100644
--- a/engines/saga2/patrol.h
+++ b/engines/saga2/patrol.h
@@ -31,7 +31,7 @@ namespace Saga2 {
class TilePoint;
class PatrolRouteList;
-extern PatrolRouteList *patrolRouteList; // Global patrol route array
+extern PatrolRouteList **patrolRouteList; // Global patrol route array
/* ===================================================================== *
PatrolRoute class
@@ -44,8 +44,12 @@ extern PatrolRouteList *patrolRouteList; // Global patrol route array
class PatrolRoute {
int16 _wayPoints; // The number of way points in this patrol route
+ TilePoint **_route;
public:
+ PatrolRoute(Common::SeekableReadStream *stream);
+ ~PatrolRoute();
+
// Return the number of way points
int16 vertices(void) const {
return _wayPoints;
@@ -55,18 +59,6 @@ public:
const TilePoint &operator[](int16 index) const;
};
-/* ===================================================================== *
- PatrolRouteData struct
- * ===================================================================== */
-
-// This class represents the patrol route data as it is read in from the
-// resource file. The patrol route data consists of an integer representing
-// the number of patrol routes, followed by the actual patrol route data.
-
-struct PatrolRouteData {
- int16 routes; // The number of routes in this data
-};
-
/* ===================================================================== *
PatrolRouteList class
* ===================================================================== */
@@ -81,27 +73,21 @@ class PatrolRouteList {
friend void initPatrolRoutes(void);
friend void cleanupPatrolRoutes(void);
- PatrolRouteData *_routeData; // A pointer to the raw patrol route
- // data.
- int32 *_offsetArray; // A pointer to a dynaically
- // allocated array of 32-bit offsets.
+ int16 _numRoutes;
+ PatrolRoute **_routes;
public:
- // Remove current patrol route data
- void clearRouteData(void);
- // Set up an initialize new patrol route data
- void setRouteData(PatrolRouteData *data);
+ PatrolRouteList(Common::SeekableReadStream *stream);
+ ~PatrolRouteList();
// Returns the number of patrol routes in the list
int16 routes(void) {
- return _routeData ? _routeData->routes : 0;
+ return _numRoutes;
}
// Returns a reference to the specified patrol route
- PatrolRoute &operator [](int16 index) {
- // FIXME: This is evil
- warning("PartolRoute[]: dangerous pointer arithmetic, this will not work");
- return *((PatrolRoute *)(_routeData + _offsetArray[index]));
+ PatrolRoute &getRoute(int16 index) {
+ return *_routes[index];
}
};
diff --git a/engines/saga2/tcoords.h b/engines/saga2/tcoords.h
index 9cccc1e58e..e5a1240217 100644
--- a/engines/saga2/tcoords.h
+++ b/engines/saga2/tcoords.h
@@ -59,8 +59,9 @@ public:
int16 u,v,z;
// constructors
- TilePoint(){}
- TilePoint( int16 nu, int16 nv, int16 nz ) { u = nu; v = nv; z = nz; }
+ TilePoint() { u = v = z = 0; }
+ TilePoint(int16 nu, int16 nv, int16 nz) { u = nu; v = nv; z = nz; }
+ TilePoint(Common::SeekableReadStream *stream);
// TilePoint operators
friend TilePoint operator+ (TilePoint a, TilePoint b)
@@ -93,18 +94,19 @@ public:
void operator+= (TilePoint a) { u += a.u; v += a.v; z += a.z; }
void operator-= (TilePoint a) { u -= a.u; v -= a.v; z -= a.z; }
- int16 quickHDistance( void )
- {
- int16 au = (int16) abs( u ),
- av = (int16) abs( v );
+ int16 quickHDistance(void) {
+ int16 au = (int16)abs(u),
+ av = (int16)abs(v);
- if (au > av) return (int16)(au + (av >> 1));
- else return (int16)(av + (au >> 1));
+ if (au > av)
+ return (int16)(au + (av >> 1));
+ else
+ return (int16)(av + (au >> 1));
}
- int16 quickDir( void );
+ int16 quickDir(void);
- int16 magnitude( void );
+ int16 magnitude(void);
};
/* ============================================================================ *
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 660b4e4582..7534bcce6a 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -1782,6 +1782,12 @@ void TileToScreenCoords(const TilePoint &tp, Point16 &p) {
p.y = mapHeight - tileScroll.y - ((int32)tp.u + (int32)tp.v) - tp.z;
}
+TilePoint::TilePoint(Common::SeekableReadStream *stream) {
+ u = stream->readSint16LE();
+ v = stream->readSint16LE();
+ z = stream->readSint16LE();
+}
+
//-----------------------------------------------------------------------
// Converts a UV vector into a rough direction vector.
Commit: 57f9908fa4a4f3afb72ebb1dc2fbf29031caf5ef
https://github.com/scummvm/scummvm/commit/57f9908fa4a4f3afb72ebb1dc2fbf29031caf5ef
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:05+02:00
Commit Message:
SAGA2: Fix mainPage initialization
Changed paths:
engines/saga2/towerfta.cpp
diff --git a/engines/saga2/towerfta.cpp b/engines/saga2/towerfta.cpp
index 537f86eca3..b9f8bd5588 100644
--- a/engines/saga2/towerfta.cpp
+++ b/engines/saga2/towerfta.cpp
@@ -273,6 +273,12 @@ TERMINATOR(termDisplayPort) {
INITIALIZER(initPanelSystem) {
initPanels(mainPort);
+ if (mainPort.map == nullptr) {
+ gPixelMap *tmap = new gPixelMap;
+ tmap->size = Point16(screenWidth, screenHeight);
+ tmap->data = new uint8[tmap->bytes()];
+ mainPort.setMap(tmap);
+ }
return TRUE;
}
Commit: cc1e2895972f6cb513e717b9d3e9c4f8605f3400
https://github.com/scummvm/scummvm/commit/cc1e2895972f6cb513e717b9d3e9c4f8605f3400
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:05+02:00
Commit Message:
SAGA2: Set blip relative to mainPort
Changed paths:
engines/saga2/floating.cpp
engines/saga2/gdraw.cpp
engines/saga2/playmode.cpp
diff --git a/engines/saga2/floating.cpp b/engines/saga2/floating.cpp
index b73249e919..bbe6a19d25 100644
--- a/engines/saga2/floating.cpp
+++ b/engines/saga2/floating.cpp
@@ -61,6 +61,7 @@ extern Rect16 tileRect;
extern gPixelMap tileDrawMap;
extern Point16 fineScroll;
extern gFont *mainFont;
+extern gDisplayPort mainPort;
extern bool allPlayerActorsDead;
@@ -560,6 +561,10 @@ void updateWindowSection(const Rect16 &r) {
tempPort.setMap(&tempMap);
tempPort.setMode(drawModeReplace);
+ // Compute the offset of the local blits (used by drawClipped)
+
+ offset = Point16(clip.x, clip.y);
+ tempPort.setOrigin(offset);
// Compute the intersection of the animated area with the clip
// rectangle. If they overlap, then copy part of the animated
@@ -593,10 +598,6 @@ void updateWindowSection(const Rect16 &r) {
animClip.width, animClip.height);
}
- // Compute the offset of the local blits (used by drawClipped)
-
- offset = Point16(clip.x, clip.y);
-
// For each window, both background and float, that overlaps
// the clip, draw the window's imagery
if (userControlsSetup) {
diff --git a/engines/saga2/gdraw.cpp b/engines/saga2/gdraw.cpp
index ff4559780b..c2bfc23591 100644
--- a/engines/saga2/gdraw.cpp
+++ b/engines/saga2/gdraw.cpp
@@ -24,6 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#include "graphics/surface.h"
#include "saga2/std.h"
#include "saga2/gdraw.h"
#include "saga2/gblitter.h"
@@ -609,7 +610,6 @@ void gPort::bltPixels(
sect;
uint8 *src_line,
*dst_line;
-
sect = intersect(clip, r);
if (!sect.empty()) { // if result is non-empty
@@ -618,8 +618,8 @@ void gPort::bltPixels(
src_line = src.data + src_y * src.size.x + src_x;
dst_line = baseRow
- + (sect.y + origin.y) * rowMod
- + sect.x + origin.x;
+ + sect.y * rowMod
+ + sect.x;
if (drawMode == drawModeMatte) { // Matte drawing mode
for (int h = sect.height; h > 0; h--, src_line += src.size.x, dst_line += rowMod) {
@@ -675,6 +675,14 @@ void gPort::bltPixels(
}
}
}
+
+ //assert(map->size.x != 121 && map->size.y != 30);
+ //assert(map->size.x != 374 && map->size.y != 146);
+ Graphics::Surface sur;
+ sur.create(map->size.x, map->size.y, Graphics::PixelFormat::createFormatCLUT8());
+ sur.setPixels(map->data);
+ //sur.debugPrint();
+ g_system->copyRectToScreen(map->data, rowMod, origin.x, origin.y, map->size.x, map->size.y);
}
/****** gdraw.cpp/gPort::bltPixelMask ********************************
diff --git a/engines/saga2/playmode.cpp b/engines/saga2/playmode.cpp
index e7c3e950a8..091e032872 100644
--- a/engines/saga2/playmode.cpp
+++ b/engines/saga2/playmode.cpp
@@ -337,23 +337,11 @@ void drawCompressedImage(gPort &port, const Point16 pos, void *image) {
map.data = (uint8 *)hdr->data;
port.setMode(drawModeMatte);
- if (port.map == nullptr) {
- gPixelMap *tmap = new gPixelMap;
- tmap->size = map.size;
- tmap->data = new uint8[map.bytes()];
- port.setMap(tmap);
- }
port.bltPixels(map, 0, 0,
pos.x, pos.y,
map.size.x, map.size.y);
- Graphics::Surface sur;
- sur.create(port.map->size.x, port.map->size.y, Graphics::PixelFormat::createFormatCLUT8());
- sur.setPixels(port.map->data);
-
- //sur.debugPrint();
- g_system->copyRectToScreen(sur.getPixels(), sur.pitch, 0, 0, sur.w, sur.h);
if (hdr->compress)
delete[] map.data;
Commit: 79e1a95181242d49f7add6881b174e0c595d4b46
https://github.com/scummvm/scummvm/commit/79e1a95181242d49f7add6881b174e0c595d4b46
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:05+02:00
Commit Message:
SAGA2: Fix gDisplayPage::bltPixels
Changed paths:
engines/saga2/vwdraw.cpp
engines/saga2/vwpage.cpp
diff --git a/engines/saga2/vwdraw.cpp b/engines/saga2/vwdraw.cpp
index e6c426af95..e94e20b250 100644
--- a/engines/saga2/vwdraw.cpp
+++ b/engines/saga2/vwdraw.cpp
@@ -93,6 +93,7 @@ void gDisplayPort::bltPixels(
sect;
uint8 *src_line;
+ clip = Rect16(0, 0, map->size.x, map->size.y);
sect = intersect(clip, r);
if (!sect.empty()) { // if result is non-empty
diff --git a/engines/saga2/vwpage.cpp b/engines/saga2/vwpage.cpp
index fa5fa57895..ab702ecc6c 100644
--- a/engines/saga2/vwpage.cpp
+++ b/engines/saga2/vwpage.cpp
@@ -78,7 +78,7 @@ public:
#ifndef KLUDGE
static bool displayEnabled(void) {
- return (ddWindow != NULL);
+ return true;
}
#endif
@@ -480,14 +480,7 @@ void vWDisplayPage::writePixels(Rect16 &r, uint8 *pixPtr, uint16 pixMod) {
wRect.right = r.x + r.width;
wRect.bottom = r.y + r.height;
- // FIXME: Debug purposes-code for displaying things on the screen
- // updateScreen should not be called here
- warning("FIXME: writePixels");
- Graphics::Surface sur;
- sur.create(r.width, r.height, Graphics::PixelFormat::createFormatCLUT8());
- sur.setPixels(pixPtr);
- //sur.debugPrint();
- g_system->copyRectToScreen(sur.getPixels(), sur.pitch, r.x, r.y, sur.w, sur.h);
+ g_system->copyRectToScreen(pixPtr, pixMod, r.x, r.y, r.width, r.height);
g_system->updateScreen();
//_BltPixels(pixPtr, pixMod, dstPtr, ddWindow->lPitch, r.width, r.height);
@@ -514,11 +507,15 @@ void vWDisplayPage::readPixels(Rect16 &r, uint8 *pixPtr, uint16 pixMod) {
// Function to quickly transfer pixels from an off-screen
// buffer to a rectangle on the SVGA display;
void vWDisplayPage::writeColorPixels(Rect16 r, uint8 *pixPtr, uint16 pixMod, uint8 color) {
+ warning("STUB: writeColorPixels");
+ writePixels(r, pixPtr, pixMod);
}
// Function to quickly transfer pixels from an off-screen
// buffer to a rectangle on the SVGA display;
void vWDisplayPage::writeComplementPixels(Rect16 r, uint8 *pixPtr, uint16 pixMod, uint8 color) {
+ warning("STUB: writeComplementPixels");
+ writePixels(r, pixPtr, pixMod);
}
} // end of namespace Saga2
Commit: 68dd738ec8f02c0b448b514e7e47d0bc70d13207
https://github.com/scummvm/scummvm/commit/68dd738ec8f02c0b448b514e7e47d0bc70d13207
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:05+02:00
Commit Message:
SAGA2: Plug memory leak
Changed paths:
engines/saga2/patrol.cpp
diff --git a/engines/saga2/patrol.cpp b/engines/saga2/patrol.cpp
index c4bdb2ac82..99abfb2708 100644
--- a/engines/saga2/patrol.cpp
+++ b/engines/saga2/patrol.cpp
@@ -225,6 +225,8 @@ void initPatrolRoutes(void) {
Common::SeekableReadStream *stream = loadResourceToStream(patrolRouteRes, MKTAG('R', 'T', 'E', i), "patrol route data");
patrolRouteList[i] = new PatrolRouteList(stream);
+
+ delete stream;
}
}
Commit: 1c562392a030668dcc6f85c6bd2a870c04897eae
https://github.com/scummvm/scummvm/commit/1c562392a030668dcc6f85c6bd2a870c04897eae
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:05+02:00
Commit Message:
SAGA2: Complete vWDisplayPage::writeTransPixels(). This fixes text rendering
Changed paths:
engines/saga2/vwpage.cpp
diff --git a/engines/saga2/vwpage.cpp b/engines/saga2/vwpage.cpp
index ab702ecc6c..501cf707d6 100644
--- a/engines/saga2/vwpage.cpp
+++ b/engines/saga2/vwpage.cpp
@@ -495,8 +495,11 @@ void vWDisplayPage::writeTransPixels(Rect16 &r, uint8 *pixPtr, uint16 pixMod) {
if (!displayEnabled()) //ddWindow || !ddWindow->bIsActive )
return;
- warning("STUB: writeTransPixels, transparency is ignored");
- g_system->copyRectToScreen(pixPtr, pixMod, r.x, r.y, r.width, r.height);
+ Graphics::Surface *surf = g_system->lockScreen();
+
+ _BltPixelsT(pixPtr, pixMod, (byte *)surf->getBasePtr(r.x, r.y), surf->pitch, r.width, r.height );
+
+ g_system->unlockScreen();
}
#endif
Commit: 67688d5eb1caf1ebeda2a4caecc52cc5681f1032
https://github.com/scummvm/scummvm/commit/67688d5eb1caf1ebeda2a4caecc52cc5681f1032
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:05+02:00
Commit Message:
SAGA2: Implemented more graphics-related methods
Changed paths:
engines/saga2/blitters.cpp
engines/saga2/vwpage.cpp
diff --git a/engines/saga2/blitters.cpp b/engines/saga2/blitters.cpp
index 29b0105582..5c6259138c 100644
--- a/engines/saga2/blitters.cpp
+++ b/engines/saga2/blitters.cpp
@@ -60,11 +60,15 @@ void _BltPixelsT(uint8 *srcPtr, uint32 srcMod, uint8 *dstPtr, uint32 dstMod, uin
}
void _FillRect(uint8 *dstPtr, uint32 dstMod, uint32 width, uint32 height, uint32 color) {
- warning("STUB: _FillRect()");
+ for (uint y = 0; y < height; y++) {
+ memset(dstPtr, color, width);
+
+ dstPtr += dstMod;
+ }
}
void _HLine(uint8 *dstPtr, uint32 width, uint32 color) {
- warning("STUB: _HLine()");
+ memset(dstPtr, color, width);
}
void unpackImage(gPixelMap &map, int16 width, int16 rowCount, int8 *srcData) {
diff --git a/engines/saga2/vwpage.cpp b/engines/saga2/vwpage.cpp
index 501cf707d6..afc46c068a 100644
--- a/engines/saga2/vwpage.cpp
+++ b/engines/saga2/vwpage.cpp
@@ -402,25 +402,11 @@ uint8 vWDisplayPage::getPixel(int x, int y) {
// Fill a rectangle on the SVGA display. Note the rect must
// be correct -- there is no clipping or error checking...
void vWDisplayPage::fillRect(Rect16 r, uint8 color) {
-#if 0
- uint8 *dstPtr;
-
- if (!displayEnabled()) //ddWindow || !ddWindow->bIsActive )
- return;
-
- dstPtr = (uint8 *)ddWindow->LockBackBuffer(NULL);
- if (!dstPtr) {
- gError::warn("Failed buffer lock");
- return ;
- }
-
+ Graphics::Surface *surf = g_system->lockScreen();
- _FillRect(dstPtr + (r.y * ddWindow->lPitch) + r.x, ddWindow->lPitch,
- r.width, r.height, color);
+ _FillRect((byte *)surf->getBasePtr(r.x, r.y), surf->pitch, r.width, r.height, color);
- ddWindow->UnlockBackBuffer(dstPtr);
-#endif
- warning("STUBL: fillRect");
+ g_system->unlockScreen();
}
// Fill a rectangle on the SVGA display. Note the rect must
@@ -429,42 +415,17 @@ void vWDisplayPage::invertRect(Rect16 r, uint8 color) {
}
void vWDisplayPage::hLine(int16 x, int16 y, int16 width, uint8 color) {
-#if 0
- uint8 *dstPtr;
-
- if (!displayEnabled()) //ddWindow || !ddWindow->bIsActive )
- return;
-
- dstPtr = (uint8 *)ddWindow->LockBackBuffer(NULL);
- if (!dstPtr) {
- gError::warn("Failed buffer lock");
- return;
- }
+ Graphics::Surface *surf = g_system->lockScreen();
+ _HLine((byte *)surf->getBasePtr(x, y), width, color);
- _HLine(dstPtr + (y * ddWindow->lPitch) + x, width, color);
- ddWindow->UnlockBackBuffer(dstPtr);
-#endif
- warning("STUB: hLine");
+ g_system->unlockScreen();
}
void vWDisplayPage::vLine(int16 x, int16 y, int16 height, uint8 color) {
-#if 0
- uint8 *dstPtr;
-
- if (!displayEnabled()) //ddWindow || !ddWindow->bIsActive )
- return;
-
- dstPtr = (uint8 *)ddWindow->LockBackBuffer(NULL);
- if (!dstPtr) {
- gError::warn("Failed buffer lock");
- return;
- }
+ Graphics::Surface *surf = g_system->lockScreen();
- _FillRect(dstPtr + (y * ddWindow->lPitch) + x, ddWindow->lPitch, 1, height, color);
- ddWindow->UnlockBackBuffer(dstPtr);
-#endif
- warning("STUB: vLine");
+ _FillRect((byte *)surf->getBasePtr(x, y), surf->pitch, 1, height, color);
}
Commit: 58cd891353ece84f64336266251c4db6c0057695
https://github.com/scummvm/scummvm/commit/58cd891353ece84f64336266251c4db6c0057695
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:05+02:00
Commit Message:
SAGA2: Remove unused graphics primitives
Changed paths:
engines/saga2/vdraw.h
engines/saga2/vpage.h
engines/saga2/vwdraw.cpp
engines/saga2/vwpage.cpp
diff --git a/engines/saga2/vdraw.h b/engines/saga2/vdraw.h
index 2220136efe..ff1f14fc8e 100644
--- a/engines/saga2/vdraw.h
+++ b/engines/saga2/vdraw.h
@@ -43,26 +43,10 @@ public:
clip = Rect16(0, 0, dPage->size.x, dPage->size.y);
}
- void setPixel(int16 x, int16 y, gPen color) {
- if (x >= clip.x && x < clip.x + clip.width
- && y >= clip.y && y < clip.y + clip.height) {
- displayPage->setPixel(x + origin.x, y + origin.y, color);
- }
- }
-
- gPen getPixel(int16 x, int16 y) {
- return displayPage->getPixel(x + origin.x, y + origin.y);
- }
- gPen getPixel(Point16 p) {
- return displayPage->getPixel(p.x + origin.x, p.y + origin.y);
- }
-
// Lowest-level drawing functions, (virtually) retargeted to
// call SVGA drawing routines
void fillRect(const Rect16 r);
- void hLine(int16 x, int16 y, int16 width);
- void vLine(int16 x, int16 y, int16 height);
void clear(void) {
displayPage->fillRect(clip, fgPen);
diff --git a/engines/saga2/vpage.h b/engines/saga2/vpage.h
index b40c5d5860..68cd5018e9 100644
--- a/engines/saga2/vpage.h
+++ b/engines/saga2/vpage.h
@@ -41,18 +41,11 @@ public:
virtual void setReadBank(uint16) {}
#endif
- // Function to set and get pixel
- virtual void setPixel(int x, int y, uint8 color);
- virtual uint8 getPixel(int x, int y);
-
// Basic rectangle drawing function
virtual void fillRect(Rect16 r, uint8 color);
// Complement mode drawing function
virtual void invertRect(Rect16 r, uint8 color);
- virtual void hLine(int16 x, int16 y, int16 width, uint8 color);
- virtual void vLine(int16 x, int16 y, int16 height, uint8 color);
-
// REM: General rectangular display blitting function
// REM: Special-case blitting functions
diff --git a/engines/saga2/vwdraw.cpp b/engines/saga2/vwdraw.cpp
index e94e20b250..d6eacdc34e 100644
--- a/engines/saga2/vwdraw.cpp
+++ b/engines/saga2/vwdraw.cpp
@@ -52,33 +52,6 @@ void gDisplayPort::fillRect(const Rect16 r) {
}
}
-void gDisplayPort::hLine(int16 x, int16 y, int16 width) {
- Rect16 sect;
-
- // Temporarily convert the coords into a rectangle, for
- // easy clipping
-
- sect = intersect(clip, Rect16(x, y, width, 1));
- sect.x += origin.x; // apply origin translate
- sect.y += origin.y;
-
- if (!sect.empty()) // if result is non-empty
- displayPage->hLine(sect.x, sect.y, sect.width, fgPen);
-}
-
-void gDisplayPort::vLine(int16 x, int16 y, int16 height) {
- Rect16 sect;
-
- // Temporarily convert the coords into a rectangle, for
- // easy clipping
-
- sect = intersect(clip, Rect16(x, y, 1, height));
- sect.x += origin.x; // apply origin translate
- sect.y += origin.y;
-
- if (!sect.empty()) // if result is non-empty
- displayPage->vLine(sect.x, sect.y, sect.height, fgPen);
-}
// movePixels
void gDisplayPort::bltPixels(
diff --git a/engines/saga2/vwpage.cpp b/engines/saga2/vwpage.cpp
index afc46c068a..229064f9ca 100644
--- a/engines/saga2/vwpage.cpp
+++ b/engines/saga2/vwpage.cpp
@@ -43,38 +43,6 @@ void WriteToLogFile(char *, ...);
* ===================================================================== */
#define vWDisplayPage vDisplayPage
-/*
-class vWDisplayPage : public vDisplayPage {
-public:
-
- // Function to set and get pixel
- void setPixel( int x, int y, uint8 color );
- uint8 getPixel( int x, int y );
-
- // Basic rectangle drawing function
- void fillRect( Rect16 r, uint8 color );
- // Complement mode drawing function
- void invertRect( Rect16 r, uint8 color );
-
- void hLine( int16 x, int16 y, int16 width, uint8 color );
- void vLine( int16 x, int16 y, int16 height, uint8 color );
-
- // REM: General rectangular display blitting function
- // REM: Special-case blitting functions
-
- // General-purpose blitting functions to transfer data
- // from svga to offscreen buffer and vice versa
- // (dispRect is the rectangle on the SVGA page, pixPtr
- // is the buffer to transfer the pixels to/from, and
- // pixMod is the line modulus of the buffer.)
-
- void readPixels( Rect16 &dispRect, uint8 *pixPtr, uint16 pixMod );
- void writePixels( Rect16 &dispRect, uint8 *pixPtr, uint16 pixMod );
- void writeTransPixels( Rect16 &dispRect, uint8 *pixPtr, uint16 pixMod );
- void writeColorPixels( Rect16 dispRect, uint8 *pixPtr, uint16 pixMod, uint8 color );
- void writeComplementPixels( Rect16 dispRect, uint8 *pixPtr, uint16 pixMod, uint8 color );
-};
-*/
#ifndef KLUDGE
static bool displayEnabled(void) {
@@ -354,51 +322,6 @@ void BltDDRect(Rect16 &r, uint8 *srcPtr, bool bTransparent, uint16 pixMod, bool
Member functions for display page
* ===================================================================== */
-void vWDisplayPage::setPixel(int x, int y, uint8 color) {
-#if 0
- uint8 *dstptr;
-
- if (!displayEnabled()) //ddWindow || !ddWindow->bIsActive )
- return;
-
- dstptr = (uint8 *)ddWindow->LockBackBuffer(NULL);
- if (dstptr == NULL) {
- gError::warn("Failed buffer lock");
- return;
- }
-
-
- dstptr [(y * ddWindow->lPitch) + x] = color;
-
- ddWindow->UnlockBackBuffer(dstptr);
-#endif
- warning("STUB: setPixel");
-}
-
-uint8 vWDisplayPage::getPixel(int x, int y) {
-#if 0
- uint8 *dstPtr;
- uint8 retValue;
-
- if (!displayEnabled()) //ddWindow || !ddWindow->bIsActive )
- return 0;
-
- dstPtr = (uint8 *)ddWindow->LockBackBuffer(NULL);
-
- if (!dstPtr) {
- gError::warn("Failed buffer lock");
- return 0;
- }
-
- retValue = dstPtr[(y * ddWindow->lPitch) + x];
- ddWindow->UnlockBackBuffer(dstPtr);
-
- return retValue;
-#endif
- warning("STUB: vWDisplayPage::GetPixel");
- return 0;
-}
-
// Fill a rectangle on the SVGA display. Note the rect must
// be correct -- there is no clipping or error checking...
void vWDisplayPage::fillRect(Rect16 r, uint8 color) {
@@ -414,21 +337,6 @@ void vWDisplayPage::fillRect(Rect16 r, uint8 color) {
void vWDisplayPage::invertRect(Rect16 r, uint8 color) {
}
-void vWDisplayPage::hLine(int16 x, int16 y, int16 width, uint8 color) {
- Graphics::Surface *surf = g_system->lockScreen();
-
- _HLine((byte *)surf->getBasePtr(x, y), width, color);
-
- g_system->unlockScreen();
-}
-
-void vWDisplayPage::vLine(int16 x, int16 y, int16 height, uint8 color) {
- Graphics::Surface *surf = g_system->lockScreen();
-
- _FillRect((byte *)surf->getBasePtr(x, y), surf->pitch, 1, height, color);
-}
-
-
#define USE_BLTDDRECT
// -- we'll want to use this when we figure out why bltDDRect doesnt work here
#define USE_RECT
Commit: ab19d4437bc18a9e6c4217c2f304e641d0ddf4d2
https://github.com/scummvm/scummvm/commit/ab19d4437bc18a9e6c4217c2f304e641d0ddf4d2
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:05+02:00
Commit Message:
SAGA2: Remove unnecessary drawing code
Changed paths:
engines/saga2/floating.cpp
engines/saga2/gdraw.cpp
engines/saga2/vwpage.cpp
diff --git a/engines/saga2/floating.cpp b/engines/saga2/floating.cpp
index bbe6a19d25..b5f0b772d6 100644
--- a/engines/saga2/floating.cpp
+++ b/engines/saga2/floating.cpp
@@ -561,10 +561,6 @@ void updateWindowSection(const Rect16 &r) {
tempPort.setMap(&tempMap);
tempPort.setMode(drawModeReplace);
- // Compute the offset of the local blits (used by drawClipped)
-
- offset = Point16(clip.x, clip.y);
- tempPort.setOrigin(offset);
// Compute the intersection of the animated area with the clip
// rectangle. If they overlap, then copy part of the animated
@@ -598,6 +594,10 @@ void updateWindowSection(const Rect16 &r) {
animClip.width, animClip.height);
}
+ // Compute the offset of the local blits (used by drawClipped)
+
+ offset = Point16(clip.x, clip.y);
+
// For each window, both background and float, that overlaps
// the clip, draw the window's imagery
if (userControlsSetup) {
diff --git a/engines/saga2/gdraw.cpp b/engines/saga2/gdraw.cpp
index c2bfc23591..ff4559780b 100644
--- a/engines/saga2/gdraw.cpp
+++ b/engines/saga2/gdraw.cpp
@@ -24,7 +24,6 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "graphics/surface.h"
#include "saga2/std.h"
#include "saga2/gdraw.h"
#include "saga2/gblitter.h"
@@ -610,6 +609,7 @@ void gPort::bltPixels(
sect;
uint8 *src_line,
*dst_line;
+
sect = intersect(clip, r);
if (!sect.empty()) { // if result is non-empty
@@ -618,8 +618,8 @@ void gPort::bltPixels(
src_line = src.data + src_y * src.size.x + src_x;
dst_line = baseRow
- + sect.y * rowMod
- + sect.x;
+ + (sect.y + origin.y) * rowMod
+ + sect.x + origin.x;
if (drawMode == drawModeMatte) { // Matte drawing mode
for (int h = sect.height; h > 0; h--, src_line += src.size.x, dst_line += rowMod) {
@@ -675,14 +675,6 @@ void gPort::bltPixels(
}
}
}
-
- //assert(map->size.x != 121 && map->size.y != 30);
- //assert(map->size.x != 374 && map->size.y != 146);
- Graphics::Surface sur;
- sur.create(map->size.x, map->size.y, Graphics::PixelFormat::createFormatCLUT8());
- sur.setPixels(map->data);
- //sur.debugPrint();
- g_system->copyRectToScreen(map->data, rowMod, origin.x, origin.y, map->size.x, map->size.y);
}
/****** gdraw.cpp/gPort::bltPixelMask ********************************
diff --git a/engines/saga2/vwpage.cpp b/engines/saga2/vwpage.cpp
index 229064f9ca..b7b9438e22 100644
--- a/engines/saga2/vwpage.cpp
+++ b/engines/saga2/vwpage.cpp
@@ -342,24 +342,9 @@ void vWDisplayPage::invertRect(Rect16 r, uint8 color) {
#define USE_RECT
void vWDisplayPage::writePixels(Rect16 &r, uint8 *pixPtr, uint16 pixMod) {
- Common::Rect wRect;
-
- wRect.left = r.x;
- wRect.top = r.y;
- wRect.right = r.x + r.width;
- wRect.bottom = r.y + r.height;
-
g_system->copyRectToScreen(pixPtr, pixMod, r.x, r.y, r.width, r.height);
- g_system->updateScreen();
-
- //_BltPixels(pixPtr, pixMod, dstPtr, ddWindow->lPitch, r.width, r.height);
}
-#ifndef USE_RECT
-void vWDisplayPage::writeTransPixels(Rect16 &r, uint8 *pixPtr, uint16 pixMod) {
- BltDDRect(r, pixPtr, TRUE, pixMod, TRUE);
-}
-#else
void vWDisplayPage::writeTransPixels(Rect16 &r, uint8 *pixPtr, uint16 pixMod) {
if (!displayEnabled()) //ddWindow || !ddWindow->bIsActive )
return;
@@ -370,7 +355,6 @@ void vWDisplayPage::writeTransPixels(Rect16 &r, uint8 *pixPtr, uint16 pixMod) {
g_system->unlockScreen();
}
-#endif
void vWDisplayPage::readPixels(Rect16 &r, uint8 *pixPtr, uint16 pixMod) {
BltDDRect(r, pixPtr, FALSE, pixMod, FALSE);
Commit: 555a2053da90e3387d3bfe70e9b0ba3730f3b95f
https://github.com/scummvm/scummvm/commit/555a2053da90e3387d3bfe70e9b0ba3730f3b95f
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:05+02:00
Commit Message:
SAGA2: Fix cursor location
Changed paths:
engines/saga2/gpointer.cpp
diff --git a/engines/saga2/gpointer.cpp b/engines/saga2/gpointer.cpp
index a4c7e7b847..7e84e7f540 100644
--- a/engines/saga2/gpointer.cpp
+++ b/engines/saga2/gpointer.cpp
@@ -225,7 +225,7 @@ void gMousePointer::setImage(
pointerImage = &img;
currentPosition = pos + offsetPosition;
- CursorMan.replaceCursor(img.data, img.size.x, img.size.y, x, y, 0);
+ CursorMan.replaceCursor(img.data, img.size.x, img.size.y, x + img.size.x, y, 0);
CursorMan.showMouse(true);
show();
}
Commit: 4a7092c4491b46e85f7159e6eb6bfa641cc2e90f
https://github.com/scummvm/scummvm/commit/4a7092c4491b46e85f7159e6eb6bfa641cc2e90f
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:06+02:00
Commit Message:
SAGA2: Fix cursor location again
Changed paths:
engines/saga2/gpointer.cpp
diff --git a/engines/saga2/gpointer.cpp b/engines/saga2/gpointer.cpp
index 7e84e7f540..3e8b2fedaf 100644
--- a/engines/saga2/gpointer.cpp
+++ b/engines/saga2/gpointer.cpp
@@ -225,7 +225,7 @@ void gMousePointer::setImage(
pointerImage = &img;
currentPosition = pos + offsetPosition;
- CursorMan.replaceCursor(img.data, img.size.x, img.size.y, x + img.size.x, y, 0);
+ CursorMan.replaceCursor(img.data, img.size.x, img.size.y, -x, -y, 0);
CursorMan.showMouse(true);
show();
}
Commit: c35f98e9f0106e57fe00006dab19bf13423a64d8
https://github.com/scummvm/scummvm/commit/c35f98e9f0106e57fe00006dab19bf13423a64d8
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:06+02:00
Commit Message:
SAGA2: Remove unneccessary cursor drawing code
Changed paths:
engines/saga2/gpointer.cpp
diff --git a/engines/saga2/gpointer.cpp b/engines/saga2/gpointer.cpp
index 3e8b2fedaf..f7d990fa3a 100644
--- a/engines/saga2/gpointer.cpp
+++ b/engines/saga2/gpointer.cpp
@@ -64,46 +64,7 @@ bool gMousePointer::init(Point16 pointerLimits) {
// Private routine to draw the mouse pointer image
void gMousePointer::draw(void) {
-#if defined( USEWINDOWS )
- if (useWinCursor)
- return;
-#endif
-
- if (pointerImage && hideCount < 1 && saveMap.data) {
- // Compute the area actually drawn
-
- saveExtent =
- intersect(videoPort->clip,
- Rect16(currentPosition.x, currentPosition.y,
- pointerImage->size.x, pointerImage->size.y));
-
- // Added this to fix a shortcoming of intersect().
- if (saveExtent.width <= 0 || saveExtent.height <= 0) {
- shown = 0;
- return;
- }
-
- // blit from the screen to the backsave buffer
- videoPort->displayPage->readPixels(saveExtent,
- saveMap.data,
- saveMap.size.x);
-
- // Draw the actual pointer (the color-remapped one)
- enum draw_modes saveMode = videoPort->drawMode;// current drawing mode
-
- videoPort->setMode(drawModeMatte);
- videoPort->bltPixels(
- *pointerImage,
- 0, 0,
- currentPosition.x, currentPosition.y,
- pointerImage->size.x, pointerImage->size.y);
-
- // undo any changes we did to the port
- videoPort->setMode(saveMode);
- shown = 1;
- } else {
- shown = 0;
- }
+ CursorMan.showMouse(true);
}
// Private routine to restore the mouse pointer image
Commit: 9d92c179284f5e272c153b646fe2a569543ce8e3
https://github.com/scummvm/scummvm/commit/9d92c179284f5e272c153b646fe2a569543ce8e3
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:06+02:00
Commit Message:
SAGA2: Replace rmem in grabinfo.cpp
Changed paths:
engines/saga2/grabinfo.cpp
diff --git a/engines/saga2/grabinfo.cpp b/engines/saga2/grabinfo.cpp
index 4ab565a829..1cf34b4815 100644
--- a/engines/saga2/grabinfo.cpp
+++ b/engines/saga2/grabinfo.cpp
@@ -57,7 +57,7 @@ GrabInfo::GrabInfo() {
GrabInfo::~GrabInfo() {
if (pointerMap.data != NULL)
- RDisposePtr(pointerMap.data);
+ delete[] pointerMap.data;
}
// set the move count based on val and whether the object is
@@ -193,7 +193,7 @@ void GrabInfo::setIcon(void) {
mapBytes = spr->size.x * spr->size.y;
if ((mapData
- = (uint8 *)RNewPtr(mapBytes, NULL, "Mouse icon data"))
+ = new uint8[mapBytes]())
!= NULL) {
// Clear out the image data
memset(mapData, 0, mapBytes);
@@ -217,7 +217,7 @@ void GrabInfo::clearIcon(void) {
assert(grabObj == NULL);
if (pointerMap.data != NULL) {
- RDisposePtr(pointerMap.data);
+ delete[] pointerMap.data;
pointerMap.size.x = 0;
pointerMap.size.y = 0;
pointerMap.data = NULL;
Commit: b9e04f912e8946ad6eff8d65174a234a9ec309bd
https://github.com/scummvm/scummvm/commit/b9e04f912e8946ad6eff8d65174a234a9ec309bd
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:06+02:00
Commit Message:
SAGA2: Cleanup grabinfo.cpp
Changed paths:
engines/saga2/grabinfo.cpp
diff --git a/engines/saga2/grabinfo.cpp b/engines/saga2/grabinfo.cpp
index 1cf34b4815..83146cb279 100644
--- a/engines/saga2/grabinfo.cpp
+++ b/engines/saga2/grabinfo.cpp
@@ -43,20 +43,20 @@ GrabInfo mouseInfo;
GrabInfo::GrabInfo() {
pointerMap.size.x = 0;
pointerMap.size.y = 0;
- pointerMap.data = NULL;
+ pointerMap.data = nullptr;
// null out the "held" object
grabId = Nothing;
- grabObj = NULL;
- intentDoable = TRUE;
+ grabObj = nullptr;
+ intentDoable = true;
intention = WalkTo;
textBuf[0] = '\0';
- displayGauge = FALSE;
+ displayGauge = false;
}
GrabInfo::~GrabInfo() {
- if (pointerMap.data != NULL)
+ if (pointerMap.data != nullptr)
delete[] pointerMap.data;
}
@@ -175,9 +175,9 @@ void GrabInfo::setIcon(void) {
assert(
pointerMap.size.x == 0
&& pointerMap.size.y == 0
- && pointerMap.data == NULL);
+ && pointerMap.data == nullptr);
- assert(grabObj != NULL && isObject(grabObj));
+ assert(grabObj != nullptr && isObject(grabObj));
Sprite *spr;
ProtoObj *proto;
@@ -194,7 +194,7 @@ void GrabInfo::setIcon(void) {
if ((mapData
= new uint8[mapBytes]())
- != NULL) {
+ != nullptr) {
// Clear out the image data
memset(mapData, 0, mapBytes);
@@ -214,13 +214,13 @@ void GrabInfo::setIcon(void) {
}
void GrabInfo::clearIcon(void) {
- assert(grabObj == NULL);
+ assert(grabObj == nullptr);
- if (pointerMap.data != NULL) {
+ if (pointerMap.data != nullptr) {
delete[] pointerMap.data;
pointerMap.size.x = 0;
pointerMap.size.y = 0;
- pointerMap.data = NULL;
+ pointerMap.data = nullptr;
}
}
@@ -265,14 +265,14 @@ void GrabInfo::placeObject(const Location &loc) {
grabObj->move(loc);
// Turn off state variables
- grabObj = NULL;
+ grabObj = nullptr;
grabId = Nothing;
- intentDoable = TRUE;
+ intentDoable = true;
setIntent(WalkTo);
clearIcon();
// Display the saved text
- setMouseText(textBuf[0] != '\0' ? textBuf : NULL);
+ setMouseText(textBuf[0] != '\0' ? textBuf : nullptr);
// Display the saved gauge data
if (displayGauge)
@@ -284,7 +284,7 @@ void GrabInfo::placeObject(const Location &loc) {
// this should be use to return the object to the container
// and/or remove the object from the cursor.
void GrabInfo::replaceObject(void) {
- if (grabObj == NULL)
+ if (grabObj == nullptr)
return;
// if actually attached to cursor, replace
@@ -295,19 +295,19 @@ void GrabInfo::replaceObject(void) {
// Update the ContainerView from which the object came
// updateView = ContainerView::findPane( grabObj->parent() );
-// if ( updateView != NULL )
+// if ( updateView != nullptr )
// ( updateView->getWindow() )->update( updateView->getExtent() );
}
// Turn off state variables
- grabObj = NULL;
+ grabObj = nullptr;
grabId = Nothing;
- intentDoable = TRUE;
+ intentDoable = true;
setIntent(WalkTo);
clearIcon();
// Display the saved text
- setMouseText(textBuf[0] != '\0' ? textBuf : NULL);
+ setMouseText(textBuf[0] != '\0' ? textBuf : nullptr);
// Display the saved gauge data
if (displayGauge)
@@ -321,31 +321,31 @@ void GrabInfo::replaceObject(void) {
// is currently no grabbed object the text will be displayed, else the
// text pointer will simply be saved.
void GrabInfo::setText(const char *txt) {
- if ((txt != NULL) && strlen(txt)) {
+ if ((txt != nullptr) && strlen(txt)) {
strncpy(textBuf, txt, bufSize);
textBuf[bufSize - 1] = '\0';
- if (grabObj == NULL)
+ if (grabObj == nullptr)
setMouseText(textBuf);
} else {
textBuf[0] = '\0';
- if (grabObj == NULL)
- setMouseText(NULL);
+ if (grabObj == nullptr)
+ setMouseText(nullptr);
}
}
// request a change to the mouse gauge
void GrabInfo::setGauge(int16 numerator, int16 denominator) {
- displayGauge = TRUE;
+ displayGauge = true;
gaugeNumerator = numerator;
gaugeDenominator = denominator;
- if (grabObj == NULL)
+ if (grabObj == nullptr)
setMouseGauge(gaugeNumerator, gaugeDenominator);
}
// clear the mouse gauge
void GrabInfo::clearGauge(void) {
- displayGauge = FALSE;
- if (grabObj == NULL) clearMouseGauge();
+ displayGauge = false;
+ if (grabObj == nullptr) clearMouseGauge();
}
#if CURSOR_CYCLING
@@ -365,9 +365,9 @@ void cycleCursor() {
else {
if (!walkEnabled && curIntent == GrabInfo::WalkTo)
++curIntent;
- if (curIntent == GrabInfo::PickUp && mouseInfo.getObject() != NULL)
+ if (curIntent == GrabInfo::PickUp && mouseInfo.getObject() != nullptr)
++curIntent;
- if (curIntent == GrabInfo::Drop && mouseInfo.getObject() == NULL)
+ if (curIntent == GrabInfo::Drop && mouseInfo.getObject() == nullptr)
++curIntent;
if (!eyeEnabled && curIntent == GrabInfo::LookAt)
++curIntent;
@@ -376,7 +376,7 @@ void cycleCursor() {
curIntent = 1; //Set Cursor First State Skip None
else {
curIntent = 2;
- if (curIntent == GrabInfo::PickUp && mouseInfo.getObject() != NULL)
+ if (curIntent == GrabInfo::PickUp && mouseInfo.getObject() != nullptr)
++curIntent;
}
}
Commit: 067fcb00d740f21da62dd79dc07a281878c82947
https://github.com/scummvm/scummvm/commit/067fcb00d740f21da62dd79dc07a281878c82947
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:06+02:00
Commit Message:
SAGA2: Fix save game dialog crash
Changed paths:
engines/saga2/gtextbox.cpp
engines/saga2/uidialog.cpp
engines/saga2/vwdraw.cpp
diff --git a/engines/saga2/gtextbox.cpp b/engines/saga2/gtextbox.cpp
index aeb39db208..a5cdcf6202 100644
--- a/engines/saga2/gtextbox.cpp
+++ b/engines/saga2/gtextbox.cpp
@@ -181,7 +181,7 @@ gTextBox::gTextBox(
flags = flg;
currentLen[index] = buffer ? strlen(buffer) : 0;
cursorPos = anchorPos = scrollPixels = 0;
- undoBuffer = (char *)malloc(sizeof(char) * (maxLen + 1));
+ undoBuffer = new char[maxLen + 1]();
textFont = font;
fontHeight = height;
fontOffset = fontHeight + 2;
@@ -233,7 +233,7 @@ gTextBox::~gTextBox() {
deSelect();
selected = 0;
if (undoBuffer) {
- delete undoBuffer;
+ delete[] undoBuffer;
}
}
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index ac13972d00..7b735d7990 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -593,11 +593,12 @@ void destroyFileFields(char **strings) {
uint16 i;
for (i = 0; i < numEditLines; i++) {
- if (strings[i]) delete strings[i];
- strings[i] = NULL;
+ if (strings[i])
+ delete[] strings[i];
+ strings[i] = nullptr;
}
- delete strings;
+ delete[] strings;
}
bool getSaveName(int8 saveNo, SaveFileHeader &header) {
diff --git a/engines/saga2/vwdraw.cpp b/engines/saga2/vwdraw.cpp
index d6eacdc34e..a046179086 100644
--- a/engines/saga2/vwdraw.cpp
+++ b/engines/saga2/vwdraw.cpp
@@ -66,7 +66,8 @@ void gDisplayPort::bltPixels(
sect;
uint8 *src_line;
- clip = Rect16(0, 0, map->size.x, map->size.y);
+ if (clip.empty())
+ clip = Rect16(0, 0, map->size.x, map->size.y);
sect = intersect(clip, r);
if (!sect.empty()) { // if result is non-empty
Commit: 8051350749eaa52d79e22d345ad105f343dbaa74
https://github.com/scummvm/scummvm/commit/8051350749eaa52d79e22d345ad105f343dbaa74
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:06+02:00
Commit Message:
SAGA2: Cleanup uidialog.cpp
Changed paths:
engines/saga2/uidialog.cpp
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index 7b735d7990..a79b6cec7a 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -545,8 +545,8 @@ gOwnerSelCompButton *autoAggressBtn,
static int deferredLoadID = 0;
-static bool deferredLoadFlag = FALSE;
-static bool deferredSaveFlag = FALSE;
+static bool deferredLoadFlag = false;
+static bool deferredSaveFlag = false;
static char deferredSaveName[64];
inline bool isUserAction(gEvent ev) {
@@ -609,19 +609,19 @@ bool getSaveName(int8 saveNo, SaveFileHeader &header) {
getSaveFileName(saveNo, fileName);
// Open the file or throw an exception
- if ((fileHandle = fopen(fileName, "rb")) == NULL) {
- return FALSE;
+ if ((fileHandle = fopen(fileName, "rb")) == nullptr) {
+ return false;
}
// Read the save file header
if (fread(&header, sizeof(header), 1, fileHandle) != 1) {
- return FALSE;
+ return false;
}
// close the used file handle
- if (fileHandle != NULL) fclose(fileHandle);
+ if (fileHandle != nullptr) fclose(fileHandle);
- return TRUE;
+ return true;
}
@@ -634,7 +634,7 @@ int16 FileDialog(int16 fileProcess) {
char **fieldStrings;
uint16 stringIndex;
bool displayOnly;
- void **arrowUpIm = NULL, **arrowDnIm = NULL, **pushBtnIm = NULL;
+ void **arrowUpIm = nullptr, **arrowDnIm = nullptr, **pushBtnIm = nullptr;
AppFunc *fileCommands[2] = { cmdFileSave, cmdFileLoad };
@@ -654,10 +654,10 @@ int16 FileDialog(int16 fileProcess) {
if (fileProcess == typeSave) {
stringIndex = 0;
- displayOnly = FALSE;
+ displayOnly = false;
} else {
stringIndex = 1;
- displayOnly = TRUE;
+ displayOnly = true;
}
// resource info
@@ -669,7 +669,7 @@ int16 FileDialog(int16 fileProcess) {
requestInfo rInfo;
rInfo.result = -1;
- rInfo.running = TRUE;
+ rInfo.running = true;
// point to the modal window
ModalWindow *win;
@@ -684,8 +684,8 @@ int16 FileDialog(int16 fileProcess) {
#ifndef ALLOW_BAD_LOADS
if (displayOnly && numValid(fieldStrings) == 0) {
destroyFileFields(fieldStrings);
- if (userDialog("Error", "No saved games to load!\n Would you like to start over?", "_Yes", "_No", NULL) != 1) {
- deferredLoadFlag = TRUE;
+ if (userDialog("Error", "No saved games to load!\n Would you like to start over?", "_Yes", "_No", nullptr) != 1) {
+ deferredLoadFlag = true;
deferredLoadID = 999;
return typeLoad;
}
@@ -705,7 +705,7 @@ int16 FileDialog(int16 fileProcess) {
// create the window
checkAlloc(win = new ModalWindow(saveLoadWindowRect,
0,
- NULL));
+ nullptr));
gCompButton *t;
// make the quit button
@@ -727,14 +727,14 @@ int16 FileDialog(int16 fileProcess) {
//t->accelKey=34+0x80;
// attach the title
checkAlloc(new CPlaqText(*win, saveLoadTextRects[0],
- textStrings[stringIndex][0], &Plate18Font, NULL, pal, 0, NULL));
+ textStrings[stringIndex][0], &Plate18Font, 0, pal, 0, nullptr));
// attach the text box editing field object
checkAlloc(textBox = new gTextBox(*win, editBaseRect, &Onyx10Font,
textHeight, textPen, textBackground, textHilite, textBackHilite, cursorColor,
- NULL, "Error out", fieldStrings, editLen, 0, (uint16) - 1, displayOnly, NULL,
+ nullptr, "Error out", fieldStrings, editLen, 0, (uint16) - 1, displayOnly, nullptr,
fileCommands[fileProcess], cmdDialogQuit));
@@ -752,12 +752,12 @@ int16 FileDialog(int16 fileProcess) {
//win->draw();
//G_BASE.setActive(textBox);
- EventLoop(rInfo.running, TRUE);
+ EventLoop(rInfo.running, true);
// remove the window all attatched controls
if (win) delete win;
- win = NULL;
+ win = nullptr;
// unload all image arrays
unloadImageRes(arrowUpIm, numBtnImages);
@@ -767,7 +767,7 @@ int16 FileDialog(int16 fileProcess) {
// remove the resource handle
if (decRes) resFile->disposeContext(decRes);
- decRes = NULL;
+ decRes = nullptr;
// destroy the file fields
destroyFileFields(fieldStrings);
@@ -824,10 +824,10 @@ int16 OptionsDialog(bool disableSaveResume) {
requestInfo rInfo;
rInfo.result = -1;
- rInfo.running = TRUE;
+ rInfo.running = true;
deferredLoadID = 0;
- deferredLoadFlag = FALSE;
- deferredSaveFlag = FALSE;
+ deferredLoadFlag = false;
+ deferredSaveFlag = false;
deferredSaveName[0] = '\0';
// point to the modal window
@@ -860,7 +860,7 @@ int16 OptionsDialog(bool disableSaveResume) {
// create the window
checkAlloc(win = new ModalWindow(optionsWindowRect,
0,
- NULL));
+ nullptr));
gCompButton *t;
// buttons
@@ -919,11 +919,11 @@ int16 OptionsDialog(bool disableSaveResume) {
0, cmdSetMIDIVolume));
checkAlloc(new CPlaqText(*win, optionsTextRects[0],
- textStrings[0], &Plate18Font, 0, pal, 0, NULL));
+ textStrings[0], &Plate18Font, 0, pal, 0, nullptr));
for (int i = 1; i < numOptionsTexts; i++) {
checkAlloc(new CPlaqText(*win, optionsTextRects[i],
- textStrings[i], &SmallFont, textPosLeft, pal, 0, NULL));
+ textStrings[i], &SmallFont, textPosLeft, pal, 0, nullptr));
}
win->setDecorations(optionsDecorations,
@@ -934,13 +934,13 @@ int16 OptionsDialog(bool disableSaveResume) {
win->userData = &rInfo;
win->open();
- EventLoop(rInfo.running, TRUE);
+ EventLoop(rInfo.running, true);
writeConfig();
// remove the window all attatched controls
if (win) delete win;
- win = NULL;
+ win = nullptr;
// unload all image arrays
unloadImageRes(slideFaceImag, numSlideFace);
@@ -949,7 +949,7 @@ int16 OptionsDialog(bool disableSaveResume) {
// remove the resource handle
if (decRes) resFile->disposeContext(decRes);
- decRes = NULL;
+ decRes = nullptr;
// replace the damaged area
@@ -998,10 +998,10 @@ char stripAccel(char *t, const char *s) {
char accel = '\0';
char *underscore;
- if (t == NULL || s == NULL) return accel;
+ if (t == nullptr || s == nullptr) return accel;
strcpy(t, s);
- if ((underscore = strchr(t, '_')) != NULL) {
+ if ((underscore = strchr(t, '_')) != nullptr) {
accel = toupper(underscore[1]);
strcpy(underscore, s + (underscore - t) + 1);
}
@@ -1024,7 +1024,7 @@ hResContext *udDecRes;
// compressed image array
void **udDialogPushImag;
-bool udInit = FALSE;
+bool udInit = false;
bool initUserDialog(void) {
@@ -1039,7 +1039,7 @@ bool initUserDialog(void) {
// create the window
checkAlloc(udWin = new ModalWindow(messageWindowRect,
0,
- NULL));
+ nullptr));
udWin->setDecorations(messageDecorations,
elementsof(messageDecorations),
@@ -1048,11 +1048,11 @@ bool initUserDialog(void) {
udWin->userData = &udrInfo;
if (udDecRes) resFile->disposeContext(udDecRes);
- udDecRes = NULL;
+ udDecRes = nullptr;
- udInit = TRUE;
+ udInit = true;
- return TRUE;
+ return true;
}
bool userDialogAvailable(void) {
@@ -1060,10 +1060,10 @@ bool userDialogAvailable(void) {
}
void cleanupUserDialog(void) {
- udInit = FALSE;
+ udInit = false;
// remove the window all attatched controls
if (udWin) delete udWin;
- udWin = NULL;
+ udWin = nullptr;
// unload all image arrays
unloadImageRes(udDialogPushImag, numBtnImages);
@@ -1094,10 +1094,10 @@ int16 userDialog(const char *title, const char *msg, const char *bMsg1,
// make the text coloring object
textPallete pal(33 + 9, 36 + 9, 41 + 9, 34 + 9, 40 + 9, 43 + 9);
- if (udWin == NULL) return -1;
+ if (udWin == nullptr) return -1;
udrInfo.result = -1;
- udrInfo.running = TRUE;
+ udrInfo.running = true;
gCompButton *t;
@@ -1124,16 +1124,16 @@ int16 userDialog(const char *title, const char *msg, const char *bMsg1,
// title for the box
checkAlloc(new CPlaqText(*udWin, messageTextRects[0],
- title, &Plate18Font, NULL, pal, 0, NULL));
+ title, &Plate18Font, nullptr, pal, 0, nullptr));
// message for box
checkAlloc(new CPlacardPanel(*udWin, messageTextRects[1],
- msg, &Onyx10Font, NULL, pal, 0, NULL));
+ msg, &Onyx10Font, nullptr, pal, 0, nullptr));
udWin->open();
- EventLoop(udrInfo.running, TRUE);
+ EventLoop(udrInfo.running, true);
udWin->close();
@@ -1153,10 +1153,10 @@ int16 userDialog(const char *title, const char *msg, const char *bMsg1,
* ===================================================================== */
bool initUserDialog(void) {
- return TRUE;
+ return true;
}
bool userDialogAvailable(void) {
- return TRUE;
+ return true;
}
void cleanupUserDialog(void) {}
@@ -1201,7 +1201,7 @@ int16 userDialog(const char *title, const char *msg, const char *bMsg1,
void **dialogPushImag;
rInfo.result = -1;
- rInfo.running = TRUE;
+ rInfo.running = true;
if (!fullInitialized)
return -1;
@@ -1216,7 +1216,7 @@ int16 userDialog(const char *title, const char *msg, const char *bMsg1,
// create the window
checkAlloc(win = new ModalWindow(messageWindowRect,
0,
- NULL));
+ nullptr));
gCompButton *t;
@@ -1243,11 +1243,11 @@ int16 userDialog(const char *title, const char *msg, const char *bMsg1,
// title for the box
checkAlloc(new CPlaqText(*win, messageTextRects[0],
- title, &Plate18Font, NULL, pal, 0, NULL));
+ title, &Plate18Font, 0, pal, 0, nullptr));
// message for box
checkAlloc(new CPlacardPanel(*win, messageTextRects[1],
- msg, &Onyx10Font, NULL, pal, 0, NULL));
+ msg, &Onyx10Font, 0, pal, 0, nullptr));
win->setDecorations(messageDecorations,
elementsof(messageDecorations),
@@ -1258,7 +1258,7 @@ int16 userDialog(const char *title, const char *msg, const char *bMsg1,
win->open();
- EventLoop(rInfo.running, TRUE);
+ EventLoop(rInfo.running, true);
// remove the window all attatched controls
@@ -1269,7 +1269,7 @@ int16 userDialog(const char *title, const char *msg, const char *bMsg1,
// remove the resource handle
if (decRes) resFile->disposeContext(decRes);
- decRes = NULL;
+ decRes = nullptr;
// replace the damaged area
mainWindow->invalidate(messageWindowRect);
@@ -1342,7 +1342,7 @@ int16 CPlacardWindow:: SplitString(
for (count = 0; count < maxStrings;) {
textStart[count++] = text;
- if ((text = strchr(text, delimiter)) == NULL) break;
+ if ((text = strchr(text, delimiter)) == nullptr) break;
*text++ = '\0';
}
return count;
@@ -1355,7 +1355,7 @@ bool CPlacardWindow::pointerHit(gPanelMessage &) {
requestInfo *ri;
win = getWindow(); // get the window pointer
- ri = win ? (requestInfo *)win->userData : NULL;
+ ri = win ? (requestInfo *)win->userData : nullptr;
if (ri) {
ri->running = 0;
@@ -1363,7 +1363,7 @@ bool CPlacardWindow::pointerHit(gPanelMessage &) {
}
//activate( gEventMouseDown );
- return TRUE;
+ return true;
}
void CPlacardWindow::drawClipped(
@@ -1397,7 +1397,7 @@ void CPlacardWindow::drawClipped(
textFont,
0,
textPal,
- FALSE,
+ false,
titleStrings[i]);
}
}
@@ -1453,7 +1453,7 @@ int16 CPlacardPanel:: SplitString(
for (count = 0; count < maxStrings;) {
textStart[count++] = text;
- if ((text = strchr(text, delimiter)) == NULL) break;
+ if ((text = strchr(text, delimiter)) == nullptr) break;
*text++ = '\0';
}
return count;
@@ -1488,7 +1488,7 @@ void CPlacardPanel::drawClipped(
buttonFont,
0,
textFacePal,
- FALSE,
+ false,
titleStrings[i]);
}
}
@@ -1528,7 +1528,7 @@ void placardWindow(int8 type, char *text) {
requestInfo rInfo;
rInfo.result = -1;
- rInfo.running = TRUE;
+ rInfo.running = true;
// point to the modal window
CPlacardWindow *win;
@@ -1548,7 +1548,7 @@ void placardWindow(int8 type, char *text) {
pal.set(62, 64, 67, 11, 23, 17);
// create the window
- checkAlloc(win = new CPlacardWindow(plaqRectWood, 0, NULL, text, pal, &Plate18Font));
+ checkAlloc(win = new CPlacardWindow(plaqRectWood, 0, nullptr, text, pal, &Plate18Font));
// setup the background imagery
win->setDecorations(plaqDecWood,
@@ -1563,7 +1563,7 @@ void placardWindow(int8 type, char *text) {
pal.set(16, 12, 18, 11, 23, 0x78);
// create the window
- checkAlloc(win = new CPlacardWindow(plaqRectStone, 0, NULL, text, pal, &Plate18Font));
+ checkAlloc(win = new CPlacardWindow(plaqRectStone, 0, nullptr, text, pal, &Plate18Font));
// setup the background imagery
win->setDecorations(plaqDecStone,
@@ -1578,7 +1578,7 @@ void placardWindow(int8 type, char *text) {
pal.set(89, 93, 95, 11, 23, 0x76);
// create the window
- checkAlloc(win = new CPlacardWindow(plaqRectBrass, 0, NULL, text, pal, &Plate18Font));
+ checkAlloc(win = new CPlacardWindow(plaqRectBrass, 0, nullptr, text, pal, &Plate18Font));
// setup the background imagery
win->setDecorations(plaqDecBrass,
@@ -1597,7 +1597,7 @@ void placardWindow(int8 type, char *text) {
win->open();
- EventLoop(rInfo.running, TRUE);
+ EventLoop(rInfo.running, true);
// remove the window all attatched controls
@@ -1615,18 +1615,18 @@ void placardWindow(int8 type, char *text) {
void updateAutoAggressionButton(bool setting) {
- if (autoAggressBtn != NULL)
+ if (autoAggressBtn != nullptr)
autoAggressBtn->select(setting);
}
void updateAutoWeaponButton(bool setting) {
- if (autoWeaponBtn != NULL)
+ if (autoWeaponBtn != nullptr)
autoWeaponBtn->select(setting);
}
//void updateShowNightButton( bool setting )
//{
-// if ( nightBtn != NULL )
+// if ( nightBtn != nullptr )
// nightBtn->select( setting );
//}
@@ -1637,7 +1637,7 @@ APPFUNC(cmdDialogQuit) {
if (ev.panel && isUserAction(ev) && ev.value) {
win = ev.panel->getWindow(); // get the window pointer
- ri = win ? (requestInfo *)win->userData : NULL;
+ ri = win ? (requestInfo *)win->userData : nullptr;
if (ri) {
ri->running = 0;
@@ -1653,7 +1653,7 @@ APPFUNC(cmdFileSave) {
if (ev.panel && isUserAction(ev) && ev.value) {
// now close the window
win = ev.panel->getWindow(); // get the window pointer
- ri = win ? (requestInfo *)win->userData : NULL;
+ ri = win ? (requestInfo *)win->userData : nullptr;
if (ri) {
ri->running = 0;
@@ -1670,7 +1670,7 @@ APPFUNC(cmdFileSave) {
saveGameState(saveIndex, textBox->getLine(saveIndex));
#else
deferredLoadID = saveIndex;
- deferredSaveFlag = TRUE;
+ deferredSaveFlag = true;
strcpy(deferredSaveName, textBox->getLine(saveIndex));
#endif
}
@@ -1690,7 +1690,7 @@ APPFUNC(cmdFileLoad) {
// close window
win = ev.panel->getWindow(); // get the window pointer
- ri = win ? (requestInfo *)win->userData : NULL;
+ ri = win ? (requestInfo *)win->userData : nullptr;
if (ri) {
ri->running = 0;
@@ -1698,7 +1698,7 @@ APPFUNC(cmdFileLoad) {
}
deferredLoadID = saveNo;
- deferredLoadFlag = TRUE;
+ deferredLoadFlag = true;
}
}
}
@@ -1733,13 +1733,13 @@ APPFUNC(cmdOptionsNewGame) {
gWindow *win;
requestInfo *ri;
win = ev.panel->getWindow(); // get the window pointer
- ri = win ? (requestInfo *)win->userData : NULL;
+ ri = win ? (requestInfo *)win->userData : nullptr;
if (ri) {
ri->running = 0;
ri->result = ev.panel->id;
deferredLoadID = 999;
- deferredLoadFlag = TRUE;
+ deferredLoadFlag = true;
}
}
}
@@ -1753,7 +1753,7 @@ APPFUNC(cmdOptionsLoadGame) {
// if the fileDialog actually did loading
if (FileDialog(typeLoad) == typeLoad) {
win = ev.panel->getWindow(); // get the window pointer
- ri = win ? (requestInfo *)win->userData : NULL;
+ ri = win ? (requestInfo *)win->userData : nullptr;
if (ri) {
ri->running = 0;
@@ -1769,17 +1769,17 @@ APPFUNC(cmdQuitGame) {
if (ev.panel && isUserAction(ev) && ev.value) {
win = ev.panel->getWindow(); // get the window pointer
- ri = win ? (requestInfo *)win->userData : NULL;
+ ri = win ? (requestInfo *)win->userData : nullptr;
if (ri
&& userDialog(
VFYX_DIALOG_NAME,
VFYX_DIALOG_CAPTION,
VFYX_DIALOG_BUTTON1,
- VFYX_DIALOG_BUTTON2, NULL) == 0) {
+ VFYX_DIALOG_BUTTON2, nullptr) == 0) {
endGame();
- ri->running = FALSE;
+ ri->running = false;
ri->result = ev.panel->id;
}
}
Commit: d72f53efdc0aae5b04b266a9b2c9417684ce45cc
https://github.com/scummvm/scummvm/commit/d72f53efdc0aae5b04b266a9b2c9417684ce45cc
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:06+02:00
Commit Message:
SAGA2: Fix activeItemList loading
Changed paths:
engines/saga2/tile.cpp
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 7534bcce6a..3727d92ca6 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -1422,11 +1422,24 @@ static void readMetaTile(hResContext *con, MetaTile &til) {
til.properties = con->readU32LE();
}
+static void readActiveItem(hResContext *con, ActiveItem &itm) {
+ // FIXME: 32-bit pointer to 64-bit pointer conversion.
+ // Is this dangerous?
+ itm.nextHash = (ActiveItemPtr)con->readU32LE();
+ itm.scriptClassID = con->readU16LE();
+ itm.associationOffset = con->readU16LE();
+ itm.numAssociations = con->readByte();
+ itm.itemType = con->readByte();
+ itm.group.grDataOffset = con->readU16LE();
+ itm.instance.groupID = con->readU16LE();
+}
+
void initMaps(void) {
int16 i;
const int metaTileSize = 30;
const int tileRefSize = 4;
const int assocSize = 2;
+ const int activeItemSize = 14;
// Load all of the tile terrain banks
for (i = 0; i < maxBanks; i++) {
@@ -1500,10 +1513,11 @@ void initMaps(void) {
// If there is an active item list, load it
if (tileRes->size(tagID + MKTAG(0, 0, 0, (uint8)i)) > 0) {
- mapData->activeItemList =
- (ActiveItemPtr)LoadResource(tileRes,
- tagID + MKTAG(0, 0, 0, (uint8)i),
- "active item list");
+ int activeItemCount = tileRes->size(tagID + MKTAG(0, 0, 0, (uint8)i)) / activeItemSize;
+ mapData->activeItemList = new ActiveItem[activeItemCount];
+ for (int k = 0; k < activeItemCount; ++k)
+ readActiveItem(tileRes, mapData->activeItemList[k]);
+
if (mapData->activeItemList == nullptr)
error("Unable to load active item list");
} else
Commit: b4558ea22c2a9ac6f6ddcdace22ea6d9bc1939da
https://github.com/scummvm/scummvm/commit/b4558ea22c2a9ac6f6ddcdace22ea6d9bc1939da
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:06+02:00
Commit Message:
SAGA2: Fix tile rendering
Changed paths:
engines/saga2/blitters.cpp
diff --git a/engines/saga2/blitters.cpp b/engines/saga2/blitters.cpp
index 5c6259138c..101f5af31f 100644
--- a/engines/saga2/blitters.cpp
+++ b/engines/saga2/blitters.cpp
@@ -115,7 +115,6 @@ void unpackSprite(gPixelMap *map, uint8 *sprData) {
//}
void drawTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData) {
- warning("STUB: drawTile()");
const byte *tilePointer;
const byte *readPointer;
byte *drawPointer;
@@ -124,15 +123,9 @@ void drawTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData) {
int row, col, count, lowBound;
int bgRunCount;
int fgRunCount;
- const int32 SAGA_ISOTILE_WIDTH = 32;
+ const int32 SAGA_ISOTILE_WIDTH = 64;
Point16 point(x, y);
-
-// if (tileIndex >= _tilesTable.size()) {
-// error("IsoMap::drawTile wrong tileIndex");
-// }
-
-
if (point.x + SAGA_ISOTILE_WIDTH < 0) {
return;
}
@@ -141,10 +134,6 @@ void drawTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData) {
return;
}
- if ((height <= 8) || (height > 64)) {
- return;
- }
-
tilePointer = srcData;
drawPoint = point;
@@ -155,99 +144,6 @@ void drawTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData) {
return;
}
-#if 0
- if (location != NULL) {
- if (location->z <= -16) {
- if (location->z <= -48) {
- if (location->u() < -THRESH8 || location->v() < -THRESH8) {
- return;
- }
- } else {
- if (location->u() < THRESH0 || location->v() < THRESH0) {
- return;
- }
- }
- } else {
- if (location->z >= 16) {
- return;
- } else {
- switch (_tilesTable[tileIndex].getMaskRule()) {
- case kMaskRuleNever:
- return;
- case kMaskRuleAlways:
- default:
- break;
- case kMaskRuleUMIN:
- if (location->u() < THRESH0) {
- return;
- }
- break;
- case kMaskRuleUMID:
- if (location->u() < THRESH8) {
- return;
- }
- break;
- case kMaskRuleUMAX:
- if (location->u() < THRESH16) {
- return;
- }
- break;
- case kMaskRuleVMIN:
- if (location->v() < THRESH0) {
- return;
- }
- break;
- case kMaskRuleVMID:
- if (location->v() < THRESH8) {
- return;
- }
- break;
- case kMaskRuleVMAX:
- if (location->v() < THRESH16) {
- return;
- }
- break;
- case kMaskRuleYMIN:
- if (location->uv() < THRESH0 * 2) {
- return;
- }
- break;
- case kMaskRuleYMID:
- if (location->uv() < THRESH8 * 2) {
- return;
- }
- break;
- case kMaskRuleYMAX:
- if (location->uv() < THRESH16 * 2) {
- return;
- }
- break;
- case kMaskRuleUVMAX:
- if (location->u() < THRESH16 && location->v() < THRESH16) {
- return;
- }
- break;
- case kMaskRuleUVMIN:
- if (location->u() < THRESH0 || location->v() < THRESH0) {
- return;
- }
- break;
- case kMaskRuleUorV:
- if (location->u() < THRESH8 && location->v() < THRESH8) {
- return;
- }
- break;
- case kMaskRuleUandV:
- if (location->u() < THRESH8 || location->v() < THRESH8) {
- return;
- }
- break;
- }
- }
- }
- }
-#endif
-
readPointer = tilePointer;
lowBound = MIN((int)(drawPoint.y + height), (int)map->size.y);
for (row = drawPoint.y; row < lowBound; row++) {
@@ -308,24 +204,6 @@ void drawTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData) {
}
}
}
-
- // Compute dirty rect
- int rectX = MAX<int>(drawPoint.x, 0);
- int rectY = MAX<int>(drawPoint.y, 0);
- int rectX2 = MIN<int>(drawPoint.x + SAGA_ISOTILE_WIDTH, map->size.x);
- int rectY2 = lowBound;
- debugC(3, kDebugTiles, "Rect = (%d,%d,%d,%d)", rectX, rectY, rectX2, rectY2);
-
- // FIXME: Debug purposes-code for displaying things on the screen
- // updateScreen should not be called here
- warning("FIXME: drawTile");
- Graphics::Surface sur;
- sur.create(map->size.x, map->size.y, Graphics::PixelFormat::createFormatCLUT8());
- sur.setPixels(map->data);
- //sur.debugPrint();
- g_system->copyRectToScreen(sur.getPixels(), sur.pitch, 0, 0, sur.w, sur.h);
- g_system->updateScreen();
- //g_vm->_render->addDirtyRect(Common::Rect(rectX, rectY, rectX2, rectY2));
}
Commit: 1063a98c2260f9bc41d68c562ec5242f14e0d73d
https://github.com/scummvm/scummvm/commit/1063a98c2260f9bc41d68c562ec5242f14e0d73d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:07+02:00
Commit Message:
SAGA2: Implement unpackSprite()
Changed paths:
engines/saga2/blitters.cpp
diff --git a/engines/saga2/blitters.cpp b/engines/saga2/blitters.cpp
index 101f5af31f..45305a1907 100644
--- a/engines/saga2/blitters.cpp
+++ b/engines/saga2/blitters.cpp
@@ -107,7 +107,24 @@ void unpackImage(gPixelMap *map, int32 width, int32 rowCount, int8 *srcData) {
}
void unpackSprite(gPixelMap *map, uint8 *sprData) {
- warning("STUB: unpackSprite()");
+ byte *dst = map->data;
+ int bytes = map->size.x * map->size.y;
+
+ while (true) {
+ byte trans = *sprData++;
+ memset(dst, 0, trans);
+ dst += trans;
+ bytes -= trans;
+
+ if (bytes < 0)
+ break;
+
+ byte fill = *sprData++;
+ memcpy(dst, sprData, fill);
+ dst += fill;
+ bytes -= fill;
+ sprData += fill;
+ }
}
//void drawTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData) {
Commit: 262dc756ad2239b0510dfd0d962bb88214f5d2e8
https://github.com/scummvm/scummvm/commit/262dc756ad2239b0510dfd0d962bb88214f5d2e8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:07+02:00
Commit Message:
SAGA2: Code cleanup
Changed paths:
engines/saga2/blitters.cpp
diff --git a/engines/saga2/blitters.cpp b/engines/saga2/blitters.cpp
index 45305a1907..8c95f4f785 100644
--- a/engines/saga2/blitters.cpp
+++ b/engines/saga2/blitters.cpp
@@ -33,10 +33,9 @@
namespace Saga2 {
void _BltPixels(uint8 *srcPtr, uint32 srcMod, uint8 *dstPtr, uint32 dstMod, uint32 width, uint32 height) {
- uint8 *src, *dst;
for (uint y = 0; y < height; y++) {
- src = srcPtr + srcMod * y;
- dst = dstPtr + dstMod * y;
+ uint8 *src = srcPtr + srcMod * y;
+ uint8 *dst = dstPtr + dstMod * y;
for (uint x = 0; x < width; x++) {
*dst++ = *src++;
}
@@ -44,10 +43,9 @@ void _BltPixels(uint8 *srcPtr, uint32 srcMod, uint8 *dstPtr, uint32 dstMod, uint
}
void _BltPixelsT(uint8 *srcPtr, uint32 srcMod, uint8 *dstPtr, uint32 dstMod, uint32 width, uint32 height) {
- uint8 *src, *dst;
for (uint y = 0; y < height; y++) {
- src = srcPtr + srcMod * y;
- dst = dstPtr + dstMod * y;
+ uint8 *src = srcPtr + srcMod * y;
+ uint8 *dst = dstPtr + dstMod * y;
for (uint x = 0; x < width; x++) {
byte c = *src++;
@@ -72,9 +70,9 @@ void _HLine(uint8 *dstPtr, uint32 width, uint32 color) {
}
void unpackImage(gPixelMap &map, int16 width, int16 rowCount, int8 *srcData) {
- int8 *dest = (int8 *)map.data;
+ int8 *dest = (int8 *)map.data;
int16 bytecount = (width + 1) & ~1;
- int16 rowMod = map.size.x - bytecount;
+ int16 rowMod = map.size.x - bytecount;
while (rowCount--) {
for (int16 k = 0; k < bytecount;) {
@@ -127,10 +125,6 @@ void unpackSprite(gPixelMap *map, uint8 *sprData) {
}
}
-//void drawTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData) {
-// warning("STUB: drawTile()");
-//}
-
void drawTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData) {
const byte *tilePointer;
const byte *readPointer;
@@ -143,13 +137,11 @@ void drawTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData) {
const int32 SAGA_ISOTILE_WIDTH = 64;
Point16 point(x, y);
- if (point.x + SAGA_ISOTILE_WIDTH < 0) {
+ if (point.x + SAGA_ISOTILE_WIDTH < 0)
return;
- }
- if (point.x - SAGA_ISOTILE_WIDTH >= map->size.x) {
+ if (point.x - SAGA_ISOTILE_WIDTH >= map->size.x)
return;
- }
tilePointer = srcData;
@@ -157,9 +149,8 @@ void drawTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData) {
drawPoint.y -= height;
- if (drawPoint.y >= map->size.y) {
+ if (drawPoint.y >= map->size.y)
return;
- }
readPointer = tilePointer;
lowBound = MIN((int)(drawPoint.y + height), (int)map->size.y);
@@ -171,9 +162,8 @@ void drawTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData) {
for (;;) {
bgRunCount = *readPointer++;
widthCount += bgRunCount;
- if (widthCount >= SAGA_ISOTILE_WIDTH) {
+ if (widthCount >= SAGA_ISOTILE_WIDTH)
break;
- }
drawPointer += bgRunCount;
col += bgRunCount;
@@ -183,9 +173,9 @@ void drawTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData) {
count = 0;
int colDiff = - col;
if (colDiff > 0) {
- if (colDiff > fgRunCount) {
+ if (colDiff > fgRunCount)
colDiff = fgRunCount;
- }
+
count = colDiff;
col += colDiff;
}
@@ -193,9 +183,9 @@ void drawTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData) {
colDiff = map->size.x - col;
if (colDiff > 0) {
int countDiff = fgRunCount - count;
- if (colDiff > countDiff) {
+ if (colDiff > countDiff)
colDiff = countDiff;
- }
+
if (colDiff > 0) {
byte *dst = (byte *)(drawPointer + count);
memcpy(dst, (readPointer + count), colDiff);
@@ -210,9 +200,8 @@ void drawTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData) {
for (;;) {
bgRunCount = *readPointer++;
widthCount += bgRunCount;
- if (widthCount >= SAGA_ISOTILE_WIDTH) {
+ if (widthCount >= SAGA_ISOTILE_WIDTH)
break;
- }
fgRunCount = *readPointer++;
widthCount += fgRunCount;
@@ -229,15 +218,9 @@ void maskTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData) {
}
void TBlit(gPixelMap *dstMap, gPixelMap *srcMap, int xpos, int ypos) {
- byte *srcPtr,
- *dstPtr;
- int16 srcMod,
- dstMod;
- int16 x, y, w, h;
- int32 offset = 0;
-
- w = srcMap->size.x;
- h = srcMap->size.y;
+ int16 w = srcMap->size.x;
+ int16 h = srcMap->size.y;
+ int32 offset = 0;
if (ypos < 0) {
h += ypos;
@@ -258,14 +241,14 @@ void TBlit(gPixelMap *dstMap, gPixelMap *srcMap, int xpos, int ypos) {
if (w < 0 || h < 0)
return;
- dstMod = dstMap->size.x - w;
- srcMod = srcMap->size.x - w;
+ int16 dstMod = dstMap->size.x - w;
+ int16 srcMod = srcMap->size.x - w;
- srcPtr = srcMap->data + offset;
- dstPtr = dstMap->data + xpos + ypos * dstMap->size.x;
+ byte *srcPtr = srcMap->data + offset;
+ byte *dstPtr = dstMap->data + xpos + ypos * dstMap->size.x;
- for (y = 0; y < h; y++) {
- for (x = 0; x < w; x++) {
+ for (int16 y = 0; y < h; y++) {
+ for (int16 x = 0; x < w; x++) {
byte c = *srcPtr++;
if (c == 0)
@@ -283,19 +266,12 @@ void TBlit4(gPixelMap *d, gPixelMap *s, int32 x, int32 y) {
}
void compositePixels(gPixelMap *compMap, gPixelMap *sprMap, int xpos, int ypos, byte *lookup) {
- byte *srcPtr,
- *dstPtr;
- int16 rowMod;
- int16 x, y;
-
- // Blit the temp map onto the composite map
+ byte *srcPtr = sprMap->data;
+ byte *dstPtr = compMap->data + xpos + ypos * compMap->size.x;
+ int16 rowMod = compMap->size.x - sprMap->size.x;
- srcPtr = sprMap->data;
- dstPtr = compMap->data + xpos + ypos * compMap->size.x;
- rowMod = compMap->size.x - sprMap->size.x;
-
- for (y = 0; y < sprMap->size.y; y++) {
- for (x = 0; x < sprMap->size.x; x++) {
+ for (int16 y = 0; y < sprMap->size.y; y++) {
+ for (int16 x = 0; x < sprMap->size.x; x++) {
byte c = *srcPtr++;
if (c == 0)
@@ -308,28 +284,21 @@ void compositePixels(gPixelMap *compMap, gPixelMap *sprMap, int xpos, int ypos,
}
void compositePixelsRvs(gPixelMap *compMap, gPixelMap *sprMap, int xpos, int ypos, byte *lookup) {
- byte *srcPtr,
- *dstPtr;
- int16 rowMod;
- int16 x, y;
-
- // Blit the temp map onto the composite map
+ byte *srcPtr = sprMap->data + sprMap->bytes();
+ byte *dstPtr = compMap->data + xpos + (ypos + sprMap->size.y) * compMap->size.x;
- srcPtr = sprMap->data + sprMap->bytes();
- dstPtr = compMap->data + xpos + (ypos + sprMap->size.y) * compMap->size.x;
+ int16 rowMod = compMap->size.x + sprMap->size.x;
- rowMod = compMap->size.x + sprMap->size.x;
-
- for (y = 0; y < sprMap->size.y; y++) {
+ for (int16 y = 0; y < sprMap->size.y; y++) {
dstPtr -= rowMod;
- for (x = 0; x < sprMap->size.x; x++) {
+ for (int16 x = 0; x < sprMap->size.x; x++) {
byte c = *--srcPtr;
if (c == 0)
dstPtr++;
else
- *dstPtr++ = lookup[ c ];
+ *dstPtr++ = lookup[c];
}
}
}
Commit: a6827afb6e313800495bcef752dbbf417f10266c
https://github.com/scummvm/scummvm/commit/a6827afb6e313800495bcef752dbbf417f10266c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:07+02:00
Commit Message:
SAGA2: Re-added accidentally removed debug code
Changed paths:
engines/saga2/blitters.cpp
diff --git a/engines/saga2/blitters.cpp b/engines/saga2/blitters.cpp
index 8c95f4f785..8a7501ac77 100644
--- a/engines/saga2/blitters.cpp
+++ b/engines/saga2/blitters.cpp
@@ -210,6 +210,22 @@ void drawTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData) {
}
}
}
+
+ // Compute dirty rect
+ int rectX = MAX<int>(drawPoint.x, 0);
+ int rectY = MAX<int>(drawPoint.y, 0);
+ int rectX2 = MIN<int>(drawPoint.x + SAGA_ISOTILE_WIDTH, map->size.x);
+ int rectY2 = lowBound;
+ debugC(3, kDebugTiles, "Rect = (%d,%d,%d,%d)", rectX, rectY, rectX2, rectY2);
+
+#if 0
+ Graphics::Surface sur;
+ sur.create(map->size.x, map->size.y, Graphics::PixelFormat::createFormatCLUT8());
+ sur.setPixels(map->data);
+ //sur.debugPrint();
+ g_system->copyRectToScreen(sur.getPixels(), sur.pitch, 0, 0, sur.w, sur.h);
+ g_system->updateScreen();
+#endif
}
Commit: c432dc7442cac2d273a860266f7ac57c6ea3f3ee
https://github.com/scummvm/scummvm/commit/c432dc7442cac2d273a860266f7ac57c6ea3f3ee
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:07+02:00
Commit Message:
SAGA2: Cleanup tileload.cpp
Changed paths:
engines/saga2/tile.cpp
engines/saga2/tileload.cpp
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 3727d92ca6..310ac89135 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -106,7 +106,6 @@ void setAreaSound(const TilePoint &baseCoords);
TileBankPtr tileBanks[maxBanks];
extern HandleArray tileImageBanks;
-void tileFault(int bank, int num);
void updateHandleRefs(const TilePoint &pt); //, StandingTileInfo *stiResult )
void updateFrameCount(void);
diff --git a/engines/saga2/tileload.cpp b/engines/saga2/tileload.cpp
index 64ff9870ba..f88894a845 100644
--- a/engines/saga2/tileload.cpp
+++ b/engines/saga2/tileload.cpp
@@ -36,46 +36,14 @@ namespace Saga2 {
const uint16 tileBankCount = 25;
-const uint32 tileImageID = MKTAG('T', 'I', 'L', 0);
+const uint32 tileImageID = MKTAG('T', 'I', 'L', 0);
-/* ===================================================================== *
- Prototypes
- * ===================================================================== */
-
-// Assembly-language function to copy pixel to SVGA
-
-#if DEBUG
-void TPLine(const TilePoint &start, const TilePoint &stop);
-#endif
-
-
-/* ===================================================================== *
- Imports
- * ===================================================================== */
extern gPixelMap tileDrawMap;
-
extern int16 currentMapNum;
-
extern hResource *objResFile;
-
-/* ===================================================================== *
- Tile structure management
- * ===================================================================== */
-
extern hResContext *tileRes; // tile resource handle
-/* ===================================================================== *
- Debugging displays
- * ===================================================================== */
-
-void sprintBA(char buf[], BitArray *x);
-
-/* ===================================================================== *
- Debugging displays
- * ===================================================================== */
-
-
static byte *tileResLoad(hResID i, bool asynch = FALSE) {
if (tileRes)
return tileRes->loadResource(i, "tile image bank");
@@ -83,42 +51,13 @@ static byte *tileResLoad(hResID i, bool asynch = FALSE) {
return nullptr;
}
-
-//LoadOnCall<UByteHandle> tileImageBanks(64, tileResLoad, tileImageID);
HandleArray tileImageBanks(64, tileResLoad, tileImageID);
-/* ===================================================================== *
- Debugging displays
- * ===================================================================== */
-
-
-void showBanks() {
-}
-
-void showBank(BankBits bb) {
- WriteStatusF(4, "%8.8X:%8.8X ", bb.b[1], bb.b[0]);
-}
-
-void sprintBA(char buf[], BitArray *x) {
- uint32 v;
- if (x->currentSize())
- for (int16 i = (uint16) x->currentSize() / 32 ; i >= 0; i--) {
- v = x->getChunk(i);
- sprintf(buf, "%8.8X", v);
- if (i) sprintf(buf, ",");
- }
-}
-
-/* ===================================================================== *
- load tile resources as needed
- * ===================================================================== */
-
void initTileBank(int16 bankNum) {
byte *th;
th = tileImageBanks[bankNum];
}
-
void RHeapsAMess(void);
void freeAllTileBanks(void) {
@@ -138,15 +77,6 @@ void updateHandleRefs(const TilePoint &) { //, StandingTileInfo *stiResult )
tileImageBanks.flush();
}
-#if DEBUG
-void tileFault(int bank, int num) {
- WriteStatusF(0, "Bad Tile: %d/%d", bank, num);
-}
-#else
-void tileFault(int, int) {
-}
-#endif
-
void initTileBanks(void) {
for (int16 i = 0; i < tileBankCount; i++)
initTileBank(i);
@@ -157,7 +87,6 @@ void drawPlatform(
Point16 screenPos, // screen position
int16 uOrg, // for TAG search
int16 vOrg) { // for TAG search
- int16 u, v;
int16 right = tileDrawMap.size.x,
bottom = tileDrawMap.size.y;
@@ -171,21 +100,21 @@ void drawPlatform(
tilePos.y = screenPos.y - (platformWidth - 1) * tileHeight;
- u = platformWidth - 1;
- v = platformWidth - 1;
+ int16 u = platformWidth - 1;
+ int16 v = platformWidth - 1;
debugC(3, kDebugTiles, "drawPlatform: right = %d, bottom = %d, x = %d, x2 = %d, origin = %d,%d, tilePos.y=%d, u,v = %d,%d", right, bottom, x, x2, origin.u, origin.v,
tilePos.y, u, v);
for (int row = 0; row < 15; row++) {
if (tilePos.y > 0) {
- int16 col = 0;
+ int16 col = 0;
TilePoint pCoords(u, v, 0);
tilePos.x = x;
if (length > x2) {
- int16 offset = (length - x2) >> 1;
+ int16 offset = (length - x2) >> 1;
pCoords.u += offset;
pCoords.v -= offset;
@@ -199,36 +128,25 @@ void drawPlatform(
col += 2,
pCoords.u++,
pCoords.v--,
- tilePos.x += tileWidth
- ) {
- Platform **pGet;
-
- if (tilePos.x < 0) continue;
-
- for (pGet = pList; *pGet; pGet++) {
- Platform &p = **pGet;
- int16 h,
- y;
- TileInfo *ti;
- uint8 *imageData;
- int16 trFlags;
-
- ti = p.fetchTile(
- currentMapNum,
- pCoords,
- origin,
- &imageData,
- h,
- trFlags);
- if (ti == NULL) continue;
-
- y = tilePos.y - h;
-
- if (ti->attrs.height > 0
- && y < bottom + ti->attrs.height - 1) {
- drawTile(&tileDrawMap,
- tilePos.x, y, ti->attrs.height,
- imageData);
+ tilePos.x += tileWidth) {
+
+ if (tilePos.x < 0)
+ continue;
+
+ for (Platform **pGet = pList; *pGet; pGet++) {
+ Platform &p = **pGet;
+ int16 h;
+ uint8 *imageData;
+ int16 trFlags;
+
+ TileInfo *ti = p.fetchTile(currentMapNum, pCoords, origin, &imageData, h, trFlags);
+ if (ti == NULL)
+ continue;
+
+ int16 y = tilePos.y - h;
+
+ if (ti->attrs.height > 0 && y < bottom + ti->attrs.height - 1) {
+ drawTile(&tileDrawMap, tilePos.x, y, ti->attrs.height, imageData);
}
}
}
Commit: 1481a8c9dfa1cdec458bb246a0c9a9330722c61d
https://github.com/scummvm/scummvm/commit/1481a8c9dfa1cdec458bb246a0c9a9330722c61d
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:07+02:00
Commit Message:
SAGA2: Work on fixing map loading
Changed paths:
engines/saga2/tile.cpp
engines/saga2/tile.h
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 310ac89135..b3e8ac53f4 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -1410,6 +1410,24 @@ void cleanupTileTasks(void) {
//-----------------------------------------------------------------------
// Initialize map data
+static void readTileBank(hResContext *con, TileBank *tb) {
+ tb->numTiles = con->readU32LE();
+ tb->tileArray->offset = con->readU32LE();
+ TileAttrs *att = &tb->tileArray->attrs;
+ att->terrainHeight = con->readByte();
+ att->height = con->readByte();
+ att->terrainMask = con->readU16LE();
+ att->fgdTerrain = con->readByte();
+ att->bgdTerrain = con->readByte();
+ con->read(att->reserved0, 8);
+ att->maskRule = con->readByte();
+ att->altMask = con->readByte();
+ con->read(att->cornerHeight, 4);
+ att->cycleRange = con->readByte();
+ att->tileFlags = con->readByte();
+ att->reserved1 = con->readU16LE();
+}
+
static void readMetaTile(hResContext *con, MetaTile &til) {
til.highestPixel = con->readU16LE();
til.banksNeeded.b[0] = con->readU32LE();
@@ -1421,16 +1439,34 @@ static void readMetaTile(hResContext *con, MetaTile &til) {
til.properties = con->readU32LE();
}
+static void readMap(hResContext *con, MapHeader *map) {
+ map->size = con->readS16LE();
+ map->edgeType = con->readS16LE();
+ map->mapData = new uint16[map->size * map->size];
+
+ for (int i = 0; i < map->size * map->size; ++i)
+ map->mapData[i] = con->readU16LE();
+}
+
static void readActiveItem(hResContext *con, ActiveItem &itm) {
// FIXME: 32-bit pointer to 64-bit pointer conversion.
// Is this dangerous?
- itm.nextHash = (ActiveItemPtr)con->readU32LE();
+ itm.nextHash = nullptr;
+ con->readU32LE();
itm.scriptClassID = con->readU16LE();
itm.associationOffset = con->readU16LE();
itm.numAssociations = con->readByte();
itm.itemType = con->readByte();
- itm.group.grDataOffset = con->readU16LE();
itm.instance.groupID = con->readU16LE();
+ itm.instance.u = con->readS16LE();
+ itm.instance.v = con->readS16LE();
+ itm.instance.h = con->readS16LE();
+ itm.instance.stateIndex = con->readU16LE();
+ itm.instance.scriptFlags = con->readU16LE();
+ itm.instance.targetU = con->readU16LE();
+ itm.instance.targetV = con->readU16LE();
+ itm.instance.targetZ = con->readByte();
+ itm.instance.worldNum = con->readByte();
}
void initMaps(void) {
@@ -1438,14 +1474,13 @@ void initMaps(void) {
const int metaTileSize = 30;
const int tileRefSize = 4;
const int assocSize = 2;
- const int activeItemSize = 14;
+ const int activeItemSize = 28;
// Load all of the tile terrain banks
for (i = 0; i < maxBanks; i++) {
if (tileRes->seek(tileTerrainID + MKTAG(0, 0, 0, (uint8)i))) {
- tileBanks[i] = (TileBankPtr)LoadResource(tileRes,
- tileTerrainID + MKTAG(0, 0, 0, (uint8)i),
- "tile terrain bank");
+ tileBanks[i] = new TileBank;
+ readTileBank(tileRes, tileBanks[i]);
} else
tileBanks[i] = nullptr;
}
@@ -1464,19 +1499,26 @@ void initMaps(void) {
for (i = 0; i < worldCount; i++) {
WorldMapData *mapData = &mapList[i];
int16 j;
+ int iMapID = mapID + MKTAG(0, 0, 0, (uint8)i);
+ int iMetaID = metaID + MKTAG(0, 0, 0, (uint8)i);
+ int iTagRefID = tagDataID + MKTAG(0, 0, 0, (uint8)i);
+ int iAssocID = assocID + MKTAG(0, 0, 0, (uint8)i);
+ int iActiveItemID = tagID + MKTAG(0, 0, 0, (uint8)i);
// Initialize the world ID
mapData->worldID = WorldBaseID + i;
// Load the map
- mapData->map = (MapPtr)LoadResource(tileRes,
- mapID + MKTAG(0, 0, 0, (uint8)i), "world map");
+ mapData->map = new MapHeader;
+ tileRes->seek(iMapID);
+ readMap(tileRes, mapData->map);
if (mapData->map == nullptr)
error("Unable to load map");
- debugC(3, kDebugTiles, "map: size = %d, mapData = %p", mapData->map->size, (void*)mapData->map->mapData);
+ debugC(2, kDebugTiles, "map: size = %d, mapData = %p", mapData->map->size, (void*)mapData->map->mapData);
- int metaTileCount = tileRes->size(metaID + MKTAG(0, 0, 0, (uint8)i)) / metaTileSize;
+ int metaTileCount = tileRes->size(iMetaID) / metaTileSize;
mapData->metaList = new MetaTile[metaTileCount]();
+ tileRes->seek(iMetaID);
for (int k = 0; k < metaTileCount; ++k)
readMetaTile(tileRes, mapData->metaList[k]);
@@ -1484,12 +1526,13 @@ void initMaps(void) {
error("Unable to load meta tile list");
// If there is tag data, load it
- if (tileRes->size(tagDataID + MKTAG(0, 0, 0, (uint8)i)) > 0) {
- int tileRefCount = tileRes->size(tagDataID + MKTAG(0, 0, 0, (uint8)i)) / tileRefSize;
+ if (tileRes->size(iTagRefID) > 0) {
+ int tileRefCount = tileRes->size(iTagRefID) / tileRefSize;
mapData->activeItemData = new TileRef[tileRefCount]();
if (mapData->activeItemData == nullptr)
error("Unable to load active item data");
+ tileRes->seek(iTagRefID);
for (int k = 0; k < tileRefCount; ++k) {
mapData->activeItemData[k].tile = tileRes->readU16LE();
mapData->activeItemData[k].flags = tileRes->readByte();
@@ -1499,21 +1542,23 @@ void initMaps(void) {
mapData->activeItemData = nullptr;
// If there is an association list, load it
- if (tileRes->size(assocID + MKTAG(0, 0, 0, (uint8)i)) > 0) {
- int assocCount = tileRes->size(assocID + MKTAG(0, 0, 0, (uint8)i)) / assocSize;
+ if (tileRes->size(iAssocID) > 0) {
+ int assocCount = tileRes->size(iAssocID) / assocSize;
mapData->assocList = new uint16[assocCount]();
if (mapData->assocList == nullptr)
error("Unable to load association list");
+ tileRes->seek(iAssocID);
for (int k = 0; k < assocCount; ++k)
mapData->assocList[k] = tileRes->readU16LE();
} else
mapData->assocList = nullptr;
// If there is an active item list, load it
- if (tileRes->size(tagID + MKTAG(0, 0, 0, (uint8)i)) > 0) {
- int activeItemCount = tileRes->size(tagID + MKTAG(0, 0, 0, (uint8)i)) / activeItemSize;
+ if (tileRes->size(iActiveItemID) > 0) {
+ int activeItemCount = tileRes->size(iActiveItemID) / activeItemSize;
mapData->activeItemList = new ActiveItem[activeItemCount];
+ tileRes->seek(iActiveItemID);
for (int k = 0; k < activeItemCount; ++k)
readActiveItem(tileRes, mapData->activeItemList[k]);
@@ -2207,6 +2252,20 @@ metaTileNoise MetaTile::HeavyMetaMusic(void) {
//-----------------------------------------------------------------------
// Return a pointer to the specified platform
+static void readPlatform(hResContext *con, Platform &plt) {
+ plt.height = con->readU16LE();
+ plt.highestPixel = con->readU16LE();
+ plt.flags = con->readU16LE();
+
+ for (int j = 0; j < platformWidth; ++j) {
+ for (int i = 0; i < platformWidth; ++i) {
+ plt.tiles[j][i].tile = con->readU16LE();
+ plt.tiles[j][i].flags = con->readByte();
+ plt.tiles[j][i].tileHeight = con->readByte();
+ }
+ }
+}
+
Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
const int cacheFlag = 0x8000;
@@ -2280,10 +2339,8 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
// Now, load the actual metatile data...
if (tileRes->seek(platformID + MKTAG(0, 0, 0, mapNum))) {
if (tileRes->skip(plIndex * sizeof(Platform))) {
- if (tileRes->read(&pce->pl, sizeof(Platform)));
- {
- return &pce->pl;
- }
+ readPlatform(tileRes, pce->pl);
+ return &pce->pl;
}
}
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index 4095a73b88..40ea698273 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -845,7 +845,7 @@ typedef MetaTile *MetaTilePtr,
struct MapHeader {
int16 size; // size of map
int16 edgeType; // edge type of map
- uint16 mapData[1]; // start of map array
+ uint16 *mapData; // start of map array
};
enum mapEdgeTypes {
Commit: 419b3f850681de9a9f8848b7f0a926818b3b613c
https://github.com/scummvm/scummvm/commit/419b3f850681de9a9f8848b7f0a926818b3b613c
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:07+02:00
Commit Message:
SAGA2: Fix tileBanks loading
Changed paths:
engines/saga2/tile.cpp
engines/saga2/tile.h
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index b3e8ac53f4..c9936c7b6f 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -1410,22 +1410,25 @@ void cleanupTileTasks(void) {
//-----------------------------------------------------------------------
// Initialize map data
-static void readTileBank(hResContext *con, TileBank *tb) {
+static void readTileBank(hResContext *con, int count, TileBank *tb) {
tb->numTiles = con->readU32LE();
- tb->tileArray->offset = con->readU32LE();
- TileAttrs *att = &tb->tileArray->attrs;
- att->terrainHeight = con->readByte();
- att->height = con->readByte();
- att->terrainMask = con->readU16LE();
- att->fgdTerrain = con->readByte();
- att->bgdTerrain = con->readByte();
- con->read(att->reserved0, 8);
- att->maskRule = con->readByte();
- att->altMask = con->readByte();
- con->read(att->cornerHeight, 4);
- att->cycleRange = con->readByte();
- att->tileFlags = con->readByte();
- att->reserved1 = con->readU16LE();
+ tb->tileArray = new TileInfo[count];
+ for (int i = 0; i < count; ++i) {
+ tb->tileArray[i].offset = con->readU32LE();
+ TileAttrs *att = &tb->tileArray[i].attrs;
+ att->terrainHeight = con->readByte();
+ att->height = con->readByte();
+ att->terrainMask = con->readU16LE();
+ att->fgdTerrain = con->readByte();
+ att->bgdTerrain = con->readByte();
+ con->read(att->reserved0, 8);
+ att->maskRule = con->readByte();
+ att->altMask = con->readByte();
+ con->read(att->cornerHeight, 4);
+ att->cycleRange = con->readByte();
+ att->tileFlags = con->readByte();
+ att->reserved1 = con->readU16LE();
+ }
}
static void readMetaTile(hResContext *con, MetaTile &til) {
@@ -1471,6 +1474,7 @@ static void readActiveItem(hResContext *con, ActiveItem &itm) {
void initMaps(void) {
int16 i;
+ const int tileInfoSize = 28;
const int metaTileSize = 30;
const int tileRefSize = 4;
const int assocSize = 2;
@@ -1480,7 +1484,9 @@ void initMaps(void) {
for (i = 0; i < maxBanks; i++) {
if (tileRes->seek(tileTerrainID + MKTAG(0, 0, 0, (uint8)i))) {
tileBanks[i] = new TileBank;
- readTileBank(tileRes, tileBanks[i]);
+ int tileBankSize = tileRes->size(tileTerrainID + MKTAG(0, 0, 0, (uint8)i));
+ int tiCount = (tileBankSize - 4) / tileInfoSize;
+ readTileBank(tileRes, tiCount, tileBanks[i]);
} else
tileBanks[i] = nullptr;
}
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index 40ea698273..e6b8078f9f 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -312,7 +312,7 @@ struct TileInfo {
class TileBank {
public:
uint32 numTiles; // number of tiles in list
- TileInfo tileArray[1]; // variable-sized array
+ TileInfo *tileArray; // variable-sized array
TileInfo *tile(uint16 index) {
return &tileArray[index];
Commit: 24eb580ea378745ae55c93d4fc8d3d5ae21b733d
https://github.com/scummvm/scummvm/commit/24eb580ea378745ae55c93d4fc8d3d5ae21b733d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:07+02:00
Commit Message:
SAGA2: Remove anonymous struct in actor.h
Changed paths:
engines/saga2/actor.h
engines/saga2/player.cpp
diff --git a/engines/saga2/actor.h b/engines/saga2/actor.h
index d283909d39..6026d0323d 100644
--- a/engines/saga2/actor.h
+++ b/engines/saga2/actor.h
@@ -105,32 +105,22 @@ struct ActorAttributes {
vitalityLimit = 256,
};
- union {
- struct {
-
- // Automatic skills
- uint8 archery, // Accuracy of missile weapons
- swordcraft, // Accuracy of bladed melee weapons
- shieldcraft, // Actor's ability to use a shield
- bludgeon, // Accuracy of non-bladed melee weapons
- throwing, // Ability to throw objects accurately
- spellcraft, // Accuracy of spell combat
- stealth, // Ability to remain unnoticed
- agility, // Ability to dodge
- brawn, // Ability to lift, and damage of weapons
- lockpick; // Ability to pick locks
-
- // Manual skills
- uint8 pilfer, // Ability to "lift" an item
- firstAid, // Ability to heal recent injuries
- spotHidden; // Ability to spot hidden objects
-
-
- };
-
- uint8 allSkills[numSkills]; // number of skills
- };
-
+ // Automatic skills
+ uint8 archery, // Accuracy of missile weapons
+ swordcraft, // Accuracy of bladed melee weapons
+ shieldcraft, // Actor's ability to use a shield
+ bludgeon, // Accuracy of non-bladed melee weapons
+ throwing, // Ability to throw objects accurately
+ spellcraft, // Accuracy of spell combat
+ stealth, // Ability to remain unnoticed
+ agility, // Ability to dodge
+ brawn, // Ability to lift, and damage of weapons
+ lockpick; // Ability to pick locks
+
+ // Manual skills
+ uint8 pilfer, // Ability to "lift" an item
+ firstAid, // Ability to heal recent injuries
+ spotHidden; // Ability to spot hidden objects
// Pad byte for alignment
int8 pad;
@@ -139,24 +129,41 @@ struct ActorAttributes {
int16 vitality;
// Magic energy
- union {
- struct {
- int16 redMana,
- orangeMana,
- yellowMana,
- greenMana,
- blueMana,
- violetMana;
- };
-
- int16 allManas[numManas];
- };
+ int16 redMana,
+ orangeMana,
+ yellowMana,
+ greenMana,
+ blueMana,
+ violetMana;
uint8 &skill(int16 id) {
- return allSkills[id];
+ switch (id) {
+ case skillIDArchery: return archery;
+ case skillIDSwordcraft: return swordcraft;
+ case skillIDShieldcraft: return shieldcraft;
+ case skillIDBludgeon: return bludgeon;
+ case skillIDThrowing: return throwing;
+ case skillIDSpellcraft: return spellcraft;
+ case skillIDStealth: return stealth;
+ case skillIDAgility: return agility;
+ case skillIDBrawn: return brawn;
+ case skillIDLockpick: return lockpick;
+ case skillIDPilfer: return pilfer;
+ case skillIDFirstAid: return firstAid;
+ case skillIDSpotHidden: return spotHidden;
+ }
+ error("Incorrect skill id: %d", id);
}
int16 &mana(int16 id) {
- return allManas[id];
+ switch (id) {
+ case manaIDRed: return redMana;
+ case manaIDOrange: return orangeMana;
+ case manaIDYellow: return yellowMana;
+ case manaIDGreen: return greenMana;
+ case manaIDBlue: return blueMana;
+ case manaIDViolet: return violetMana;
+ }
+ error("Incorrect mana id: %d", id);
}
uint8 getSkillLevel(int16 id) {
diff --git a/engines/saga2/player.cpp b/engines/saga2/player.cpp
index cc05d1f098..8f4f706562 100644
--- a/engines/saga2/player.cpp
+++ b/engines/saga2/player.cpp
@@ -149,8 +149,8 @@ void PlayerActor::AttribUpdate(void) {
for (int16 i = 0; i < numSkills; i++) {
// go through each skill and update as needed
- stdAttribUpdate(effStats->allSkills[i],
- baseStats.allSkills[i],
+ stdAttribUpdate(effStats->skill(i),
+ baseStats.skill(i),
i);
}
}
Commit: ffc0ed5fd2247c74dab13d45cb0f33ffbd1e86ab
https://github.com/scummvm/scummvm/commit/ffc0ed5fd2247c74dab13d45cb0f33ffbd1e86ab
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:07+02:00
Commit Message:
SAGA2: Eliminate global objects in weapons.cpp
Changed paths:
engines/saga2/combat.h
engines/saga2/effects.h
engines/saga2/idtypes.h
engines/saga2/objproto.cpp
engines/saga2/saga2.cpp
engines/saga2/saga2.h
engines/saga2/towerfta.cpp
engines/saga2/weapons.cpp
engines/saga2/weapons.h
diff --git a/engines/saga2/combat.h b/engines/saga2/combat.h
index cf5cdaf47d..cec659c735 100644
--- a/engines/saga2/combat.h
+++ b/engines/saga2/combat.h
@@ -39,7 +39,6 @@ enum weaponHitType {
//-----------------------------------------------------------------------
-typedef uint16 weaponID;
#define nullWeapon 0
enum combatSound {
diff --git a/engines/saga2/effects.h b/engines/saga2/effects.h
index ccd1697749..00a77ce26f 100644
--- a/engines/saga2/effects.h
+++ b/engines/saga2/effects.h
@@ -72,60 +72,10 @@ enum effectTypes {
effectTAG, // mana drain, money drain
effectLocation, // mana drain, money drain
effectSpecial,
- effectStrike, // weapon strike effect
+ effectStrike // weapon strike effect
};
-//
-// Attribute effects - look familiar ?
-//
-/* all the skill* are now in the spellid enum
-enum effectAttribTypes {
- skillArchery = 0,
- skillSwordcraft = 1,
- skillShieldcraft = 2,
- skillBludgeon = 3,
- skillThrowing = 4,
- skillSpellcraft = 5,
- skillStealth = 6,
- skillAgility = 7,
- skillBrawn = 8,
- skillLockpick = 9,
- skillPilfer = 10,
- skillFirstAid = 11,
- skillSpotHidden = 12,
-};
-*/
-//
-// Damage effects - these are the types of damage in the world
-// Damage being defined as a change in effective vitality
-// Note that healing is negative damage.
-//
-
-enum effectDamageTypes {
- // Generic
- damageOther = 0, // Healing, cause wounds
- // Combat damage
- damageImpact = 1, // hammers, maces
- damageSlash = 2, // swords
- damageProjectile = 3, // arrows, poin-ted sticks
- // Magic damage
- damageFire = 4, // Yellow
- damageAcid = 5, // Violet
- damageHeat = 6, // Red
- damageCold = 7, // Blue
- damageLightning = 8, // Orange
- damagePoison = 9, // Green
- // Other magic damage
- damageMental = 10, // dain bramage
- damageToUndead = 11, // undead take this damage
- damageDirMagic = 12, // the plusses on swords etc.
- // Physiological Damage
- damageStarve = 13, // You must eat!
- // other
- damageEnergy = 14, // Generally hard to resist - god damage
-};
-
//
// Resistance Effects - these correspond exactly to the Damage types
// A separate enum is defined to permit differentiation between
diff --git a/engines/saga2/idtypes.h b/engines/saga2/idtypes.h
index c611c21a39..35ac0ebb72 100644
--- a/engines/saga2/idtypes.h
+++ b/engines/saga2/idtypes.h
@@ -230,6 +230,38 @@ typedef uint8 ColorTable[256];
// number of containers
const int kNumViews = 3;
+enum {
+ kMaxWeapons = 256
+};
+
+//
+// Damage effects - these are the types of damage in the world
+// Damage being defined as a change in effective vitality
+// Note that healing is negative damage.
+//
+enum effectDamageTypes {
+ // Generic
+ damageOther = 0, // Healing, cause wounds
+ // Combat damage
+ damageImpact = 1, // hammers, maces
+ damageSlash = 2, // swords
+ damageProjectile = 3, // arrows, poin-ted sticks
+ // Magic damage
+ damageFire = 4, // Yellow
+ damageAcid = 5, // Violet
+ damageHeat = 6, // Red
+ damageCold = 7, // Blue
+ damageLightning = 8, // Orange
+ damagePoison = 9, // Green
+ // Other magic damage
+ damageMental = 10, // dain bramage
+ damageToUndead = 11, // undead take this damage
+ damageDirMagic = 12, // the plusses on swords etc.
+ // Physiological Damage
+ damageStarve = 13, // You must eat!
+ // other
+ damageEnergy = 14 // Generally hard to resist - god damage
+};
} // end of namespace Saga2
diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp
index 3c472f97fc..23913ed755 100644
--- a/engines/saga2/objproto.cpp
+++ b/engines/saga2/objproto.cpp
@@ -37,6 +37,7 @@
#include "saga2/weapons.h"
#include "saga2/spellbuk.h"
#include "saga2/combat.h"
+#include "saga2/tile.h"
#include "saga2/methods.r"
#include "saga2/pclass.r"
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index 3bc789fee6..aa9f85eefa 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -63,7 +63,7 @@ Saga2Engine::Saga2Engine(OSystem *syst)
SearchMan.addSubDirectoryMatching(gameDataDir, "res");
- debug("Saga2Engine::Saga2Engine");
+ _loadedWeapons = 0;
}
Saga2Engine::~Saga2Engine() {
diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h
index a4b77e2c52..1922a41ad2 100644
--- a/engines/saga2/saga2.h
+++ b/engines/saga2/saga2.h
@@ -28,6 +28,9 @@
#include "common/system.h"
#include "engines/engine.h"
+#include "saga2/idtypes.h"
+#include "saga2/weapons.h"
+
namespace Video {
class SmackerDecoder;
};
@@ -74,6 +77,9 @@ public:
// We need random numbers
Common::RandomSource *_rnd;
+ WeaponStuff _weaponRack[kMaxWeapons];
+ weaponID _loadedWeapons = 0;
+
private:
Video::SmackerDecoder *_smkDecoder;
int _videoX, _videoY;
diff --git a/engines/saga2/towerfta.cpp b/engines/saga2/towerfta.cpp
index b9f8bd5588..3842e8100f 100644
--- a/engines/saga2/towerfta.cpp
+++ b/engines/saga2/towerfta.cpp
@@ -39,6 +39,7 @@
#include "saga2/weapons.h"
#include "saga2/loadsave.h"
#include "saga2/display.h"
+#include "saga2/tile.h"
namespace Saga2 {
diff --git a/engines/saga2/weapons.cpp b/engines/saga2/weapons.cpp
index ea3c7629a5..3a316df31b 100644
--- a/engines/saga2/weapons.cpp
+++ b/engines/saga2/weapons.cpp
@@ -26,6 +26,7 @@
#include "saga2/std.h"
#include "saga2/weapons.h"
+#include "saga2/spelshow.h"
#include "saga2/spellbuk.h"
#include "saga2/actor.h"
#include "saga2/spellio.h"
@@ -45,28 +46,8 @@ namespace Saga2 {
// which relate to spell casting
//
-/* ===================================================================== *
- Constants
- * ===================================================================== */
-
-const int32 maxWeapons = 256;
-const int32 maxWeaponPrototypes = 256;
-
-/* ===================================================================== *
- Global data
- * ===================================================================== */
-
-WeaponStuff weaponRack[maxWeapons];
-weaponID loadedWeapons = 0;
-
-
-//-----------------------------------------------------------------------
-// prototypes
-
static void loadWeaponData(void);
-//-----------------------------------------------------------------------
-
ProtoEffect *createNewProtoEffect(ResourceItemEffect *rie) {
ProtoEffect *pe = NULL;
@@ -157,16 +138,16 @@ void initWeapons(void) {
//-----------------------------------------------------------------------
void cleanupWeapons(void) {
- for (int i = 0; i < maxWeapons; i++)
- weaponRack[i].killEffects();
+ for (int i = 0; i < kMaxWeapons; i++)
+ g_vm->_weaponRack[i].killEffects();
}
//-----------------------------------------------------------------------
WeaponStuff &getWeapon(weaponID i) {
- if (i < loadedWeapons)
- return weaponRack[i];
- return weaponRack[nullWeapon];
+ if (i < g_vm->_loadedWeapons)
+ return g_vm->_weaponRack[i];
+ return g_vm->_weaponRack[nullWeapon];
}
//-----------------------------------------------------------------------
@@ -184,7 +165,10 @@ GameObject *getShieldItem(GameObject *defender) {
WeaponProtoEffect member functions
* ===================================================================== */
-//-----------------------------------------------------------------------
+WeaponProtoEffect::~WeaponProtoEffect(void) {
+ if (effect != NULL)
+ delete effect;
+}
void WeaponProtoEffect::implement(
Actor *enactor,
@@ -338,14 +322,14 @@ static void loadWeaponData(void) {
error("Unable to load weapon effect %d", i);
if (rie->item) {
- weaponRack[rie->item].setID(rie->item);
- weaponRack[rie->item].addEffect(rie);
+ g_vm->_weaponRack[rie->item].setID(rie->item);
+ g_vm->_weaponRack[rie->item].addEffect(rie);
}
RDisposePtr(rie);
i++;
}
- loadedWeapons = i;
+ g_vm->_loadedWeapons = i;
assert(i > 1);
auxResFile->disposeContext(spellRes);
diff --git a/engines/saga2/weapons.h b/engines/saga2/weapons.h
index b2912a9390..25801b2904 100644
--- a/engines/saga2/weapons.h
+++ b/engines/saga2/weapons.h
@@ -27,12 +27,14 @@
#ifndef SAGA2_WEAPONS_H
#define SAGA2_WEAPONS_H
-#include "saga2/spelshow.h"
-
namespace Saga2 {
struct ResourceItemEffect;
+class Actor;
+class GameObject;
+class ProtoEffect;
+
ProtoEffect *createNewProtoEffect(ResourceItemEffect *rie);
//-----------------------------------------------------------------------
@@ -59,9 +61,7 @@ public:
WeaponProtoEffect(ResourceItemEffect *rie) :
effect(createNewProtoEffect(rie)) {
}
- ~WeaponProtoEffect(void) {
- if (effect != NULL) delete effect;
- }
+ ~WeaponProtoEffect(void);
void implement(
Actor *enactor,
Commit: c4071bc8e958c90f8c255d5d2746f48155d4fca8
https://github.com/scummvm/scummvm/commit/c4071bc8e958c90f8c255d5d2746f48155d4fca8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:07+02:00
Commit Message:
SAGA2: Cleanup for weapons.cpp
Changed paths:
engines/saga2/weapons.cpp
diff --git a/engines/saga2/weapons.cpp b/engines/saga2/weapons.cpp
index 3a316df31b..9c0549f387 100644
--- a/engines/saga2/weapons.cpp
+++ b/engines/saga2/weapons.cpp
@@ -49,113 +49,72 @@ namespace Saga2 {
static void loadWeaponData(void);
ProtoEffect *createNewProtoEffect(ResourceItemEffect *rie) {
- ProtoEffect *pe = NULL;
+ ProtoEffect *pe = NULL;
switch (rie->effectGroup) {
- case effectNone :
+ case effectNone:
return NULL;
- case effectAttrib :
- pe = new ProtoEnchantment(
- makeEnchantmentID(
- rie->effectGroup,
- rie->effectType,
- rie->baseDamage),
- rie->reserved0,
- rie->reserved1);
+ case effectAttrib:
+ pe = new ProtoEnchantment(makeEnchantmentID(rie->effectGroup, rie->effectType, rie->baseDamage),
+ rie->reserved0, rie->reserved1);
break;
- case effectResist :
- case effectImmune :
- case effectOthers :
- case effectNonActor :
- pe = new ProtoEnchantment(
- makeEnchantmentID(
- rie->effectGroup,
- rie->effectType,
- rie->skillDamage),
- rie->reserved0,
- rie->reserved1);
+ case effectResist:
+ case effectImmune:
+ case effectOthers:
+ case effectNonActor:
+ pe = new ProtoEnchantment(makeEnchantmentID(rie->effectGroup, rie->effectType, rie->skillDamage),
+ rie->reserved0, rie->reserved1);
break;
- case effectDamage :
- pe = new ProtoDamage(
- rie->baseDice,
- rie->diceSides ? rie->diceSides : 6,
- rie->skillDice,
- rie->baseDamage,
- (effectDamageTypes) rie->effectType,
- 0,
- rie->targeting & spellTargCaster,
- rie->skillDamage);
+ case effectDamage:
+ pe = new ProtoDamage(rie->baseDice, rie->diceSides ? rie->diceSides : 6, rie->skillDice, rie->baseDamage,
+ (effectDamageTypes) rie->effectType, 0, rie->targeting & spellTargCaster, rie->skillDamage);
break;
- case effectDrains :
- pe = new ProtoDrainage(
- rie->baseDice,
- rie->diceSides ? rie->diceSides : 6,
- rie->skillDice,
- rie->baseDamage,
- (effectDrainsTypes) rie->effectType,
- 0,
- rie->targeting & spellTargCaster);
+ case effectDrains:
+ pe = new ProtoDrainage(rie->baseDice, rie->diceSides ? rie->diceSides : 6, rie->skillDice, rie->baseDamage,
+ (effectDrainsTypes) rie->effectType, 0, rie->targeting & spellTargCaster);
break;
- case effectPoison :
- pe = new ProtoEnchantment(
- makeEnchantmentID(rie->baseDamage), // poison
- rie->reserved0,
- rie->reserved1);
-
- case effectTAG :
- pe = new ProtoTAGEffect(
- (effectTAGTypes) rie->effectType,
- rie->skillDamage,
- rie->baseDamage);
+ case effectPoison:
+ pe = new ProtoEnchantment(makeEnchantmentID(rie->baseDamage), // poison
+ rie->reserved0, rie->reserved1);
+
+ case effectTAG:
+ pe = new ProtoTAGEffect((effectTAGTypes)rie->effectType, rie->skillDamage, rie->baseDamage);
break;
- case effectLocation :
- pe = new ProtoLocationEffect(
- (effectLocationTypes) rie->effectType,
- rie->baseDamage);
+ case effectLocation:
+ pe = new ProtoLocationEffect((effectLocationTypes)rie->effectType, rie->baseDamage);
break;
- case effectSpecial :
- pe = new ProtoSpecialEffect(
- SagaSpellCall,
- rie->baseDamage);
+ case effectSpecial:
+ pe = new ProtoSpecialEffect(SagaSpellCall, rie->baseDamage);
break;
}
- if (pe == NULL)
+ if (pe == nullptr)
error("failed to alloc protoEffect");
return pe;
}
-//-----------------------------------------------------------------------
-// InitMagic called from main startup code
-
void initWeapons(void) {
loadWeaponData();
}
-//-----------------------------------------------------------------------
-
void cleanupWeapons(void) {
for (int i = 0; i < kMaxWeapons; i++)
g_vm->_weaponRack[i].killEffects();
}
-//-----------------------------------------------------------------------
-
WeaponStuff &getWeapon(weaponID i) {
if (i < g_vm->_loadedWeapons)
return g_vm->_weaponRack[i];
return g_vm->_weaponRack[nullWeapon];
}
-//-----------------------------------------------------------------------
-
GameObject *getShieldItem(GameObject *defender) {
assert(isActor(defender));
- Actor *a = (Actor *) defender;
- GameObject *obj;
+ Actor *a = (Actor *) defender;
+ GameObject *obj;
a->defensiveObject(&obj);
return obj;
@@ -164,18 +123,13 @@ GameObject *getShieldItem(GameObject *defender) {
/* ===================================================================== *
WeaponProtoEffect member functions
* ===================================================================== */
-
WeaponProtoEffect::~WeaponProtoEffect(void) {
if (effect != NULL)
delete effect;
}
-void WeaponProtoEffect::implement(
- Actor *enactor,
- GameObject *target,
- GameObject *,
- uint8) {
- SpellTarget targ(target);
+void WeaponProtoEffect::implement(Actor *enactor, GameObject *target, GameObject *, uint8) {
+ SpellTarget targ(target);
if (effect != NULL)
effect->implement(enactor, &targ);
@@ -184,41 +138,24 @@ void WeaponProtoEffect::implement(
/* ===================================================================== *
WeaponStrikeEffect member functions
* ===================================================================== */
-
-//-----------------------------------------------------------------------
-
-void WeaponStrikeEffect::implement(
- Actor *enactor,
- GameObject *target,
- GameObject *strikingObj,
- uint8 strength) {
+void WeaponStrikeEffect::implement(Actor *enactor, GameObject *target, GameObject *strikingObj, uint8 strength) {
assert(isActor(enactor));
assert(isObject(target) || isActor(target));
assert(isObject(strikingObj) || isActor(strikingObj));
- int8 totalDice,
- totalBase;
+ int8 totalDice, totalBase;
totalDice = dice + strength * skillDice;
totalBase = base + strength * skillBase;
- target->acceptDamage(
- enactor->thisID(),
- totalBase,
- type,
- totalDice,
- sides);
+ target->acceptDamage(enactor->thisID(), totalBase, type, totalDice, sides);
}
-//-----------------------------------------------------------------------
-
WeaponStuff::WeaponStuff() {
effects = NULL;
master = nullWeapon;
}
-//-----------------------------------------------------------------------
-
WeaponStuff::~WeaponStuff() {
while (effects != NULL) {
WeaponEffect *curEffect = effects;
@@ -229,8 +166,6 @@ WeaponStuff::~WeaponStuff() {
master = nullWeapon;
}
-//-----------------------------------------------------------------------
-
void WeaponStuff::killEffects(void) {
while (effects != NULL) {
WeaponEffect *curEffect = effects;
@@ -240,8 +175,6 @@ void WeaponStuff::killEffects(void) {
}
}
-//-----------------------------------------------------------------------
-
void WeaponStuff::addEffect(WeaponEffect *we) {
WeaponEffect *e = effects;
if (effects) {
@@ -252,21 +185,19 @@ void WeaponStuff::addEffect(WeaponEffect *we) {
}
}
-//-----------------------------------------------------------------------
-
void WeaponStuff::addEffect(ResourceItemEffect *rie) {
WeaponEffect *we;
assert(rie);
assert(rie && rie->item == master);
if (rie->effectGroup == effectStrike) {
- we = new WeaponStrikeEffect(
- (effectDamageTypes)rie->effectType,
- rie->baseDice,
- rie->diceSides != 0 ? rie->diceSides : 6,
- rie->skillDice,
- rie->baseDamage,
- rie->skillDamage);
+ we = new WeaponStrikeEffect(
+ (effectDamageTypes)rie->effectType,
+ rie->baseDice,
+ rie->diceSides != 0 ? rie->diceSides : 6,
+ rie->skillDice,
+ rie->baseDamage,
+ rie->skillDamage);
} else
we = new WeaponProtoEffect(rie);
@@ -277,46 +208,28 @@ void WeaponStuff::addEffect(ResourceItemEffect *rie) {
effects = we;
else {
WeaponEffect *tail;
- for (tail = effects; tail->next; tail = tail->next) ;
+ for (tail = effects; tail->next; tail = tail->next)
+ ;
tail->next = we;
}
}
-//-----------------------------------------------------------------------
-
-void WeaponStuff::implement(
- Actor *enactor,
- GameObject *target,
- GameObject *strikingObj,
- uint8 strength) {
- WeaponEffect *we;
-
- for (we = effects; we != NULL; we = we->next)
+void WeaponStuff::implement(Actor *enactor, GameObject *target, GameObject *strikingObj, uint8 strength) {
+ for (WeaponEffect *we = effects; we != NULL; we = we->next)
we->implement(enactor, target, strikingObj, strength);
}
//-----------------------------------------------------------------------
static void loadWeaponData(void) {
- int16 i;
- hResContext *spellRes;
-
- // Get spell definitions
- spellRes = auxResFile->newContext(
- MKTAG('I', 'T', 'E', 'M'),
- "weapon resources");
+ hResContext *spellRes = auxResFile->newContext(MKTAG('I', 'T', 'E', 'M'), "weapon resources");
if (spellRes == NULL || !spellRes->_valid)
error("Error accessing weapon resource group.");
// get spell effects
- i = 0;
- while (spellRes->size(
- MKTAG('E', 'F', 'F', i)) > 0) {
- ResourceItemEffect *rie =
- (ResourceItemEffect *)LoadResource(
- spellRes,
- MKTAG('E', 'F', 'F', i),
- "weapon effect");
+ int16 i = 0;
+ while (spellRes->size(MKTAG('E', 'F', 'F', i)) > 0) {
+ ResourceItemEffect *rie = (ResourceItemEffect *)LoadResource(spellRes, MKTAG('E', 'F', 'F', i), "weapon effect");
if (rie == NULL)
error("Unable to load weapon effect %d", i);
Commit: 8833b47fe444ac04fd817aba0d6cd4a75786db5f
https://github.com/scummvm/scummvm/commit/8833b47fe444ac04fd817aba0d6cd4a75786db5f
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:08+02:00
Commit Message:
SAGA2: Fix crash because of fetchPlatform
Changed paths:
engines/saga2/tile.cpp
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index c9936c7b6f..2a5910fc66 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -2273,8 +2273,6 @@ static void readPlatform(hResContext *con, Platform &plt) {
}
Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
- const int cacheFlag = 0x8000;
-
uint16 plIndex = stack[layer];
PlatformCacheEntry *pce;
@@ -2286,73 +2284,41 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
if (plIndex == nullID) {
return nullptr;
}
- // if platform in cache
- else if (plIndex & cacheFlag) {
- plIndex &= ~cacheFlag;
-
- assert(plIndex < platformCacheSize);
-
- // Get the address of the pce from the cache
- pce = &platformCache[plIndex];
-
- assert(pce->platformNum >= 0);
- assert(pce->metaID != NoMetaTile);
- assert(pce->metaID == thisID(mapNum));
-
- // Move to the end of the LRU
- pce->remove();
- platformLRU.addTail(*pce);
-
- // return the address of the platform
- return &pce->pl;
- }
- // if platform not in memory
- else {
- int cacheIndex;
-
- // Since the platform is not in the cache, we need to
- // dump something from the cache. Dump the one that
- // was least recently used.
- // Get head of LRU chain.
- pce = (PlatformCacheEntry *)platformLRU.remHead();
- platformLRU.addTail(*pce);
-
- // Compute the layer of this entry in the cache
- cacheIndex = pce - platformCache;
- assert(cacheIndex < platformCacheSize);
- assert(cacheIndex >= 0);
-
- // Now, flush the old mt from the cache.
- // This assumes that all metatiles from all worlds are loaded.
-
- if (pce->metaID != NoMetaTile) {
- MetaTile *oldMeta = metaTileAddress(pce->metaID);
- assert(pce->layerNum < maxPlatforms);
- assert(oldMeta->stack[pce->layerNum] == (cacheFlag | cacheIndex));
- oldMeta->stack[pce->layerNum] = pce->platformNum;
+ int cacheIndex;
+
+ // Since the platform is not in the cache, we need to
+ // dump something from the cache. Dump the one that
+ // was least recently used.
+ // Get head of LRU chain.
+ pce = (PlatformCacheEntry *)platformLRU.remHead();
+ platformLRU.addTail(*pce);
+
+ // Compute the layer of this entry in the cache
+ cacheIndex = pce - platformCache;
+ assert(cacheIndex < platformCacheSize);
+ assert(cacheIndex >= 0);
+
+ // Initialize the cache entry to the new platform data.
+ pce->platformNum = plIndex;
+ pce->layerNum = layer;
+ pce->metaID = thisID(mapNum);
+ stack[layer] = (cacheIndex);
+
+ assert(plIndex >= 0);
+ assert(plIndex * sizeof(Platform) < tileRes->size(platformID + MKTAG(0, 0, 0, mapNum)));
+ debug(3, "plIndex: %d", plIndex);
+
+ // Now, load the actual metatile data...
+ if (tileRes->seek(platformID + MKTAG(0, 0, 0, mapNum))) {
+ if (tileRes->skip(plIndex * sizeof(Platform))) {
+ readPlatform(tileRes, pce->pl);
+ return &pce->pl;
}
-
- // Initialize the cache entry to the new platform data.
- pce->platformNum = plIndex;
- pce->layerNum = layer;
- pce->metaID = thisID(mapNum);
- stack[layer] = (cacheFlag | cacheIndex);
-
- assert(plIndex >= 0);
- assert(plIndex * sizeof(Platform) < tileRes->size(platformID + MKTAG(0, 0, 0, mapNum)));
-
- // Now, load the actual metatile data...
- if (tileRes->seek(platformID + MKTAG(0, 0, 0, mapNum))) {
- if (tileRes->skip(plIndex * sizeof(Platform))) {
- readPlatform(tileRes, pce->pl);
- return &pce->pl;
- }
- }
-
- error("Unable to read Platform %d of map %d", plIndex, mapNum);
- return nullptr;
}
+
+ error("Unable to read Platform %d of map %d", plIndex, mapNum);
+ return nullptr;
}
//-----------------------------------------------------------------------
@@ -4376,12 +4342,29 @@ struct TileCycleArchive {
//-----------------------------------------------------------------------
// Initialize the tile cycling state array
+static void readCycle(hResContext *con, TileCycleData &cyc) {
+ cyc.counter = con->readS32LE();
+ cyc.pad = con->readByte();
+ cyc.numStates = con->readByte();
+ cyc.currentState = con->readByte();
+ cyc.cycleSpeed = con->readByte();
+
+ for (int i = 0; i < 16; ++i)
+ cyc.cycleList[i] = con->readU16LE();
+}
+
void initTileCyclingStates(void) {
- cycleList = (CyclePtr)LoadResource(tileRes, cycleID, "tile cycle data");
+ const int tileCycleDataSize = 40;
+
+ cycleCount = tileRes->size(cycleID) / tileCycleDataSize;
+ cycleList = new TileCycleData[cycleCount];
+ tileRes->seek(cycleID);
+ for (int i = 0; i < cycleCount; ++i)
+ readCycle(tileRes, cycleList[i]);
+
if (cycleList == nullptr)
error("Unable to load tile cycling data");
- cycleCount = tileRes->size(cycleID) / sizeof(TileCycleData);
}
//-----------------------------------------------------------------------
Commit: 4150f987aada8b9dc0c512972c54fdd202e310e4
https://github.com/scummvm/scummvm/commit/4150f987aada8b9dc0c512972c54fdd202e310e4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:08+02:00
Commit Message:
SAGA2: Added more debug output
Changed paths:
engines/saga2/detection.cpp
engines/saga2/patrol.cpp
engines/saga2/saga2.h
engines/saga2/std.h
engines/saga2/weapons.cpp
diff --git a/engines/saga2/detection.cpp b/engines/saga2/detection.cpp
index 740f0dd185..2c4277fe63 100644
--- a/engines/saga2/detection.cpp
+++ b/engines/saga2/detection.cpp
@@ -34,6 +34,7 @@ static const DebugChannelDef debugFlagList[] = {
{Saga2::kDebugInit, "init", "Debug the initialization process"},
{Saga2::kDebugTiles, "tiles", "Debug the tiles"},
{Saga2::kDebugPalettes, "palettes", "Debug the palettes"},
+ {Saga2::kDebugLoading, "loading", "Debug the loading"},
DEBUG_CHANNEL_END
};
diff --git a/engines/saga2/patrol.cpp b/engines/saga2/patrol.cpp
index 99abfb2708..fe01db4654 100644
--- a/engines/saga2/patrol.cpp
+++ b/engines/saga2/patrol.cpp
@@ -211,12 +211,15 @@ void initPatrolRoutes(void) {
if (patrolRouteRes == nullptr || !patrolRouteRes->_valid)
error("Error accessing patrol route resource group.");
+ debugC(1, kDebugLoading, "Loading Patrol Routes for %d worlds", worldCount);
+
// Allocate the patrol route list array
patrolRouteList = (PatrolRouteList **)malloc(sizeof(PatrolRouteList *) * worldCount);
if (patrolRouteList == nullptr)
error("Unable to allocate the patrol route list");
+ int count = 0;
for (int16 i = 0; i < worldCount; i++) {
patrolRouteList[i] = nullptr;
@@ -225,11 +228,14 @@ void initPatrolRoutes(void) {
Common::SeekableReadStream *stream = loadResourceToStream(patrolRouteRes, MKTAG('R', 'T', 'E', i), "patrol route data");
patrolRouteList[i] = new PatrolRouteList(stream);
+ count++;
delete stream;
}
}
+ debugC(1, kDebugLoading, "Loading Patrol Routes, loaded %d entries", count);
+
// Dispose of the patrol route resource context
auxResFile->disposeContext(patrolRouteRes);
}
diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h
index 1922a41ad2..d58a5b9bb1 100644
--- a/engines/saga2/saga2.h
+++ b/engines/saga2/saga2.h
@@ -46,7 +46,8 @@ enum {
kDebugEventLoop = 1 << 3,
kDebugInit = 1 << 4,
kDebugTiles = 1 << 5,
- kDebugPalettes = 1 << 6
+ kDebugPalettes = 1 << 6,
+ kDebugLoading = 1 << 7
};
#define TICKSPERSECOND (728L/10L)
diff --git a/engines/saga2/std.h b/engines/saga2/std.h
index fe2622fb49..ed84c76868 100644
--- a/engines/saga2/std.h
+++ b/engines/saga2/std.h
@@ -28,6 +28,8 @@
#define SAGA2_STD_H
#include "common/system.h"
+#include "common/debug.h"
+
typedef uint32 ChunkID;
#define MakeID(a,b,c,d) ((d<<24L)|(c<<16L)|(b<<8L)|a)
diff --git a/engines/saga2/weapons.cpp b/engines/saga2/weapons.cpp
index 9c0549f387..bb802d1cf3 100644
--- a/engines/saga2/weapons.cpp
+++ b/engines/saga2/weapons.cpp
@@ -158,7 +158,7 @@ WeaponStuff::WeaponStuff() {
WeaponStuff::~WeaponStuff() {
while (effects != NULL) {
- WeaponEffect *curEffect = effects;
+ WeaponEffect *curEffect = effects;
effects = effects->next;
delete curEffect;
@@ -168,7 +168,7 @@ WeaponStuff::~WeaponStuff() {
void WeaponStuff::killEffects(void) {
while (effects != NULL) {
- WeaponEffect *curEffect = effects;
+ WeaponEffect *curEffect = effects;
effects = effects->next;
delete curEffect;
@@ -178,7 +178,8 @@ void WeaponStuff::killEffects(void) {
void WeaponStuff::addEffect(WeaponEffect *we) {
WeaponEffect *e = effects;
if (effects) {
- while (e->next) e = e->next;
+ while (e->next)
+ e = e->next;
e->next = we;
} else {
effects = we;
@@ -199,7 +200,7 @@ void WeaponStuff::addEffect(ResourceItemEffect *rie) {
rie->baseDamage,
rie->skillDamage);
} else
- we = new WeaponProtoEffect(rie);
+ we = new WeaponProtoEffect(rie);
if (we == NULL)
error("failed to alloc weapon effect");
@@ -226,6 +227,8 @@ static void loadWeaponData(void) {
if (spellRes == NULL || !spellRes->_valid)
error("Error accessing weapon resource group.");
+ debugC(1, kDebugLoading, "Loading Weapon Data");
+
// get spell effects
int16 i = 0;
while (spellRes->size(MKTAG('E', 'F', 'F', i)) > 0) {
@@ -245,6 +248,8 @@ static void loadWeaponData(void) {
g_vm->_loadedWeapons = i;
assert(i > 1);
+ debugC(1, kDebugLoading, "Loading Weapon Data, loaded %d entries", i);
+
auxResFile->disposeContext(spellRes);
}
Commit: 74a572b12c204434f8c4dbdb33e8cbe43a81e3a3
https://github.com/scummvm/scummvm/commit/74a572b12c204434f8c4dbdb33e8cbe43a81e3a3
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:08+02:00
Commit Message:
SAGA2: Fix alloc-dealloc mismatch in cleanupMaps
Changed paths:
engines/saga2/tile.cpp
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 2a5910fc66..ec5d9f1280 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -1615,7 +1615,13 @@ void cleanupMaps(void) {
WorldMapData *mapData = &mapList[i];
// Dump the map
- free(mapData->map);
+ if (mapData->map != nullptr) {
+ if (mapData->map->mapData != nullptr)
+ delete[] mapData->map->mapData;
+
+ delete mapData->map;
+ mapData->map = nullptr;
+ }
// Dump the meta tile list
delete[] mapData->metaList;
@@ -1630,7 +1636,7 @@ void cleanupMaps(void) {
// If there is an active item list, dump it
if (mapData->activeItemList != nullptr)
- free(mapData->activeItemList);
+ delete[] mapData->activeItemList;
// Dump the object ripping table ID list
delete[] mapData->ripTableIDList;
@@ -1641,8 +1647,13 @@ void cleanupMaps(void) {
// Dump all of the tile terrain banks
for (i = 0; i < maxBanks; i++) {
- if (tileBanks[i] != nullptr)
- free(tileBanks[i]);
+ if (tileBanks[i] != nullptr) {
+ if (tileBanks[i]->tileArray != nullptr)
+ delete[] tileBanks[i]->tileArray;
+
+ delete tileBanks[i];
+ tileBanks[i] = nullptr;
+ }
}
}
Commit: 88b857ce48e3023dd6e27d73b696ec0f41b2fdb8
https://github.com/scummvm/scummvm/commit/88b857ce48e3023dd6e27d73b696ec0f41b2fdb8
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:08+02:00
Commit Message:
SAGA2: Change debug messages
Changed paths:
engines/saga2/tile.cpp
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index ec5d9f1280..e897072e47 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -2318,7 +2318,7 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
assert(plIndex >= 0);
assert(plIndex * sizeof(Platform) < tileRes->size(platformID + MKTAG(0, 0, 0, mapNum)));
- debug(3, "plIndex: %d", plIndex);
+ debugC(3, kDebugLoading, "plIndex: %d", plIndex);
// Now, load the actual metatile data...
if (tileRes->seek(platformID + MKTAG(0, 0, 0, mapNum))) {
@@ -4373,6 +4373,8 @@ void initTileCyclingStates(void) {
for (int i = 0; i < cycleCount; ++i)
readCycle(tileRes, cycleList[i]);
+ debugC(2, kDebugLoading, "Loaded Cycles: cycleCount = %d", cycleCount);
+
if (cycleList == nullptr)
error("Unable to load tile cycling data");
Commit: b0d54372270ed7c44846ecd5730cb52a40af57b0
https://github.com/scummvm/scummvm/commit/b0d54372270ed7c44846ecd5730cb52a40af57b0
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:08+02:00
Commit Message:
SAGA2: Made weapon loading portable
Changed paths:
engines/saga2/weapons.cpp
engines/saga2/weapons.h
diff --git a/engines/saga2/weapons.cpp b/engines/saga2/weapons.cpp
index bb802d1cf3..2fc934b14c 100644
--- a/engines/saga2/weapons.cpp
+++ b/engines/saga2/weapons.cpp
@@ -48,45 +48,64 @@ namespace Saga2 {
static void loadWeaponData(void);
-ProtoEffect *createNewProtoEffect(ResourceItemEffect *rie) {
+ProtoEffect *createNewProtoEffect(Common::SeekableReadStream *stream) {
ProtoEffect *pe = NULL;
- switch (rie->effectGroup) {
+ /* int16 item = */stream->readSint16LE(); // spell ID
+ int16 effectGroup = stream->readSint16LE(); // effect group
+
+ int16 effectType = stream->readSint16LE(); // effect ID
+ int16 targeting = stream->readSint16LE(); // targeting
+ int16 baseDice = stream->readSint16LE(); // base dice
+ int16 skillDice = stream->readSint16LE(); // skill dice
+ int16 baseDamage = stream->readSint16LE(); // attrib change
+ int16 skillDamage = stream->readSint16LE(); // attrib change
+ int16 reserved0 = stream->readSint16LE(); // min enchant
+ int16 reserved1 = stream->readSint16LE(); // min enchant
+ int16 diceSides = stream->readSint16LE();
+
+ if (diceSides == 0)
+ diceSides = 6;
+
+ switch (effectGroup) {
case effectNone:
return NULL;
case effectAttrib:
- pe = new ProtoEnchantment(makeEnchantmentID(rie->effectGroup, rie->effectType, rie->baseDamage),
- rie->reserved0, rie->reserved1);
+ pe = new ProtoEnchantment(makeEnchantmentID(effectGroup, effectType, baseDamage), reserved0, reserved1);
break;
+
case effectResist:
case effectImmune:
case effectOthers:
case effectNonActor:
- pe = new ProtoEnchantment(makeEnchantmentID(rie->effectGroup, rie->effectType, rie->skillDamage),
- rie->reserved0, rie->reserved1);
+ pe = new ProtoEnchantment(makeEnchantmentID(effectGroup, effectType, skillDamage), reserved0, reserved1);
break;
+
case effectDamage:
- pe = new ProtoDamage(rie->baseDice, rie->diceSides ? rie->diceSides : 6, rie->skillDice, rie->baseDamage,
- (effectDamageTypes) rie->effectType, 0, rie->targeting & spellTargCaster, rie->skillDamage);
+ pe = new ProtoDamage(baseDice, diceSides, skillDice, baseDamage,
+ (effectDamageTypes)effectType, 0, targeting & spellTargCaster, skillDamage);
break;
+
case effectDrains:
- pe = new ProtoDrainage(rie->baseDice, rie->diceSides ? rie->diceSides : 6, rie->skillDice, rie->baseDamage,
- (effectDrainsTypes) rie->effectType, 0, rie->targeting & spellTargCaster);
+ pe = new ProtoDrainage(baseDice, diceSides, skillDice, baseDamage,
+ (effectDrainsTypes)effectType, 0, targeting & spellTargCaster);
break;
case effectPoison:
- pe = new ProtoEnchantment(makeEnchantmentID(rie->baseDamage), // poison
- rie->reserved0, rie->reserved1);
+ pe = new ProtoEnchantment(makeEnchantmentID(baseDamage), // poison
+ reserved0, reserved1);
case effectTAG:
- pe = new ProtoTAGEffect((effectTAGTypes)rie->effectType, rie->skillDamage, rie->baseDamage);
+ pe = new ProtoTAGEffect((effectTAGTypes)effectType, skillDamage, baseDamage);
break;
+
case effectLocation:
- pe = new ProtoLocationEffect((effectLocationTypes)rie->effectType, rie->baseDamage);
+ pe = new ProtoLocationEffect((effectLocationTypes)effectType, baseDamage);
break;
+
case effectSpecial:
- pe = new ProtoSpecialEffect(SagaSpellCall, rie->baseDamage);
+ pe = new ProtoSpecialEffect(SagaSpellCall, baseDamage);
break;
}
@@ -186,21 +205,31 @@ void WeaponStuff::addEffect(WeaponEffect *we) {
}
}
-void WeaponStuff::addEffect(ResourceItemEffect *rie) {
+void WeaponStuff::addEffect(Common::SeekableReadStream *stream) {
WeaponEffect *we;
- assert(rie);
- assert(rie && rie->item == master);
-
- if (rie->effectGroup == effectStrike) {
- we = new WeaponStrikeEffect(
- (effectDamageTypes)rie->effectType,
- rie->baseDice,
- rie->diceSides != 0 ? rie->diceSides : 6,
- rie->skillDice,
- rie->baseDamage,
- rie->skillDamage);
- } else
- we = new WeaponProtoEffect(rie);
+
+ int16 item = stream->readSint16LE(); // spell ID
+ int16 effectGroup = stream->readSint16LE(); // effect group
+
+ if (effectGroup == effectStrike) {
+ effectDamageTypes effectType = (effectDamageTypes)stream->readSint16LE(); // effect ID
+ int16 targeting = stream->readSint16LE(); // targeting
+ int16 baseDice = stream->readSint16LE(); // base dice
+ int16 skillDice = stream->readSint16LE(); // skill dice
+ int16 baseDamage = stream->readSint16LE(); // attrib change
+ int16 skillDamage = stream->readSint16LE(); // attrib change
+ int16 reserved0 = stream->readSint16LE(); // min enchant
+ int16 reserved1 = stream->readSint16LE(); // min enchant
+ int16 diceSides = stream->readSint16LE();
+
+ if (diceSides == 0)
+ diceSides = 6;
+
+ we = new WeaponStrikeEffect(effectType, baseDice, diceSides, skillDice, baseDamage, skillDamage);
+ } else {
+ stream->seek(0);
+ we = new WeaponProtoEffect(stream);
+ }
if (we == NULL)
error("failed to alloc weapon effect");
@@ -232,17 +261,21 @@ static void loadWeaponData(void) {
// get spell effects
int16 i = 0;
while (spellRes->size(MKTAG('E', 'F', 'F', i)) > 0) {
- ResourceItemEffect *rie = (ResourceItemEffect *)LoadResource(spellRes, MKTAG('E', 'F', 'F', i), "weapon effect");
+ Common::SeekableReadStream *stream = loadResourceToStream(spellRes, MKTAG('E', 'F', 'F', i), "weapon effect");
- if (rie == NULL)
+ if (stream == nullptr)
error("Unable to load weapon effect %d", i);
- if (rie->item) {
- g_vm->_weaponRack[rie->item].setID(rie->item);
- g_vm->_weaponRack[rie->item].addEffect(rie);
+ int16 id = stream->readSint16LE();
+ stream->seek(0);
+
+ if (id) {
+ g_vm->_weaponRack[id].setID(id);
+ g_vm->_weaponRack[id].addEffect(stream);
}
- RDisposePtr(rie);
+ delete stream;
+
i++;
}
g_vm->_loadedWeapons = i;
diff --git a/engines/saga2/weapons.h b/engines/saga2/weapons.h
index 25801b2904..8445ff505d 100644
--- a/engines/saga2/weapons.h
+++ b/engines/saga2/weapons.h
@@ -35,7 +35,7 @@ class Actor;
class GameObject;
class ProtoEffect;
-ProtoEffect *createNewProtoEffect(ResourceItemEffect *rie);
+ProtoEffect *createNewProtoEffect(Common::SeekableReadStream *stream);
//-----------------------------------------------------------------------
@@ -58,8 +58,8 @@ class WeaponProtoEffect : public WeaponEffect {
ProtoEffect *effect;
public:
- WeaponProtoEffect(ResourceItemEffect *rie) :
- effect(createNewProtoEffect(rie)) {
+ WeaponProtoEffect(Common::SeekableReadStream *stream) :
+ effect(createNewProtoEffect(stream)) {
}
~WeaponProtoEffect(void);
@@ -116,7 +116,7 @@ public:
master = id;
}
void addEffect(WeaponEffect *we);
- void addEffect(ResourceItemEffect *rse);
+ void addEffect(Common::SeekableReadStream *stream);
void killEffects(void);
void implement(
Actor *enactor,
Commit: 4eebd6d6bf961060e928f1e90d6ed660e899dd1d
https://github.com/scummvm/scummvm/commit/4eebd6d6bf961060e928f1e90d6ed660e899dd1d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:08+02:00
Commit Message:
SAGA2: Fix remaining warnings in weapons.cpp
Changed paths:
engines/saga2/objproto.cpp
engines/saga2/objproto.h
engines/saga2/weapons.cpp
diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp
index 23913ed755..4d32af709c 100644
--- a/engines/saga2/objproto.cpp
+++ b/engines/saga2/objproto.cpp
@@ -1295,7 +1295,7 @@ bool PhysicalContainerProto::canToggleLock(
// Unlock or lock the physical container
bool PhysicalContainerProto::acceptLockToggleAction(
ObjectID dObj,
- ObjectID enactor) {
+ ObjectID enactor, uint8) {
GameObject *dObjPtr = GameObject::objectAddress(dObj);
// Toggle locked bit
diff --git a/engines/saga2/objproto.h b/engines/saga2/objproto.h
index 2f54f2849c..d8b99a7b6f 100644
--- a/engines/saga2/objproto.h
+++ b/engines/saga2/objproto.h
@@ -490,10 +490,7 @@ public:
ObjectID dObj,
ObjectID enactor,
uint8 keyCode);
- virtual bool acceptLockToggleAction(
- ObjectID dObj,
- ObjectID enactor,
- uint8 keyCode);
+ virtual bool acceptLockToggleAction(ObjectID dObj, ObjectID enactor, uint8 keyCode);
// Mix this object with another.
bool acceptMix(ObjectID dObj, ObjectID enactor, ObjectID mixObj);
@@ -717,7 +714,7 @@ public:
ObjectID dObj,
ObjectID enactor,
uint8 keyCode);
- virtual bool acceptLockToggleAction(ObjectID dObj, ObjectID enactor);
+ virtual bool acceptLockToggleAction(ObjectID dObj, ObjectID enactor, uint8 keyCode);
// Insert another object into this object
bool acceptInsertionAction(
diff --git a/engines/saga2/weapons.cpp b/engines/saga2/weapons.cpp
index 2fc934b14c..e1cf42dcf4 100644
--- a/engines/saga2/weapons.cpp
+++ b/engines/saga2/weapons.cpp
@@ -208,18 +208,18 @@ void WeaponStuff::addEffect(WeaponEffect *we) {
void WeaponStuff::addEffect(Common::SeekableReadStream *stream) {
WeaponEffect *we;
- int16 item = stream->readSint16LE(); // spell ID
+ /*int16 item = */stream->readSint16LE(); // spell ID
int16 effectGroup = stream->readSint16LE(); // effect group
if (effectGroup == effectStrike) {
effectDamageTypes effectType = (effectDamageTypes)stream->readSint16LE(); // effect ID
- int16 targeting = stream->readSint16LE(); // targeting
+ /*int16 targeting = */stream->readSint16LE(); // targeting
int16 baseDice = stream->readSint16LE(); // base dice
int16 skillDice = stream->readSint16LE(); // skill dice
int16 baseDamage = stream->readSint16LE(); // attrib change
int16 skillDamage = stream->readSint16LE(); // attrib change
- int16 reserved0 = stream->readSint16LE(); // min enchant
- int16 reserved1 = stream->readSint16LE(); // min enchant
+ /*int16 reserved0 = */stream->readSint16LE(); // min enchant
+ /* int16 reserved1 = */stream->readSint16LE(); // min enchant
int16 diceSides = stream->readSint16LE();
if (diceSides == 0)
Commit: 97f7a0e529ffd5e0ca236e9519599d0f61ef406c
https://github.com/scummvm/scummvm/commit/97f7a0e529ffd5e0ca236e9519599d0f61ef406c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:08+02:00
Commit Message:
SAGA2: Drop custom TRUE/FALSE
Changed paths:
engines/saga2/actor.cpp
engines/saga2/actor.h
engines/saga2/assign.cpp
engines/saga2/assign.h
engines/saga2/audiobuf.cpp
engines/saga2/audiores.cpp
engines/saga2/audiosmp.h
engines/saga2/audiosys.h
engines/saga2/automap.cpp
engines/saga2/band.h
engines/saga2/beegee.cpp
engines/saga2/bitarray.h
engines/saga2/blitters.cpp
engines/saga2/button.cpp
engines/saga2/calender.cpp
engines/saga2/config.cpp
engines/saga2/contain.cpp
engines/saga2/contain.h
engines/saga2/display.cpp
engines/saga2/display.h
engines/saga2/dispnode.cpp
engines/saga2/document.cpp
engines/saga2/effects.cpp
engines/saga2/effects.h
engines/saga2/enchant.cpp
engines/saga2/floating.cpp
engines/saga2/floating.h
engines/saga2/fta.h
engines/saga2/gamemode.cpp
engines/saga2/gdraw.cpp
engines/saga2/gdraw.h
engines/saga2/gpointer.cpp
engines/saga2/grequest.cpp
engines/saga2/gtext.cpp
engines/saga2/gtextbox.cpp
engines/saga2/gtextbox.h
engines/saga2/imagcach.cpp
engines/saga2/interp.cpp
engines/saga2/intrface.cpp
engines/saga2/intrface.h
engines/saga2/keybored.cpp
engines/saga2/magic.cpp
engines/saga2/mainmap.cpp
engines/saga2/mapfeatr.cpp
engines/saga2/mapfeatr.h
engines/saga2/messager.h
engines/saga2/mission.cpp
engines/saga2/modal.cpp
engines/saga2/motion.cpp
engines/saga2/motion.h
engines/saga2/mouseimg.cpp
engines/saga2/msgbox.cpp
engines/saga2/music.h
engines/saga2/noise.cpp
engines/saga2/objects.h
engines/saga2/objproto.cpp
engines/saga2/objproto.h
engines/saga2/oncall.h
engines/saga2/panel.cpp
engines/saga2/panel.h
engines/saga2/player.cpp
engines/saga2/player.h
engines/saga2/priqueue.h
engines/saga2/property.cpp
engines/saga2/property.h
engines/saga2/queues.h
engines/saga2/rect.h
engines/saga2/rmem.cpp
engines/saga2/rmem.h
engines/saga2/rserver.cpp
engines/saga2/sagafunc.cpp
engines/saga2/savefile.cpp
engines/saga2/sensor.cpp
engines/saga2/speech.cpp
engines/saga2/spelcast.cpp
engines/saga2/spellbuk.h
engines/saga2/sprite.cpp
engines/saga2/sprite.h
engines/saga2/std.h
engines/saga2/target.cpp
engines/saga2/task.cpp
engines/saga2/task.h
engines/saga2/tile.h
engines/saga2/tileload.cpp
engines/saga2/tileload.h
engines/saga2/tilemode.cpp
engines/saga2/tower.cpp
engines/saga2/towerfta.cpp
engines/saga2/transit.cpp
engines/saga2/tromode.cpp
engines/saga2/uidialog.h
engines/saga2/vbacksav.cpp
engines/saga2/vbacksav.h
engines/saga2/videobox.cpp
engines/saga2/vwdraw.cpp
engines/saga2/vwpage.cpp
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 57fc4ea295..558348667a 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -162,7 +162,7 @@ bool ActorProto::useAction(ObjectID dObj, ObjectID enactor) {
if (a->isDead())
return ((PhysicalContainerProto *)this)->PhysicalContainerProto::useAction(dObj, enactor);
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -189,10 +189,10 @@ bool ActorProto::openAction(ObjectID dObj, ObjectID) {
assert(!dObjPtr->isOpen() && !dObjPtr->isLocked());
- cn = CreateContainerNode(dObj, FALSE, openMindType);
+ cn = CreateContainerNode(dObj, false, openMindType);
cn->markForShow(); // Deferred open
dObjPtr->objectFlags |= objectOpen; // Set open bit;
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -212,7 +212,7 @@ bool ActorProto::closeAction(ObjectID dObj, ObjectID) {
// Clear open bit
dObjPtr->objectFlags &= ~objectOpen;
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -232,12 +232,12 @@ bool ActorProto::strikeAction(
Location al = Location(a->getLocation(), a->IDParent());
if (itemPtr->acceptStrike(enactor, dObj, effStats->getSkillLevel(skillIDBludgeon)))
- return TRUE;
+ return true;
soundFXs = &objectSoundFXTable[soundFXClass];
makeCombatSound(soundFXs->soundFXMissed, al);
- return FALSE;
+ return false;
}
bool ActorProto::damageAction(
@@ -268,7 +268,7 @@ bool ActorProto::damageAction(
GameObject::objectAddress(dObj),
effStats->getSkillLevel(skillIDBrawn));
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -287,7 +287,7 @@ bool ActorProto::acceptDropAction(
if (a->isDead()) {
a->dropInventoryObject(droppedObj, count);
- return TRUE;
+ return true;
}
Location newLoc;
@@ -305,7 +305,7 @@ bool ActorProto::acceptDropAction(
// NOTE: Added check so that dropping an object on an actor who
// already has the object will do nothing.
- if (droppedObj->IDParent() == dObj) return TRUE;
+ if (droppedObj->IDParent() == dObj) return true;
dropType = droppedObj->containmentSet();
@@ -352,11 +352,11 @@ bool ActorProto::acceptDropAction(
return scf.returnVal == actionResultSuccess;
// Place the object in the actor's inventory (if possible)
- if (!a->placeObject(enactor, droppedID, TRUE, count))
+ if (!a->placeObject(enactor, droppedID, true, count))
a->dropInventoryObject(droppedObj, count);
}
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -429,7 +429,7 @@ bool ActorProto::acceptDamageAction(
damage = MAX(damage - armorAttribs.damageAbsorbtion, 0);
}
- if (damage == 0) return FALSE;
+ if (damage == 0) return false;
if (isActor(enactor))
enactorPtr = (Actor *)GameObject::objectAddress(enactor);
@@ -490,7 +490,7 @@ bool ActorProto::acceptDamageAction(
WriteStatusF(5, "Damage: %d", damage);
}
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -520,9 +520,9 @@ bool ActorProto::acceptHealingAction(
WriteStatusF(5, "Healing: %d", healing);
} else
- return FALSE;
+ return false;
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -586,7 +586,7 @@ bool ActorProto::acceptStrikeAction(
// Hit has succeeded
GameObject *blockingObj = a->blockingObject(enactorPtr);
- bool blocked = FALSE;
+ bool blocked = false;
// Test for block success
if (blockingObj != NULL) {
@@ -601,7 +601,7 @@ bool ActorProto::acceptStrikeAction(
enactor,
strikingObj,
skillIndex);
- blocked = TRUE;
+ blocked = true;
// Cause skill growth
blockingObj->proto()->applySkillGrowth(dObj, 5);
@@ -628,7 +628,7 @@ bool ActorProto::acceptStrikeAction(
}
}
- return TRUE;
+ return true;
} else {
// This actor has dodged the blow, apply agility growth
@@ -641,7 +641,7 @@ bool ActorProto::acceptStrikeAction(
}
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -675,11 +675,11 @@ bool ActorProto::acceptInsertionAtAction(
// Split the merged object if needed.
if (itemPtr->isMergeable() // If mergeable
&& num < itemPtr->getExtra()) { // And not dropping whole pile
- if (num == 0) return FALSE; // If mergeing zero, then do nothing
+ if (num == 0) return false; // If mergeing zero, then do nothing
extractedObj = itemPtr->extractMerged(itemPtr->getExtra() - num);
if (extractedObj == NULL)
- return FALSE;
+ return false;
extractedObj->move(oldLoc);
}
@@ -712,12 +712,12 @@ bool ActorProto::acceptInsertionAtAction(
if (dObjPtr->canFitBulkwise(itemPtr)
&& dObjPtr->canFitMasswise(itemPtr)) {
itemPtr->move(Location(where, dObj));
- result = TRUE;
+ result = true;
} else {
itemPtr->move(oldLoc);
if (extractedObj != NULL)
GameObject::mergeWith(extractedObj, itemPtr, extractedObj->getExtra());
- result = FALSE;
+ result = false;
}
// Re-equip the item if necessary
@@ -868,7 +868,7 @@ bool ActorProto::canFitBulkwise(GameObject *container, GameObject *obj) {
}
#if DEBUG
- return TRUE;
+ return true;
#endif
}
@@ -894,7 +894,7 @@ bool ActorProto::canFitMasswise(GameObject *container, GameObject *obj) {
}
#if DEBUG
- return TRUE;
+ return true;
#endif
}
@@ -1817,23 +1817,23 @@ void Actor::stopAttack(GameObject *target) {
// Determine if this actor can block an attack
bool Actor::canDefend(void) {
- if (isDead()) return FALSE;
+ if (isDead()) return false;
// Look at left hand object, generally the defensive object
if (leftHandObject != Nothing) {
GameObject *obj = GameObject::objectAddress(leftHandObject);
- if (obj->proto()->canBlock()) return TRUE;
+ if (obj->proto()->canBlock()) return true;
}
// Look at right hand object, generally the offensive object
if (rightHandObject != Nothing) {
GameObject *obj = GameObject::objectAddress(rightHandObject);
- if (obj->proto()->canBlock()) return TRUE;
+ if (obj->proto()->canBlock()) return true;
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -1926,7 +1926,7 @@ int16 Actor::setAction(int16 newState, int16 flags) {
if (appearance == NULL) return 0;
- // If this animation has no frames, then return FALSE
+ // If this animation has no frames, then return false
anim = appearance->poseList->animation(newState);
numPoses = anim->count[currentFacing];
if (numPoses <= 0) return 0;
@@ -1947,7 +1947,7 @@ int16 Actor::setAction(int16 newState, int16 flags) {
}
//-----------------------------------------------------------------------
-// returns TRUE if the action is available in the current direction.
+// returns true if the action is available in the current direction.
//
bool Actor::isActionAvailable(int16 newState, bool anyDir) {
@@ -1957,20 +1957,20 @@ bool Actor::isActionAvailable(int16 newState, bool anyDir) {
// RLockHandle( appearance->animations );
// RUnlockHandle( appearance->animations );
- if (appearance == NULL) return FALSE;
+ if (appearance == NULL) return false;
- // If this animation has no frames, then return FALSE
+ // If this animation has no frames, then return false
anim = appearance->poseList->animation(newState);
if (anyDir) {
for (int i = 0; i < numPoseFacings; i++) {
- if (anim->count[i] > 0) return TRUE;
+ if (anim->count[i] > 0) return true;
}
} else {
- if (anim->count[currentFacing] > 0) return TRUE;
+ if (anim->count[currentFacing] > 0) return true;
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -1989,7 +1989,7 @@ int16 Actor::animationFrames(int16 actionType, Direction dir) {
//-----------------------------------------------------------------------
// Update the current animation sequence to the next frame.
-// Returns TRUE if the animation sequence has finished.
+// Returns true if the animation sequence has finished.
bool Actor::nextAnimationFrame(void) {
ActorAnimation *anim;
@@ -2001,13 +2001,13 @@ bool Actor::nextAnimationFrame(void) {
if (appearance == NULL) {
if (animationFlags & animateOnHold) {
- return FALSE;
+ return false;
} else if (animationFlags & animateRepeat) {
animationFlags |= animateOnHold;
- return FALSE;
+ return false;
} else {
animationFlags |= animateFinished;
- return TRUE;
+ return true;
}
} else animationFlags &= ~animateOnHold;
@@ -2016,17 +2016,17 @@ bool Actor::nextAnimationFrame(void) {
numPoses = anim->count[currentFacing];
if (numPoses <= 0) {
animationFlags |= animateFinished;
- return TRUE; // no poses, return DONE
+ return true; // no poses, return DONE
}
// If the sprite could not be displayed because it has not
// been loaded, then don't update the animation state --
// wait until the sprite gets loaded, and then continue
// with the action.
- if (animationFlags & animateNotLoaded) return FALSE;
+ if (animationFlags & animateNotLoaded) return false;
// If the animation has reached the last frame, then exit.
- if (animationFlags & animateFinished) return TRUE;
+ if (animationFlags & animateFinished) return true;
if (animationFlags & animateRandom) {
// Select a random frame from the series.
@@ -2077,7 +2077,7 @@ bool Actor::nextAnimationFrame(void) {
} else //If Last Frame And Not Animate Repeat or Alternate
animationFlags |= animateFinished;
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -2241,7 +2241,7 @@ void Actor::updateAppearance(int32) {
}
bool Actor::SetAvailableAction(int16 flags, ...) {
- bool result = FALSE;
+ bool result = false;
va_list Actions;
va_start(Actions, flags); //Initialize To First Argument Even Though We Dont Use It In The Loop
@@ -2249,7 +2249,7 @@ bool Actor::SetAvailableAction(int16 flags, ...) {
int thisAction = va_arg(Actions, int); //Increment To Second Argument Ignoring Flags
if (thisAction < 0) break; //Check If Last Parameter Since Last Always Should Be -1
if (setAction(thisAction, flags)) { //Try To Set This Action
- result = TRUE; //If Successful
+ result = true; //If Successful
break;
}
}
@@ -2324,7 +2324,7 @@ void Actor::evaluateNeeds(void) {
if ((proto->containmentSet() & ProtoObj::isWeapon)
&& isActionAvailable(proto->fightStanceAction(thisID()))) {
- foundWeapon = TRUE;
+ foundWeapon = true;
break;
}
}
@@ -2332,7 +2332,7 @@ void Actor::evaluateNeeds(void) {
if (!foundWeapon
&& (isActionAvailable(actionSwingHigh)
|| isActionAvailable(actionTwoHandSwingHigh)))
- foundWeapon = TRUE;
+ foundWeapon = true;
if (!foundWeapon)
flags |= afraid;
@@ -2492,7 +2492,7 @@ void Actor::updateState(void) {
disposition == dispositionEnemy
? actorPropIDPlayerActor
: actorPropIDEnemy),
- TRUE);
+ true);
if (task != NULL)
curTask->setTask(task);
@@ -2897,7 +2897,7 @@ bool Actor::addFollower(Actor *newBandMember) {
// Allocate a new band, if needed
if (followers == NULL && (followers = new Band(this)) == NULL)
- return FALSE;
+ return false;
return followers->add(newBandMember);
}
@@ -3022,10 +3022,10 @@ bool Actor::addKnowledge(uint16 kID) {
for (int i = 0; i < elementsof(knowledge); i++) {
if (knowledge[i] == 0) {
knowledge[i] = kID;
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -3035,10 +3035,10 @@ bool Actor::removeKnowledge(uint16 kID) {
for (int i = 0; i < elementsof(knowledge); i++) {
if (knowledge[i] == kID) {
knowledge[i] = 0;
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -3125,11 +3125,11 @@ bool Actor::canSenseProtaganistIndirectly(SenseInfo &info, int16 range) {
for (i = 0; i < followers->size(); i++) {
if ((*followers)[i]->canSenseProtaganist(info, range))
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -3145,11 +3145,11 @@ bool Actor::canSenseSpecificActorIndirectly(
for (i = 0; i < followers->size(); i++) {
if ((*followers)[i]->canSenseSpecificActor(info, range, a))
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -3165,11 +3165,11 @@ bool Actor::canSenseSpecificObjectIndirectly(
for (i = 0; i < followers->size(); i++) {
if ((*followers)[i]->canSenseSpecificObject(info, range, obj))
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -3185,11 +3185,11 @@ bool Actor::canSenseActorPropertyIndirectly(
for (i = 0; i < followers->size(); i++) {
if ((*followers)[i]->canSenseActorProperty(info, range, prop))
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -3205,11 +3205,11 @@ bool Actor::canSenseObjectPropertyIndirectly(
for (i = 0; i < followers->size(); i++) {
if ((*followers)[i]->canSenseObjectProperty(info, range, prop))
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
@@ -3223,32 +3223,32 @@ bool Actor::canSenseObjectPropertyIndirectly(
bool Actor::takeMana(ActorManaID i, int8 dMana) {
#if NO_MONSTER_MANA
if (!isPlayerActor(this))
- return TRUE;
+ return true;
#endif
assert(i >= manaIDRed && i <= manaIDViolet);
if ((&effectiveStats.redMana)[i] < dMana)
- return FALSE;
+ return false;
(&effectiveStats.redMana)[i] -= dMana;
updateIndicators();
- return TRUE;
+ return true;
}
bool Actor::hasMana(ActorManaID i, int8 dMana) {
#if NO_MONSTER_MANA
if (!isPlayerActor(this))
- return TRUE;
+ return true;
#endif
assert(i >= manaIDRed && i <= manaIDViolet);
if ((&effectiveStats.redMana)[i] < dMana)
- return FALSE;
- return TRUE;
+ return false;
+ return true;
}
//-----------------------------------------------------------------------
// Saving throw funcion
bool Actor::makeSavingThrow(void) {
- return FALSE;
+ return false;
}
//-------------------------------------------------------------------
@@ -3306,13 +3306,13 @@ void updateActorStates(void) {
//-------------------------------------------------------------------
void pauseActorStates(void) {
- actorStatesPaused = TRUE;
+ actorStatesPaused = true;
}
//-------------------------------------------------------------------
void resumeActorStates(void) {
- actorStatesPaused = FALSE;
+ actorStatesPaused = false;
}
//-------------------------------------------------------------------
diff --git a/engines/saga2/actor.h b/engines/saga2/actor.h
index 6026d0323d..7f9ab1af81 100644
--- a/engines/saga2/actor.h
+++ b/engines/saga2/actor.h
@@ -239,7 +239,7 @@ public:
// returns the containment type flags for this object
virtual uint16 containmentSet(void);
- // returns TRUE if this object can contain another object
+ // returns true if this object can contain another object
virtual bool canContain(ObjectID dObj, ObjectID item);
// Determine if this object can contain another object at a
@@ -871,9 +871,9 @@ public:
// are no poses in the sequence.
int16 setAction(int16 newState, int16 flags);
- // returns TRUE if the action is available in the current
+ // returns true if the action is available in the current
// direction.
- bool isActionAvailable(int16 newState, bool anyDir = FALSE);
+ bool isActionAvailable(int16 newState, bool anyDir = false);
// Return the number of animation frames in the specified action
// for the specified direction
@@ -882,7 +882,7 @@ public:
// Update the current animation sequence to the next frame
bool nextAnimationFrame(void);
- // calculate which sprite frames to show. Return FALSE if
+ // calculate which sprite frames to show. Return false if
// sprite frames are not loaded.
bool calcSpriteFrames(void);
diff --git a/engines/saga2/assign.cpp b/engines/saga2/assign.cpp
index 3b661834e9..139137e774 100644
--- a/engines/saga2/assign.cpp
+++ b/engines/saga2/assign.cpp
@@ -173,7 +173,7 @@ void ActorAssignment::startTask(void) {
// Determine if this assignment needs to create a task at this time
bool ActorAssignment::taskNeeded(void) {
- return TRUE;
+ return true;
}
/* ===================================================================== *
@@ -280,7 +280,7 @@ void PatrolRouteAssignment::handleTaskCompletion(TaskResult result) {
bool PatrolRouteAssignment::isValid(void) {
// If the route has already been completed, then the assignment is
// no longer valid
- if (flags & routeCompleted) return FALSE;
+ if (flags & routeCompleted) return false;
return ActorAssignment::isValid();
}
@@ -551,7 +551,7 @@ Task *HuntToBeNearActorAssignment::getTask(TaskStack *ts) {
ts,
*getTarget(),
range,
- (flags & track) != FALSE);
+ (flags & track) != false);
}
/* ===================================================================== *
@@ -562,7 +562,7 @@ Task *HuntToBeNearActorAssignment::getTask(TaskStack *ts) {
HuntToKillAssignment::HuntToKillAssignment(Actor *a, bool trackFlag) :
ActorAssignment(indefinitely) {
assert(isActor(a) && a != getActor());
- initialize(SpecificActorTarget(a), trackFlag, TRUE);
+ initialize(SpecificActorTarget(a), trackFlag, true);
}
// Construct with no time limit and abstract actor target
@@ -570,7 +570,7 @@ HuntToKillAssignment::HuntToKillAssignment(
const ActorTarget &at,
bool trackFlag) :
ActorAssignment(indefinitely) {
- initialize(at, trackFlag, FALSE);
+ initialize(at, trackFlag, false);
}
@@ -645,7 +645,7 @@ bool HuntToKillAssignment::isValid(void) {
if (flags & specificActor) {
SpecificActorTarget *sat = (SpecificActorTarget *)getTarget();
- if (sat->getTargetActor()->isDead()) return FALSE;
+ if (sat->getTargetActor()->isDead()) return false;
}
// Otherwise, determine if the base class thinks this is a valid
@@ -674,7 +674,7 @@ bool HuntToKillAssignment::taskNeeded(void) {
}
// Otherwise, we'll always want to create a task
- return TRUE;
+ return true;
}
//----------------------------------------------------------------------
@@ -684,7 +684,7 @@ Task *HuntToKillAssignment::getTask(TaskStack *ts) {
return new HuntToKillTask(
ts,
*getTarget(),
- (flags & track) != FALSE);
+ (flags & track) != false);
}
/* ===================================================================== *
diff --git a/engines/saga2/assign.h b/engines/saga2/assign.h
index d76083ce3d..6320ed2022 100644
--- a/engines/saga2/assign.h
+++ b/engines/saga2/assign.h
@@ -248,14 +248,14 @@ public:
HuntToBeNearActorAssignment(
Actor *a,
uint16 r,
- bool trackFlag = FALSE);
+ bool trackFlag = false);
// Construct with time limit and specific actor
HuntToBeNearActorAssignment(
uint16 until,
Actor *a,
uint16 r,
- bool trackFlag = FALSE) :
+ bool trackFlag = false) :
ActorAssignment(until) {
assert(isActor(a) && a != getActor());
initialize(SpecificActorTarget(a), r, trackFlag);
@@ -265,14 +265,14 @@ public:
HuntToBeNearActorAssignment(
const ActorTarget &at,
uint16 r,
- bool trackFlag = FALSE);
+ bool trackFlag = false);
// Construct with time limit and abstract actor target
HuntToBeNearActorAssignment(
uint16 until,
const ActorTarget &at,
uint16 r,
- bool trackFlag = FALSE) :
+ bool trackFlag = false) :
ActorAssignment(until) {
initialize(at, r, trackFlag);
}
@@ -324,30 +324,30 @@ public:
// Constructors -- initial assignment construction
// Construct with no time limit and specific actor
- HuntToKillAssignment(Actor *a, bool trackFlag = FALSE);
+ HuntToKillAssignment(Actor *a, bool trackFlag = false);
// Construct with time limit and specific actor
HuntToKillAssignment(
uint16 until,
Actor *a,
- bool trackFlag = FALSE) :
+ bool trackFlag = false) :
ActorAssignment(until) {
assert(isActor(a) && a != getActor());
- initialize(SpecificActorTarget(a), trackFlag, TRUE);
+ initialize(SpecificActorTarget(a), trackFlag, true);
}
// Construct with no time limit and abstract actor target
HuntToKillAssignment(
const ActorTarget &at,
- bool trackFlag = FALSE);
+ bool trackFlag = false);
// Construct with time limit and abstract actor target
HuntToKillAssignment(
uint16 until,
const ActorTarget &at,
- bool trackFlag = FALSE) :
+ bool trackFlag = false) :
ActorAssignment(until) {
- initialize(at, trackFlag, FALSE);
+ initialize(at, trackFlag, false);
}
// Constructor -- reconstructs from archive buffer
diff --git a/engines/saga2/audiobuf.cpp b/engines/saga2/audiobuf.cpp
index 6854d9233c..32ed66852b 100644
--- a/engines/saga2/audiobuf.cpp
+++ b/engines/saga2/audiobuf.cpp
@@ -70,7 +70,7 @@ extern audioInterface *audio;
Buffer::Buffer(size_t newSize) {
assert(newSize > 0);
- internallyAllocated = TRUE;
+ internallyAllocated = true;
size = newSize;
data[0] = malloc(newSize);
data[1] = NULL;
@@ -95,7 +95,7 @@ workBuffer::workBuffer(size_t newSize, int16 newID)
: Buffer(newSize) {
bufID = newID;
fillBuffer = 0;
- targetSated = FALSE;
+ targetSated = false;
}
workBuffer::~workBuffer(void) {
@@ -124,7 +124,7 @@ doubleBuffer::doubleBuffer(size_t newSize, audioInterface *sd, int16 newID)
bufID = newID;
fillBuffer = 0;
targetPos = 0;
- targetSated = FALSE;
+ targetSated = false;
ailSampleHandle = AIL_allocate_sample_handle(sd->dig);
if (ailSampleHandle == NULL)
error("Unable to allocate audio handle");
@@ -160,7 +160,7 @@ singleBuffer::singleBuffer(size_t newSize, audioInterface *sd, int16 newID)
bufID = newID;
fillBuffer = 0;
- targetSated = FALSE;
+ targetSated = false;
ailSampleHandle = AIL_allocate_sample_handle(sd->dig);
if (ailSampleHandle == NULL)
audioFatal("Unable to allocate audio handle");
@@ -191,7 +191,7 @@ musicBuffer::musicBuffer(size_t newSize, audioInterface *sd, int16 newID)
bufID = newID;
fillBuffer = 0;
- targetSated = FALSE;
+ targetSated = false;
ailSampleHandle = AIL_allocate_sequence_handle(sd->mid);
if (ailSampleHandle == NULL)
audioFatal("Unable to allocate music handle");
@@ -290,18 +290,18 @@ void musicBuffer::format(soundSample *) {
/* laden() determine whether a buffer can be written to. */
bool Buffer::laden(void) {
- if (-1 == washed()) return TRUE;
+ if (-1 == washed()) return true;
activate(0);
- return FALSE;
+ return false;
}
// fairly trivial for work buffers
bool workBuffer::laden(void) {
if (-1 == washed())
- return TRUE;
+ return true;
activate(0);
- return FALSE;
+ return false;
}
// sound buffers need to find out from AIL whether a buffer is free
@@ -309,30 +309,30 @@ bool workBuffer::laden(void) {
bool doubleBuffer::laden(void) {
assert(ailSampleHandle);
if (-1 == washed())
- return TRUE;
+ return true;
else if (targetSated)
activate(fillBuffer);
- return (FALSE);
+ return (false);
}
bool singleBuffer::laden(void) {
assert(ailSampleHandle);
if (targetSated)
activate(0);
- return (FALSE);
+ return (false);
}
bool musicBuffer::laden(void) {
if (targetSated)
activate(0);
- return (FALSE);
+ return (false);
}
bool cacheBuffer::laden(void) {
if (-1 == washed())
- return TRUE;
+ return true;
activate(0);
- return FALSE;
+ return false;
}
@@ -767,7 +767,7 @@ void doubleBuffer::activate(int16 bufNo) {
assert(ailSampleHandle);
n = bufNo;
if (washed() > -1) {
- targetSated = FALSE;
+ targetSated = false;
fillBuffer = AILLOCated;
wSize = size;
wData = data[fillBuffer];
@@ -779,7 +779,7 @@ void doubleBuffer::activate(int16 bufNo) {
wData = data[0];
rSize = 0;
rData = data[0];
- targetSated = TRUE;
+ targetSated = true;
}
}
@@ -787,7 +787,7 @@ void singleBuffer::activate(int16 bufNo) {
int32 n;
assert(ailSampleHandle);
n = bufNo;
- targetSated = FALSE;
+ targetSated = false;
fillBuffer = 0;
wSize = size;
wData = data[fillBuffer];
@@ -801,7 +801,7 @@ void musicBuffer::activate(int16 bufNo) {
n = bufNo;
audioSet = 0;
if (washed() > -1) {
- targetSated = FALSE;
+ targetSated = false;
fillBuffer = 0;
wSize = size;
wData = data[fillBuffer];
@@ -813,7 +813,7 @@ void musicBuffer::activate(int16 bufNo) {
wData = data[0];
rSize = 0;
rData = data[0];
- targetSated = TRUE;
+ targetSated = true;
}
}
diff --git a/engines/saga2/audiores.cpp b/engines/saga2/audiores.cpp
index 8acf414888..ae511088d9 100644
--- a/engines/saga2/audiores.cpp
+++ b/engines/saga2/audiores.cpp
@@ -59,21 +59,21 @@ bool bufCheckResID(hResContext *hrc, uint32 s) {
bool hResCheckResID(hResContext *hrc, uint32 s) {
if (hrc != NULL)
return hrc->seek(s);
- return FALSE;
+ return false;
}
bool hResCheckResID(hResContext *hrc, uint32 s[]) {
int i = 0;
if (s != NULL) {
if (s[0] == 0)
- return FALSE;
+ return false;
while (s[i]) {
if (!hResCheckResID(hrc, s[i]))
- return FALSE;
+ return false;
i++;
}
}
- return TRUE;
+ return true;
}
/* ===================================================================== *
@@ -87,7 +87,7 @@ bool hResCheckResID(hResContext *hrc, uint32 s[]) {
// open / seek
int16 hResSeek(Buffer &sb, soundSample &ss, hResContext *hrc, bool Cheksize) {
- if (hrc->seek(ss.curSeg) == FALSE) {
+ if (hrc->seek(ss.curSeg) == false) {
warning("Audio: %d is an invalid res ID", ss.curSeg);
return 1;
}
@@ -113,11 +113,11 @@ int16 hResRead(Buffer &sb, soundSample &ss, hResContext *hrc) {
int16 rVal = 0;
#if ASYNCH_AUDIO
- bool partial = FALSE;
+ bool partial = false;
count = min(count, ASYNCH_READ_SIZE);
if (count > ASYNCH_READ_SIZE) {
count = ASYNCH_READ_SIZE;
- partial = TRUE;
+ partial = true;
}
#endif
diff --git a/engines/saga2/audiosmp.h b/engines/saga2/audiosmp.h
index ffcb8588af..5e4c882d85 100644
--- a/engines/saga2/audiosmp.h
+++ b/engines/saga2/audiosmp.h
@@ -131,12 +131,12 @@ public:
defaultChannels = channelMono;
defaultSpeed = soundRate22K;
defaultDataSize = granularity16Bit;
- initialized = TRUE;
+ initialized = true;
return 0;
}
void setDefaultProfile(soundSampleChannels c, soundSampleRate r, soundSampleGranularity g) {
- if (initialized != TRUE) init();
+ if (initialized != true) init();
defaultChannels = c;
defaultSpeed = r;
defaultDataSize = g;
diff --git a/engines/saga2/audiosys.h b/engines/saga2/audiosys.h
index 1cba411bc0..12e9bb2cf9 100644
--- a/engines/saga2/audiosys.h
+++ b/engines/saga2/audiosys.h
@@ -287,7 +287,7 @@ public:
bool enabled(volumeTarget i);
void enable(volumeTarget i, bool onOff);
void disable(volumeTarget i) {
- enable(i, FALSE);
+ enable(i, false);
}
void setVolume(volumeTarget targ, volumeMode op, Volume val);
Volume getVolume(volumeTarget src);
@@ -337,7 +337,7 @@ private:
#endif
)
return e;
- return TRUE;
+ return true;
}
diff --git a/engines/saga2/automap.cpp b/engines/saga2/automap.cpp
index 9f4e55b672..4eb587dfd4 100644
--- a/engines/saga2/automap.cpp
+++ b/engines/saga2/automap.cpp
@@ -49,7 +49,7 @@ extern GameWorld *currentWorld;
requestInfo rInfo;
#if DEBUG
-bool autoMapCheat = FALSE;
+bool autoMapCheat = false;
#endif
static CAutoMap *pAutoMap = NULL;
@@ -240,9 +240,9 @@ bool CAutoMap::activate(gEventType why) {
if (why == gEventMouseDown) { // momentarily depress
selected = 1;
notify(why, 0); // notify App of successful hit
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
#define SpecialKey(k) ((k>>8)+0x80)
@@ -252,21 +252,21 @@ bool CAutoMap::keyStroke(gPanelMessage &msg) {
switch (msg.key) {
case 0x1B:
cmdAutoMapEsc(ev);
- return TRUE;
+ return true;
case SpecialKey(homeKey):
cmdAutoMapHome(ev);
- return TRUE;
+ return true;
case SpecialKey(endKey):
cmdAutoMapEnd(ev);
- return TRUE;
+ return true;
case SpecialKey(pageUpKey):
cmdAutoMapPgUp(ev);
- return TRUE;
+ return true;
case SpecialKey(pageDownKey):
cmdAutoMapPgDn(ev);
- return TRUE;
+ return true;
default:
- return FALSE;
+ return false;
}
}
@@ -336,7 +336,7 @@ bool CAutoMap::pointerHit(gPanelMessage &msg) {
}
activate(gEventMouseDown);
- return TRUE;
+ return true;
}
// ------------------------------------------------------------------------
@@ -518,7 +518,7 @@ void CAutoMap::createSmallMap(void) {
int16 openAutoMap() {
rInfo.result = -1;
- rInfo.running = TRUE;
+ rInfo.running = true;
hResContext *decRes;
gCompButton *closeAutoMap;
@@ -565,7 +565,7 @@ int16 openAutoMap() {
pAutoMap->locateRegion();
pAutoMap->open();
- EventLoop(rInfo.running, FALSE);
+ EventLoop(rInfo.running, false);
// delete stuff
delete pAutoMap;
diff --git a/engines/saga2/band.h b/engines/saga2/band.h
index 86aece1125..14b7f40f1e 100644
--- a/engines/saga2/band.h
+++ b/engines/saga2/band.h
@@ -100,9 +100,9 @@ public:
bool add(Actor *newMember) {
if (memberCount < elementsof(members)) {
members[memberCount++] = newMember;
- return TRUE;
+ return true;
} else
- return FALSE;
+ return false;
}
void remove(Actor *member) {
diff --git a/engines/saga2/beegee.cpp b/engines/saga2/beegee.cpp
index 914cab45e0..6b993d30ff 100644
--- a/engines/saga2/beegee.cpp
+++ b/engines/saga2/beegee.cpp
@@ -46,7 +46,7 @@ struct auxAudioTheme {
soundSegment loopID;
auxAudioTheme() {
- active = FALSE;
+ active = false;
loopID = 0;
l = Nowhere;
}
@@ -93,7 +93,7 @@ static Point32 themeAt;
static int32 lastGameTime = 0;
static int32 elapsedGameTime = 0;
-static bool playingExternalLoop = FALSE;
+static bool playingExternalLoop = false;
int activeFactions[maxFactions];
@@ -140,7 +140,7 @@ void addAuxTheme(Location loc, soundSegment lid) {
if (!aats[i].active) {
aats[i].l = loc;
aats[i].loopID = lid;
- aats[i].active = TRUE;
+ aats[i].active = true;
return;
}
}
@@ -149,14 +149,14 @@ void addAuxTheme(Location loc, soundSegment lid) {
void killAuxTheme(soundSegment lid) {
for (int i = 0; i < AUXTHEMES; i++) {
if (aats[i].active && aats[i].loopID == lid) {
- aats[i].active = FALSE;
+ aats[i].active = false;
}
}
}
void killAllAuxThemes(void) {
for (int i = 0; i < AUXTHEMES; i++) {
- aats[i].active = FALSE;
+ aats[i].active = false;
}
}
@@ -169,7 +169,7 @@ void disableBGLoop(int32 s) {
void enableBGLoop(void) {
uint32 cr = currentTheme;
- playingExternalLoop = FALSE;
+ playingExternalLoop = false;
currentTheme = 0;
audioEnvironmentUseSet(cr, auxTheme, themeAt);
}
diff --git a/engines/saga2/bitarray.h b/engines/saga2/bitarray.h
index 7e134c2ec8..d42dcae68f 100644
--- a/engines/saga2/bitarray.h
+++ b/engines/saga2/bitarray.h
@@ -104,8 +104,8 @@ public:
}
friend bool operator!= (BitArray c, BitArray d) {
- for (uint16 i = 0; i < c.currentSize(); i++) if (c.b[i] != d.b[i]) return TRUE;
- return FALSE;
+ for (uint16 i = 0; i < c.currentSize(); i++) if (c.b[i] != d.b[i]) return true;
+ return false;
}
friend BitArray operator^ (BitArray c, BitArray d) {
diff --git a/engines/saga2/blitters.cpp b/engines/saga2/blitters.cpp
index 8a7501ac77..16475c7989 100644
--- a/engines/saga2/blitters.cpp
+++ b/engines/saga2/blitters.cpp
@@ -325,7 +325,7 @@ bool initGraphics(void) {
}
bool initProcessResources(void) {
- return TRUE;
+ return true;
}
void termProcessResources(void) {
diff --git a/engines/saga2/button.cpp b/engines/saga2/button.cpp
index 7e15a15bf1..22ef2b463d 100644
--- a/engines/saga2/button.cpp
+++ b/engines/saga2/button.cpp
@@ -46,7 +46,7 @@ void gCompImage::init(void) {
compImages = NULL;
max = 0;
min = 0;
- internalAlloc = FALSE;
+ internalAlloc = false;
currentImage = 0;
numPtrAlloc = 0;
// imageText[0] = NULL;
@@ -61,7 +61,7 @@ gCompImage::gCompImage(gPanelList &list, const Rect16 &box, void *image, uint16
if (image) {
compImages = (void **)malloc(sizeof(pVOID) * 1); // allocate room for one pointer
compImages[0] = image;
- internalAlloc = FALSE;
+ internalAlloc = false;
numPtrAlloc = 1;
}
}
@@ -90,7 +90,7 @@ gCompImage::gCompImage(gPanelList &list,
}
max = numImages - 1;
- internalAlloc = TRUE;
+ internalAlloc = true;
numPtrAlloc = numImages;
// get rid of this context
@@ -365,8 +365,8 @@ void gCompButton::loadImages(hResContext *con, hResID res1, hResID res2) {
dimImage = NULL;
}
- internalAlloc = TRUE;
- dimmed = FALSE;
+ internalAlloc = true;
+ dimmed = false;
}
void gCompButton::loadImages(hResID contextID, hResID res1, hResID res2) {
@@ -415,8 +415,8 @@ gCompButton::gCompButton(gPanelList &list, const Rect16 &box, void **images, int
dimImage = NULL;
}
- internalAlloc = FALSE;
- dimmed = FALSE;
+ internalAlloc = false;
+ dimmed = false;
extent = box;
}
@@ -432,8 +432,8 @@ gCompButton::gCompButton(gPanelList &list, const Rect16 &box, void **images, int
dimImage = NULL;
}
- internalAlloc = FALSE;
- dimmed = FALSE;
+ internalAlloc = false;
+ dimmed = false;
extent = box;
}
@@ -453,7 +453,7 @@ gCompButton::gCompButton(gPanelList &list, const Rect16 &box, void **images, int
dimImage = NULL;
}
- internalAlloc = FALSE;
+ internalAlloc = false;
dimmed = dimNess;
extent = box;
}
@@ -473,8 +473,8 @@ gCompButton::gCompButton(gPanelList &list, const Rect16 &box, void *image, uint1
dimImage = NULL;
}
- internalAlloc = FALSE;
- dimmed = FALSE;
+ internalAlloc = false;
+ dimmed = false;
extent = box;
}
@@ -500,9 +500,9 @@ gCompButton::~gCompButton(void) {
void gCompButton::dim(bool enable) {
if (enable) {
- if (!dimmed) dimmed = TRUE;
+ if (!dimmed) dimmed = true;
} else {
- if (dimmed) dimmed = FALSE;
+ if (dimmed) dimmed = false;
}
window.update(extent);
@@ -527,7 +527,7 @@ bool gCompButton::activate(gEventType why) {
notify(gEventNewValue, 1); // notify App of successful hit
}
playMemSound(2);
- return FALSE;
+ return false;
}
void gCompButton::pointerMove(gPanelMessage &msg) {
@@ -538,10 +538,10 @@ void gCompButton::pointerMove(gPanelMessage &msg) {
}
bool gCompButton::pointerHit(gPanelMessage &) {
- if (dimmed) return FALSE;
+ if (dimmed) return false;
activate(gEventMouseDown);
- return TRUE;
+ return true;
}
void gCompButton::pointerRelease(gPanelMessage &) {
@@ -624,7 +624,7 @@ bool gToggleCompButton::activate(gEventType why) {
notify(gEventNewValue, selected); // notify App of successful hit
playMemSound(1);
}
- return FALSE;
+ return false;
}
bool gToggleCompButton::pointerHit(gPanelMessage &) {
@@ -660,7 +660,7 @@ bool gOwnerSelCompButton::activate(gEventType why) {
notify(gEventNewValue, selected); // notify App of successful hit
playMemSound(2);
}
- return FALSE;
+ return false;
}
bool gOwnerSelCompButton::pointerHit(gPanelMessage &) {
@@ -694,8 +694,8 @@ gMultCompButton::gMultCompButton(gPanelList &list, const Rect16 &box, hResContex
checkAlloc(images[i]);
}
- response = TRUE;
- internalAlloc = TRUE;
+ response = true;
+ internalAlloc = true;
max = numRes - 1;
min = 0;
current = clamp(min, initial, max);
@@ -715,8 +715,8 @@ gMultCompButton::gMultCompButton(gPanelList &list, const Rect16 &box, void **new
images = newImages;
- response = TRUE;
- internalAlloc = FALSE;
+ response = true;
+ internalAlloc = false;
max = numRes - 1;
min = 0;
current = initial;
@@ -738,7 +738,7 @@ gMultCompButton::gMultCompButton(gPanelList &list, const Rect16 &box, void **new
images = newImages;
response = hitResponse;
- internalAlloc = FALSE;
+ internalAlloc = false;
max = numRes - 1;
min = 0;
current = initial;
@@ -775,7 +775,7 @@ bool gMultCompButton::activate(gEventType why) {
playMemSound(1);
// playSound( MKTAG('C','B','T',5) );
}
- return FALSE;
+ return false;
}
bool gMultCompButton::pointerHit(gPanelMessage &) {
@@ -883,7 +883,7 @@ bool gSlider::activate(gEventType why) {
gPanel::deactivate();
notify(gEventNewValue, slCurrent); // notify App of successful hit
}
- return FALSE;
+ return false;
}
void gSlider::deactivate(void) {
@@ -900,7 +900,7 @@ bool gSlider::pointerHit(gPanelMessage &msg) {
window.update(extent);
activate(gEventMouseDown);
- return TRUE;
+ return true;
}
void gSlider::pointerMove(gPanelMessage &msg) {
diff --git a/engines/saga2/calender.cpp b/engines/saga2/calender.cpp
index 18d1395f82..6bcd26c6e0 100644
--- a/engines/saga2/calender.cpp
+++ b/engines/saga2/calender.cpp
@@ -176,14 +176,14 @@ uint16 FrameAlarm::elapsed(void) {
// Pause the global calender
void pauseCalender(void) {
- calenderPaused = TRUE;
+ calenderPaused = true;
}
//-----------------------------------------------------------------------
// Restart the paused global calender
void resumeCalender(void) {
- calenderPaused = FALSE;
+ calenderPaused = false;
}
//-----------------------------------------------------------------------
@@ -214,7 +214,7 @@ uint32 operator - (const CalenderTime &time1, const CalenderTime &time2) {
// Initialize the game calender
void initCalender(void) {
- calenderPaused = FALSE;
+ calenderPaused = false;
calender.years = 0;
calender.weeks = 0;
calender.days = 0;
diff --git a/engines/saga2/config.cpp b/engines/saga2/config.cpp
index f901bef618..121c9ce26f 100644
--- a/engines/saga2/config.cpp
+++ b/engines/saga2/config.cpp
@@ -62,12 +62,12 @@ static void defaultConfig(configuration &config) {
config.musicVolume = 127;
config.soundVolume = 127;
config.voiceVolume = 127;
- config.autoAggression = TRUE;
- config.autoWeapon = TRUE;
- config.speechText = TRUE;
- config.showNight = TRUE;
+ config.autoAggression = true;
+ config.autoWeapon = true;
+ config.speechText = true;
+ config.showNight = true;
#ifdef _WIN32
- config.windowed = FALSE;
+ config.windowed = false;
#endif
strcpy(config.soundResfilePath, ".\\");
strcpy(config.voiceResfilePath, ".\\");
diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index 0be38bc9c4..d1ba065f54 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -103,9 +103,9 @@ static bool alreadyDone;
// static mouse info variables
ObjectID ContainerView::lastPickedObjectID = Nothing;
int32 ContainerView::lastPickedObjectQuantity = - 1;
-bool ContainerView::objTextAlarm = FALSE;
+bool ContainerView::objTextAlarm = false;
char ContainerView::mouseText[ContainerView::bufSize] = { "" };
-bool ContainerView::mouseInView = FALSE;
+bool ContainerView::mouseInView = false;
uint16 ContainerView::numPicked = 1;
GameObject *ContainerView::objToGet;
int32 ContainerView::amountAccumulator = 0;
@@ -275,7 +275,7 @@ ContainerView::ContainerView(
containerObject = GameObject::objectAddress(nd.object);
scrollPosition = 0;
totalRows = app.totRows;
- setMousePoll(TRUE);
+ setMousePoll(true);
}
// Destructor
@@ -307,19 +307,19 @@ ContainerView::~ContainerView() {
********************************************************************
*/
-// returns TRUE if the object is visible for this type of
+// returns true if the object is visible for this type of
// container.
bool ContainerView::isVisible(GameObject *item) {
ProtoObj *proto = item->proto();
if (proto->containmentSet() & ProtoObj::isEnchantment)
- return FALSE;
+ return false;
// If Intangible Container then don't show it.
if ((proto->containmentSet() & (ProtoObj::isContainer | ProtoObj::isIntangible)) == (ProtoObj::isContainer | ProtoObj::isIntangible))
- return TRUE;
+ return true;
- return TRUE;
+ return true;
}
// total the mass, bulk, and number of all objects in container.
@@ -606,7 +606,7 @@ GameObject *ContainerView::pickObject(const Point16 &pickPos) {
bool ContainerView::activate(gEventType why) {
gPanel::activate(why);
- return TRUE;
+ return true;
}
void ContainerView::deactivate(void) {
@@ -621,22 +621,22 @@ void ContainerView::pointerMove(gPanelMessage &msg) {
// static bool that tells if the mouse cursor
// is in a panel
- mouseInView = FALSE;
- mouseInfo.setDoable(TRUE);
+ mouseInView = false;
+ mouseInfo.setDoable(true);
} else {
// if( msg.pointerEnter )
{
// static bool that tells if the mouse cursor
// is in a panel
- mouseInView = TRUE;
+ mouseInView = true;
GameObject *mouseObject;
mouseObject = mouseInfo.getObject();
if (!node.isAccessable(getCenterActorID())) {
- mouseInfo.setDoable(FALSE);
+ mouseInfo.setDoable(false);
} else if (mouseObject == NULL) {
- mouseInfo.setDoable(TRUE);
+ mouseInfo.setDoable(true);
} else {
mouseInfo.setDoable(containerObject->canContain(mouseObject->thisID()));
}
@@ -656,13 +656,13 @@ bool ContainerView::pointerHit(gPanelMessage &msg) {
mouseObject = mouseInfo.getObject();
mouseSet = mouseObject ? mouseObject->containmentSet() : 0;
- if (!mouseInfo.getDoable()) return FALSE;
+ if (!mouseInfo.getDoable()) return false;
if (msg.doubleClick && !alreadyDone) {
dblClick(mouseObject, slotObject, msg);
} else { // single click
if (mouseObject != NULL) {
- alreadyDone = TRUE; // if object then no doubleClick
+ alreadyDone = true; // if object then no doubleClick
if (mouseInfo.getIntent() == GrabInfo::Drop) {
if (mouseSet & ProtoObj::isTangible) {
@@ -694,7 +694,7 @@ bool ContainerView::pointerHit(gPanelMessage &msg) {
}
} else {
// default to doubleClick active
- alreadyDone = FALSE;
+ alreadyDone = false;
clickOn(msg, mouseObject, slotObject);
}
}
@@ -744,7 +744,7 @@ void ContainerView::timerTick(gPanelMessage &msg) {
}
void ContainerView::dblClick(GameObject *mouseObject, GameObject *slotObject, gPanelMessage &msg) {
- alreadyDone = TRUE;
+ alreadyDone = true;
// double click stuff
dblClickOn(msg, mouseObject, slotObject);
@@ -792,7 +792,7 @@ void ContainerView::dblClickOn(
PlayerActorID pID;
// Only player actors can be possessors as far as the UI is concerned
- if (actorIDToPlayerID(possessor, pID) == FALSE) possessor = Nothing;
+ if (actorIDToPlayerID(possessor, pID) == false) possessor = Nothing;
mouseInfo.replaceObject(); //Put Object Back
if (!(proto->setUseCursor(mObj->thisID()))) {
@@ -831,7 +831,7 @@ void ContainerView::dropPhysical(
MotionTask::dropObjectOnObject(*centerActor, *mObj, *cObj, num);
}
- alreadyDone = TRUE;
+ alreadyDone = true;
}
}
@@ -878,7 +878,7 @@ void ContainerView::useConcept(
// If there is an object here drop the mouse object onto it
mObj->dropOn(centerActorID, cObj->thisID());
- alreadyDone = TRUE;
+ alreadyDone = true;
}
}
@@ -905,8 +905,8 @@ void ContainerView::updateMouseText(Point16 &pickPos) {
lastPickedObjectID = Nothing;
lastPickedObjectQuantity = -1;
- // set the display alarm to FALSE
- objTextAlarm = FALSE;
+ // set the display alarm to false
+ objTextAlarm = false;
return;
}
@@ -926,7 +926,7 @@ void ContainerView::updateMouseText(Point16 &pickPos) {
mouseText[0] = NULL;
// reset the alarm flag
- objTextAlarm = FALSE;
+ objTextAlarm = false;
// set the hint alarm
containerObjTextAlarm.set(ticksPerSecond / 2);
@@ -957,7 +957,7 @@ void ContainerView::setDelayedCursorText(GameObject *obj) {
mouseText[0] = NULL;
// reset the alarm flag
- objTextAlarm = FALSE;
+ objTextAlarm = false;
// set the hint alarm
containerObjTextAlarm.set(ticksPerSecond / 2);
@@ -981,7 +981,7 @@ EnchantmentContainerView::EnchantmentContainerView(
// Check If Sprite Should Be Shown
bool EnchantmentContainerView::pointerHit(gPanelMessage &) {
- return TRUE;
+ return true;
}
void EnchantmentContainerView::pointerMove(gPanelMessage &) {}
@@ -1345,7 +1345,7 @@ IntangibleContainerWindow::IntangibleContainerWindow(
assert(mindSelectorCompButton != NULL);
- mindSelectorCompButton->setResponse(FALSE);
+ mindSelectorCompButton->setResponse(false);
// set the decorations for this window
setDecorations(mentalDecorations,
@@ -1389,12 +1389,12 @@ ContainerNode::ContainerNode(ContainerList &cl, ObjectID id, int typ) {
// Convert the possessor() of the object to a player actor ID,
// if it is indeed a player actor; Else set to "nobody".
if (isActor(id)) {
- if (actorIDToPlayerID(id, ownerID) == FALSE)
+ if (actorIDToPlayerID(id, ownerID) == false)
ownerID = ContainerNode::nobody;
} else {
ObjectID possessor = obj->possessor();
- if (possessor == Nothing || actorIDToPlayerID(possessor, ownerID) == FALSE)
+ if (possessor == Nothing || actorIDToPlayerID(possessor, ownerID) == false)
ownerID = ContainerNode::nobody;
}
@@ -1572,7 +1572,7 @@ ContainerNode *ContainerList::find(ObjectID id, int16 type) {
return NULL;
}
-// returns TRUE if the object represented by the container can be
+// returns true if the object represented by the container can be
// accessed by the player.
bool ContainerNode::isAccessable(ObjectID enactor) {
Actor *a = (Actor *)GameObject::objectAddress(enactor);
@@ -1590,10 +1590,10 @@ bool ContainerNode::isAccessable(ObjectID enactor) {
holder = obj->possessor();
if (holder != Nothing || isActor(object)) {
// "Reach" for other players is further than for other objects
- if (holder != a->thisID() && dist > 96) return FALSE;
- } else if (dist > maxOpenDistance) return FALSE;
+ if (holder != a->thisID() && dist > 96) return false;
+ } else if (dist > maxOpenDistance) return false;
- return TRUE;
+ return true;
}
// Change the owner of a ready container (for indiv mode)
@@ -1693,7 +1693,7 @@ ContainerNode *CreateContainerNode(ObjectID id, bool open, int16) {
PlayerActorID owner;
if (isActor(id)) {
- if (actorIDToPlayerID(id, owner) == FALSE)
+ if (actorIDToPlayerID(id, owner) == false)
owner = ContainerNode::nobody;
if (((Actor *)obj)->isDead()) {
@@ -1710,7 +1710,7 @@ ContainerNode *CreateContainerNode(ObjectID id, bool open, int16) {
else fatal("Attempt to open non-dead actor as a container.\n");
#endif
} else {
- if (actorIDToPlayerID(obj->possessor(), owner) == FALSE)
+ if (actorIDToPlayerID(obj->possessor(), owner) == false)
owner = ContainerNode::nobody;
if (!(cn = globalContainerList.find(id, ContainerNode::physicalType)))
@@ -1786,13 +1786,13 @@ void initContainerNodes(void) {
// Verify the globalContainerList only has ready ContainerNodes
ContainerNode *node;
- bool onlyReady = TRUE;
+ bool onlyReady = true;
for (node = (ContainerNode *)globalContainerList.first();
node != NULL;
node = (ContainerNode *)node->next()) {
if (node->getType() != ContainerNode::readyType) {
- onlyReady = FALSE;
+ onlyReady = false;
break;
}
}
@@ -2007,7 +2007,7 @@ APPFUNC(cmdMindContainerFunc) {
break;
default:
- assert(FALSE); // should never get here
+ assert(false); // should never get here
break;
}
diff --git a/engines/saga2/contain.h b/engines/saga2/contain.h
index 380b26bf45..27c18df4e3 100644
--- a/engines/saga2/contain.h
+++ b/engines/saga2/contain.h
@@ -157,7 +157,7 @@ public:
// Draw the quantity indicator below the object if quantity > 1
void drawQuantity(gPort &port, GameObject *item, ProtoObj *objProto, int16 x, int16 y);
- // returns TRUE if the object is visible for this type of
+ // returns true if the object is visible for this type of
// container.
virtual bool isVisible(GameObject *obj);
@@ -523,7 +523,7 @@ public:
object = id;
}
- // returns TRUE if the object represented by the container can be
+ // returns true if the object represented by the container can be
// accessed by the player.
bool isAccessable(ObjectID enactor);
@@ -558,7 +558,7 @@ public:
extern ContainerList globalContainerList;
-ContainerNode *CreateContainerNode(ObjectID id, bool open = TRUE, int16 mindType = 0);
+ContainerNode *CreateContainerNode(ObjectID id, bool open = true, int16 mindType = 0);
ContainerNode *CreateReadyContainerNode(PlayerActorID player);
ContainerNode *OpenMindContainer(PlayerActorID player, int16 open, int16 type);
diff --git a/engines/saga2/display.cpp b/engines/saga2/display.cpp
index 24f0c27ec0..9d82f0d7e6 100644
--- a/engines/saga2/display.cpp
+++ b/engines/saga2/display.cpp
@@ -44,7 +44,7 @@ extern CFTWindow *pWindow;
Globals
* ===================================================================== */
-bool paletteMayHaveChanged = FALSE;
+bool paletteMayHaveChanged = false;
/* ===================================================================== *
@@ -52,10 +52,10 @@ bool paletteMayHaveChanged = FALSE;
* ===================================================================== */
static uint32 displayStatus = GraphicsInit;
-static bool gameSuspendFlag = FALSE;
-static bool paletteSuspendFlag = FALSE;
+static bool gameSuspendFlag = false;
+static bool paletteSuspendFlag = false;
#ifndef _WIN32
-static bool VideoSaved = FALSE;
+static bool VideoSaved = false;
static uint8 VideoSaveMode;
#endif
@@ -100,7 +100,7 @@ void suspendGame(void) {
#ifdef _WIN32
suspendProcessResources();
#endif
- gameSuspendFlag = TRUE;
+ gameSuspendFlag = true;
}
}
@@ -116,7 +116,7 @@ bool gameSuspended(void) {
void resumeGame(void) {
if (gameSuspendFlag) {
- gameSuspendFlag = FALSE;
+ gameSuspendFlag = false;
#ifdef _WIN32
resumeProcessResources();
#endif
@@ -137,7 +137,7 @@ void resumeGame(void) {
void endGame(void) {
blackOut();
displayDisable(GameEnded);
- gameRunning = FALSE;
+ gameRunning = false;
}
@@ -253,12 +253,12 @@ static void switchOff(void) {
* ===================================================================== */
void enablePaletteChanges(void) {
- paletteSuspendFlag = FALSE;
- paletteMayHaveChanged = TRUE;
+ paletteSuspendFlag = false;
+ paletteMayHaveChanged = true;
}
void disablePaletteChanges(void) {
- paletteSuspendFlag = TRUE;
+ paletteSuspendFlag = true;
}
bool paletteChangesEnabled(void) {
@@ -274,14 +274,14 @@ bool paletteChangesEnabled(void) {
// notice that screen may be dirty
void delayedDisplayEnable(void) {
- delayReDraw = FALSE;
+ delayReDraw = false;
}
// ------------------------------------------------------------------------
// notice that palette may be dirty
void externalPaletteIntrusion(void) {
- paletteMayHaveChanged = TRUE;
+ paletteMayHaveChanged = true;
}
// ------------------------------------------------------------------------
@@ -294,14 +294,14 @@ void reDrawScreen(void) {
//updateAllUserControls();
drawMainDisplay();
mainWindow->invalidate(r);
- delayReDraw = FALSE;
+ delayReDraw = false;
if (paletteMayHaveChanged) {
- paletteMayHaveChanged = FALSE;
+ paletteMayHaveChanged = false;
assertCurrentPalette();
- paletteMayHaveChanged = FALSE;
+ paletteMayHaveChanged = false;
}
} else
- delayReDraw = TRUE;
+ delayReDraw = true;
//mainWindow->invalidate(r);
}
diff --git a/engines/saga2/display.h b/engines/saga2/display.h
index f4743e93dc..d0db76c16d 100644
--- a/engines/saga2/display.h
+++ b/engines/saga2/display.h
@@ -68,13 +68,13 @@ void initBackPanel(void);
// ------------------------------------------------------------------------
// Display disable flags
-void displayEnable(DisplayDisabledBecause reason, bool onOff = TRUE);
+void displayEnable(DisplayDisabledBecause reason, bool onOff = true);
bool displayEnabled(uint32 mask = 0xFFFFFFFF);
bool displayOkay(void);
void mainEnable(void);
void mainDisable(void);
-inline void displayDisable(DisplayDisabledBecause reason, bool onOff = FALSE) {
+inline void displayDisable(DisplayDisabledBecause reason, bool onOff = false) {
displayEnable(reason, onOff);
}
diff --git a/engines/saga2/dispnode.cpp b/engines/saga2/dispnode.cpp
index c809fd9f0b..9bf558e3f0 100644
--- a/engines/saga2/dispnode.cpp
+++ b/engines/saga2/dispnode.cpp
@@ -97,7 +97,7 @@ uint8 identityColors[256] = {
// build the list of stuff to draw (like guns)
void buildDisplayList(void) {
- mainDisplayList.buildObjects(TRUE);
+ mainDisplayList.buildObjects(true);
activeSpells.buildList();
}
@@ -215,7 +215,7 @@ void DisplayNodeList::buildObjects(bool fromScratch) {
if ((dist >= loadDist
|| obj->IDParent() != currentWorld->thisID())) {
// Mark this object as being off-screen
- obj->setOnScreen(FALSE);
+ obj->setOnScreen(false);
// If it's an actor
if (isActor(obj)) {
@@ -366,7 +366,7 @@ void DisplayNode::drawObject(void) {
leftIndex, // drawing order of left
rightIndex, // drawing order of right
partCount; // number of sprite parts
- bool ghostIt = FALSE;
+ bool ghostIt = false;
GameObject *obj = object;
ProtoObj *proto = obj->proto();
Point16 drawPos;
@@ -395,8 +395,8 @@ void DisplayNode::drawObject(void) {
hitBox.width = -1;
hitBox.height = -1;
- obj->setOnScreen(FALSE);
- obj->setObscured(FALSE);
+ obj->setOnScreen(false);
+ obj->setObscured(false);
return;
}
}
@@ -422,21 +422,21 @@ void DisplayNode::drawObject(void) {
hitBox.height = -1;
// Mark as being off screen
- obj->setOnScreen(FALSE);
- obj->setObscured(FALSE);
+ obj->setOnScreen(false);
+ obj->setObscured(false);
return;
}
if (!obj->isOnScreen()) {
SenseInfo info;
- obj->setOnScreen(TRUE);
+ obj->setOnScreen(true);
if (getCenterActor()->canSenseSpecificObject(info, maxSenseRange, obj->thisID()))
- obj->setSightedByCenter(TRUE);
+ obj->setSightedByCenter(true);
else {
- obj->setSightedByCenter(FALSE);
- obj->setObscured(FALSE);
+ obj->setSightedByCenter(false);
+ obj->setObscured(false);
}
obj->sightCtr = 5;
@@ -445,10 +445,10 @@ void DisplayNode::drawObject(void) {
SenseInfo info;
if (getCenterActor()->canSenseSpecificObject(info, maxSenseRange, obj->thisID()))
- obj->setSightedByCenter(TRUE);
+ obj->setSightedByCenter(true);
else {
- obj->setSightedByCenter(FALSE);
- obj->setObscured(FALSE);
+ obj->setSightedByCenter(false);
+ obj->setObscured(false);
}
obj->sightCtr = 5;
@@ -493,8 +493,8 @@ void DisplayNode::drawObject(void) {
|| drawPos.y < -maxSpriteBaseLine
|| drawPos.y > tileRect.y + tileRect.height + maxSpriteHeight) {
// Mark as being off screen
- a->setOnScreen(FALSE);
- a->setObscured(FALSE);
+ a->setOnScreen(false);
+ a->setObscured(false);
return;
}
@@ -511,7 +511,7 @@ void DisplayNode::drawObject(void) {
baseBubbleSpriteIndex + a->kludgeCount);
sc->offset.x = scList->offset.y = 0;
sc->colorTable = mainColors;
- sc->flipped = FALSE;
+ sc->flipped = false;
partCount = 1;
bodyIndex = 0;
@@ -526,8 +526,8 @@ void DisplayNode::drawObject(void) {
hitBox.height = -1;
// Mark as being off screen
- a->setOnScreen(FALSE);
- a->setObscured(FALSE);
+ a->setOnScreen(false);
+ a->setObscured(false);
return;
}
@@ -538,19 +538,19 @@ void DisplayNode::drawObject(void) {
hitBox.height = -1;
return;
}
- ghostIt = TRUE;
+ ghostIt = true;
}
if (!a->isOnScreen()) {
SenseInfo info;
- a->setOnScreen(TRUE);
+ a->setOnScreen(true);
if (getCenterActor()->canSenseSpecificActor(info, maxSenseRange, a))
- a->setSightedByCenter(TRUE);
+ a->setSightedByCenter(true);
else {
- a->setSightedByCenter(FALSE);
- a->setObscured(FALSE);
+ a->setSightedByCenter(false);
+ a->setObscured(false);
}
a->sightCtr = 5;
@@ -559,10 +559,10 @@ void DisplayNode::drawObject(void) {
SenseInfo info;
if (getCenterActor()->canSenseSpecificActor(info, maxSenseRange, a))
- a->setSightedByCenter(TRUE);
+ a->setSightedByCenter(true);
else {
- a->setSightedByCenter(FALSE);
- a->setObscured(FALSE);
+ a->setSightedByCenter(false);
+ a->setObscured(false);
}
a->sightCtr = 5;
@@ -770,7 +770,7 @@ void DisplayNode::drawObject(void) {
}
if (!ghostIt && obj->isGhosted())
- ghostIt = TRUE;
+ ghostIt = true;
int16 effectFlags = 0;
bool obscured;
@@ -950,10 +950,10 @@ bool DisplayNodeList::dissipated(void) {
if (count) {
for (int i = 0; i < count; i++) {
if (displayList[i].efx && !displayList[i].efx->isDead())
- return FALSE;
+ return false;
}
}
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -970,7 +970,7 @@ void Effectron::drawEffect(void) {
const int16 partCount = 1;
const int16 bodyIndex = 0;
ColorTable eColors; // colors for object
- bool obscured = FALSE;
+ bool obscured = false;
Point16 drawPos;
TilePoint objCoords = SpellPos();
SpriteComponent scList[3],
@@ -1004,7 +1004,7 @@ void Effectron::drawEffect(void) {
getColorTranslation(eColors, this);
sc->colorTable = eColors;
- sc->flipped = FALSE;
+ sc->flipped = false;
obscured = (visiblePixelsInSprite(sc->sp,
sc->flipped,
diff --git a/engines/saga2/document.cpp b/engines/saga2/document.cpp
index fa171e3793..095323e500 100644
--- a/engines/saga2/document.cpp
+++ b/engines/saga2/document.cpp
@@ -179,7 +179,7 @@ CDocument::CDocument(CDocumentAppearance &dApp,
currentPage = 0;
totalLines = 0;
totalPages = 0;
- pageBreakSet = TRUE;
+ pageBreakSet = true;
// null out the image pointer array
for (int16 i = 0; i < maxPages; i++) {
@@ -235,9 +235,9 @@ bool CDocument::activate(gEventType why) {
if (why == gEventMouseDown) { // momentarily depress
selected = 1;
notify(why, 0); // notify App of successful hit
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
#define SpecialKey(k) ((k>>8)+0x80)
@@ -248,21 +248,21 @@ bool CDocument::keyStroke(gPanelMessage &msg) {
switch (msg.key) {
case 0x1B:
cmdDocumentEsc(ev);
- return TRUE;
+ return true;
case SpecialKey(leftArrowKey):
cmdDocumentLt(ev);
- return TRUE;
+ return true;
case SpecialKey(rightArrowKey):
cmdDocumentRt(ev);
- return TRUE;
+ return true;
case SpecialKey(upArrowKey):
cmdDocumentUp(ev);
- return TRUE;
+ return true;
case SpecialKey(downArrowKey):
cmdDocumentDn(ev);
- return TRUE;
+ return true;
default:
- return FALSE;
+ return false;
}
}
@@ -339,7 +339,7 @@ bool CDocument::pointerHit(gPanelMessage &msg) {
}
activate(gEventMouseDown);
- return TRUE;
+ return true;
}
void CDocument::gotoPage(int8 page) {
@@ -530,10 +530,10 @@ bool CDocument::checkForPageBreak(char *string, uint16 index, int32 &offset) {
offset = index;
// and set the new page flag
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
bool CDocument::checkForImage(char *string,
@@ -609,10 +609,10 @@ bool CDocument::checkForImage(char *string,
textPictureOffset;
// set the new page flag
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
@@ -628,7 +628,7 @@ void CDocument::makePages(void) {
uint16 linesPerPage = pageHeight / (textHeight + 1);
uint16 dummy;
uint16 i;
- bool newPage = FALSE;
+ bool newPage = false;
while (offset >= 0 && pageIndex <= maxPages) {
@@ -645,12 +645,12 @@ void CDocument::makePages(void) {
if (checkForPageBreak(str, i, offset)) {
// if a break did not just occur
if (!pageBreakSet) {
- newPage = TRUE;
- pageBreakSet = TRUE;
+ newPage = true;
+ pageBreakSet = true;
} else {
// eat the newPage and
// reset the flag for a just set break
- pageBreakSet = FALSE;
+ pageBreakSet = false;
}
}
@@ -658,12 +658,12 @@ void CDocument::makePages(void) {
if (checkForImage(str, i, pageIndex, offset)) {
// if a break did not just occur
if (!pageBreakSet) {
- newPage = TRUE;
- pageBreakSet = TRUE;
+ newPage = true;
+ pageBreakSet = true;
} else {
// eat the newPage and
// reset the flag for a just set break
- pageBreakSet = FALSE;
+ pageBreakSet = false;
}
lineIndex = lineOffset[pageIndex];
@@ -671,7 +671,7 @@ void CDocument::makePages(void) {
}
// we got token that was not a page break so reset the flag
- pageBreakSet = FALSE;
+ pageBreakSet = false;
}
// set the length of this line
@@ -691,7 +691,7 @@ void CDocument::makePages(void) {
numLines[pageIndex] = lineIndex;
pageIndex++;
- newPage = FALSE;
+ newPage = false;
/* debug
WriteStatusF( 5, "page#:%d", pageIndex );
@@ -901,7 +901,7 @@ int16 openScroll(uint16 textScript) {
requestInfo rInfo;
rInfo.result = -1;
- rInfo.running = TRUE;
+ rInfo.running = true;
// point to book
@@ -938,7 +938,7 @@ int16 openScroll(uint16 textScript) {
win->open();
// do stuff
- EventLoop(rInfo.running, TRUE);
+ EventLoop(rInfo.running, true);
// remove the window all attatched controls
delete win;
@@ -965,7 +965,7 @@ int16 openBook(uint16 textScript) {
requestInfo rInfo;
rInfo.result = -1;
- rInfo.running = TRUE;
+ rInfo.running = true;
warning("STUB: openBook()");
#if 0
@@ -990,7 +990,7 @@ int16 openBook(uint16 textScript) {
win->open();
// do stuff
- EventLoop(rInfo.running, TRUE);
+ EventLoop(rInfo.running, true);
// remove the window all attatched controls
delete win;
@@ -1010,7 +1010,7 @@ int16 openParchment(uint16 textScript) {
requestInfo rInfo;
rInfo.result = -1;
- rInfo.running = TRUE;
+ rInfo.running = true;
warning("STUB: openParchment()");
#if 0
@@ -1034,7 +1034,7 @@ int16 openParchment(uint16 textScript) {
win->open();
// do stuff
- EventLoop(rInfo.running, TRUE);
+ EventLoop(rInfo.running, true);
// remove the window all attatched controls
delete win;
diff --git a/engines/saga2/effects.cpp b/engines/saga2/effects.cpp
index eb3febea3d..a7dc59dde0 100644
--- a/engines/saga2/effects.cpp
+++ b/engines/saga2/effects.cpp
@@ -459,7 +459,7 @@ SPECIALSPELL(Resurrect) {
SPECIALSPELL(DispellPoison) {
if (isActor(trg->getObject())) {
Actor *a = (Actor *) trg->getObject();
- DispelObjectEnchantment(a->thisID(), makeEnchantmentID(actorPoisoned, TRUE));
+ DispelObjectEnchantment(a->thisID(), makeEnchantmentID(actorPoisoned, true));
}
}
diff --git a/engines/saga2/effects.h b/engines/saga2/effects.h
index 00a77ce26f..6faef28f75 100644
--- a/engines/saga2/effects.h
+++ b/engines/saga2/effects.h
@@ -324,7 +324,7 @@ inline bool isHarmful(uint16 enchID) {
if (typ == effectAttrib) return amt < 0;
if (typ == effectOthers)
return (sub >= actorSlowAttack && sub <= actorBlind);
- return FALSE;
+ return false;
}
// ------------------------------------------------------------------
@@ -370,7 +370,7 @@ public:
}
//int implementation( void ) { return imp; }
virtual bool applicable(SpellTarget &) {
- return FALSE;
+ return false;
}
virtual void implement(GameObject *, SpellTarget *, int8 = 0) {}
};
@@ -391,7 +391,7 @@ class ProtoDamage: public ProtoEffect {
public:
- ProtoDamage(int8 d, int8 s, int8 sd, int8 b, effectDamageTypes t, int, bool afSelf = FALSE, int8 sb = 0) {
+ ProtoDamage(int8 d, int8 s, int8 sd, int8 b, effectDamageTypes t, int, bool afSelf = false, int8 sb = 0) {
type = t;
dice = d;
sides = s;
@@ -423,7 +423,7 @@ class ProtoDrainage: public ProtoEffect {
public:
- ProtoDrainage(int8 d, int8 s, int8 sd, int8 b, effectDrainsTypes t, int, bool afSelf = FALSE) {
+ ProtoDrainage(int8 d, int8 s, int8 sd, int8 b, effectDrainsTypes t, int, bool afSelf = false) {
type = t;
dice = d;
sides = s;
@@ -525,7 +525,7 @@ public:
}
bool applicable(SpellTarget &) {
- return (TRUE);
+ return (true);
}
void implement(GameObject *, SpellTarget *trg, int8 deltaDamage = 0);
@@ -553,7 +553,7 @@ public:
}
bool applicable(SpellTarget &) {
- return TRUE;
+ return true;
//return (trg.getType()==SpellTarget::spellTargetObject ||
// trg.getType()==SpellTarget::spellTargetObjectPoint) &&
// isActor(trg.getObject());
diff --git a/engines/saga2/enchant.cpp b/engines/saga2/enchant.cpp
index 855ba642e9..b98a5b7b56 100644
--- a/engines/saga2/enchant.cpp
+++ b/engines/saga2/enchant.cpp
@@ -102,10 +102,10 @@ bool DispelObjectEnchantment(
// Remove the enchantment and it's effects
ench->deleteObject();
obj->evalEnchantments();
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
//-------------------------------------------------------------------
@@ -234,11 +234,11 @@ void evalObjectEnchantments(GameObject *obj) {
// If more enchantment types are added, then we'll
// have to do this a bit differently...
- if (FindObjectEnchantment(obj->thisID(), makeEnchantmentID(effectNonActor, objectInvisible, TRUE)))
+ if (FindObjectEnchantment(obj->thisID(), makeEnchantmentID(effectNonActor, objectInvisible, true)))
obj->setFlags((uint8) - 1, objectInvisible);
else
obj->setFlags(0, objectInvisible);
- if (FindObjectEnchantment(obj->thisID(), makeEnchantmentID(effectNonActor, objectLocked, FALSE)))
+ if (FindObjectEnchantment(obj->thisID(), makeEnchantmentID(effectNonActor, objectLocked, false)))
obj->setFlags((uint8) - 1, objectLocked);
}
diff --git a/engines/saga2/floating.cpp b/engines/saga2/floating.cpp
index b5f0b772d6..a86a4e6f86 100644
--- a/engines/saga2/floating.cpp
+++ b/engines/saga2/floating.cpp
@@ -186,10 +186,10 @@ void DecoratedWindow::draw(void) { // redraw the window
pointer.show();
}
-// Return TRUE if window floats above animated are
+// Return true if window floats above animated are
bool DecoratedWindow::isBackdrop(void) {
- return FALSE;
+ return false;
}
// Update a region of a window, and all floaters which
@@ -218,10 +218,10 @@ void BackWindow::invalidate(Rect16 &area) {
window.update(area);
}
-// Return TRUE if window floats above animated are
+// Return true if window floats above animated are
bool BackWindow::isBackdrop(void) {
- return TRUE;
+ return true;
}
// A backdrop window can never go to front.
@@ -242,7 +242,7 @@ DragBar::DragBar(gPanelList &list, const Rect16 &r)
}
bool DragBar::activate(gEventType) {
- return TRUE;
+ return true;
}
void DragBar::deactivate(void) {
@@ -256,7 +256,7 @@ bool DragBar::pointerHit(gPanelMessage &msg) {
dragPos.y = wExtent.y;
dragOffset = msg.pickAbsPos;
- return TRUE;
+ return true;
}
// Inform the main drawing loop that a floating window needs to
@@ -275,14 +275,14 @@ void DragBar::pointerDrag(gPanelMessage &msg) {
if (pos != dragPos) {
dragPos = pos;
- update = TRUE;
+ update = true;
dragWindow = (FloatingWindow *)&window;
}
}
void DragBar::pointerRelease(gPanelMessage &) {
deactivate();
- update = FALSE; // just in case
+ update = false; // just in case
dragWindow = NULL;
}
@@ -308,12 +308,12 @@ bool gButton::activate(gEventType why) {
deactivate();
notify(gEventNewValue, 1); // notify App of successful hit
}
- return FALSE;
+ return false;
}
bool gButton::pointerHit(gPanelMessage &) {
activate(gEventMouseDown);
- return TRUE;
+ return true;
}
void gButton::pointerRelease(gPanelMessage &) {
@@ -372,7 +372,7 @@ bool gToggleButton::activate(gEventType why) {
gPanel::deactivate();
notify(gEventNewValue, selected); // notify App of successful hit
}
- return FALSE;
+ return false;
}
bool gToggleButton::pointerHit(gPanelMessage &) {
@@ -639,7 +639,7 @@ void drawFloatingWindows(gPort &port, const Point16 &offset, const Rect16 &clip)
// Move the window to the new position
DragBar::dragWindow->setExtent(newExtent);
- DragBar::update = FALSE;
+ DragBar::update = false;
if (newExtent.overlap(oldExtent)) {
// If the positions overlap, update them as a single
diff --git a/engines/saga2/floating.h b/engines/saga2/floating.h
index 3e57b65109..bf17824aff 100644
--- a/engines/saga2/floating.h
+++ b/engines/saga2/floating.h
@@ -89,7 +89,7 @@ class DragBar : public gControl {
public:
static Point16 dragOffset, // mouse offset
dragPos; // new position of window
- static bool update; // TRUE = update window pos
+ static bool update; // true = update window pos
static FloatingWindow *dragWindow; // which window to update
DragBar(gPanelList &, const Rect16 &);
diff --git a/engines/saga2/fta.h b/engines/saga2/fta.h
index 956bfa7054..549047e16a 100644
--- a/engines/saga2/fta.h
+++ b/engines/saga2/fta.h
@@ -80,7 +80,7 @@ struct gMouseState;
class GameMode {
public:
GameMode *prev; // previous nested mode
- int16 nestable; // TRUE if mode nests
+ int16 nestable; // true if mode nests
static GameMode *modeStackPtr[Max_Modes]; // Array Of Current Mode Stack Pointers to Game Objects
static int modeStackCtr; // Counter For Array Of Mode Stack Pointers to Game Objects
diff --git a/engines/saga2/gamemode.cpp b/engines/saga2/gamemode.cpp
index 428607a226..dadd913b0b 100644
--- a/engines/saga2/gamemode.cpp
+++ b/engines/saga2/gamemode.cpp
@@ -44,7 +44,7 @@ GameMode *GameMode::modeStackPtr[Max_Modes] = { NULL };
GameMode *GameMode::newmodeStackPtr[Max_Modes] = { NULL };
int GameMode::modeStackCtr = 0;
int GameMode::newmodeStackCtr = 0;
-int GameMode::newmodeFlag = FALSE;
+int GameMode::newmodeFlag = false;
void GameMode::modeUnStack(void) {
modeStackPtr[modeStackCtr] = NULL; //Always Start Cleanup At modeStackCtr
@@ -65,11 +65,11 @@ void GameMode::modeUnStack(int StopHere) {
}
bool GameMode::update(void) {
- bool result = FALSE;
+ bool result = false;
int ModeCtr = 0;
- newmodeFlag = FALSE;
+ newmodeFlag = false;
for (int i = 0; i < newmodeStackCtr; i++, ModeCtr++)
if (newmodeStackPtr[i] != modeStackPtr[i])
@@ -111,7 +111,7 @@ void GameMode::SetStack(GameMode *modeFirst, ...) {
#endif
va_end(Modes); //Clean Up
- newmodeFlag = TRUE;
+ newmodeFlag = true;
return;
}
@@ -119,7 +119,7 @@ void GameMode::SetStack(GameMode *modeFirst, ...) {
void GameMode::SetStack(GameMode **newStack, int newStackSize) {
newmodeStackCtr = newStackSize;
memcpy(newmodeStackPtr, newStack, sizeof(GameMode *) * newStackSize);
- newmodeFlag = TRUE;
+ newmodeFlag = true;
}
void GameMode::modeStack(GameMode *AddThisMode) {
diff --git a/engines/saga2/gdraw.cpp b/engines/saga2/gdraw.cpp
index ff4559780b..b5e09a4ff3 100644
--- a/engines/saga2/gdraw.cpp
+++ b/engines/saga2/gdraw.cpp
@@ -431,7 +431,7 @@ void gPort::vLine(int16 x, int16 y, int16 height) {
**********************************************************************
*/
void gPort::line(int16 x1, int16 y1, int16 x2, int16 y2) {
- bool clipNeeded = FALSE;
+ bool clipNeeded = false;
int16 xAbs, yAbs,
xMove, yMove,
@@ -447,13 +447,13 @@ void gPort::line(int16 x1, int16 y1, int16 x2, int16 y2) {
if (x1 > x2) { // drawing left
if (x1 < clip.x || x2 >= clipRight) return;
- if (x2 < clip.x || x1 >= clipRight) clipNeeded = TRUE;
+ if (x2 < clip.x || x1 >= clipRight) clipNeeded = true;
xDir = xMove = -1; // amount to adjust address
xAbs = x1 - x2; // length of line
} else { // drawing right
if (x2 < clip.x || x1 >= clipRight) return;
- if (x1 < clip.x || x2 >= clipRight) clipNeeded = TRUE;
+ if (x1 < clip.x || x2 >= clipRight) clipNeeded = true;
xDir = xMove = 1; // amount to adjust address
xAbs = x2 - x1; // length of line
@@ -461,14 +461,14 @@ void gPort::line(int16 x1, int16 y1, int16 x2, int16 y2) {
if (y1 > y2) { // drawing up
if (y1 < clip.y || y2 >= clipBottom) return;
- if (y2 < clip.y || y1 >= clipBottom) clipNeeded = TRUE;
+ if (y2 < clip.y || y1 >= clipBottom) clipNeeded = true;
yDir = -1;
yAbs = y1 - y2;
yMove = -rowMod;
} else { // drawing down
if (y2 < clip.y || y1 >= clipBottom) return;
- if (y1 < clip.y || y2 >= clipBottom) clipNeeded = TRUE;
+ if (y1 < clip.y || y2 >= clipBottom) clipNeeded = true;
yDir = 1;
yAbs = y2 - y1;
diff --git a/engines/saga2/gdraw.h b/engines/saga2/gdraw.h
index 7f2d6e7699..906bdf2fab 100644
--- a/engines/saga2/gdraw.h
+++ b/engines/saga2/gdraw.h
@@ -204,7 +204,7 @@ public:
// Set attributes
- virtual void setMap(gPixelMap *newmap, bool inverted = FALSE);
+ virtual void setMap(gPixelMap *newmap, bool inverted = false);
// Direct colors
diff --git a/engines/saga2/gpointer.cpp b/engines/saga2/gpointer.cpp
index f7d990fa3a..ef03acc624 100644
--- a/engines/saga2/gpointer.cpp
+++ b/engines/saga2/gpointer.cpp
@@ -59,7 +59,7 @@ gMousePointer::~gMousePointer(void) {
// Init & status check
bool gMousePointer::init(Point16 pointerLimits) {
- return TRUE;
+ return true;
}
// Private routine to draw the mouse pointer image
diff --git a/engines/saga2/grequest.cpp b/engines/saga2/grequest.cpp
index 52db9a8199..05732f5260 100644
--- a/engines/saga2/grequest.cpp
+++ b/engines/saga2/grequest.cpp
@@ -328,13 +328,13 @@ public:
void ModalDisplayWindow::pointerRelease(gPanelMessage &) {
requestInfo *ri = (requestInfo *)userData;
- if (ri) ri->running = FALSE;
+ if (ri) ri->running = false;
}
bool ModalDisplayWindow::keyStroke(gPanelMessage &) {
requestInfo *ri = (requestInfo *)userData;
- if (ri) ri->running = FALSE;
- return TRUE;
+ if (ri) ri->running = false;
+ return true;
}
/* ===================================================================== *
@@ -351,7 +351,7 @@ int16 GameDialogA(
ModalRequestWindow *win;
rInfo.result = -1;
- rInfo.running = TRUE;
+ rInfo.running = true;
win = new ModalRequestWindow(
Rect16((drawPage->size.x - 200) / 2,
@@ -372,7 +372,7 @@ int16 GameDialogA(
win->userData = &rInfo;
win->open();
- EventLoop(rInfo.running, FALSE);
+ EventLoop(rInfo.running, false);
delete win;
return rInfo.result;
@@ -404,7 +404,7 @@ int16 GameDisplayA(
ModalDisplayWindow *win;
rInfo.result = -1;
- rInfo.running = TRUE;
+ rInfo.running = true;
win = new ModalDisplayWindow(
Rect16((drawPage->size.x - 200) / 2,
@@ -424,7 +424,7 @@ int16 GameDisplayA(
win->userData = &rInfo;
win->open();
- EventLoop(rInfo.running, FALSE);
+ EventLoop(rInfo.running, false);
delete win;
return rInfo.result;
diff --git a/engines/saga2/gtext.cpp b/engines/saga2/gtext.cpp
index 82eaf6d2b6..28f829f9dc 100644
--- a/engines/saga2/gtext.cpp
+++ b/engines/saga2/gtext.cpp
@@ -688,7 +688,7 @@ void gPort::drawStringChars(
x = xpos;
s = (uint8 *)str;
- underscore = textStyles & textStyleUnderScore ? TRUE : FALSE;
+ underscore = textStyles & textStyleUnderScore ? true : false;
for (i = 0; i < len; i++) {
int16 last_x = x;
@@ -698,7 +698,7 @@ void gPort::drawStringChars(
if (drawchar == '_' && underbar) {
len--;
drawchar = *s++;
- if (textStyles & textStyleUnderBar) underscore = TRUE;
+ if (textStyles & textStyleUnderBar) underscore = true;
if (textStyles & textStyleHiLiteBar) color = bgPen;
}
x += font->charKern[drawchar];
@@ -710,7 +710,7 @@ void gPort::drawStringChars(
int16 width = x - last_x;
while (width-- > 0) *put++ = color;
- if (!(textStyles & textStyleUnderScore)) underscore = FALSE;
+ if (!(textStyles & textStyleUnderScore)) underscore = false;
}
}
}
@@ -1369,8 +1369,8 @@ void XS_DrawTextWrapped(
if (box->Height >= line_count * row_height)
ypos += (box->Height - line_count * row_height) / 2;
- X_Masking(TRUE);
- X_Clipping(FALSE);
+ X_Masking(true);
+ X_Clipping(false);
for (i = 0; i < line_count; i++) {
DrawFixedString(dest,
diff --git a/engines/saga2/gtextbox.cpp b/engines/saga2/gtextbox.cpp
index a5cdcf6202..544e76ddc4 100644
--- a/engines/saga2/gtextbox.cpp
+++ b/engines/saga2/gtextbox.cpp
@@ -67,7 +67,7 @@ extern gMousePointer pointer; // the actual pointer
*
* It does not currently support the concept of cut & paste.
*
-* This class returns TRUE to the "tabSelect" query indicating
+* This class returns true to the "tabSelect" query indicating
* that it is tab-selectable.
*
* /h2/NOTIFICATIONS
@@ -173,8 +173,8 @@ gTextBox::gTextBox(
int16 i;
- hilit = FALSE;
- noUndo = FALSE;
+ hilit = false;
+ noUndo = false;
index = 0; // index into string array ( which string )
maxLen = length;
@@ -196,13 +196,13 @@ gTextBox::gTextBox(
oldMark = -1;
displayOnly = noEditing;
- editing = FALSE;
+ editing = false;
editRect = box;
editRect.height = fontHeight;
- inDrag = FALSE;
+ inDrag = false;
onEnter = cmdEnter;
onEscape = cmdEscape;
- isActiveCtl = FALSE;
+ isActiveCtl = false;
selected = 0;
parent = &list;
@@ -216,15 +216,15 @@ gTextBox::gTextBox(
currentLen[i] = MIN<int>(editLen, strlen(stringBufs[i]));
}
- internalBuffer = FALSE;
- fullRedraw = TRUE;
+ internalBuffer = false;
+ fullRedraw = true;
index = 0;
enSelect(0);
if (!displayOnly) {
cursorPos = 0;
anchorPos = currentLen[index];
}
- fullRedraw = TRUE;
+ fullRedraw = true;
}
//-----------------------------------------------------------------------
@@ -259,7 +259,7 @@ gTextBox::~gTextBox() {
* length How many characters to insert.
*
* RESULT
-* TRUE if there was enough room in the buffer to insert the text.
+* true if there was enough room in the buffer to insert the text.
*
**********************************************************************
*/
@@ -273,7 +273,7 @@ bool gTextBox::insertText(char *newText, int length) {
// If inserting the text would make the string too long,
// then don't insert it.
- if (currentLen[index] - selWidth + length >= maxLen) return FALSE;
+ if (currentLen[index] - selWidth + length >= maxLen) return false;
// Move the text after the selection to where it will be
// after the insertion.
@@ -298,7 +298,7 @@ bool gTextBox::insertText(char *newText, int length) {
RMemIntegrity();
- return TRUE;
+ return true;
}
/****** gtextbox.cpp/gTextBox::setText *******************************
@@ -354,17 +354,17 @@ bool gTextBox::activate(gEventType why) {
if (why == gEventAltValue) { // momentarily depress
selected = 1;
notify(why, 0); // notify App of successful hit
- return TRUE;
+ return true;
}
- isActiveCtl = TRUE;
+ isActiveCtl = true;
if (!selected) {
enSelect(index);
}
selected = 1;
- fullRedraw = TRUE;
+ fullRedraw = true;
draw();
if (why == gEventNone)
- return TRUE;
+ return true;
return gPanel::activate(why);
}
@@ -372,9 +372,9 @@ bool gTextBox::activate(gEventType why) {
void gTextBox::deactivate(void) {
selected = 0;
- isActiveCtl = FALSE;
+ isActiveCtl = false;
draw();
- fullRedraw = TRUE;
+ fullRedraw = true;
gPanel::deactivate();
}
@@ -393,7 +393,7 @@ bool gTextBox::changed(void) {
if (undoBuffer && editing) {
return memcmp(undoBuffer, fieldStrings[index], currentLen[index] + 1);
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -453,7 +453,7 @@ void gTextBox::scroll(int8 req) {
}
if (endLine != visBase) {
- fullRedraw = TRUE;
+ fullRedraw = true;
}
endLine = visBase;
@@ -464,7 +464,7 @@ void gTextBox::scroll(int8 req) {
textBoxExtent.y = (fontOffset * visIndex) + extent.y;
setEditExtent(textBoxExtent);
- fullRedraw = TRUE;
+ fullRedraw = true;
}
}
@@ -476,8 +476,8 @@ void gTextBox::deSelect(bool commit) {
commitEdit();
else
revertEdit();
- editing = FALSE;
- fullRedraw = TRUE;
+ editing = false;
+ fullRedraw = true;
}
}
@@ -488,11 +488,11 @@ void gTextBox::enSelect(int which) {
index = which;
if (!displayOnly) {
prepareEdit(which);
- editing = TRUE;
+ editing = true;
cursorPos = 0;
anchorPos = currentLen[index];
} else {
- hilit = TRUE;
+ hilit = true;
}
}
@@ -500,10 +500,10 @@ void gTextBox::enSelect(int which) {
void gTextBox::reSelect(int which) {
if (which != index) {
- deSelect(FALSE);
+ deSelect(false);
draw();
enSelect(which);
- fullRedraw = TRUE;
+ fullRedraw = true;
}
}
@@ -598,7 +598,7 @@ bool gTextBox::pointerHit(gPanelMessage &msg) {
makeActive();
}
}
- return TRUE; //gControl::activate( gEventMouseDown );
+ return true; //gControl::activate( gEventMouseDown );
}
@@ -616,7 +616,7 @@ void gTextBox::pointerDrag(gPanelMessage &msg) {
} else {
newPos = WhichIChar(mainFont, (uint8 *)fieldStrings[index], msg.pickPos.x - 3, currentLen[index]);
}
- inDrag = TRUE;
+ inDrag = true;
if (cursorPos != newPos) {
//if (newPos<cursorPos)
cursorPos = newPos;
@@ -634,7 +634,7 @@ void gTextBox::pointerDrag(gPanelMessage &msg) {
void gTextBox::pointerRelease(gPanelMessage &msg) {
if (!msg.leftButton) {
- inDrag = FALSE;
+ inDrag = false;
draw();
}
}
@@ -659,19 +659,19 @@ bool gTextBox::keyStroke(gPanelMessage &msg) {
switch (key) {
case SpecialKey(upArrowKey):
selectionUp(1);
- return TRUE;
+ return true;
case SpecialKey(downArrowKey):
selectionDown(1);
- return TRUE;
+ return true;
case SpecialKey(pageUpKey):
selectionUp(linesPerPage);
- return TRUE;
+ return true;
case SpecialKey(pageDownKey):
selectionDown(linesPerPage);
- return TRUE;
+ return true;
}
}
@@ -705,7 +705,7 @@ bool gTextBox::keyStroke(gPanelMessage &msg) {
if (selWidth == 0) { // if insertion point
// don't delete if at end
- if (selStart >= currentLen[index]) return FALSE;
+ if (selStart >= currentLen[index]) return false;
selWidth = 1; // delete 1 char
}
@@ -729,7 +729,7 @@ bool gTextBox::keyStroke(gPanelMessage &msg) {
break;
default:
- if (flags & textBoxNoFilter) return FALSE;
+ if (flags & textBoxNoFilter) return false;
break;
}
} else if (key == '\r' || key == '\n') { // return key
@@ -748,7 +748,7 @@ bool gTextBox::keyStroke(gPanelMessage &msg) {
(*onEnter)(ev);
}
- return TRUE;
+ return true;
} else if (key == 0x1B) { // escape key
revertEdit();
deactivate(); // deactivate the text box
@@ -761,11 +761,11 @@ bool gTextBox::keyStroke(gPanelMessage &msg) {
(*onEscape)(ev);
}
- if (flags & textBoxNoFilter) return FALSE;
- return TRUE;
+ if (flags & textBoxNoFilter) return false;
+ return true;
} else if (key == '\b' && editing) { // BACKSPACE
if (selWidth == 0) { // if insertion point
- if (selStart < 1) return FALSE; // if at start, do nothing
+ if (selStart < 1) return false; // if at start, do nothing
selStart--; // if I-bar, backup 1 char
selWidth = 1; // delete 1 char
}
@@ -781,7 +781,7 @@ bool gTextBox::keyStroke(gPanelMessage &msg) {
} else if (key == SpecialKey(deleteKey) && editing) { // DELETE character
if (selWidth == 0) { // if insertion point
// don't delete if at end
- if (selStart >= currentLen[index]) return FALSE;
+ if (selStart >= currentLen[index]) return false;
selWidth = 1; // delete 1 char
}
@@ -793,7 +793,7 @@ bool gTextBox::keyStroke(gPanelMessage &msg) {
cursorPos = anchorPos = selStart; // adjust cursor pos
currentLen[index] -= selWidth; // adjust str len
notify(gEventAltValue, 0); // tell app about new value
- } else if (key == '\t' && editing) return FALSE; // reprocess keystroke
+ } else if (key == '\t' && editing) return false; // reprocess keystroke
else if (key == 26 && editing) { // control-z
if (undoBuffer) {
cursorPos = anchorPos = currentLen[index] = undoLen;
@@ -803,7 +803,7 @@ bool gTextBox::keyStroke(gPanelMessage &msg) {
} else if (editing) {
// Insert text, if it will fit
- if (insertText((char *)&key, 1) == FALSE) return FALSE;
+ if (insertText((char *)&key, 1) == false) return false;
notify(gEventAltValue, 0); // tell app about new value
}
@@ -819,9 +819,9 @@ bool gTextBox::keyStroke(gPanelMessage &msg) {
pointer.show(port, extent); // show mouse pointer
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
@@ -832,7 +832,7 @@ bool gTextBox::keyStroke(gPanelMessage &msg) {
//-----------------------------------------------------------------------
bool gTextBox::tabSelect(void) {
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -1021,7 +1021,7 @@ void gTextBox::drawClipped(void) {
if (fullRedraw) {
drawAll(port, Point16(0, 0), Rect16(0, 0, rect.width, rect.height));
- fullRedraw = FALSE;
+ fullRedraw = false;
}
if (editing) {
diff --git a/engines/saga2/gtextbox.h b/engines/saga2/gtextbox.h
index 497b2eb09d..8198f1d049 100644
--- a/engines/saga2/gtextbox.h
+++ b/engines/saga2/gtextbox.h
@@ -125,7 +125,7 @@ protected:
void scroll(int8);
void enSelect(int which);
- void deSelect(bool commit = FALSE);
+ void deSelect(bool commit = false);
void reSelect(int which);
bool activate(gEventType why); // activate the control
diff --git a/engines/saga2/imagcach.cpp b/engines/saga2/imagcach.cpp
index 6e899b1b03..ce0a6bbcf5 100644
--- a/engines/saga2/imagcach.cpp
+++ b/engines/saga2/imagcach.cpp
@@ -65,34 +65,34 @@ bool CImageNode::isSameImage(hResContext *con, uint32 resID) {
if (con) {
if (con->getResID() == contextID &&
resourceID == resID) {
- return TRUE; // match
+ return true; // match
}
}
- return FALSE; // no match
+ return false; // no match
}
bool CImageNode::isSameImage(void *imagePtr) {
// if the image passed has the same address as the image in the node...
if (imagePtr == image) {
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
-// return TRUE if this node needs to be deleted
+// return true if this node needs to be deleted
bool CImageNode::releaseRequest(void) {
// the number of requests on this resource goes down by one
requested--;
// if that was the last request, release this node
if (requested <= 0) {
- return TRUE;
+ return true;
}
// not the last request, keep image
- return FALSE;
+ return false;
}
void *CImageNode::getImagePtr(void) {
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index b1899e3462..3a7a4a0368 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -123,7 +123,7 @@ uint8 *builtinObjectAddress(int16 segment, uint16 index) {
case builtinAbstract:
assert(index > 0);
- if (lookupExport(index, segNum, segOff) == FALSE)
+ if (lookupExport(index, segNum, segOff) == false)
error("SAGA: Cannot take address of abtract class");
return segmentAddress(segNum, segOff);
@@ -680,7 +680,7 @@ bool Thread::interpret(void) {
programCounter.offset = (pc - (codeSeg));
stackPtr = (uint8 *)stack;
flags |= finished;
- return TRUE;
+ return true;
} else {
programCounter.segment = *stack++;
programCounter.offset = *stack++;
@@ -1103,7 +1103,7 @@ bool Thread::interpret(void) {
programCounter.offset = (pc - (codeSeg));
stackPtr = (uint8 *)stack;
- return FALSE;
+ return false;
}
/* ============================================================================ *
@@ -1605,9 +1605,9 @@ void Thread::dispatch(void) {
break;
case waitTagSemaphore:
- if (((ActiveItem *)th->waitParam)->isExclusive() == FALSE) {
+ if (((ActiveItem *)th->waitParam)->isExclusive() == false) {
th->flags &= ~waiting;
- ((ActiveItem *)th->waitParam)->setExclusive(TRUE);
+ ((ActiveItem *)th->waitParam)->setExclusive(true);
}
break;
}
@@ -1765,7 +1765,7 @@ static bool lookupExport(
if (segNum > 1000)
error("SAGA failure: Bad data in export table entry #%d (see scripts.r)", entry);
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -1987,7 +1987,7 @@ void abortObjectThreads(Thread *keep, uint16 objID) {
}
bool abortAllThreads(void) {
- bool result = TRUE;
+ bool result = true;
Thread *th;
for (th = threadList.first(); th; th = th->next) {
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index 16212fbe88..aa063719eb 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -246,9 +246,9 @@ APPFUNC(cmdManaInd);
/* ===================================================================== *
Globals
* ===================================================================== */
-static bool indivControlsFlag = FALSE;
+static bool indivControlsFlag = false;
-bool userControlsSetup = FALSE;
+bool userControlsSetup = false;
/* ===================================================================== *
@@ -710,7 +710,7 @@ CStatusLine::CStatusLine(gPanelList &list,
{
int i;
- lineDisplayed = FALSE;
+ lineDisplayed = false;
queueHead = queueTail = 0;
for (i = 0; i < elementsof(lineQueue); i++)
@@ -744,15 +744,15 @@ void CStatusLine::experationCheck(void) {
if (lineDisplayed
&& (waitAlarm.check()
|| (queueTail != queueHead && minWaitAlarm.check()))) {
- enable(FALSE);
+ enable(false);
window.update(extent);
- lineDisplayed = FALSE;
+ lineDisplayed = false;
}
if (!lineDisplayed && queueTail != queueHead) {
// enable the control
- enable(TRUE);
+ enable(true);
// set up the time for this message
waitAlarm.set(lineQueue[queueTail].frameTime);
@@ -772,14 +772,14 @@ void CStatusLine::experationCheck(void) {
// draw the new textline
window.update(extent);
- lineDisplayed = TRUE;
+ lineDisplayed = true;
}
}
void CStatusLine::clear(void) {
- enable(FALSE);
+ enable(false);
window.update(extent);
- lineDisplayed = FALSE;
+ lineDisplayed = false;
queueHead = queueTail = 0;
}
@@ -807,7 +807,7 @@ CMassWeightIndicator::CMassWeightIndicator(gPanelList *panel, const Point16 &pos
bulkPiePos.x += bulkPieXOffset;
bulkPiePos.y += bulkPieYOffset;
- bRedraw = TRUE; // this MUST be true or the indicators will not draw the first time
+ bRedraw = true; // this MUST be true or the indicators will not draw the first time
// attach the resource context
containerRes = resFile->newContext(containerGroupID, "container context");
@@ -890,11 +890,11 @@ void CMassWeightIndicator::recalculate(void) {
if (containerObject) {
- setMassPie(retMass = getWeightRatio(containerObject, mass, FALSE));
- setBulkPie(retBulk = getBulkRatio(containerObject, bulk, FALSE));
+ setMassPie(retMass = getWeightRatio(containerObject, mass, false));
+ setBulkPie(retBulk = getBulkRatio(containerObject, bulk, false));
} else {
- setMassPie(retMass = getWeightRatio(playerList[getCenterActorPlayerID()].getActor(), mass, FALSE));
- setBulkPie(retBulk = getBulkRatio(playerList[getCenterActorPlayerID()].getActor(), bulk, FALSE));
+ setMassPie(retMass = getWeightRatio(playerList[getCenterActorPlayerID()].getActor(), mass, false));
+ setBulkPie(retBulk = getBulkRatio(playerList[getCenterActorPlayerID()].getActor(), bulk, false));
}
}
@@ -906,7 +906,7 @@ void CMassWeightIndicator::recalculate(void) {
void CMassWeightIndicator::update(void) {
CMassWeightIndicator *indNode = nullptr;
- if (bRedraw == TRUE) {
+ if (bRedraw == true) {
for (indNode = (CMassWeightIndicator *)indList.first();
indNode;
indNode = (CMassWeightIndicator *)indNode->next()) {
@@ -914,7 +914,7 @@ void CMassWeightIndicator::update(void) {
indNode->invalidate();
}
- bRedraw = FALSE;
+ bRedraw = false;
}
}
@@ -1224,7 +1224,7 @@ bool CManaIndicator::needUpdate(PlayerActor *player) {
int16 manaAmount;
int16 baseManaAmount;
uint16 i;
- bool newData = FALSE;
+ bool newData = false;
// this could do more array checking, but
// the number of mana type should remain stable
@@ -1234,11 +1234,11 @@ bool CManaIndicator::needUpdate(PlayerActor *player) {
// check for new data
if (manaAmount != currentMana[i] || baseManaAmount != currentBaseMana[i]) {
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
@@ -1251,7 +1251,7 @@ bool CManaIndicator::update(PlayerActor *player) {
int16 manaAmount;
int16 baseManaAmount;
uint16 i;
- bool newData = FALSE;
+ bool newData = false;
// this could do more array checking, but
// the number of mana type should remain stable
@@ -1261,7 +1261,7 @@ bool CManaIndicator::update(PlayerActor *player) {
// check for new data
if (manaAmount != currentMana[i] || baseManaAmount != currentBaseMana[i]) {
- newData = TRUE;
+ newData = true;
currentMana[i] = manaAmount;
currentBaseMana[i] = baseManaAmount;
@@ -1270,16 +1270,16 @@ bool CManaIndicator::update(PlayerActor *player) {
// get manaLine info ( which star/ring image, and position on screen )
// from getStarInfo which takes the mana type index ( i ),
// current mana total, and the player base mana
- if (newData == TRUE) {
+ if (newData == true) {
getManaLineInfo(i, manaAmount, baseManaAmount, &manaLines[i]);
}
}
// return the state of data change
- if (newData == FALSE) {
- return FALSE;
+ if (newData == false) {
+ return false;
} else {
- return TRUE;
+ return true;
}
}
@@ -1708,9 +1708,9 @@ void SetupUserControls(void) {
for (n = 0; n < kNumViews; n++) {
// portrait button
checkAlloc(portBtns[n] = new gMultCompButton(*trioControls, views[n][index++],
- portImag[n], numPortImages, 0, FALSE, brotherIDs[n], cmdPortrait));
+ portImag[n], numPortImages, 0, false, brotherIDs[n], cmdPortrait));
- portBtns[n]->setMousePoll(TRUE);
+ portBtns[n]->setMousePoll(true);
// aggressive button
checkAlloc(aggressBtns[n] = new gOwnerSelCompButton(*trioControls, views[n][index++],
@@ -1747,8 +1747,8 @@ void SetupUserControls(void) {
// portrait button
checkAlloc(indivPortBtn = new gMultCompButton(*indivControls, views[0][index++],
- portImag[0], numPortImages, 0, FALSE, uiIndiv, cmdPortrait));
- indivPortBtn->setMousePoll(TRUE);
+ portImag[0], numPortImages, 0, false, uiIndiv, cmdPortrait));
+ indivPortBtn->setMousePoll(true);
// aggressive button
checkAlloc(indivAggressBtn = new gOwnerSelCompButton(*indivControls, views[0][index++],
@@ -1803,7 +1803,7 @@ void SetupUserControls(void) {
// make the mana indicator
checkAlloc(ManaIndicator = new CManaIndicator(*indivControls));
- ManaIndicator->setMousePoll(TRUE);
+ ManaIndicator->setMousePoll(true);
// get rid of the resource contexts
if (imageRes) {
@@ -1813,21 +1813,21 @@ void SetupUserControls(void) {
//The controls need to be enabled but undrawn at startup
//if ( displayEnabled() )
- // userControlsSetup = TRUE;
+ // userControlsSetup = true;
updateAllUserControls();
}
void enableUserControls(void) {
- userControlsSetup = TRUE;
+ userControlsSetup = true;
}
void disableUserControls(void) {
- userControlsSetup = FALSE;
+ userControlsSetup = false;
}
// defines the cleanup for ALL user interface controls
void CleanupUserControls(void) {
- userControlsSetup = FALSE;
+ userControlsSetup = false;
CleanupButtonImages();
}
@@ -1906,7 +1906,7 @@ inline T GetRatio(T curUnits, T maxUnits, T ratio) {
return clamp(0, curUnits, ratio);
}
-uint16 getWeightRatio(GameObject *obj, uint16 &maxRatio, bool bReturnMaxRatio = TRUE) {
+uint16 getWeightRatio(GameObject *obj, uint16 &maxRatio, bool bReturnMaxRatio = true) {
assert(isObject(obj) || isActor(obj));
uint16 weight;
@@ -1930,7 +1930,7 @@ uint16 getWeightRatio(GameObject *obj, uint16 &maxRatio, bool bReturnMaxRatio =
}
-uint16 getBulkRatio(GameObject *obj, uint16 &maxRatio, bool bReturnMaxRatio = TRUE) {
+uint16 getBulkRatio(GameObject *obj, uint16 &maxRatio, bool bReturnMaxRatio = true) {
assert(isObject(obj) || isActor(obj));
uint16 maxBulk;
@@ -1972,7 +1972,7 @@ void setEnchantmentDisplay(void) {
// sets the individual brother control state buttons
void setIndivBtns(uint16 brotherID) { // top = 0, mid = 1, bot = 2
- indivControlsFlag = TRUE;
+ indivControlsFlag = true;
// set the indiv bro
indivBrother = brotherID;
@@ -2005,13 +2005,13 @@ void setIndivBtns(uint16 brotherID) { // top = 0, mid = 1, bot = 2
uint16 pieBulkRatio = MassWeightIndicator->getBulkPieDiv();
PlayerActor *brother = &playerList[brotherID];
- MassWeightIndicator->setMassPie(getWeightRatio(brother->getActor(), pieWeightRatio, FALSE));
- MassWeightIndicator->setBulkPie(getBulkRatio(brother->getActor(), pieBulkRatio, FALSE));
+ MassWeightIndicator->setMassPie(getWeightRatio(brother->getActor(), pieWeightRatio, false));
+ MassWeightIndicator->setBulkPie(getBulkRatio(brother->getActor(), pieBulkRatio, false));
}
// sets the trio brothers control state buttons
void setTrioBtns(void) {
- indivControlsFlag = FALSE;
+ indivControlsFlag = false;
// reset any value that might have changed in idividual mode
centerBtns[indivBrother]->select(indivCenterBtn->isSelected());
@@ -2028,16 +2028,16 @@ void setControlPanelsToIndividualMode(uint16 brotherID) {
setIndivBtns(brotherID);
// set the mode controls
- trioControls->show(FALSE, FALSE);
- indivControls->show(TRUE, TRUE);
- trioControls->show(FALSE, TRUE);
+ trioControls->show(false, false);
+ indivControls->show(true, true);
+ trioControls->show(false, true);
}
void setControlPanelsToTrioMode(void) {
setTrioBtns();
- indivControls->show(FALSE, FALSE);
- trioControls->show(TRUE, TRUE);
- indivControls->show(FALSE, TRUE);
+ indivControls->show(false, false);
+ trioControls->show(true, true);
+ indivControls->show(false, true);
}
void toggleIndivMode(void) {
@@ -2123,7 +2123,7 @@ void updateBrotherRadioButtons(uint16 brotherID) {
centerBtns[uiKevin]->ghost(isBrotherDead(uiKevin));
if (brotherID == indivBrother) {
- indivCenterBtn->select(TRUE);
+ indivCenterBtn->select(true);
indivCenterBtn->ghost(isBrotherDead(brotherID));
}
@@ -2246,10 +2246,10 @@ APPFUNC(cmdPortrait) {
}
// ( ( gGenericControl * )ev.panel )->disableDblClick();
- // clickActionDone = TRUE;
+ // clickActionDone = true;
} else if (mouseInfo.getIntent() == GrabInfo::Use) {
mouseInfo.replaceObject();
-// clickActionDone = TRUE;
+// clickActionDone = true;
}
} else if (panID != uiIndiv) {
if (!isBrotherDead(panID)) {
@@ -2265,7 +2265,7 @@ APPFUNC(cmdPortrait) {
if (ev.value == gCompImage::leave) {
mouseInfo.setText(nullptr);
- mouseInfo.setDoable(TRUE);
+ mouseInfo.setDoable(true);
break;
}
@@ -2279,9 +2279,9 @@ APPFUNC(cmdPortrait) {
mouseInfo.setText(nullptr);
if ((enactor->getLocation() - targetActor->getLocation()).quickHDistance() > 96) {
- mouseInfo.setDoable(FALSE);
+ mouseInfo.setDoable(false);
} else {
- mouseInfo.setDoable(TRUE);
+ mouseInfo.setDoable(true);
}
} else {
@@ -2511,7 +2511,7 @@ APPFUNC(cmdHealthStar) {
}
if (ev.value == gCompImage::enter) {
- ev.panel->setMousePoll(TRUE);
+ ev.panel->setMousePoll(true);
}
// get the stats for the selected brother
@@ -2679,7 +2679,7 @@ APPFUNC(cmdManaInd) {
break;
default:
- assert(FALSE); // should never get here
+ assert(false); // should never get here
break;
}
@@ -2700,7 +2700,7 @@ bool isIndivMode(void) {
}
void initUIState(void) {
- indivControlsFlag = FALSE;
+ indivControlsFlag = false;
indivBrother = 0;
//updateAllUserControls();
@@ -2816,7 +2816,7 @@ void gEnchantmentDisplay::pointerMove(gPanelMessage &msg) {
} else {
int16 x = extent.width - 10;
- setMousePoll(TRUE);
+ setMousePoll(true);
setValue(getCenterActorPlayerID());
for (int i = 0; i < iconCount; i++) {
diff --git a/engines/saga2/intrface.h b/engines/saga2/intrface.h
index 3e5fcc1adf..6db8dae92d 100644
--- a/engines/saga2/intrface.h
+++ b/engines/saga2/intrface.h
@@ -348,7 +348,7 @@ public:
pieBulk->invalidate();
}
- CMassWeightIndicator(gPanelList *, const Point16 &, uint16 type = 1, bool death = FALSE);
+ CMassWeightIndicator(gPanelList *, const Point16 &, uint16 type = 1, bool death = false);
~CMassWeightIndicator(void);
uint16 getMassPieDiv(void) {
diff --git a/engines/saga2/keybored.cpp b/engines/saga2/keybored.cpp
index 53cac4ddfa..4999a0808b 100644
--- a/engines/saga2/keybored.cpp
+++ b/engines/saga2/keybored.cpp
@@ -140,7 +140,7 @@ void TileModeHandleKey(int16 key, int16 /* qual */) {
case 'q':
case 0x1b:
- gameRunning = FALSE;
+ gameRunning = false;
break;
case 'j':
@@ -230,8 +230,8 @@ void TileModeHandleKey(int16 key, int16 /* qual */) {
#endif
#ifdef FRANKC
case '~':
- buttonList[tradeButton]->enable(TRUE);
- buttonList[tradeBackButton]->enable(TRUE);
+ buttonList[tradeButton]->enable(true);
+ buttonList[tradeBackButton]->enable(true);
buttonList[tradeButton]->invalidate();
buttonList[tradeBackButton]->invalidate();
tradeNathanCV = new ReadyContainerView(*playControls,
@@ -272,7 +272,7 @@ void TileModeHandleKey(int16 key, int16 /* qual */) {
case 'y':
tilePickPos.u += 100;
tilePickPos.v += 100;
- MotionTask::walkToDirect((Actor &)*GameObject::objectAddress( 32817 ) , tilePickPos, FALSE );
+ MotionTask::walkToDirect((Actor &)*GameObject::objectAddress( 32817 ) , tilePickPos, false );
break;
case 'z':
@@ -280,7 +280,7 @@ void TileModeHandleKey(int16 key, int16 /* qual */) {
subTarget.setTargetObject( a->thisID() );
((Actor *)GameObject::objectAddress( 32791 ))->setupTarget( subTarget ,
Actor::huntToBeNear,
- FALSE,
+ false,
Actor::priorityMedium );
break;
*/
@@ -342,7 +342,7 @@ void TileModeHandleKey(int16 key, int16 /* qual */) {
case 'f':
if (pickedActor != Nothing)
- new ((Actor *)GameObject::objectAddress(pickedActor)) HuntToBeNearActorAssignment(SpecificActorTarget(getCenterActor()), 16, TRUE);
+ new ((Actor *)GameObject::objectAddress(pickedActor)) HuntToBeNearActorAssignment(SpecificActorTarget(getCenterActor()), 16, true);
break;
case '[':
diff --git a/engines/saga2/magic.cpp b/engines/saga2/magic.cpp
index d572a0ba03..a4f4d3e75b 100644
--- a/engines/saga2/magic.cpp
+++ b/engines/saga2/magic.cpp
@@ -141,20 +141,20 @@ bool validTarget(GameObject *enactor, GameObject *target, ActiveItem *tag, Skill
enactor->getLocation() -
target->getLocation())
.magnitude()) {
- return FALSE;
+ return false;
}
#endif
if (target->IDParent() != enactor->IDParent()) {
- return FALSE;
+ return false;
}
if (!lineOfSight(enactor, target, terrainTransparent))
- return FALSE;
+ return false;
if (isActor(target)) {
Actor *a = (Actor *) target;
Actor *e = (Actor *) enactor;
if (a->hasEffect(actorInvisible) && !e->hasEffect(actorSeeInvis))
- return FALSE;
+ return false;
}
if (target->thisID() == enactor->thisID())
return sp.canTarget(spellTargCaster);
@@ -166,7 +166,7 @@ bool validTarget(GameObject *enactor, GameObject *target, ActiveItem *tag, Skill
enactor->getWorldLocation() -
TAGPos(tag))
.magnitude()) {
- return FALSE;
+ return false;
}
return sp.canTarget(spellTargTAG);
}
@@ -176,7 +176,7 @@ bool validTarget(GameObject *enactor, GameObject *target, ActiveItem *tag, Skill
enactor->getLocation() -
)
.magnitude()) {
- return FALSE;
+ return false;
}
#endif
return sp.canTarget(spellTargLocation);
@@ -191,16 +191,16 @@ bool canCast(GameObject *enactor, SkillProto *spell) {
int amt = sProto.getManaAmt();
if (ami == sManaIDSkill)
- return TRUE;
+ return true;
#if NPC_MANA_CHECK
if (isActor(enactor)) {
Actor *a = (Actor *) enactor;
assert(ami >= manaIDRed && ami <= manaIDViolet);
if ((&a->effectiveStats.redMana)[ami] < amt)
- return FALSE;
- return TRUE;
+ return false;
+ return true;
} else {
- return TRUE;
+ return true;
}
#endif
return enactor->hasCharge(ami, amt);
@@ -225,7 +225,7 @@ bool canCast(GameObject *enactor, SkillProto *spell) {
// cast untargeted spell
bool castUntargetedSpell(GameObject *enactor, SkillProto *spell) {
castSpell(enactor, enactor, spell);
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -238,7 +238,7 @@ bool castSpell(GameObject *enactor, Location &target, SkillProto *spell) {
} else
implementSpell(enactor, target, spell);
}
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -251,7 +251,7 @@ bool castSpell(GameObject *enactor, ActiveItem *target, SkillProto *spell) {
} else
implementSpell(enactor, target, spell);
}
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -269,7 +269,7 @@ bool castSpell(GameObject *enactor, GameObject *target, SkillProto *spell) {
} else
implementSpell(enactor, target, spell);
}
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -288,7 +288,7 @@ bool implementSpell(GameObject *enactor, Location &target, SkillProto *spell)
if (!r) {
Location cal = Location(a->getLocation(), a->IDParent());
Saga2::playSoundAt(MKTAG('S', 'P', 'L', spellFailSound), cal);
- return FALSE;
+ return false;
}
PlayerActorID playerID;
@@ -299,13 +299,13 @@ bool implementSpell(GameObject *enactor, Location &target, SkillProto *spell)
}
} else {
if (!enactor->deductCharge(ami, sProto.getManaAmt())) {
- return FALSE;
+ return false;
}
}
activeSpells.add(new SpellInstance(GetOwner(enactor), target, sProto.getDisplayID()));
sProto.playSound(enactor);
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -328,7 +328,7 @@ bool implementSpell(GameObject *enactor, ActiveItem *target, SkillProto *spell)
if (!r) {
Location cal = Location(a->getLocation(), a->IDParent());
Saga2::playSoundAt(MKTAG('S', 'P', 'L', spellFailSound), cal);
- return FALSE;
+ return false;
}
PlayerActorID playerID;
@@ -339,13 +339,13 @@ bool implementSpell(GameObject *enactor, ActiveItem *target, SkillProto *spell)
}
} else {
if (!enactor->deductCharge(ami, sProto.getManaAmt())) {
- return FALSE;
+ return false;
}
}
activeSpells.add(new SpellInstance(GetOwner(enactor), l, sProto.getDisplayID()));
sProto.playSound(enactor);
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -366,7 +366,7 @@ bool implementSpell(GameObject *enactor, GameObject *target, SkillProto *spell)
if (!r) {
Location cal = Location(a->getLocation(), a->IDParent());
Saga2::playSoundAt(MKTAG('S', 'P', 'L', spellFailSound), cal);
- return FALSE;
+ return false;
}
PlayerActorID playerID;
@@ -377,13 +377,13 @@ bool implementSpell(GameObject *enactor, GameObject *target, SkillProto *spell)
}
} else {
if (!enactor->deductCharge(ami, sProto.getManaAmt())) {
- return FALSE;
+ return false;
}
}
activeSpells.add(new SpellInstance(GetOwner(enactor), target, sProto.getDisplayID()));
sProto.playSound(enactor);
- return TRUE;
+ return true;
}
} // end of namespace Saga2
diff --git a/engines/saga2/mainmap.cpp b/engines/saga2/mainmap.cpp
index 876c2e0470..04979646d3 100644
--- a/engines/saga2/mainmap.cpp
+++ b/engines/saga2/mainmap.cpp
@@ -45,9 +45,9 @@ void initCleanup() {
}
bool initializeGame() {
if (setupGame())
- return TRUE;
+ return true;
- return FALSE;
+ return false;
}
void shutdownGame() {
warning("STUB: shutdownGame");
diff --git a/engines/saga2/mapfeatr.cpp b/engines/saga2/mapfeatr.cpp
index 423a3a0156..f70ab54f8c 100644
--- a/engines/saga2/mapfeatr.cpp
+++ b/engines/saga2/mapfeatr.cpp
@@ -311,7 +311,7 @@ void termMapFeatures(void) {
CMapFeature::CMapFeature(TilePoint where, int16 inWorld, const char *desc) {
- visible = FALSE;
+ visible = false;
featureCoords = where;
world = inWorld;
strncpy(name, desc, MAX_MAP_FEATURE_NAME_LENGTH);
@@ -367,7 +367,7 @@ bool CMapFeature::hitCheck(TileRegion viewRegion,
TilePoint comparePoint) {
int32 x, y;
- if (world != inWorld) return FALSE;
+ if (world != inWorld) return false;
TilePoint fCoords = featureCoords >> (tileUVShift + platShift);
if (visible &&
fCoords.u >= viewRegion.min.u &&
@@ -386,7 +386,7 @@ bool CMapFeature::hitCheck(TileRegion viewRegion,
TilePoint DisplayPoint = TilePoint(x, y, 0);
return isHit(DisplayPoint, comparePoint);
}
- return FALSE;
+ return false;
}
/* ===================================================================== *
diff --git a/engines/saga2/mapfeatr.h b/engines/saga2/mapfeatr.h
index 134ff003e5..a1bb267012 100644
--- a/engines/saga2/mapfeatr.h
+++ b/engines/saga2/mapfeatr.h
@@ -55,7 +55,7 @@ public:
CMapFeature(TilePoint where, int16 inWorld, const char *desc);
virtual ~CMapFeature() {}
- void expose(bool canSee = TRUE) {
+ void expose(bool canSee = true) {
visible = canSee;
}
void draw(TileRegion tr, int16 inWorld, TilePoint bc, gPort &tport);
@@ -107,7 +107,7 @@ public:
virtual void blit(gPort &tp, int32 x, int32 y);
virtual void update(void) {}
virtual bool isHit(TilePoint disp, TilePoint mouse) {
- return FALSE;
+ return false;
}
};
diff --git a/engines/saga2/messager.h b/engines/saga2/messager.h
index 29c24b5fcd..61c187b32e 100644
--- a/engines/saga2/messager.h
+++ b/engines/saga2/messager.h
@@ -68,10 +68,10 @@ protected:
public:
Messager() {
- enabled = TRUE;
+ enabled = true;
}
Messager(char *entry) {
- enabled = TRUE;
+ enabled = true;
}
virtual ~Messager() {}
@@ -79,10 +79,10 @@ public:
size_t va(const char *format, va_list argptr);
void enable() {
- enabled = TRUE;
+ enabled = true;
}
void disable() {
- enabled = FALSE;
+ enabled = false;
}
bool active() {
return enabled;
diff --git a/engines/saga2/mission.cpp b/engines/saga2/mission.cpp
index 88528a792a..28014a7470 100644
--- a/engines/saga2/mission.cpp
+++ b/engines/saga2/mission.cpp
@@ -94,22 +94,22 @@ ActiveMission *ActiveMission::missionAddress(int index) {
bool ActiveMission::addObjectID(ObjectID objID) {
if (numObjectIDs < elementsof(missionObjectList)) {
missionObjectList[numObjectIDs++] = objID;
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
// Add record of object creation to mission
bool ActiveMission::removeObjectID(ObjectID objID) {
- bool found = FALSE;
+ bool found = false;
for (int i = 0; i < numObjectIDs; i++) {
if (found) {
missionObjectList[i - 1] = missionObjectList[i];
} else {
- if (missionObjectList[i] == objID) found = TRUE;
+ if (missionObjectList[i] == objID) found = true;
}
}
@@ -122,25 +122,25 @@ bool ActiveMission::removeObjectID(ObjectID objID) {
// Add record of knowledge creation to mission
bool ActiveMission::addKnowledgeID(ObjectID actor, uint16 knowledgeID) {
- if (!isActor(actor)) return FALSE;
+ if (!isActor(actor)) return false;
if (numKnowledgeIDs < elementsof(missionKnowledgeList)) {
Actor *a = (Actor *)GameObject::objectAddress(actor);
- if (!a->addKnowledge(knowledgeID)) return FALSE;
+ if (!a->addKnowledge(knowledgeID)) return false;
missionKnowledgeList[numKnowledgeIDs].id = actor;
missionKnowledgeList[numKnowledgeIDs++].kID = knowledgeID;
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
// Add record of knowledge creation to mission
bool ActiveMission::removeKnowledgeID(ObjectID actor, uint16 knowledgeID) {
- bool found = FALSE;
+ bool found = false;
for (int i = 0; i < numKnowledgeIDs; i++) {
if (found) {
@@ -148,7 +148,7 @@ bool ActiveMission::removeKnowledgeID(ObjectID actor, uint16 knowledgeID) {
} else {
if (missionKnowledgeList[i].id == actor
&& missionKnowledgeList[i].kID == knowledgeID) {
- found = TRUE;
+ found = true;
}
}
}
diff --git a/engines/saga2/modal.cpp b/engines/saga2/modal.cpp
index d39b1a0439..5f6d637a39 100644
--- a/engines/saga2/modal.cpp
+++ b/engines/saga2/modal.cpp
@@ -47,7 +47,7 @@ void ModalModeHandleKey(short, short);
GameMode ModalMode = {
NULL, // no previous mode
- FALSE, // mode is not nestable
+ false, // mode is not nestable
ModalModeSetup,
ModalModeCleanup,
ModalModeHandleTask,
diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp
index fa71c6e9f7..7ff85fa035 100644
--- a/engines/saga2/motion.cpp
+++ b/engines/saga2/motion.cpp
@@ -240,7 +240,7 @@ bool unstickObject(GameObject *obj) {
outside = objRoofID(obj, mapNum, obj->getLocation()) == 0;
if (checkBlocked(obj, obj->getLocation()) == blockageNone)
- return FALSE;
+ return false;
#if 1
#if DEBUG
@@ -303,7 +303,7 @@ bool unstickObject(GameObject *obj) {
WriteStatusF(9, "Unstick Dist: %d", radius);
#endif
obj->move(bestPos);
- return TRUE;
+ return true;
}
#else
@@ -328,7 +328,7 @@ bool unstickObject(GameObject *obj) {
&& tHeight >= pos.z - maxStepHeight * 4) {
pos.z = tHeight;
obj->move(pos);
- return TRUE;
+ return true;
}
}
}
@@ -338,7 +338,7 @@ bool unstickObject(GameObject *obj) {
#if DEBUG
WriteStatusF(9, "Unstick Failed!");
#endif
- return TRUE;
+ return true;
}
// Calculates the direction of a missile based upon the velocity vector
@@ -1223,7 +1223,7 @@ void MotionTask::remove(int16 returnVal) {
// Make sure the actor is not left in a permanently
// uninterruptable state with no motion task to reset it
if (a->isPermanentlyUninterruptable())
- a->setInterruptablity(TRUE);
+ a->setInterruptablity(true);
}
DNode::remove();
@@ -2184,7 +2184,7 @@ void MotionTask::ballisticAction(void) {
if (isActor(obj)) {
// Before anything else make sure the actor is in an
// uninterruptable state.
- ((Actor *)obj)->setInterruptablity(FALSE);
+ ((Actor *)obj)->setInterruptablity(false);
}
@@ -2276,7 +2276,7 @@ void MotionTask::ballisticAction(void) {
return;
}
- if (checkContact(obj, newPos, &collisionObject) == FALSE) {
+ if (checkContact(obj, newPos, &collisionObject) == false) {
location = newPos;
} else {
TilePoint oldVelocity = velocity;
@@ -2380,7 +2380,7 @@ void MotionTask::ballisticAction(void) {
if (isActor(obj) && probe & (1 << 2)) {
StandingTileInfo sti;
- if (freeFall(location, sti) == FALSE) {
+ if (freeFall(location, sti) == false) {
int16 velocityMagnitude = oldVelocity.magnitude();
fallingDamage(obj, velocityMagnitude);
@@ -2412,7 +2412,7 @@ void MotionTask::ballisticAction(void) {
// very small, then we'll assume that the object
// has come to rest.
- if (freeFall(location, sti) == FALSE) {
+ if (freeFall(location, sti) == false) {
obj->move(location);
remove(); // delete motion task
setObjectSurface(obj, sti);
@@ -2438,7 +2438,7 @@ void MotionTask::ballisticAction(void) {
bool MotionTask::nextWayPoint(void) {
// If the pathfinder hasn't managed to determine waypoints
// yet, then return failure.
-// if ( ( flags & pathFind ) && pathCount < 0 ) return FALSE;
+// if ( ( flags & pathFind ) && pathCount < 0 ) return false;
// If there are still waypoints in the path list, then
// retrieve the next waypoint.
@@ -2452,7 +2452,7 @@ bool MotionTask::nextWayPoint(void) {
// Next vertex in path polyline
immediateLocation = pathList[pathIndex++];
else
- return FALSE;
+ return false;
} else {
if (flags & wandering) {
immediateLocation = Nowhere;
@@ -2477,11 +2477,11 @@ bool MotionTask::nextWayPoint(void) {
immediateLocation = finalTarget;
}
// else we're close enough to call it quits.
- else return FALSE;
+ else return false;
}
}
- return TRUE;
+ return true;
}
@@ -2501,11 +2501,11 @@ bool MotionTask::checkWalk(
newPos = object->location + (dirTable[direction] * speed) / 2;
newPos.z = object->location.z + stepUp;
- if (checkWalkable(object, newPos)) return FALSE;
+ if (checkWalkable(object, newPos)) return false;
// movementDirection = direction;
pos = newPos;
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -2534,8 +2534,8 @@ void MotionTask::walkAction(void) {
ProtoObj *proto;
int16 impact = 0;
- bool moveTaskWaiting = FALSE,
- moveTaskDone = FALSE;
+ bool moveTaskWaiting = false,
+ moveTaskDone = false;
WalkType walkType = walkNormal;
assert(isActor(object));
@@ -2550,7 +2550,7 @@ void MotionTask::walkAction(void) {
proto = a->proto();
// Make sure that the actor is interruptable
- a->setInterruptablity(TRUE);
+ a->setInterruptablity(true);
// Set the speed of movement based on whether we are walking
// or running. Running only occurs after we have accelerated.
@@ -2625,12 +2625,12 @@ void MotionTask::walkAction(void) {
break;
}
- if (nextWayPoint() == FALSE) {
+ if (nextWayPoint() == false) {
// If no waypoint could be found and this motion task has
// a path find request, then go into "wait" mode.
if (pathFindTask)
- moveTaskWaiting = TRUE;
- else moveTaskDone = TRUE;
+ moveTaskWaiting = true;
+ else moveTaskDone = true;
break;
} else {
flags &= ~reset;
@@ -2677,16 +2677,16 @@ void MotionTask::walkAction(void) {
}
#endif
- moveBlocked = FALSE;
+ moveBlocked = false;
if (moveTaskDone || moveTaskWaiting) {
movementDirection = a->currentFacing;
} else if (targetDist == 0 && abs(targetVector.z) > maxStepHeight) {
if (pathFindTask)
- moveTaskWaiting = TRUE;
+ moveTaskWaiting = true;
else {
movementDirection = a->currentFacing;
- moveBlocked = TRUE;
+ moveBlocked = true;
}
} else if (targetDist <= speed) {
int16 blockageType;
@@ -2710,21 +2710,21 @@ void MotionTask::walkAction(void) {
// octant this frame, then they cannot move so a terrain test is unneeded.
if (directionAngle <= 1 && directionAngle >= -1) {
// Test the terrain to see if we can go there.
- if ((blockageType = checkWalkable(object, newPos)) != FALSE) {
+ if ((blockageType = checkWalkable(object, newPos)) != false) {
// Try stepping up to a higher terrain too.
newPos.z = object->location.z + maxStepHeight;
if (checkWalkable(object, newPos) != blockageNone) {
// If there is a path find task pending, put the walk action
// on hold until it finishes, else, abort the walk action.
if (pathFindTask)
- moveTaskWaiting = TRUE;
+ moveTaskWaiting = true;
else {
movementDirection = a->currentFacing;
- moveBlocked = TRUE;
+ moveBlocked = true;
}
- /* if (!(flags & pathFind) || nextWayPoint() == FALSE)
+ /* if (!(flags & pathFind) || nextWayPoint() == false)
{
- moveBlocked = TRUE;
+ moveBlocked = true;
flags |= blocked;
newPos.z = object->location.z;
@@ -2734,7 +2734,7 @@ void MotionTask::walkAction(void) {
}
} else {
int16 height;
- bool foundPath = FALSE;
+ bool foundPath = false;
movementDirection = targetVector.quickDir();
@@ -2758,7 +2758,7 @@ void MotionTask::walkAction(void) {
if (!checkWalkable(object, pos)) {
newPos = pos;
- foundPath = TRUE;
+ foundPath = true;
break;
}
}
@@ -2767,20 +2767,20 @@ void MotionTask::walkAction(void) {
// Check left and right facings if a path was not found in
// the forward direction.
- if (foundPath == FALSE) {
+ if (foundPath == false) {
int16 leftDir = spinLeft(movementDirection),
rightDir = spinRight(movementDirection);
for (height = 0; height <= maxStepHeight; height += 8) {
if (checkWalk(rightDir, speedScale, height, newPos)) {
movementDirection = rightDir;
- foundPath = TRUE;
+ foundPath = true;
break;
}
if (checkWalk(leftDir, speedScale, height, newPos)) {
movementDirection = leftDir;
- foundPath = TRUE;
+ foundPath = true;
break;
}
}
@@ -2789,38 +2789,38 @@ void MotionTask::walkAction(void) {
// Let's try moving at a right angle to the current path to
// get around this annoying obstacle...
- if (foundPath == FALSE) {
+ if (foundPath == false) {
if (targetVector.u > speed / 2
&& checkWalk(dirUpRight, speedScale, 0, newPos)) {
movementDirection = dirUpRight;
- foundPath = TRUE;
+ foundPath = true;
} else if (-targetVector.u > speed / 2
&& checkWalk(dirDownLeft, speedScale, 0, newPos)) {
movementDirection = dirDownLeft;
- foundPath = TRUE;
+ foundPath = true;
} else if (targetVector.v > speed / 2
&& checkWalk(dirUpLeft, speedScale, 0, newPos)) {
movementDirection = dirUpLeft;
- foundPath = TRUE;
+ foundPath = true;
} else if (-targetVector.v > speed / 2
&& checkWalk(dirDownRight, speedScale, 0, newPos)) {
movementDirection = dirDownRight;
- foundPath = TRUE;
+ foundPath = true;
}
}
// If we just couldn't find a valid path no matter how hard
// we tried, then just give up and say that we were blocked.
- if (foundPath == FALSE) {
+ if (foundPath == false) {
// If there is a path find task pending, put the walk action
// on hold until it finishes, else, abort the walk action.
if (pathFindTask)
- moveTaskWaiting = TRUE;
+ moveTaskWaiting = true;
else {
movementDirection = a->currentFacing;
- moveBlocked = TRUE;
+ moveBlocked = true;
}
}
}
@@ -2895,7 +2895,7 @@ void MotionTask::walkAction(void) {
&& tHeight < newPos.z)
newPos.z = tHeight;
- if (freeFall(newPos, sti) == FALSE) {
+ if (freeFall(newPos, sti) == false) {
int16 newAction;
if (sti.surfaceTile != NULL
@@ -3870,7 +3870,7 @@ void MotionTask::dodgeAction(void) {
// If the attacker is not attacking, we're done
if (attackerMotion == NULL
|| !attackerMotion->isMeleeAttack()) {
- a->setInterruptablity(TRUE);
+ a->setInterruptablity(true);
remove();
return;
}
@@ -4146,7 +4146,7 @@ void MotionTask::defensiveMeleeAction(void) {
// If the attacker is not attacking, we're done
if (attackerMotion == NULL
|| !attackerMotion->isMeleeAttack()) {
- a->setInterruptablity(TRUE);
+ a->setInterruptablity(true);
remove();
return;
}
@@ -4169,7 +4169,7 @@ void MotionTask::defensiveMeleeAction(void) {
// Wait for the attacker's attack
if (attackerMotion == NULL
|| !attackerMotion->isMeleeAttack()) {
- a->setInterruptablity(TRUE);
+ a->setInterruptablity(true);
remove();
}
}
@@ -4193,8 +4193,8 @@ void MotionTask::updatePositions(void) {
ProtoObj *proto = obj->proto();
Actor *a = (Actor *)obj;
int16 impact = 0;
- bool moveTaskWaiting = FALSE,
- moveTaskDone = FALSE;
+ bool moveTaskWaiting = false,
+ moveTaskDone = false;
nextMT = (MotionTask *)mt->next();
@@ -4277,7 +4277,7 @@ void MotionTask::updatePositions(void) {
}
} else {
a->setAction(newAction, 0);
- a->setInterruptablity(FALSE);
+ a->setInterruptablity(false);
mt->flags &= ~reset;
}
} else if (a->nextAnimationFrame() || (mt->flags & inWater)) {
@@ -4293,8 +4293,8 @@ void MotionTask::updatePositions(void) {
(mt->flags & requestRun) != 0);
}
nextMT = mt;
- } else if (mt->freeFall(obj->location, sti) == FALSE)
- moveTaskDone = TRUE;
+ } else if (mt->freeFall(obj->location, sti) == false)
+ moveTaskDone = true;
} else {
// If actor was running, go through an abreviated
// landing sequence by aborting the landing animation
@@ -4322,7 +4322,7 @@ void MotionTask::updatePositions(void) {
if (mt->flags & reset) {
a->setAction(actionJumpUp, 0);
- a->setInterruptablity(FALSE);
+ a->setInterruptablity(false);
mt->flags &= ~reset;
} else if (a->nextAnimationFrame()) {
mt->motionType = motionTypeThrown;
@@ -4356,7 +4356,7 @@ void MotionTask::updatePositions(void) {
mt->flags |= reset;
nextMT = mt;
} else
- moveTaskDone = TRUE;
+ moveTaskDone = true;
}
break;
@@ -4366,7 +4366,7 @@ void MotionTask::updatePositions(void) {
mt->actionCounter = 5;
mt->flags &= ~reset;
} else if (--mt->actionCounter == 0)
- moveTaskDone = TRUE;
+ moveTaskDone = true;
break;
case motionTypeUseObject:
@@ -4375,7 +4375,7 @@ void MotionTask::updatePositions(void) {
a->setActionPoints(2);
mt->directObject->use(a->thisID());
//nextMT=mt;
- moveTaskDone = TRUE;
+ moveTaskDone = true;
break;
case motionTypeUseObjectOnObject:
@@ -4400,7 +4400,7 @@ void MotionTask::updatePositions(void) {
a->thisID(),
mt->indirectObject->thisID());
if (mt && mt->motionType == motionTypeUseObjectOnObject)
- moveTaskDone = TRUE;
+ moveTaskDone = true;
else
nextMT = mt;
}
@@ -4412,7 +4412,7 @@ void MotionTask::updatePositions(void) {
a->thisID(),
mt->indirectObject->thisID());
if (mt && mt->motionType == motionTypeUseObjectOnObject)
- moveTaskDone = TRUE;
+ moveTaskDone = true;
else
nextMT = mt;
}
@@ -4453,7 +4453,7 @@ void MotionTask::updatePositions(void) {
a->setActionPoints(2);
mt->directObject->useOn(a->thisID(), mt->TAI);
if (mt && mt->motionType == motionTypeUseObjectOnTAI)
- moveTaskDone = TRUE;
+ moveTaskDone = true;
else
nextMT = mt;
}
@@ -4473,7 +4473,7 @@ void MotionTask::updatePositions(void) {
a->setActionPoints(2);
mt->directObject->useOn(a->thisID(), mt->targetLoc);
if (mt && mt->motionType == motionTypeUseObjectOnLocation)
- moveTaskDone = TRUE;
+ moveTaskDone = true;
else
nextMT = mt;
}
@@ -4512,7 +4512,7 @@ void MotionTask::updatePositions(void) {
// The actor will now be uniterruptable
a->setActionPoints(2);
mt->TAI->use(a->thisID());
- moveTaskDone = TRUE;
+ moveTaskDone = true;
}
break;
@@ -4533,7 +4533,7 @@ void MotionTask::updatePositions(void) {
mt->targetLoc,
mt->moveCount);
if (mt && mt->motionType == motionTypeDropObject)
- moveTaskDone = TRUE;
+ moveTaskDone = true;
else
nextMT = mt;
}
@@ -4544,12 +4544,12 @@ void MotionTask::updatePositions(void) {
mt->targetLoc,
mt->moveCount);
if (mt && mt->motionType == motionTypeDropObject)
- moveTaskDone = TRUE;
+ moveTaskDone = true;
else
nextMT = mt;
}
- CMassWeightIndicator::bRedraw = TRUE; // tell the mass/weight indicators to refresh
+ CMassWeightIndicator::bRedraw = true; // tell the mass/weight indicators to refresh
break;
@@ -4568,7 +4568,7 @@ void MotionTask::updatePositions(void) {
mt->indirectObject->thisID(),
mt->moveCount);
if (mt && mt->motionType == motionTypeDropObjectOnObject)
- moveTaskDone = TRUE;
+ moveTaskDone = true;
else
nextMT = mt;
}
@@ -4580,12 +4580,12 @@ void MotionTask::updatePositions(void) {
mt->indirectObject->thisID(),
mt->moveCount);
if (mt && mt->motionType == motionTypeDropObjectOnObject)
- moveTaskDone = TRUE;
+ moveTaskDone = true;
else
nextMT = mt;
}
- CMassWeightIndicator::bRedraw = TRUE; // tell the mass/weight indicators to refresh
+ CMassWeightIndicator::bRedraw = true; // tell the mass/weight indicators to refresh
break;
@@ -4606,7 +4606,7 @@ void MotionTask::updatePositions(void) {
mt->TAI,
mt->targetLoc);
if (mt && mt->motionType == motionTypeDropObjectOnTAI)
- moveTaskDone = TRUE;
+ moveTaskDone = true;
else
nextMT = mt;
}
@@ -4660,11 +4660,11 @@ void MotionTask::updatePositions(void) {
if (mt->flags & reset) {
if (a->isActionAvailable(actionDie)) {
a->setAction(actionDie, 0);
- a->setInterruptablity(FALSE);
+ a->setInterruptablity(false);
mt->flags &= ~reset;
} else {
- moveTaskDone = TRUE;
- a->setInterruptablity(TRUE);
+ moveTaskDone = true;
+ a->setInterruptablity(true);
if (!a->hasEffect(actorDisappearOnDeath)) {
a->setAction(actionDead, 0);
a->die();
@@ -4675,8 +4675,8 @@ void MotionTask::updatePositions(void) {
}
}
} else if (a->nextAnimationFrame()) {
- moveTaskDone = TRUE;
- a->setInterruptablity(TRUE);
+ moveTaskDone = true;
+ a->setInterruptablity(true);
if (!a->hasEffect(actorDisappearOnDeath)) {
a->setAction(actionDead, 0);
a->die();
@@ -4695,7 +4695,7 @@ void MotionTask::updatePositions(void) {
//-----------------------------------------------------------------------
// Manages any object which has no supporting surface.
-// Returns TRUE if object is still falling.
+// Returns true if object is still falling.
bool MotionTask::freeFall(TilePoint &newPos, StandingTileInfo &sti) {
int16 tHeight;
@@ -4704,7 +4704,7 @@ bool MotionTask::freeFall(TilePoint &newPos, StandingTileInfo &sti) {
tHeight = tileSlopeHeight(newPos, object, &sti);
- if (object->objectFlags & objectFloating) return FALSE;
+ if (object->objectFlags & objectFloating) return false;
velocity.u = (newPos.u - object->location.u) * 2 / 3;
velocity.v = (newPos.v - object->location.v) * 2 / 3;
@@ -4725,12 +4725,12 @@ supported:
}
newPos.z = tHeight;
// setObjectSurface( object, sti );
- return FALSE;
+ return false;
} else {
motionType = motionTypeRise;
immediateLocation.z = tHeight;
object->move(newPos);
- return TRUE;
+ return true;
}
}
@@ -4752,10 +4752,10 @@ falling:
// newPos = tPos;
object->move(tPos);
- return TRUE;
+ return true;
} else {
newPos = tPos;
- return FALSE;
+ return false;
}
}
@@ -4828,7 +4828,7 @@ falling:
object->move(newPos);
unstickObject(object);
newPos = object->getLocation();
- return TRUE;
+ return true;
}
}
@@ -4946,20 +4946,20 @@ bool checkLadder(Actor *a, const TilePoint &loc) {
else
MotionTask::downLadder(*a);
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
void pauseInterruptableMotions(void) {
- interruptableMotionsPaused = TRUE;
+ interruptableMotionsPaused = true;
}
void resumeInterruptableMotions(void) {
- interruptableMotionsPaused = FALSE;
+ interruptableMotionsPaused = false;
}
/* ===================================================================== *
diff --git a/engines/saga2/motion.h b/engines/saga2/motion.h
index 977db74acf..cdf9d9403b 100644
--- a/engines/saga2/motion.h
+++ b/engines/saga2/motion.h
@@ -347,27 +347,27 @@ public:
static void walkTo(
Actor &obj,
const TilePoint &target,
- bool run = FALSE,
- bool canAgitate = TRUE);
+ bool run = false,
+ bool canAgitate = true);
static void walkTo(
ThreadID th,
Actor &obj,
const TilePoint &target,
- bool run = FALSE,
- bool canAgitate = TRUE);
+ bool run = false,
+ bool canAgitate = true);
static void walkToDirect(
Actor &obj,
const TilePoint &target,
- bool run = FALSE,
- bool canAgitate = TRUE);
+ bool run = false,
+ bool canAgitate = true);
static void walkToDirect(
ThreadID th,
Actor &obj,
const TilePoint &target,
- bool run = FALSE,
- bool canAgitate = TRUE);
- static void wander(Actor &obj, bool run = FALSE);
- static void tetheredWander(Actor &obj, const TileRegion &tether, bool run = FALSE);
+ bool run = false,
+ bool canAgitate = true);
+ static void wander(Actor &obj, bool run = false);
+ static void tetheredWander(Actor &obj, const TileRegion &tether, bool run = false);
// static void runTo( GameObject &obj, const TilePoint &target );
static void staggerTo(Actor &obj, const TilePoint &target);
static void upLadder(Actor &obj);
@@ -485,8 +485,8 @@ public:
}
// Update to a new final target
- void changeTarget(const TilePoint &newPos, bool run = FALSE);
- void changeDirectTarget(const TilePoint &newPos, bool run = FALSE);
+ void changeTarget(const TilePoint &newPos, bool run = false);
+ void changeDirectTarget(const TilePoint &newPos, bool run = false);
void finishWalk(void); // stop walking
void finishTurn(void) {
if (isTurn()) remove();
diff --git a/engines/saga2/mouseimg.cpp b/engines/saga2/mouseimg.cpp
index 1a4032fbe8..15c187264a 100644
--- a/engines/saga2/mouseimg.cpp
+++ b/engines/saga2/mouseimg.cpp
@@ -114,7 +114,7 @@ gStaticImage *mouseCursors[kMouseMax];
static uint8 gaugeImageBuffer[gaugeImageWidth * gaugeImageHeight];
static gStaticImage gaugeImage(gaugeImageWidth, gaugeImageHeight, gaugeImageBuffer);
-static bool showGauge = FALSE;
+static bool showGauge = false;
/* ===================================================================== *
Functions
@@ -358,7 +358,7 @@ void setMouseTextF(char *format, ...) {
if (format == nullptr) {
setMouseText(nullptr);
- G_BASE.mouseHintSet = TRUE;
+ G_BASE.mouseHintSet = true;
} else {
char lineBuf[128];
va_list argptr;
@@ -368,7 +368,7 @@ void setMouseTextF(char *format, ...) {
va_end(argptr);
setMouseText(lineBuf);
- G_BASE.mouseHintSet = TRUE;
+ G_BASE.mouseHintSet = true;
}
}
@@ -415,7 +415,7 @@ void setMouseGauge(int numerator, int denominator) {
}
}
- showGauge = TRUE;
+ showGauge = true;
setupMousePointer();
}
@@ -424,7 +424,7 @@ void setMouseGauge(int numerator, int denominator) {
// Turn off the gauge on the mouse pointer
void clearMouseGauge(void) {
- showGauge = FALSE;
+ showGauge = false;
setupMousePointer();
}
diff --git a/engines/saga2/msgbox.cpp b/engines/saga2/msgbox.cpp
index 82dc0b4641..e3a58215b2 100644
--- a/engines/saga2/msgbox.cpp
+++ b/engines/saga2/msgbox.cpp
@@ -147,7 +147,7 @@ ErrorWindow::ErrorWindow(char *msg, char *btnMsg1, char *btnMsg2)
// requester info struct
rInfo.result = -1;
- rInfo.running = TRUE;
+ rInfo.running = true;
strcpy(mbChs1Text, "\x13");
strcpy(mbChs2Text, "\x1B");
@@ -179,7 +179,7 @@ ErrorWindow::ErrorWindow(char *msg, char *btnMsg1, char *btnMsg2)
int16 ErrorWindow::getResult(void) {
open();
draw();
- EventLoop(rInfo.running, TRUE);
+ EventLoop(rInfo.running, true);
return rInfo.result;
}
@@ -193,25 +193,25 @@ void ErrorWindow::ErrorModeHandleKey(short key, short) {
if (strchr(mbChs2Text, tolower(key)) ||
strchr(mbChs2Text, toupper(key))) {
rInfo.result = 2;
- rInfo.running = FALSE;
+ rInfo.running = false;
return;
}
if (strchr(mbChs1Text, tolower(key)) ||
strchr(mbChs1Text, toupper(key))) {
rInfo.result = 1;
- rInfo.running = FALSE;
+ rInfo.running = false;
return;
}
if (numBtns < 2) {
rInfo.result = 1;
- rInfo.running = FALSE;
+ rInfo.running = false;
return;
}
}
GameMode SimpleMode = {
NULL, // no previous mode
- FALSE, // mode is not nestable
+ false, // mode is not nestable
ErrorWindow::ErrorModeSetup,
ErrorWindow::ErrorModeCleanup,
ErrorWindow::ErrorModeHandleTask,
@@ -240,7 +240,7 @@ SimpleWindow::~SimpleWindow(void) {
}
bool SimpleWindow::isModal(void) {
- return TRUE;
+ return true;
}
void SimpleWindow::update(const Rect16 &) {
@@ -261,7 +261,7 @@ void SimpleWindow::drawClipped(
int16 textPos = textPosHigh;
//textPallete pal( 33+9, 36+9, 41+9, 34+9, 40+9, 43+9 );
textPallete pal(33 + 9, 33 + 9, 41 + 9, 33 + 9, 33 + 9, 41 + 9);
- bool selected = FALSE;
+ bool selected = false;
box.x += 10;
box.y += 10;
@@ -380,14 +380,14 @@ bool SimpleButton::activate(gEventType why) {
deactivate();
notify(gEventNewValue, 1); // notify App of successful hit
}
- return FALSE;
+ return false;
}
bool SimpleButton::pointerHit(gPanelMessage &) {
- //if (ghosted) return FALSE;
+ //if (ghosted) return false;
activate(gEventMouseDown);
- return TRUE;
+ return true;
}
void SimpleButton::pointerRelease(gPanelMessage &) {
diff --git a/engines/saga2/music.h b/engines/saga2/music.h
index 78f88836d3..362e3e4123 100644
--- a/engines/saga2/music.h
+++ b/engines/saga2/music.h
@@ -54,10 +54,10 @@ private:
public:
Deejay() {
enemy = -1;
- aggr = FALSE;
- day = TRUE;
- susp = FALSE;
- ugd = FALSE;
+ aggr = false;
+ day = true;
+ susp = false;
+ ugd = false;
}
~Deejay() {}
diff --git a/engines/saga2/noise.cpp b/engines/saga2/noise.cpp
index 12b2cdd644..75f6fd488b 100644
--- a/engines/saga2/noise.cpp
+++ b/engines/saga2/noise.cpp
@@ -145,7 +145,7 @@ bool hResCheckResID(hResContext *hrc, uint32 s[]);
// Specific DECODER routines
BUFFERLOD(seekMusic) {
- return hResSeek(sb, ss, musicRes, TRUE);
+ return hResSeek(sb, ss, musicRes, true);
}
BUFFERLOD(readMusic) {
return hResRead(sb, ss, musicRes);
@@ -154,7 +154,7 @@ BUFFERLOD(flushMusic) {
return hResFlush(sb, ss, musicRes);
}
BUFFERLOD(seekLongSound) {
- return hResSeek(sb, ss, longRes, FALSE);
+ return hResSeek(sb, ss, longRes, false);
}
BUFFERLOD(readLongSound) {
return hResRead(sb, ss, longRes);
@@ -163,7 +163,7 @@ BUFFERLOD(flushLongSound) {
return hResFlush(sb, ss, longRes);
}
BUFFERLOD(seekSound) {
- return hResSeek(sb, ss, soundRes, TRUE);
+ return hResSeek(sb, ss, soundRes, true);
}
BUFFERLOD(readSound) {
return hResRead(sb, ss, soundRes);
@@ -172,7 +172,7 @@ BUFFERLOD(flushSound) {
return hResFlush(sb, ss, soundRes);
}
BUFFERLOD(seekLoop) {
- return hResSeek(sb, ss, loopRes, TRUE);
+ return hResSeek(sb, ss, loopRes, true);
}
BUFFERLOD(readLoop) {
return hResRead(sb, ss, loopRes);
@@ -181,7 +181,7 @@ BUFFERLOD(flushLoop) {
return hResFlush(sb, ss, loopRes);
}
BUFFERLOD(seekVoice) {
- return hResSeek(sb, ss, voiceRes, FALSE);
+ return hResSeek(sb, ss, voiceRes, false);
}
BUFFERLOD(readVoice) {
return hResRead(sb, ss, voiceRes);
@@ -391,7 +391,7 @@ bool haveKillerSoundCard(void) {
#ifndef _WIN32
if (audio && audio->mid != NULL)
return audio->goodMIDICard();
- return FALSE;
+ return false;
#else
return GetPrivateProfileInt("Sound", "WavetableMIDI", 1, iniFile);
#endif
@@ -430,13 +430,13 @@ void resumeLoops(void) {
}
void suspendMusic(void) {
- audioEnvironmentSuspend(TRUE);
+ audioEnvironmentSuspend(true);
}
void resumeMusic(void) {
//if (audio->enabled(volMusic))
if (musicRes)
- audioEnvironmentSuspend(FALSE);
+ audioEnvironmentSuspend(false);
}
void suspendAudio(void) {
@@ -552,12 +552,12 @@ void playVoice(uint32 s) {
// supplemental interface for speech
bool sayVoice(uint32 s[]) {
- bool worked = FALSE;
+ bool worked = false;
#ifndef AUDIO_DISABLED
if (hResCheckResID(voiceRes, s)) {
audio->queueVoice(s, voiceDec, Here);
if (audio->talking())
- worked = TRUE;
+ worked = true;
}
#endif
return worked;
@@ -615,12 +615,12 @@ void playSoundAt(uint32 s, Location playAt) {
// voice playback w/ attenuation
bool sayVoiceAt(uint32 s[], Point32 p) {
- bool worked = FALSE;
+ bool worked = false;
#ifndef AUDIO_DISABLED
if (hResCheckResID(voiceRes, s)) {
audio->queueVoice(s, voiceDec, p);
if (audio->talking())
- worked = TRUE;
+ worked = true;
}
#endif
return worked;
@@ -630,7 +630,7 @@ bool sayVoiceAt(uint32 s[], Location playAt) {
Point32 p = translateLocation(playAt);
if (p != VeryFarAway)
return sayVoiceAt(s, p);
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
diff --git a/engines/saga2/objects.h b/engines/saga2/objects.h
index 564c9b1cac..9c1bb6d881 100644
--- a/engines/saga2/objects.h
+++ b/engines/saga2/objects.h
@@ -257,7 +257,7 @@ public:
void updateImage(ObjectID); // move to new location in world,
// (assumes setLocation has been called)
- // Remove an object from a stack of objects. Returns TRUE if it was in a stack.
+ // Remove an object from a stack of objects. Returns true if it was in a stack.
bool unstack(void);
// this correctly moves merged or stacked objects
@@ -317,7 +317,7 @@ public:
bool getAvailableSlot(
GameObject *obj,
TilePoint *slot,
- bool canMerge = FALSE,
+ bool canMerge = false,
GameObject **mergeObj = NULL);
// Find a slot to place the specified object within this object and
@@ -326,7 +326,7 @@ public:
bool placeObject(
ObjectID enactor,
ObjectID objID,
- bool canMerge = FALSE,
+ bool canMerge = false,
int16 num = 1);
// Drop the specified object on the ground in a semi-random location
diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp
index 4d32af709c..a66430e7a7 100644
--- a/engines/saga2/objproto.cpp
+++ b/engines/saga2/objproto.cpp
@@ -71,7 +71,7 @@ ObjectID ProtoObj::placeObject(void) {
// Check if item can be contained by this object
bool ProtoObj::canContain(ObjectID dObj, ObjectID item) {
- return FALSE;
+ return false;
}
// Determine if the object can contain another object at the specified
@@ -80,17 +80,17 @@ bool ProtoObj::canContainAt(
ObjectID dObj,
ObjectID item,
const TilePoint &where) {
- return FALSE;
+ return false;
}
// Determine if this type of object is two handed
bool ProtoObj::isTwoHanded(ObjectID) {
- return FALSE;
+ return false;
}
// Determine if this type of object is a missile
bool ProtoObj::isMissile(void) {
- return FALSE;
+ return false;
}
//Create Container Window
@@ -106,7 +106,7 @@ bool ProtoObj::use(ObjectID dObj, ObjectID enactor) {
int16 scriptResult;
// Setup use cursor, if necessary
- if (setUseCursor(dObj)) return TRUE;
+ if (setUseCursor(dObj)) return true;
// Handle object script in a standard fashion
if ((scriptResult = stdActionScript(
@@ -120,12 +120,12 @@ bool ProtoObj::use(ObjectID dObj, ObjectID enactor) {
// The default action is not to set up a use cursor
bool ProtoObj::setUseCursor(ObjectID dObj) {
- return FALSE;
+ return false;
}
// The virtual use action command
bool ProtoObj::useAction(ObjectID dObj, ObjectID enactor) {
- return FALSE;
+ return false;
}
// UseOn object command
@@ -149,7 +149,7 @@ bool ProtoObj::useOn(ObjectID dObj, ObjectID enactor, ObjectID item) {
// Perform the use on action
bool ProtoObj::useOnAction(ObjectID dObj, ObjectID enactor, ObjectID item) {
- return FALSE;
+ return false;
}
// UseOn active item command
@@ -186,7 +186,7 @@ bool ProtoObj::useOn(ObjectID dObj, ObjectID enactor, ActiveItem *item) {
// Perform the use on action
bool ProtoObj::useOnAction(ObjectID dObj, ObjectID enactor, ActiveItem *item) {
- return FALSE;
+ return false;
}
// UseOn location command
@@ -234,14 +234,14 @@ bool ProtoObj::useOn(ObjectID dObj, ObjectID enactor, const Location &loc) {
// Perform the use on action
bool ProtoObj::useOnAction(ObjectID dObj, ObjectID enactor, const Location &loc) {
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
-// Returns TRUE if object in continuous use.
+// Returns true if object in continuous use.
bool ProtoObj::isObjectBeingUsed(GameObject *) {
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -249,7 +249,7 @@ bool ProtoObj::isObjectBeingUsed(GameObject *) {
// specified actor
bool ProtoObj::useSlotAvailable(GameObject *, Actor *) {
- return FALSE;
+ return false;
}
// Open this object
@@ -258,7 +258,7 @@ bool ProtoObj::open(ObjectID dObj, ObjectID enactor) {
int16 scriptResult;
- if (!canOpen(dObj, enactor)) return FALSE;
+ if (!canOpen(dObj, enactor)) return false;
// Handle object script in a standard fashion
if ((scriptResult = stdActionScript(
@@ -272,12 +272,12 @@ bool ProtoObj::open(ObjectID dObj, ObjectID enactor) {
// Virtual function to determine if this object can be opened
bool ProtoObj::canOpen(ObjectID, ObjectID) {
- return FALSE;
+ return false;
}
// Virtual function to actually open the object
bool ProtoObj::openAction(ObjectID, ObjectID) {
- return FALSE;
+ return false;
}
// Close this object
@@ -287,7 +287,7 @@ bool ProtoObj::close(ObjectID dObj, ObjectID enactor) {
int16 scriptResult;
GameObject *dObjPtr = GameObject::objectAddress(dObj);
- if (!dObjPtr->isOpen()) return FALSE;
+ if (!dObjPtr->isOpen()) return false;
// Handle object script in a standard fashion
if ((scriptResult = stdActionScript(
@@ -301,7 +301,7 @@ bool ProtoObj::close(ObjectID dObj, ObjectID enactor) {
// Virtual function to actually close the object
bool ProtoObj::closeAction(ObjectID, ObjectID) {
- return FALSE;
+ return false;
}
// Take this object
@@ -310,7 +310,7 @@ bool ProtoObj::take(ObjectID dObj, ObjectID enactor, int16 num) {
assert(mouseInfo.getObjectId() == Nothing);
// >>> this needs to be dynamic!
- if (mass > 200 || bulk > 200) return FALSE;
+ if (mass > 200 || bulk > 200) return false;
int16 scriptResult;
@@ -326,12 +326,12 @@ bool ProtoObj::take(ObjectID dObj, ObjectID enactor, int16 num) {
// Virtual function to take the object
bool ProtoObj::takeAction(ObjectID, ObjectID) {
- return FALSE;
+ return false;
}
// Virtual function to take the object
bool ProtoObj::takeAction(ObjectID, ObjectID, int16 num) {
- return FALSE;
+ return false;
}
@@ -339,7 +339,7 @@ bool ProtoObj::takeAction(ObjectID, ObjectID, int16 num) {
bool ProtoObj::drop(ObjectID dObj, ObjectID enactor, const Location &loc, int16 num) {
assert(dObj != Nothing);
- if (!canDropAt(dObj, enactor, loc)) return FALSE;
+ if (!canDropAt(dObj, enactor, loc)) return false;
// Handle object script in a non-standard fashion
scriptCallFrame scf;
@@ -367,12 +367,12 @@ bool ProtoObj::drop(ObjectID dObj, ObjectID enactor, const Location &loc, int16
// Virtual function to determine if this object can be dropped at the
// specified location
bool ProtoObj::canDropAt(ObjectID, ObjectID, const Location &) {
- return FALSE;
+ return false;
}
// Virtual function to drop the object
bool ProtoObj::dropAction(ObjectID, ObjectID, const Location &, int16) {
- return FALSE;
+ return false;
}
// drop an object onto another object and handle the result.
@@ -380,7 +380,7 @@ bool ProtoObj::dropOn(ObjectID dObj, ObjectID enactor, ObjectID target, int16 co
assert(dObj != Nothing);
// this prevents objects from being dropped on themselves
- if (target == dObj) return TRUE;
+ if (target == dObj) return true;
int16 scriptResult;
@@ -437,7 +437,7 @@ bool ProtoObj::dropOnAction(
ActiveItem *,
const Location &,
int16) {
- return FALSE;
+ return false;
}
// Strike another object with this object
@@ -459,7 +459,7 @@ bool ProtoObj::strike(ObjectID dObj, ObjectID enactor, ObjectID item) {
// Virtual function to strike another object with this object
bool ProtoObj::strikeAction(ObjectID, ObjectID, ObjectID) {
- return FALSE;
+ return false;
}
// Damage another object with this object
@@ -480,7 +480,7 @@ bool ProtoObj::damage(ObjectID dObj, ObjectID enactor, ObjectID target) {
// Virtual function to damage another object with this object
bool ProtoObj::damageAction(ObjectID, ObjectID, ObjectID) {
- return FALSE;
+ return false;
}
// Eat this object
@@ -501,7 +501,7 @@ bool ProtoObj::eat(ObjectID dObj, ObjectID enactor) {
// Virtual function to eat this object
bool ProtoObj::eatAction(ObjectID, ObjectID) {
- return FALSE;
+ return false;
}
// Insert this object into another object
@@ -523,7 +523,7 @@ bool ProtoObj::insert(ObjectID dObj, ObjectID enactor, ObjectID item) {
// Virtual function to insert this object into another object
bool ProtoObj::insertAction(ObjectID, ObjectID, ObjectID) {
- return FALSE;
+ return false;
}
// Remove this object from the object it is in
@@ -544,7 +544,7 @@ bool ProtoObj::remove(ObjectID dObj, ObjectID enactor) {
// Virtual function to remove this object from the object it is in
bool ProtoObj::removeAction(ObjectID, ObjectID) {
- return FALSE;
+ return false;
}
// Handle the effects of an object being dropped on this object
@@ -611,7 +611,7 @@ bool ProtoObj::acceptDamageAction(
int8,
uint8,
int8) {
- return TRUE;
+ return true;
}
bool ProtoObj::acceptHealing(
@@ -642,7 +642,7 @@ bool ProtoObj::acceptHealing(
// Virtual function to damage this object directly
bool ProtoObj::acceptHealingAction(ObjectID, ObjectID, int8) {
- return FALSE;
+ return false;
}
// Accept strike from another object (allows this object to cause
@@ -677,7 +677,7 @@ bool ProtoObj::acceptStrikeAction(
ObjectID,
ObjectID,
uint8) {
- return TRUE;
+ return true;
}
// Unlock or lock this object with a key.
@@ -689,7 +689,7 @@ bool ProtoObj::acceptLockToggle(
int16 scriptResult;
- if (!canToggleLock(dObj, enactor, keyCode)) return FALSE;
+ if (!canToggleLock(dObj, enactor, keyCode)) return false;
// Handle object script in a standard fashion
if ((scriptResult = stdActionScript(
@@ -703,12 +703,12 @@ bool ProtoObj::acceptLockToggle(
// Virtual function to determine if the lock can be toggled
bool ProtoObj::canToggleLock(ObjectID, ObjectID, uint8) {
- return FALSE;
+ return false;
}
// Virtual function to actually toggle the lock
bool ProtoObj::acceptLockToggleAction(ObjectID, ObjectID, uint8) {
- return FALSE;
+ return false;
}
// Mix this object with another.
@@ -730,7 +730,7 @@ bool ProtoObj::acceptMix(ObjectID dObj, ObjectID enactor, ObjectID mixObj) {
// Virtual function to mix this object with another
bool ProtoObj::acceptMixAction(ObjectID, ObjectID, ObjectID) {
- return FALSE;
+ return false;
}
// Insert another object into this object.
@@ -742,7 +742,7 @@ bool ProtoObj::acceptInsertion(
assert(dObj != Nothing);
assert(item != Nothing);
- if (!canContain(dObj, item)) return FALSE;
+ if (!canContain(dObj, item)) return false;
int16 scriptResult;
@@ -758,7 +758,7 @@ bool ProtoObj::acceptInsertion(
// Virtual function to insert an object into this object
bool ProtoObj::acceptInsertionAction(ObjectID, ObjectID, ObjectID, int16) {
- return FALSE;
+ return false;
}
// Insert another object into this object at a specified slot
@@ -771,7 +771,7 @@ bool ProtoObj::acceptInsertionAt(
assert(dObj != Nothing);
assert(item != Nothing);
- if (!canContainAt(dObj, item, where)) return FALSE;
+ if (!canContainAt(dObj, item, where)) return false;
int16 scriptResult;
@@ -789,7 +789,7 @@ bool ProtoObj::acceptInsertionAt(
// specified slot
bool ProtoObj::acceptInsertionAtAction(
ObjectID, ObjectID, ObjectID, const TilePoint &, int16) {
- return FALSE;
+ return false;
}
@@ -822,7 +822,7 @@ ObjectSpriteInfo ProtoObj::getSprite(GameObject *obj, enum spriteTypes spr, int1
sprIndex = obj->missileFacing;
else {
sprIndex = 16 - obj->missileFacing;
- sprInfo.flipped = TRUE;
+ sprInfo.flipped = true;
}
sprInfo.sp = missileSprites->sprite(sprIndex);
@@ -919,7 +919,7 @@ GameObject *ProtoObj::getSpell(ObjectID) {
// Determine if this type of object can block an attack
bool ProtoObj::canBlock(void) {
- return FALSE;
+ return false;
}
// Return a mask of bits indicating the directions relative to the
@@ -980,13 +980,13 @@ void ProtoObj::doBackgroundUpdate(GameObject *obj) {
// ------------------------------------------------------------------------
bool ProtoObj::canFitBulkwise(GameObject *, GameObject *) {
- return FALSE;
+ return false;
}
// ------------------------------------------------------------------------
bool ProtoObj::canFitMasswise(GameObject *, GameObject *) {
- return FALSE;
+ return false;
}
// ------------------------------------------------------------------------
@@ -1013,7 +1013,7 @@ uint16 InventoryProto::containmentSet(void) {
bool InventoryProto::takeAction(ObjectID dObj, ObjectID enactor, int16 num) {
mouseInfo.copyObject(dObj, GrabInfo::Drop, num);
- return TRUE;
+ return true;
}
bool InventoryProto::canDropAt(
@@ -1023,7 +1023,7 @@ bool InventoryProto::canDropAt(
assert(enactor != Nothing);
// If we're not dropping it onto a world, we're okay
- if (!isWorld(loc.context)) return TRUE;
+ if (!isWorld(loc.context)) return true;
GameObject *enactorPtr = GameObject::objectAddress(enactor);
@@ -1033,9 +1033,9 @@ bool InventoryProto::canDropAt(
if (enactorPtr->IDParent() != loc.context
|| (loc - enactorPtr->getLocation()).quickHDistance()
> tileUVSize * platformWidth * 4)
- return FALSE;
+ return false;
- return TRUE;
+ return true;
}
bool InventoryProto::dropAction(
@@ -1076,11 +1076,11 @@ bool InventoryProto::dropAction(
// Split the merged object if needed.
if (dObjPtr->isMergeable() // If mergeable
&& num < dObjPtr->getExtra()) { // And not dropping whole pile
- if (num == 0) return FALSE; // If mergeing zero, then do nothing
+ if (num == 0) return false; // If mergeing zero, then do nothing
extractedObj = dObjPtr->extractMerged(dObjPtr->getExtra() - num);
if (extractedObj == NULL)
- return FALSE;
+ return false;
extractedObj->move(
Location(dObjPtr->getLocation(), dObjPtr->IDParent()));
@@ -1092,7 +1092,7 @@ bool InventoryProto::dropAction(
// Make sure the game engine knows that it may scavenge this
// object if necessary
if (!dObjPtr->isImportant())
- dObjPtr->setScavengable(TRUE);
+ dObjPtr->setScavengable(true);
} else {
int16 offsetDist = enactorProto->crossSection + crossSection;
Direction vectorDir = vector.quickDir();
@@ -1118,7 +1118,7 @@ bool InventoryProto::dropAction(
if (startPt == Nowhere) {
if (extractedObj != NULL)
GameObject::mergeWith(extractedObj, dObjPtr, extractedObj->getExtra());
- return FALSE;
+ return false;
}
dObjPtr->move(Location(startPt, loc.context));
@@ -1126,7 +1126,7 @@ bool InventoryProto::dropAction(
// Make sure the game engine knows that it may scavenge this
// object if necessary
if (!dObjPtr->isImportant())
- dObjPtr->setScavengable(TRUE);
+ dObjPtr->setScavengable(true);
MotionTask::throwObjectTo(*dObjPtr, loc);
}
@@ -1136,7 +1136,7 @@ bool InventoryProto::dropAction(
return targetObj->acceptInsertionAt(enactor, dObj, loc, num);
}
- return TRUE;
+ return true;
}
bool InventoryProto::dropOnAction(
@@ -1156,10 +1156,10 @@ bool InventoryProto::dropOnAction(
if (!dObjPtr->isMoving() && target->trigger(enactor, dObj))
dObjPtr->currentTAG = target->thisID();
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
// Virtual function to handle the effects of an object being dropped
@@ -1217,7 +1217,7 @@ bool PhysicalContainerProto::canContain(ObjectID dObj, ObjectID item) {
// inside of "item". Do this by looking at all of the ancestors of
// dObj and make sure that none of them equal "item".
for (pPtr = GameObject::objectAddress(dObj); pPtr; pPtr = pPtr->parent()) {
- if (pPtr == itemPtr) return FALSE;
+ if (pPtr == itemPtr) return false;
}
return dObj != item
@@ -1228,8 +1228,8 @@ bool PhysicalContainerProto::canContainAt(
ObjectID dObj,
ObjectID item,
const TilePoint &where) {
- if (canContain(dObj, item) == FALSE) return FALSE;
- return TRUE;
+ if (canContain(dObj, item) == false) return false;
+ return true;
}
bool PhysicalContainerProto::useAction(ObjectID dObj, ObjectID enactor) {
@@ -1259,11 +1259,11 @@ bool PhysicalContainerProto::openAction(ObjectID dObj, ObjectID) {
assert(!dObjPtr->isOpen() && !dObjPtr->isLocked());
- cn = CreateContainerNode(dObj, FALSE);
+ cn = CreateContainerNode(dObj, false);
cn->markForShow(); // Deferred open
dObjPtr->objectFlags |= objectOpen; // Set open bit;
globalContainerList.setUpdate(dObjPtr->IDParent());
- return TRUE;
+ return true;
}
bool PhysicalContainerProto::closeAction(ObjectID dObj, ObjectID) {
@@ -1279,7 +1279,7 @@ bool PhysicalContainerProto::closeAction(ObjectID dObj, ObjectID) {
// Clear open bit
dObjPtr->objectFlags &= ~objectOpen;
globalContainerList.setUpdate(dObjPtr->IDParent());
- return TRUE;
+ return true;
}
// Determine if this object's lock can be toggled
@@ -1301,7 +1301,7 @@ bool PhysicalContainerProto::acceptLockToggleAction(
// Toggle locked bit
dObjPtr->objectFlags ^= objectLocked;
- return TRUE;
+ return true;
}
// Insert another object into this object
@@ -1318,12 +1318,12 @@ bool PhysicalContainerProto::acceptInsertionAction(
// Place the object in the container (if possible)
if ((dObjPtr->objectFlags & objectLocked)
- || !dObjPtr->placeObject(enactor, item, TRUE, num)) {
+ || !dObjPtr->placeObject(enactor, item, true, num)) {
if (isWorld(dObjPtr->IDParent()))
dObjPtr->dropInventoryObject(itemPtr, num);
else {
if (!itemPtr->dropOn(enactor, dObjPtr->IDParent(), num))
- return FALSE;
+ return false;
}
}
@@ -1334,7 +1334,7 @@ bool PhysicalContainerProto::acceptInsertionAction(
// not be redrawn in this case.
// if (prevItemPtr) globalContainerList.setUpdate( prevItemPtr->IDParent() );
- return TRUE;
+ return true;
}
// Insert another object into this object at the specified slot
@@ -1355,11 +1355,11 @@ bool PhysicalContainerProto::acceptInsertionAtAction(
// Split the merged object if needed.
if (itemPtr->isMergeable() // If mergeable
&& num < itemPtr->getExtra()) { // And not dropping whole pile
- if (num == 0) return FALSE; // If mergeing zero, then do nothing
+ if (num == 0) return false; // If mergeing zero, then do nothing
extractedObj = itemPtr->extractMerged(itemPtr->getExtra() - num);
if (extractedObj == NULL)
- return FALSE;
+ return false;
extractedObj->move(oldLoc);
}
@@ -1368,13 +1368,13 @@ bool PhysicalContainerProto::acceptInsertionAtAction(
if (dObjPtr->canFitBulkwise(itemPtr)
&& dObjPtr->canFitMasswise(itemPtr)) {
itemPtr->move(Location(where, dObj));
- return TRUE;
+ return true;
}
itemPtr->move(oldLoc);
if (extractedObj != NULL)
GameObject::mergeWith(extractedObj, itemPtr, extractedObj->getExtra());
- return FALSE;
+ return false;
}
// ------------------------------------------------------------------------
@@ -1393,7 +1393,7 @@ bool PhysicalContainerProto::canFitBulkwise(GameObject *container, GameObject *o
}
#if DEBUG
- return TRUE;
+ return true;
#endif
}
@@ -1409,11 +1409,11 @@ bool PhysicalContainerProto::canFitMasswise(GameObject *container, GameObject *o
if (!isWorld(container->IDParent()))
return container->parent()->canFitMasswise(obj);
- return TRUE;
+ return true;
}
#if DEBUG
- return TRUE;
+ return true;
#endif
}
@@ -1442,7 +1442,7 @@ uint16 PhysicalContainerProto::bulkCapacity(GameObject *) {
bool KeyProto::setUseCursor(ObjectID dObj) {
assert(mouseInfo.getObjectId() == Nothing);
mouseInfo.copyObject(GameObject::objectAddress(dObj), GrabInfo::Use);
- return TRUE;
+ return true;
}
// Send acceptLockToggle message to container
@@ -1454,10 +1454,10 @@ bool KeyProto::useOnAction(ObjectID dObj, ObjectID enactor, ObjectID withObj) {
if (!container->acceptLockToggle(enactor, lockType)) {
// WriteStatusF( 3, "%s doesn't work", thisKey->objName() );
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
// Send acceptLockToggle message to active terrain
@@ -1468,10 +1468,10 @@ bool KeyProto::useOnAction(ObjectID dObj, ObjectID enactor, ActiveItem *withTAI)
if (!withTAI->acceptLockToggle(enactor, keyID)) {
// WriteStatusF( 3, "%s doesn't work", thisKey->objName() );
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
/* ==================================================================== *
@@ -1485,7 +1485,7 @@ uint16 BottleProto::containmentSet(void) {
bool BottleProto::useAction(ObjectID dObj, ObjectID enactor) {
//Set Up Empty Bottle Sprite
- return TRUE;
+ return true;
}
/* ==================================================================== *
@@ -1497,7 +1497,7 @@ uint16 FoodProto::containmentSet(void) {
}
bool FoodProto::useAction(ObjectID dObj, ObjectID enactor) {
- return TRUE;
+ return true;
}
/* ==================================================================== *
@@ -1526,7 +1526,7 @@ Sprite *WeaponProto::getOrientedSprite(GameObject *obj, int16 offset) {
}
//-----------------------------------------------------------------------
-// Returns TRUE if object in continuous use.
+// Returns true if object in continuous use.
bool WeaponProto::isObjectBeingUsed(GameObject *obj) {
ObjectID wielder = obj->possessor();
@@ -1536,9 +1536,9 @@ bool WeaponProto::isObjectBeingUsed(GameObject *obj) {
if (a->rightHandObject == obj->thisID()
|| a->leftHandObject == obj->thisID())
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
/* ==================================================================== *
@@ -1553,7 +1553,7 @@ bool MeleeWeaponProto::useAction(ObjectID dObj, ObjectID enactor) {
GameObject *dObjPtr = GameObject::objectAddress(dObj);
Actor *a = (Actor *)GameObject::objectAddress(enactor);
- if (enactor != dObjPtr->IDParent()) return FALSE;
+ if (enactor != dObjPtr->IDParent()) return false;
if (dObj == a->rightHandObject)
a->holdInRightHand(Nothing);
@@ -1573,7 +1573,7 @@ bool MeleeWeaponProto::useAction(ObjectID dObj, ObjectID enactor) {
a->holdInRightHand(dObj);
}
- return TRUE;
+ return true;
}
bool MeleeWeaponProto::useOnAction(
@@ -1581,7 +1581,7 @@ bool MeleeWeaponProto::useOnAction(
ObjectID enactor,
ObjectID item) {
if (item == enactor) //If Trying To Hurt Oneself Stop It!!!
- return FALSE;
+ return false;
return strike(dObj, enactor, item);
@@ -1601,12 +1601,12 @@ bool MeleeWeaponProto::strikeAction(
Location ol = Location(a->getWorldLocation(), a->IDParent());
if (itemPtr->acceptStrike(enactor, dObj, getSkillValue(enactor)))
- return TRUE;
+ return true;
soundFXs = &objectSoundFXTable[soundFXClass];
makeCombatSound(soundFXs->soundFXMissed, ol);
- return FALSE;
+ return false;
}
bool MeleeWeaponProto::damageAction(
@@ -1636,7 +1636,7 @@ bool MeleeWeaponProto::damageAction(
GameObject::objectAddress(dObj),
effStats->getSkillLevel(skillIDBrawn));
- return TRUE;
+ return true;
}
bool MeleeWeaponProto::acceptDamageAction(
@@ -1647,7 +1647,7 @@ bool MeleeWeaponProto::acceptDamageAction(
int8,
uint8,
int8) {
- return TRUE;
+ return true;
}
// Determine if this type of weapon must be wielded with two hands
@@ -1701,7 +1701,7 @@ void MeleeWeaponProto::initiateDefense(
// Melee weapons can block an attack
bool MeleeWeaponProto::canBlock(void) {
- return TRUE;
+ return true;
}
// Return a mask of bits indicating the directions relative to the
@@ -1772,11 +1772,11 @@ bool MeleeWeaponProto::useSlotAvailable(GameObject *obj, Actor *a) {
return !isTwoHanded(a->thisID())
&& !leftHandObjectPtr->proto()->isTwoHanded(a->thisID());
}
- return TRUE;
+ return true;
}
assert(isObject(a->rightHandObject));
- return FALSE;
+ return false;
}
/* ==================================================================== *
@@ -1864,7 +1864,7 @@ bool BowProto::useAction(ObjectID dObj, ObjectID enactor) {
GameObject *dObjPtr = GameObject::objectAddress(dObj);
Actor *a = (Actor *)GameObject::objectAddress(enactor);
- if (enactor != dObjPtr->IDParent()) return FALSE;
+ if (enactor != dObjPtr->IDParent()) return false;
// If this object is in the enactor's left hand remove it else
// place it into his left hand
@@ -1875,12 +1875,12 @@ bool BowProto::useAction(ObjectID dObj, ObjectID enactor) {
a->holdInLeftHand(dObj);
}
- return TRUE;
+ return true;
}
// Bows are two handed
bool BowProto::isTwoHanded(ObjectID) {
- return TRUE;
+ return true;
}
// Initiate the bow firing motion
@@ -1982,7 +1982,7 @@ bool WeaponWandProto::useAction(ObjectID dObj, ObjectID enactor) {
GameObject *dObjPtr = GameObject::objectAddress(dObj);
Actor *a = (Actor *)GameObject::objectAddress(enactor);
- if (enactor != dObjPtr->IDParent()) return FALSE;
+ if (enactor != dObjPtr->IDParent()) return false;
// If this object is in the enactor's left hand remove it else
// place it into his left hand
@@ -1993,12 +1993,12 @@ bool WeaponWandProto::useAction(ObjectID dObj, ObjectID enactor) {
a->holdInLeftHand(dObj);
}
- return TRUE;
+ return true;
}
// Wands are two handed
bool WeaponWandProto::isTwoHanded(ObjectID) {
- return TRUE;
+ return true;
}
// Initiate the use wand motion
@@ -2083,10 +2083,10 @@ Sprite *ProjectileProto::getOrientedSprite(GameObject *, int16) {
}
//-----------------------------------------------------------------------
-// Returns TRUE if object in continuous use.
+// Returns true if object in continuous use.
bool ProjectileProto::isObjectBeingUsed(GameObject *) {
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -2102,7 +2102,7 @@ uint8 ProjectileProto::weaponRating(
// Projectiles are missiles
bool ProjectileProto::isMissile(void) {
- return TRUE;
+ return true;
}
/* ==================================================================== *
@@ -2159,7 +2159,7 @@ bool ArrowProto::damageAction(
GameObject::objectAddress(dObj),
effStats->getSkillLevel(skillIDBrawn));
- return TRUE;
+ return true;
}
// ------------------------------------------------------------------------
@@ -2203,7 +2203,7 @@ uint8 ArmorProto::adjustDamage(uint8 damage) {
}
//-----------------------------------------------------------------------
-// Returns TRUE if object in continuous use.
+// Returns true if object in continuous use.
bool ArmorProto::isObjectBeingUsed(GameObject *obj) {
ObjectID aID = obj->possessor();
@@ -2213,10 +2213,10 @@ bool ArmorProto::isObjectBeingUsed(GameObject *obj) {
ObjectID id = obj->thisID();
for (int i = 0; i < ARMOR_COUNT; i++) {
- if (a->armorObjects[i] == id) return TRUE;
+ if (a->armorObjects[i] == id) return true;
}
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -2243,7 +2243,7 @@ bool ArmorProto::useAction(ObjectID dObj, ObjectID enactor) {
assert(obj->proto() == this);
- if (enactor != obj->IDParent()) return FALSE;
+ if (enactor != obj->IDParent()) return false;
int16 slot = whereWearable;
@@ -2254,7 +2254,7 @@ bool ArmorProto::useAction(ObjectID dObj, ObjectID enactor) {
globalContainerList.setUpdate(obj->IDParent());
- return TRUE;
+ return true;
}
/* ==================================================================== *
@@ -2273,7 +2273,7 @@ bool ShieldProto::useAction(ObjectID dObj, ObjectID enactor) {
GameObject *dObjPtr = GameObject::objectAddress(dObj);
Actor *a = (Actor *)GameObject::objectAddress(enactor);
- if (enactor != dObjPtr->IDParent()) return FALSE;
+ if (enactor != dObjPtr->IDParent()) return false;
if (a->rightHandObject != Nothing) {
assert(isObject(a->rightHandObject));
@@ -2281,12 +2281,12 @@ bool ShieldProto::useAction(ObjectID dObj, ObjectID enactor) {
GameObject::objectAddress(a->rightHandObject);
if (rightHandObjectPtr->proto()->isTwoHanded(enactor))
- return FALSE;
+ return false;
}
a->holdInLeftHand(dObj != a->leftHandObject ? dObj : Nothing);
- return TRUE;
+ return true;
}
bool ShieldProto::acceptDamageAction(
@@ -2297,7 +2297,7 @@ bool ShieldProto::acceptDamageAction(
int8,
uint8,
int8) {
- return TRUE;
+ return true;
}
Sprite *ShieldProto::getOrientedSprite(GameObject *obj, int16 offset) {
@@ -2323,7 +2323,7 @@ void ShieldProto::initiateDefense(
// Shields can block an attack
bool ShieldProto::canBlock(void) {
- return TRUE;
+ return true;
}
// Return a mask of bits indicating the directions relative to the
@@ -2333,7 +2333,7 @@ uint8 ShieldProto::defenseDirMask(void) {
}
//-----------------------------------------------------------------------
-// Returns TRUE if object in continuous use.
+// Returns true if object in continuous use.
bool ShieldProto::isObjectBeingUsed(GameObject *obj) {
ObjectID wielder = obj->possessor();
@@ -2343,9 +2343,9 @@ bool ShieldProto::isObjectBeingUsed(GameObject *obj) {
if (a->rightHandObject == obj->thisID()
|| a->leftHandObject == obj->thisID())
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -2366,10 +2366,10 @@ bool ShieldProto::useSlotAvailable(GameObject *obj, Actor *a) {
return !rightHandObjectPtr->proto()->isTwoHanded(a->thisID());
}
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -2421,11 +2421,11 @@ uint8 ShieldProto::getDamageSound(const ObjectSoundFXs &soundFXs) {
bool ToolProto::setUseCursor(ObjectID dObj) {
assert(mouseInfo.getObjectId() == Nothing);
mouseInfo.copyObject(GameObject::objectAddress(dObj), GrabInfo::Use);
- return TRUE;
+ return true;
}
bool ToolProto::useOnAction(ObjectID, ObjectID, ObjectID) {
- return TRUE;
+ return true;
}
/* ==================================================================== *
@@ -2456,7 +2456,7 @@ bool BookProto::useAction(ObjectID dObj, ObjectID enactor) {
break;
}
- return TRUE;
+ return true;
}
/* ==================================================================== *
@@ -2468,7 +2468,7 @@ bool ScrollProto::useAction(ObjectID dObj, ObjectID enactor) {
openScroll(bookObj->getExtra()); // open the modal book with text filled in with
// the previously run script
- return TRUE;
+ return true;
}
/* ==================================================================== *
@@ -2476,7 +2476,7 @@ bool ScrollProto::useAction(ObjectID dObj, ObjectID enactor) {
* ==================================================================== */
bool AutoMapProto::openAction(ObjectID, ObjectID) {
- return FALSE;
+ return false;
}
/* ==================================================================== *
@@ -2495,7 +2495,7 @@ bool IntangibleObjProto::useAction(ObjectID dObj, ObjectID enactor) {
if(obj->isAlias()) //This Tells Whether Its A Copy Or Not
grabTangible(dObj);//Set To Use If Its The Copy
*/
- return FALSE;
+ return false;
}
bool IntangibleObjProto::takeAction(ObjectID dObj, ObjectID enactor, int16) {
@@ -2505,11 +2505,11 @@ bool IntangibleObjProto::takeAction(ObjectID dObj, ObjectID enactor, int16) {
GameObject *dObjPtr = GameObject::objectAddress(dObj);
if (dObjPtr->isTrueSkill())
- return FALSE;
+ return false;
mouseInfo.copyObject(dObj);
- return TRUE;
+ return true;
}
bool IntangibleObjProto::canDropAt(
@@ -2537,13 +2537,13 @@ bool IntangibleObjProto::dropAction(
if ((newObj = dObjPtr->makeAlias(Location(dObjPtr->getLocation(), dObjPtr->IDParent()))) != Nothing) {
if (container->acceptInsertionAt(enactor, newObj, loc))
- return TRUE;
+ return true;
else
GameObject::objectAddress(newObj)->deleteObject();
}
}
- return FALSE;
+ return false;
}
bool IntangibleObjProto::acceptDropAction(
@@ -2564,7 +2564,7 @@ bool IntangibleObjProto::acceptDropAction(
return droppedObjPtr->drop(enactor, loc);
}
- return FALSE;
+ return false;
}
ObjectID IntangibleObjProto::placeObject(void) {
@@ -2589,7 +2589,7 @@ ObjectSpriteInfo IntangibleObjProto::getSprite(
GameObject *obj,
enum spriteTypes spr,
int16) {
- ObjectSpriteInfo sprInfo = { NULL, FALSE };
+ ObjectSpriteInfo sprInfo = { NULL, false };
switch (spr) {
case objOnGround:
@@ -2646,14 +2646,14 @@ bool SkillProto::useAction(ObjectID dObj, ObjectID enactor) {
SpellStuff &sp = spellBook[getSpellID()];
if (nonUsable(this))
- return FALSE;
+ return false;
if (nonTargeted(this)) {
Actor *attackerPtr = (Actor *) GameObject::objectAddress(enactor);
return castUntargetedSpell(attackerPtr, this);
}
mouseInfo.copyObject(dObj, GrabInfo::Use);
- return TRUE;
+ return true;
}
// cast a skill at various things
@@ -2679,7 +2679,7 @@ bool SkillProto::useOnAction(ObjectID dObj, ObjectID enactor, const Location &lo
}
bool SkillProto::canDropAt(ObjectID, ObjectID, const Location &) {
- return TRUE;
+ return true;
}
bool SkillProto::dropAction(ObjectID dObj, ObjectID enactor, const Location &loc, int16 num) {
@@ -2691,7 +2691,7 @@ bool SkillProto::dropAction(ObjectID dObj, ObjectID enactor, const Location &lo
if (validTarget(enactorPtr, NULL, NULL, this))
return useOn(dObj, enactor, loc);
- return FALSE;
+ return false;
}
return IntangibleObjProto::dropAction(dObj, enactor, loc, num);
@@ -3006,11 +3006,11 @@ bool IntangibleContainerProto::openAction(ObjectID dObj, ObjectID enactor) {
GameObject *dObjPtr = GameObject::objectAddress(dObj);
// Perform appropriate opening tasks
- cn = CreateContainerNode(enactor, FALSE);
+ cn = CreateContainerNode(enactor, false);
cn->markForShow();
// dObjPtr->objectFlags |= GameObject::objectOpen; // Set open bit;
- return TRUE;
+ return true;
}
bool IntangibleContainerProto::closeAction(ObjectID dObj, ObjectID) {
@@ -3025,7 +3025,7 @@ bool IntangibleContainerProto::closeAction(ObjectID dObj, ObjectID) {
// Clear open bit
// dObjPtr->objectFlags &= ~GameObject::objectOpen;
- return TRUE;
+ return true;
}
uint16 IntangibleContainerProto::containmentSet(void) {
diff --git a/engines/saga2/objproto.h b/engines/saga2/objproto.h
index d8b99a7b6f..963b7c31b5 100644
--- a/engines/saga2/objproto.h
+++ b/engines/saga2/objproto.h
@@ -106,7 +106,7 @@ public:
void screenPos( Point16 &screenCoords );
int16 screenDepth( void );
- // returns TRUE if it is within the view area of the current
+ // returns true if it is within the view area of the current
// map.
bool visible( void );
*/
@@ -308,7 +308,7 @@ public:
// returns the containment type flags for this object
virtual uint16 containmentSet(void);
- // returns TRUE if this object can contain another object
+ // returns true if this object can contain another object
virtual bool canContain(ObjectID dObj, ObjectID item);
// Determine if this object can contain another object at a specified
@@ -580,10 +580,10 @@ public:
}
virtual bool makeSavingThrow(void) {
- return FALSE;
+ return false;
}
- // Returns TRUE if object in continuous use.
+ // Returns true if object in continuous use.
virtual bool isObjectBeingUsed(GameObject *obj);
// Determine if the specified object's 'use' slot is available within
@@ -852,7 +852,7 @@ public:
virtual Sprite *getOrientedSprite(GameObject *obj, int16 offset);
weaponID getWeaponID(void);
- // Returns TRUE if object in continuous use.
+ // Returns true if object in continuous use.
bool isObjectBeingUsed(GameObject *obj);
// Rate this weapon's goodness for a specified attack situation
@@ -1056,7 +1056,7 @@ public:
// return the address of the sprite when held in hand
virtual Sprite *getOrientedSprite(GameObject *obj, int16 offset);
- // Returns TRUE if object in continuous use.
+ // Returns true if object in continuous use.
bool isObjectBeingUsed(GameObject *obj);
// Projectiles are missiles
@@ -1115,7 +1115,7 @@ public:
// Compute how much damage this defensive object will absorb
virtual uint8 adjustDamage(uint8 damage);
- // Returns TRUE if object in continuous use.
+ // Returns true if object in continuous use.
bool isObjectBeingUsed(GameObject *obj);
// Determine if the specified object's 'use' slot is available within
@@ -1160,7 +1160,7 @@ public:
// wielders facing in which this object can defend
virtual uint8 defenseDirMask(void);
- // Returns TRUE if object in continuous use.
+ // Returns true if object in continuous use.
bool isObjectBeingUsed(GameObject *obj);
// Determine if the specified object's 'use' slot is available within
diff --git a/engines/saga2/oncall.h b/engines/saga2/oncall.h
index 5f003bd9d3..bfd8c5c74d 100644
--- a/engines/saga2/oncall.h
+++ b/engines/saga2/oncall.h
@@ -97,7 +97,7 @@ public:
RESTYPE operator[](uint32 ind) {
// assert (ind<handles);
- if (!locked[ind]) handle[ind] = rLoad(ind, FALSE);
+ if (!locked[ind]) handle[ind] = rLoad(ind, false);
return handle[ind];
}
@@ -124,17 +124,17 @@ template <class RESTYPE> RESTYPE LoadOnCall<RESTYPE>::rLoad(uint16 ind, bool asy
RESTYPE t;
if (isValidPtr(handle[ind]) && locked[ind]) {
RLockHandle((RHANDLE) handle[ind]);
- locked.Bit(ind, TRUE);
- wanted.Bit(ind, FALSE);
- recent.Bit(ind, TRUE);
+ locked.Bit(ind, true);
+ wanted.Bit(ind, false);
+ recent.Bit(ind, true);
return handle[ind];
}
if (isValidPtr(handle[ind]) && wanted[ind]) {
// wait for handle
RLockHandle((RHANDLE) handle[ind]);
- locked.Bit(ind, TRUE);
- wanted.Bit(ind, FALSE);
- recent.Bit(ind, TRUE);
+ locked.Bit(ind, true);
+ wanted.Bit(ind, false);
+ recent.Bit(ind, true);
return NULL;
}
@@ -143,7 +143,7 @@ template <class RESTYPE> RESTYPE LoadOnCall<RESTYPE>::rLoad(uint16 ind, bool asy
locked.Bit(ind, !asynch);
wanted.Bit(ind, asynch);
- recent.Bit(ind, TRUE);
+ recent.Bit(ind, true);
if (asynch) {
handle[ind] = (RESTYPE) NULL;
@@ -159,8 +159,8 @@ template <class RESTYPE> RESTYPE LoadOnCall<RESTYPE>::rLoad(uint16 ind, bool asy
template <class RESTYPE> void LoadOnCall<RESTYPE>::rFree(uint16 ind) {
if (isValidPtr(handle[ind])) {
RUnlockHandle((RHANDLE) handle[ind]);
- locked.Bit(ind, FALSE);
- //recent.Bit(ind,FALSE);
+ locked.Bit(ind, false);
+ //recent.Bit(ind,false);
// washHandle(handle[ind]);
}
}
@@ -168,12 +168,12 @@ template <class RESTYPE> void LoadOnCall<RESTYPE>::rFree(uint16 ind) {
template <class RESTYPE> void LoadOnCall<RESTYPE>::rInit(uint16 ind) {
RESTYPE t;
if (!isValidPtr(handle[ind])) {
- t = (RESTYPE) loader(tileID + MKTAG(0, 0, 0, ind), FALSE);
+ t = (RESTYPE) loader(tileID + MKTAG(0, 0, 0, ind), false);
handle[ind] = t;
- locked.Bit(ind, TRUE);
+ locked.Bit(ind, true);
RUnlockHandle((RHANDLE) handle[ind]);
- locked.Bit(ind, FALSE);
- recent.Bit(ind, FALSE);
+ locked.Bit(ind, false);
+ recent.Bit(ind, false);
}
}
diff --git a/engines/saga2/panel.cpp b/engines/saga2/panel.cpp
index 2436be004c..fff13560c1 100644
--- a/engines/saga2/panel.cpp
+++ b/engines/saga2/panel.cpp
@@ -105,15 +105,15 @@ void gPanel::draw(void) {}
void gPanel::drawClipped(gPort &, const Point16 &, const Rect16 &) {}
void gPanel::pointerMove(gPanelMessage &) {}
bool gPanel::pointerHit(gPanelMessage &) {
- return FALSE;
+ return false;
}
bool gPanel::pointerRHit(gPanelMessage &) {
- return FALSE;
+ return false;
}
void gPanel::pointerDrag(gPanelMessage &) {}
void gPanel::pointerRelease(gPanelMessage &) {}
bool gPanel::keyStroke(gPanelMessage &) {
- return FALSE;
+ return false;
}
void gPanel::timerTick(gPanelMessage &) {}
void gPanel::onMouseHintDelay(void) {}
@@ -149,7 +149,7 @@ void gPanel::notify(enum gEventType type, int32 value) {
}
bool gPanel::activate(gEventType) {
- return FALSE;
+ return false;
}
void gPanel::deactivate(void) {
@@ -370,7 +370,7 @@ gWindow::gWindow(const Rect16 &box, uint16 ident, const char saveName[], AppFunc
: gPanelList(*this, box, NULL, ident, cmd)
//, saver(WIIFF_POS|WIIFS_NORMAL|WIIFE_ONEXIT,iniFile,saveName,box,this)
{
- openFlag = FALSE;
+ openFlag = false;
// pointerImage = &arrowPtr;
// pointerOffset = Point16( 0, 0 );
@@ -410,7 +410,7 @@ gWindow::~gWindow() {
}
bool gWindow::open(void) {
- if (isOpen()) return TRUE;
+ if (isOpen()) return true;
// Send a "pointer-leave" message to mouse panel.
@@ -424,10 +424,10 @@ bool gWindow::open(void) {
// pointer.setImage( *pointerImage, pointerOffset.x, pointerOffset.y );
// pointer.show();
- openFlag = TRUE;
+ openFlag = true;
draw();
- return TRUE;
+ return true;
}
void gWindow::close(void) {
@@ -442,7 +442,7 @@ void gWindow::close(void) {
// but just in case).
if (DragBar::dragWindow == (FloatingWindow *)this) return;
- openFlag = FALSE;
+ openFlag = false;
// remove this window from the window list.
@@ -487,7 +487,7 @@ void gWindow::toFront(void) { // re-order the windows
}
bool gWindow::isModal(void) {
- return FALSE;
+ return false;
}
void gWindow::setPos(Point16 pos) {
@@ -539,9 +539,9 @@ bool gWindow::activate(gEventType why) {
if (why == gEventMouseDown) { // momentarily depress
selected = 1;
notify(why, 0); // notify App of successful hit
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
void gWindow::pointerMove(gPanelMessage &) {
@@ -550,7 +550,7 @@ void gWindow::pointerMove(gPanelMessage &) {
bool gWindow::pointerHit(gPanelMessage &) {
activate(gEventMouseDown);
- return TRUE;
+ return true;
}
void gWindow::pointerDrag(gPanelMessage &) {
@@ -674,12 +674,12 @@ void gControl::draw(void) {
gGenericControl::gGenericControl(gPanelList &list, const Rect16 &box,
uint16 ident, AppFunc *cmd)
: gControl(list, box, NULL, ident, cmd) {
- dblClickFlag = FALSE;
+ dblClickFlag = false;
}
bool gGenericControl::activate(gEventType) {
selected = 1;
- return TRUE;
+ return true;
}
void gGenericControl::deactivate(void) {
@@ -695,14 +695,14 @@ bool gGenericControl::pointerHit(gPanelMessage &msg) {
if (msg.rightButton)
notify(gEventRMouseDown, 0);
else if (msg.doubleClick && !dblClickFlag) {
- dblClickFlag = TRUE;
+ dblClickFlag = true;
notify(gEventDoubleClick, 0);
} else {
- dblClickFlag = FALSE;
+ dblClickFlag = false;
notify(gEventMouseDown, 0);
}
- return TRUE;
+ return true;
}
void gGenericControl::pointerDrag(gPanelMessage &) {
@@ -813,7 +813,7 @@ void gToolBase::handleMouse(Common::Event &event, uint32 time) {
// is occuring outside the panel, then it should be
// deselected.
- if (activePanel->extent.ptInside(pickPos) == FALSE)
+ if (activePanel->extent.ptInside(pickPos) == false)
activePanel->deactivate();
}
@@ -959,18 +959,18 @@ void gToolBase::handleMouse(Common::Event &event, uint32 time) {
if (mousePanel->pointerHit(msg)) {
activePanel = mousePanel;
if (_curMouseState.left)
- leftDrag = TRUE;
+ leftDrag = true;
else
- rightDrag = TRUE;
+ rightDrag = true;
}
}
- } else if ((leftDrag && _curMouseState.left == FALSE) // check for release
- || (rightDrag && _curMouseState.right == FALSE)) {
+ } else if ((leftDrag && _curMouseState.left == false) // check for release
+ || (rightDrag && _curMouseState.right == false)) {
if (activePanel && mousePanel) { // if a control is active
setMsg(msg, mousePanel); // send it a release message
mousePanel->pointerRelease(msg);
}
- leftDrag = rightDrag = FALSE;
+ leftDrag = rightDrag = false;
}
}
@@ -1106,10 +1106,10 @@ int16 rightButtonState(void) {
}
void LockUI(bool state) {
- if (state == TRUE) {
+ if (state == true) {
if (lockUINest <= 0) {
pointer.hide();
- enableUIKeys(FALSE);
+ enableUIKeys(false);
G_BASE.setActive(NULL);
}
lockUINest++;
@@ -1117,7 +1117,7 @@ void LockUI(bool state) {
lockUINest--;
assert(lockUINest >= 0);
if (lockUINest <= 0) {
- enableUIKeys(TRUE);
+ enableUIKeys(true);
pointer.show();
}
}
diff --git a/engines/saga2/panel.h b/engines/saga2/panel.h
index f777a35a9e..9967c132d2 100644
--- a/engines/saga2/panel.h
+++ b/engines/saga2/panel.h
@@ -71,7 +71,7 @@ class gWindow;
void HandleMouse(gMouseState &mouse);
void HandleKeyStroke(int key, int qual);
void HandleTimerTick(long newTick);
-void EventLoop(bool &running, bool modal = FALSE);
+void EventLoop(bool &running, bool modal = false);
/* ===================================================================== *
Constants
@@ -172,7 +172,7 @@ protected:
public:
- bool isActive(void); // TRUE if we are active panel
+ bool isActive(void); // true if we are active panel
virtual bool activate(gEventType why); // activate the control
virtual void deactivate(void); // deactivate the control
virtual void draw(void); // redraw the panel.
@@ -208,7 +208,7 @@ public:
bool getEnabled(void) const {
return (bool) enabled;
}
- void show(bool shown = TRUE, bool inval = TRUE) {
+ void show(bool shown = true, bool inval = true) {
enable(shown);
if (inval) invalidate();
}
@@ -324,7 +324,7 @@ public:
}
protected:
- bool openFlag; // TRUE if window open.
+ bool openFlag; // true if window open.
//gWindowWinInfoInINIFile saver;
@@ -425,7 +425,7 @@ public:
// Disable double click for next mouse click
void disableDblClick(void) {
- dblClickFlag = TRUE;
+ dblClickFlag = true;
}
enum controlValue {
diff --git a/engines/saga2/player.cpp b/engines/saga2/player.cpp
index 8f4f706562..74baa76a55 100644
--- a/engines/saga2/player.cpp
+++ b/engines/saga2/player.cpp
@@ -276,7 +276,7 @@ void PlayerActor::skillAdvance(SkillProto *proto,
uint8 points,
uint8 useMult) { // useMult defaulted to 1
// get the skill level for the skill passed ( i.e. 1-100 )
- uint8 skillLevel = getSkillLevel(proto, TRUE); // true, use base stats
+ uint8 skillLevel = getSkillLevel(proto, true); // true, use base stats
// get the stat index in question
uint8 stat = getStatIndex(proto);
@@ -369,7 +369,7 @@ void PlayerActor::vitalityAdvance(uint8 points) {
// this function will return a value of 0 - 4 to indicate
// relative proficiency in requested skill
-int8 PlayerActor::getSkillLevel(SkillProto *skill, bool base) { // basestats defaulted to FALSE
+int8 PlayerActor::getSkillLevel(SkillProto *skill, bool base) { // basestats defaulted to false
// get the id for this skill
SpellID skillID = skill->getSpellID();
@@ -502,7 +502,7 @@ ActorAttributes *PlayerActor::getEffStats(void) {
void PlayerActor::handleAttacked(void) {
if (!notifiedOfAttack) {
StatusMsg(ATTACK_STATUS, getActor()->objName());
- notifiedOfAttack = TRUE;
+ notifiedOfAttack = true;
}
}
@@ -563,7 +563,7 @@ void setCenterActor(PlayerActorID newCenter) {
if (a->isDead()) return;
// Take previous center actor out of fight stance
- getCenterActor()->setFightStance(FALSE);
+ getCenterActor()->setFightStance(false);
// get rid of any following assignments the center actor might have
if (a->leader) {
@@ -663,7 +663,7 @@ void autoAdjustAggression(void) {
// Iterate through all player actors
for (i = 0; i < playerActors; i++) {
if (i == centerActor || isBanded(i)) {
- bool enemiesPresent = FALSE;
+ bool enemiesPresent = false;
Actor *actor = playerList[i].getActor();
if (actor->getStats()->vitality >= minAutoAggressionVitality) {
@@ -685,7 +685,7 @@ void autoAdjustAggression(void) {
a = (Actor *)obj;
if (a->disposition == dispositionEnemy) {
- enemiesPresent = TRUE;
+ enemiesPresent = true;
break;
}
}
@@ -769,23 +769,23 @@ int16 getPortraitType(PlayerActorID id) {
bool actorToPlayerID(Actor *a, PlayerActorID &result) {
if (a->disposition >= dispositionPlayer) {
result = a->disposition - dispositionPlayer;
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
bool actorIDToPlayerID(ObjectID id, PlayerActorID &result) {
- if (!isActor(id)) return FALSE;
+ if (!isActor(id)) return false;
Actor *a = (Actor *)GameObject::objectAddress(id);
if (a->disposition >= dispositionPlayer) {
result = a->disposition - dispositionPlayer;
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
void handlePlayerActorDeath(PlayerActorID id) {
@@ -798,15 +798,15 @@ void handlePlayerActorDeath(PlayerActorID id) {
if ((newCenter = iter.first()) != NULL)
setCenterActor(getPlayerActorID(newCenter));
else
- allPlayerActorsDead = TRUE;
+ allPlayerActorsDead = true;
}
PlayerActor *player = &playerList[id];
player->clearAggression();
player->clearBanded();
- updateBrotherAggressionButton(id, FALSE);
- updateBrotherBandingButton(id, FALSE);
+ updateBrotherAggressionButton(id, false);
+ updateBrotherBandingButton(id, false);
StatusMsg(DEATH_STATUS, player->getActor()->objName());
}
@@ -849,7 +849,7 @@ void transportCenterBand(const Location &loc) {
loc,
1,
3,
- FALSE);
+ false);
if (dest != Nowhere) {
a->move(Location(dest, loc.context));
@@ -929,14 +929,14 @@ void initPlayerActors(void) {
p->vitalityMemory = 0;
// Clear the attack notification flag
- p->notifiedOfAttack = FALSE;
+ p->notifiedOfAttack = false;
// Set the actor's disposition field to reflect that that
// actor is a player actor
a->disposition = dispositionPlayer + i;
// Turn on banding for player actors
- setBanded(i, TRUE);
+ setBanded(i, true);
}
readyContainerSetup();
diff --git a/engines/saga2/player.h b/engines/saga2/player.h
index 54abe64ace..162198b3c2 100644
--- a/engines/saga2/player.h
+++ b/engines/saga2/player.h
@@ -122,7 +122,7 @@ public:
}
// gets level of skill
- int8 getSkillLevel(SkillProto *, bool base = FALSE);
+ int8 getSkillLevel(SkillProto *, bool base = false);
// get the actorAttributes allskills index from proto
uint8 getStatIndex(SkillProto *);
@@ -215,7 +215,7 @@ public:
// Simply reset the attack notification flag
void resetAttackNotification(void) {
- notifiedOfAttack = FALSE;
+ notifiedOfAttack = false;
}
};
diff --git a/engines/saga2/priqueue.h b/engines/saga2/priqueue.h
index 178fd50449..59e3e43610 100644
--- a/engines/saga2/priqueue.h
+++ b/engines/saga2/priqueue.h
@@ -69,7 +69,7 @@ bool PriorityQueue<ITEM, size>::insert(ITEM &newItem) {
ITEM *qi,
*parentItem;
- if (tail >= size + 1) return FALSE;
+ if (tail >= size + 1) return false;
for (index = tail, qi = &queue[index];
index > 1;
@@ -83,7 +83,7 @@ bool PriorityQueue<ITEM, size>::insert(ITEM &newItem) {
*qi = newItem;
tail++;
- return TRUE;
+ return true;
}
// Function to remove the lowest element from the queue
@@ -96,7 +96,7 @@ bool PriorityQueue<ITEM, size>::remove(ITEM &result) {
childNum,
tailVal;
- if (tail <= 1) return FALSE;
+ if (tail <= 1) return false;
result = *item;
tail--;
@@ -124,7 +124,7 @@ bool PriorityQueue<ITEM, size>::remove(ITEM &result) {
if (itemNum != tail) {
*item = queue[tail];
}
- return TRUE;
+ return true;
}
} // end of namepsace Saga2
diff --git a/engines/saga2/property.cpp b/engines/saga2/property.cpp
index 3eacbdbd86..f95ddb2cf0 100644
--- a/engines/saga2/property.cpp
+++ b/engines/saga2/property.cpp
@@ -142,7 +142,7 @@ const ActorProperty *actorPropArray[actorPropIDCount] = {
// Determine if this tile has water
static bool tileHasWater(TileInfo *ti) {
- return ti->combinedTerrainMask() & terrainWater ? TRUE : FALSE;
+ return ti->combinedTerrainMask() & terrainWater ? true : false;
}
const SimpleTileProperty tilePropHasWater(tileHasWater);
@@ -203,11 +203,11 @@ bool MetaTilePropertyAnd::operator()(
uint16 i;
// Iterate through each element in the array and if any evaluate to
- // FALSE, return FALSE immediately.
+ // false, return false immediately.
for (i = 0; i < arraySize; i++)
- if ((*propertyArray[i])(mt, mapNum, tp) == FALSE) return FALSE;
+ if ((*propertyArray[i])(mt, mapNum, tp) == false) return false;
- return TRUE;
+ return true;
}
/* ===================================================================== *
@@ -221,11 +221,11 @@ bool MetaTilePropertyOr::operator()(
uint16 i;
// Iterate through each element in the array and if any evaluate to
- // TRUE, return TRUE immediately.
+ // true, return true immediately.
for (i = 0; i < arraySize; i++)
- if ((*propertyArray[i])(mt, mapNum, tp)) return TRUE;
+ if ((*propertyArray[i])(mt, mapNum, tp)) return true;
- return FALSE;
+ return false;
}
@@ -255,13 +255,13 @@ static bool metaTileHasWater(
height,
trFlags);
if (ti->combinedTerrainMask() & terrainWater)
- return TRUE;
+ return true;
}
}
}
}
- return FALSE;
+ return false;
}
const SimpleMetaTileProperty metaTilePropHasWater(metaTileHasWater);
diff --git a/engines/saga2/property.h b/engines/saga2/property.h
index 356de3735d..7c8e2ba8b8 100644
--- a/engines/saga2/property.h
+++ b/engines/saga2/property.h
@@ -35,8 +35,8 @@ namespace Saga2 {
// This is an abstract property function object class. A property function
// object can be used to determine if an object of type T has a certain
// property. In order to do this, a pointer to an object of type T is
-// passed to the operator () member function, which returns TRUE if the
-// object has the property and FALSE if it does not.
+// passed to the operator () member function, which returns true if the
+// object has the property and false if it does not.
// These function objects can be used to process only subset of object of
// type T which meet certain criteria, without having to know what those
@@ -135,8 +135,8 @@ CompoundProperty< T >::~CompoundProperty(void) {
* ===================================================================== */
// This class defines an 'and' compound property. Each of the sub
-// properties in the compound property list must evaluate to TRUE for this
-// function object to evaluate to TRUE.
+// properties in the compound property list must evaluate to true for this
+// function object to evaluate to true.
template < class T >
class PropertyAnd : public CompoundProperty< T > {
@@ -155,13 +155,13 @@ bool PropertyAnd< T >::operator()(T *obj) const {
uint16 i;
// Iterate through each element in the array and if any evaluate to
- // FALSE, return FALSE immediately.
+ // false, return false immediately.
for (i = 0; i < arraySize; i++)
- if ((*propertyArray[i])(obj) == FALSE) return FALSE;
+ if ((*propertyArray[i])(obj) == false) return false;
#endif
warning("STUB: PropertyAnd");
- return TRUE;
+ return true;
}
/* ===================================================================== *
@@ -169,8 +169,8 @@ bool PropertyAnd< T >::operator()(T *obj) const {
* ===================================================================== */
// This class defines an 'or' compound property. If any of the sub
-// properties in the compound property list evaluate to TRUE this function
-// object will evaluate to TRUE.
+// properties in the compound property list evaluate to true this function
+// object will evaluate to true.
template < class T >
class PropertyOr : public CompoundProperty< T > {
@@ -189,13 +189,13 @@ bool PropertyOr< T >::operator()(T *obj) const {
uint16 i;
// Iterate through each element in the array and if any evaluate to
- // TRUE, return TRUE immediately.
+ // true, return true immediately.
for (i = 0; i < arraySize; i++)
- if ((*propertyArray[i])(obj)) return TRUE;
+ if ((*propertyArray[i])(obj)) return true;
#endif
warning("STUB: PropertyOr");
- return FALSE;
+ return false;
}
/* ===================================================================== *
diff --git a/engines/saga2/queues.h b/engines/saga2/queues.h
index 81205da57b..645051f284 100644
--- a/engines/saga2/queues.h
+++ b/engines/saga2/queues.h
@@ -120,13 +120,13 @@ public:
bool insert(const BASETYPE b) {
SimpleQueueElement *newElt = new SimpleQueueElement(b);
- if (newElt == NULL) return FALSE;
+ if (newElt == NULL) return false;
if (tail)
tail->next = newElt;
else
head = newElt;
tail = newElt;
- return TRUE;
+ return true;
}
};
@@ -196,13 +196,13 @@ public:
bool insert(const BASETYPE b) {
PublicQueueElement *newElt = new PublicQueueElement(b);
- if (newElt == NULL) return FALSE;
+ if (newElt == NULL) return false;
if (tail)
tail->next = newElt;
else
head = newElt;
tail = newElt;
- return TRUE;
+ return true;
}
};
@@ -279,13 +279,13 @@ public:
bool insert(BASETYPE *b) {
SimplePtrQueueElement *newElt = new SimplePtrQueueElement(b);
- if (newElt == NULL) return FALSE;
+ if (newElt == NULL) return false;
if (tail)
tail->next = newElt;
else
head = newElt;
tail = newElt;
- return TRUE;
+ return true;
}
};
@@ -358,13 +358,13 @@ public:
bool insert(BASETYPE *b) {
PublicPtrQueueElement *newElt = new PublicPtrQueueElement(b);
- if (newElt == NULL) return FALSE;
+ if (newElt == NULL) return false;
if (tail)
tail->next = newElt;
else
head = newElt;
tail = newElt;
- return TRUE;
+ return true;
}
};
diff --git a/engines/saga2/rect.h b/engines/saga2/rect.h
index 7f1a302575..381d4fdc06 100644
--- a/engines/saga2/rect.h
+++ b/engines/saga2/rect.h
@@ -347,7 +347,7 @@ public:
return width <= 0 || height <= 0;
}
- bool ptInside(int16 px, int16 py) const { // TRUE if point inside
+ bool ptInside(int16 px, int16 py) const { // true if point inside
return px >= x && px < (x + width) && py >= y && py < (y + height);
}
bool ptInside(const Point16 p) const {
@@ -508,7 +508,7 @@ public:
return width <= 0 || height <= 0;
}
- bool ptInside(int32 px, int32 py) const { // TRUE if point inside
+ bool ptInside(int32 px, int32 py) const { // true if point inside
return px >= x && px < (x + width) && py >= y && py < (y + height);
}
bool ptInside(const Point16 p) const {
diff --git a/engines/saga2/rmem.cpp b/engines/saga2/rmem.cpp
index 21ce64caec..5db8a9a740 100644
--- a/engines/saga2/rmem.cpp
+++ b/engines/saga2/rmem.cpp
@@ -75,8 +75,8 @@ void setWalls(uint8 *begin, uint32 length);
#else
# define WARN_LEAKS 0
-# define WIPE_ALLOC FALSE
-# define WIPE_FREE FALSE
+# define WIPE_ALLOC false
+# define WIPE_FREE false
# define wallSize 0 // compile wall size as zero
# define mungEnable 0 // disable munging
@@ -156,7 +156,7 @@ static void *rmemAlloc(size_t s, const char desc[]) {
//quick dealloc
-static bool complicatedFree = TRUE;
+static bool complicatedFree = true;
static void rmemFree(void *mem) {
if (whichHeap(mem) != NULL) {
@@ -168,7 +168,7 @@ static void rmemFree(void *mem) {
void RMemFastCleanup(void) {
#if !DEBUG
- complicatedFree = FALSE;
+ complicatedFree = false;
#endif
}
@@ -765,9 +765,9 @@ static bool PurgeBlocks(RHeapPtr heap, uint32 needed) {
rh->data = NULL; // NULL the handle.
RDelinkHandle(rh); // delink from chain.
- if (freedUp > needed) return TRUE;
+ if (freedUp > needed) return true;
}
- return FALSE;
+ return false;
}
// This function attempts to get free up enough space for a new
@@ -823,7 +823,7 @@ static void GetSpace(RHeapPtr heap, uint32 needed) {
static void *NewPtr(int32 size, RHeapPtr heap, bool high, const char desc[]) {
uint8 *mem;
- bool triedCompact = FALSE;
+ bool triedCompact = false;
int tries;
if (heap == NULL) heap = heapList;
@@ -838,25 +838,25 @@ static void *NewPtr(int32 size, RHeapPtr heap, bool high, const char desc[]) {
if (triedCompact) return NULL;
GetSpace(heap, size);
- triedCompact = TRUE;
+ triedCompact = true;
}
return NULL;
}
void *_RNewPtr(int32 size, RHeapPtr heap, const char desc[]) {
#if RMEM_VISIBLE
- void *ptr = NewPtr(size, heap, TRUE, desc);
+ void *ptr = NewPtr(size, heap, true, desc);
SHOWMEM;
return ptr;
#else
- return NewPtr(size, heap, TRUE, desc);
+ return NewPtr(size, heap, true, desc);
#endif
}
void *_RNewClearPtr(int32 size, RHeapPtr heap, const char desc[]) {
uint8 *mem;
- if ((mem = (uint8 *) NewPtr(size, heap, TRUE, desc)) != NULL)
+ if ((mem = (uint8 *) NewPtr(size, heap, true, desc)) != NULL)
memset(mem, 0, size);
SHOWMEM;
@@ -932,7 +932,7 @@ static RHandleBlock *NewHandleBlock(RHeapPtr heap, const char desc[]) {
RHandleBlock *hBlock, *prevBlock;
int i;
// allocate space for handle block
- if ((hBlock = (RHandleBlock *) NewPtr(sizeof * hBlock, heap, TRUE, desc)) != NULL) {
+ if ((hBlock = (RHandleBlock *) NewPtr(sizeof * hBlock, heap, true, desc)) != NULL) {
SHOWMEM;
memset(hBlock, 0, sizeof * hBlock);
@@ -1054,7 +1054,7 @@ RHANDLE _RNewHandle(int32 size, RHeapPtr heap, const char desc[]) {
if (heap == NULL) heap = heapList;
if ((handle = FindFreeHandle(heap)) != NULL) {
- if ((mem = NewPtr(size, heap, FALSE, desc)) != NULL) {
+ if ((mem = NewPtr(size, heap, false, desc)) != NULL) {
pr = PrefixBaseAddr(mem); // get memory prefix
pr->handle = handle; // point prefix back to handle
handle->data = mem; // point handle to prefix
@@ -1135,7 +1135,7 @@ void *_RAllocHandleData(RHANDLE handle, int32 size, const char desc[]) {
if (hb->data != NULL) RDisposeHandleData(handle);
- if ((mem = NewPtr(size, heap, FALSE, desc)) != NULL) {
+ if ((mem = NewPtr(size, heap, false, desc)) != NULL) {
pr = PrefixBaseAddr(mem); // get memory prefix
pr->handle = hb; // point prefix back to handle
hb->data = mem; // point handle to prefix
@@ -1284,7 +1284,7 @@ bool _RHandleLoaded(RHANDLE handle) {
RMemPrefix *pr;
RHandle *hb = HandleBaseAddr(handle);
- if (handle == NULL || hb->data == NULL) return FALSE;
+ if (handle == NULL || hb->data == NULL) return false;
pr = PrefixBaseAddr(hb->data);
return (pr->flags & rMemLoading) ? 0 : 1;
}
@@ -1293,7 +1293,7 @@ bool _RHandleLoading(RHANDLE handle) {
RMemPrefix *pr;
RHandle *hb = HandleBaseAddr(handle);
- if (handle == NULL || hb->data == NULL) return FALSE;
+ if (handle == NULL || hb->data == NULL) return false;
pr = PrefixBaseAddr(hb->data);
return (pr->flags & rMemLoading) ? 1 : 0;
}
@@ -1406,7 +1406,7 @@ bool _RMemIntegrity(void) {
""
#endif
);
- return FALSE;
+ return false;
}
// Check memory wall integrity
@@ -1421,7 +1421,7 @@ bool _RMemIntegrity(void) {
blk = blk->next;
}
}
- return TRUE;
+ return true;
}
@@ -1466,7 +1466,7 @@ static bool _RMemCleanHeap(RHeapPtr heap) {
else if (leakWarnings == maxLeakWarnings)
memoryWarning("Warning: too many memory leak warnings. Remaining warnings ignored\n");
else
- return TRUE;
+ return true;
}
// Go to the next block
@@ -1478,7 +1478,7 @@ static bool _RMemCleanHeap(RHeapPtr heap) {
last_free = (uint8 *)blk + blk->size;
}
- return TRUE;
+ return true;
}
#endif
diff --git a/engines/saga2/rmem.h b/engines/saga2/rmem.h
index 6d1db34ce2..359c0fb327 100644
--- a/engines/saga2/rmem.h
+++ b/engines/saga2/rmem.h
@@ -138,10 +138,10 @@ void _RCacheHandle(RHANDLE handle);
void _RHandleStartLoading(RHANDLE handle);
void _RHandleDoneLoading(RHANDLE handle);
-// Return TRUE if loaded data is valid
+// Return true if loaded data is valid
bool _RHandleLoaded(RHANDLE handle);
-// Return TRUE if loaded data will be valid soon.
+// Return true if loaded data will be valid soon.
bool _RHandleLoading(RHANDLE handle);
void RShowMem(void);
diff --git a/engines/saga2/rserver.cpp b/engines/saga2/rserver.cpp
index e2b465a3ee..ea57a44711 100644
--- a/engines/saga2/rserver.cpp
+++ b/engines/saga2/rserver.cpp
@@ -54,7 +54,7 @@ public:
RHANDLE handle; // where to put the data
uint32 offset, // offset in file of data
length; // desired length of data
- bool done; // TRUE if load is finished
+ bool done; // true if load is finished
void *userData; // for app use
// Function to notify when request is done.
@@ -115,7 +115,7 @@ void ResourceServer::service(void) {
WriteStatusF(1, "Loaded: %8.8d", actual);
#endif
} else {
- currentRequest->done = TRUE;
+ currentRequest->done = true;
resourceRequestPool.addTail(*currentRequest);
currentRequest = NULL;
@@ -158,7 +158,7 @@ void RequestResource(
RHandleStartLoading(handle);
- rr->done = FALSE;
+ rr->done = false;
rr->handle = handle;
rr->offset = offset;
rr->length = length;
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index 6fbe80dfe1..ae9904a6a0 100644
--- a/engines/saga2/sagafunc.cpp
+++ b/engines/saga2/sagafunc.cpp
@@ -837,10 +837,10 @@ int16 scriptGameObjectCanSenseProtaganist(int16 *args) {
scf.enactor = obj->thisID();
scf.directObject = info.sensedObject->thisID();
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -864,10 +864,10 @@ int16 scriptGameObjectCanSenseSpecificActor(int16 *args) {
scf.enactor = obj->thisID();
scf.directObject = info.sensedObject->thisID();
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -888,10 +888,10 @@ int16 scriptGameObjectCanSenseSpecificObject(int16 *args) {
scf.enactor = obj->thisID();
scf.directObject = info.sensedObject->thisID();
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -910,10 +910,10 @@ int16 scriptGameObjectCanSenseActorProperty(int16 *args) {
scf.enactor = obj->thisID();
scf.directObject = info.sensedObject->thisID();
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -932,10 +932,10 @@ int16 scriptGameObjectCanSenseObjectProperty(int16 *args) {
scf.enactor = obj->thisID();
scf.directObject = info.sensedObject->thisID();
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -992,8 +992,8 @@ int16 scriptGameObjectSetMass(int16 *args) {
if (obj->proto()->flags & ResourceObjectPrototype::objPropMergeable) {
globalContainerList.setUpdate(obj->IDParent());
}
- return TRUE;
- } else return FALSE;
+ return true;
+ } else return false;
}
//-----------------------------------------------------------------------
@@ -1517,7 +1517,7 @@ int16 scriptActorAnimationFrames(int16 *args) {
//-----------------------------------------------------------------------
// Update the current animation sequence to the next frame.
-// Returns TRUE if there are more animation frames in the current
+// Returns true if there are more animation frames in the current
// sequence.
// int "c" nextAnimationFrame( void );
@@ -1683,10 +1683,10 @@ int16 scriptActorAssignPatrolRoute(int16 *args) {
? args[3]
: -1)
!= NULL)
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -1714,10 +1714,10 @@ int16 scriptActorAssignPartialPatrolRoute(int16 *args) {
args[3],
args[4])
!= NULL)
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -1744,10 +1744,10 @@ int16 scriptActorAssignBeNearLocation(int16 *args) {
targetLoc,
args[4])
!= NULL)
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -1778,10 +1778,10 @@ int16 scriptActorAssignBeNearActor(int16 *args) {
args[2],
args[3])
!= NULL)
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -1806,10 +1806,10 @@ int16 scriptActorAssignKillActor(int16 *args) {
targetActor,
args[2])
!= NULL)
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -1855,10 +1855,10 @@ int16 scriptActorAssignTetheredWander(int16 *args) {
* CalenderTime::framesPerHour,
tetherReg)
!= NULL)
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -1879,10 +1879,10 @@ int16 scriptActorAssignAttend(int16 *args) {
% CalenderTime::framesPerDay,
GameObject::objectAddress(args[1]))
!= NULL)
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -2087,8 +2087,8 @@ int16 scriptActorDeductPayment(int16 *args) {
}
}
- // If he doesn't have enough, return FALSE.
- if (paymentFound < paymentAmount) return FALSE;
+ // If he doesn't have enough, return false.
+ if (paymentFound < paymentAmount) return false;
// Now, deduct the actual currency
for (id = iter.first(&obj); id != Nothing; id = iter.next(&obj)) {
@@ -2133,7 +2133,7 @@ int16 scriptActorDeductPayment(int16 *args) {
}
// Payment succeeded!
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -2462,7 +2462,7 @@ int16 scriptTagIsLocked(int16 *) {
MONOLOG(TAG::IsLocked);
ActiveItem *ai = (ActiveItem *)thisThread->thisObject;
- return ai->isLocked() ? TRUE : FALSE;
+ return ai->isLocked() ? true : false;
}
//-----------------------------------------------------------------------
@@ -2573,8 +2573,8 @@ static int16 lockCount;
int16 scriptTagObtainLock(int16 *) {
ActiveItem *ai = (ActiveItem *)thisThread->thisObject;
- if (ai->isExclusive() == FALSE) {
- ai->setExclusive(TRUE);
+ if (ai->isExclusive() == false) {
+ ai->setExclusive(true);
#if DEBUG*0
lockCount += 1;
WriteStatusF(15, "Locked: %d\n", lockCount);
@@ -2592,7 +2592,7 @@ int16 scriptTagObtainLock(int16 *) {
int16 scriptTagReleaseLock(int16 *) {
ActiveItem *ai = (ActiveItem *)thisThread->thisObject;
- ai->setExclusive(FALSE);
+ ai->setExclusive(false);
#if DEBUG*0
lockCount -= 1;
WriteStatusF(15, "Locked: %d\n", lockCount);
@@ -2895,7 +2895,7 @@ int16 scriptSetGameMode(int16 *args) {
// Mode zero is "game not running".
if (args[0] == 0)
endGame();
- //gameRunning = FALSE;
+ //gameRunning = false;
// REM: Add other modes
@@ -3420,7 +3420,7 @@ int16 scriptSelectNearbySite(int16 *args) {
scriptCallFrame &scf = thisThread->threadArgs;
scf.coords = tp;
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -3706,8 +3706,8 @@ extern bool tileLockFlag;
int16 scriptLockTiles(int16 *args) {
MONOLOG(LockTiles);
- if (args[0] == FALSE) tileLockFlag = FALSE;
- else tileLockFlag = TRUE;
+ if (args[0] == false) tileLockFlag = false;
+ else tileLockFlag = true;
return 0;
}
diff --git a/engines/saga2/savefile.cpp b/engines/saga2/savefile.cpp
index 01731835b2..bcdc62817c 100644
--- a/engines/saga2/savefile.cpp
+++ b/engines/saga2/savefile.cpp
@@ -90,7 +90,7 @@ SaveFileConstructor::~SaveFileConstructor(void) {
bool SaveFileConstructor::newChunk(ChunkID id, int32 size) {
// Determine if file position is at end of previous chunk
- if (posInChunk < chunkSize) return FALSE;
+ if (posInChunk < chunkSize) return false;
assert(posInChunk == chunkSize);
@@ -108,7 +108,7 @@ bool SaveFileConstructor::newChunk(ChunkID id, int32 size) {
chunkSize = size;
posInChunk = 0;
- return TRUE;
+ return true;
}
//----------------------------------------------------------------------
@@ -135,7 +135,7 @@ int32 SaveFileConstructor::write(void *buf, int32 size) {
bool SaveFileConstructor::writeChunk(ChunkID id, void *buf, int32 size) {
// Determine if file position is at end of previous chunk
- if (posInChunk < chunkSize) return FALSE;
+ if (posInChunk < chunkSize) return false;
assert(posInChunk == chunkSize);
@@ -158,7 +158,7 @@ bool SaveFileConstructor::writeChunk(ChunkID id, void *buf, int32 size) {
chunkSize = posInChunk = size;
// Return success
- return TRUE;
+ return true;
}
/* ===================================================================== *
@@ -206,7 +206,7 @@ bool SaveFileReader::firstChunk(ChunkID &chunk, int32 &size) {
// Read the chunk header
if (fread(&chunkHeader, sizeof(chunkHeader), 1, fileHandle) != 1)
- return FALSE;
+ return false;
// Initialize the chunk variables
chunkSize = chunkHeader.size;
@@ -217,7 +217,7 @@ bool SaveFileReader::firstChunk(ChunkID &chunk, int32 &size) {
size = chunkHeader.size;
// Return success
- return TRUE;
+ return true;
}
//----------------------------------------------------------------------
@@ -237,7 +237,7 @@ bool SaveFileReader::nextChunk(ChunkID &chunk, int32 &size) {
// Read the chunk header
if (fread(&chunkHeader, sizeof(chunkHeader), 1, fileHandle) != 1)
- return FALSE;
+ return false;
// Initialize the chunk variables
chunkSize = chunkHeader.size;
@@ -248,7 +248,7 @@ bool SaveFileReader::nextChunk(ChunkID &chunk, int32 &size) {
size = chunkHeader.size;
// Return success
- return TRUE;
+ return true;
}
//----------------------------------------------------------------------
diff --git a/engines/saga2/sensor.cpp b/engines/saga2/sensor.cpp
index 68eaf9b3eb..74e0616c4a 100644
--- a/engines/saga2/sensor.cpp
+++ b/engines/saga2/sensor.cpp
@@ -633,17 +633,17 @@ bool ProtaganistSensor::check(SenseInfo &info, uint32 senseFlags) {
continue;
info.sensedObject = protag;
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
//----------------------------------------------------------------------
// Evaluate an event to determine if the object is waiting for it
bool ProtaganistSensor::evaluateEvent(const GameEvent &) {
- return FALSE;
+ return false;
}
/* ===================================================================== *
@@ -696,17 +696,17 @@ bool ObjectSensor::check(SenseInfo &info, uint32 senseFlags) {
continue;
info.sensedObject = objToTest;
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
//----------------------------------------------------------------------
// Evaluate an event to determine if the object is waiting for it
bool ObjectSensor::evaluateEvent(const GameEvent &) {
- return FALSE;
+ return false;
}
/* ===================================================================== *
@@ -765,7 +765,7 @@ bool SpecificObjectSensor::check(SenseInfo &info, uint32 senseFlags) {
bool objIsActor = isActor(getObject());
if (senseFlags & (1 << actorBlind))
- return FALSE;
+ return false;
// This extra test is a HACK to ensure that the center actor
// will be able to sense a protaganist even if the protaganist
@@ -776,20 +776,20 @@ bool SpecificObjectSensor::check(SenseInfo &info, uint32 senseFlags) {
|| !isPlayerActor((Actor *)soughtObject))) {
Actor *a = (Actor *) soughtObject;
if (!(senseFlags & actorSeeInvis) && a->hasEffect(actorInvisible))
- return FALSE;
+ return false;
}
if (getRange() != 0
&& !getObject()->inRange(soughtObject->getLocation(), getRange()))
- return FALSE;
+ return false;
if (objIsActor
&& (!underSameRoof(getObject(), soughtObject)
|| !lineOfSight(getObject(), soughtObject, terrainTransparent)))
- return FALSE;
+ return false;
info.sensedObject = soughtObject;
- return TRUE;
+ return true;
}
//----------------------------------------------------------------------
@@ -925,7 +925,7 @@ bool SpecificActorSensor::check(SenseInfo &info, uint32 senseFlags) {
bool objIsActor = isActor(getObject());
if (senseFlags & (1 << actorBlind))
- return FALSE;
+ return false;
// This extra test is a HACK to ensure that the center actor
// will be able to sense a protaganist even if the protaganist
@@ -934,20 +934,20 @@ bool SpecificActorSensor::check(SenseInfo &info, uint32 senseFlags) {
|| getObject() != getCenterActor()
|| !isPlayerActor(soughtActor)) {
if (!(senseFlags & actorSeeInvis) && soughtActor->hasEffect(actorInvisible))
- return FALSE;
+ return false;
}
if (getRange() != 0
&& !getObject()->inRange(soughtActor->getLocation(), getRange()))
- return FALSE;
+ return false;
if (objIsActor
&& (!underSameRoof(getObject(), soughtActor)
|| !lineOfSight(getObject(), soughtActor, terrainTransparent)))
- return FALSE;
+ return false;
info.sensedObject = soughtActor;
- return TRUE;
+ return true;
}
//----------------------------------------------------------------------
@@ -1068,7 +1068,7 @@ int16 EventSensor::getType(void) {
// Determine if the object can sense what it's looking for
bool EventSensor::check(SenseInfo &, uint32) {
- return FALSE;
+ return false;
}
//----------------------------------------------------------------------
@@ -1081,7 +1081,7 @@ bool EventSensor::evaluateEvent(const GameEvent &event) {
? getObject()->inRange(
event.directObject->getLocation(),
getRange())
- : TRUE)
+ : true)
&& (!isActor(getObject())
|| (underSameRoof(getObject(), event.directObject)
&& lineOfSight(
diff --git a/engines/saga2/speech.cpp b/engines/saga2/speech.cpp
index 9d5615e3be..95532b5e36 100644
--- a/engines/saga2/speech.cpp
+++ b/engines/saga2/speech.cpp
@@ -275,7 +275,7 @@ bool Speech::append(char *text, int32 sampID) {
// Check to see if there's enough room in the character buffer
if (charCount + len >= sizeof(speechBuffer)
- || sampleCount >= MAX_SAMPLES) return FALSE;
+ || sampleCount >= MAX_SAMPLES) return false;
// Copy text to end of text in buffer, including '\0'
memcpy(&speechBuffer[charCount], text, len + 1);
@@ -287,7 +287,7 @@ bool Speech::append(char *text, int32 sampID) {
if (sampID)
sampleID[sampleCount++] = extendID(sampID);
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -304,7 +304,7 @@ bool Speech::activate(void) {
speechFlags |= spQueued;
// This routine can't fail
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -335,7 +335,7 @@ bool Speech::setupActive(void) {
setWidth();
// If speech position is off-screen, then skip
- if (!calcPosition(initialSpeechPosition)) return FALSE;
+ if (!calcPosition(initialSpeechPosition)) return false;
if (sampleCount) {
GameObject *go = GameObject::objectAddress(objID);
@@ -431,9 +431,9 @@ bool Speech::setupActive(void) {
// REM: Also set pointer to arrow shape.
mouseInfo.setIntent(GrabInfo::WalkTo);
// mouseInfo.setDoable( tileRect.ptInside( ev.mouse ) );
- speakButtonControls->enable(TRUE);
+ speakButtonControls->enable(true);
- speechList.SetLock(FALSE);
+ speechList.SetLock(false);
} else {
// If there is a lock flag on this speech, then LockUI()
speechList.SetLock(speechFlags & spLock);
@@ -446,7 +446,7 @@ bool Speech::setupActive(void) {
}
// speechFinished.set( ticksPerSecond*2 );
- return (TRUE);
+ return (true);
}
//This Function Sets Up Width And Height For A Speech
@@ -495,7 +495,7 @@ bool Speech::calcPosition(Point16 &p) {
GameObject *obj = GameObject::objectAddress(objID);
TilePoint tp = obj->getWorldLocation();
- if (!isVisible(obj)) return FALSE;
+ if (!isVisible(obj)) return false;
TileToScreenCoords(tp, p);
@@ -507,7 +507,7 @@ bool Speech::calcPosition(Point16 &p) {
p.y - (bounds.height + actorHeight),
tileRect.height - 50 - bounds.height);
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -520,7 +520,7 @@ bool Speech::displayText(void) {
// speech along with the display. Otherwise, calculate the
// position from the actor.
if (speechButtonCount > 0) p = initialSpeechPosition;
- else if (!calcPosition(p)) return FALSE;
+ else if (!calcPosition(p)) return false;
// Blit to the port
backPort.setMode(drawModeMatte);
@@ -530,7 +530,7 @@ bool Speech::displayText(void) {
p.y + fineScroll.y,
bounds.width, bounds.height);
- return TRUE;
+ return true;
}
//-----------------------------------------------------------------------
@@ -555,7 +555,7 @@ void Speech::dispose(void) {
// Clear the number of active buttons
speechLineCount = speechButtonCount = 0;
- speakButtonControls->enable(FALSE);
+ speakButtonControls->enable(false);
if (!(speechFlags & spNoAnimate) && isActor(objID)) {
Actor *a = (Actor *)GameObject::objectAddress(objID);
@@ -595,7 +595,7 @@ void updateSpeech(void) {
if (sp->longEnough() &&
(speechButtonCount == 0 || sp->selectedButton != 0))
sp->dispose();
- } else speechList.SetLock(FALSE);
+ } else speechList.SetLock(false);
}
bool Speech::longEnough(void) {
@@ -675,7 +675,7 @@ void abortAllSpeeches(void) {
// }
// if (abortEnabled)
// {
-// skipSpeeches = TRUE;
+// skipSpeeches = true;
// wakeUpThreads( TWAIT_SPEECH );
// }
@@ -1005,9 +1005,9 @@ bool isVisible(GameObject *obj) {
if ((distanceY >= loadDistY) ||
(distanceX >= loadDistX))
- return (FALSE);
+ return (false);
- return (TRUE);
+ return (true);
}
/* ===================================================================== *
@@ -1018,7 +1018,7 @@ bool isVisible(GameObject *obj) {
// Initialize the SpeechTaskList
SpeechTaskList::SpeechTaskList(void) {
- lockFlag = FALSE;
+ lockFlag = false;
for (int i = 0; i < elementsof(array); i++) {
free.addTail(array[i]);
@@ -1034,7 +1034,7 @@ SpeechTaskList::SpeechTaskList(void **buf) {
int16 i,
count;
- lockFlag = FALSE;
+ lockFlag = false;
// Initialize the free list
for (i = 0; i < elementsof(array); i++) {
@@ -1205,15 +1205,15 @@ Speech *SpeechTaskList::newTask(ObjectID id, uint16 flags) {
}
void SpeechTaskList::SetLock(int newState) {
- if (newState && lockFlag == FALSE) {
+ if (newState && lockFlag == false) {
extern void noStickyMap(void);
noStickyMap();
- LockUI(TRUE);
- lockFlag = TRUE;
- } else if (lockFlag && newState == FALSE) {
- LockUI(FALSE);
- lockFlag = FALSE;
+ LockUI(true);
+ lockFlag = true;
+ } else if (lockFlag && newState == false) {
+ LockUI(false);
+ lockFlag = false;
}
}
diff --git a/engines/saga2/spelcast.cpp b/engines/saga2/spelcast.cpp
index 5a918bc814..dd2c991753 100644
--- a/engines/saga2/spelcast.cpp
+++ b/engines/saga2/spelcast.cpp
@@ -97,14 +97,14 @@ bool SpellStuff::safe(void) {
case eAreaBall:
case eAreaWall:
case eAreaStorm:
- return FALSE;
+ return false;
case eAreaBolt:
case eAreaBeam:
case eAreaCone:
case eAreaWave:
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
//-----------------------------------------------------------------------
@@ -702,14 +702,14 @@ bool SpellInstance::buildList(void) {
if (eList.dissipated()) {
termEffect();
if (effect->next == NULL)
- return FALSE;
+ return false;
effect = effect->next;
effSeq++;
//
initEffect(target->getPoint());
}
- eList.buildEffects(FALSE);
- return TRUE;
+ eList.buildEffects(false);
+ return true;
}
// ------------------------------------------------------------------
@@ -724,7 +724,7 @@ bool SpellInstance::updateStates(int32 deltaTime) {
if (maxAge > 0 && age > maxAge)
termEffect();
eList.updateEStates(deltaTime);
- return TRUE;
+ return true;
}
diff --git a/engines/saga2/spellbuk.h b/engines/saga2/spellbuk.h
index 4af4edb0c7..d7f473cedc 100644
--- a/engines/saga2/spellbuk.h
+++ b/engines/saga2/spellbuk.h
@@ -152,7 +152,7 @@ public:
return (targetableTypes == spellTargNone);
}
bool untargeted(void) {
- return FALSE; //(targetableTypes == spellTargWorld ) ||
+ return false; //(targetableTypes == spellTargWorld ) ||
}
//(targetableTypes == spellTargCaster ) ||
//(targetableTypes == targetableTypes &
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index bf18196a26..1ad86ad36d 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -448,7 +448,7 @@ void ExpandColorMappedSprite(
uint8 GetSpritePixel(
Sprite *sp, // sprite pointer
- int16 flipped, // TRUE if sprite was flipped
+ int16 flipped, // true if sprite was flipped
const Point16 &testPoint) { // where to render to
gPixelMap sprMap; // sprite map
uint8 result;
diff --git a/engines/saga2/sprite.h b/engines/saga2/sprite.h
index 7c2e1097bb..cdf585eb8b 100644
--- a/engines/saga2/sprite.h
+++ b/engines/saga2/sprite.h
@@ -179,7 +179,7 @@ struct SpriteComponent {
Sprite *sp; // the sprite to draw
Point16 offset; // offset from given origin
uint8 *colorTable; // color lookup table
- uint8 flipped; // TRUE if horizontally flipped.
+ uint8 flipped; // true if horizontally flipped.
};
enum spriteEffectFlags {
@@ -321,7 +321,7 @@ void ExpandColorMappedSprite(
// Return a specific pixel from a sprite for mouse hit test
uint8 GetSpritePixel(
Sprite *sp, // sprite pointer
- int16 flipped, // TRUE if sprite was flipped
+ int16 flipped, // true if sprite was flipped
const Point16 &testPoint); // where to render to
// Return the number of visible pixels in a sprite after terrain masking
diff --git a/engines/saga2/std.h b/engines/saga2/std.h
index ed84c76868..0b3fadd042 100644
--- a/engines/saga2/std.h
+++ b/engines/saga2/std.h
@@ -49,16 +49,8 @@ typedef uint32 ChunkID;
#define offsetof(type,field) (uint32)&(((type *)0)->field)
#endif
-#ifndef FALSE
-#define FALSE 0
-#endif
-#ifndef TRUE
-#define TRUE 1
-#endif
-#define OK 0
-#define EMPTY -1
-
-typedef bool BOOL;
+#define OK 0
+#define EMPTY -1
#define maxuint8 0xff
#define minuint8 0
diff --git a/engines/saga2/target.cpp b/engines/saga2/target.cpp
index d24247dd0b..1b685f246f 100644
--- a/engines/saga2/target.cpp
+++ b/engines/saga2/target.cpp
@@ -147,10 +147,10 @@ void insertLocation(
* ===================================================================== */
bool Target::isObjectTarget(void) const {
- return FALSE;
+ return false;
}
bool Target::isActorTarget(void) const {
- return FALSE;
+ return false;
}
/* ===================================================================== *
@@ -212,7 +212,7 @@ void LocationTarget::clone(void *mem) const {
// Determine if the specified target is equivalent to this target
bool LocationTarget::operator == (const Target &t) const {
- if (t.getType() != locationTarget) return FALSE;
+ if (t.getType() != locationTarget) return false;
LocationTarget *targetPtr = (LocationTarget *)&t;
@@ -406,7 +406,7 @@ void SpecificTileTarget::clone(void *mem) const {
// Determine if the specified target is equivalent to this target
bool SpecificTileTarget::operator == (const Target &t) const {
- if (t.getType() != specificTileTarget) return FALSE;
+ if (t.getType() != specificTileTarget) return false;
SpecificTileTarget *targetPtr = (SpecificTileTarget *)&t;
@@ -475,7 +475,7 @@ void TilePropertyTarget::clone(void *mem) const {
// Determine if the specified target is equivalent to this target
bool TilePropertyTarget::operator == (const Target &t) const {
- if (t.getType() != tilePropertyTarget) return FALSE;
+ if (t.getType() != tilePropertyTarget) return false;
TilePropertyTarget *targetPtr = (TilePropertyTarget *)&t;
@@ -658,7 +658,7 @@ void SpecificMetaTileTarget::clone(void *mem) const {
// Determine if the specified target is equivalent to this target
bool SpecificMetaTileTarget::operator == (const Target &t) const {
- if (t.getType() != specificMetaTileTarget) return FALSE;
+ if (t.getType() != specificMetaTileTarget) return false;
SpecificMetaTileTarget *targetPtr = (SpecificMetaTileTarget *)&t;
@@ -731,7 +731,7 @@ void MetaTilePropertyTarget::clone(void *mem) const {
// Determine if the specified target is equivalent to this target
bool MetaTilePropertyTarget::operator == (const Target &t) const {
- if (t.getType() != metaTilePropertyTarget) return FALSE;
+ if (t.getType() != metaTilePropertyTarget) return false;
MetaTilePropertyTarget *targetPtr = (MetaTilePropertyTarget *)&t;
@@ -823,7 +823,7 @@ void ObjectTarget::searchObject(
}
bool ObjectTarget::isObjectTarget(void) const {
- return TRUE;
+ return true;
}
TilePoint ObjectTarget::where(GameWorld *world, const TilePoint &tp) const {
@@ -1016,7 +1016,7 @@ void SpecificObjectTarget::clone(void *mem) const {
// Determine if the specified target is equivalent to this target
bool SpecificObjectTarget::operator == (const Target &t) const {
- if (t.getType() != specificObjectTarget) return FALSE;
+ if (t.getType() != specificObjectTarget) return false;
SpecificObjectTarget *targetPtr = (SpecificObjectTarget *)&t;
@@ -1177,7 +1177,7 @@ void ObjectPropertyTarget::clone(void *mem) const {
// Determine if the specified target is equivalent to this target
bool ObjectPropertyTarget::operator == (const Target &t) const {
- if (t.getType() != objectPropertyTarget) return FALSE;
+ if (t.getType() != objectPropertyTarget) return false;
ObjectPropertyTarget *targetPtr = (ObjectPropertyTarget *)&t;
@@ -1197,7 +1197,7 @@ bool ActorTarget::isTarget(GameObject *obj) const {
}
bool ActorTarget::isActorTarget(void) const {
- return TRUE;
+ return true;
}
Actor *ActorTarget::actor(GameWorld *world, const TilePoint &tp) const {
@@ -1288,7 +1288,7 @@ void SpecificActorTarget::clone(void *mem) const {
// Determine if the specified target is equivalent to this target
bool SpecificActorTarget::operator == (const Target &t) const {
- if (t.getType() != specificActorTarget) return FALSE;
+ if (t.getType() != specificActorTarget) return false;
SpecificActorTarget *targetPtr = (SpecificActorTarget *)&t;
@@ -1479,7 +1479,7 @@ void ActorPropertyTarget::clone(void *mem) const {
// Determine if the specified target is equivalent to this target
bool ActorPropertyTarget::operator == (const Target &t) const {
- if (t.getType() != actorPropertyTarget) return FALSE;
+ if (t.getType() != actorPropertyTarget) return false;
ActorPropertyTarget *targetPtr = (ActorPropertyTarget *)&t;
diff --git a/engines/saga2/task.cpp b/engines/saga2/task.cpp
index 4c0350c34f..fcab0fceba 100644
--- a/engines/saga2/task.cpp
+++ b/engines/saga2/task.cpp
@@ -184,11 +184,11 @@ TaskStackList::TaskStackList(void) {
int i;
for (i = 0; i < elementsof(array); i++) {
- array[i].deleted = FALSE;
+ array[i].deleted = false;
free.addTail(array[i]);
}
- lazyDelete = FALSE;
+ lazyDelete = false;
deletionList = NULL;
}
@@ -339,7 +339,7 @@ void TaskStackList::deleteTaskStack(void *p) {
- offsetof(TaskStackPlaceHolder, buf));
if (lazyDelete) {
- tsp->deleted = TRUE;
+ tsp->deleted = true;
tsp->nextDeletion = deletionList;
deletionList = tsp;
} else {
@@ -359,7 +359,7 @@ void TaskStackList::updateTaskStacks(void) {
TaskStackPlaceHolder *tsp;
// Make sure all deletions during task processing are lazy
- lazyDelete = TRUE;
+ lazyDelete = true;
for (tsp = (TaskStackPlaceHolder *)list.first();
tsp != NULL;
@@ -381,7 +381,7 @@ void TaskStackList::updateTaskStacks(void) {
}
// Process all lazy deletions
- lazyDelete = FALSE;
+ lazyDelete = false;
while (deletionList != NULL) {
TaskStackPlaceHolder *nextDeletion = deletionList->nextDeletion;
@@ -393,7 +393,7 @@ void TaskStackList::updateTaskStacks(void) {
// Now that the real deletion has taken place reset the deleted
// flag
- deletionList->deleted = FALSE;
+ deletionList->deleted = false;
deletionList = nextDeletion;
}
@@ -431,10 +431,10 @@ void updateActorTasks(void) {
}
void pauseActorTasks(void) {
- actorTasksPaused = TRUE;
+ actorTasksPaused = true;
}
void resumeActorTasks(void) {
- actorTasksPaused = FALSE;
+ actorTasksPaused = false;
}
//----------------------------------------------------------------------
@@ -626,7 +626,7 @@ public:
tp = ((TaskPlaceHolder *)(
(uint8 *)t
- offsetof(TaskPlaceHolder, buf)));
- tp->marked = TRUE;
+ tp->marked = true;
}
// Verify that all allocated tasks are marked
@@ -765,7 +765,7 @@ void *TaskList::newTask(void)
#if DEBUG
tp->fileName = file;
tp->lineNo = line;
- tp->marked = FALSE;
+ tp->marked = false;
#endif
// Place the place holder into the active list
list.addTail(*tp);
@@ -796,7 +796,7 @@ void *TaskList::newTask(TaskID id)
#if DEBUG
tp->fileName = file;
tp->lineNo = line;
- tp->marked = FALSE;
+ tp->marked = false;
#endif
// Place the place holder into the active list
list.addTail(*tp);
@@ -851,7 +851,7 @@ void TaskList::clearMarks(void) {
for (tp = (TaskPlaceHolder *)list.first();
tp != NULL;
tp = (TaskPlaceHolder *)tp->next())
- tp->marked = FALSE;
+ tp->marked = false;
}
#endif
@@ -1321,7 +1321,7 @@ void WanderTask::pause(void) {
// Call abort to stop the wandering motion
abortTask();
- paused = TRUE;
+ paused = true;
counter = (g_vm->_rnd->getRandomNumber(63) + g_vm->_rnd->getRandomNumber(63)) / 2;
}
@@ -1329,7 +1329,7 @@ void WanderTask::pause(void) {
// Set this task into the wander state
void WanderTask::wander(void) {
- paused = FALSE;
+ paused = false;
counter = (g_vm->_rnd->getRandomNumber(255) + g_vm->_rnd->getRandomNumber(255)) / 2;
}
@@ -1445,7 +1445,7 @@ void TetheredWanderTask::abortTask(void) {
// Determine if the specified task is equivalent to this task
bool TetheredWanderTask::operator == (const Task &t) const {
- if (t.getType() != tetheredWanderTask) return FALSE;
+ if (t.getType() != tetheredWanderTask) return false;
TetheredWanderTask *taskPtr = (TetheredWanderTask *)&t;
@@ -1475,7 +1475,7 @@ TaskResult TetheredWanderTask::handleWander(void) {
gotoTether = NULL;
}
- bool startWander = FALSE;
+ bool startWander = false;
TileRegion motionTether;
MotionTask *actorMotion = a->moveTask;
@@ -1489,7 +1489,7 @@ TaskResult TetheredWanderTask::handleWander(void) {
|| motionTether.max.v != maxV);
} else
- startWander = TRUE;
+ startWander = true;
// If the actor is not already wandering, start a wander motion
// task
@@ -1759,7 +1759,7 @@ int16 GotoLocationTask::getType(void) const {
// Determine if the specified task is equivalent to this task
bool GotoLocationTask::operator == (const Task &t) const {
- if (t.getType() != gotoLocationTask) return FALSE;
+ if (t.getType() != gotoLocationTask) return false;
GotoLocationTask *taskPtr = (GotoLocationTask *)&t;
@@ -1786,7 +1786,7 @@ TilePoint GotoLocationTask::intermediateDest(void) {
bool GotoLocationTask::lineOfSight(void) {
// Let's pretend that there is always a line of sight to the
// target location
- return TRUE;
+ return true;
}
//----------------------------------------------------------------------
@@ -1797,7 +1797,7 @@ bool GotoLocationTask::run(void) {
return runThreshold != maxuint8
? (targetLoc - actorLoc).quickHDistance() > runThreshold
|| abs(targetLoc.z - actorLoc.z) > runThreshold
- : FALSE;
+ : false;
}
/* ===================================================================== *
@@ -1860,7 +1860,7 @@ int16 GotoRegionTask::getType(void) const {
// Determine if the specified task is equivalent to this task
bool GotoRegionTask::operator == (const Task &t) const {
- if (t.getType() != gotoRegionTask) return FALSE;
+ if (t.getType() != gotoRegionTask) return false;
GotoRegionTask *taskPtr = (GotoRegionTask *)&t;
@@ -1888,13 +1888,13 @@ TilePoint GotoRegionTask::intermediateDest(void) {
//----------------------------------------------------------------------
bool GotoRegionTask::lineOfSight(void) {
- return TRUE;
+ return true;
}
//----------------------------------------------------------------------
bool GotoRegionTask::run(void) {
- return FALSE;
+ return false;
}
/* ===================================================================== *
@@ -2099,7 +2099,7 @@ int16 GotoObjectTask::getType(void) const {
// Determine if the specified task is equivalent to this task
bool GotoObjectTask::operator == (const Task &t) const {
- if (t.getType() != gotoObjectTask) return FALSE;
+ if (t.getType() != gotoObjectTask) return false;
GotoObjectTask *taskPtr = (GotoObjectTask *)&t;
@@ -2118,7 +2118,7 @@ GameObject *GotoObjectTask::getObject(void) {
bool GotoObjectTask::run(void) {
// Running after objects has not been implemented yet
- return FALSE;
+ return false;
}
/* ===================================================================== *
@@ -2173,7 +2173,7 @@ int16 GotoActorTask::getType(void) const {
// Determine if the specified task is equivalent to this task
bool GotoActorTask::operator == (const Task &t) const {
- if (t.getType() != gotoActorTask) return FALSE;
+ if (t.getType() != gotoActorTask) return false;
GotoActorTask *taskPtr = (GotoActorTask *)&t;
@@ -2400,7 +2400,7 @@ int16 GoAwayFromObjectTask::getType(void) const {
// Determine if the specified task is equivalent to this task
bool GoAwayFromObjectTask::operator == (const Task &t) const {
- if (t.getType() != goAwayFromObjectTask) return FALSE;
+ if (t.getType() != goAwayFromObjectTask) return false;
GoAwayFromObjectTask *taskPtr = (GoAwayFromObjectTask *)&t;
@@ -2480,7 +2480,7 @@ int16 GoAwayFromActorTask::getType(void) const {
// Determine if the specified task is equivalent to this task
bool GoAwayFromActorTask::operator == (const Task &t) const {
- if (t.getType() != goAwayFromActorTask) return FALSE;
+ if (t.getType() != goAwayFromActorTask) return false;
GoAwayFromActorTask *taskPtr = (GoAwayFromActorTask *)&t;
@@ -2833,7 +2833,7 @@ int16 HuntToBeNearLocationTask::getType(void) const {
// Determine if the specified task is equivalent to this task
bool HuntToBeNearLocationTask::operator == (const Task &t) const {
- if (t.getType() != huntToBeNearLocationTask) return FALSE;
+ if (t.getType() != huntToBeNearLocationTask) return false;
HuntToBeNearLocationTask *taskPtr = (HuntToBeNearLocationTask *)&t;
@@ -3038,7 +3038,7 @@ int16 HuntToBeNearObjectTask::getType(void) const {
// Determine if the specified task is equivalent to this task
bool HuntToBeNearObjectTask::operator == (const Task &t) const {
- if (t.getType() != huntToBeNearObjectTask) return FALSE;
+ if (t.getType() != huntToBeNearObjectTask) return false;
HuntToBeNearObjectTask *taskPtr = (HuntToBeNearObjectTask *)&t;
@@ -3178,7 +3178,7 @@ int16 HuntToPossessTask::getType(void) const {
// Determine if the specified task is equivalent to this task
bool HuntToPossessTask::operator == (const Task &t) const {
- if (t.getType() != huntToPossessTask) return FALSE;
+ if (t.getType() != huntToPossessTask) return false;
HuntToPossessTask *taskPtr = (HuntToPossessTask *)&t;
@@ -3475,7 +3475,7 @@ int16 HuntToBeNearActorTask::getType(void) const {
// Determine if the specified task is equivalent to this task
bool HuntToBeNearActorTask::operator == (const Task &t) const {
- if (t.getType() != huntToBeNearActorTask) return FALSE;
+ if (t.getType() != huntToBeNearActorTask) return false;
HuntToBeNearActorTask *taskPtr = (HuntToBeNearActorTask *)&t;
@@ -3539,7 +3539,7 @@ bool HuntToBeNearActorTask::atTarget(void) {
// target actor
if (targetLoc != Nowhere
&& stack->getActor()->inRange(targetLoc, range))
- return TRUE;
+ return true;
else {
if (goAway != NULL) {
goAway->abortTask();
@@ -3547,7 +3547,7 @@ bool HuntToBeNearActorTask::atTarget(void) {
goAway = NULL;
}
- return FALSE;
+ return false;
}
}
@@ -3627,7 +3627,7 @@ HuntToKillTask::HuntToKillTask(
if (isActor(a->currentTarget))
currentTarget = (Actor *)a->currentTarget;
- a->setFightStance(TRUE);
+ a->setFightStance(true);
}
//----------------------------------------------------------------------
@@ -3682,7 +3682,7 @@ int16 HuntToKillTask::getType(void) const {
// Determine if the specified task is equivalent to this task
bool HuntToKillTask::operator == (const Task &t) const {
- if (t.getType() != huntToKillTask) return FALSE;
+ if (t.getType() != huntToKillTask) return false;
HuntToKillTask *taskPtr = (HuntToKillTask *)&t;
@@ -3699,7 +3699,7 @@ void HuntToKillTask::abortTask(void) {
a->flags &= ~Actor::specialAttack;
- a->setFightStance(FALSE);
+ a->setFightStance(false);
}
//----------------------------------------------------------------------
@@ -4052,7 +4052,7 @@ int16 HuntToGiveTask::getType(void) const {
// Determine if the specified task is equivalent to this task
bool HuntToGiveTask::operator == (const Task &t) const {
- if (t.getType() != huntToGiveTask) return FALSE;
+ if (t.getType() != huntToGiveTask) return false;
HuntToGiveTask *taskPtr = (HuntToGiveTask *)&t;
@@ -4068,7 +4068,7 @@ void HuntToGiveTask::evaluateTarget(void) {}
//----------------------------------------------------------------------
bool HuntToGiveTask::atTarget(void) {
- return FALSE;
+ return false;
}
//----------------------------------------------------------------------
@@ -4108,13 +4108,13 @@ bool BandTask::BandingRepulsorIterator::first(
repulsorVector = bandMember->getLocation() - a->getLocation();
repulsorStrength = 1;
- return TRUE;
+ return true;
}
bandIndex++;
}
- return FALSE;
+ return false;
}
//----------------------------------------------------------------------
@@ -4134,13 +4134,13 @@ bool BandTask::BandingRepulsorIterator::next(
repulsorVector = bandMember->getLocation() - a->getLocation();
repulsorStrength = 1;
- return TRUE;
+ return true;
}
bandIndex++;
}
- return FALSE;
+ return false;
}
//----------------------------------------------------------------------
@@ -4335,7 +4335,7 @@ bool BandTask::targetHasChanged(GotoTask *gotoTarget) {
> slop)
gotoLocation->changeTarget(currentTarget);
- return FALSE;
+ return false;
}
//----------------------------------------------------------------------
@@ -4363,10 +4363,10 @@ bool BandTask::atTarget(void) {
attend = NULL;
}
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
//----------------------------------------------------------------------
@@ -4440,10 +4440,10 @@ bool BandTask::BandAndAvoidEnemiesRepulsorIterator::firstEnemyRepulsor(
actorArray[actorIndex]->getLocation() - a->getLocation();
repulsorStrength = 6;
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
//----------------------------------------------------------------------
@@ -4461,10 +4461,10 @@ bool BandTask::BandAndAvoidEnemiesRepulsorIterator::nextEnemyRepulsor(
actorArray[actorIndex]->getLocation() - a->getLocation();
repulsorStrength = 6;
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
//----------------------------------------------------------------------
@@ -4473,12 +4473,12 @@ bool BandTask::BandAndAvoidEnemiesRepulsorIterator::nextEnemyRepulsor(
bool BandTask::BandAndAvoidEnemiesRepulsorIterator::first(
TilePoint &repulsorVector,
int16 &repulsorStrength) {
- iteratingThruEnemies = FALSE;
+ iteratingThruEnemies = false;
if (BandingRepulsorIterator::first(repulsorVector, repulsorStrength))
- return TRUE;
+ return true;
- iteratingThruEnemies = TRUE;
+ iteratingThruEnemies = true;
return firstEnemyRepulsor(repulsorVector, repulsorStrength);
}
@@ -4490,9 +4490,9 @@ bool BandTask::BandAndAvoidEnemiesRepulsorIterator::next(
int16 &repulsorStrength) {
if (!iteratingThruEnemies) {
if (BandingRepulsorIterator::next(repulsorVector, repulsorStrength))
- return TRUE;
+ return true;
- iteratingThruEnemies = TRUE;
+ iteratingThruEnemies = true;
return firstEnemyRepulsor(repulsorVector, repulsorStrength);
}
@@ -4671,7 +4671,7 @@ TaskResult FollowPatrolRouteTask::update(void) {
// Determine if the specified task is equivalent to this task
bool FollowPatrolRouteTask::operator == (const Task &t) const {
- if (t.getType() != followPatrolRouteTask) return FALSE;
+ if (t.getType() != followPatrolRouteTask) return false;
FollowPatrolRouteTask *taskPtr = (FollowPatrolRouteTask *)&t;
@@ -4752,7 +4752,7 @@ TaskResult FollowPatrolRouteTask::handlePaused(void) {
// Set this task into the paused state
void FollowPatrolRouteTask::pause(void) {
- paused = TRUE;
+ paused = true;
counter = (g_vm->_rnd->getRandomNumber(63) + g_vm->_rnd->getRandomNumber(63)) / 2;
}
@@ -4846,7 +4846,7 @@ TaskResult AttendTask::update(void) {
// Determine if the specified task is equivalent to this task
bool AttendTask::operator == (const Task &t) const {
- if (t.getType() != attendTask) return FALSE;
+ if (t.getType() != attendTask) return false;
AttendTask *taskPtr = (AttendTask *)&t;
@@ -5014,7 +5014,7 @@ TaskResult DefendTask::update(void) {
// Determine if the specified task is equivalent to this task
bool DefendTask::operator == (const Task &t) const {
- if (t.getType() != defendTask) return FALSE;
+ if (t.getType() != defendTask) return false;
DefendTask *taskPtr = (DefendTask *)&t;
@@ -5173,7 +5173,7 @@ TaskResult ParryTask::update(void) {
// Determine if the specified task is equivalent to this task
bool ParryTask::operator == (const Task &t) const {
- if (t.getType() != parryTask) return FALSE;
+ if (t.getType() != parryTask) return false;
ParryTask *taskPtr = (ParryTask *)&t;
diff --git a/engines/saga2/task.h b/engines/saga2/task.h
index 4f335df57e..d52eeb4c3e 100644
--- a/engines/saga2/task.h
+++ b/engines/saga2/task.h
@@ -330,7 +330,7 @@ public:
GotoTask(TaskStack *ts) :
Task(ts),
wander(NULL),
- prevRunState(FALSE) {
+ prevRunState(false) {
}
// Constructor -- reconstruct from archive buffer
@@ -535,7 +535,7 @@ public:
GotoObjectTask(
TaskStack *ts,
GameObject *obj,
- bool trackFlag = FALSE) :
+ bool trackFlag = false) :
GotoObjectTargetTask(ts, trackFlag),
targetObj(obj) {
}
@@ -574,7 +574,7 @@ class GotoActorTask : public GotoObjectTargetTask {
public:
// Constructor -- initial construction
- GotoActorTask(TaskStack *ts, Actor *a, bool trackFlag = FALSE) :
+ GotoActorTask(TaskStack *ts, Actor *a, bool trackFlag = false) :
GotoObjectTargetTask(ts, trackFlag),
targetActor(a) {
}
@@ -703,11 +703,11 @@ public:
GoAwayFromActorTask(
TaskStack *ts,
Actor *a,
- bool runFlag = FALSE);
+ bool runFlag = false);
GoAwayFromActorTask(
TaskStack *ts,
const ActorTarget &at,
- bool runFlag = FALSE);
+ bool runFlag = false);
// Constructor -- reconstruct from archive buffer
GoAwayFromActorTask(void **buf);
@@ -993,7 +993,7 @@ public:
HuntToPossessTask(TaskStack *ts, const ObjectTarget &ot) :
HuntObjectTask(ts, ot),
targetEvaluateCtr(0),
- grabFlag(FALSE) {
+ grabFlag(false) {
}
// Constructor -- reconstruct from archive buffer
@@ -1095,7 +1095,7 @@ public:
TaskStack *ts,
const ActorTarget &at,
uint16 r,
- bool trackFlag = FALSE) :
+ bool trackFlag = false) :
HuntActorTask(ts, at, trackFlag),
goAway(NULL),
range(MAX<uint16>(r, 16)),
@@ -1171,7 +1171,7 @@ public:
HuntToKillTask(
TaskStack *ts,
const ActorTarget &at,
- bool trackFlag = FALSE);
+ bool trackFlag = false);
// Constructor -- reconstruct from archive buffer
HuntToKillTask(void **buf);
@@ -1224,7 +1224,7 @@ public:
TaskStack *ts,
const ActorTarget &at,
GameObject *obj,
- bool trackFlag = FALSE) :
+ bool trackFlag = false) :
HuntActorTask(ts, at, trackFlag),
objToGive(obj) {
}
@@ -1517,7 +1517,7 @@ public:
// Set this task into the unpaused state
void followPatrolRoute(void) {
- paused = FALSE;
+ paused = false;
}
};
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index e6b8078f9f..dfd186dae3 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -1011,7 +1011,7 @@ inline bool platformRipped(Platform *pl) {
if (rippedRoofID != 0)
return pl->roofRipID() == rippedRoofID;
- return FALSE;
+ return false;
}
// Compute visible area in U/V coords
@@ -1061,7 +1061,7 @@ TilePoint selectNearbySite(
const TilePoint &startingCoords,
int32 minDist,
int32 maxDist,
- bool offScreenOnly = FALSE); // TRUE if we want it off-screen
+ bool offScreenOnly = false); // true if we want it off-screen
#ifdef _WIN32 // Set structure alignment packing value to 1 byte
diff --git a/engines/saga2/tileload.cpp b/engines/saga2/tileload.cpp
index f88894a845..968bf896fe 100644
--- a/engines/saga2/tileload.cpp
+++ b/engines/saga2/tileload.cpp
@@ -44,7 +44,7 @@ extern int16 currentMapNum;
extern hResource *objResFile;
extern hResContext *tileRes; // tile resource handle
-static byte *tileResLoad(hResID i, bool asynch = FALSE) {
+static byte *tileResLoad(hResID i, bool asynch = false) {
if (tileRes)
return tileRes->loadResource(i, "tile image bank");
else
diff --git a/engines/saga2/tileload.h b/engines/saga2/tileload.h
index a3feba3bf8..d7564e0b9e 100644
--- a/engines/saga2/tileload.h
+++ b/engines/saga2/tileload.h
@@ -139,7 +139,7 @@ public:
bool operator[](uint16 i) {
if (i < size) return (bool)(b[i / 32] & (1 << (i % 32)));
- else return FALSE;
+ else return false;
}
void resize(uint16 newSize);
@@ -218,8 +218,8 @@ public:
friend bool operator!= (FixedBitArray c, FixedBitArray d) {
for (uint16 i = 0; i < lWords; i++)
- if (c.b[i] != d.b[i]) return TRUE;
- return FALSE;
+ if (c.b[i] != d.b[i]) return true;
+ return false;
}
friend FixedBitArray operator^ (FixedBitArray c, FixedBitArray d) {
diff --git a/engines/saga2/tilemode.cpp b/engines/saga2/tilemode.cpp
index 623df7cc7e..3ee5f6c003 100644
--- a/engines/saga2/tilemode.cpp
+++ b/engines/saga2/tilemode.cpp
@@ -87,7 +87,7 @@ private:
* ===================================================================== */
//void startVideo( char *fileName,int x, int y );
-//int16 OptionsDialog( bool disableSaveResume=FALSE );
+//int16 OptionsDialog( bool disableSaveResume=false );
extern int16 speechButtonCount; // count of speech buttons
extern void abortSpeech(void);
@@ -155,7 +155,7 @@ ObjectID pickedActor;
#endif
#if CHEATMOVE
ObjectID selectedObject = Nothing;
-bool nudge = FALSE;
+bool nudge = false;
#endif
extern ObjectID viewCenterObject;
@@ -169,7 +169,7 @@ static struct _delayedNavigation {
_delayedNavigation(void) {;}
} delayedNavigation;
-static bool navigationDelayed = FALSE;
+static bool navigationDelayed = false;
extern Rect16 tileRect;
@@ -177,7 +177,7 @@ extern Rect16 tileRect;
GameMode TileMode = {
NULL, // no previous mode
- FALSE, // mode is not nestable
+ false, // mode is not nestable
TileModeSetup,
TileModeCleanup,
TileModeHandleTask,
@@ -194,17 +194,17 @@ extern gToolBase G_BASE;
extern Alarm frameAlarm; // 10 fps frame rate
Alarm updateAlarm, // max coord update rate
pathFindAlarm; // mouse click rate for path find
-bool tileLockFlag; // TRUE if tile mode is locked
+bool tileLockFlag; // true if tile mode is locked
GameObject *mouseObject = NULL; // object being dragged
Point32 lastMousePos; // Last mouse position over map
static bool mousePressed, // State of mouse button
- clickActionDone = TRUE; // Flag indication wether current
+ clickActionDone = true; // Flag indication wether current
// mouse click action is done
-static bool runFlag = FALSE; // Reflexs wether the mouse is
+static bool runFlag = false; // Reflexs wether the mouse is
// the run zone
-static bool uiKeysEnabled = TRUE;
+static bool uiKeysEnabled = true;
static char lastUnusedKey = '\0';
@@ -222,7 +222,7 @@ extern uint32 frames;
extern hResContext *imageRes; // image resource handle
// Combat related data
-static bool aggressiveActFlag = FALSE; // Indicates wether or not
+static bool aggressiveActFlag = false; // Indicates wether or not
// there has been an
// aggressive act
static CalenderTime timeOfLastAggressiveAct; // Used to determine the
@@ -280,14 +280,14 @@ static void pauseCombat(void) {
pauseActorStates();
pauseActorTasks();
- setCenterActorIndicator(TRUE);
+ setCenterActorIndicator(true);
}
//-----------------------------------------------------------------------
// This function performs all combat un-pausing tasks
static void resumeCombat(void) {
- setCenterActorIndicator(FALSE);
+ setCenterActorIndicator(false);
resumeActorTasks();
resumeActorStates();
@@ -302,8 +302,8 @@ static void resumeCombat(void) {
static void startCombat(void) {
if (globalConfig.autoAggression) autoAdjustAggression();
- setCombatBehavior(TRUE);
- combatPaused = FALSE;
+ setCombatBehavior(true);
+ combatPaused = false;
}
//-----------------------------------------------------------------------
@@ -311,10 +311,10 @@ static void startCombat(void) {
static void endCombat(void) {
if (combatPaused) {
- combatPaused = FALSE;
+ combatPaused = false;
resumeCombat();
}
- setCombatBehavior(FALSE);
+ setCombatBehavior(false);
handleEndOfCombat();
}
@@ -355,7 +355,7 @@ void logAggressiveAct(ObjectID attackerID, ObjectID attackeeID) {
if (actorIDToPlayerID(attackeeID, playerID))
handlePlayerActorAttacked(playerID);
- aggressiveActFlag = TRUE;
+ aggressiveActFlag = true;
timeOfLastAggressiveAct = calender;
}
}
@@ -379,10 +379,10 @@ bool areThereActiveEnemies(void) {
if (isActor(obj)
&& !((Actor *)obj)->isDead()
&& ((Actor *)obj)->disposition == dispositionEnemy)
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
void CheckCombatMood(void) {
@@ -390,7 +390,7 @@ void CheckCombatMood(void) {
TilePoint centerLoc;
ActiveRegion *ar;
GameWorld *world;
- static bool wasHostile = FALSE;
+ static bool wasHostile = false;
ar = getActiveRegion(getCenterActorPlayerID());
if (ar == NULL) return;
@@ -409,7 +409,7 @@ void CheckCombatMood(void) {
bool agress = isCenterActorAggressive();
- wasHostile = FALSE;
+ wasHostile = false;
clearActiveFactions();
for (iter8.first(&obj); obj != NULL; iter8.next(&obj)) {
if (isActor(obj)
@@ -417,7 +417,7 @@ void CheckCombatMood(void) {
&& ((Actor *)obj)->disposition == dispositionEnemy) {
if (agress || !(((Actor *)obj)->flags & Actor::afraid)) {
incrementActiveFaction((Actor *) obj);
- wasHostile = TRUE;
+ wasHostile = true;
}
}
}
@@ -531,7 +531,7 @@ static void evalMouseState(void) {
&& (a->inRange(obj->getLocation(), 8)
|| lineOfSight(a, obj, terrainTransparent))) {
mouseInfo.setIntent(GrabInfo::Attack);
- mouseInfo.setDoable(TRUE);
+ mouseInfo.setDoable(true);
} else {
mouseInfo.setIntent(GrabInfo::WalkTo);
walkToPos = obj->getLocation();
@@ -609,9 +609,9 @@ static void evalMouseState(void) {
void initTileModeState(void) {
assert(uiKeysEnabled);
- aggressiveActFlag = FALSE;
- inCombat = FALSE;
- combatPaused = FALSE;
+ aggressiveActFlag = false;
+ inCombat = false;
+ combatPaused = false;
}
//-----------------------------------------------------------------------
@@ -656,7 +656,7 @@ void loadTileModeState(SaveFileReader &saveGame) {
&timeOfLastAggressiveAct,
sizeof(timeOfLastAggressiveAct));
}
- tileLockFlag = FALSE;
+ tileLockFlag = false;
}
/* ===================================================================== *
@@ -678,7 +678,7 @@ void TileModeSetup(void) {
tileMapControl = new gStickyDragControl(*playControls, tileRect, 0, cmdClickTileMap);
//Enable Tile Mode Specific Controls
- tileControls->enable(TRUE);
+ tileControls->enable(true);
initTileBanks();
@@ -703,7 +703,7 @@ void TileModeSetup(void) {
void TileModeCleanup(void) {
//Disable Tile Mode Specific Controls
- tileControls->enable(FALSE);
+ tileControls->enable(false);
freeAllTileBanks();
@@ -729,7 +729,7 @@ static int postDisplayFrame = 3;
extern int lockUINest;
void TileModeHandleTask(void) {
- bool taskChek = FALSE;
+ bool taskChek = false;
// Run any SAGA scripts which are waiting to run.
dispatchScripts();
@@ -757,12 +757,12 @@ void TileModeHandleTask(void) {
else if (timeSinceLastAggressiveAct() < 60
&& areThereActiveEnemies()) {
if (!inCombat) {
- inCombat = TRUE;
+ inCombat = true;
startCombat();
}
} else {
if (inCombat) {
- inCombat = FALSE;
+ inCombat = false;
endCombat();
}
}
@@ -770,12 +770,12 @@ void TileModeHandleTask(void) {
if (inCombat) {
if (!a->isMoving() && a->isInterruptable() && lockUINest == 0) {
if (!combatPaused) {
- combatPaused = TRUE;
+ combatPaused = true;
pauseCombat();
}
} else {
if (combatPaused) {
- combatPaused = FALSE;
+ combatPaused = false;
resumeCombat();
}
}
@@ -790,10 +790,10 @@ void TileModeHandleTask(void) {
// do an alarm check for container views
if (containerObjTextAlarm.check()) {
- ContainerView::objTextAlarm = TRUE;
+ ContainerView::objTextAlarm = true;
}
- if (ContainerView::objTextAlarm == TRUE) {
+ if (ContainerView::objTextAlarm == true) {
// if the mouse is in a container...
if (ContainerView::mouseInView) {
mouseInfo.setText(ContainerView::mouseText);
@@ -885,8 +885,8 @@ void TileModeHandleTask(void) {
if (delayedNavigation.pathFindFlag)
navigatePath(delayedNavigation.walkToPos);
else
- navigateDirect(delayedNavigation.walkToPos, FALSE);
- navigationDelayed = FALSE;
+ navigateDirect(delayedNavigation.walkToPos, false);
+ navigationDelayed = false;
}
updateContainerWindows();
@@ -912,9 +912,9 @@ void TileModeHandleTask(void) {
updateMainDisplay();
if (inCombat || postDisplayFrame++ > 2)
- taskChek = TRUE;
+ taskChek = true;
} else if (postDisplayFrame) {
- taskChek = TRUE;
+ taskChek = true;
}
if (taskChek) {
postDisplayFrame = 0;
@@ -959,8 +959,8 @@ void TileModeHandleKey(int16 key, int16 qual) {
abortSpeech();
if (uiKeysEnabled) {
if (tileMapControl->isSticky()) {
- tileMapControl->setSticky(FALSE);
- mousePressed = FALSE;
+ tileMapControl->setSticky(false);
+ mousePressed = false;
setMouseImage(kMouseArrowImage, 0, 0);
evalMouseState();
}
@@ -1000,15 +1000,15 @@ void TileModeHandleKey(int16 key, int16 qual) {
// Keyboard equivalents for mental containers
case 'i':
if (uiKeysEnabled)
- OpenMindContainer(getCenterActorPlayerID(), TRUE, 0);
+ OpenMindContainer(getCenterActorPlayerID(), true, 0);
break;
case 's':
if (uiKeysEnabled)
- OpenMindContainer(getCenterActorPlayerID(), TRUE, 1);
+ OpenMindContainer(getCenterActorPlayerID(), true, 1);
break;
case 'k':
if (uiKeysEnabled)
- OpenMindContainer(getCenterActorPlayerID(), TRUE, 2);
+ OpenMindContainer(getCenterActorPlayerID(), true, 2);
break;
case 'm':
@@ -1090,7 +1090,7 @@ void showMouseEvent(char eventType) {
static APPFUNC(cmdClickTileMap) {
- static bool dblClick = FALSE;
+ static bool dblClick = false;
// REM: This code needs to be moved elsewhere. We put it
// here for testing purposes only. It should actually go on
@@ -1116,11 +1116,11 @@ static APPFUNC(cmdClickTileMap) {
case gEventMouseMove:
case gEventMouseDrag:
if (ev.value & gGenericControl::leave) {
- mousePressed = FALSE;
+ mousePressed = false;
if (mouseInfo.getObject() == NULL)
mouseInfo.setIntent(GrabInfo::WalkTo);
- mouseInfo.setDoable(TRUE);
+ mouseInfo.setDoable(true);
// Remove any mouse text
lastPickedObject = Nothing;
@@ -1132,9 +1132,9 @@ static APPFUNC(cmdClickTileMap) {
case gEventMouseDown:
- mousePressed = TRUE;
+ mousePressed = true;
- clickActionDone = FALSE;
+ clickActionDone = false;
{
// Get the center actor's ID and a pointer to the center
@@ -1176,10 +1176,10 @@ static APPFUNC(cmdClickTileMap) {
}
((gGenericControl *)ev.panel)->disableDblClick();
- clickActionDone = TRUE;
+ clickActionDone = true;
} else if (mouseInfo.getIntent() == GrabInfo::Use) {
mouseInfo.replaceObject();
- clickActionDone = TRUE;
+ clickActionDone = true;
}
} else if (pickedTAI != NULL) {
// we dropped the object onto active terrain
@@ -1214,11 +1214,11 @@ static APPFUNC(cmdClickTileMap) {
}
((gGenericControl *)ev.panel)->disableDblClick();
- clickActionDone = TRUE;
+ clickActionDone = true;
}
} else if (mouseInfo.getIntent() == GrabInfo::Use) {
mouseInfo.replaceObject();
- clickActionDone = TRUE;
+ clickActionDone = true;
}
} else if (pickedObject == Nothing) {
// we dropped the object on the ground
@@ -1232,7 +1232,7 @@ static APPFUNC(cmdClickTileMap) {
Location(tilePickPos, currentWorld->thisID()),
mouseInfo.getMoveCount());
((gGenericControl *)ev.panel)->disableDblClick();
- clickActionDone = TRUE;
+ clickActionDone = true;
} else if (mouseInfo.getIntent() == GrabInfo::Use
&& mouseInfo.getDoable()) {
// New for spells - this enables objects to be used on a
@@ -1242,10 +1242,10 @@ static APPFUNC(cmdClickTileMap) {
*centerActorPtr,
*mouseObject,
Location(tilePickPos, currentWorld->thisID()));
- clickActionDone = TRUE;
+ clickActionDone = true;
} else if (mouseInfo.getIntent() == GrabInfo::Use) {
mouseInfo.replaceObject();
- clickActionDone = TRUE;
+ clickActionDone = true;
}
}
} else if (pickedObject != Nothing) {
@@ -1256,7 +1256,7 @@ static APPFUNC(cmdClickTileMap) {
if (actorIDToPlayerID(pickedObject, pID) && !isBrotherDead(pID)) {
setCenterBrother(pID);
- clickActionDone = TRUE;
+ clickActionDone = true;
} else if (mouseInfo.getIntent() == GrabInfo::PickUp
|| mouseInfo.getIntent() == GrabInfo::Open) {
GameObject *pickedObjPtr =
@@ -1271,7 +1271,7 @@ static APPFUNC(cmdClickTileMap) {
quantity = pickedObjPtr->getExtra();
if (pickedObjPtr->take(centerActorID, quantity))
- clickActionDone = TRUE;
+ clickActionDone = true;
} else if (mouseInfo.getIntent() == GrabInfo::Attack) {
centerActorPtr->attack(
GameObject::objectAddress(pickedObject));
@@ -1291,12 +1291,12 @@ static APPFUNC(cmdClickTileMap) {
if (mouseInfo.getIntent() == GrabInfo::WalkTo
&& mouseInfo.getDoable()) {
if (pickedTAI == NULL) {
- navigateDirect(walkToPos, FALSE);
+ navigateDirect(walkToPos, false);
// ( ( gGenericControl * )ev.panel )->disableDblClick();
} else {
- navigationDelayed = TRUE;
+ navigationDelayed = true;
delayedNavigation.walkToPos = walkToPos;
- delayedNavigation.pathFindFlag = FALSE;
+ delayedNavigation.pathFindFlag = false;
delayedNavigation.delay.set(ticksPerSecond / 2);
}
pathFindAlarm.set(ticksPerSecond / 2);
@@ -1307,10 +1307,10 @@ static APPFUNC(cmdClickTileMap) {
case gEventMouseUp:
- mousePressed = FALSE;
+ mousePressed = false;
if (dblClick)
- dblClick = FALSE;
+ dblClick = false;
else {
if (pathFindAlarm.check()) { // mouse click was too long for path find
if (mouseInfo.getIntent() == GrabInfo::WalkTo) {
@@ -1319,11 +1319,11 @@ static APPFUNC(cmdClickTileMap) {
if (a->moveTask && a->moveTask->isWalk())
a->moveTask->finishWalk();
}
- navigationDelayed = FALSE;
+ navigationDelayed = false;
} else {
if (navigationDelayed) {
delayedNavigation.walkToPos = walkToPos;
- delayedNavigation.pathFindFlag = TRUE;
+ delayedNavigation.pathFindFlag = true;
delayedNavigation.delay.set(ticksPerSecond / 2);
} else {
Actor *a = getCenterActor();
@@ -1331,7 +1331,7 @@ static APPFUNC(cmdClickTileMap) {
if ((walkToPos - a->getLocation()).quickHDistance() > 24)
navigatePath(walkToPos);
else
- navigateDirect(walkToPos, FALSE);
+ navigateDirect(walkToPos, false);
}
}
}
@@ -1339,9 +1339,9 @@ static APPFUNC(cmdClickTileMap) {
case gEventDoubleClick:
- dblClick = TRUE;
+ dblClick = true;
- navigationDelayed = FALSE;
+ navigationDelayed = false;
if ((mouseObject = mouseInfo.getObject()) != NULL) {
mouseInfo.replaceObject();
@@ -1364,7 +1364,7 @@ static APPFUNC(cmdClickTileMap) {
GameObject::objectAddress(pickedObject);
MotionTask::useObject(*getCenterActor(), *pickedObjPtr);
- clickActionDone = TRUE;
+ clickActionDone = true;
}
}
} else if (pickedTAI != NULL) {
@@ -1378,9 +1378,9 @@ static APPFUNC(cmdClickTileMap) {
|| lineOfSight(a, TAILoc, terrainTransparent)))
MotionTask::useTAI(*a, *pickedTAI);
} else {
- tileMapControl->setSticky(TRUE);
+ tileMapControl->setSticky(true);
setMouseImage(kMouseAutoWalkImage, -8, -8);
- mousePressed = TRUE;
+ mousePressed = true;
}
break;
@@ -1400,7 +1400,7 @@ void navigateDirect(TilePoint pick, bool runFlag_) {
// REM: Do running here...
- MotionTask::walkToDirect(*a, pick, runFlag_, FALSE);
+ MotionTask::walkToDirect(*a, pick, runFlag_, false);
}
}
@@ -1416,7 +1416,7 @@ void navigatePath(TilePoint pick) {
a->moveTask->changeTarget(pick);
else
// else create a new motion task
- MotionTask::walkTo(*a, pick, FALSE, FALSE);
+ MotionTask::walkTo(*a, pick, false, false);
}
}
@@ -1498,12 +1498,12 @@ void cheatMove(int16 key) {
gStickyDragControl::gStickyDragControl(gPanelList &list, const Rect16 &box,
uint16 ident, AppFunc *cmd)
: gGenericControl(list, box, ident, cmd) {
- sticky = FALSE;
+ sticky = false;
}
void gStickyDragControl::deactivate(void) {
if (sticky) setMouseImage(kMouseArrowImage, 0, 0);
- sticky = FALSE;
+ sticky = false;
gGenericControl::deactivate();
}
@@ -1514,18 +1514,18 @@ void gStickyDragControl::deactivate(void) {
bool gStickyDragControl::pointerHit(gPanelMessage &msg) {
if (sticky) setMouseImage(kMouseArrowImage, 0, 0);
- sticky = FALSE;
+ sticky = false;
return gGenericControl::pointerHit(msg);
}
void gStickyDragControl::pointerRelease(gPanelMessage &msg) {
- if (sticky == FALSE)
+ if (sticky == false)
gGenericControl::pointerRelease(msg);
}
void noStickyMap(void) {
((gPanel *)tileMapControl)->deactivate();
- mousePressed = FALSE;
+ mousePressed = false;
}
} // end of namespace Saga2
diff --git a/engines/saga2/tower.cpp b/engines/saga2/tower.cpp
index 789e186470..90c7287a2d 100644
--- a/engines/saga2/tower.cpp
+++ b/engines/saga2/tower.cpp
@@ -70,7 +70,7 @@ static bool initTowerLayer(int is) {
return r;
}
-static bool cleanupErr = FALSE;
+static bool cleanupErr = false;
static void termTowerLayer(int is) {
tower[is].term();
@@ -84,7 +84,7 @@ static void termTowerLayer(int is) {
INITIALIZER(programInit) {
for (initializationState = 0; initializationState < maxInitState;) {
int32 tLevel = getTowerLayer(initializationState);
- bool r = FALSE;
+ bool r = false;
SystemEventLoop();
r = initTowerLayer(tLevel);
@@ -92,10 +92,10 @@ INITIALIZER(programInit) {
setInitState(initializationState + 1);
} else {
error("Tower Initialization Step %d Failed (record %d)", initializationState, tLevel);
- return FALSE;
+ return false;
}
}
- return TRUE;
+ return true;
}
// ------------------------------------------------------------------------
@@ -114,7 +114,7 @@ TERMINATOR(programTerm) {
// Null Builder
INITIALIZER(initTowerBase) {
- return TRUE;
+ return true;
}
// ------------------------------------------------------------------------
diff --git a/engines/saga2/towerfta.cpp b/engines/saga2/towerfta.cpp
index 3842e8100f..ff1c5a479e 100644
--- a/engines/saga2/towerfta.cpp
+++ b/engines/saga2/towerfta.cpp
@@ -125,7 +125,7 @@ extern gPanelList *indivControls;
// ------------------------------------------------------------------------
INITIALIZER(initSystemConfig) {
- return TRUE;
+ return true;
}
// uses null cleanup
@@ -143,7 +143,7 @@ TERMINATOR(termMemPool) {
INITIALIZER(initPlayIntro) {
setIntroMode();
- return TRUE;
+ return true;
}
TERMINATOR(termPlayOutro) {
@@ -175,7 +175,7 @@ TERMINATOR(termResourceFiles) {
INITIALIZER(initResourceServers) {
initServers();
- return TRUE;
+ return true;
}
TERMINATOR(termResourceServers) {
@@ -187,7 +187,7 @@ TERMINATOR(termResourceServers) {
INITIALIZER(initPathFinders) {
initPathFinder();
- return TRUE;
+ return true;
}
TERMINATOR(termPathFinders) {
@@ -199,7 +199,7 @@ TERMINATOR(termPathFinders) {
INITIALIZER(initSAGAInterpreter) {
initScripts();
- return TRUE;
+ return true;
}
TERMINATOR(termSAGAInterpreter) {
@@ -211,7 +211,7 @@ TERMINATOR(termSAGAInterpreter) {
INITIALIZER(initAudioChannels) {
startAudio();
- return TRUE;
+ return true;
}
TERMINATOR(termAudioChannels) {
@@ -249,7 +249,7 @@ TERMINATOR(termResourceHandles) {
INITIALIZER(initPalettes) {
loadPalettes();
- return TRUE;
+ return true;
}
TERMINATOR(termPalettes) {
@@ -261,7 +261,7 @@ TERMINATOR(termPalettes) {
INITIALIZER(initDisplayPort) {
initBackPanel();
- return TRUE;
+ return true;
}
TERMINATOR(termDisplayPort) {
@@ -280,7 +280,7 @@ INITIALIZER(initPanelSystem) {
tmap->data = new uint8[tmap->bytes()];
mainPort.setMap(tmap);
}
- return TRUE;
+ return true;
}
TERMINATOR(termPanelSystem) {
@@ -292,7 +292,7 @@ TERMINATOR(termPanelSystem) {
INITIALIZER(initMainWindow) {
mainWindow->open();
- return TRUE;
+ return true;
}
TERMINATOR(termMainWindow) {
@@ -363,7 +363,7 @@ TERMINATOR(termDisplay) {
INITIALIZER(initGameMaps) {
initMaps();
- return TRUE;
+ return true;
}
TERMINATOR(termGameMaps) {
@@ -375,7 +375,7 @@ TERMINATOR(termGameMaps) {
INITIALIZER(initRouteData) {
initPatrolRoutes();
- return TRUE;
+ return true;
}
TERMINATOR(termRouteData) {
@@ -387,7 +387,7 @@ TERMINATOR(termRouteData) {
INITIALIZER(initActorSprites) {
initSprites();
- return TRUE;
+ return true;
}
TERMINATOR(termActorSprites) {
@@ -399,7 +399,7 @@ TERMINATOR(termActorSprites) {
INITIALIZER(initWeaponData) {
initWeapons();
- return TRUE;
+ return true;
}
TERMINATOR(termWeaponData) {
@@ -411,7 +411,7 @@ TERMINATOR(termWeaponData) {
INITIALIZER(initSpellData) {
initMagic();
- return TRUE;
+ return true;
}
TERMINATOR(termSpellData) {
@@ -423,7 +423,7 @@ TERMINATOR(termSpellData) {
INITIALIZER(initObjectSoundFX) {
initObjectSoundFXTable();
- return TRUE;
+ return true;
}
TERMINATOR(termObjectSoundFX) {
@@ -434,7 +434,7 @@ TERMINATOR(termObjectSoundFX) {
INITIALIZER(initObjectPrototypes) {
initPrototypes();
- return TRUE;
+ return true;
}
TERMINATOR(termObjectPrototypes) {
@@ -446,7 +446,7 @@ TERMINATOR(termObjectPrototypes) {
INITIALIZER(initDynamicGameData) {
initGameState();
- return TRUE;
+ return true;
}
TERMINATOR(termDynamicGameData) {
@@ -461,7 +461,7 @@ INITIALIZER(initGameMode) {
GameMode::SetStack(gameModes, 2);
if (GameMode::newmodeFlag)
GameMode::update();
- return TRUE;
+ return true;
}
TERMINATOR(termGameMode) {
@@ -475,7 +475,7 @@ void RMemFastCleanup(void);
INITIALIZER(initTop) {
niceScreenStartup();
- return TRUE;
+ return true;
}
TERMINATOR(termTop) {
diff --git a/engines/saga2/transit.cpp b/engines/saga2/transit.cpp
index 8d9bbe258a..a0969df922 100644
--- a/engines/saga2/transit.cpp
+++ b/engines/saga2/transit.cpp
@@ -49,14 +49,14 @@ static gPalette newPalette;
bool isModalMode(void) {
uint16 i;
- bool modalFlag = FALSE;
+ bool modalFlag = false;
for (i = 0; i < GameMode::modeStackCtr; i++) {
// go through each stacked mode
// and if modal mode is one of them,
// then set the modal flag
if (GameMode::modeStackPtr[i] == &ModalMode) {
- modalFlag = TRUE;
+ modalFlag = true;
}
}
diff --git a/engines/saga2/tromode.cpp b/engines/saga2/tromode.cpp
index 34c42795e5..0427cf0b0a 100644
--- a/engines/saga2/tromode.cpp
+++ b/engines/saga2/tromode.cpp
@@ -48,7 +48,7 @@ namespace Saga2 {
#define LOSE_VID "END_4" VIDEO_EXTENSION
-#define ERASE_BETWEEN TRUE
+#define ERASE_BETWEEN true
#define VIDEO_X 0
#define VIDEO_Y 0
@@ -62,7 +62,7 @@ extern bool allPlayerActorsDead;
extern int16 queueIn,
queueOut;
-int16 OptionsDialog(bool disableSaveResume = FALSE);
+int16 OptionsDialog(bool disableSaveResume = false);
void SystemEventLoop(void);
void freeAllTileBanks(void);
void resetInputDevices(void);
@@ -85,7 +85,7 @@ void waitForInput(void);
static void TroModeSetup(void);
static void TroModeCleanup(void);
-static bool abortFlag = FALSE;
+static bool abortFlag = false;
#ifndef NO_LOAD_AFTER_WIN
//DO_OUTRO_IN_CLEANUP
static int whichOutro = -1;
@@ -127,7 +127,7 @@ void setWintroMode(int16 whichOne) {
endGame();
#else
whichOutro = whichOne;
- allPlayerActorsDead = TRUE;
+ allPlayerActorsDead = true;
#endif
}
@@ -139,7 +139,7 @@ void fadeUp();
void dumpGBASE(char *msg);
void setLostroMode(void) {
- allPlayerActorsDead = FALSE;
+ allPlayerActorsDead = false;
if (GameMode::newmodeFlag)
GameMode::update();
@@ -153,7 +153,7 @@ void setLostroMode(void) {
whichOutro = -1;
TroModeCleanup();
}
- OptionsDialog(TRUE);
+ OptionsDialog(true);
reDrawScreen();
}
@@ -162,7 +162,7 @@ void setLostroMode(void) {
* ===================================================================== */
void TroModeExternEvent(void) {
- abortFlag = TRUE;
+ abortFlag = true;
}
// ------------------------------------------------------------------------
@@ -172,14 +172,14 @@ static void TroModeSetup(void) {
suspendAudio();
pointer.hide();
#ifdef _WIN32
- cursorFullHide(TRUE);
+ cursorFullHide(true);
#endif
quickSavePalette();
blackOut();
displayDisable(PlayingVideo);
pushVidState();
resetInputDevices();
- abortFlag = FALSE;
+ abortFlag = false;
}
// ------------------------------------------------------------------------
@@ -193,7 +193,7 @@ static void TroModeCleanup(void) {
quickRestorePalette();
resumeAudio();
#ifdef _WIN32
- cursorFullHide(FALSE);
+ cursorFullHide(false);
#endif
pointer.show();
// pointer.manditoryShow(); // hide mouse pointer
@@ -221,7 +221,7 @@ static void waitForVideo(void) {
// Wait till the user hits a key or clicks or screams or whatever
void waitForInput(void) {
- abortFlag = FALSE;
+ abortFlag = false;
while (!abortFlag) {
SystemEventLoop();
if (abortFlag)
@@ -240,7 +240,7 @@ static void playAVideo(const char *fileName, int x, int y) { //, int16 from, int
g_vm->startVideo(fileName, x, y);
if (!g_vm->checkVideo()) {
g_vm->endVideo();
- abortFlag = TRUE;
+ abortFlag = true;
return;
}
waitForVideo();
@@ -256,7 +256,7 @@ static void playAVideo(const char *fileName, int x, int y) { //, int16 from, int
static void doIntro(void) {
playAVideo(INTRO_VID1, 0, 0);
- abortFlag = FALSE;
+ abortFlag = false;
playAVideo(INTRO_VID2, 0, 0);
}
diff --git a/engines/saga2/uidialog.h b/engines/saga2/uidialog.h
index db9f506ea6..ea29a03d50 100644
--- a/engines/saga2/uidialog.h
+++ b/engines/saga2/uidialog.h
@@ -53,7 +53,7 @@ enum placardTypes {
* ===================================================================== */
// dialog funcs
-int16 OptionsDialog(bool disableSaveResume = FALSE);
+int16 OptionsDialog(bool disableSaveResume = false);
// helper funcs
void initFileFields(char **fieldStrings);
diff --git a/engines/saga2/vbacksav.cpp b/engines/saga2/vbacksav.cpp
index d73d11081b..dd78cf4053 100644
--- a/engines/saga2/vbacksav.cpp
+++ b/engines/saga2/vbacksav.cpp
@@ -48,7 +48,7 @@ gBackSave::gBackSave(const Rect16 &extent) {
setMap(&savedPixels);
setMode(drawModeReplace);
- saved = FALSE;
+ saved = false;
}
/********* vbacksav.cpp/gBackSave::~gBackSave ************************
@@ -88,7 +88,7 @@ void gBackSave::save(gDisplayPort &port) {
port.displayPage->readPixels(savedRegion,
savedPixels.data,
savedPixels.size.x);
- saved = TRUE;
+ saved = true;
}
}
@@ -111,7 +111,7 @@ void gBackSave::restore(gDisplayPort &port) {
port.displayPage->writePixels(savedRegion,
savedPixels.data,
savedPixels.size.x);
- saved = FALSE;
+ saved = false;
}
}
diff --git a/engines/saga2/vbacksav.h b/engines/saga2/vbacksav.h
index 51aa1ed993..5656010415 100644
--- a/engines/saga2/vbacksav.h
+++ b/engines/saga2/vbacksav.h
@@ -37,7 +37,7 @@ namespace Saga2 {
class gBackSave : private gPort {
Rect16 savedRegion; // extent of saved region
gPixelMap savedPixels; // buffer of saved pixels
- bool saved; // TRUE = saved.
+ bool saved; // true = saved.
public:
gBackSave(const Rect16 &extent);
diff --git a/engines/saga2/videobox.cpp b/engines/saga2/videobox.cpp
index 0a73e66c9d..f236be3891 100644
--- a/engines/saga2/videobox.cpp
+++ b/engines/saga2/videobox.cpp
@@ -71,9 +71,9 @@ bool CVideoBox::activate(gEventType why) {
if (why == gEventMouseDown) { // momentarily depress
selected = 1;
notify(why, 0); // notify App of successful hit
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
void CVideoBox::pointerMove(gPanelMessage &) {
@@ -94,7 +94,7 @@ bool CVideoBox::pointerHit(gPanelMessage &) {
}
activate(gEventMouseDown);
- return TRUE;
+ return true;
}
void CVideoBox::pointerDrag(gPanelMessage &) {
@@ -128,7 +128,7 @@ void CVideoBox::init(void) {
// set the result info to nominal startup values
rInfo.result = -1;
- rInfo.running = TRUE;
+ rInfo.running = true;
// init the resource context handle
decRes = resFile->newContext(MKTAG('V', 'I', 'D', 'O'),
@@ -156,7 +156,7 @@ int16 CVideoBox::openVidBox(char *fileName) {
g_vm->startVideo(fileName, x + borderWidth, y + borderWidth);
// run this modal event loop
- //EventLoop( rInfo.running, TRUE );
+ //EventLoop( rInfo.running, true );
rInfo.running = g_vm->checkVideo();
while (rInfo.running)
rInfo.running = g_vm->checkVideo();
diff --git a/engines/saga2/vwdraw.cpp b/engines/saga2/vwdraw.cpp
index a046179086..3ee226f21c 100644
--- a/engines/saga2/vwdraw.cpp
+++ b/engines/saga2/vwdraw.cpp
@@ -173,7 +173,7 @@ void gDisplayPort::scrollPixels(
void gDisplayPort::line(int16 x1, int16 y1, int16 x2, int16 y2) {
#if 0
- bool clipNeeded = FALSE;
+ bool clipNeeded = false;
int16 xAbs, yAbs,
xMove, yMove,
@@ -190,13 +190,13 @@ void gDisplayPort::line(int16 x1, int16 y1, int16 x2, int16 y2) {
if (x1 > x2) { // drawing left
if (x1 < clip.x || x2 >= clipRight) return;
- if (x2 < clip.x || x1 >= clipRight) clipNeeded = TRUE;
+ if (x2 < clip.x || x1 >= clipRight) clipNeeded = true;
xDir = xMove = -1; // amount to adjust address
xAbs = x1 - x2; // length of line
} else { // drawing right
if (x2 < clip.x || x1 >= clipRight) return;
- if (x1 < clip.x || x2 >= clipRight) clipNeeded = TRUE;
+ if (x1 < clip.x || x2 >= clipRight) clipNeeded = true;
xDir = xMove = 1; // amount to adjust address
xAbs = x2 - x1; // length of line
@@ -204,14 +204,14 @@ void gDisplayPort::line(int16 x1, int16 y1, int16 x2, int16 y2) {
if (y1 > y2) { // drawing up
if (y1 < clip.y || y2 >= clipBottom) return;
- if (y2 < clip.y || y1 >= clipBottom) clipNeeded = TRUE;
+ if (y2 < clip.y || y1 >= clipBottom) clipNeeded = true;
yDir = -1;
yAbs = y1 - y2;
yMove = -displayPage->size.x;
} else { // drawing down
if (y2 < clip.y || y1 >= clipBottom) return;
- if (y1 < clip.y || y2 >= clipBottom) clipNeeded = TRUE;
+ if (y1 < clip.y || y2 >= clipBottom) clipNeeded = true;
yDir = 1;
yAbs = y2 - y1;
diff --git a/engines/saga2/vwpage.cpp b/engines/saga2/vwpage.cpp
index b7b9438e22..8630e1bc37 100644
--- a/engines/saga2/vwpage.cpp
+++ b/engines/saga2/vwpage.cpp
@@ -187,7 +187,7 @@ void BltDDRect(Rect16 &r, uint8 *srcPtr, bool bTransparent, uint16 pixMod, bool
uint32 pagex, pagey;
uint32 i;
uint32 offy = r.y;
- bool show = FALSE;
+ bool show = false;
if (!displayEnabled()) //ddWindow || !ddWindow->bIsActive )
return;
@@ -198,7 +198,7 @@ void BltDDRect(Rect16 &r, uint8 *srcPtr, bool bTransparent, uint16 pixMod, bool
ourBlitter = _BltPixelsT;
else {
ourBlitter = _BltPixels;
- show = TRUE;
+ show = true;
}
start = r.x + (r.y * ddWindow->lPitch); // starting rect offset
@@ -357,7 +357,7 @@ void vWDisplayPage::writeTransPixels(Rect16 &r, uint8 *pixPtr, uint16 pixMod) {
}
void vWDisplayPage::readPixels(Rect16 &r, uint8 *pixPtr, uint16 pixMod) {
- BltDDRect(r, pixPtr, FALSE, pixMod, FALSE);
+ BltDDRect(r, pixPtr, false, pixMod, false);
}
// Function to quickly transfer pixels from an off-screen
Commit: 6d09e62b2bc158e56bb87b557cc239d42833c2fb
https://github.com/scummvm/scummvm/commit/6d09e62b2bc158e56bb87b557cc239d42833c2fb
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:09+02:00
Commit Message:
SAGA2: Add more debug messages
Changed paths:
engines/saga2/tile.cpp
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index e897072e47..58ac6b0d24 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -2922,10 +2922,12 @@ inline void drawMetaTiles(void) {
viewPos.x = (tileScroll.x >> tileDXShift)
- (platformWidth * mapList[currentMapNum].mapSize),
- viewPos.y = (platformWidth
- * mapList[currentMapNum].mapSize
- * tileDX)
- - tileScroll.y;
+ viewPos.y = (platformWidth
+ * mapList[currentMapNum].mapSize
+ * tileDX)
+ - tileScroll.y;
+
+ debugC(2, kDebugTiles, "viewPos = (%d,%d)", viewPos.x, viewPos.y);
// coordinates of the view window upper left corner in U,V
@@ -2935,17 +2937,21 @@ inline void drawMetaTiles(void) {
/ (platformWidth * 2);
baseCoords.z = 0;
+ debugC(2, kDebugTiles, "baseCoords = (%d,%d,%d)", baseCoords.u, baseCoords.v, baseCoords.z);
+
setAreaSound(baseCoords); //+TilePoint(tileRectWidth, tileRectHeight,0));
updateHandleRefs(baseCoords); // viewPoint, &sti );
// coordinates of current metatile (in X,Y), relative to screen
metaPos.x = (baseCoords.u - baseCoords.v) * metaDX
- - viewPos.x * tileDX;
+ - viewPos.x * tileDX;
metaPos.y = viewPos.y
- (baseCoords.u + baseCoords.v) * metaDY;
+ debugC(2, kDebugTiles, "metaPos = (%d,%d)", metaPos.x, metaPos.y);
+
// Loop through each horizontal row of metatiles
// REM: also account for highest possible platform
// (replace 256 constant with better value)
@@ -4613,6 +4619,7 @@ void updateMainDisplay(void) {
// Get the coordinates of the object which the camera is tracking
getViewTrackPos(trackPos);
+ debugC(1, kDebugTiles, "trackPos = (%d,%d,%d)", trackPos.u, trackPos.v, trackPos.z);
viewDiff = trackPos - lastViewLoc;
lastViewLoc = trackPos;
@@ -4631,6 +4638,7 @@ void updateMainDisplay(void) {
targetScroll.y =
curMap->mapHeight - (trackPos.u + trackPos.v)
- trackPos.z - tileRect.height / 2 - 32;
+ debugC(1, kDebugTiles, "targetScroll = (%d,%d)", targetScroll.x, targetScroll.y);
// Compute the delta vector between the current scroll position
// and the desired scroll position, and also compute the
Commit: 9d8887f2970f09fe139924e60e8c3e0245241887
https://github.com/scummvm/scummvm/commit/9d8887f2970f09fe139924e60e8c3e0245241887
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:09+02:00
Commit Message:
SAGA2: Cleanup weapons.h
Changed paths:
engines/saga2/weapons.h
diff --git a/engines/saga2/weapons.h b/engines/saga2/weapons.h
index 8445ff505d..5e8f2bfd4f 100644
--- a/engines/saga2/weapons.h
+++ b/engines/saga2/weapons.h
@@ -45,69 +45,45 @@ public:
WeaponEffect(void) : next(NULL) {}
virtual ~WeaponEffect(void) {}
- virtual void implement(
- Actor *enactor,
- GameObject *target,
- GameObject *strikingObj,
- uint8 strength) = 0;
+ virtual void implement(Actor *enactor, GameObject *target, GameObject *strikingObj, uint8 strength) = 0;
};
//-----------------------------------------------------------------------
class WeaponProtoEffect : public WeaponEffect {
- ProtoEffect *effect;
+ ProtoEffect *effect;
public:
- WeaponProtoEffect(Common::SeekableReadStream *stream) :
- effect(createNewProtoEffect(stream)) {
+ WeaponProtoEffect(Common::SeekableReadStream *stream) : effect(createNewProtoEffect(stream)) {
}
~WeaponProtoEffect(void);
- void implement(
- Actor *enactor,
- GameObject *target,
- GameObject *strikingObj,
- uint8 strength);
+ void implement(Actor *enactor, GameObject*target, GameObject *strikingObj, uint8 strength);
};
//-----------------------------------------------------------------------
class WeaponStrikeEffect : public WeaponEffect {
- effectDamageTypes type; // damage type
- int8 dice, // # of dice to roll
- sides, // # of sides on dice
- skillDice, // multiply additional dice
- base, // absolute damage amount
- skillBase;
+ effectDamageTypes type; // damage type
+ int8 dice; // # of dice to roll
+ int8 sides; // # of sides on dice
+ int8 skillDice; // multiply additional dice
+ int8 base; // absolute damage amount
+ int8 skillBase;
public:
- WeaponStrikeEffect(
- effectDamageTypes t,
- int8 d,
- int8 s,
- int8 sd,
- int8 b,
- int8 sb) :
- type(t),
- dice(d),
- sides(s),
- skillDice(sd),
- base(b),
- skillBase(sb) {
+ WeaponStrikeEffect(effectDamageTypes t, int8 d, int8 s, int8 sd, int8 b, int8 sb) :
+ type(t), dice(d), sides(s), skillDice(sd), base(b), skillBase(sb) {
}
- void implement(
- Actor *enactor,
- GameObject *target,
- GameObject *strikingObj,
- uint8 strength);
+ void implement(Actor *enactor, GameObject *target, GameObject *strikingObj, uint8 trength);
};
//-----------------------------------------------------------------------
class WeaponStuff {
- weaponID master; // index in array
- WeaponEffect *effects; // the effects of this weapon
+ weaponID master; // index in array
+ WeaponEffect *effects; // the effects of this weapon
public:
WeaponStuff();
@@ -118,11 +94,7 @@ public:
void addEffect(WeaponEffect *we);
void addEffect(Common::SeekableReadStream *stream);
void killEffects(void);
- void implement(
- Actor *enactor,
- GameObject *target,
- GameObject *strikingObj,
- uint8 strength);
+ void implement(Actor *enactor, GameObject *target, GameObject *strikingObj, uint8 strength);
};
//-----------------------------------------------------------------------
Commit: c9d0eb45d0db44bf9ce8a1b25833f3b1a0a0dab6
https://github.com/scummvm/scummvm/commit/c9d0eb45d0db44bf9ce8a1b25833f3b1a0a0dab6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:09+02:00
Commit Message:
SAGA2: Rename class viariables in weapons.h
Changed paths:
engines/saga2/weapons.cpp
engines/saga2/weapons.h
diff --git a/engines/saga2/weapons.cpp b/engines/saga2/weapons.cpp
index e1cf42dcf4..91d00f8133 100644
--- a/engines/saga2/weapons.cpp
+++ b/engines/saga2/weapons.cpp
@@ -143,15 +143,15 @@ GameObject *getShieldItem(GameObject *defender) {
WeaponProtoEffect member functions
* ===================================================================== */
WeaponProtoEffect::~WeaponProtoEffect(void) {
- if (effect != NULL)
- delete effect;
+ if (_effect != NULL)
+ delete _effect;
}
void WeaponProtoEffect::implement(Actor *enactor, GameObject *target, GameObject *, uint8) {
SpellTarget targ(target);
- if (effect != NULL)
- effect->implement(enactor, &targ);
+ if (_effect != NULL)
+ _effect->implement(enactor, &targ);
}
/* ===================================================================== *
@@ -164,44 +164,44 @@ void WeaponStrikeEffect::implement(Actor *enactor, GameObject *target, GameObjec
int8 totalDice, totalBase;
- totalDice = dice + strength * skillDice;
- totalBase = base + strength * skillBase;
+ totalDice = _dice + strength * _skillDice;
+ totalBase = _base + strength * _skillBase;
- target->acceptDamage(enactor->thisID(), totalBase, type, totalDice, sides);
+ target->acceptDamage(enactor->thisID(), totalBase, _type, totalDice, _sides);
}
WeaponStuff::WeaponStuff() {
- effects = NULL;
- master = nullWeapon;
+ _effects = NULL;
+ _master = nullWeapon;
}
WeaponStuff::~WeaponStuff() {
- while (effects != NULL) {
- WeaponEffect *curEffect = effects;
+ while (_effects != NULL) {
+ WeaponEffect *curEffect = _effects;
- effects = effects->next;
+ _effects = _effects->_next;
delete curEffect;
}
- master = nullWeapon;
+ _master = nullWeapon;
}
void WeaponStuff::killEffects(void) {
- while (effects != NULL) {
- WeaponEffect *curEffect = effects;
+ while (_effects != NULL) {
+ WeaponEffect *curEffect = _effects;
- effects = effects->next;
+ _effects = _effects->_next;
delete curEffect;
}
}
void WeaponStuff::addEffect(WeaponEffect *we) {
- WeaponEffect *e = effects;
- if (effects) {
- while (e->next)
- e = e->next;
- e->next = we;
+ WeaponEffect *e = _effects;
+ if (_effects) {
+ while (e->_next)
+ e = e->_next;
+ e->_next = we;
} else {
- effects = we;
+ _effects = we;
}
}
@@ -234,18 +234,18 @@ void WeaponStuff::addEffect(Common::SeekableReadStream *stream) {
if (we == NULL)
error("failed to alloc weapon effect");
- if (effects == NULL)
- effects = we;
+ if (_effects == NULL)
+ _effects = we;
else {
WeaponEffect *tail;
- for (tail = effects; tail->next; tail = tail->next)
+ for (tail = _effects; tail->_next; tail = tail->_next)
;
- tail->next = we;
+ tail->_next = we;
}
}
void WeaponStuff::implement(Actor *enactor, GameObject *target, GameObject *strikingObj, uint8 strength) {
- for (WeaponEffect *we = effects; we != NULL; we = we->next)
+ for (WeaponEffect *we = _effects; we != NULL; we = we->_next)
we->implement(enactor, target, strikingObj, strength);
}
diff --git a/engines/saga2/weapons.h b/engines/saga2/weapons.h
index 5e8f2bfd4f..616b84a392 100644
--- a/engines/saga2/weapons.h
+++ b/engines/saga2/weapons.h
@@ -41,9 +41,9 @@ ProtoEffect *createNewProtoEffect(Common::SeekableReadStream *stream);
class WeaponEffect {
public:
- WeaponEffect *next; // pointer to additional effects
+ WeaponEffect *_next; // pointer to additional effects
- WeaponEffect(void) : next(NULL) {}
+ WeaponEffect(void) : _next(NULL) {}
virtual ~WeaponEffect(void) {}
virtual void implement(Actor *enactor, GameObject *target, GameObject *strikingObj, uint8 strength) = 0;
};
@@ -51,10 +51,10 @@ public:
//-----------------------------------------------------------------------
class WeaponProtoEffect : public WeaponEffect {
- ProtoEffect *effect;
+ ProtoEffect *_effect;
public:
- WeaponProtoEffect(Common::SeekableReadStream *stream) : effect(createNewProtoEffect(stream)) {
+ WeaponProtoEffect(Common::SeekableReadStream *stream) : _effect(createNewProtoEffect(stream)) {
}
~WeaponProtoEffect(void);
@@ -64,16 +64,16 @@ public:
//-----------------------------------------------------------------------
class WeaponStrikeEffect : public WeaponEffect {
- effectDamageTypes type; // damage type
- int8 dice; // # of dice to roll
- int8 sides; // # of sides on dice
- int8 skillDice; // multiply additional dice
- int8 base; // absolute damage amount
- int8 skillBase;
+ effectDamageTypes _type;// damage type
+ int8 _dice; // # of dice to roll
+ int8 _sides; // # of sides on dice
+ int8 _skillDice; // multiply additional dice
+ int8 _base; // absolute damage amount
+ int8 _skillBase;
public:
WeaponStrikeEffect(effectDamageTypes t, int8 d, int8 s, int8 sd, int8 b, int8 sb) :
- type(t), dice(d), sides(s), skillDice(sd), base(b), skillBase(sb) {
+ _type(t), _dice(d), _sides(s), _skillDice(sd), _base(b), _skillBase(sb) {
}
void implement(Actor *enactor, GameObject *target, GameObject *strikingObj, uint8 trength);
@@ -82,14 +82,14 @@ public:
//-----------------------------------------------------------------------
class WeaponStuff {
- weaponID master; // index in array
- WeaponEffect *effects; // the effects of this weapon
+ weaponID _master; // index in array
+ WeaponEffect *_effects; // the effects of this weapon
public:
WeaponStuff();
~WeaponStuff();
void setID(weaponID id) {
- master = id;
+ _master = id;
}
void addEffect(WeaponEffect *we);
void addEffect(Common::SeekableReadStream *stream);
Commit: 364c3469afb2d97b2cab1bc32ad3add0ebdd9a45
https://github.com/scummvm/scummvm/commit/364c3469afb2d97b2cab1bc32ad3add0ebdd9a45
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:09+02:00
Commit Message:
SAGA2: Implement maskTile() and do cleanups
Changed paths:
engines/saga2/blitters.cpp
engines/saga2/blitters.h
engines/saga2/tile.h
engines/saga2/tileload.cpp
diff --git a/engines/saga2/blitters.cpp b/engines/saga2/blitters.cpp
index 16475c7989..3ceb6cb4a5 100644
--- a/engines/saga2/blitters.cpp
+++ b/engines/saga2/blitters.cpp
@@ -125,7 +125,7 @@ void unpackSprite(gPixelMap *map, uint8 *sprData) {
}
}
-void drawTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData) {
+void drawTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData, bool mask) {
const byte *tilePointer;
const byte *readPointer;
byte *drawPointer;
@@ -188,7 +188,10 @@ void drawTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData) {
if (colDiff > 0) {
byte *dst = (byte *)(drawPointer + count);
- memcpy(dst, (readPointer + count), colDiff);
+ if (mask)
+ memset(dst, 0, colDiff);
+ else
+ memcpy(dst, (readPointer + count), colDiff);
col += colDiff;
}
}
@@ -230,7 +233,7 @@ void drawTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData) {
void maskTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData) {
- warning("STUB: maskTile()");
+ drawTile(map, x, y, height, srcData, true);
}
void TBlit(gPixelMap *dstMap, gPixelMap *srcMap, int xpos, int ypos) {
diff --git a/engines/saga2/blitters.h b/engines/saga2/blitters.h
index 9fb4269dc4..955ab1984c 100644
--- a/engines/saga2/blitters.h
+++ b/engines/saga2/blitters.h
@@ -31,86 +31,27 @@ namespace Saga2 {
class gPixelMap;
-// VWPAGE.CPP , GDRAW.CPP
+void _BltPixels(uint8 *srcPtr, uint32 srcMod, uint8 *dstPtr, uint32 dstMod, uint32 width, uint32 height);
-// Assembly-language function to copy pixel to SVGA (opaque)
-
-void _BltPixels(uint8 *srcPtr, uint32 srcMod,
- uint8 *dstPtr, uint32 dstMod,
- uint32 width, uint32 height);
-
-// Assembly-language function to copy pixel to SVGA (transparent)
-
-void _BltPixelsT(uint8 *srcPtr, uint32 srcMod,
- uint8 *dstPtr, uint32 dstMod,
- uint32 width, uint32 height);
-
-// Assembly-language function to do rectangle fill (opaque)
-
-void _FillRect(uint8 *dstPtr, uint32 dstMod,
- uint32 width, uint32 height, uint32 color);
-
-// Assembly-language function to draw horizontal line (opaque)
+void _BltPixelsT(uint8 *srcPtr, uint32 srcMod, uint8 *dstPtr, uint32 dstMod, uint32 width, uint32 height);
+void _FillRect(uint8 *dstPtr, uint32 dstMod, uint32 width, uint32 height, uint32 color);
void _HLine(uint8 *dstPtr, uint32 width, uint32 color);
-/* ===================================================================== *
- RUNLEN.ASM
- * ===================================================================== */
-
-// INTRFACE.CPP, PLAYMODE.CPP
-
-void unpackImage(gPixelMap *map,
- int32 width,
- int32 rowCount,
- int8 *srcData);
-
-void unpackImage(gPixelMap &map,
- int16 width,
- int16 rowCount,
- int8 *srcData);
-/* ===================================================================== *
- SPRDRAW.ASM
- * ===================================================================== */
-
-// SPRITE.CPP
+void unpackImage(gPixelMap *map, int32 width, int32 rowCount, int8 *srcData);
+void unpackImage(gPixelMap &map, int16 width, int16 rowCount, int8 *srcData);
void unpackSprite(gPixelMap *map, uint8 *sprData);
-void compositePixels(
- gPixelMap *compMap,
- gPixelMap *sprMap,
- int32 xpos,
- int32 ypos,
- uint8 *lookup);
-void compositePixelsRvs(
- gPixelMap *compMap,
- gPixelMap *sprMap,
- int32 xpos,
- int32 ypos,
- uint8 *lookup);
-
-// FTA.H, AUTOMAP.CPP, DISPNODE.CPP, INTRFACE.CPP, MOUSEIMG.CPP, SPRITE.CPP
-// TILE.CPP, ITEVIDEO.CPP
+void compositePixels(gPixelMap *compMap, gPixelMap *sprMap, int32 xpos, int32 ypos, uint8 *lookup);
+void compositePixelsRvs(gPixelMap *compMap, gPixelMap *sprMap, int32 xpos, int32 ypos, uint8 *lookup);
// Fast transparent blitting routine in assembly
-
void TBlit(gPixelMap *d, gPixelMap *s, int32 x, int32 y);
void TBlit4(gPixelMap *d, gPixelMap *s, int32 x, int32 y);
-/* ===================================================================== *
- TILEDRAW.ASM
- * ===================================================================== */
-
-// TILE.H, TILELOAD.CPP
-
-void drawTile(gPixelMap *map,
- int32 x, int32 y, int32 height,
- uint8 *srcData);
-
-void maskTile(gPixelMap *map,
- int32 x, int32 y, int32 height,
- uint8 *srcData);
+void drawTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData, bool mask = false);
+void maskTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData);
} // end of namespace Saga2
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index dfd186dae3..f3f9d1b425 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -326,36 +326,20 @@ public:
* ===================================================================== */
struct TileRef {
- TileID tile; // which tile
- uint8 flags; // tile flags
- uint8 tileHeight; // height of tile above platform
+ TileID tile; // which tile
+ uint8 flags; // tile flags
+ uint8 tileHeight; // height of tile above platform
};
enum tileRefFlags {
- trTileTAG = (1 << 0), // this tile part of a TAG
- trTileHidden = (1 << 1), // tile hidden when covered
- trTileFlipped = (1 << 2), // draw tile flipped horizontal
- trTileSensitive = (1 << 3), // tile is triggerable (TAG only)
+ trTileTAG = (1 << 0), // this tile part of a TAG
+ trTileHidden = (1 << 1), // tile hidden when covered
+ trTileFlipped = (1 << 2), // draw tile flipped horizontal
+ trTileSensitive = (1 << 3) // tile is triggerable (TAG only)
};
-typedef TileRef *TileRefPtr,
- * *TileRefHandle;
+typedef TileRef *TileRefPtr, **TileRefHandle;
-/* ===================================================================== *
- Assembly-language tile-drawing functions
- * ===================================================================== */
-
-// moved to FTAASM.H
-
-#ifndef FTAASM_H
-extern void drawTile(gPixelMap *map,
- int32 x, int32 y, int32 height,
- uint8 *srcData);
-
-extern void maskTile(gPixelMap *map,
- int32 x, int32 y, int32 height,
- uint8 *srcData);
-#endif
void drawMainDisplay(void);
/* ===================================================================== *
diff --git a/engines/saga2/tileload.cpp b/engines/saga2/tileload.cpp
index 968bf896fe..ef846561ca 100644
--- a/engines/saga2/tileload.cpp
+++ b/engines/saga2/tileload.cpp
@@ -31,6 +31,7 @@
#include "saga2/tile.h"
#include "saga2/hresmgr.h"
#include "saga2/oncall.h"
+#include "saga2/blitters.h"
namespace Saga2 {
Commit: 26f6c564ed0879d26bd849cabc35a00e8df67e0f
https://github.com/scummvm/scummvm/commit/26f6c564ed0879d26bd849cabc35a00e8df67e0f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:09+02:00
Commit Message:
SAGA2: Remove ReadTimer()
Changed paths:
R engines/saga2/input.cpp
engines/saga2/input.h
engines/saga2/panel.cpp
engines/saga2/panel.h
diff --git a/engines/saga2/input.cpp b/engines/saga2/input.cpp
deleted file mode 100644
index f9939c6ff3..0000000000
--- a/engines/saga2/input.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#include "saga2/std.h"
-#include "saga2/input.h"
-
-namespace Saga2 {
-
-void InitMouse(int16 width, int16 height) {
- warning("STUB: InitMouse()");
-}
-
-void CleanupMouse(void) {
- warning("STUB: CleanupMouse()");
-}
-
-gTimeStamp ReadTimer() {
- warning("STUB: ReadTimer()");
- return 0;
-}
-
-bool ReadKeyboard(int &key, int &qual) {
- warning("STUB: ReadKeyboard()");
- return false;
-}
-
-} // end of namespace Saga2
diff --git a/engines/saga2/input.h b/engines/saga2/input.h
index 949c430705..e0f3984078 100644
--- a/engines/saga2/input.h
+++ b/engines/saga2/input.h
@@ -117,7 +117,6 @@ void CleanupMouse(void);
void ReadMouse(gMouseState &st);
uint16 ReadQualifiers(void);
bool ReadKeyboard(int &key, int &qual);
-gTimeStamp ReadTimer(void);
bool DoubleClick(gTimeStamp oldTime);
} // end of namespace Saga2
diff --git a/engines/saga2/panel.cpp b/engines/saga2/panel.cpp
index fff13560c1..4bb91243dd 100644
--- a/engines/saga2/panel.cpp
+++ b/engines/saga2/panel.cpp
@@ -922,8 +922,7 @@ void gToolBase::handleMouse(Common::Event &event, uint32 time) {
// 1/3 of a second, and that the mouse ptr hasn't moved
// very much.
- if (((uint32)(msg.timeStamp - lastClickTime)
- < (ticksPerSecond * 2 / 3))
+ if (((uint32)(msg.timeStamp - lastClickTime) < 333)
|| _curMouseState.left > 1
|| _curMouseState.right > 1) {
Point16 diff = lastClickPos - _curMouseState.pos;
@@ -978,7 +977,7 @@ void gToolBase::handleMouse(Common::Event &event, uint32 time) {
}
void gToolBase::leavePanel(void) {
- msg.timeStamp = ReadTimer();
+ msg.timeStamp = g_system->getMillis();
if (mousePanel) {
msg.inPanel = 0;
@@ -1013,7 +1012,7 @@ void gToolBase::handleKeyStroke(Common::Event &event) {
msg.pointerLeave = 0;
msg.key = ((key & 0xFF) != 0) ? key & 0xff : (key >> 8) + 0x80;
msg.qualifier = qualifier;
- msg.timeStamp = ReadTimer();
+ msg.timeStamp = g_system->getMillis();
if (activePanel) { // send keystroke to active panel
setMsg(msg, activePanel); // set up gPanelMessage
@@ -1067,7 +1066,7 @@ void gToolBase::handleTimerTick(int32 tick) {
setMsg(msg, mousePanel); // set up gPanelMessage
mousePanel->pointerMove(msg);
} else if (!mouseHintSet
- && ((uint32)(tick - lastMouseMoveTime) > ticksPerSecond / 2)) {
+ && ((uint32)(tick - lastMouseMoveTime) > 500)) {
mousePanel->onMouseHintDelay();
}
}
diff --git a/engines/saga2/panel.h b/engines/saga2/panel.h
index 9967c132d2..ad0867d131 100644
--- a/engines/saga2/panel.h
+++ b/engines/saga2/panel.h
@@ -237,7 +237,7 @@ public:
uint16 key, // keystroke from keyboard
qualifier; // qualifier from keyboard
- int32 timeStamp; // time of message
+ uint32 timeStamp; // time of message
};
/* ===================================================================== *
Commit: c7fad67025025fb5b7b727b44a014d6c12a08447
https://github.com/scummvm/scummvm/commit/c7fad67025025fb5b7b727b44a014d6c12a08447
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:09+02:00
Commit Message:
SAGA2: Remove input.cpp
Changed paths:
engines/saga2/input.h
engines/saga2/module.mk
engines/saga2/panel.cpp
diff --git a/engines/saga2/input.h b/engines/saga2/input.h
index e0f3984078..61ee551bf8 100644
--- a/engines/saga2/input.h
+++ b/engines/saga2/input.h
@@ -110,15 +110,6 @@ struct gMouseState {
left;
};
-typedef uint32 gTimeStamp;
-
-void InitMouse(int16 width, int16 height);
-void CleanupMouse(void);
-void ReadMouse(gMouseState &st);
-uint16 ReadQualifiers(void);
-bool ReadKeyboard(int &key, int &qual);
-bool DoubleClick(gTimeStamp oldTime);
-
} // end of namespace Saga2
#endif
diff --git a/engines/saga2/module.mk b/engines/saga2/module.mk
index 5d9108a099..3afe0399f8 100644
--- a/engines/saga2/module.mk
+++ b/engines/saga2/module.mk
@@ -32,7 +32,6 @@ MODULE_OBJS := \
gtextbox.o \
hresmgr.o \
imagcach.o \
- input.o \
interp.o \
intrface.o \
keybored.o \
diff --git a/engines/saga2/panel.cpp b/engines/saga2/panel.cpp
index 4bb91243dd..f556fea53d 100644
--- a/engines/saga2/panel.cpp
+++ b/engines/saga2/panel.cpp
@@ -1088,12 +1088,10 @@ void HandleTimerTick(long tick) {
void initPanels(gDisplayPort &port) {
port.setDisplayPage(&protoPage);
globalPort = &port;
- InitMouse(gDisplaySize.x, gDisplaySize.y);
mainFont = &Helv11Font;
}
void cleanupPanels(void) {
- CleanupMouse();
}
int16 leftButtonState(void) {
Commit: 2f10c15f9f99dc6ded792cb5146f422cad0214a5
https://github.com/scummvm/scummvm/commit/2f10c15f9f99dc6ded792cb5146f422cad0214a5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:09+02:00
Commit Message:
SAGA2: Fix warning in motion.h
Changed paths:
engines/saga2/motion.cpp
engines/saga2/motion.h
diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp
index 7ff85fa035..0d6a77cf52 100644
--- a/engines/saga2/motion.cpp
+++ b/engines/saga2/motion.cpp
@@ -620,7 +620,7 @@ void *MotionTask::restore(void *buf) {
enactorID = *((ObjectID *)buf);
buf = (ObjectID *)buf + 1;
- enactor = enactorID != Nothing
+ o.enactor = enactorID != Nothing
? (Actor *)GameObject::objectAddress(enactorID)
: NULL;
}
@@ -649,7 +649,7 @@ void *MotionTask::restore(void *buf) {
|| motionType == motionTypeDropObject
|| motionType == motionTypeDropObjectOnObject
|| motionType == motionTypeDropObjectOnTAI) {
- directObject = *((ObjectID *)buf) != Nothing
+ o.directObject = *((ObjectID *)buf) != Nothing
? GameObject::objectAddress(*((ObjectID *)buf))
: NULL;
buf = (ObjectID *)buf + 1;
@@ -659,7 +659,7 @@ void *MotionTask::restore(void *buf) {
if (motionType == motionTypeUseObjectOnObject
|| motionType == motionTypeDropObjectOnObject) {
- indirectObject = *((ObjectID *)buf) != Nothing
+ o.indirectObject = *((ObjectID *)buf) != Nothing
? GameObject::objectAddress(
*((ObjectID *)buf))
: NULL;
@@ -667,7 +667,7 @@ void *MotionTask::restore(void *buf) {
} else {
if (motionType == motionTypeUseObjectOnTAI
|| motionType == motionTypeDropObjectOnTAI) {
- TAI = *((ActiveItemID *)buf) != NoActiveItem
+ o.TAI = *((ActiveItemID *)buf) != NoActiveItem
? ActiveItem::activeItemAddress(
*((ActiveItemID *)buf))
: NULL;
@@ -682,7 +682,7 @@ void *MotionTask::restore(void *buf) {
}
}
} else if (motionType == motionTypeUseTAI) {
- TAI = *((ActiveItemID *)buf) != NoActiveItem
+ o.TAI = *((ActiveItemID *)buf) != NoActiveItem
? ActiveItem::activeItemAddress(*((ActiveItemID *)buf))
: NULL;
buf = (ActiveItemID *)buf + 1;
@@ -763,16 +763,16 @@ void *MotionTask::restore(void *buf) {
buf = (ObjectID *)buf + 2;
// Convert IDs to pointers
- attacker = attackerID != Nothing
+ d.attacker = attackerID != Nothing
? (Actor *)GameObject::objectAddress(attackerID)
: NULL;
- defensiveObj = defensiveObjID != Nothing
+ d.defensiveObj = defensiveObjID != Nothing
? GameObject::objectAddress(defensiveObjID)
: NULL;
// Restore the defense flags
- defenseFlags = *((uint8 *)buf);
+ d.defenseFlags = *((uint8 *)buf);
buf = (uint8 *)buf + 1;
// Restore the action counter
@@ -794,7 +794,7 @@ void *MotionTask::restore(void *buf) {
buf = (ObjectID *)buf + 1;
// Convert ID to pointer
- attacker = attackerID != Nothing
+ d.attacker = attackerID != Nothing
? (Actor *)GameObject::objectAddress(attackerID)
: NULL;
@@ -915,7 +915,7 @@ int32 MotionTask::archiveSize(void) {
size += sizeof(direction)
+ sizeof(ObjectID) // attacker ID
+ sizeof(ObjectID) // defensiveObj ID
- + sizeof(defenseFlags)
+ + sizeof(d.defenseFlags)
+ sizeof(actionCounter);
if (motionType = motionTypeOneHandedParry)
@@ -1025,8 +1025,8 @@ void *MotionTask::archive(void *buf) {
*((ObjectID *)buf) = targetObjID;
buf = (ObjectID *)buf + 1;
- enactorID = enactor != NULL
- ? enactor->thisID()
+ enactorID = o.enactor != NULL
+ ? o.enactor->thisID()
: Nothing;
*((ObjectID *)buf) = enactorID;
@@ -1054,8 +1054,8 @@ void *MotionTask::archive(void *buf) {
|| motionType == motionTypeDropObject
|| motionType == motionTypeDropObjectOnObject
|| motionType == motionTypeDropObjectOnTAI) {
- *((ObjectID *)buf) = directObject != NULL
- ? directObject->thisID()
+ *((ObjectID *)buf) = o.directObject != NULL
+ ? o.directObject->thisID()
: Nothing;
buf = (ObjectID *)buf + 1;
@@ -1064,15 +1064,15 @@ void *MotionTask::archive(void *buf) {
if (motionType == motionTypeUseObjectOnObject
|| motionType == motionTypeDropObjectOnObject) {
- *((ObjectID *)buf) = indirectObject != NULL
- ? indirectObject->thisID()
+ *((ObjectID *)buf) = o.indirectObject != NULL
+ ? o.indirectObject->thisID()
: Nothing;
buf = (ObjectID *)buf + 1;
} else {
if (motionType == motionTypeUseObjectOnTAI
|| motionType == motionTypeDropObjectOnTAI) {
- *((ActiveItemID *)buf) = TAI != NULL
- ? TAI->thisID()
+ *((ActiveItemID *)buf) = o.TAI != NULL
+ ? o.TAI->thisID()
: NoActiveItem;
buf = (ActiveItemID *)buf + 1;
}
@@ -1085,8 +1085,8 @@ void *MotionTask::archive(void *buf) {
}
}
} else if (motionType == motionTypeUseTAI) {
- *((ActiveItemID *)buf) = TAI != NULL
- ? TAI->thisID()
+ *((ActiveItemID *)buf) = o.TAI != NULL
+ ? o.TAI->thisID()
: NoActiveItem;
buf = (ActiveItemID *)buf + 1;
@@ -1161,8 +1161,8 @@ void *MotionTask::archive(void *buf) {
*((Direction *)buf) = direction;
buf = (Direction *)buf + 1;
- attackerID = attacker != NULL ? attacker->thisID() : Nothing;
- defensiveObjID = defensiveObj != NULL ? defensiveObj->thisID() : Nothing;
+ attackerID = d.attacker != NULL ? d.attacker->thisID() : Nothing;
+ defensiveObjID = d.defensiveObj != NULL ? d.defensiveObj->thisID() : Nothing;
// Store the attacker's and defensive object's IDs
*((ObjectID *)buf) = attackerID;
@@ -1170,7 +1170,7 @@ void *MotionTask::archive(void *buf) {
buf = (ObjectID *)buf + 2;
// Store the defense flags
- *((uint8 *)buf) = defenseFlags;
+ *((uint8 *)buf) = d.defenseFlags;
buf = (uint8 *)buf + 1;
// Store the action counter
@@ -1187,7 +1187,7 @@ void *MotionTask::archive(void *buf) {
|| motionType == motionTypeFallDown) {
ObjectID attackerID;
- attackerID = attacker != NULL ? attacker->thisID() : Nothing;
+ attackerID = d.attacker != NULL ? d.attacker->thisID() : Nothing;
// Store the attacker's ID
*((ObjectID *)buf) = attackerID;
@@ -1396,7 +1396,7 @@ void MotionTask::shootObject(
obj.missileFacing = missileDir(mt->velocity);
mt->motionType = motionTypeShot;
- mt->enactor = &doer;
+ mt->o.enactor = &doer;
mt->targetObj = ⌖
}
}
@@ -1606,7 +1606,7 @@ void MotionTask::useObject(Actor &a, GameObject &dObj) {
if ((mt = mTaskList.newTask(&a)) != NULL) {
if (mt->motionType != motionTypeUseObject) {
mt->motionType = motionTypeUseObject;
- mt->directObject = &dObj;
+ mt->o.directObject = &dObj;
mt->flags = reset;
if (isPlayerActor(&a)) mt->flags |= privledged;
}
@@ -1625,8 +1625,8 @@ void MotionTask::useObjectOnObject(
if ((mt = mTaskList.newTask(&a)) != NULL) {
if (mt->motionType != motionTypeUseObjectOnObject) {
mt->motionType = motionTypeUseObjectOnObject;
- mt->directObject = &dObj;
- mt->indirectObject = ⌖
+ mt->o.directObject = &dObj;
+ mt->o.indirectObject = ⌖
mt->flags = reset;
if (isPlayerActor(&a)) mt->flags |= privledged;
}
@@ -1645,8 +1645,8 @@ void MotionTask::useObjectOnTAI(
if ((mt = mTaskList.newTask(&a)) != NULL) {
if (mt->motionType != motionTypeUseObjectOnTAI) {
mt->motionType = motionTypeUseObjectOnTAI;
- mt->directObject = &dObj;
- mt->TAI = ⌖
+ mt->o.directObject = &dObj;
+ mt->o.TAI = ⌖
mt->flags = reset;
}
}
@@ -1664,7 +1664,7 @@ void MotionTask::useObjectOnLocation(
if ((mt = mTaskList.newTask(&a)) != NULL) {
if (mt->motionType != motionTypeUseObjectOnLocation) {
mt->motionType = motionTypeUseObjectOnLocation;
- mt->directObject = &dObj;
+ mt->o.directObject = &dObj;
mt->targetLoc = target;
mt->flags = reset;
}
@@ -1680,7 +1680,7 @@ void MotionTask::useTAI(Actor &a, ActiveItem &dTAI) {
if ((mt = mTaskList.newTask(&a)) != NULL) {
if (mt->motionType != motionTypeUseTAI) {
mt->motionType = motionTypeUseTAI;
- mt->TAI = &dTAI;
+ mt->o.TAI = &dTAI;
mt->flags = reset;
}
}
@@ -1698,7 +1698,7 @@ void MotionTask::dropObject(Actor &a,
if ((mt = mTaskList.newTask(&a)) != NULL) {
if (mt->motionType != motionTypeDropObject) {
mt->motionType = motionTypeDropObject;
- mt->directObject = &dObj;
+ mt->o.directObject = &dObj;
mt->targetLoc = loc;
mt->flags = reset;
mt->moveCount = num;
@@ -1733,8 +1733,8 @@ void MotionTask::dropObjectOnObject(
if ((mt = mTaskList.newTask(&a)) != NULL) {
if (mt->motionType != motionTypeDropObjectOnObject) {
mt->motionType = motionTypeDropObjectOnObject;
- mt->directObject = &dObj;
- mt->indirectObject = ⌖
+ mt->o.directObject = &dObj;
+ mt->o.indirectObject = ⌖
mt->flags = reset;
mt->moveCount = num;
}
@@ -1754,8 +1754,8 @@ void MotionTask::dropObjectOnTAI(
if ((mt = mTaskList.newTask(&a)) != NULL) {
if (mt->motionType != motionTypeDropObjectOnTAI) {
mt->motionType = motionTypeDropObjectOnTAI;
- mt->directObject = &dObj;
- mt->TAI = ⌖
+ mt->o.directObject = &dObj;
+ mt->o.TAI = ⌖
mt->targetLoc = loc;
mt->flags = reset;
}
@@ -1920,11 +1920,11 @@ void MotionTask::twoHandedParry(
if ((mt = mTaskList.newTask(&a)) != NULL) {
if (mt->motionType != motionTypeTwoHandedParry) {
mt->motionType = motionTypeTwoHandedParry;
- mt->attacker = &opponent;
- mt->defensiveObj = &weapon;
+ mt->d.attacker = &opponent;
+ mt->d.defensiveObj = &weapon;
}
mt->flags = reset;
- mt->defenseFlags = 0;
+ mt->d.defenseFlags = 0;
}
}
@@ -1940,11 +1940,11 @@ void MotionTask::oneHandedParry(
if ((mt = mTaskList.newTask(&a)) != NULL) {
if (mt->motionType != motionTypeOneHandedParry) {
mt->motionType = motionTypeOneHandedParry;
- mt->attacker = &opponent;
- mt->defensiveObj = &weapon;
+ mt->d.attacker = &opponent;
+ mt->d.defensiveObj = &weapon;
}
mt->flags = reset;
- mt->defenseFlags = 0;
+ mt->d.defenseFlags = 0;
}
}
@@ -1960,11 +1960,11 @@ void MotionTask::shieldParry(
if ((mt = mTaskList.newTask(&a)) != NULL) {
if (mt->motionType != motionTypeShieldParry) {
mt->motionType = motionTypeShieldParry;
- mt->attacker = &opponent;
- mt->defensiveObj = &shield;
+ mt->d.attacker = &opponent;
+ mt->d.defensiveObj = &shield;
}
mt->flags = reset;
- mt->defenseFlags = 0;
+ mt->d.defenseFlags = 0;
}
}
@@ -1977,10 +1977,10 @@ void MotionTask::dodge(Actor &a, Actor &opponent) {
if ((mt = mTaskList.newTask(&a)) != NULL) {
if (mt->motionType != motionTypeDodge) {
mt->motionType = motionTypeDodge;
- mt->attacker = &opponent;
+ mt->d.attacker = &opponent;
}
mt->flags = reset;
- mt->defenseFlags = 0;
+ mt->d.defenseFlags = 0;
}
}
@@ -1995,7 +1995,7 @@ void MotionTask::acceptHit(Actor &a, Actor &opponent) {
if ((mt = mTaskList.newTask(&a)) != NULL) {
if (mt->motionType != motionTypeAcceptHit) {
mt->motionType = motionTypeAcceptHit;
- mt->attacker = &opponent;
+ mt->d.attacker = &opponent;
mt->flags = reset;
}
}
@@ -2010,7 +2010,7 @@ void MotionTask::fallDown(Actor &a, Actor &opponent) {
if ((mt = mTaskList.newTask(&a)) != NULL) {
if (mt->motionType != motionTypeFallDown) {
mt->motionType = motionTypeFallDown;
- mt->attacker = &opponent;
+ mt->d.attacker = &opponent;
mt->flags = reset;
}
}
@@ -2287,7 +2287,7 @@ void MotionTask::ballisticAction(void) {
// motion as if there was no collision.
if (collisionObject == targetObj) {
if (object->strike(
- enactor->thisID(),
+ o.enactor->thisID(),
targetObj->thisID())) {
// The arrow struck, so delete the arrow and
// end this motion
@@ -3541,9 +3541,9 @@ uint16 MotionTask::framesUntilStrike(void) {
GameObject *MotionTask::blockingObject(Actor *thisAttacker) {
return isDefense()
- && (defenseFlags & blocking)
- && thisAttacker == attacker
- ? defensiveObj
+ && (d.defenseFlags & blocking)
+ && thisAttacker == d.attacker
+ ? d.defensiveObj
: NULL;
}
@@ -3761,7 +3761,7 @@ void MotionTask::twoHandedParryAction(void) {
Actor *a = (Actor *)object;
int16 animationFrames;
- direction = (attacker->getLocation() - a->getLocation()).quickDir();
+ direction = (d.attacker->getLocation() - a->getLocation()).quickDir();
if (a->appearance != NULL
&& a->isActionAvailable(actionTwoHandParry)) {
@@ -3796,7 +3796,7 @@ void MotionTask::oneHandedParryAction(void) {
Actor *a = (Actor *)object;
int16 animationFrames;
- direction = (attacker->getLocation() - a->getLocation()).quickDir();
+ direction = (d.attacker->getLocation() - a->getLocation()).quickDir();
combatMotionType = oneHandedParryHigh;
if (a->appearance != NULL
@@ -3832,7 +3832,7 @@ void MotionTask::shieldParryAction(void) {
Actor *a = (Actor *)object;
int16 animationFrames;
- direction = (attacker->getLocation() - a->getLocation()).quickDir();
+ direction = (d.attacker->getLocation() - a->getLocation()).quickDir();
if (a->appearance != NULL
&& a->isActionAvailable(actionShieldParry)) {
@@ -3864,7 +3864,7 @@ void MotionTask::shieldParryAction(void) {
void MotionTask::dodgeAction(void) {
Actor *a = (Actor *)object;
- MotionTask *attackerMotion = attacker->moveTask;
+ MotionTask *attackerMotion = d.attacker->moveTask;
if (flags & reset) {
// If the attacker is not attacking, we're done
@@ -3933,7 +3933,7 @@ void MotionTask::acceptHitAction(void) {
int16 animationFrames;
a->currentFacing =
- (attacker->getWorldLocation() - a->getLocation()).quickDir();
+ (d.attacker->getWorldLocation() - a->getLocation()).quickDir();
if (a->appearance != NULL
&& a->isActionAvailable(actionHit, a->currentFacing)) {
@@ -3991,7 +3991,7 @@ void MotionTask::fallDownAction(void) {
int16 animationFrames;
a->currentFacing =
- (attacker->getWorldLocation() - a->getLocation()).quickDir();
+ (d.attacker->getWorldLocation() - a->getLocation()).quickDir();
if (a->appearance != NULL
&& a->isActionAvailable(actionKnockedDown, a->currentFacing)) {
@@ -4139,10 +4139,10 @@ void MotionTask::useMagicWeaponAction(void) {
void MotionTask::defensiveMeleeAction(void) {
Actor *a = (Actor *)object;
- MotionTask *attackerMotion = attacker->moveTask;
+ MotionTask *attackerMotion = d.attacker->moveTask;
// Determine if the blocking action has been initiated
- if (!(defenseFlags & blocking)) {
+ if (!(d.defenseFlags & blocking)) {
// If the attacker is not attacking, we're done
if (attackerMotion == NULL
|| !attackerMotion->isMeleeAttack()) {
@@ -4157,7 +4157,7 @@ void MotionTask::defensiveMeleeAction(void) {
// If the strike is about to land start the blocking motion
if (attackerMotion->framesUntilStrike() <= 1)
- defenseFlags |= blocking;
+ d.defenseFlags |= blocking;
} else {
// If the actors appearance becomes NULL, make sure this action
// no longer depends upon the animation
@@ -4373,32 +4373,32 @@ void MotionTask::updatePositions(void) {
// This will be uninterrutable for 2 frames
a->setActionPoints(2);
- mt->directObject->use(a->thisID());
+ mt->o.directObject->use(a->thisID());
//nextMT=mt;
moveTaskDone = true;
break;
case motionTypeUseObjectOnObject:
- if (isWorld(mt->indirectObject->IDParent())) {
+ if (isWorld(mt->o.indirectObject->IDParent())) {
if (
1
#ifdef THIS_SHOULD_BE_IN_TILEMODE
a->inUseRange(
- mt->indirectObject->getLocation(),
- mt->directObject)
+ mt->o.indirectObject->getLocation(),
+ mt->o.directObject)
#endif
) {
- mt->direction = (mt->indirectObject->getLocation()
+ mt->direction = (mt->o.indirectObject->getLocation()
- a->getLocation()).quickDir();
if (a->currentFacing != mt->direction)
a->turn(mt->direction);
else {
// The actor will now be uniterruptable
a->setActionPoints(2);
- mt->directObject->useOn(
+ mt->o.directObject->useOn(
a->thisID(),
- mt->indirectObject->thisID());
+ mt->o.indirectObject->thisID());
if (mt && mt->motionType == motionTypeUseObjectOnObject)
moveTaskDone = true;
else
@@ -4408,9 +4408,9 @@ void MotionTask::updatePositions(void) {
} else {
// The actor will now be uniterruptable
a->setActionPoints(2);
- mt->directObject->useOn(
+ mt->o.directObject->useOn(
a->thisID(),
- mt->indirectObject->thisID());
+ mt->o.indirectObject->thisID());
if (mt && mt->motionType == motionTypeUseObjectOnObject)
moveTaskDone = true;
else
@@ -4425,11 +4425,11 @@ void MotionTask::updatePositions(void) {
TilePoint actorLoc = a->getLocation(),
TAILoc;
TileRegion TAIReg;
- ActiveItem *TAG = mt->TAI->getGroup();
+ ActiveItem *TAG = mt->o.TAI->getGroup();
// Compute in points the region of the TAI
- TAIReg.min.u = mt->TAI->instance.u << tileUVShift;
- TAIReg.min.v = mt->TAI->instance.v << tileUVShift;
+ TAIReg.min.u = mt->o.TAI->instance.u << tileUVShift;
+ TAIReg.min.v = mt->o.TAI->instance.v << tileUVShift;
TAIReg.max.u = TAIReg.min.u
+ (TAG->group.uSize << tileUVShift);
TAIReg.max.v = TAIReg.min.v
@@ -4451,7 +4451,7 @@ void MotionTask::updatePositions(void) {
else {
// The actor will now be uniterruptable
a->setActionPoints(2);
- mt->directObject->useOn(a->thisID(), mt->TAI);
+ mt->o.directObject->useOn(a->thisID(), mt->o.TAI);
if (mt && mt->motionType == motionTypeUseObjectOnTAI)
moveTaskDone = true;
else
@@ -4471,7 +4471,7 @@ void MotionTask::updatePositions(void) {
else {
// The actor will now be uniterruptable
a->setActionPoints(2);
- mt->directObject->useOn(a->thisID(), mt->targetLoc);
+ mt->o.directObject->useOn(a->thisID(), mt->targetLoc);
if (mt && mt->motionType == motionTypeUseObjectOnLocation)
moveTaskDone = true;
else
@@ -4485,11 +4485,11 @@ void MotionTask::updatePositions(void) {
TilePoint actorLoc = a->getLocation(),
TAILoc;
TileRegion TAIReg;
- ActiveItem *TAG = mt->TAI->getGroup();
+ ActiveItem *TAG = mt->o.TAI->getGroup();
// Compute in points the region of the TAI
- TAIReg.min.u = mt->TAI->instance.u << tileUVShift;
- TAIReg.min.v = mt->TAI->instance.v << tileUVShift;
+ TAIReg.min.u = mt->o.TAI->instance.u << tileUVShift;
+ TAIReg.min.v = mt->o.TAI->instance.v << tileUVShift;
TAIReg.max.u = TAIReg.min.u
+ (TAG->group.uSize << tileUVShift);
TAIReg.max.v = TAIReg.min.v
@@ -4511,7 +4511,7 @@ void MotionTask::updatePositions(void) {
else {
// The actor will now be uniterruptable
a->setActionPoints(2);
- mt->TAI->use(a->thisID());
+ mt->o.TAI->use(a->thisID());
moveTaskDone = true;
}
break;
@@ -4529,7 +4529,7 @@ void MotionTask::updatePositions(void) {
else {
// The actor will now be uniterruptable
a->setActionPoints(2);
- mt->directObject->drop(a->thisID(),
+ mt->o.directObject->drop(a->thisID(),
mt->targetLoc,
mt->moveCount);
if (mt && mt->motionType == motionTypeDropObject)
@@ -4540,7 +4540,7 @@ void MotionTask::updatePositions(void) {
} else {
// The actor will now be uniterruptable
a->setActionPoints(2);
- mt->directObject->drop(a->thisID(),
+ mt->o.directObject->drop(a->thisID(),
mt->targetLoc,
mt->moveCount);
if (mt && mt->motionType == motionTypeDropObject)
@@ -4555,17 +4555,17 @@ void MotionTask::updatePositions(void) {
case motionTypeDropObjectOnObject:
- if (isWorld(mt->indirectObject->IDParent())) {
- mt->direction = (mt->indirectObject->getLocation()
+ if (isWorld(mt->o.indirectObject->IDParent())) {
+ mt->direction = (mt->o.indirectObject->getLocation()
- a->getLocation()).quickDir();
if (a->currentFacing != mt->direction)
a->turn(mt->direction);
else {
// The actor will now be uniterruptable
a->setActionPoints(2);
- mt->directObject->dropOn(
+ mt->o.directObject->dropOn(
a->thisID(),
- mt->indirectObject->thisID(),
+ mt->o.indirectObject->thisID(),
mt->moveCount);
if (mt && mt->motionType == motionTypeDropObjectOnObject)
moveTaskDone = true;
@@ -4575,9 +4575,9 @@ void MotionTask::updatePositions(void) {
} else {
// The actor will now be uniterruptable
a->setActionPoints(2);
- mt->directObject->dropOn(
+ mt->o.directObject->dropOn(
a->thisID(),
- mt->indirectObject->thisID(),
+ mt->o.indirectObject->thisID(),
mt->moveCount);
if (mt && mt->motionType == motionTypeDropObjectOnObject)
moveTaskDone = true;
@@ -4601,9 +4601,9 @@ void MotionTask::updatePositions(void) {
else {
// The actor will now be uniterruptable
a->setActionPoints(2);
- mt->directObject->dropOn(
+ mt->o.directObject->dropOn(
a->thisID(),
- mt->TAI,
+ mt->o.TAI,
mt->targetLoc);
if (mt && mt->motionType == motionTypeDropObjectOnTAI)
moveTaskDone = true;
diff --git a/engines/saga2/motion.h b/engines/saga2/motion.h
index cdf9d9403b..2fcbebd1e7 100644
--- a/engines/saga2/motion.h
+++ b/engines/saga2/motion.h
@@ -131,7 +131,7 @@ class MotionTask : private DNode {
agitated = (1 << 12), // Walking around blockage
agitatable = (1 << 13), // Will agitate when blocked
onStairs = (1 << 14), // actor is climbing stairs
- privledged = (1 << 15), // don't let AI interrupt this
+ privledged = (1 << 15) // don't let AI interrupt this
};
Direction direction; // direction of movement
@@ -161,7 +161,7 @@ class MotionTask : private DNode {
};
enum defenseMotionFlags {
- blocking = (1 << 0), // actor is blocking an attack
+ blocking = (1 << 0) // actor is blocking an attack
};
union {
@@ -173,14 +173,14 @@ class MotionTask : private DNode {
// upon.
Actor *enactor;
ActiveItem *TAI; // TAI involved in interation
- };
+ } o;
// Defensive motion stuff
struct {
Actor *attacker; // attacking actor
GameObject *defensiveObj; // shield or parrying weapon
uint8 defenseFlags; // various combat flags
- };
+ } d;
};
public:
@@ -191,18 +191,18 @@ public:
twoHandedSwingLeftHigh,
twoHandedSwingLeftLow,
twoHandedSwingRightHigh,
- twoHandedSwingRightLow,
+ twoHandedSwingRightLow
};
enum OneHandedSwingTypes {
oneHandedSwingHigh,
oneHandedSwingLow,
- oneHandedThrust,
+ oneHandedThrust
};
enum OneHandedParryTypes {
oneHandedParryHigh,
- oneHandedParryLow,
+ oneHandedParryLow
};
private:
@@ -253,7 +253,7 @@ private:
// Other combat actions
motionTypeAcceptHit, // show effect of hit
motionTypeFallDown, // be knocked off feet
- motionTypeDie, // self-explanatory
+ motionTypeDie // self-explanatory
};
@@ -525,7 +525,7 @@ public:
// Determine if this motion is a dodge motion
bool isDodging(Actor *thisAttacker) {
- return motionType == motionTypeDodge && thisAttacker == attacker;
+ return motionType == motionTypeDodge && thisAttacker == d.attacker;
}
static void initMotionTasks(void);
Commit: 54fb9a226aabc38cbbd78e9f907ef7225af3198f
https://github.com/scummvm/scummvm/commit/54fb9a226aabc38cbbd78e9f907ef7225af3198f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:09+02:00
Commit Message:
SAGA2: Added warnings for unsafe pointer arithmetics
Changed paths:
engines/saga2/assign.cpp
engines/saga2/band.cpp
engines/saga2/pool.h
engines/saga2/sensor.cpp
engines/saga2/task.cpp
engines/saga2/timers.cpp
diff --git a/engines/saga2/assign.cpp b/engines/saga2/assign.cpp
index 139137e774..27fbfb3220 100644
--- a/engines/saga2/assign.cpp
+++ b/engines/saga2/assign.cpp
@@ -145,7 +145,7 @@ TaskStack *ActorAssignment::createTask(void) {
Actor *ActorAssignment::getActor(void) const {
// FIXME: This is utterly evil
- warning("getActor(): dangerous pointer arithmetic, this will not work");
+ warning("FIXME: ActorAssignment::getActor(): unsafe pointer arithmetics");
return (Actor *)(this - offsetof(Actor, assignmentBuf));
}
diff --git a/engines/saga2/band.cpp b/engines/saga2/band.cpp
index 7ec299e94c..f8a3df3c11 100644
--- a/engines/saga2/band.cpp
+++ b/engines/saga2/band.cpp
@@ -85,7 +85,7 @@ public:
BandID getBandID(Band *b) {
BandPlaceHolder *bp;
- warning("BandPlaceHolder: unsafe pointer arithmetics");
+ warning("FIXME: BandPlaceHolder::getBandID(): unsafe pointer arithmetics");
bp = ((BandPlaceHolder *)((uint8 *)b - offsetof(BandPlaceHolder, buf)));
return bp - array;
}
@@ -242,7 +242,7 @@ void *BandList::newBand(BandID id) {
void BandList::deleteBand(void *p) {
BandPlaceHolder *bp;
- warning("BandList: unsafe pointer arithmetics");
+ warning("FIXME: BandList::deleteBand(): unsafe pointer arithmetics");
// Convert the pointer to the Band to a pointer to the
// BandPlaceHolder
diff --git a/engines/saga2/pool.h b/engines/saga2/pool.h
index fd48e86f69..40c8856e0f 100644
--- a/engines/saga2/pool.h
+++ b/engines/saga2/pool.h
@@ -88,6 +88,7 @@ public:
// Deallocate an object of type T given its address
void free(void *p) {
+ warning("FIXME: Pool::free(): unsafe pointer arithmetics");
_free((uint8 *)p - offsetof(PoolNode, buf));
}
};
diff --git a/engines/saga2/sensor.cpp b/engines/saga2/sensor.cpp
index 74e0616c4a..7c194f98b0 100644
--- a/engines/saga2/sensor.cpp
+++ b/engines/saga2/sensor.cpp
@@ -99,6 +99,7 @@ void *newSensorList(void) {
void deleteSensorList(void *p) {
SensorListHolder *listHolderToDelete;
+ warning("FIXME: deleteSensorList(): unsafe pointer arithmetics");
listHolderToDelete =
(SensorListHolder *)((uint8 *)p
- offsetof(
@@ -149,6 +150,7 @@ void *newSensor(int16 ctr) {
void deleteSensor(void *p) {
SensorHolder *sensorHolderToDelete;
+ warning("FIXME: deleteSensor(): unsafe pointer arithmetics");
sensorHolderToDelete =
(SensorHolder *)((uint8 *)p - offsetof(SensorHolder, sensorBuffer));
diff --git a/engines/saga2/task.cpp b/engines/saga2/task.cpp
index fcab0fceba..2ca1346b68 100644
--- a/engines/saga2/task.cpp
+++ b/engines/saga2/task.cpp
@@ -159,6 +159,7 @@ public:
TaskStackID getTaskStackID(TaskStack *ts) {
TaskStackPlaceHolder *tsp;
+ warning("FIXME: TaskStackList::getTaskStackID(): unsafe pointer arithmetics");
tsp = ((TaskStackPlaceHolder *)(
(uint8 *)ts
- offsetof(TaskStackPlaceHolder, buf)));
@@ -332,6 +333,8 @@ void *TaskStackList::newTaskStack(TaskStackID id) {
void TaskStackList::deleteTaskStack(void *p) {
TaskStackPlaceHolder *tsp;
+ warning("FIXME: TaskStackList::deleteTaskStack(): unsafe pointer arithmetics");
+
// Convert the pointer to the TaskStack to a pointer to the
// TaskStackPlaceHolder
tsp = (TaskStackPlaceHolder *)(
@@ -606,6 +609,7 @@ public:
TaskID getTaskID(Task *t) {
TaskPlaceHolder *tp;
+ warning("FIXME: TaskList::getTaskID(): unsafe pointer arithmetics");
tp = ((TaskPlaceHolder *)(
(uint8 *)t
- offsetof(TaskPlaceHolder, buf)));
@@ -623,6 +627,7 @@ public:
void markTask(Task *t) {
TaskPlaceHolder *tp;
+ warning("FIXME: TaskList::markTask(): unsafe pointer arithmetics");
tp = ((TaskPlaceHolder *)(
(uint8 *)t
- offsetof(TaskPlaceHolder, buf)));
@@ -811,6 +816,7 @@ void *TaskList::newTask(TaskID id)
void TaskList::deleteTask(void *p) {
TaskPlaceHolder *tp;
+ warning("FIXME: TaskList::deleteTask(): unsafe pointer arithmetics");
// Convert the pointer to the Task to a pointer to the
// TaskPlaceHolder
tp = (TaskPlaceHolder *)(
diff --git a/engines/saga2/timers.cpp b/engines/saga2/timers.cpp
index 61135de48b..3a45c120e1 100644
--- a/engines/saga2/timers.cpp
+++ b/engines/saga2/timers.cpp
@@ -96,6 +96,7 @@ void *newTimerList(void) {
void deleteTimerList(void *p) {
TimerListHolder *listHolderToDelete;
+ warning("FIXME: deleteTimerList(): unsafe pointer arithmetics");
listHolderToDelete =
(TimerListHolder *)((uint8 *)p
- offsetof(
@@ -146,6 +147,7 @@ void *newTimer(void) {
void deleteTimer(void *p) {
TimerHolder *timerHolderToDelete;
+ warning("FIXME: deleteTimer(): unsafe pointer arithmetics");
timerHolderToDelete =
(TimerHolder *)((uint8 *)p - offsetof(TimerHolder, timerBuffer));
Commit: 75f66d267c77c7605d37faefaf5eccd14e615a5c
https://github.com/scummvm/scummvm/commit/75f66d267c77c7605d37faefaf5eccd14e615a5c
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:10+02:00
Commit Message:
SAGA2: Add more debug messages
Changed paths:
engines/saga2/tile.cpp
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 58ac6b0d24..ab40dc8a63 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -2296,6 +2296,8 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
return nullptr;
}
+ debugC(2, kDebugLoading, "Fetching platform (%d,%d)", mapNum, layer);
+
int cacheIndex;
// Since the platform is not in the cache, we need to
@@ -2318,7 +2320,7 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
assert(plIndex >= 0);
assert(plIndex * sizeof(Platform) < tileRes->size(platformID + MKTAG(0, 0, 0, mapNum)));
- debugC(3, kDebugLoading, "plIndex: %d", plIndex);
+ debugC(3, kDebugLoading, "- plIndex: %d", plIndex);
// Now, load the actual metatile data...
if (tileRes->seek(platformID + MKTAG(0, 0, 0, mapNum))) {
@@ -4463,6 +4465,10 @@ uint16 objRoofID(GameObject *obj, int16 objMapNum, const TilePoint &objCoords) {
int objRoofPlatNum = -1;
int16 metaU, metaV;
+ debugC(3, kDebugTiles, "objRoofID:");
+ debugC(3, kDebugTiles, "- obj = %p; objMapNum = %d; objCoords = (%d,%d,%d)",
+ (void *)obj, objMapNum, objCoords.u, objCoords.v, objCoords.z);
+
objHeight = objCoords.z;
objTileReg.min.u = (objCoords.u - subTileSize) >> tileUVShift;
@@ -4470,11 +4476,15 @@ uint16 objRoofID(GameObject *obj, int16 objMapNum, const TilePoint &objCoords) {
objTileReg.max.u = (objCoords.u + subTileSize + tileUVMask) >> tileUVShift;
objTileReg.max.v = (objCoords.v + subTileSize + tileUVMask) >> tileUVShift;
+ debugC(3, kDebugTiles, "objTileReg = ((%d,%d), (%d,%d))", objTileReg.min.u, objTileReg.min.v, objTileReg.max.u, objTileReg.max.v);
+
objMetaReg.min.u = objTileReg.min.u >> platShift;
objMetaReg.min.v = objTileReg.min.v >> platShift;
objMetaReg.max.u = (objTileReg.max.u + platMask) >> platShift;
objMetaReg.max.v = (objTileReg.max.v + platMask) >> platShift;
+ debugC(3, kDebugTiles, "objMetaReg = ((%d,%d), (%d,%d))", objMetaReg.min.u, objMetaReg.min.v, objMetaReg.max.u, objMetaReg.max.v);
+
for (metaU = objMetaReg.min.u;
metaU < objMetaReg.max.u;
metaU++) {
Commit: e3d66a8d052a6018176b4be76b1dca710bfe156f
https://github.com/scummvm/scummvm/commit/e3d66a8d052a6018176b4be76b1dca710bfe156f
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:10+02:00
Commit Message:
SAGA2: Cleanup tileload.h
Changed paths:
engines/saga2/tileload.h
diff --git a/engines/saga2/tileload.h b/engines/saga2/tileload.h
index d7564e0b9e..a6e65fd0fb 100644
--- a/engines/saga2/tileload.h
+++ b/engines/saga2/tileload.h
@@ -42,13 +42,6 @@ const int maxBanks = 64; // 64 banks maximum
// To facilitate loading of tile banks on demand, a bit-array
// is used to indicate which banks are needed for each metatile
// to render.
-/*
-struct BankBits {
- uint32 b[maxBanks / 32];
-
- bool isSet( int i ) { return b[i >> 5] & (1 << (i & 31)); }
-};
- */
class BankBits {
public:
@@ -65,10 +58,6 @@ public:
friend BankBits operator+ (BankBits c, BankBits d) {
return BankBits(c.b[0] + d.b[0], c.b[1] + d.b[1]);
}
- /*
- friend BankBits operator- (BankBits c)
- { return BankBits( -c.b[0], -c.b[1] ); }
- */
friend BankBits operator- (BankBits c, BankBits d) {
return BankBits(c.b[0] - d.b[0], c.b[1] - d.b[1]);
@@ -229,142 +218,8 @@ public:
t.b[i] = c.b[i] ^ d.b[i];
return t;
}
-
-#if 0
- void operator>>=(int a) {
- bool c = b[0] & 1;
- b[0] >>= (uint32)a;
- b[1] >>= (uint32)a;
- b[1] |= ((1 << 31) & (uint32)c);
- }
-
- void operator<<=(int a) {
- bool c = b[1] & (1 << 31);
- b[0] >>= (uint32)a;
- b[0] |= (1 & (uint32)c);
- b[1] >>= (uint32)a;
- }
-
- friend FixedBitArray operator+ (FixedBitArray c, FixedBitArray d) {
- FixedBitArray t(max(c.currentSize(), d.currentSize()));
- for (uint16 i = 0; i < t.currentSize(); i++) t.b[i] = c.b[i] + d.b[i];
- return t;
- }
-
- friend FixedBitArray operator- (FixedBitArray c) {
- return FixedBitArray(-c.b[0], -c.b[1]);
- }
-
- friend FixedBitArray operator- (FixedBitArray c, FixedBitArray d) {
- FixedBitArray t(max(c.currentSize(), d.currentSize()));
- for (uint16 i = 0; i < t.currentSize(); i++) t.b[i] = c.b[i] - d.b[i];
- return t;
- }
- bool isSet(int i) {
- return b[i >> 5] & ((uint32) 1 << (i & 31));
- }
-
- void SetBit(int16 i) {
- b[i / 32] |= ((uint32) 1 << (i % 32)) ;
- }
- void NotBit(int16 i) {
- b[i / 32] &= ~((uint32) 1 << (i % 32));
- }
- void Reset(uint32 c, uint32 d) {
- b[0] = c;
- b[1] = d;
- }
- bool Test() {
- return (b[0] || b[1]);
- }
-#endif
-
-};
-
-/*
-template <class RES> class loadOnCall {
-private:
- uint16 handles;
- RES *handle;
- bitarray loaded(0);
- bitArray last(0);
-
- RES *loadRes( uint16 i);
- void freeRes( uint16 i);
- void initRes( uint16 i);
-
-
-public:
- RES *loadOnCall(uint16 size) ;
- ~loadOnCall();
-
- setSize( uint16 newSize );
-
- RES *operator[] (uint16 i)
- { if (i>=handles) return ((RES *) NULL);
- if (!loaded[i]) handle[i]=loadRes(i);
- return handle[i]; }
- void set(uint16 i)
- { if i<size b[i/32] |= ((uint32) 1<<(i%32)); }
- void clr(uint16 i)
- { if i<size b[i/32] &= ~((uint32) 1<<(i%32)); }
- void clear( void )
- { for (int i=0;i<=(size/32)+1;i++) b[i]=0; }
- void flush( void )
- { for (int i=0;i<=(size/32)+1;i++)
- {
- if (last[i] && !loaded[i]) freeRes(i);
- last[i]=loaded[i];
- }
- }
};
-template <class RES> RES *loadOnCall<RES>::loadRes( uint16 i )
-{
- RES h;
-
- if (handle[i])
- {
- loaded.SetBit(i);
- RLockHandle( (RHANDLE) handle[i] );
- return handle[i];
- }
-
- h = (RES) tileRes->load( tileID + RES_ID( 0,0,0,i ) );
-
- loaded.SetBit(i);
-
- handle[i] = h;
- return h;
-}
-
-template <class RES> RES *loadOnCall<RES>::initRes( uint16 i )
-{
- RES h;
-
- if (!handle[i])
- {
- h = (RES) tileRes->load( tileID + RES_ID( 0,0,0,i ) );
- loaded.SetBit(i);
- handle[i] = h;
- return h;
- }
-}
-
-template <class RES> void loadOnCall<RES>::freeRes( uint16 i )
-{
- if (handle[i])
- {
- RUnlockHandle((RHANDLE) handles[i]);
- loaded.NotBit(i);
- }
-}
-*/
-
-#ifdef _WIN32 // Set structure alignment packing value to 1 byte
-#pragma pack( pop )
-#endif
-
} // end of namespace Saga2
#endif
Commit: d116f2c34b8325d6f3aa67fd3fabcd40cc044852
https://github.com/scummvm/scummvm/commit/d116f2c34b8325d6f3aa67fd3fabcd40cc044852
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:10+02:00
Commit Message:
SAGA2: Rename class variables in tileload.h
Changed paths:
engines/saga2/tile.cpp
engines/saga2/tileload.h
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index ab40dc8a63..0ed6922078 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -1433,8 +1433,8 @@ static void readTileBank(hResContext *con, int count, TileBank *tb) {
static void readMetaTile(hResContext *con, MetaTile &til) {
til.highestPixel = con->readU16LE();
- til.banksNeeded.b[0] = con->readU32LE();
- til.banksNeeded.b[1] = con->readU32LE();
+ til.banksNeeded._b[0] = con->readU32LE();
+ til.banksNeeded._b[1] = con->readU32LE();
for (int i = 0; i < maxPlatforms; ++i)
til.stack[i] = con->readU16LE();
diff --git a/engines/saga2/tileload.h b/engines/saga2/tileload.h
index a6e65fd0fb..e4ebca9667 100644
--- a/engines/saga2/tileload.h
+++ b/engines/saga2/tileload.h
@@ -45,73 +45,73 @@ const int maxBanks = 64; // 64 banks maximum
class BankBits {
public:
- uint32 b[maxBanks / 32];
+ uint32 _b[maxBanks / 32];
// constructors
BankBits() {}
BankBits(uint32 c, uint32 d) {
- b[0] = c;
- b[1] = d;
+ _b[0] = c;
+ _b[1] = d;
}
// BankBits operators
friend BankBits operator+ (BankBits c, BankBits d) {
- return BankBits(c.b[0] + d.b[0], c.b[1] + d.b[1]);
+ return BankBits(c._b[0] + d._b[0], c._b[1] + d._b[1]);
}
friend BankBits operator- (BankBits c, BankBits d) {
- return BankBits(c.b[0] - d.b[0], c.b[1] - d.b[1]);
+ return BankBits(c._b[0] - d._b[0], c._b[1] - d._b[1]);
}
void operator>>=(int a) {
- bool c = (bool)(b[0] & 1);
- b[0] >>= (uint32)a;
- b[1] >>= (uint32)a;
- b[1] |= ((1 << 31) & (uint32)c);
+ bool c = (bool)(_b[0] & 1);
+ _b[0] >>= (uint32)a;
+ _b[1] >>= (uint32)a;
+ _b[1] |= ((1 << 31) & (uint32)c);
}
void operator<<=(int a) {
- bool c = (bool)(b[1] & (1 << 31));
- b[0] >>= (uint32)a;
- b[0] |= (1 & (uint32)c);
- b[1] >>= (uint32)a;
+ bool c = (bool)(_b[1] & (1 << 31));
+ _b[0] >>= (uint32)a;
+ _b[0] |= (1 & (uint32)c);
+ _b[1] >>= (uint32)a;
}
friend BankBits operator& (BankBits c, BankBits d) {
- return BankBits(c.b[0] & d.b[0], c.b[1] & d.b[1]);
+ return BankBits(c._b[0] & d._b[0], c._b[1] & d._b[1]);
}
friend BankBits operator| (BankBits c, BankBits d) {
- return BankBits(c.b[0] | d.b[0], c.b[1] | d.b[1]);
+ return BankBits(c._b[0] | d._b[0], c._b[1] | d._b[1]);
}
friend BankBits operator|= (BankBits c, BankBits d) {
- return BankBits(c.b[0] |= d.b[0], c.b[1] |= d.b[1]);
+ return BankBits(c._b[0] |= d._b[0], c._b[1] |= d._b[1]);
}
friend bool operator!= (BankBits c, BankBits d) {
- return (c.b[0] != d.b[0] && c.b[1] != d.b[1]);
+ return (c._b[0] != d._b[0] && c._b[1] != d._b[1]);
}
friend BankBits operator^ (BankBits c, BankBits d) {
- return BankBits(c.b[0] ^ d.b[0], c.b[1] ^ d.b[1]);
+ return BankBits(c._b[0] ^ d._b[0], c._b[1] ^ d._b[1]);
}
bool isSet(uint16 i) {
- return (bool)(b[i >> 5] & ((uint32) 1 << (i & 31)));
+ return (bool)(_b[i >> 5] & ((uint32) 1 << (i & 31)));
}
void SetBit(int16 i) {
- b[i / 32] |= ((uint32) 1 << (i % 32)) ;
+ _b[i / 32] |= ((uint32) 1 << (i % 32)) ;
}
void NotBit(int16 i) {
- b[i / 32] &= ~((uint32) 1 << (i % 32));
+ _b[i / 32] &= ~((uint32) 1 << (i % 32));
}
void Reset(uint32 c, uint32 d) {
- b[0] = c;
- b[1] = d;
+ _b[0] = c;
+ _b[1] = d;
}
bool Test() {
- return (b[0] || b[1]);
+ return (_b[0] || _b[1]);
}
// Point16 functions
@@ -120,14 +120,14 @@ public:
class bitArray {
private:
- uint32 *b;
- uint16 size;
+ uint32 *_b;
+ uint16 _size;
public:
bitArray(uint16 newSize);
~bitArray();
bool operator[](uint16 i) {
- if (i < size) return (bool)(b[i / 32] & (1 << (i % 32)));
+ if (i < _size) return (bool)(_b[i / 32] & (1 << (i % 32)));
else return false;
}
void resize(uint16 newSize);
@@ -150,10 +150,10 @@ private:
return (1 << (n & 31));
}
- uint32 b[lWords];
+ uint32 _b[lWords];
void clear(void) {
- memset(&b, 0, sizeof b);
+ memset(&_b, 0, sizeof _b);
}
public:
@@ -163,17 +163,17 @@ public:
}
uint32 getChunk(uint16 i) {
- return b[i];
+ return _b[i];
}
bool operator[](uint32 ind) {
- return (ind < size && (b[WORDNUM(ind)] & BITMASK(ind)));
+ return (ind < size && (_b[WORDNUM(ind)] & BITMASK(ind)));
}
void Bit(uint32 ind, bool val) {
if (ind < size) {
- if (val) b[WORDNUM(ind)] |= BITMASK(ind);
- else b[WORDNUM(ind)] &= ~BITMASK(ind);
+ if (val) _b[WORDNUM(ind)] |= BITMASK(ind);
+ else _b[WORDNUM(ind)] &= ~BITMASK(ind);
}
}
@@ -187,7 +187,7 @@ public:
FixedBitArray t;
for (uint16 i = 0; i < lWords; i++)
- t.b[i] = c.b[i] & d.b[i];
+ t._b[i] = c._b[i] & d._b[i];
return t;
}
@@ -195,19 +195,19 @@ public:
FixedBitArray t;
for (uint16 i = 0; i < lWords; i++)
- t.b[i] = c.b[i] | d.b[i];
+ t._b[i] = c._b[i] | d._b[i];
return t;
}
friend FixedBitArray &operator|= (FixedBitArray c, FixedBitArray d) {
for (uint16 i = 0; i < lWords; i++)
- c.b[i] |= d.b[i];
+ c._b[i] |= d._b[i];
return c;
}
friend bool operator!= (FixedBitArray c, FixedBitArray d) {
for (uint16 i = 0; i < lWords; i++)
- if (c.b[i] != d.b[i]) return true;
+ if (c._b[i] != d._b[i]) return true;
return false;
}
@@ -215,7 +215,7 @@ public:
FixedBitArray t;
for (uint16 i = 0; i < lWords; i++)
- t.b[i] = c.b[i] ^ d.b[i];
+ t._b[i] = c._b[i] ^ d._b[i];
return t;
}
};
Commit: 59e21d89ad1b5230e8af2ccf27831f357e9655cb
https://github.com/scummvm/scummvm/commit/59e21d89ad1b5230e8af2ccf27831f357e9655cb
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:10+02:00
Commit Message:
SAGA2: Load tile bank in constructor
Changed paths:
engines/saga2/tile.cpp
engines/saga2/tile.h
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 0ed6922078..2aeec5c079 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -1410,12 +1410,22 @@ void cleanupTileTasks(void) {
//-----------------------------------------------------------------------
// Initialize map data
-static void readTileBank(hResContext *con, int count, TileBank *tb) {
- tb->numTiles = con->readU32LE();
- tb->tileArray = new TileInfo[count];
+TileBank::TileBank(hResContext *con, hResID id) {
+ const int tileInfoSize = 28;
+ int size = con->size(id);
+ int count = (size - 4) / tileInfoSize; // Skip 4 bytes (numTiles)
+
+ if (!con->seek(id)) {
+ numTiles = 0;
+ tileArray = nullptr;
+ return;
+ }
+
+ numTiles = con->readU32LE();
+ tileArray = new TileInfo[count];
for (int i = 0; i < count; ++i) {
- tb->tileArray[i].offset = con->readU32LE();
- TileAttrs *att = &tb->tileArray[i].attrs;
+ tileArray[i].offset = con->readU32LE();
+ TileAttrs *att = &tileArray[i].attrs;
att->terrainHeight = con->readByte();
att->height = con->readByte();
att->terrainMask = con->readU16LE();
@@ -1474,7 +1484,6 @@ static void readActiveItem(hResContext *con, ActiveItem &itm) {
void initMaps(void) {
int16 i;
- const int tileInfoSize = 28;
const int metaTileSize = 30;
const int tileRefSize = 4;
const int assocSize = 2;
@@ -1482,13 +1491,11 @@ void initMaps(void) {
// Load all of the tile terrain banks
for (i = 0; i < maxBanks; i++) {
- if (tileRes->seek(tileTerrainID + MKTAG(0, 0, 0, (uint8)i))) {
- tileBanks[i] = new TileBank;
- int tileBankSize = tileRes->size(tileTerrainID + MKTAG(0, 0, 0, (uint8)i));
- int tiCount = (tileBankSize - 4) / tileInfoSize;
- readTileBank(tileRes, tiCount, tileBanks[i]);
- } else
+ tileBanks[i] = new TileBank(tileRes, tileTerrainID + MKTAG(0, 0, 0, (uint8)i));
+ if (tileBanks[i]->tileArray == nullptr) {
+ delete tileBanks[i];
tileBanks[i] = nullptr;
+ }
}
// Count the worlds by seeking the map data
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index f3f9d1b425..8e88c5a535 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -314,6 +314,13 @@ public:
uint32 numTiles; // number of tiles in list
TileInfo *tileArray; // variable-sized array
+ TileBank() {
+ numTiles = 0;
+ tileArray = nullptr;
+ }
+
+ TileBank(hResContext *con, hResID id);
+
TileInfo *tile(uint16 index) {
return &tileArray[index];
}
Commit: 87f37e642763239cf98b2c6d7eb83012ce8495ee
https://github.com/scummvm/scummvm/commit/87f37e642763239cf98b2c6d7eb83012ce8495ee
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:10+02:00
Commit Message:
SAGA2: Rename TileBank's class variables
Changed paths:
engines/saga2/tile.cpp
engines/saga2/tile.h
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 2aeec5c079..855fd58863 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -1416,16 +1416,16 @@ TileBank::TileBank(hResContext *con, hResID id) {
int count = (size - 4) / tileInfoSize; // Skip 4 bytes (numTiles)
if (!con->seek(id)) {
- numTiles = 0;
- tileArray = nullptr;
+ _numTiles = 0;
+ _tileArray = nullptr;
return;
}
- numTiles = con->readU32LE();
- tileArray = new TileInfo[count];
+ _numTiles = con->readU32LE();
+ _tileArray = new TileInfo[count];
for (int i = 0; i < count; ++i) {
- tileArray[i].offset = con->readU32LE();
- TileAttrs *att = &tileArray[i].attrs;
+ _tileArray[i].offset = con->readU32LE();
+ TileAttrs *att = &_tileArray[i].attrs;
att->terrainHeight = con->readByte();
att->height = con->readByte();
att->terrainMask = con->readU16LE();
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index 8e88c5a535..dd84fe8c0b 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -311,18 +311,18 @@ struct TileInfo {
class TileBank {
public:
- uint32 numTiles; // number of tiles in list
- TileInfo *tileArray; // variable-sized array
+ uint32 _numTiles; // number of tiles in list
+ TileInfo *_tileArray; // variable-sized array
TileBank() {
- numTiles = 0;
- tileArray = nullptr;
+ _numTiles = 0;
+ _tileArray = nullptr;
}
TileBank(hResContext *con, hResID id);
TileInfo *tile(uint16 index) {
- return &tileArray[index];
+ return &_tileArray[index];
}
};
Commit: 04a5d3936f6b323fc5d84fef774ac43778718007
https://github.com/scummvm/scummvm/commit/04a5d3936f6b323fc5d84fef774ac43778718007
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:10+02:00
Commit Message:
SAGA2: Rename a few global variables in tile.cpp
Changed paths:
engines/saga2/playmode.cpp
engines/saga2/tile.cpp
engines/saga2/tile.h
engines/saga2/tileload.cpp
diff --git a/engines/saga2/playmode.cpp b/engines/saga2/playmode.cpp
index 091e032872..d6444c815a 100644
--- a/engines/saga2/playmode.cpp
+++ b/engines/saga2/playmode.cpp
@@ -153,8 +153,8 @@ extern bool gameRunning;
bool checkTileAreaPort(void) {
if (gameRunning && tileDrawMap.data == nullptr) {
// Allocate back buffer for tile rendering
- tileDrawMap.size.x = (tileRect.width + tileWidth - 1) & ~tileDXMask;
- tileDrawMap.size.y = (tileRect.height + tileWidth - 1) & ~tileDXMask;
+ tileDrawMap.size.x = (tileRect.width + kTileWidth - 1) & ~kTileDXMask;
+ tileDrawMap.size.y = (tileRect.height + kTileWidth - 1) & ~kTileDXMask;
tileDrawMap.data = new uint8[tileDrawMap.bytes()]();
}
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 855fd58863..046fdfd639 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -1492,7 +1492,7 @@ void initMaps(void) {
// Load all of the tile terrain banks
for (i = 0; i < maxBanks; i++) {
tileBanks[i] = new TileBank(tileRes, tileTerrainID + MKTAG(0, 0, 0, (uint8)i));
- if (tileBanks[i]->tileArray == nullptr) {
+ if (tileBanks[i]->_tileArray == nullptr) {
delete tileBanks[i];
tileBanks[i] = nullptr;
}
@@ -1655,8 +1655,8 @@ void cleanupMaps(void) {
// Dump all of the tile terrain banks
for (i = 0; i < maxBanks; i++) {
if (tileBanks[i] != nullptr) {
- if (tileBanks[i]->tileArray != nullptr)
- delete[] tileBanks[i]->tileArray;
+ if (tileBanks[i]->_tileArray != nullptr)
+ delete[] tileBanks[i]->_tileArray;
delete tileBanks[i];
tileBanks[i] = nullptr;
@@ -2724,7 +2724,7 @@ inline void drawMetaRow(TilePoint coords, Point16 pos) {
// REM: precompute this later, by scanning the platform
// for individual altitudes
- p->highestPixel = tileHeight * (platformWidth - 1) + maxTileHeight * 2 + 64;
+ p->highestPixel = kTileHeight * (platformWidth - 1) + maxTileHeight * 2 + 64;
if (pos.y <= 0
|| pos.y - p->highestPixel >= tileDrawMap.size.y)
@@ -2929,20 +2929,20 @@ inline void drawMetaTiles(void) {
//updateHandleRefs(baseCoords); // viewPoint, &sti );
// coordinates of the view window on the map in X,Y (in 16 pixel units)
- viewPos.x = (tileScroll.x >> tileDXShift)
+ viewPos.x = (tileScroll.x >> kTileDXShift)
- (platformWidth * mapList[currentMapNum].mapSize),
viewPos.y = (platformWidth
* mapList[currentMapNum].mapSize
- * tileDX)
+ * kTileDX)
- tileScroll.y;
debugC(2, kDebugTiles, "viewPos = (%d,%d)", viewPos.x, viewPos.y);
// coordinates of the view window upper left corner in U,V
- baseCoords.u = ((2 * (viewPos.y >> tileDXShift) + metaDY / 16) + viewPos.x)
+ baseCoords.u = ((2 * (viewPos.y >> kTileDXShift) + metaDY / 16) + viewPos.x)
/ (platformWidth * 2);
- baseCoords.v = ((2 * (viewPos.y >> tileDXShift) + metaDY / 16) - viewPos.x)
+ baseCoords.v = ((2 * (viewPos.y >> kTileDXShift) + metaDY / 16) - viewPos.x)
/ (platformWidth * 2);
baseCoords.z = 0;
@@ -2954,7 +2954,7 @@ inline void drawMetaTiles(void) {
// coordinates of current metatile (in X,Y), relative to screen
metaPos.x = (baseCoords.u - baseCoords.v) * metaDX
- - viewPos.x * tileDX;
+ - viewPos.x * kTileDX;
metaPos.y = viewPos.y
- (baseCoords.u + baseCoords.v) * metaDY;
@@ -3171,13 +3171,13 @@ void maskPlatform(
Point16 tilePos;
int16 x = screenPos.x,
- x2 = x / tileDX;
+ x2 = x / kTileDX;
int16 length = 1;
TilePoint rLoc;
TilePoint origin(uOrg, vOrg, 0);
- tilePos.y = screenPos.y - (platformWidth - 1) * tileHeight;
+ tilePos.y = screenPos.y - (platformWidth - 1) * kTileHeight;
u = platformWidth - 1;
v = platformWidth - 1;
@@ -3202,7 +3202,7 @@ void maskPlatform(
rLoc.v += offset * tileUVSize;
offset <<= 1;
col += offset;
- tilePos.x += tileDX * offset;
+ tilePos.x += kTileDX * offset;
}
for (;
@@ -3212,7 +3212,7 @@ void maskPlatform(
pCoords.v--,
rLoc.u -= tileUVSize,
rLoc.v += tileUVSize,
- tilePos.x += tileWidth
+ tilePos.x += kTileWidth
) {
Platform **pGet;
@@ -3258,20 +3258,20 @@ void maskPlatform(
}
if (row < 7) {
- x -= tileDX;
+ x -= kTileDX;
x2++;
length += 2;
u--;
relLoc.u += tileUVSize;
} else {
- x += tileDX;
+ x += kTileDX;
x2--;
length -= 2;
v--;
relLoc.v += tileUVSize;
}
- tilePos.y += tileDY;
+ tilePos.y += kTileDY;
}
}
@@ -3362,7 +3362,7 @@ void maskMetaRow(
// REM: precompute this later, by scanning the platform
// for individual altitudes
- p->highestPixel = tileHeight * (platformWidth - 1) + maxTileHeight + 192;
+ p->highestPixel = kTileHeight * (platformWidth - 1) + maxTileHeight + 192;
if (pos.y <= 0
|| pos.y - p->highestPixel >= sMap.size.y)
@@ -3397,24 +3397,24 @@ void drawTileMask(
// coordinates of the view window on the map in X,Y (in 16 pixel units)
- viewPos.x = (aPos.x >> tileDXShift)
+ viewPos.x = (aPos.x >> kTileDXShift)
- (platformWidth * mapList[currentMapNum].mapSize),
viewPos.y = (platformWidth
- * mapList[currentMapNum].mapSize << tileDXShift)
+ * mapList[currentMapNum].mapSize << kTileDXShift)
- aPos.y;
// coordinates of the view window upper left corner in U,V
- baseCoords.u = ((2 * (viewPos.y >> tileDXShift) + metaDY / 16) + viewPos.x)
+ baseCoords.u = ((2 * (viewPos.y >> kTileDXShift) + metaDY / 16) + viewPos.x)
/ (platformWidth * 2);
- baseCoords.v = ((2 * (viewPos.y >> tileDXShift) + metaDY / 16) - viewPos.x)
+ baseCoords.v = ((2 * (viewPos.y >> kTileDXShift) + metaDY / 16) - viewPos.x)
/ (platformWidth * 2);
baseCoords.z = 0;
// coordinates of current metatile (in X,Y), relative to screen
metaPos.x = (baseCoords.u - baseCoords.v) * metaDX
- - viewPos.x * tileDX;
+ - viewPos.x * kTileDX;
metaPos.y = viewPos.y
- (baseCoords.u + baseCoords.v) * metaDY;
@@ -3566,7 +3566,7 @@ TilePoint pickTilePos(Point32 pos, const TilePoint &protagPos) {
// Inspect packed tile bitmap to determine if a pixel is opaque.
bool isTilePixelOpaque(int16 baseX, int16 baseY, int16 mapHeight, uint8 *td) {
bool opaque;
- int16 x = baseX + tileDX,
+ int16 x = baseX + kTileDX,
y = mapHeight - baseY,
accum = 0;
@@ -3576,7 +3576,7 @@ bool isTilePixelOpaque(int16 baseX, int16 baseY, int16 mapHeight, uint8 *td) {
// skip initial transparency
accum = *td;
td++;
- while (accum < tileWidth) {
+ while (accum < kTileWidth) {
// skip opaque run
accum += *td;
td += *td + 1;
@@ -3634,7 +3634,7 @@ SurfaceType pointOnTile(TileInfo *ti,
// Adjust the relative X coordinate to ensure it is actually within
// the tile's boundaries.
- relPos.x = clamp(-tileDX + 2, relPos.x, tileDX - 1);
+ relPos.x = clamp(-kTileDX + 2, relPos.x, kTileDX - 1);
// If the tile has no raised terrain
if (!(combinedMask & terrainRaised)) {
@@ -4149,8 +4149,8 @@ TilePoint pickTile(Point32 pos,
// Compute the X and Y offset of the exact mouse click point
// relative to the base of the tile.
- relPos.x = pos.x - curMap->mapHeight - (tileCoords.u - tileCoords.v) * tileDX;
- relPos.y = curMap->mapHeight - pos.y - (tileCoords.u + tileCoords.v) * tileDY;
+ relPos.x = pos.x - curMap->mapHeight - (tileCoords.u - tileCoords.v) * kTileDX;
+ relPos.y = curMap->mapHeight - pos.y - (tileCoords.u + tileCoords.v) * kTileDY;
// Compute which metatile the click occured on, and the tile
// within that metatile, and the origin coords of the metatile
@@ -4164,7 +4164,7 @@ TilePoint pickTile(Point32 pos,
mt = curMap->lookupMeta(mCoords);
// While we are less than the pick altitude
- while (relPos.y < zMax + tileDX + maxStepHeight - abs(relPos.x >> 1)) {
+ while (relPos.y < zMax + kTileDX + maxStepHeight - abs(relPos.x >> 1)) {
// If there is a metatile on this spot
if (mt != nullptr) {
// Iterate through all platforms
@@ -4263,7 +4263,7 @@ TilePoint pickTile(Point32 pos,
origin = mCoords << platShift;
mt = curMap->lookupMeta(mCoords);
}
- relPos.x += tileDX;
+ relPos.x += kTileDX;
} else {
tCoords.v--;
coords.v -= tileUVSize;
@@ -4273,9 +4273,9 @@ TilePoint pickTile(Point32 pos,
origin = mCoords << platShift;
mt = curMap->lookupMeta(mCoords);
}
- relPos.x -= tileDX;
+ relPos.x -= kTileDX;
}
- relPos.y += tileDY;
+ relPos.y += kTileDY;
// Compute new altitude range based upon the tile position
// relative to the protaganist's position.
@@ -4678,7 +4678,7 @@ void updateMainDisplay(void) {
else tileScroll += (scrollDelta * scrollSpeed) / scrollDistance;
// Compute the fine scrolling offsets
- fineScroll.x = tileScroll.x & tileDXMask;
+ fineScroll.x = tileScroll.x & kTileDXMask;
fineScroll.y = 0;
// Compute the center of the screen in (u,v) coords.
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index dd84fe8c0b..cfcc1fbc42 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -63,23 +63,26 @@ inline void TileID2Bank(TileID t, int16 &bank, int16 &num) {
* ===================================================================== */
// Tile metrics
-const int tileWidth = 64, // width of tile
- tileHeight = 32, // minimum height of tile
- tileMaxHeight = 160, // max height of tile
- tileDX = (tileWidth / 2), // tile X delta
- tileDY = (tileHeight / 2), // tile Y delta
- tileDXShift = 5, // log2( tileDX )
- tileDYShift = 4, // log2( tileDY )
- tileDXMask = (tileDX - 1), // bitmask for Tile DX
- tileDYMask = (tileDY - 1); // bitmask for Tile DY
+
+enum {
+ kTileWidth = 64,
+ kTileHeight = 32,
+ kTileMaxHeight = 160,
+ kTileDX = (kTileWidth / 2),
+ kTileDY = (kTileHeight / 2),
+ kTileDXShift = 5,
+ kTileDYShift = 4,
+ kTileDXMask = (kTileDX - 1),
+ kTileDYMask = (kTileDY - 1)
+};
const int maxTileHeight = 160; // tallest possible tile
const int platUVSize = tileUVSize * platformWidth;
// Metatile metrics
-const int metaTileWidth = tileWidth * platformWidth,
- metaTileHeight = tileHeight * platformWidth,
+const int metaTileWidth = kTileWidth * platformWidth,
+ metaTileHeight = kTileHeight * platformWidth,
metaDX = metaTileWidth / 2,
metaDY = metaTileHeight / 2;
@@ -92,10 +95,10 @@ const int subTileSize = 4,
// Constants to convert an X,Y into subtile coordinates
-const int subTileDX = (tileDX / 4),
- subTileDY = (tileDY / 4),
- subTileDXShift = (tileDXShift - 2),
- subTileDYShift = (tileDYShift - 2);
+const int subTileDX = (kTileDX / 4),
+ subTileDY = (kTileDY / 4),
+ subTileDXShift = (kTileDXShift - 2),
+ subTileDYShift = (kTileDYShift - 2);
const int subTileMaskUShift = 4,
subTileMaskVShift = 1;
diff --git a/engines/saga2/tileload.cpp b/engines/saga2/tileload.cpp
index ef846561ca..cee7e9aba3 100644
--- a/engines/saga2/tileload.cpp
+++ b/engines/saga2/tileload.cpp
@@ -95,11 +95,11 @@ void drawPlatform(
Point16 tilePos;
int16 x = screenPos.x,
- x2 = x / tileDX;
+ x2 = x / kTileDX;
int16 length = 1;
TilePoint origin(uOrg, vOrg, 0);
- tilePos.y = screenPos.y - (platformWidth - 1) * tileHeight;
+ tilePos.y = screenPos.y - (platformWidth - 1) * kTileHeight;
int16 u = platformWidth - 1;
int16 v = platformWidth - 1;
@@ -121,7 +121,7 @@ void drawPlatform(
pCoords.v -= offset;
offset <<= 1;
col += offset;
- tilePos.x += tileDX * offset;
+ tilePos.x += kTileDX * offset;
}
for (;
@@ -129,7 +129,7 @@ void drawPlatform(
col += 2,
pCoords.u++,
pCoords.v--,
- tilePos.x += tileWidth) {
+ tilePos.x += kTileWidth) {
if (tilePos.x < 0)
continue;
@@ -154,18 +154,18 @@ void drawPlatform(
}
if (row < 7) {
- x -= tileDX;
+ x -= kTileDX;
x2++;
length += 2;
u--;
} else {
- x += tileDX;
+ x += kTileDX;
x2--;
length -= 2;
v--;
}
- tilePos.y += tileDY;
+ tilePos.y += kTileDY;
}
}
Commit: 9bc9370e37e90d919cb663d3155ce896e24a05af
https://github.com/scummvm/scummvm/commit/9bc9370e37e90d919cb663d3155ce896e24a05af
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:10+02:00
Commit Message:
SAGA2: Make custom alarms use OSystem::getMillis
Changed paths:
engines/saga2/timer.cpp
diff --git a/engines/saga2/timer.cpp b/engines/saga2/timer.cpp
index ec3430a6d6..6d15cb985f 100644
--- a/engines/saga2/timer.cpp
+++ b/engines/saga2/timer.cpp
@@ -116,18 +116,18 @@ void resumeTimer(void) {
* ====================================================================== */
void Alarm::set(uint32 dur) {
- basetime = gameTime;
+ basetime = g_system->getMillis();
duration = dur;
}
bool Alarm::check(void) {
- return ((uint32)(gameTime - basetime) > duration);
+ return ((uint32)(g_system->getMillis() - basetime) > duration * 1000);
}
// time elapsed since alarm set
uint32 Alarm::elapsed(void) {
- return (uint32)(gameTime - basetime);
+ return (uint32)(g_system->getMillis() - basetime);
}
} // end of namespace Saga2
Commit: 05275a31297ab86671ef753e87c197045bbd13a9
https://github.com/scummvm/scummvm/commit/05275a31297ab86671ef753e87c197045bbd13a9
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:10+02:00
Commit Message:
SAGA2: Temporary crash prevention
Changed paths:
engines/saga2/objproto.cpp
diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp
index a66430e7a7..03398d8576 100644
--- a/engines/saga2/objproto.cpp
+++ b/engines/saga2/objproto.cpp
@@ -970,6 +970,12 @@ void ProtoObj::doBackgroundUpdate(GameObject *obj) {
TilePoint location = obj->getLocation();
GameWorld *w = obj->world();
+ // XXX: Temporary crash prevention
+ // We should properly solve the problem
+ warning("XXX: doBackgroundUpdate");
+ if (location.u == -1 && location.v == -1)
+ return;
+
if (w == NULL
|| !w->getSector(
location.u >> sectorShift,
Commit: 4d0272732f25caa40ab06ce0f2c9cc560d739abe
https://github.com/scummvm/scummvm/commit/4d0272732f25caa40ab06ce0f2c9cc560d739abe
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:11+02:00
Commit Message:
SAGA2: Fix crash on thread deletion
Changed paths:
engines/saga2/interp.cpp
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 3a7a4a0368..ea80a10c71 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -1494,7 +1494,8 @@ Thread::~Thread() {
// Deallocate the thread stack
free(stackBase);
- deleteThread(this);
+ // XXX: Deleting like this causes a crash
+ //deleteThread(this);
}
//-----------------------------------------------------------------------
Commit: 9eca51a1590412b94705ec902e32bdbf89920f9b
https://github.com/scummvm/scummvm/commit/9eca51a1590412b94705ec902e32bdbf89920f9b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:11+02:00
Commit Message:
SAGA2: Move platformLRU to Common::List
Changed paths:
engines/saga2/tile.cpp
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 046fdfd639..3b4cb4a4ad 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -202,7 +202,7 @@ CyclePtr cycleList; // list of tile cycling info
// Platform caching management
const int platformCacheSize = 256;
-DList platformLRU; // least recently used
+Common::List<int> platformLRU; // least recently used
PlatformCacheEntry platformCache[platformCacheSize];
/* ===================================================================== *
@@ -1831,7 +1831,7 @@ void initPlatformCache(void) {
// Fill up the LRU with empty platforms
pce->metaID = NoMetaTile;
- platformLRU.addTail(*pce);
+ platformLRU.push_back(i);
}
}
@@ -2305,17 +2305,17 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
debugC(2, kDebugLoading, "Fetching platform (%d,%d)", mapNum, layer);
- int cacheIndex;
-
// Since the platform is not in the cache, we need to
// dump something from the cache. Dump the one that
// was least recently used.
// Get head of LRU chain.
- pce = (PlatformCacheEntry *)platformLRU.remHead();
- platformLRU.addTail(*pce);
+ int cacheIndex = platformLRU.front();
+ platformLRU.pop_front();
+ platformLRU.push_back(cacheIndex);
+
+ pce = &platformCache[cacheIndex];
// Compute the layer of this entry in the cache
- cacheIndex = pce - platformCache;
assert(cacheIndex < platformCacheSize);
assert(cacheIndex >= 0);
Commit: 1e9f393e08b3803bb1c2ec4d7cd8476d0b834619
https://github.com/scummvm/scummvm/commit/1e9f393e08b3803bb1c2ec4d7cd8476d0b834619
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:11+02:00
Commit Message:
SAGA2: Move appearanceLRU to Common::List
Changed paths:
engines/saga2/sprite.cpp
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index 1ad86ad36d..133321f9f7 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -112,7 +112,7 @@ hResContext *spriteRes, // sprite resource handle
static ActorAppearance appearanceTable[32];
// A least-recently-used list of actor appearances
-static DList appearanceLRU;
+static Common::List<ActorAppearance *> appearanceLRU;
/* ===================================================================== *
Quick memory routines
@@ -590,7 +590,7 @@ void ActorAppearance::loadSpriteBanks(int16 banksNeeded) {
// Make this one the most recently used entry
remove();
- appearanceLRU.addTail(*this);
+ appearanceLRU.push_back(this);
// Load in additional sprite banks if requested...
for (bank = 0; bank < (long)elementsof(spriteBanks); bank++) {
@@ -616,7 +616,6 @@ static void readColorScheme(hResContext *con, ColorScheme &col) {
}
ActorAppearance *LoadActorAppearance(uint32 id, int16 banksNeeded) {
- ActorAppearance *aa;
int16 bank;
const int actorAnimSetSize = 8;
const int colorSchemeSize = 44;
@@ -625,33 +624,30 @@ ActorAppearance *LoadActorAppearance(uint32 id, int16 banksNeeded) {
// Search the table for either a matching appearance,
// or for an empty one.
- for (aa = (ActorAppearance *)appearanceLRU.first();
- aa != nullptr;
- aa = (ActorAppearance *)aa->next()) {
- if (aa->id == id // If has same ID
- && aa->poseList != nullptr) { // and frames not dumped
+ for (Common::List<ActorAppearance *>::iterator it = appearanceLRU.begin(); it != appearanceLRU.end(); ++it) {
+ if ((*it)->id == id // If has same ID
+ && (*it)->poseList != nullptr) { // and frames not dumped
// then use this one!
- aa->useCount++;
- aa->loadSpriteBanks(banksNeeded);
- return aa;
+ (*it)->useCount++;
+ (*it)->loadSpriteBanks(banksNeeded);
+ return *it;
}
}
// If we couldn't find an extact match, search for an
// empty one.
- if (aa == nullptr) {
- // Search from LRU end of list.
- for (aa = (ActorAppearance *)appearanceLRU.first();
- aa != nullptr;
- aa = (ActorAppearance *)aa->next()) {
- if (aa->useCount == 0) // If not in use
- break; // then use this one!
+ ActorAppearance *aa = nullptr;
+ // Search from LRU end of list.
+ for (Common::List<ActorAppearance *>::iterator it = appearanceLRU.begin(); it != appearanceLRU.end(); ++it) {
+ if ((*it)->useCount == 0) { // If not in use
+ aa = *it; // then use this one!
+ break;
}
+ }
- // If none available, that's fatal...
- if (aa == nullptr) {
- error("All ActorAppearance records are in use!");
- }
+ // If none available, that's fatal...
+ if (aa == nullptr) {
+ error("All ActorAppearance records are in use!");
}
// Dump the sprites being stored
@@ -767,7 +763,7 @@ void initSprites(void) {
ActorAppearance *aa = &appearanceTable[i];
aa->useCount = 0;
- appearanceLRU.addHead(*aa);
+ appearanceLRU.push_front(aa);
}
}
Commit: 2b67a92944f2caba1fb5e946b89c1f34e66553bd
https://github.com/scummvm/scummvm/commit/2b67a92944f2caba1fb5e946b89c1f34e66553bd
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:11+02:00
Commit Message:
SAGA2: Code cleanup
Changed paths:
engines/saga2/hresmgr.cpp
engines/saga2/interp.cpp
engines/saga2/tile.cpp
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index 2f28d15ee9..c501193f6d 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -182,9 +182,11 @@ bool hResContext::seek(hResID id) {
_bytecount = 0;
_bytepos = 0;
- if (!_valid) return false;
+ if (!_valid)
+ return false;
- if ((entry = findEntry(id)) == nullptr) return false;
+ if ((entry = findEntry(id)) == nullptr)
+ return false;
_bytecount = entry->size;
_bytepos = entry->resOffset();
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index ea80a10c71..104277ca02 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -39,10 +39,6 @@
namespace Saga2 {
-/* ============================================================================ *
- Constants
- * ============================================================================ */
-
#define IMMED_WORD(w) ((w = *pc++),(w |= (*pc++)<<8))
#define BRANCH(w) pc = codeSeg + (w)
@@ -52,26 +48,11 @@ const uint32 sagaID = MKTAG('S', 'A', 'G', 'A'),
const int initialStackFrameSize = 10;
-/* ============================================================================ *
- Protos
- * ============================================================================ */
-
static bool lookupExport(uint16 entry, uint16 &segNum, uint16 &segOff);
-
uint8 *segmentAddress(uint16 segment, uint16 offset);
-/* ============================================================================ *
- Globals
- * ============================================================================ */
-
Thread *thisThread;
-// xRefTable points to a list of segment / offset pairs which
-// indicate where to find every external symbol that lies within
-// a script.
-
-//struct SegmentRef *xRefTable;
-
struct ModuleEntry *moduleList; // loaded from resource
int16 moduleBaseResource,
moduleCount;
@@ -89,19 +70,9 @@ int16 extendedThreadLevel;
int16 lastExport;
-/* ============================================================================ *
- Externals
- * ============================================================================ */
-
-//extern struct SpeechObject activeSpeech;
-
extern hResource *scriptResFile; // script resources
hResContext *scriptRes; // script resource handle
-/* ============================================================================ *
- Functions
- * ============================================================================ */
-
void script_error(char *msg) {
thisThread->flags |= Thread::aborted;
WriteStatusF(0, msg);
@@ -110,7 +81,6 @@ void script_error(char *msg) {
//-----------------------------------------------------------------------
// Return the address of a builtin object, such as an Actor or a TAG,
// given a segment number and an index
-
uint8 *builtinObjectAddress(int16 segment, uint16 index) {
uint16 segNum, segOff;
@@ -145,7 +115,6 @@ uint8 *builtinObjectAddress(int16 segment, uint16 index) {
// function table for the class associated with this object. Also
// return the address of the C function call table for this builtin
// class.
-
uint16 *builtinVTableAddress(int16 btype, uint8 *addr, CallTable **callTab) {
GameObject *obj;
ActiveItem *aItem;
@@ -196,13 +165,11 @@ uint16 *builtinVTableAddress(int16 btype, uint8 *addr, CallTable **callTab) {
error("SAGA Failure: Attempt to call member function of invalid builtin type.\n");
}
-// assert( script > 0 );
-
// Look up the vtable in the export table.
if (script != 0 && lookupExport(script, vtSeg, vtOffset)) {
-// gError::warn( "vtable was %d %d %d\n", script, vtSeg, vtOffset );
return (uint16 *)segmentAddress(vtSeg, vtOffset);
- } else return NULL;
+ } else
+ return NULL;
}
uint8 *segmentAddress(uint16 segment, uint16 offset) {
@@ -210,7 +177,8 @@ uint8 *segmentAddress(uint16 segment, uint16 offset) {
// A segment number of less than zero means that this is
// a "builtin" object, in other words the game engine itself
- if ((int16)segment < 0) return builtinObjectAddress(segment, offset);
+ if ((int16)segment < 0)
+ return builtinObjectAddress(segment, offset);
segHandle = scriptRes->loadIndexResource(segment, "object segment");
if (segHandle == nullptr)
@@ -222,14 +190,14 @@ uint8 *segmentAddress(uint16 segment, uint16 offset) {
uint8 *segmentArrayAddress(uint16 segment, uint16 index) {
byte *segHandle = nullptr;
- if ((int16)segment < 0) return builtinObjectAddress(segment, index);
+ if ((int16)segment < 0)
+ return builtinObjectAddress(segment, index);
segHandle = scriptRes->loadIndexResource(segment, "object array segment");
if (segHandle == nullptr)
return nullptr;
- return segHandle + sizeof(uint16)
- + (index * READ_LE_INT16(segHandle));
+ return segHandle + sizeof(uint16) + (index * READ_LE_INT16(segHandle));
}
// Returns the address of a byte given an addressing mode
@@ -305,11 +273,8 @@ uint8 *byteAddress(Thread *th, uint8 **pcPtr) {
// Compute address of object
return segmentAddress(seg, index) + offset;
}
+
error("byteAddress: Invalid addressing mode: %d.\n", *pcPtr);
-// return NULL;
-#if _WIN32
- return NULL;
-#endif
}
// Returns the address of an object given an addressing mode
@@ -386,10 +351,9 @@ uint8 *objectAddress(
}
// Returns the address and access mask of a bit, given addressing mode
-
uint8 *bitAddress(Thread *th, uint8 **pcPtr, int16 *mask) {
uint8 *pc = *pcPtr,
- *addr;
+ *addr;
uint16 seg,
offset;
@@ -437,16 +401,8 @@ uint8 *bitAddress(Thread *th, uint8 **pcPtr, int16 *mask) {
case addr_this:
error("Addressing relative to 'this' not supported just yet.\n");
-// addr_indirect, // use SEG:offset on stack
-// addr_indirect_index, // use SEG:index:offset on stack
-
}
error("bitAddress: Invalid addressing mode: %d.\n", *pcPtr);
-// fatal( "Invalid addressing mode.\n" );
-// return NULL;
-#if _WIN32
- return NULL;
-#endif
}
// Returns the address of a string
@@ -466,7 +422,6 @@ uint8 *Thread::strAddress(int strNum) {
//-----------------------------------------------------------------------
// RandomGenerator class - a random number generator class for function
// objects which each maintain a local seed.
-
class RandomGenerator {
uint32 a; // seed
static const uint32 b; // arbitrary constant
@@ -493,7 +448,6 @@ const uint32 RandomGenerator::b = 31415821;
//-----------------------------------------------------------------------
// A restricted random function
-
int16 RRandom(int16 c, int16 s, int16 id) {
// Create a local random number generator with a seed calculated
// with a non-deterministic portion generated by the standard
@@ -506,7 +460,6 @@ int16 RRandom(int16 c, int16 s, int16 id) {
/* ============================================================================ *
Main interpreter
* ============================================================================ */
-
void print_script_name(uint8 *codePtr, char *descr = NULL) {
char scriptName[32];
uint8 *sym = codePtr - 1;
@@ -560,16 +513,8 @@ bool Thread::interpret(void) {
thisThread = this; // set current thread address
- for (instruction_count = 0;
- instruction_count < maxTimeSlice;
- instruction_count++) {
+ for (instruction_count = 0; instruction_count < maxTimeSlice; instruction_count++) {
switch (op = *pc++) {
-
-// case op_nextblock:
-// n = (pc-1-(codeSeg)) / 1024; // calculate address of this block
-// BRANCH((n + 1) * 1024); // jump to next block
-// break;
-
case op_dup:
*--stack = stack[0]; // duplicate value on stack
break;
@@ -607,10 +552,6 @@ bool Thread::interpret(void) {
*--stack = *addr; // get byte from address
break;
-#if 0
- op_getstr, // read from string field (mode)
-#endif
-
// Note that in the current implementation, "put" ops leave
// the value that was stored on the stack. We mat also do a
// 'vput' which consumes the variable.
@@ -647,15 +588,9 @@ bool Thread::interpret(void) {
*addr = *stack++; // put integer to address
break;
-#if 0
- op_putstr, // put to string field (mode)
-#endif
-
case op_enter:
-//#if DEBUG
-// print_script_name( pc - 1 );
-//#endif
+ print_script_name(pc - 1);
*--stack = framePtr; // save old frame ptr on stack
framePtr = (uint8 *)stack - stackBase; // new frame pointer
IMMED_WORD(w); // pick up word after address
@@ -668,9 +603,7 @@ bool Thread::interpret(void) {
returnVal = *stack++;
case op_return_v: // return with void
- debugC(1, kDebugScripts, "Scripts: op_return");
-
-// REM: When we implement dynamic strings we'll want to clean up first.
+ debugC(1, kDebugScripts, "Scripts: op_return_v");
stack = (int16 *)(stackBase + framePtr); // pop autos
framePtr = *stack++; // restore frame pointer
@@ -686,8 +619,7 @@ bool Thread::interpret(void) {
programCounter.offset = *stack++;
//RUnlockHandle((RHANDLE)codeSeg);
- codeSeg = scriptRes->loadIndexResource(programCounter.segment,
- "saga code segment");
+ codeSeg = scriptRes->loadIndexResource(programCounter.segment, "saga code segment");
pc = (codeSeg) + programCounter.offset;
n = *stack++; // get argument count from call
@@ -741,7 +673,6 @@ bool Thread::interpret(void) {
case op_ccall: // call C function
case op_ccall_v: // call C function
-
n = *pc++; // get argument count
IMMED_WORD(w); // get function number
if (w < 0 || w >= globalCFuncs.numEntries)
@@ -759,7 +690,6 @@ bool Thread::interpret(void) {
} else flags &= ~expectResult; // script not expecting result
// if the thread is asleep, then no more instructions
-
if (flags & asleep)
instruction_count = maxTimeSlice; // break out of loop!
@@ -825,6 +755,7 @@ bool Thread::interpret(void) {
// calculate PC address
pc = (codeSeg) + programCounter.offset;
print_script_name(pc, objectName(seg, offset));
+
break;
} else if (vtableEntry[1] != 0xffff) { // It's a C func
// Save the ID of the invoked object
@@ -924,8 +855,6 @@ bool Thread::interpret(void) {
}
break;
-// case op_jmp_sswitch: // string-based case/switch
-
case op_jmp_seedrandom: // seeded random jump
case op_jmp_random: // random jump
@@ -998,95 +927,82 @@ bool Thread::interpret(void) {
// dropped variable.
case op_add:
- w = (stack[1] + stack [0]);
+ w = (stack[1] + stack[0]);
*++stack = w;
break;
case op_sub:
- w = (stack[1] - stack [0]);
+ w = (stack[1] - stack[0]);
*++stack = w;
break;
case op_mul:
- w = (stack[1] * stack [0]);
+ w = (stack[1] * stack[0]);
*++stack = w;
break;
case op_div:
- w = (stack[1] / stack [0]);
+ w = (stack[1] / stack[0]);
*++stack = w;
break;
case op_mod:
- w = (stack[1] % stack [0]);
+ w = (stack[1] % stack[0]);
*++stack = w;
break;
case op_eq:
- w = (stack[1] == stack [0]);
+ w = (stack[1] == stack[0]);
*++stack = w;
break;
case op_ne:
- w = (stack[1] != stack [0]);
+ w = (stack[1] != stack[0]);
*++stack = w;
break;
case op_gt:
- w = (stack[1] > stack [0]);
+ w = (stack[1] > stack[0]);
*++stack = w;
break;
case op_lt:
- w = (stack[1] < stack [0]);
+ w = (stack[1] < stack[0]);
*++stack = w;
break;
case op_ge:
- w = (stack[1] >= stack [0]);
+ w = (stack[1] >= stack[0]);
*++stack = w;
break;
case op_le:
- w = (stack[1] <= stack [0]);
+ w = (stack[1] <= stack[0]);
*++stack = w;
break;
case op_rsh:
- w = (stack[1] >> stack [0]);
+ w = (stack[1] >> stack[0]);
*++stack = w;
break;
case op_lsh:
- w = (stack[1] << stack [0]);
+ w = (stack[1] << stack[0]);
*++stack = w;
break;
case op_and:
- w = (stack[1] & stack [0]);
+ w = (stack[1] & stack[0]);
*++stack = w;
break;
case op_or:
- w = (stack[1] | stack [0]);
+ w = (stack[1] | stack[0]);
*++stack = w;
break;
case op_xor:
- w = (stack[1] ^ stack [0]);
+ w = (stack[1] ^ stack[0]);
*++stack = w;
break;
case op_land:
- w = (stack[1] && stack [0]);
+ w = (stack[1] && stack[0]);
*++stack = w;
break;
case op_lor:
- w = (stack[1] || stack [0]);
+ w = (stack[1] || stack[0]);
*++stack = w;
break;
case op_lxor:
- w = (stack[1] && !stack [0]) || (!stack[1] && stack[0 ]);
+ w = (stack[1] && !stack[0]) || (!stack[1] && stack[0]);
*++stack = w;
break;
-#if 0
- // String functions. First figure out how strings are going to be
- // stored!!
-
- op_str_eq,
- op_str_ne,
- op_str_gt,
- op_str_lt,
- op_str_ge,
- op_str_le,
- op_strcat, // string concatenation
- op_strformat, // string formatting
-#endif
case op_speak:
case op_dialog_begin:
case op_dialog_end:
@@ -1441,12 +1357,10 @@ Thread::Thread(uint16 segNum, uint16 segOff, scriptCallFrame &args) {
}
newThread(this);
-// assert ((codeSeg)[programCounter.offset] == op_enter);
}
//-----------------------------------------------------------------------
// Constructor -- reconstruct from archive buffer
-
Thread::Thread(void **buf) {
void *bufferPtr = *buf;
@@ -1467,8 +1381,7 @@ Thread::Thread(void **buf) {
stackOffset = *((int16 *)bufferPtr);
bufferPtr = (int16 *)bufferPtr + 1;
- codeSeg = scriptRes->loadIndexResource(programCounter.segment,
- "saga code segment");
+ codeSeg = scriptRes->loadIndexResource(programCounter.segment, "saga code segment");
stackBase = (UBytePtr)malloc(stackSize);
stackPtr = stackBase + stackSize - stackOffset;
@@ -1652,9 +1565,6 @@ scriptResult Thread::run(void) {
interpret();
}
error("Thread timed out!\n");
-#ifdef _WIN32
- return scriptResultFinished;
-#endif
}
//-----------------------------------------------------------------------
@@ -1680,7 +1590,6 @@ void Thread::clearExtended(void) {
/* ============================================================================ *
Script Management functions
* ============================================================================ */
-
void initScripts(void) {
// Open the script resource group
scriptRes = scriptResFile->newContext(sagaID, "script resources");
@@ -1829,7 +1738,8 @@ scriptResult runMethod(
// For abstract classes, the object index is also the class
// index.
- if (bType == builtinAbstract) index = scriptClassID;
+ if (bType == builtinAbstract)
+ index = scriptClassID;
// Lookup class function table in export table
if (scriptClassID < 0)
@@ -1959,58 +1869,4 @@ void wakeUpThread(ThreadID id, int16 returnVal) {
}
}
-//-----------------------------------------------------------------------
-// Old routines
-
-#if 0
-void wakeUpThreadsDelayed(enum WaitTypes wakeupType, int newdelay) {
- Thread *th;
-
- for (th = threadList.first(); th; th = th->next) {
- if ((th->flags & THREADF_WAITING) && th->waitType == wakeupType) {
- // Set thread to delayed mode.
-
- SetAlarm(&th->waitAlarm, newdelay); // set the alarm
- th->waitType = TWAIT_DELAY;
- }
- }
-}
-
-void abortObjectThreads(Thread *keep, uint16 objID) {
- Thread *th;
-
- for (th = threadList.first(); th; th = th->next) {
- if (th != keep && objID == th->threadArgs.theActor) {
- th->flags &= ~THREADF_WAITING;
- th->flags |= THREADF_ABORTED;
- }
- }
-}
-
-bool abortAllThreads(void) {
- bool result = true;
- Thread *th;
-
- for (th = threadList.first(); th; th = th->next) {
-#if 0
- if (th->flags & THREADF_WAITING) {
- switch (th->waitType) {
-
- case TWAIT_DELAY:
- case TWAIT_SPEECH:
- break;
-
- case TWAIT_DIALOG_BEGIN:
- case TWAIT_DIALOG_END:
- break;
- }
- }
-#endif
- th->flags |= THREADF_ABORTED;
- }
- dispatchThreads();
- return result;
-}
-#endif
-
} // end of namespace Saga2
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 3b4cb4a4ad..fd883b358a 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -816,7 +816,7 @@ void initActiveItemStates(void) {
error("Unable to allocate the active item state array array");
for (i = 0; i < worldCount; i++) {
- stateArray[i] = (byte *)LoadResource(tileRes, tagStateID + MKTAG(0, 0, 0, uint8(i)),
+ stateArray[i] = (byte *)LoadResource(tileRes, tagStateID + i,
"active item state array");
if (stateArray[i] == nullptr)
@@ -835,7 +835,7 @@ void saveActiveItemStates(SaveFileConstructor &saveGame) {
void *bufferPtr;
for (i = 0; i < worldCount; i++) {
- int32 size = tileRes->size(tagStateID + MKTAG(0, 0, 0, uint8(i)));
+ int32 size = tileRes->size(tagStateID + i);
archiveBufSize += sizeof(int16);
if (stateArray[i] != nullptr)
archiveBufSize += size;
@@ -853,7 +853,7 @@ void saveActiveItemStates(SaveFileConstructor &saveGame) {
ActiveItemPtr activeItemList = mapData->activeItemList;
int16 activeItemCount = mapData->activeCount,
j;
- int32 arraySize = tileRes->size(tagStateID + MKTAG(0, 0, 0, uint8(i)));
+ int32 arraySize = tileRes->size(tagStateID + i);
uint8 *bufferedStateArray;
// Save the size of the state array
@@ -1491,7 +1491,7 @@ void initMaps(void) {
// Load all of the tile terrain banks
for (i = 0; i < maxBanks; i++) {
- tileBanks[i] = new TileBank(tileRes, tileTerrainID + MKTAG(0, 0, 0, (uint8)i));
+ tileBanks[i] = new TileBank(tileRes, tileTerrainID + i);
if (tileBanks[i]->_tileArray == nullptr) {
delete tileBanks[i];
tileBanks[i] = nullptr;
@@ -1500,8 +1500,10 @@ void initMaps(void) {
// Count the worlds by seeking the map data
for (worldCount = 0;
- tileRes->seek(mapID + MKTAG(0, 0, 0, (uint8)worldCount));
- worldCount++) ;
+ tileRes->seek(mapID + worldCount);
+ worldCount++) {
+ warning("MapID: %s %08x res: %s % 08x", tag2str(mapID), mapID, tag2str(mapID + worldCount), mapID + worldCount);
+ }
// Allocate the map data array
mapList = new WorldMapData[worldCount]();
@@ -1512,11 +1514,11 @@ void initMaps(void) {
for (i = 0; i < worldCount; i++) {
WorldMapData *mapData = &mapList[i];
int16 j;
- int iMapID = mapID + MKTAG(0, 0, 0, (uint8)i);
- int iMetaID = metaID + MKTAG(0, 0, 0, (uint8)i);
- int iTagRefID = tagDataID + MKTAG(0, 0, 0, (uint8)i);
- int iAssocID = assocID + MKTAG(0, 0, 0, (uint8)i);
- int iActiveItemID = tagID + MKTAG(0, 0, 0, (uint8)i);
+ int iMapID = mapID + i;
+ int iMetaID = metaID + i;
+ int iTagRefID = tagDataID + i;
+ int iAssocID = assocID + i;
+ int iActiveItemID = tagID + i;
// Initialize the world ID
mapData->worldID = WorldBaseID + i;
@@ -1584,7 +1586,7 @@ void initMaps(void) {
mapData->metaCount = metaTileCount;
// Compute the number of active items in list
- mapData->activeCount = tileRes->size(tagID + MKTAG(0, 0, 0, (uint8)i))
+ mapData->activeCount = tileRes->size(tagID + i)
/ sizeof(ActiveItem); // Not portable?
// Allocate an object ripping table ID list
@@ -2326,11 +2328,11 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
stack[layer] = (cacheIndex);
assert(plIndex >= 0);
- assert(plIndex * sizeof(Platform) < tileRes->size(platformID + MKTAG(0, 0, 0, mapNum)));
+ assert(plIndex * sizeof(Platform) < tileRes->size(platformID + mapNum));
debugC(3, kDebugLoading, "- plIndex: %d", plIndex);
// Now, load the actual metatile data...
- if (tileRes->seek(platformID + MKTAG(0, 0, 0, mapNum))) {
+ if (tileRes->seek(platformID + mapNum)) {
if (tileRes->skip(plIndex * sizeof(Platform))) {
readPlatform(tileRes, pce->pl);
return &pce->pl;
Commit: e1b7e43878ca717107e7e0ef556fb9a083f6d48a
https://github.com/scummvm/scummvm/commit/e1b7e43878ca717107e7e0ef556fb9a083f6d48a
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:11+02:00
Commit Message:
SAGA2: Remove dlist usage in loadSpriteBanks
Changed paths:
engines/saga2/sprite.cpp
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index 133321f9f7..52713a33f5 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -589,7 +589,6 @@ void ActorAppearance::loadSpriteBanks(int16 banksNeeded) {
WriteStatusF(2, "Loading Banks: %x", banksNeeded);
// Make this one the most recently used entry
- remove();
appearanceLRU.push_back(this);
// Load in additional sprite banks if requested...
Commit: 805fc06ed2812c65f43ba52748e5c06eb5d03a73
https://github.com/scummvm/scummvm/commit/805fc06ed2812c65f43ba52748e5c06eb5d03a73
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:11+02:00
Commit Message:
SAGA2: Load sprite resources portably
Changed paths:
engines/saga2/sprite.cpp
engines/saga2/sprite.h
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index 52713a33f5..cb530043c7 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -250,7 +250,7 @@ void DrawCompositeMaskedSprite(
// Unpack the sprite into the temp map
- unpackSprite(&sprMap, (uint8 *)(sp + 1));
+ unpackSprite(&sprMap, sp->_data);
// Blit the temp map onto the composite map
@@ -361,7 +361,7 @@ void DrawSprite(
sprMap.data = (uint8 *)getQuickMem(sprMap.bytes());
// Unpack the sprite into the temp map
- unpackSprite(&sprMap, (uint8 *)(sp + 1));
+ unpackSprite(&sprMap, sp->_data);
// Blit to the port
port.setMode(drawModeMatte);
@@ -391,7 +391,7 @@ void DrawColorMappedSprite(
sprReMap.data = (uint8 *)getQuickMem(sprReMap.bytes());
// Unpack the sprite into the temp map
- unpackSprite(&sprMap, (uint8 *)(sp + 1));
+ unpackSprite(&sprMap, sp->_data);
memset(sprReMap.data, 0, sprReMap.bytes());
@@ -429,7 +429,7 @@ void ExpandColorMappedSprite(
sprMap.data = (uint8 *)getQuickMem(sprMap.bytes());
// Unpack the sprite into the temp map
- unpackSprite(&sprMap, (uint8 *)(sp + 1));
+ unpackSprite(&sprMap, sp->_data);
// remap the sprite to the color table given
compositePixels(
@@ -458,7 +458,7 @@ uint8 GetSpritePixel(
sprMap.data = (uint8 *)getQuickMem(sprMap.bytes());
// Unpack the sprite into the temp map
- unpackSprite(&sprMap, (uint8 *)(sp + 1));
+ unpackSprite(&sprMap, sp->_data);
// Map the coords to the bitmap and return the pixel
if (flipped) {
@@ -513,7 +513,7 @@ uint16 visiblePixelsInSprite(
sprMap.size = sp->size;
sprMap.data = (uint8 *)getQuickMem(sprMap.bytes());
- unpackSprite(&sprMap, (uint8 *)(sp + 1));
+ unpackSprite(&sprMap, sp->_data);
org.x = drawPos.x - xMin;
org.y = drawPos.y - yMin;
@@ -594,8 +594,11 @@ void ActorAppearance::loadSpriteBanks(int16 banksNeeded) {
// Load in additional sprite banks if requested...
for (bank = 0; bank < (long)elementsof(spriteBanks); bank++) {
// Load the sprite handle...
- if (spriteBanks[bank] == nullptr && (banksNeeded & (1 << bank)))
- spriteBanks[bank] = (SpriteSet *)spriteRes->loadResource(id + MKTAG(0, 0, 0, bank), "sprite bank");
+ if (spriteBanks[bank] == nullptr && (banksNeeded & (1 << bank))) {
+ Common::SeekableReadStream *stream = loadResourceToStream(spriteRes, id + MKTAG(0, 0, 0, bank), "sprite bank");
+ spriteBanks[bank] = new SpriteSet(stream);
+ delete stream;
+ }
}
}
@@ -705,13 +708,45 @@ void ReleaseActorAppearance(ActorAppearance *aa) {
Sprite initialization routines
* ===================================================================== */
-static void readSpriteResource(hResContext *con, SpriteSet &spr) {
- spr.count = con->readU32LE();
- spr.offsets[0] = con->readU32LE();
+Sprite::Sprite(Common::SeekableReadStream *stream) {
+ size.x = stream->readSint16LE();
+ size.y = stream->readSint16LE();
+ offset.x = stream->readSint16LE();
+ offset.y = stream->readSint16LE();
+
+ int data_size = size.x * size.y;
+ _data = (byte *)malloc(data_size * sizeof(byte));
+ stream->read(_data, data_size);
+}
+
+Sprite::~Sprite() {
+ free(_data);
+}
+
+SpriteSet::SpriteSet(Common::SeekableReadStream *stream) {
+ count = stream->readUint32LE();
+ _sprites = (Sprite **)malloc(count * sizeof(Sprite *));
+
+ for (uint i = 0; i < count; ++i) {
+ stream->seek(4 + i * 4);
+ uint32 offset = stream->readUint32LE();
+ stream->seek(offset);
+ _sprites[i] = new Sprite(stream);
+ }
+}
+
+SpriteSet::~SpriteSet() {
+ for (int i = 0; i < count; ++i) {
+ if (_sprites[i])
+ delete _sprites[i];
+ }
+
+ free(_sprites);
}
void initSprites(void) {
int i;
+ Common::SeekableReadStream *stream = nullptr;
spriteRes = resFile->newContext(spriteGroupID, "sprite resources");
if (!spriteRes->_valid)
@@ -727,15 +762,15 @@ void initSprites(void) {
assert(schemeRes && schemeRes->_valid);
// object sprites
- objectSprites = (SpriteSet *)spriteRes->loadResource(objectSpriteID, "object sprites");
- //if (spriteRes->seek(objectSpriteID) == 0)
- // error("Unable to load object sprites");
-
- //readSpriteResource(spriteRes, *objectSprites)
+ stream = loadResourceToStream(spriteRes, objectSpriteID, "object sprites");
+ objectSprites = new SpriteSet(stream);
+ delete stream;
assert(objectSprites);
// intagible object sprites
- mentalSprites = (SpriteSet *)spriteRes->loadResource(mentalSpriteID, "mental sprites");
+ stream = loadResourceToStream(spriteRes, mentalSpriteID, "mental sprites");
+ mentalSprites = new SpriteSet(stream);
+ delete stream;
assert(mentalSprites);
for (i = 0; i < maxWeaponSpriteSets; i++) {
@@ -748,12 +783,14 @@ void initSprites(void) {
continue;
}
- weaponSprites[i] = (SpriteSet *)spriteRes->loadResource(
- weaponSpriteID,
- "weapon sprite set");
+ stream = loadResourceToStream(spriteRes, weaponSpriteID, "weapon sprite set");
+ weaponSprites[i] = new SpriteSet(stream);
+ delete stream;
}
- missileSprites = (SpriteSet *)spriteRes->loadResource(missileSpriteID, "missle sprites");
+ stream = loadResourceToStream(spriteRes, missileSpriteID, "missle sprites");
+ missileSprites = new SpriteSet(stream);
+ delete stream;
initQuickMem(0x10000);
diff --git a/engines/saga2/sprite.h b/engines/saga2/sprite.h
index cdf585eb8b..b21e738ae7 100644
--- a/engines/saga2/sprite.h
+++ b/engines/saga2/sprite.h
@@ -49,6 +49,10 @@ class gPixelMap;
struct Sprite {
Extent16 size; // size of sprite
Point16 offset; // sprite origin point
+ byte *_data;
+
+ Sprite(Common::SeekableReadStream *stream);
+ ~Sprite();
// sprite data follows.
};
@@ -57,13 +61,16 @@ struct Sprite {
struct SpriteSet {
uint32 count; // number of images in the range
- uint32 offsets[1]; // offsets into sprite list
+ Sprite **_sprites;
// (variable-length array)
// sprite structures follow table
+ SpriteSet(Common::SeekableReadStream *stream);
+ ~SpriteSet();
+
// Member function to return a sprite from the set
Sprite *sprite(int16 index) {
- return (Sprite *)((uint8 *)this + offsets[index]);
+ return _sprites[index];
}
// Sprite &operator[]( int32 index )
Commit: 4b5ab189f339a61b4bfdfd5f4c049bf82db02331
https://github.com/scummvm/scummvm/commit/4b5ab189f339a61b4bfdfd5f4c049bf82db02331
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:11+02:00
Commit Message:
SAGA2: Fix alloc-dealloc mismatch in cleanupSprites
Changed paths:
engines/saga2/sprite.cpp
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index cb530043c7..a8cddcede4 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -809,16 +809,16 @@ void cleanupSprites(void) {
cleanupQuickMem();
if (objectSprites)
- free(objectSprites);
+ delete objectSprites;
objectSprites = nullptr;
if (mentalSprites)
- free(mentalSprites);
+ delete mentalSprites;
mentalSprites = nullptr;
for (i = 0; i < maxWeaponSpriteSets; i++) {
if (weaponSprites[i]) {
- free(weaponSprites[i]);
+ delete weaponSprites[i];
weaponSprites[i] = nullptr;
}
}
Commit: dfd278c3004ec804bc0e810ca41031621b973ec2
https://github.com/scummvm/scummvm/commit/dfd278c3004ec804bc0e810ca41031621b973ec2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:11+02:00
Commit Message:
SAGA2: Print out opcodes during execution
Changed paths:
engines/saga2/interp.cpp
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 104277ca02..4d12eb7e74 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -499,6 +499,8 @@ char *objectName(int16 segNum, uint16 segOff) {
return "???";
}
+#define D_OP(x) debugC(1, kDebugScripts, "[%04ld]: %s", (pc - codeSeg), #x)
+
bool Thread::interpret(void) {
uint8 *pc,
*addr;
@@ -516,38 +518,46 @@ bool Thread::interpret(void) {
for (instruction_count = 0; instruction_count < maxTimeSlice; instruction_count++) {
switch (op = *pc++) {
case op_dup:
+ D_OP(op_dup);
*--stack = stack[0]; // duplicate value on stack
break;
case op_drop: // drop word on stack
+ D_OP(op_drop);
stack++;
break;
case op_zero: // constant integer of zero
+ D_OP(op_zero);
*--stack = 0; // push integer on stack
break;
case op_one: // constant integer of one
+ D_OP(op_one);
*--stack = 1; // push integer on stack
break;
case op_strlit: // string literal (also pushes word)
case op_constint: // constant integer
+ D_OP(op_strlit);
IMMED_WORD(w); // pick up word after opcode
*--stack = w; // push integer on stack
break;
case op_getflag: // get a flag
+ D_OP(op_getflag);
addr = bitAddress(this, &pc, &w); // get address of bit
*--stack = (*addr) & w ? 1 : 0; // true or false if bit set
break;
case op_getint: // read from integer field (mode)
+ D_OP(op_getint);
addr = byteAddress(this, &pc); // get address of integer
*--stack = *(uint16 *)addr; // get integer from address
break;
case op_getbyte: // read from integer field (mode)
+ D_OP(op_getbyte);
addr = byteAddress(this, &pc); // get address of integer
*--stack = *addr; // get byte from address
break;
@@ -557,39 +567,45 @@ bool Thread::interpret(void) {
// 'vput' which consumes the variable.
case op_putflag: // put to flag bit (mode)
+ D_OP(op_putflag);
addr = bitAddress(this, &pc, &w); // get address of bit
if (*stack) *addr |= w; // set bit if stack non-zero
else *addr &= ~w; // else clear it
break;
case op_putflag_v: // put to flag bit (mode)
+ D_OP(op_putflag_v);
addr = bitAddress(this, &pc, &w); // get address of bit
if (*stack++) *addr |= w; // set bit if stack non-zero
else *addr &= ~w; // else clear it
break;
case op_putint: // put to integer field (mode)
+ D_OP(op_putint);
addr = byteAddress(this, &pc); // get address of integer
*(uint16 *)addr = *stack; // put integer to address
break;
case op_putint_v: // put to integer field (mode)
+ D_OP(op_putint_v);
addr = byteAddress(this, &pc); // get address of integer
*(uint16 *)addr = *stack++; // put integer to address
break;
case op_putbyte: // put to byte field (mode)
+ D_OP(op_putbyte);
addr = byteAddress(this, &pc); // get address of integer
*addr = *stack; // put integer to address
break;
case op_putbyte_v: // put to byte field (mode)
+ D_OP(op_putbyte_v);
addr = byteAddress(this, &pc); // get address of integer
*addr = *stack++; // put integer to address
break;
case op_enter:
-
+ D_OP(op_enter);
print_script_name(pc - 1);
*--stack = framePtr; // save old frame ptr on stack
framePtr = (uint8 *)stack - stackBase; // new frame pointer
@@ -600,11 +616,10 @@ bool Thread::interpret(void) {
// function calls
case op_return: // return with value
+ D_OP(op_return);
returnVal = *stack++;
case op_return_v: // return with void
-
- debugC(1, kDebugScripts, "Scripts: op_return_v");
-
+ D_OP(op_return_v);
stack = (int16 *)(stackBase + framePtr); // pop autos
framePtr = *stack++; // restore frame pointer
@@ -631,6 +646,7 @@ bool Thread::interpret(void) {
break;
case op_call_near: // call function in same seg
+ D_OP(op_call_near);
n = *pc++; // get argument count
@@ -650,6 +666,7 @@ bool Thread::interpret(void) {
break;
case op_call_far: // call function in other seg
+ D_OP(op_call_far);
n = *pc++; // get argument count
@@ -673,6 +690,11 @@ bool Thread::interpret(void) {
case op_ccall: // call C function
case op_ccall_v: // call C function
+ if (op == op_ccall)
+ D_OP(op_ccall);
+ else
+ D_OP(op_call_v);
+
n = *pc++; // get argument count
IMMED_WORD(w); // get function number
if (w < 0 || w >= globalCFuncs.numEntries)
@@ -697,6 +719,11 @@ bool Thread::interpret(void) {
case op_call_member: // call member function
case op_call_member_v: // call member function (void)
+ if (op == op_call_member)
+ D_OP(op_call_member);
+ else
+ D_OP(op_call_member_v);
+
n = *pc++; // get argument count
w = *pc++; // index of member function
@@ -803,36 +830,37 @@ bool Thread::interpret(void) {
break;
case op_jmp_true_v:
-
+ D_OP(op_jmp_true_v);
IMMED_WORD(w); // pick up word after address
if (*stack++ != 0) BRANCH(w); // if stack is non-zero, jump
break;
case op_jmp_false_v:
-
+ D_OP(op_jmp_false_v);
IMMED_WORD(w); // pick up word after address
if (*stack++ == 0) BRANCH(w); // if stack is zero, jump
break;
case op_jmp_true:
-
+ D_OP(op_true);
IMMED_WORD(w); // pick up word after address
if (*stack != 0) BRANCH(w); // if stack is non-zero. jump
break;
case op_jmp_false:
-
+ D_OP(op_false);
IMMED_WORD(w); // pick up word after address
if (*stack == 0) BRANCH(w); // if stack is zero, jump
break;
case op_jmp:
-
+ D_OP(op_jmp);
IMMED_WORD(w); // pick up word after address
BRANCH(w); // jump relative to module
break;
case op_jmp_switch:
+ D_OP(op_jmp_switch);
IMMED_WORD(n); // n = number of cases
w = *stack++; // w = value on stack
{
@@ -857,6 +885,10 @@ bool Thread::interpret(void) {
case op_jmp_seedrandom: // seeded random jump
case op_jmp_random: // random jump
+ if (op == op_jmp_seedrandom)
+ D_OP(op_jmp_seedrandom);
+ else
+ D_OP(op_random);
if (op == op_jmp_random) {
IMMED_WORD(n); // n = number of cases
@@ -890,32 +922,39 @@ bool Thread::interpret(void) {
break;
case op_negate:
+ D_OP(op_negate);
*stack = - *stack;
break; // negate TOS
case op_not:
+ D_OP(op_not);
*stack = ! *stack;
break; // not TOS
case op_compl:
+ D_OP(op_compl);
*stack = ~ *stack;
break; // complement TOS
case op_inc_v:
+ D_OP(op_inc_v);
addr = byteAddress(this, &pc); // get address of integer
*(uint16 *)addr += 1; // bump value by one
break;
case op_dec_v:
+ D_OP(op_dec_v);
addr = byteAddress(this, &pc); // get address of integer
*(uint16 *)addr -= 1; // bump value by one
break;
case op_postinc:
+ D_OP(op_postinc);
addr = byteAddress(this, &pc); // get address of integer
*--stack = *(uint16 *)addr; // get integer from address
*(uint16 *)addr += 1; // bump value by one
break;
case op_postdec:
+ D_OP(op_postdec);
addr = byteAddress(this, &pc); // get address of integer
*--stack = *(uint16 *)addr; // get integer from address
*(uint16 *)addr -= 1; // bump value by one
@@ -927,78 +966,97 @@ bool Thread::interpret(void) {
// dropped variable.
case op_add:
+ D_OP(op_add);
w = (stack[1] + stack[0]);
*++stack = w;
break;
case op_sub:
+ D_OP(op_sub);
w = (stack[1] - stack[0]);
*++stack = w;
break;
case op_mul:
+ D_OP(op_mul);
w = (stack[1] * stack[0]);
*++stack = w;
break;
case op_div:
+ D_OP(op_div);
w = (stack[1] / stack[0]);
*++stack = w;
break;
case op_mod:
+ D_OP(op_mod);
w = (stack[1] % stack[0]);
*++stack = w;
break;
case op_eq:
+ D_OP(op_eq);
w = (stack[1] == stack[0]);
*++stack = w;
break;
case op_ne:
+ D_OP(op_ne);
w = (stack[1] != stack[0]);
*++stack = w;
break;
case op_gt:
+ D_OP(op_gt);
w = (stack[1] > stack[0]);
*++stack = w;
break;
case op_lt:
+ D_OP(op_lt);
w = (stack[1] < stack[0]);
*++stack = w;
break;
case op_ge:
+ D_OP(op_ge);
w = (stack[1] >= stack[0]);
*++stack = w;
break;
case op_le:
+ D_OP(op_le);
w = (stack[1] <= stack[0]);
*++stack = w;
break;
case op_rsh:
+ D_OP(op_rsh);
w = (stack[1] >> stack[0]);
*++stack = w;
break;
case op_lsh:
+ D_OP(op_lsh);
w = (stack[1] << stack[0]);
*++stack = w;
break;
case op_and:
+ D_OP(op_and);
w = (stack[1] & stack[0]);
*++stack = w;
break;
case op_or:
+ D_OP(op_or);
w = (stack[1] | stack[0]);
*++stack = w;
break;
case op_xor:
+ D_OP(op_xor);
w = (stack[1] ^ stack[0]);
*++stack = w;
break;
case op_land:
+ D_OP(op_land);
w = (stack[1] && stack[0]);
*++stack = w;
break;
case op_lor:
+ D_OP(op_lor);
w = (stack[1] || stack[0]);
*++stack = w;
break;
case op_lxor:
+ D_OP(op_lxor);
w = (stack[1] && !stack[0]) || (!stack[1] && stack[0]);
*++stack = w;
break;
Commit: 6742ee174d46d9f491aa55a7a09f13c773101681
https://github.com/scummvm/scummvm/commit/6742ee174d46d9f491aa55a7a09f13c773101681
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:12+02:00
Commit Message:
SAGA2: Implement Point16 loading with Common::SeekableReadStream
Changed paths:
engines/saga2/rect.cpp
engines/saga2/rect.h
engines/saga2/sprite.cpp
diff --git a/engines/saga2/rect.cpp b/engines/saga2/rect.cpp
index a3b676b34d..ca53eda78a 100644
--- a/engines/saga2/rect.cpp
+++ b/engines/saga2/rect.cpp
@@ -29,6 +29,11 @@
namespace Saga2 {
+void Point16::load(Common::SeekableReadStream *stream) {
+ x = stream->readSint16LE();
+ y = stream->readSint16LE();
+}
+
Rect16 bound(const Rect16 a, const Rect16 b) {
int16 x1, x2, y1, y2;
diff --git a/engines/saga2/rect.h b/engines/saga2/rect.h
index 381d4fdc06..4222aebcd7 100644
--- a/engines/saga2/rect.h
+++ b/engines/saga2/rect.h
@@ -57,6 +57,9 @@ public:
y = HIWORD(lparam);
}
#endif
+
+ void load(Common::SeekableReadStream *stream);
+
// Point16 operators
friend Point16 operator+ (Point16 a, Point16 b) {
return Point16(a.x + b.x, a.y + b.y);
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index a8cddcede4..54dc295021 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -709,10 +709,8 @@ void ReleaseActorAppearance(ActorAppearance *aa) {
* ===================================================================== */
Sprite::Sprite(Common::SeekableReadStream *stream) {
- size.x = stream->readSint16LE();
- size.y = stream->readSint16LE();
- offset.x = stream->readSint16LE();
- offset.y = stream->readSint16LE();
+ size.load(stream);
+ offset.load(stream);
int data_size = size.x * size.y;
_data = (byte *)malloc(data_size * sizeof(byte));
Commit: a825bbbcb713df3befd14f5bbd743623029b42c9
https://github.com/scummvm/scummvm/commit/a825bbbcb713df3befd14f5bbd743623029b42c9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:12+02:00
Commit Message:
SAGA2: Print stack on execution
Changed paths:
engines/saga2/interp.cpp
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 4d12eb7e74..cdb68fa2f4 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -499,6 +499,22 @@ char *objectName(int16 segNum, uint16 segOff) {
return "???";
}
+static void print_stack(int16 *stackBase, int16 *stack) {
+ int16 *end = (int16 *)((byte *)stackBase + kStackSize - initialStackFrameSize);
+ int size = end - stack;
+
+ if (size > 10)
+ end = stack + 10;
+
+ debugCN(2, kDebugScripts, "stack size: %d: [", size);
+ for (int16 *i = stack; i <= end; i++)
+ debugCN(2, kDebugScripts, "%d ", *i);
+ if (size > 10)
+ debugCN(2, kDebugScripts, "... ");
+
+ debugC(2, kDebugScripts, "]");
+}
+
#define D_OP(x) debugC(1, kDebugScripts, "[%04ld]: %s", (pc - codeSeg), #x)
bool Thread::interpret(void) {
@@ -516,6 +532,8 @@ bool Thread::interpret(void) {
thisThread = this; // set current thread address
for (instruction_count = 0; instruction_count < maxTimeSlice; instruction_count++) {
+ print_stack((int16 *)stackBase, stack);
+
switch (op = *pc++) {
case op_dup:
D_OP(op_dup);
Commit: 9b298a0328a655dfa871268de51e143ef6645bd3
https://github.com/scummvm/scummvm/commit/9b298a0328a655dfa871268de51e143ef6645bd3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:12+02:00
Commit Message:
SAGA2: Print out address modes during script execution
Changed paths:
engines/saga2/interp.cpp
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index cdb68fa2f4..287f67824a 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -206,24 +206,27 @@ uint8 *byteAddress(Thread *th, uint8 **pcPtr) {
uint8 *pc = *pcPtr,
*addr;
uint16 seg,
- offset,
+ offset, offset2,
index,
*arg;
switch (*pc++) {
case addr_data:
IMMED_WORD(offset);
+ debugC(3, kDebugScripts, "byteAddress: data[%d] = %d", offset, dataSegment[offset]);
*pcPtr = pc;
return &dataSegment[offset];
case addr_near:
IMMED_WORD(offset);
+ debugC(3, kDebugScripts, "byteAddress: near[%d] = %d", offset, th->codeSeg[offset]);
*pcPtr = pc;
return th->codeSeg + offset;
case addr_far:
IMMED_WORD(seg);
IMMED_WORD(offset);
+ debugC(3, kDebugScripts, "byteAddress: far[%d:%d] = %d", seg, offset, *segmentAddress(seg, offset));
*pcPtr = pc;
return segmentAddress(seg, offset);
@@ -231,17 +234,20 @@ uint8 *byteAddress(Thread *th, uint8 **pcPtr) {
IMMED_WORD(seg);
IMMED_WORD(offset);
addr = segmentArrayAddress(seg, offset);
- IMMED_WORD(offset);
+ IMMED_WORD(offset2);
+ debugC(3, kDebugScripts, "byteAddress: array[%d:%d:%d] = %d", seg, offset, offset2, addr[offset2]);
*pcPtr = pc;
- return addr + offset;
+ return addr + offset2;
case addr_stack:
IMMED_WORD(offset);
+ debugC(3, kDebugScripts, "byteAddress: stack[%d] = %d", offset, *(th->stackBase + th->framePtr + (int16)offset));
*pcPtr = pc;
return th->stackBase + th->framePtr + (int16)offset;
case addr_thread:
IMMED_WORD(offset);
+ debugC(3, kDebugScripts, "byteAddress: thread[%d] = %d", offset, *((uint8 *)&th->threadArgs + offset));
*pcPtr = pc;
return (uint8 *)&th->threadArgs + offset;
@@ -249,10 +255,10 @@ uint8 *byteAddress(Thread *th, uint8 **pcPtr) {
IMMED_WORD(offset);
arg = (uint16 *)(th->stackBase + th->framePtr + 8);
*pcPtr = pc;
+ debugC(3, kDebugScripts, "byteAddress: this[%d]", offset);
if (arg[0] == dataSegIndex)
return &dataSegment[arg[1] + offset];
- return segmentArrayAddress(arg[0],
- arg[1]) + offset;
+ return segmentArrayAddress(arg[0], arg[1]) + offset;
case addr_deref:
@@ -268,6 +274,7 @@ uint8 *byteAddress(Thread *th, uint8 **pcPtr) {
// within the object.
IMMED_WORD(seg);
IMMED_WORD(offset);
+ debugC(3, kDebugScripts, "byteAddress: deref[%d:%d:%d] = %d", seg, index, offset, *(segmentAddress(seg, index) + offset));
*pcPtr = pc;
// Compute address of object
@@ -499,17 +506,19 @@ char *objectName(int16 segNum, uint16 segOff) {
return "???";
}
+#define STACK_PRINT_DEPTH 30
+
static void print_stack(int16 *stackBase, int16 *stack) {
int16 *end = (int16 *)((byte *)stackBase + kStackSize - initialStackFrameSize);
int size = end - stack;
- if (size > 10)
- end = stack + 10;
+ if (size > STACK_PRINT_DEPTH)
+ end = stack + STACK_PRINT_DEPTH;
debugCN(2, kDebugScripts, "stack size: %d: [", size);
for (int16 *i = stack; i <= end; i++)
debugCN(2, kDebugScripts, "%d ", *i);
- if (size > 10)
+ if (size > STACK_PRINT_DEPTH)
debugCN(2, kDebugScripts, "... ");
debugC(2, kDebugScripts, "]");
Commit: 0e0bd85b40c6731e4dbebf4f731aa231f894fcdb
https://github.com/scummvm/scummvm/commit/0e0bd85b40c6731e4dbebf4f731aa231f894fcdb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:12+02:00
Commit Message:
Revert "SAGA2: Make custom alarms use OSystem::getMillis"
This reverts commit daac47c9fc563303bbca3ef27cfa7070424e7d26.
Changed paths:
engines/saga2/timer.cpp
diff --git a/engines/saga2/timer.cpp b/engines/saga2/timer.cpp
index 6d15cb985f..ec3430a6d6 100644
--- a/engines/saga2/timer.cpp
+++ b/engines/saga2/timer.cpp
@@ -116,18 +116,18 @@ void resumeTimer(void) {
* ====================================================================== */
void Alarm::set(uint32 dur) {
- basetime = g_system->getMillis();
+ basetime = gameTime;
duration = dur;
}
bool Alarm::check(void) {
- return ((uint32)(g_system->getMillis() - basetime) > duration * 1000);
+ return ((uint32)(gameTime - basetime) > duration);
}
// time elapsed since alarm set
uint32 Alarm::elapsed(void) {
- return (uint32)(g_system->getMillis() - basetime);
+ return (uint32)(gameTime - basetime);
}
} // end of namespace Saga2
Commit: aee8d39e7c72d9fcfc392c63f76180d221a632f4
https://github.com/scummvm/scummvm/commit/aee8d39e7c72d9fcfc392c63f76180d221a632f4
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:12+02:00
Commit Message:
SAGA2: Load TileBank and MapHeader with Common::SeekableReadStream
Changed paths:
engines/saga2/tile.cpp
engines/saga2/tile.h
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index fd883b358a..2a270c20b4 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -1410,37 +1410,37 @@ void cleanupTileTasks(void) {
//-----------------------------------------------------------------------
// Initialize map data
-TileBank::TileBank(hResContext *con, hResID id) {
- const int tileInfoSize = 28;
- int size = con->size(id);
- int count = (size - 4) / tileInfoSize; // Skip 4 bytes (numTiles)
-
- if (!con->seek(id)) {
- _numTiles = 0;
- _tileArray = nullptr;
- return;
- }
+TileBank::TileBank(Common::SeekableReadStream *stream) {
+ _numTiles = stream->readUint32LE();
+ _tileArray = new TileInfo[_numTiles];
- _numTiles = con->readU32LE();
- _tileArray = new TileInfo[count];
- for (int i = 0; i < count; ++i) {
- _tileArray[i].offset = con->readU32LE();
+ for (uint i = 0; i < _numTiles; ++i) {
+ _tileArray[i].offset = stream->readUint32LE();
TileAttrs *att = &_tileArray[i].attrs;
- att->terrainHeight = con->readByte();
- att->height = con->readByte();
- att->terrainMask = con->readU16LE();
- att->fgdTerrain = con->readByte();
- att->bgdTerrain = con->readByte();
- con->read(att->reserved0, 8);
- att->maskRule = con->readByte();
- att->altMask = con->readByte();
- con->read(att->cornerHeight, 4);
- att->cycleRange = con->readByte();
- att->tileFlags = con->readByte();
- att->reserved1 = con->readU16LE();
+ att->terrainHeight = stream->readByte();
+ att->height = stream->readByte();
+ att->terrainMask = stream->readUint16LE();
+ att->fgdTerrain = stream->readByte();
+ att->bgdTerrain = stream->readByte();
+ stream->read(att->reserved0, 8);
+ att->maskRule = stream->readByte();
+ att->altMask = stream->readByte();
+ stream->read(att->cornerHeight, 4);
+ att->cycleRange = stream->readByte();
+ att->tileFlags = stream->readByte();
+ att->reserved1 = stream->readUint16LE();
}
}
+MapHeader::MapHeader(Common::SeekableReadStream *stream) {
+ size = stream->readSint16LE();
+ edgeType = stream->readSint16LE();
+ mapData = new uint16[size * size];
+
+ for (int i = 0; i < size * size; ++i)
+ mapData[i] = stream->readUint16LE();
+}
+
static void readMetaTile(hResContext *con, MetaTile &til) {
til.highestPixel = con->readU16LE();
til.banksNeeded._b[0] = con->readU32LE();
@@ -1452,15 +1452,6 @@ static void readMetaTile(hResContext *con, MetaTile &til) {
til.properties = con->readU32LE();
}
-static void readMap(hResContext *con, MapHeader *map) {
- map->size = con->readS16LE();
- map->edgeType = con->readS16LE();
- map->mapData = new uint16[map->size * map->size];
-
- for (int i = 0; i < map->size * map->size; ++i)
- map->mapData[i] = con->readU16LE();
-}
-
static void readActiveItem(hResContext *con, ActiveItem &itm) {
// FIXME: 32-bit pointer to 64-bit pointer conversion.
// Is this dangerous?
@@ -1484,6 +1475,7 @@ static void readActiveItem(hResContext *con, ActiveItem &itm) {
void initMaps(void) {
int16 i;
+ Common::SeekableReadStream *stream;
const int metaTileSize = 30;
const int tileRefSize = 4;
const int assocSize = 2;
@@ -1491,7 +1483,9 @@ void initMaps(void) {
// Load all of the tile terrain banks
for (i = 0; i < maxBanks; i++) {
- tileBanks[i] = new TileBank(tileRes, tileTerrainID + i);
+ stream = loadResourceToStream(tileRes, tileTerrainID + i, "tile terrain bank");
+ tileBanks[i] = new TileBank(stream);
+ delete stream;
if (tileBanks[i]->_tileArray == nullptr) {
delete tileBanks[i];
tileBanks[i] = nullptr;
@@ -1524,9 +1518,9 @@ void initMaps(void) {
mapData->worldID = WorldBaseID + i;
// Load the map
- mapData->map = new MapHeader;
- tileRes->seek(iMapID);
- readMap(tileRes, mapData->map);
+ stream = loadResourceToStream(tileRes, iMapID, "world map");
+ mapData->map = new MapHeader(stream);
+ delete stream;
if (mapData->map == nullptr)
error("Unable to load map");
debugC(2, kDebugTiles, "map: size = %d, mapData = %p", mapData->map->size, (void*)mapData->map->mapData);
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index cfcc1fbc42..13afea3d86 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -322,7 +322,7 @@ public:
_tileArray = nullptr;
}
- TileBank(hResContext *con, hResID id);
+ TileBank(Common::SeekableReadStream *stream);
TileInfo *tile(uint16 index) {
return &_tileArray[index];
@@ -840,6 +840,8 @@ struct MapHeader {
int16 size; // size of map
int16 edgeType; // edge type of map
uint16 *mapData; // start of map array
+
+ MapHeader(Common::SeekableReadStream *stream);
};
enum mapEdgeTypes {
Commit: a4fcdbb8f5b4af6b2ac4419105d9b30569966dd8
https://github.com/scummvm/scummvm/commit/a4fcdbb8f5b4af6b2ac4419105d9b30569966dd8
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:12+02:00
Commit Message:
SAGA2: Get rid of pointer arithmetics for metaList
Changed paths:
engines/saga2/tile.cpp
engines/saga2/tile.h
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 2a270c20b4..a4141b29d8 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -1441,15 +1441,24 @@ MapHeader::MapHeader(Common::SeekableReadStream *stream) {
mapData[i] = stream->readUint16LE();
}
-static void readMetaTile(hResContext *con, MetaTile &til) {
- til.highestPixel = con->readU16LE();
- til.banksNeeded._b[0] = con->readU32LE();
- til.banksNeeded._b[1] = con->readU32LE();
+MetaTile::MetaTile(int ind, Common::SeekableReadStream *stream) {
+ index = ind;
+ highestPixel = stream->readUint16LE();
+ banksNeeded._b[0] = stream->readUint32LE();
+ banksNeeded._b[1] = stream->readUint32LE();
for (int i = 0; i < maxPlatforms; ++i)
- til.stack[i] = con->readU16LE();
+ stack[i] = stream->readUint16LE();
- til.properties = con->readU32LE();
+ properties = stream->readUint32LE();
+}
+
+MetaTileList::MetaTileList(int count, Common::SeekableReadStream *stream) {
+ _count = count;
+ _tiles = (MetaTile **)malloc(_count * sizeof(MetaTile *));
+ for (int i = 0; i < _count; ++i) {
+ _tiles[i] = new MetaTile(i, stream);
+ }
}
static void readActiveItem(hResContext *con, ActiveItem &itm) {
@@ -1526,12 +1535,11 @@ void initMaps(void) {
debugC(2, kDebugTiles, "map: size = %d, mapData = %p", mapData->map->size, (void*)mapData->map->mapData);
int metaTileCount = tileRes->size(iMetaID) / metaTileSize;
- mapData->metaList = new MetaTile[metaTileCount]();
- tileRes->seek(iMetaID);
- for (int k = 0; k < metaTileCount; ++k)
- readMetaTile(tileRes, mapData->metaList[k]);
+ stream = loadResourceToStream(tileRes, iMetaID, "meta tile list");
+ mapData->metaList = new MetaTileList(metaTileCount, stream);
+ delete stream;
- if (mapData->metaList == nullptr)
+ if (mapData->metaList == nullptr || mapData->metaList->_tiles == nullptr)
error("Unable to load meta tile list");
// If there is tag data, load it
@@ -1627,7 +1635,14 @@ void cleanupMaps(void) {
}
// Dump the meta tile list
- delete[] mapData->metaList;
+ if (mapData->metaList) {
+ for (int k = 0; k < mapData->metaList->_count; ++i)
+ if (mapData->metaList->_tiles[i])
+ delete mapData->metaList->_tiles[i];
+
+ free(mapData->metaList->_tiles);
+ }
+ delete mapData->metaList;
// If there is active item data, dump it
if (mapData->activeItemData != nullptr)
@@ -2251,7 +2266,7 @@ RipTableID RipTable::thisID(void) {
MetaTile *MetaTile::metaTileAddress(MetaTileID id) {
return id.map != nullID && id.index != nullID
- ? &(mapList[id.map].metaList)[id.index]
+ ? mapList[id.map].metaList->_tiles[id.index]
: nullptr;
}
@@ -2259,7 +2274,7 @@ MetaTile *MetaTile::metaTileAddress(MetaTileID id) {
// Return this meta tile's ID
MetaTileID MetaTile::thisID(int16 mapNum) {
- return MetaTileID(mapNum, this - mapList[mapNum].metaList);
+ return MetaTileID(mapNum, index);
}
//-----------------------------------------------------------------------
@@ -2291,9 +2306,7 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
PlatformCacheEntry *pce;
assert(layer >= 0);
- assert(this >= mapList[mapNum].metaList
- && this < & (mapList[mapNum].metaList)[
- mapList[mapNum].metaCount]);
+ assert(index != -1);
if (plIndex == nullID) {
return nullptr;
@@ -2344,9 +2357,7 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
RipTable *MetaTile::ripTable(int16 mapNum) {
WorldMapData *mapData = &mapList[mapNum];
- return RipTable::ripTableAddress((mapData->ripTableIDList)[
- this
- - mapData->metaList]);
+ return RipTable::ripTableAddress((mapData->ripTableIDList)[index]);
}
//-----------------------------------------------------------------------
@@ -2355,7 +2366,7 @@ RipTable *MetaTile::ripTable(int16 mapNum) {
RipTableID &MetaTile::ripTableID(int16 mapNum) {
WorldMapData *mapData = &mapList[mapNum];
- return (mapData->ripTableIDList)[this - mapData->metaList];
+ return (mapData->ripTableIDList)[index];
}
/* ====================================================================== *
@@ -2425,7 +2436,7 @@ MetaTilePtr WorldMapData::lookupMeta(TilePoint coords) {
assert(mtile < metaCount);
assert(mtile >= 0);
- return &metaList[mtile];
+ return metaList->_tiles[mtile];
}
@@ -2646,7 +2657,7 @@ inline void drawMetaRow(TilePoint coords, Point16 pos) {
mapEdgeType = curMap->map->edgeType;
uint16 *mapData = curMap->map->mapData;
- MetaTilePtr metaArray = curMap->metaList;
+ MetaTilePtr *metaArray = curMap->metaList->_tiles;
int16 layerLimit;
@@ -2696,7 +2707,7 @@ inline void drawMetaRow(TilePoint coords, Point16 pos) {
if (mtile >= curMap->metaCount) mtile = curMap->metaCount - 1;
- metaPtr = &metaArray[mtile];
+ metaPtr = metaArray[mtile];
put = drawList;
if (metaPtr == nullptr) return;
@@ -3289,7 +3300,7 @@ void maskMetaRow(
mapEdgeType = curMap->map->edgeType;
uint16 *mapData = curMap->map->mapData;
- MetaTilePtr metaArray = curMap->metaList;
+ MetaTilePtr *metaArray = curMap->metaList->_tiles;
int16 layerLimit;
@@ -3336,7 +3347,7 @@ void maskMetaRow(
if (mtile >= curMap->metaCount) mtile = curMap->metaCount - 1;
- metaPtr = &metaArray[mtile];
+ metaPtr = metaArray[mtile];
put = drawList;
if (metaPtr == nullptr) return;
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index 13afea3d86..8c10a63dcd 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -802,6 +802,9 @@ struct MetaTile {
BankBits banksNeeded; // which banks are needed
uint16 stack[maxPlatforms]; // pointer to platforms
uint32 properties; // more drawing optimization
+ int index = -1;
+
+ MetaTile(int ind, Common::SeekableReadStream *stream);
// Return a pointer to a meta tile given its ID
static MetaTile *metaTileAddress(MetaTileID id);
@@ -832,6 +835,14 @@ struct MetaTile {
typedef MetaTile *MetaTilePtr,
* *MetaTileHandle;
+class MetaTileList {
+public:
+ int _count;
+ MetaTile **_tiles;
+
+ MetaTileList(int count, Common::SeekableReadStream *stream);
+};
+
/* ===================================================================== *
MapHeader struct
* ===================================================================== */
@@ -865,7 +876,7 @@ struct WorldMapData {
ObjectID worldID; // The number of this map
MapPtr map; // Map data
- MetaTilePtr metaList; // MetaTile list
+ MetaTileList *metaList; // MetaTile list
TileRefPtr activeItemData; // ActiveItem tileRefs
ActiveItemPtr activeItemList; // ActiveItem list
UWordPtr assocList; // Associations
Commit: f35c05a9def17003b79630fb66a179107e036203
https://github.com/scummvm/scummvm/commit/f35c05a9def17003b79630fb66a179107e036203
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:12+02:00
Commit Message:
SAGA2: Rename class variables MetaTile
Changed paths:
engines/saga2/tile.cpp
engines/saga2/tile.h
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index a4141b29d8..0634b514d9 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -1442,15 +1442,15 @@ MapHeader::MapHeader(Common::SeekableReadStream *stream) {
}
MetaTile::MetaTile(int ind, Common::SeekableReadStream *stream) {
- index = ind;
- highestPixel = stream->readUint16LE();
- banksNeeded._b[0] = stream->readUint32LE();
- banksNeeded._b[1] = stream->readUint32LE();
+ _index = ind;
+ _highestPixel = stream->readUint16LE();
+ _banksNeeded._b[0] = stream->readUint32LE();
+ _banksNeeded._b[1] = stream->readUint32LE();
for (int i = 0; i < maxPlatforms; ++i)
- stack[i] = stream->readUint16LE();
+ _stack[i] = stream->readUint16LE();
- properties = stream->readUint32LE();
+ _properties = stream->readUint32LE();
}
MetaTileList::MetaTileList(int count, Common::SeekableReadStream *stream) {
@@ -2274,14 +2274,14 @@ MetaTile *MetaTile::metaTileAddress(MetaTileID id) {
// Return this meta tile's ID
MetaTileID MetaTile::thisID(int16 mapNum) {
- return MetaTileID(mapNum, index);
+ return MetaTileID(mapNum, _index);
}
//-----------------------------------------------------------------------
// Return the audio theme associated with this metatile
metaTileNoise MetaTile::HeavyMetaMusic(void) {
- return properties & 0xFF;
+ return _properties & 0xFF;
}
//-----------------------------------------------------------------------
@@ -2302,11 +2302,11 @@ static void readPlatform(hResContext *con, Platform &plt) {
}
Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
- uint16 plIndex = stack[layer];
+ uint16 plIndex = _stack[layer];
PlatformCacheEntry *pce;
assert(layer >= 0);
- assert(index != -1);
+ assert(_index != -1);
if (plIndex == nullID) {
return nullptr;
@@ -2332,7 +2332,7 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
pce->platformNum = plIndex;
pce->layerNum = layer;
pce->metaID = thisID(mapNum);
- stack[layer] = (cacheIndex);
+ _stack[layer] = (cacheIndex);
assert(plIndex >= 0);
assert(plIndex * sizeof(Platform) < tileRes->size(platformID + mapNum));
@@ -2357,7 +2357,7 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
RipTable *MetaTile::ripTable(int16 mapNum) {
WorldMapData *mapData = &mapList[mapNum];
- return RipTable::ripTableAddress((mapData->ripTableIDList)[index]);
+ return RipTable::ripTableAddress((mapData->ripTableIDList)[_index]);
}
//-----------------------------------------------------------------------
@@ -2366,7 +2366,7 @@ RipTable *MetaTile::ripTable(int16 mapNum) {
RipTableID &MetaTile::ripTableID(int16 mapNum) {
WorldMapData *mapData = &mapList[mapNum];
- return (mapData->ripTableIDList)[index];
+ return (mapData->ripTableIDList)[_index];
}
/* ====================================================================== *
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index 8c10a63dcd..d317e11d2d 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -797,12 +797,13 @@ typedef uint16 metaTileNoise;
// A "Metatile" is a larger tile made up of smaller tiles.
-struct MetaTile {
- uint16 highestPixel; // more drawing optimization
- BankBits banksNeeded; // which banks are needed
- uint16 stack[maxPlatforms]; // pointer to platforms
- uint32 properties; // more drawing optimization
- int index = -1;
+class MetaTile {
+public:
+ uint16 _highestPixel; // more drawing optimization
+ BankBits _banksNeeded; // which banks are needed
+ uint16 _stack[maxPlatforms]; // pointer to platforms
+ uint32 _properties; // more drawing optimization
+ int _index = -1;
MetaTile(int ind, Common::SeekableReadStream *stream);
Commit: 180a72377fc90d1189c33eb657500a72c74c4356
https://github.com/scummvm/scummvm/commit/180a72377fc90d1189c33eb657500a72c74c4356
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:12+02:00
Commit Message:
SAGA2: Merge timer.cpp and timers.cpp
Changed paths:
R engines/saga2/timer.cpp
engines/saga2/display.cpp
engines/saga2/display.h
engines/saga2/main.cpp
engines/saga2/module.mk
engines/saga2/timers.cpp
diff --git a/engines/saga2/display.cpp b/engines/saga2/display.cpp
index 9d82f0d7e6..e17c7f5513 100644
--- a/engines/saga2/display.cpp
+++ b/engines/saga2/display.cpp
@@ -52,7 +52,6 @@ bool paletteMayHaveChanged = false;
* ===================================================================== */
static uint32 displayStatus = GraphicsInit;
-static bool gameSuspendFlag = false;
static bool paletteSuspendFlag = false;
#ifndef _WIN32
static bool VideoSaved = false;
@@ -81,56 +80,6 @@ void resumeProcessResources(void);
static void switchOn(void);
static void switchOff(void);
-
-/* ===================================================================== *
- Game suspend / resume / terminate
- * ===================================================================== */
-
-// ------------------------------------------------------------------------
-// Suspend all game activity
-
-void suspendGame(void) {
- //dispMM("Suspending game");
- if (!gameSuspendFlag) {
- //localCursorOff();
- //quickSavePalette();
- displayDisable(GameSuspended);
- suspendAudio();
- pauseTimer();
-#ifdef _WIN32
- suspendProcessResources();
-#endif
- gameSuspendFlag = true;
- }
-}
-
-// ------------------------------------------------------------------------
-// check for suspended game
-
-bool gameSuspended(void) {
- return gameSuspendFlag;
-}
-
-// ------------------------------------------------------------------------
-// resume suspended game
-
-void resumeGame(void) {
- if (gameSuspendFlag) {
- gameSuspendFlag = false;
-#ifdef _WIN32
- resumeProcessResources();
-#endif
- resumeTimer();
- resumeAudio();
- displayEnable(GameSuspended);
-#if _WIN32
- if (pWindow)
- pWindow->RestoreMinimizedDisplay();
-#endif
- }
-}
-
-
// ------------------------------------------------------------------------
// end game (normally)
diff --git a/engines/saga2/display.h b/engines/saga2/display.h
index d0db76c16d..17e3f605ee 100644
--- a/engines/saga2/display.h
+++ b/engines/saga2/display.h
@@ -50,13 +50,6 @@ enum DisplayDisabledBecause {
/* ===================================================================== *
Prototypes
* ===================================================================== */
-
-// ------------------------------------------------------------------------
-// Game suspend / resume / terminate
-
-void suspendGame(void);
-bool gameSuspended(void);
-void resumeGame(void);
void endGame(void);
// ------------------------------------------------------------------------
@@ -105,12 +98,6 @@ void popVidState(void);
void suspendAudio(void);
void resumeAudio(void);
-// ------------------------------------------------------------------------
-// Calls to suspend the game timer
-
-void pauseTimer(void);
-void resumeTimer(void);
-
// ------------------------------------------------------------------------
// The display may be disabled for several reasons these track them
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 9795821639..712d8a621f 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -315,10 +315,6 @@ void processEventLoop(bool updateScreen) {
return;
}
- debugC(1, kDebugEventLoop, "EventLoop: check for game suspend");
- if (gameSuspended())
- return;
-
debugC(1, kDebugEventLoop, "EventLoop: audio event loop");
//FIXME: Disabled for debug purposes. Enable and implement later.
//audioEventLoop();
diff --git a/engines/saga2/module.mk b/engines/saga2/module.mk
index 3afe0399f8..7f119420e7 100644
--- a/engines/saga2/module.mk
+++ b/engines/saga2/module.mk
@@ -84,7 +84,6 @@ MODULE_OBJS := \
tileline.o \
tileload.o \
tilemode.o \
- timer.o \
timers.o \
tower.o \
towerfta.o \
diff --git a/engines/saga2/timer.cpp b/engines/saga2/timer.cpp
deleted file mode 100644
index ec3430a6d6..0000000000
--- a/engines/saga2/timer.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * aint32 with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
-#include "saga2/std.h"
-#include "saga2/fta.h"
-#include "saga2/audio.h"
-
-#include "saga2/queues.h"
-#include "saga2/idtypes.h"
-#include "saga2/audiosmp.h"
-#include "saga2/audqueue.h"
-#include "saga2/audiosys.h"
-
-#include "saga2/savefile.h"
-
-namespace Saga2 {
-
-/* ====================================================================== *
- Exports
- * ====================================================================== */
-
-volatile int32 gameTime;
-
-//#ifndef WINKLUDGE
-extern audioInterface *audio;
-//#endif
-
-/* ====================================================================== *
- Locals
- * ====================================================================== */
-
-//static HTIMER gameTimer;
-//static int16 suspendTimerLevel;
-
-/* ====================================================================== *
- Timer Interrupt Hook
- * ====================================================================== */
-
-
-
-void initTimer(void) {
- // Our game master clock is based off of the AIL
- // (Audio Interface Library) timing services
-
- //gameTimer = AIL_register_timer( timerHookFunc );
- //AIL_set_timer_frequency( gameTimer, ticksPerSecond );
- //AIL_start_timer( gameTimer );
-
- gameTime = 0;
-}
-
-void saveTimer(SaveFileConstructor &saveGame) {
- int32 time = gameTime;
-
- saveGame.writeChunk(
- MakeID('T', 'I', 'M', 'E'),
- &time,
- sizeof(time));
-}
-
-void loadTimer(SaveFileReader &saveGame) {
- int32 time;
-
- saveGame.read(&time, sizeof(time));
- gameTime = time;
-}
-
-/*
-void cleanupTimer( void )
-{
- // Nothing to do, actually... AIL_Shutdown takes care of it...
-}
-*/
-
-/* ====================================================================== *
- Timer Control
- * ====================================================================== */
-
-void pauseTimer(void) {
- if (audio)
- audio->suspendGameClock();
-}
-
-void resumeTimer(void) {
- if (audio)
- audio->resumeGameClock();
-}
-
-/* ====================================================================== *
- Alarms
- * ====================================================================== */
-
-void Alarm::set(uint32 dur) {
- basetime = gameTime;
- duration = dur;
-}
-
-bool Alarm::check(void) {
- return ((uint32)(gameTime - basetime) > duration);
-}
-
-// time elapsed since alarm set
-
-uint32 Alarm::elapsed(void) {
- return (uint32)(gameTime - basetime);
-}
-
-} // end of namespace Saga2
diff --git a/engines/saga2/timers.cpp b/engines/saga2/timers.cpp
index 3a45c120e1..1e1e271aad 100644
--- a/engines/saga2/timers.cpp
+++ b/engines/saga2/timers.cpp
@@ -26,7 +26,10 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+#include "common/timer.h"
+
#include "saga2/std.h"
+#include "saga2/fta.h"
#include "saga2/timers.h"
#include "saga2/pool.h"
#include "saga2/objects.h"
@@ -34,6 +37,63 @@
namespace Saga2 {
+volatile int32 gameTime;
+bool timerPaused = false;
+
+void timerCallback(void *refCon) {
+ if (!timerPaused)
+ gameTime++;
+}
+
+void initTimer(void) {
+ gameTime = 0;
+
+ g_vm->getTimerManager()->installTimerProc(&timerCallback, 1000 / 72, nullptr, "saga2");
+}
+
+void pauseTimer() {
+ timerPaused = true;
+}
+
+void resumeTimer() {
+ timerPaused = false;
+}
+
+void saveTimer(SaveFileConstructor &saveGame) {
+ int32 time = gameTime;
+
+ saveGame.writeChunk(
+ MakeID('T', 'I', 'M', 'E'),
+ &time,
+ sizeof(time));
+}
+
+void loadTimer(SaveFileReader &saveGame) {
+ int32 time;
+
+ saveGame.read(&time, sizeof(time));
+ gameTime = time;
+}
+
+/* ====================================================================== *
+ Alarms
+ * ====================================================================== */
+
+void Alarm::set(uint32 dur) {
+ basetime = gameTime;
+ duration = dur;
+}
+
+bool Alarm::check(void) {
+ return ((uint32)(gameTime - basetime) > duration);
+}
+
+// time elapsed since alarm set
+
+uint32 Alarm::elapsed(void) {
+ return (uint32)(gameTime - basetime);
+}
+
struct TimerListHolder : public DNode {
uint8 timerListBuffer[sizeof(TimerList)];
Commit: 2d85ffea2ff10bc4e0a63966cc5f0294bcee4604
https://github.com/scummvm/scummvm/commit/2d85ffea2ff10bc4e0a63966cc5f0294bcee4604
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:12+02:00
Commit Message:
SAGA2: Disable timer for now
Changed paths:
engines/saga2/timers.cpp
diff --git a/engines/saga2/timers.cpp b/engines/saga2/timers.cpp
index 1e1e271aad..307cd31915 100644
--- a/engines/saga2/timers.cpp
+++ b/engines/saga2/timers.cpp
@@ -48,7 +48,7 @@ void timerCallback(void *refCon) {
void initTimer(void) {
gameTime = 0;
- g_vm->getTimerManager()->installTimerProc(&timerCallback, 1000 / 72, nullptr, "saga2");
+ //g_vm->getTimerManager()->installTimerProc(&timerCallback, 1000 / 72, nullptr, "saga2");
}
void pauseTimer() {
Commit: cf61650d1b26411c6cbaa7a87aaf060118579119
https://github.com/scummvm/scummvm/commit/cf61650d1b26411c6cbaa7a87aaf060118579119
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:13+02:00
Commit Message:
SAGA2: Rewrite TimerList using Common::List
Changed paths:
engines/saga2/objects.cpp
engines/saga2/saga2.h
engines/saga2/timers.cpp
engines/saga2/timers.h
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index f47ddb3282..8e6379700a 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -1671,7 +1671,6 @@ void GameObject::dropInventoryObject(GameObject *obj, int16 count) {
}
void GameObject::protoAddressToOffset() {
-
ProtoObj *objectBase = &objectProtos[0];
ProtoObj *actorBase = &actorProtos[0];
int32 newProto, size = sizeof(ResourceObjectPrototype) + 4;//Add 4 for jump Table
@@ -1793,8 +1792,7 @@ bool GameObject::addTimer(TimerID id, int16 frameInterval) {
// Fetch the existing timer list for this object or create a
// new one
- if ((timerList = fetchTimerList(this)) == nullptr
- && (timerList = new TimerList(this)) == nullptr) {
+ if ((timerList = fetchTimerList(this)) == nullptr && (timerList = new TimerList(this)) == nullptr) {
delete newTimer;
return false;
}
@@ -1803,21 +1801,19 @@ bool GameObject::addTimer(TimerID id, int16 frameInterval) {
// Search the list to see if there is already a timer with same
// ID as the new timer. If so, remove it and delete it.
- for (timerInList = (Timer *)timerList->first();
- timerInList != nullptr;
- timerInList = (Timer *)timerInList->next()) {
- assert(timerInList->getObject() == this);
+ for (Common::List<Timer *>::iterator it = timerList->_timers.begin(); it != timerList->_timers.end(); ++it) {
+ assert((*it)->getObject() == this);
- if (newTimer->thisID() == timerInList->thisID()) {
- timerInList->remove();
- delete timerInList;
+ if (newTimer->thisID() == (*it)->thisID()) {
+ timerList->_timers.remove(*it);
+ delete *it;
break;
}
}
// Put the new timer into the list
- timerList->addTail(*newTimer);
+ timerList->_timers.push_back(newTimer);
return true;
}
@@ -1830,19 +1826,13 @@ void GameObject::removeTimer(TimerID id) {
// Get this object's timer list
if ((timerList = fetchTimerList(this)) != nullptr) {
- Timer *timer;
-
- // Search the timer list for a timer with the specified ID
- for (timer = (Timer *)timerList->first();
- timer != nullptr;
- timer = (Timer *)timer->next()) {
- if (timer->thisID() == id) {
- // Remove the timer, then delete it
- timer->remove();
- delete timer;
+ for (Common::List<Timer *>::iterator it = timerList->_timers.begin(); it != timerList->_timers.end(); ++it) {
+ if ((*it)->thisID() == id) {
+ timerList->_timers.remove(*it);
+ delete *it;
- // If the list is now empty, delete it
- if (timerList->empty()) delete timerList;
+ if (timerList->_timers.empty())
+ delete timerList;
break;
}
@@ -1858,22 +1848,11 @@ void GameObject::removeAllTimers(void) {
// Get this object's timer list
if ((timerList = fetchTimerList(this)) != nullptr) {
- Timer *timer,
- *nextTimer;
-
- // Iterate through the timers
- for (timer = (Timer *)timerList->first();
- timer != nullptr;
- timer = nextTimer) {
- // Save the pointer to the next timer
- nextTimer = (Timer *)timer->next();
-
- // Remove the timer, then delete it
- timer->remove();
- delete timer;
+ for (Common::List<Timer *>::iterator it = timerList->_timers.begin(); it != timerList->_timers.end(); ++it) {
+ timerList->_timers.remove(*it);
+ delete *it;
}
- // Delete this object's timer list
delete timerList;
}
}
diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h
index d58a5b9bb1..ac2ad626dc 100644
--- a/engines/saga2/saga2.h
+++ b/engines/saga2/saga2.h
@@ -37,7 +37,8 @@ class SmackerDecoder;
namespace Saga2 {
-class Console;
+class Timer;
+class TimerList;
enum {
kDebugResources = 1 << 0,
@@ -80,6 +81,8 @@ public:
WeaponStuff _weaponRack[kMaxWeapons];
weaponID _loadedWeapons = 0;
+ Common::List<TimerList *> _timerLists;
+ Common::List<Timer *> _timers;
private:
Video::SmackerDecoder *_smkDecoder;
diff --git a/engines/saga2/timers.cpp b/engines/saga2/timers.cpp
index 307cd31915..222d46334e 100644
--- a/engines/saga2/timers.cpp
+++ b/engines/saga2/timers.cpp
@@ -94,144 +94,28 @@ uint32 Alarm::elapsed(void) {
return (uint32)(gameTime - basetime);
}
-struct TimerListHolder : public DNode {
- uint8 timerListBuffer[sizeof(TimerList)];
-
- TimerList *getTimerList(void) {
- return (TimerList *)&timerListBuffer;
- }
-};
-
-/* ===================================================================== *
- TimerHolder class
- * ===================================================================== */
-
-struct TimerHolder : public DNode {
- uint8 timerBuffer[sizeof(Timer)];
-
- Timer *getTimer(void) {
- return (Timer *)&timerBuffer;
- }
-};
-
-/* ===================================================================== *
- Globals
- * ===================================================================== */
-
-// A pool of TimerListHolders
-static RPool< TimerListHolder, 64 > timerListPool;
-
-// The list of active TimerLists
-static DList timerListList;
-
-// A pool of TimerHolders
-static RPool< TimerHolder, 128 > timerPool;
-
-// The list of active Timers
-static DList timerList;
-
/* ===================================================================== *
TimerList management functions
* ===================================================================== */
-//----------------------------------------------------------------------
-// Allocate a new TimerList
-
-void *newTimerList(void) {
- TimerListHolder *newTimerListHolder;
-
- if ((newTimerListHolder
- = (TimerListHolder *)timerListPool.alloc())
- == NULL)
- return NULL;
-
- timerListList.addTail(*newTimerListHolder);
-
- return &newTimerListHolder->timerListBuffer;
-}
-
-//----------------------------------------------------------------------
-// Deallocate an TimerList
-
-void deleteTimerList(void *p) {
- TimerListHolder *listHolderToDelete;
-
- warning("FIXME: deleteTimerList(): unsafe pointer arithmetics");
- listHolderToDelete =
- (TimerListHolder *)((uint8 *)p
- - offsetof(
- TimerListHolder,
- timerListBuffer));
-
- listHolderToDelete->remove();
- timerListPool.free(listHolderToDelete);
-}
-
//----------------------------------------------------------------------
// Fetch a specified object's TimerList
TimerList *fetchTimerList(GameObject *obj) {
- TimerListHolder *listHolder;
-
- for (listHolder = (TimerListHolder *)timerListList.first();
- listHolder != NULL;
- listHolder = (TimerListHolder *)listHolder->next()) {
- if (listHolder->getTimerList()->getObject() == obj)
- return listHolder->getTimerList();
- }
-
- return NULL;
-}
-
-/* ===================================================================== *
- Timer management functions
- * ===================================================================== */
-
-//----------------------------------------------------------------------
-// Allocate an new Timer
-
-void *newTimer(void) {
- TimerHolder *newTimerHolder;
+ for (Common::List<TimerList *>::iterator it = g_vm->_timerLists.begin(); it != g_vm->_timerLists.end(); ++it)
+ if ((*it)->getObject() == obj)
+ return *it;
- if ((newTimerHolder = (TimerHolder *)timerPool.alloc()) == NULL)
- return NULL;
-
- timerList.addTail(*newTimerHolder);
-
- return &newTimerHolder->timerBuffer;
-}
-
-//----------------------------------------------------------------------
-// Deallocated an Timer
-
-void deleteTimer(void *p) {
- TimerHolder *timerHolderToDelete;
-
- warning("FIXME: deleteTimer(): unsafe pointer arithmetics");
- timerHolderToDelete =
- (TimerHolder *)((uint8 *)p - offsetof(TimerHolder, timerBuffer));
-
- timerHolderToDelete->remove();
- timerPool.free(timerHolderToDelete);
+ return nullptr;
}
//----------------------------------------------------------------------
// Check all active Timers
-
void checkTimers(void) {
- TimerHolder *timerHolder,
- *nextTimerHolder;
-
- for (timerHolder = (TimerHolder *)timerList.first();
- timerHolder != NULL;
- timerHolder = nextTimerHolder) {
- nextTimerHolder = (TimerHolder *)timerHolder->next();
-
- Timer *timer = timerHolder->getTimer();
-
- if (timer->check()) {
- timer->reset();
- timer->getObject()->timerTick(timer->thisID());
+ for (Common::List<Timer *>::iterator it = g_vm->_timers.begin(); it != g_vm->_timers.end(); ++it) {
+ if ((*it)->check()) {
+ (*it)->reset();
+ (*it)->getObject()->timerTick((*it)->thisID());
}
}
}
@@ -247,6 +131,9 @@ void initTimers(void) {
// Save the active Timers in a save file
void saveTimers(SaveFileConstructor &saveGame) {
+ warning("STUB: saveTimers");
+
+#if 0
int16 timerListCount = 0,
timerCount = 0;
@@ -261,18 +148,14 @@ void saveTimers(SaveFileConstructor &saveGame) {
archiveBufSize += sizeof(timerListCount) + sizeof(timerCount);
// Tally the timer lists
- for (listHolder = (TimerListHolder *)timerListList.first();
- listHolder != NULL;
- listHolder = (TimerListHolder *)listHolder->next())
+ for (listHolder = (TimerListHolder *)timerListList.first(); listHolder != NULL; listHolder = (TimerListHolder *)listHolder->next())
timerListCount++;
// Add the total archive size of all of the timer lists
archiveBufSize += timerListCount * TimerList::archiveSize();
// Tally the timers
- for (timerHolder = (TimerHolder *)timerList.first();
- timerHolder != NULL;
- timerHolder = (TimerHolder *)timerHolder->next())
+ for (timerHolder = (TimerHolder *)timerList.first(); timerHolder != NULL; timerHolder = (TimerHolder *)timerHolder->next())
timerCount++;
// Add the total archive size of all of the timers
@@ -311,12 +194,16 @@ void saveTimers(SaveFileConstructor &saveGame) {
archiveBufSize);
RDisposePtr(archiveBuffer);
+#endif
}
//----------------------------------------------------------------------
// Load the Timers from a save file
void loadTimers(SaveFileReader &saveGame) {
+ warning("STUB: loadTimers");
+
+#if 0
int16 i,
timerListCount,
timerCount;
@@ -364,52 +251,45 @@ void loadTimers(SaveFileReader &saveGame) {
assert(bufferPtr == &((uint8 *)archiveBuffer)[saveGame.getChunkSize()]);
RDisposePtr(archiveBuffer);
+#endif
}
//----------------------------------------------------------------------
// Cleanup the active Timers
void cleanupTimers(void) {
- TimerListHolder *listHolder,
- *nextListHolder;
- TimerHolder *timerHolder,
- *nextTimerHolder;
-
- // Delete all timer lists
- for (listHolder = (TimerListHolder *)timerListList.first();
- listHolder != NULL;
- listHolder = nextListHolder) {
- nextListHolder = (TimerListHolder *)listHolder->next();
-
- delete listHolder->getTimerList();
- }
+ for (Common::List<TimerList *>::iterator it = g_vm->_timerLists.begin(); it != g_vm->_timerLists.end(); ++it)
+ delete *it;
- // Delete all timers
- for (timerHolder = (TimerHolder *)timerList.first();
- timerHolder != NULL;
- timerHolder = nextTimerHolder) {
- nextTimerHolder = (TimerHolder *)timerHolder->next();
-
- delete timerHolder->getTimer();
- }
+ for (Common::List<Timer *>::iterator it = g_vm->_timers.begin(); it != g_vm->_timers.end(); ++it)
+ delete *it;
}
/* ===================================================================== *
TimerList member functions
* ===================================================================== */
-//----------------------------------------------------------------------
-// Constructor -- reconstruct from an archive buffer
+TimerList::TimerList(GameObject *o) : _obj(o) {
+ g_vm->_timerLists.push_back(this);
+}
TimerList::TimerList(void **buf) {
ObjectID *bufferPtr = (ObjectID *)*buf;
+ warning("STUB: TimerList::TimerList(buf)");
+
assert(isObject(*bufferPtr) || isActor(*bufferPtr));
// Restore the object pointer
- obj = GameObject::objectAddress(*bufferPtr++);
+ _obj = GameObject::objectAddress(*bufferPtr++);
*buf = bufferPtr;
+
+ g_vm->_timerLists.push_back(this);
+}
+
+TimerList::~TimerList() {
+ g_vm->_timerLists.remove(this);
}
//----------------------------------------------------------------------
@@ -417,7 +297,7 @@ TimerList::TimerList(void **buf) {
void *TimerList::archive(void *buf) {
// Store the object's ID
- *((ObjectID *)buf) = obj->thisID();
+ *((ObjectID *)buf) = _obj->thisID();
buf = (ObjectID *)buf + 1;
return buf;
@@ -431,28 +311,35 @@ void *TimerList::archive(void *buf) {
// Constructor -- reconstruct from an archive buffer
Timer::Timer(void **buf) {
- void *bufferPtr = *buf;
+ void *bufferPtr = *buf;
+
+ warning("STUB: Timer::Timer(buf)");
- assert(isObject(*((ObjectID *)bufferPtr))
- || isActor(*((ObjectID *)bufferPtr)));
+ assert(isObject(*((ObjectID *)bufferPtr)) || isActor(*((ObjectID *)bufferPtr)));
// Restore the object pointer
- obj = GameObject::objectAddress(*((ObjectID *)bufferPtr));
+ _obj = GameObject::objectAddress(*((ObjectID *)bufferPtr));
bufferPtr = (ObjectID *)bufferPtr + 1;
// Restore the timer's ID
- id = *((TimerID *)bufferPtr);
+ _id = *((TimerID *)bufferPtr);
bufferPtr = (TimerID *)bufferPtr + 1;
// Restore the frame interval
- interval = *((int16 *)bufferPtr);
+ _interval = *((int16 *)bufferPtr);
bufferPtr = (int16 *)bufferPtr + 1;
// Restore the alarm
- memcpy(&alarm, bufferPtr, sizeof(alarm));
+ memcpy(&_alarm, bufferPtr, sizeof(Alarm));
bufferPtr = (FrameAlarm *)bufferPtr + 1;
*buf = bufferPtr;
+
+ g_vm->_timers.push_back(this);
+}
+
+Timer::~Timer() {
+ g_vm->_timers.remove(this);
}
//----------------------------------------------------------------------
@@ -470,19 +357,19 @@ int32 Timer::archiveSize(void) {
void *Timer::archive(void *buf) {
// Store the obj's ID
- *((ObjectID *)buf) = obj->thisID();
+ *((ObjectID *)buf) = _obj->thisID();
buf = (ObjectID *)buf + 1;
// Store the timer's ID
- *((TimerID *)buf) = id;
+ *((TimerID *)buf) = _id;
buf = (TimerID *)buf + 1;
// Store the frame interval
- *((int16 *)buf) = interval;
+ *((int16 *)buf) = _interval;
buf = (int16 *)buf + 1;
// Store the alarm
- memcpy(buf, &alarm, sizeof(alarm));
+ memcpy(buf, &_alarm, sizeof(Alarm));
buf = (FrameAlarm *)buf + 1;
return buf;
diff --git a/engines/saga2/timers.h b/engines/saga2/timers.h
index b8d0787648..71dc8f2484 100644
--- a/engines/saga2/timers.h
+++ b/engines/saga2/timers.h
@@ -36,19 +36,9 @@ namespace Saga2 {
class GameObject;
class TimerList;
-// Allocate an new TimerList
-void *newTimerList(void);
-// Deallocate an TimerList
-void deleteTimerList(void *p);
-
// Fetch a specified actor's TimerList
TimerList *fetchTimerList(GameObject *obj);
-// Allocate a new Timer
-void *newTimer(void);
-// Deallocate an Timer
-void deleteTimer(void *p);
-
// Check all active Timers
void checkTimers(void);
@@ -65,15 +55,18 @@ void cleanupTimers(void);
TimerList class
* ===================================================================== */
-class TimerList : public DList {
- GameObject *obj;
+class TimerList {
+ GameObject *_obj;
+
public:
// Constructor -- initial construction
- TimerList(GameObject *o) : obj(o) {}
+ TimerList(GameObject *o);
// Constructor -- reconstruct from archive buffer
TimerList(void **buf);
+ ~TimerList();
+
// Return the number of bytes needed to archive this object in
// a buffer
static int32 archiveSize(void) {
@@ -83,39 +76,34 @@ public:
// Archive this object in a buffer
void *archive(void *buf);
- void *operator new (size_t) {
- return newTimerList();
- }
- void operator delete (void *p) {
- deleteTimerList(p);
- }
-
GameObject *getObject(void) {
- return obj;
+ return _obj;
}
+
+ Common::List<Timer *> _timers;
};
/* ===================================================================== *
Timer class
* ===================================================================== */
-class Timer : public DNode {
- GameObject *obj;
- TimerID id;
- int16 interval;
- FrameAlarm alarm;
+class Timer {
+ GameObject *_obj;
+ TimerID _id;
+ int16 _interval;
+ FrameAlarm _alarm;
public:
// Constructor -- initial construction
- Timer(GameObject *o, TimerID timerID, int16 frameInterval) :
- obj(o),
- id(timerID),
- interval(frameInterval) {
- alarm.set(interval);
+ Timer(GameObject *o, TimerID timerID, int16 frameInterval) : _obj(o), _id(timerID), _interval(frameInterval) {
+ _alarm.set(_interval);
+
+ g_vm->_timers.push_back(this);
}
// Constructor -- reconstruct from archive buffer
Timer(void **buf);
+ ~Timer();
// Return the number of bytes needed to archive this object in
// a buffer
@@ -124,28 +112,21 @@ public:
// Archive this object in a buffer
void *archive(void *buf);
- void *operator new (size_t) {
- return newTimer();
- }
- void operator delete (void *p) {
- deleteTimer(p);
- }
-
GameObject *getObject(void) {
- return obj;
+ return _obj;
}
TimerID thisID(void) {
- return id;
+ return _id;
}
int16 getInterval(void) {
- return interval;
+ return _interval;
}
bool check(void) {
- return alarm.check();
+ return _alarm.check();
}
void reset(void) {
- alarm.set(interval);
+ _alarm.set(_interval);
}
};
Commit: 83af12f5e627197d4d579e752d3e312bb1388ef4
https://github.com/scummvm/scummvm/commit/83af12f5e627197d4d579e752d3e312bb1388ef4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:13+02:00
Commit Message:
SAGA2: Fix warning
Changed paths:
engines/saga2/property.h
diff --git a/engines/saga2/property.h b/engines/saga2/property.h
index 7c8e2ba8b8..b36ba580f9 100644
--- a/engines/saga2/property.h
+++ b/engines/saga2/property.h
@@ -289,7 +289,7 @@ inline const TileProperty *getTileProp(TilePropertyID id) {
MetaTile properties
* ===================================================================== */
-struct MetaTile;
+class MetaTile;
/* ===================================================================== *
MetaTileProperty class
Commit: ce603fe4e84c0e7d5fbea5821904a04b2c3a80da
https://github.com/scummvm/scummvm/commit/ce603fe4e84c0e7d5fbea5821904a04b2c3a80da
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:13+02:00
Commit Message:
SAGA2: Fix some warnings in tile.cpp
Changed paths:
engines/saga2/tile.cpp
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 0634b514d9..6cc790d221 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -998,7 +998,7 @@ static TileActivityTaskList &aTaskList =
// Constructor
TileActivityTaskList::TileActivityTaskList(void) {
- for (int i = 0; i < elementsof(array); i++) {
+ for (uint i = 0; i < elementsof(array); i++) {
free.addTail(array[i]);
}
}
@@ -1009,10 +1009,9 @@ TileActivityTaskList::TileActivityTaskList(void) {
TileActivityTaskList::TileActivityTaskList(void **buf) {
void *bufferPtr = *buf;
- int16 i,
- taskCount;
+ int16 taskCount;
- for (i = 0; i < elementsof(array); i++) {
+ for (uint i = 0; i < elementsof(array); i++) {
free.addTail(array[i]);
}
@@ -1020,7 +1019,7 @@ TileActivityTaskList::TileActivityTaskList(void **buf) {
taskCount = *((int16 *)bufferPtr);
bufferPtr = (int16 *)bufferPtr + 1;
- for (i = 0; i < taskCount; i++) {
+ for (int i = 0; i < taskCount; i++) {
ActiveItem *tai;
uint8 activityType;
@@ -1505,7 +1504,7 @@ void initMaps(void) {
for (worldCount = 0;
tileRes->seek(mapID + worldCount);
worldCount++) {
- warning("MapID: %s %08x res: %s % 08x", tag2str(mapID), mapID, tag2str(mapID + worldCount), mapID + worldCount);
+ warning("MapID: %s %08x res: %s %08x", tag2str(mapID), mapID, tag2str(mapID + worldCount), mapID + worldCount);
}
// Allocate the map data array
@@ -2760,14 +2759,12 @@ void buildRipTable(
const int32 initVal = ((int32)maxint16 << 16) | maxint16;
int32 *initPtr = (int32 *)ripTable->zTable;
- int i;
-
// Initialize table
mt->ripTableID(currentMapNum) = ripTable->thisID();
ripTable->metaID = mt->thisID(currentMapNum);
ripTable->ripID = ripID;
- for (i = 0;
+ for (uint i = 0;
i < sizeof(ripTable->zTable) / sizeof(initVal);
i++)
*initPtr++ = initVal;
@@ -2779,7 +2776,7 @@ void buildRipTable(
// calculate object ripping altitude
int16 tilesToGo = platformWidth * platformWidth;
- for (i = 0; i < maxPlatforms; i++) {
+ for (uint i = 0; i < maxPlatforms; i++) {
Platform *p;
if ((p = mt->fetchPlatform(currentMapNum, i)) == nullptr) continue;
@@ -2850,8 +2847,6 @@ void buildRipTables(void) {
mt = mIter.next();
}
- int16 i, j;
-
int16 tableIndex;
// bit array of available rip tables
@@ -2859,7 +2854,7 @@ void buildRipTables(void) {
memset(tableAvail, 0xFF, sizeof(tableAvail));
- for (i = 0; i < mtTableSize; i++) {
+ for (int i = 0; i < mtTableSize; i++) {
mt = mtTable[i];
RipTable *mtRipTable = mt->ripTable(currentMapNum);
@@ -2877,16 +2872,17 @@ void buildRipTables(void) {
// Remove empty entries from meta tile pointer array
int16 oldMtTableSize = mtTableSize;
- for (i = 0, j = 0; i < oldMtTableSize; i++) {
+ for (int i = 0, j = 0; i < oldMtTableSize; i++) {
if (mtTable[i] != nullptr)
mtTable[j++] = mtTable[i];
else
mtTableSize--;
}
- for (i = 0; i < mtTableSize; i++) {
+ for (int i = 0; i < mtTableSize; i++) {
mt = mtTable[i];
+ uint j;
// Find available table
for (j = 0; j < elementsof(ripTableList); j++) {
if (tableAvail[j >> 3] & (1 << (j & 0x7)))
Commit: b43ddb316236dd97d71ecd5822f61db90bf3cb97
https://github.com/scummvm/scummvm/commit/b43ddb316236dd97d71ecd5822f61db90bf3cb97
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:13+02:00
Commit Message:
SAGA2: Make some buffer reading code portable
Changed paths:
engines/saga2/tile.cpp
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 6cc790d221..7596198aee 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -857,7 +857,7 @@ void saveActiveItemStates(SaveFileConstructor &saveGame) {
uint8 *bufferedStateArray;
// Save the size of the state array
- *((int16 *)bufferPtr) = arraySize / sizeof(uint8);
+ WRITE_LE_INT16(bufferPtr, arraySize / sizeof(uint8));
bufferPtr = (int16 *)bufferPtr + 1;
// Copy the state data to the archive buffer
@@ -886,7 +886,7 @@ void saveActiveItemStates(SaveFileConstructor &saveGame) {
*statePtr &= ~(1 << 7);
}
} else {
- *((int16 *)bufferPtr) = 0;
+ WRITE_LE_INT16(bufferPtr, 0);
bufferPtr = (int16 *)bufferPtr + 1;
}
}
@@ -925,7 +925,7 @@ void loadActiveItemStates(SaveFileReader &saveGame) {
for (i = 0; i < worldCount; i++) {
int32 arraySize;
- arraySize = *((int16 *)bufferPtr) * sizeof(uint8);
+ arraySize = READ_LE_INT16(bufferPtr) * sizeof(uint8);
bufferPtr = (int16 *)bufferPtr + 1;
if (arraySize > 0) {
@@ -1016,7 +1016,7 @@ TileActivityTaskList::TileActivityTaskList(void **buf) {
}
// Retreive the task count
- taskCount = *((int16 *)bufferPtr);
+ taskCount = READ_LE_INT16(bufferPtr);
bufferPtr = (int16 *)bufferPtr + 1;
for (int i = 0; i < taskCount; i++) {
@@ -1071,7 +1071,7 @@ void *TileActivityTaskList::archive(void *buf) {
taskCount++;
// Store the task count
- *((int16 *)buf) = taskCount;
+ WRITE_LE_INT16(buf, taskCount);
buf = (int16 *)buf + 1;
for (tat = (TileActivityTask *)list.first();
Commit: 0535d6bd19ca168dfa068d68b8a5be0c499970da
https://github.com/scummvm/scummvm/commit/0535d6bd19ca168dfa068d68b8a5be0c499970da
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:13+02:00
Commit Message:
SAGA2: Replace some buffer usage by stream in tile.cpp
Changed paths:
engines/saga2/tile.cpp
engines/saga2/tile.h
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 7596198aee..77116732af 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -27,6 +27,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "common/debug.h"
+#include "common/memstream.h"
#include "graphics/surface.h"
#include "saga2/std.h"
@@ -1061,7 +1062,7 @@ int32 TileActivityTaskList::archiveSize(void) {
// Create an archive of this TileActivityTaskList in the specified
// archive buffer
-void *TileActivityTaskList::archive(void *buf) {
+Common::MemorySeekableReadWriteStream *TileActivityTaskList::archive(Common::MemorySeekableReadWriteStream *stream) {
int16 taskCount;
TileActivityTask *tat;
@@ -1071,8 +1072,7 @@ void *TileActivityTaskList::archive(void *buf) {
taskCount++;
// Store the task count
- WRITE_LE_INT16(buf, taskCount);
- buf = (int16 *)buf + 1;
+ taskCount = stream->readSint16LE();
for (tat = (TileActivityTask *)list.first();
tat != nullptr;
@@ -1080,15 +1080,13 @@ void *TileActivityTaskList::archive(void *buf) {
ActiveItem *ai = tat->tai;
// Store the activeItemID
- *((ActiveItemID *)buf) = ai->thisID();
- buf = (ActiveItemID *)buf + 1;
+ stream->writeSint16LE(ai->thisID());
// Store the task type
- *((uint8 *)buf) = tat->activityType;
- buf = (uint8 *)buf + 1;
+ stream->writeByte(tat->activityType);
}
- return buf;
+ return stream;
}
//-----------------------------------------------------------------------
@@ -1347,22 +1345,27 @@ void initTileTasks(void) {
void saveTileTasks(SaveFileConstructor &saveGame) {
int32 archiveBufSize;
- void *archiveBuffer;
+ byte *archiveBuffer;
+ Common::MemorySeekableReadWriteStream *stream;
archiveBufSize = aTaskList.archiveSize();
- archiveBuffer = malloc(archiveBufSize);
+ archiveBuffer = (byte *)malloc(archiveBufSize);
if (archiveBuffer == nullptr)
error("Unable to allocate tile activity task archive buffer");
- aTaskList.archive(archiveBuffer);
+ stream = new Common::MemorySeekableReadWriteStream(archiveBuffer,
+ archiveBufSize,
+ DisposeAfterUse::YES);
+
+ aTaskList.archive(stream);
saveGame.writeChunk(
MakeID('T', 'A', 'C', 'T'),
archiveBuffer,
archiveBufSize);
- free(archiveBuffer);
+ delete stream;
}
//-----------------------------------------------------------------------
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index d317e11d2d..36d5a1d6c1 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -27,6 +27,7 @@
#ifndef SAGA2_TILE_H
#define SAGA2_TILE_H
+#include "common/memstream.h"
#include "saga2/fta.h"
#include "saga2/tileload.h"
#include "saga2/annoy.h"
@@ -639,7 +640,7 @@ public:
// Create an archive of this TileActivityTaskList in the specified
// archive buffer
- void *archive(void *buf);
+ Common::MemorySeekableReadWriteStream *archive(Common::MemorySeekableReadWriteStream *stream);
// Cleanup this list
void cleanup(void);
Commit: 2948280be816ace5490b16176fc94a4c07ed0861
https://github.com/scummvm/scummvm/commit/2948280be816ace5490b16176fc94a4c07ed0861
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:13+02:00
Commit Message:
SAGA2: Fix some formatting
Changed paths:
engines/saga2/tile.cpp
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 77116732af..b18c693dc3 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -27,7 +27,6 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
#include "common/debug.h"
-#include "common/memstream.h"
#include "graphics/surface.h"
#include "saga2/std.h"
@@ -1356,7 +1355,7 @@ void saveTileTasks(SaveFileConstructor &saveGame) {
stream = new Common::MemorySeekableReadWriteStream(archiveBuffer,
archiveBufSize,
- DisposeAfterUse::YES);
+ DisposeAfterUse::YES);
aTaskList.archive(stream);
Commit: c594b9304ba86e4be3da34f1d1cf7f02c36a29da
https://github.com/scummvm/scummvm/commit/c594b9304ba86e4be3da34f1d1cf7f02c36a29da
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:13+02:00
Commit Message:
SAGA2: Move some tile constants to idtypes.h
Changed paths:
engines/saga2/idtypes.h
engines/saga2/tile.cpp
engines/saga2/tile.h
diff --git a/engines/saga2/idtypes.h b/engines/saga2/idtypes.h
index 35ac0ebb72..cb2a0b06af 100644
--- a/engines/saga2/idtypes.h
+++ b/engines/saga2/idtypes.h
@@ -263,6 +263,21 @@ enum effectDamageTypes {
damageEnergy = 14 // Generally hard to resist - god damage
};
+// Tile metrics
+
+enum {
+ kTileWidth = 64,
+ kTileHeight = 32,
+ kTileMaxHeight = 160,
+ kTileDX = (kTileWidth / 2),
+ kTileDY = (kTileHeight / 2),
+ kTileDXShift = 5,
+ kTileDYShift = 4,
+ kTileDXMask = (kTileDX - 1),
+ kTileDYMask = (kTileDY - 1),
+ kMaxTileHeight = 160
+};
+
} // end of namespace Saga2
#endif
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index b18c693dc3..57a25eef33 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -1997,7 +1997,7 @@ TileInfo *Platform::fetchTile(
#if DEBUG
if (ti->offset > maxOffset
- || ti->attrs.height > maxTileHeight
+ || ti->attrs.height > kMaxTileHeight
|| ti->attrs.height < 0) {
int16 tileNo, tileBank;
@@ -2154,7 +2154,7 @@ TileInfo *Platform::fetchTile(
#if DEBUG
if (ti->offset > maxOffset
- || ti->attrs.height > maxTileHeight
+ || ti->attrs.height > kMaxTileHeight
|| ti->attrs.height < 0) {
int16 tileNo, tileBank;
@@ -2732,7 +2732,7 @@ inline void drawMetaRow(TilePoint coords, Point16 pos) {
// REM: precompute this later, by scanning the platform
// for individual altitudes
- p->highestPixel = kTileHeight * (platformWidth - 1) + maxTileHeight * 2 + 64;
+ p->highestPixel = kTileHeight * (platformWidth - 1) + kMaxTileHeight * 2 + 64;
if (pos.y <= 0
|| pos.y - p->highestPixel >= tileDrawMap.size.y)
@@ -3367,7 +3367,7 @@ void maskMetaRow(
// REM: precompute this later, by scanning the platform
// for individual altitudes
- p->highestPixel = kTileHeight * (platformWidth - 1) + maxTileHeight + 192;
+ p->highestPixel = kTileHeight * (platformWidth - 1) + kMaxTileHeight + 192;
if (pos.y <= 0
|| pos.y - p->highestPixel >= sMap.size.y)
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index 36d5a1d6c1..ed71f98825 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -63,22 +63,6 @@ inline void TileID2Bank(TileID t, int16 &bank, int16 &num) {
Tile Size constants
* ===================================================================== */
-// Tile metrics
-
-enum {
- kTileWidth = 64,
- kTileHeight = 32,
- kTileMaxHeight = 160,
- kTileDX = (kTileWidth / 2),
- kTileDY = (kTileHeight / 2),
- kTileDXShift = 5,
- kTileDYShift = 4,
- kTileDXMask = (kTileDX - 1),
- kTileDYMask = (kTileDY - 1)
-};
-
-const int maxTileHeight = 160; // tallest possible tile
-
const int platUVSize = tileUVSize * platformWidth;
// Metatile metrics
Commit: 3839393223bd510dc8d5ee40a24cf8a84a93596a
https://github.com/scummvm/scummvm/commit/3839393223bd510dc8d5ee40a24cf8a84a93596a
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:14+02:00
Commit Message:
SAGA2: Move tcoords.h constants into idtypes.h
Changed paths:
engines/saga2/idtypes.h
engines/saga2/tcoords.h
diff --git a/engines/saga2/idtypes.h b/engines/saga2/idtypes.h
index cb2a0b06af..437031d521 100644
--- a/engines/saga2/idtypes.h
+++ b/engines/saga2/idtypes.h
@@ -278,6 +278,24 @@ enum {
kMaxTileHeight = 160
};
+// Size of a tile in ( U, V ) coords
+
+enum {
+ tileUVSize = 16,
+ tileUVShift = 4,
+ tileZSize = 8,
+ tileZShift = 3,
+ tileUVMask = (tileUVSize - 1)
+};
+
+// Size of a map sector (4 metatiles x 4 metatiles)
+
+enum {
+ sectorSize = tileUVSize * 8 * 4,
+ sectorShift = tileUVShift + 3 + 2,
+ sectorMask = (sectorSize - 1)
+};
+
} // end of namespace Saga2
#endif
diff --git a/engines/saga2/tcoords.h b/engines/saga2/tcoords.h
index e5a1240217..be5a13d169 100644
--- a/engines/saga2/tcoords.h
+++ b/engines/saga2/tcoords.h
@@ -113,20 +113,6 @@ public:
Constants
* ============================================================================ */
- // Size of a tile in ( U, V ) coords
-
-const int tileUVSize = 16,
- tileUVShift = 4,
- tileZSize = 8,
- tileZShift = 3,
- tileUVMask = (tileUVSize - 1);
-
- // Size of a map sector (4 metatiles x 4 metatiles)
-
-const int sectorSize = tileUVSize * 8 * 4,
- sectorShift = tileUVShift + 3 + 2,
- sectorMask = sectorSize - 1;
-
// A TilePoint defining a NULL location
const extern TilePoint Nowhere;
Commit: f9ecdb80aefeebf3c94461bb1173b1a2d3365aac
https://github.com/scummvm/scummvm/commit/f9ecdb80aefeebf3c94461bb1173b1a2d3365aac
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:14+02:00
Commit Message:
SAGA2: Move platform metric constants to idtypes.h
Changed paths:
engines/saga2/idtypes.h
engines/saga2/std.h
engines/saga2/tile.h
diff --git a/engines/saga2/idtypes.h b/engines/saga2/idtypes.h
index 437031d521..e48cf3fe31 100644
--- a/engines/saga2/idtypes.h
+++ b/engines/saga2/idtypes.h
@@ -296,6 +296,14 @@ enum {
sectorMask = (sectorSize - 1)
};
+// Plaftorm metrics
+const int platformWidth = 8; // width and height of platform
+enum {
+ platMask = platformWidth - 1,
+ platShift = 3,
+ platUVSize = tileUVSize * platformWidth
+};
+
} // end of namespace Saga2
#endif
diff --git a/engines/saga2/std.h b/engines/saga2/std.h
index 0b3fadd042..5b3d763cd3 100644
--- a/engines/saga2/std.h
+++ b/engines/saga2/std.h
@@ -62,10 +62,6 @@ typedef uint32 ChunkID;
#define maxuint32 0xffffffffu
#define minuint32 0u
-// Plaftorm metrics
-const int platformWidth = 8, // width and height of platform
- platMask = platformWidth - 1,
- platShift = 3;
#endif //SAGA2_STD_H
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index ed71f98825..40caeda8b5 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -63,8 +63,6 @@ inline void TileID2Bank(TileID t, int16 &bank, int16 &num) {
Tile Size constants
* ===================================================================== */
-const int platUVSize = tileUVSize * platformWidth;
-
// Metatile metrics
const int metaTileWidth = kTileWidth * platformWidth,
metaTileHeight = kTileHeight * platformWidth,
Commit: f930e14188e08148bbfd852a7cc252710f94f74a
https://github.com/scummvm/scummvm/commit/f930e14188e08148bbfd852a7cc252710f94f74a
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:14+02:00
Commit Message:
SAGA2: Use Common::HashMap for active items hash
Changed paths:
engines/saga2/tile.cpp
engines/saga2/tile.h
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 57a25eef33..7d95a06d5c 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -2457,8 +2457,7 @@ void WorldMapData::buildInstanceHash(void) {
+ ai->instance.v + (ai->instance.groupID << 2))
% elementsof(instHash);
- ai->nextHash = instHash[hashVal];
- instHash[hashVal] = ai;
+ itemHash.setVal(hashVal, ai);
}
}
}
@@ -2472,17 +2471,9 @@ ActiveItem *WorldMapData::findHashedInstance(
int16 group) {
int16 hashVal = (((tp.u + tp.z) << 4) + tp.v + (group << 2))
% elementsof(instHash);
- ActiveItem *ai;
+ if (itemHash.contains(hashVal))
+ return itemHash.getVal(hashVal);
- for (ai = instHash[hashVal];
- ai;
- ai = ai->nextHash) {
- if (ai->instance.u == tp.u
- && ai->instance.v == tp.v
- && ai->instance.h == tp.z
- && ai->instance.groupID == group)
- return ai;
- }
return nullptr;
}
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index 40caeda8b5..af6b912bb6 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -867,6 +867,7 @@ struct WorldMapData {
RipTableIDPtr ripTableIDList; // MetaTile object ripping
ActiveItem *instHash[513]; // ActiveItem hash table
+ Common::HashMap<int16, ActiveItem*> itemHash;
int16 metaCount, // Number of MetaTiles
activeCount; // Number of ActiveItems
Commit: ed2fe2befc605aaa7672bab68eab7b38209a623b
https://github.com/scummvm/scummvm/commit/ed2fe2befc605aaa7672bab68eab7b38209a623b
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:14+02:00
Commit Message:
SAGA2: Create destructors for MapHeader and MetaTileList
Changed paths:
engines/saga2/tile.cpp
engines/saga2/tile.h
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 7d95a06d5c..8808c43c38 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -1442,6 +1442,11 @@ MapHeader::MapHeader(Common::SeekableReadStream *stream) {
mapData[i] = stream->readUint16LE();
}
+MapHeader::~MapHeader() {
+ if (mapData)
+ delete[] mapData;
+}
+
MetaTile::MetaTile(int ind, Common::SeekableReadStream *stream) {
_index = ind;
_highestPixel = stream->readUint16LE();
@@ -1462,6 +1467,17 @@ MetaTileList::MetaTileList(int count, Common::SeekableReadStream *stream) {
}
}
+MetaTileList::~MetaTileList() {
+ if (_tiles) {
+ for (int i = 0; i < _count; ++i) {
+ if (_tiles[i])
+ delete _tiles[i];
+ }
+
+ free(_tiles);
+ }
+}
+
static void readActiveItem(hResContext *con, ActiveItem &itm) {
// FIXME: 32-bit pointer to 64-bit pointer conversion.
// Is this dangerous?
@@ -1627,23 +1643,12 @@ void cleanupMaps(void) {
WorldMapData *mapData = &mapList[i];
// Dump the map
- if (mapData->map != nullptr) {
- if (mapData->map->mapData != nullptr)
- delete[] mapData->map->mapData;
-
+ if (mapData->map != nullptr)
delete mapData->map;
- mapData->map = nullptr;
- }
// Dump the meta tile list
- if (mapData->metaList) {
- for (int k = 0; k < mapData->metaList->_count; ++i)
- if (mapData->metaList->_tiles[i])
- delete mapData->metaList->_tiles[i];
-
- free(mapData->metaList->_tiles);
- }
- delete mapData->metaList;
+ if (mapData->metaList)
+ delete mapData->metaList;
// If there is active item data, dump it
if (mapData->activeItemData != nullptr)
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index af6b912bb6..a089e58db6 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -825,6 +825,7 @@ public:
MetaTile **_tiles;
MetaTileList(int count, Common::SeekableReadStream *stream);
+ ~MetaTileList();
};
/* ===================================================================== *
@@ -837,6 +838,7 @@ struct MapHeader {
uint16 *mapData; // start of map array
MapHeader(Common::SeekableReadStream *stream);
+ ~MapHeader();
};
enum mapEdgeTypes {
Commit: fb2612399a31203a4b7359d7dfa934e8084ac95e
https://github.com/scummvm/scummvm/commit/fb2612399a31203a4b7359d7dfa934e8084ac95e
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:14+02:00
Commit Message:
SAGA2: Classify activeItemList
Changed paths:
engines/saga2/tile.cpp
engines/saga2/tile.h
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 8808c43c38..1a0216468b 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -351,8 +351,7 @@ int16 ActiveItem::getMapNum(void) {
WorldMapData *mapData = &mapList[mapNum];
// Determine if the active item in on this map's list
- if (this >= mapData->activeItemList
- && this < &mapData->activeItemList[mapData->activeCount])
+ if (_parent == mapData->activeItemList)
break;
}
@@ -387,7 +386,7 @@ Location ActiveItem::getInstanceLocation(void) {
ActiveItem *ActiveItem::activeItemAddress(ActiveItemID id) {
return id.getIndexNum() != activeItemIndexNullID
- ? &mapList[id.getMapNum()].activeItemList[id.getIndexNum()]
+ ? mapList[id.getMapNum()].activeItemList->_items[id.getIndexNum()]
: nullptr;
}
@@ -397,16 +396,14 @@ ActiveItem *ActiveItem::activeItemAddress(ActiveItemID id) {
ActiveItemID ActiveItem::thisID(void) {
int16 mapNum = getMapNum();
- return ActiveItemID(
- mapNum,
- this - mapList[mapNum].activeItemList);
+ return ActiveItemID(mapNum, _index);
}
//-----------------------------------------------------------------------
// Return this active item's ID
ActiveItemID ActiveItem::thisID(int16 mapNum) {
- return ActiveItemID(mapNum, this - mapList[mapNum].activeItemList);
+ return ActiveItemID(mapNum, _index);
}
//-----------------------------------------------------------------------
@@ -850,7 +847,7 @@ void saveActiveItemStates(SaveFileConstructor &saveGame) {
for (i = 0; i < worldCount; i++) {
if (stateArray[i] != nullptr) {
WorldMapData *mapData = &mapList[i];
- ActiveItemPtr activeItemList = mapData->activeItemList;
+ ActiveItemList *activeItemList = mapData->activeItemList;
int16 activeItemCount = mapData->activeCount,
j;
int32 arraySize = tileRes->size(tagStateID + i);
@@ -867,7 +864,7 @@ void saveActiveItemStates(SaveFileConstructor &saveGame) {
bufferPtr = (uint8 *)bufferPtr + arraySize;
for (j = 0; j < activeItemCount; j++) {
- ActiveItem *activeItem = &activeItemList[j];
+ ActiveItem *activeItem = activeItemList->_items[j];
uint8 *statePtr;
if (activeItem->itemType != activeTypeInstance)
@@ -930,13 +927,13 @@ void loadActiveItemStates(SaveFileReader &saveGame) {
if (arraySize > 0) {
WorldMapData *mapData = &mapList[i];
- ActiveItemPtr activeItemList = mapData->activeItemList;
+ ActiveItemList *activeItemList = mapData->activeItemList;
int16 activeItemCount = mapData->activeCount,
j;
uint8 *bufferedStateArray = (uint8 *)bufferPtr;
for (j = 0; j < activeItemCount; j++) {
- ActiveItem *activeItem = &activeItemList[j];
+ ActiveItem *activeItem = activeItemList->_items[j];
uint8 *statePtr;
if (activeItem->itemType != activeTypeInstance)
@@ -1478,25 +1475,46 @@ MetaTileList::~MetaTileList() {
}
}
-static void readActiveItem(hResContext *con, ActiveItem &itm) {
- // FIXME: 32-bit pointer to 64-bit pointer conversion.
- // Is this dangerous?
- itm.nextHash = nullptr;
- con->readU32LE();
- itm.scriptClassID = con->readU16LE();
- itm.associationOffset = con->readU16LE();
- itm.numAssociations = con->readByte();
- itm.itemType = con->readByte();
- itm.instance.groupID = con->readU16LE();
- itm.instance.u = con->readS16LE();
- itm.instance.v = con->readS16LE();
- itm.instance.h = con->readS16LE();
- itm.instance.stateIndex = con->readU16LE();
- itm.instance.scriptFlags = con->readU16LE();
- itm.instance.targetU = con->readU16LE();
- itm.instance.targetV = con->readU16LE();
- itm.instance.targetZ = con->readByte();
- itm.instance.worldNum = con->readByte();
+ActiveItem::ActiveItem(ActiveItemList *parent, int ind, Common::SeekableReadStream *stream) {
+ _parent = parent;
+ _index = ind;
+ nextHash = nullptr;
+ stream->readUint32LE();
+ scriptClassID = stream->readUint16LE();
+ associationOffset = stream->readUint16LE();
+ numAssociations = stream->readByte();
+ itemType = stream->readByte();
+ instance.groupID = stream->readUint16LE();
+ instance.u = stream->readSint16LE();
+ instance.v = stream->readSint16LE();
+ instance.v = stream->readSint16LE();
+ instance.stateIndex = stream->readUint16LE();
+ instance.scriptFlags = stream->readUint16LE();
+ instance.targetU = stream->readUint16LE();
+ instance.targetV = stream->readUint16LE();
+ instance.targetZ = stream->readByte();
+ instance.worldNum = stream->readByte();
+}
+
+ActiveItemList::ActiveItemList(WorldMapData *parent, int count, Common::SeekableReadStream *stream) {
+ _parent = parent;
+ _count = count;
+ _items = (ActiveItem **)malloc(_count * sizeof(ActiveItem *));
+
+ for (int i = 0; i < _count; ++i) {
+ _items[i] = new ActiveItem(this, i, stream);
+ }
+}
+
+ActiveItemList::~ActiveItemList() {
+ if (_items) {
+ for (int i = 0; i < _count; ++i) {
+ if (_items[i])
+ delete _items[i];
+ }
+
+ free(_items);
+ }
}
void initMaps(void) {
@@ -1591,23 +1609,22 @@ void initMaps(void) {
// If there is an active item list, load it
if (tileRes->size(iActiveItemID) > 0) {
int activeItemCount = tileRes->size(iActiveItemID) / activeItemSize;
- mapData->activeItemList = new ActiveItem[activeItemCount];
- tileRes->seek(iActiveItemID);
- for (int k = 0; k < activeItemCount; ++k)
- readActiveItem(tileRes, mapData->activeItemList[k]);
+ stream = loadResourceToStream(tileRes, iActiveItemID, "active item list");
+ mapData->activeItemList = new ActiveItemList(mapData, activeItemCount, stream);
+ delete stream;
- if (mapData->activeItemList == nullptr)
+ if (mapData->activeItemList == nullptr ||
+ mapData->activeItemList->_items == nullptr)
error("Unable to load active item list");
+
+ mapData->activeCount = activeItemCount;
+
} else
mapData->activeItemList = nullptr;
// Compute the number of meta tiles in list
mapData->metaCount = metaTileCount;
- // Compute the number of active items in list
- mapData->activeCount = tileRes->size(tagID + i)
- / sizeof(ActiveItem); // Not portable?
-
// Allocate an object ripping table ID list
mapData->ripTableIDList = new RipTableID[mapData->metaCount];
if (mapData->ripTableIDList == nullptr)
@@ -1660,7 +1677,7 @@ void cleanupMaps(void) {
// If there is an active item list, dump it
if (mapData->activeItemList != nullptr)
- delete[] mapData->activeItemList;
+ delete mapData->activeItemList;
// Dump the object ripping table ID list
delete[] mapData->ripTableIDList;
@@ -2452,11 +2469,12 @@ MetaTilePtr WorldMapData::lookupMeta(TilePoint coords) {
void WorldMapData::buildInstanceHash(void) {
int32 i;
int16 hashVal;
- ActiveItem *ai;
+ ActiveItem **ail;
memset(instHash, 0, sizeof(instHash));
- for (i = 0, ai = activeItemList; i < activeCount; i++, ai++) {
+ for (i = 0, ail = activeItemList->_items; i < activeCount; i++, ail++) {
+ ActiveItem *ai = *ail;
if (ai->itemType == activeTypeInstance) {
hashVal = (((ai->instance.u + ai->instance.h) << 4)
+ ai->instance.v + (ai->instance.groupID << 2))
@@ -2476,6 +2494,7 @@ ActiveItem *WorldMapData::findHashedInstance(
int16 group) {
int16 hashVal = (((tp.u + tp.z) << 4) + tp.v + (group << 2))
% elementsof(instHash);
+
if (itemHash.contains(hashVal))
return itemHash.getVal(hashVal);
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index a089e58db6..100d70df20 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -370,6 +370,8 @@ enum ActiveItemTypes {
// A pointer to the array of active item state arrays
extern byte **stateArray;
+class ActiveItemList;
+
class ActiveItem {
public:
ActiveItem *nextHash; // next item in hash chain
@@ -382,6 +384,8 @@ public:
uint16 associationOffset; // offset into association table
uint8 numAssociations; // number of associated items
uint8 itemType; // item type code.
+ int _index;
+ ActiveItemList *_parent;
union {
struct {
@@ -414,6 +418,8 @@ public:
activeItemExclusive = (1 << 10), // Script semaphore
};
+ ActiveItem(ActiveItemList *parent, int ind, Common::SeekableReadStream *stream);
+
// Return the map number of this active item
int16 getMapNum(void);
@@ -507,6 +513,18 @@ public:
typedef ActiveItem *ActiveItemPtr,
*ActiveItemHandle;
+struct WorldMapData;
+
+class ActiveItemList {
+public:
+ int _count;
+ ActiveItem **_items;
+ WorldMapData *_parent;
+
+ ActiveItemList(WorldMapData *parent, int count, Common::SeekableReadStream *stream);
+ ~ActiveItemList();
+};
+
#if 0
/* ===================================================================== *
@@ -864,7 +882,7 @@ struct WorldMapData {
MapPtr map; // Map data
MetaTileList *metaList; // MetaTile list
TileRefPtr activeItemData; // ActiveItem tileRefs
- ActiveItemPtr activeItemList; // ActiveItem list
+ ActiveItemList *activeItemList; // ActiveItem list
UWordPtr assocList; // Associations
RipTableIDPtr ripTableIDList; // MetaTile object ripping
Commit: da94093b4371e64ba0c4e78ed1bbc74d8b266ef0
https://github.com/scummvm/scummvm/commit/da94093b4371e64ba0c4e78ed1bbc74d8b266ef0
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:14+02:00
Commit Message:
SAGA2: Load spellSprites and spellSchemes with streams
Changed paths:
engines/saga2/dispnode.cpp
engines/saga2/speldata.cpp
engines/saga2/sprite.cpp
engines/saga2/sprite.h
diff --git a/engines/saga2/dispnode.cpp b/engines/saga2/dispnode.cpp
index 9bf558e3f0..1fa3671fb1 100644
--- a/engines/saga2/dispnode.cpp
+++ b/engines/saga2/dispnode.cpp
@@ -60,7 +60,7 @@ extern Point16 fineScroll;
extern gPort backPort;
extern SpriteSet *objectSprites, // object sprites
- * *spellSprites; // spell effect sprites
+ *spellSprites; // spell effect sprites
ActorAppearance *tempAppearance; // test structure
@@ -171,7 +171,7 @@ void DisplayNodeList::draw(void) {
objectSet = objectSprites;
if (objectSet == NULL)
error("Object sprites have been dumped!\n");
- spellSet = *spellSprites;
+ spellSet = spellSprites;
if (spellSet == NULL)
error("Spell sprites have been dumped!\n");
@@ -507,7 +507,7 @@ void DisplayNode::drawObject(void) {
a->kludgeCount = 0;
sc = &scList[0];
- sc->sp = (*spellSprites)->sprite(
+ sc->sp = spellSprites->sprite(
baseBubbleSpriteIndex + a->kludgeCount);
sc->offset.x = scList->offset.y = 0;
sc->colorTable = mainColors;
@@ -997,7 +997,7 @@ void Effectron::drawEffect(void) {
sc = &scList[0];
//sc->sp = (*spellSprites)->sprite( spriteID() );
- sc->sp = (*spellSprites)->sprite(spriteID()); //tempSpellSpriteIDs[rand()%39] );
+ sc->sp = spellSprites->sprite(spriteID()); //tempSpellSpriteIDs[rand()%39] );
sc->offset.x = scList->offset.y = 0;
SpellDisplayPrototypeList::sdpList[parent->spell]->
diff --git a/engines/saga2/speldata.cpp b/engines/saga2/speldata.cpp
index 2b5bfcdb91..4f9d299c53 100644
--- a/engines/saga2/speldata.cpp
+++ b/engines/saga2/speldata.cpp
@@ -102,11 +102,11 @@ extern SpellDisplayList activeSpells;
EffectDisplayPrototypeList EffectDisplayPrototypeList::edpList(maxEffectPrototypes);
SpellDisplayPrototypeList SpellDisplayPrototypeList::sdpList(maxSpellPrototypes);
-SpriteSet **spellSprites; // longsword test sprites
+SpriteSet *spellSprites; // longsword test sprites
SpellStuff spellBook[maxSpells];
ColorTable spellColorMaps[maxSpellColorMaps];
-ColorScheme **spellSchemes;
+ColorSchemeList *spellSchemes;
int32 loadedColorMaps;
@@ -128,11 +128,20 @@ void initMagic(void) {
defineEffects();
loadMagicData();
- spellSprites = (SpriteSet **) spriteRes->load(spellSpriteID, "spell sprites");
+ const int colorSchemeSize = 44;
+ Common::SeekableReadStream *stream;
+
+ stream = loadResourceToStream(spriteRes, spellSpriteID, "spell sprites");
+ spellSprites = new SpriteSet(stream);
assert(spellSprites);
- spellSchemes = (ColorScheme **)schemeRes->load(spellSpriteID, "scheme list");
+ delete stream;
+
+ loadedColorMaps = schemeRes->size(spellSpriteID) / colorSchemeSize;
+
+ stream = loadResourceToStream(schemeRes, spellSpriteID, "scheme list");
+ spellSchemes = new ColorSchemeList(loadedColorMaps, stream);
assert(spellSchemes);
- loadedColorMaps = schemeRes->size(spellSpriteID) / sizeof(ColorScheme);
+ delete stream;
}
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index 54dc295021..aeb011df31 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -617,6 +617,24 @@ static void readColorScheme(hResContext *con, ColorScheme &col) {
col.name[i] = con->readSByte();
}
+ColorScheme::ColorScheme(Common::SeekableReadStream *stream) {
+ for (int i = 0; i < 11; ++i)
+ bank[i] = stream->readByte();
+
+ speechColor = stream->readByte();
+
+ for (int i = 0; i < 32; ++i)
+ name[i] = stream->readSByte();
+}
+
+ColorSchemeList::ColorSchemeList(int count, Common::SeekableReadStream *stream) {
+ _count = count;
+
+ _schemes = (ColorScheme **)malloc(_count * sizeof(ColorScheme *));
+ for (int i = 0; i < _count; ++i)
+ _schemes[i] = new ColorScheme(stream);
+}
+
ActorAppearance *LoadActorAppearance(uint32 id, int16 banksNeeded) {
int16 bank;
const int actorAnimSetSize = 8;
diff --git a/engines/saga2/sprite.h b/engines/saga2/sprite.h
index b21e738ae7..c3bc884ee8 100644
--- a/engines/saga2/sprite.h
+++ b/engines/saga2/sprite.h
@@ -176,6 +176,17 @@ struct ColorScheme {
uint8 bank[11];
uint8 speechColor;
char name[32];
+
+ ColorScheme() {}
+ ColorScheme(Common::SeekableReadStream *stream);
+};
+
+class ColorSchemeList {
+public:
+ int _count;
+ ColorScheme **_schemes;
+
+ ColorSchemeList(int count, Common::SeekableReadStream *stream);
};
/* ===================================================================== *
Commit: 796c3a0f7d34a1d6521cebb079f8dbfe321fe314
https://github.com/scummvm/scummvm/commit/796c3a0f7d34a1d6521cebb079f8dbfe321fe314
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:14+02:00
Commit Message:
SAGA2: Use ColorSchemeList in speldraw.cpp
Changed paths:
engines/saga2/speldraw.cpp
diff --git a/engines/saga2/speldraw.cpp b/engines/saga2/speldraw.cpp
index 8d9a78e2fc..d401deafd1 100644
--- a/engines/saga2/speldraw.cpp
+++ b/engines/saga2/speldraw.cpp
@@ -41,7 +41,7 @@ namespace Saga2 {
Imports
* ===================================================================== */
-extern ColorScheme **spellSchemes;
+extern ColorSchemeList *spellSchemes;
extern ColorTable spellColorMaps[];
extern int32 loadedColorMaps;
@@ -152,7 +152,7 @@ void SpellDisplayPrototype::getColorTranslation(ColorTable map, Effectron *e) {
int32 i = colorMap[whichColorMap(effect, e)];
i = MAX(0, MIN(loadedColorMaps, i));
buildColorTable(map,
- (*spellSchemes)[i].bank,
+ spellSchemes->_schemes[i]->bank,
11);
}
Commit: 127299672ba39b8b5a675913fef9aad06cf601f0
https://github.com/scummvm/scummvm/commit/127299672ba39b8b5a675913fef9aad06cf601f0
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:14+02:00
Commit Message:
SAGA2: Load schemeList with stream
Changed paths:
engines/saga2/actor.cpp
engines/saga2/speech.cpp
engines/saga2/sprite.cpp
engines/saga2/sprite.h
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 558348667a..44535ad2c8 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -1905,7 +1905,7 @@ void Actor::getColorTranslation(ColorTable map) {
if (appearance
&& appearance->schemeList) {
buildColorTable(map,
- (appearance->schemeList)[colorScheme].bank,
+ appearance->schemeList->_schemes[colorScheme]->bank,
11);
} else memcpy(map, identityColors, 256);
}
diff --git a/engines/saga2/speech.cpp b/engines/saga2/speech.cpp
index 95532b5e36..c4e0f83a9a 100644
--- a/engines/saga2/speech.cpp
+++ b/engines/saga2/speech.cpp
@@ -1194,7 +1194,7 @@ Speech *SpeechTaskList::newTask(ObjectID id, uint16 flags) {
else if (a->appearance
&& a->appearance->schemeList) {
sp->penColor =
- a->appearance->schemeList[a->colorScheme].speechColor + 9;
+ a->appearance->schemeList->_schemes[a->colorScheme]->speechColor + 9;
} else sp->penColor = 4 + 9;
} else {
sp->penColor = 4 + 9;
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index aeb011df31..1ca2466c67 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -641,6 +641,7 @@ ActorAppearance *LoadActorAppearance(uint32 id, int16 banksNeeded) {
const int colorSchemeSize = 44;
int poseListSize;
int schemeListSize;
+ Common::SeekableReadStream *stream;
// Search the table for either a matching appearance,
// or for an empty one.
@@ -682,7 +683,7 @@ ActorAppearance *LoadActorAppearance(uint32 id, int16 banksNeeded) {
aa->poseList = nullptr;
if (aa->schemeList)
- delete[] aa->schemeList;
+ delete aa->schemeList;
aa->schemeList = nullptr;
// Set ID and use count
@@ -704,9 +705,9 @@ ActorAppearance *LoadActorAppearance(uint32 id, int16 banksNeeded) {
error("Could not load scheme list");
schemeListSize = schemeRes->size(id) / colorSchemeSize;
- aa->schemeList = new ColorScheme[schemeListSize];
- for (int i = 0; i < schemeListSize; ++i)
- readColorScheme(schemeRes, aa->schemeList[i]);
+ stream = loadResourceToStream(schemeRes, id, "scheme list");
+ aa->schemeList = new ColorSchemeList(schemeListSize, stream);
+ delete stream;
return aa;
}
diff --git a/engines/saga2/sprite.h b/engines/saga2/sprite.h
index c3bc884ee8..3f61408653 100644
--- a/engines/saga2/sprite.h
+++ b/engines/saga2/sprite.h
@@ -275,7 +275,7 @@ public:
uint32 id;
ActorAnimSet *poseList; // list of action sequences
- ColorScheme *schemeList; // color remapping info
+ ColorSchemeList *schemeList; // color remapping info
// Table of sprite sets. Each entry in the table
// represents a different "bank" of sprites
Commit: c4477edc40c4728ee28c3ee017f2eddd973eac91
https://github.com/scummvm/scummvm/commit/c4477edc40c4728ee28c3ee017f2eddd973eac91
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:15+02:00
Commit Message:
SAGA2: Add stub warning to Thread deconstructor
Changed paths:
engines/saga2/interp.cpp
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 287f67824a..abb3eba89a 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -1493,6 +1493,7 @@ Thread::~Thread() {
free(stackBase);
// XXX: Deleting like this causes a crash
+ warning("STUB: Thread::~Thread()");
//deleteThread(this);
}
Commit: a9729be22591bcd76d22bcf8bc685354f9875f57
https://github.com/scummvm/scummvm/commit/a9729be22591bcd76d22bcf8bc685354f9875f57
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:15+02:00
Commit Message:
SAGA2: Move tile.h constants to idtypes.h
Changed paths:
engines/saga2/idtypes.h
engines/saga2/tile.h
diff --git a/engines/saga2/idtypes.h b/engines/saga2/idtypes.h
index e48cf3fe31..14937a1a3c 100644
--- a/engines/saga2/idtypes.h
+++ b/engines/saga2/idtypes.h
@@ -304,6 +304,44 @@ enum {
platUVSize = tileUVSize * platformWidth
};
+// Metatile metrics
+enum {
+ metaTileWidth = kTileWidth * platformWidth,
+ metaTileHeight = kTileHeight * platformWidth,
+ metaDX = metaTileWidth / 2,
+ metaDY = metaTileHeight / 2
+};
+
+enum {
+ subTileSize = 4,
+ subTileMask = subTileSize - 1,
+ subTileShift = 2,
+ tileSubSize = 4,
+ tileSubMask = tileSubSize - 1,
+ tileSubShift = 2
+};
+
+// Constants to convert an X,Y into subtile coordinates
+enum {
+ subTileDX = (kTileDX / 4),
+ subTileDY = (kTileDY / 4),
+ subTileDXShift = (kTileDXShift - 2),
+ subTileDYShift = (kTileDYShift - 2)
+};
+
+enum {
+ subTileMaskUShift = 4,
+ subTileMaskVShift = 1
+};
+
+// Maximum height that a character can climb w/o steps or ladders
+enum {
+ maxStepHeight = 16, // highest climbable step
+ maxPickHeight = 64, // highest pickable step
+ maxSmoothStep = 8, // highest smoothly climbable
+ maxJumpStep = 64 // highest jump character likes
+};
+
} // end of namespace Saga2
#endif
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index 100d70df20..5eda344d2b 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -59,39 +59,6 @@ inline void TileID2Bank(TileID t, int16 &bank, int16 &num) {
num = (int16)(t & 0x3ff);
}
-/* ===================================================================== *
- Tile Size constants
- * ===================================================================== */
-
-// Metatile metrics
-const int metaTileWidth = kTileWidth * platformWidth,
- metaTileHeight = kTileHeight * platformWidth,
- metaDX = metaTileWidth / 2,
- metaDY = metaTileHeight / 2;
-
-const int subTileSize = 4,
- subTileMask = subTileSize - 1,
- subTileShift = 2,
- tileSubSize = 4,
- tileSubMask = tileSubSize - 1,
- tileSubShift = 2;
-
-// Constants to convert an X,Y into subtile coordinates
-
-const int subTileDX = (kTileDX / 4),
- subTileDY = (kTileDY / 4),
- subTileDXShift = (kTileDXShift - 2),
- subTileDYShift = (kTileDYShift - 2);
-
-const int subTileMaskUShift = 4,
- subTileMaskVShift = 1;
-
-// Maximum height that a character can climb w/o steps or ladders
-const int maxStepHeight = 16, // highest climbable step
- maxPickHeight = 64, // highest pickable step
- maxSmoothStep = 8, // highest smoothly climbable
- maxJumpStep = 64; // highest jump character likes
-
/* ===================================================================== *
Inline functions
* ===================================================================== */
Commit: 706593f763ba99bac5aa23e44fc4b2f116883597
https://github.com/scummvm/scummvm/commit/706593f763ba99bac5aa23e44fc4b2f116883597
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:15+02:00
Commit Message:
SAGA2: Load nameList with stream
Changed paths:
engines/saga2/objects.cpp
engines/saga2/playmode.cpp
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 8e6379700a..4f0fbf8907 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -66,7 +66,7 @@ const uint32 nameListID = MKTAG('N', 'A', 'M', 'E'),
Locals
* ===================================================================== */
-uint16 *nameList; // handle to list of names
+char **nameList; // handle to list of names
uint32 nameListCount;
ProtoObj *objectProtos = nullptr; // object prototypes
@@ -1461,11 +1461,9 @@ void GameObject::updateState(void) {
* ======================================================================= */
char *GameObject::nameText(uint16 index) {
- uint16 offset = nameList[index];
-
if (index < 0 || index >= nameListCount) return "Bad Name Index";
- return (char *)nameList + offset;
+ return nameList[index];
}
#define INTANGIBLE_MASK (ProtoObj::isEnchantment|ProtoObj::isSpell|ProtoObj::isSkill)
@@ -2513,12 +2511,30 @@ static void readActorPrototype(hResContext *con, ResourceActorPrototype &act) {
}
void initPrototypes(void) {
- int i;
const int resourceObjProtoSize = 52;
const int resourceActProtoSize = 86;
+ Common::SeekableReadStream *stream;
+
+ debugC(1, kDebugLoading, "Initializing Prototypes");
+
+ nameListCount = listRes->size(nameListID) / sizeof(uint16);
+ nameList = (char **)malloc(nameListCount * sizeof(char *));
+ stream = loadResourceToStream(listRes, nameListID, "name list");
+ for (uint i = 0; i < nameListCount; ++i) {
+ stream->seek(2 * i);
+ uint16 offset = stream->readUint16LE();
+
+ if (offset > stream->size())
+ break;
- nameList = (uint16 *)listRes->loadResource(nameListID, "name list");
- nameListCount = listRes->size(nameListID) / sizeof nameList[0];
+ stream->seek(offset);
+ Common::String s = stream->readString();
+ debugC(5, kDebugLoading, "Read string (size %d): %s", s.size(), s.c_str());
+
+ nameList[i] = new char[s.size() + 1];
+ Common::strlcpy(nameList[i], s.c_str(), s.size());
+ nameList[i][s.size()] = '\0';
+ }
// Load the Object prototype table
@@ -2536,7 +2552,7 @@ void initPrototypes(void) {
// Load each individual prototype. Read in everything except
// the virtual function pointer.
- for (i = 0; i < objectProtoCount; i++) {
+ for (int i = 0; i < objectProtoCount; i++) {
ResourceObjectPrototype ro;
ProtoObj *pr = &objectProtos[i];
@@ -2680,7 +2696,7 @@ void initPrototypes(void) {
if (listRes->seek(actorProtoID) == 0)
error("Unable to load Actor Prototypes");
- for (i = 0; i < actorProtoCount; i++) {
+ for (int i = 0; i < actorProtoCount; i++) {
ResourceActorPrototype ra;
ActorProto *pr = &actorProtos[i];
@@ -2696,6 +2712,16 @@ void initPrototypes(void) {
// Cleanup the prototype lists
void cleanupPrototypes(void) {
+ if (nameList) {
+ for (uint i = 0; i < nameListCount; ++i) {
+ if (nameList[i])
+ delete nameList[i];
+
+ free(nameList);
+ nameList = nullptr;
+ }
+ }
+
if (actorProtos != nullptr) {
free(actorProtos);
actorProtos = nullptr;
diff --git a/engines/saga2/playmode.cpp b/engines/saga2/playmode.cpp
index d6444c815a..fa2d364909 100644
--- a/engines/saga2/playmode.cpp
+++ b/engines/saga2/playmode.cpp
@@ -53,8 +53,6 @@ extern BackWindow *mainWindow;
extern SpriteSet *objectSprites; // object sprites
extern gToolBase G_BASE;
-extern char ***nameList; // handle to list of names
-
extern APPFUNC(cmdClickSpeech);
extern PlayerActor playerList[]; // a list of the players (brothers)
extern textPallete genericTextPal;
Commit: bc35986f9567147d817312042cd928506ee2dcc8
https://github.com/scummvm/scummvm/commit/bc35986f9567147d817312042cd928506ee2dcc8
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:15+02:00
Commit Message:
SAGA2: Use Common::Array for nameList
Changed paths:
engines/saga2/objects.cpp
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 4f0fbf8907..616acd02ca 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -66,7 +66,7 @@ const uint32 nameListID = MKTAG('N', 'A', 'M', 'E'),
Locals
* ===================================================================== */
-char **nameList; // handle to list of names
+Common::Array<char *> nameList; // handle to list of names
uint32 nameListCount;
ProtoObj *objectProtos = nullptr; // object prototypes
@@ -2513,28 +2513,27 @@ static void readActorPrototype(hResContext *con, ResourceActorPrototype &act) {
void initPrototypes(void) {
const int resourceObjProtoSize = 52;
const int resourceActProtoSize = 86;
+ uint count = 0;
Common::SeekableReadStream *stream;
+ Common::String s;
debugC(1, kDebugLoading, "Initializing Prototypes");
- nameListCount = listRes->size(nameListID) / sizeof(uint16);
- nameList = (char **)malloc(nameListCount * sizeof(char *));
stream = loadResourceToStream(listRes, nameListID, "name list");
- for (uint i = 0; i < nameListCount; ++i) {
- stream->seek(2 * i);
- uint16 offset = stream->readUint16LE();
-
- if (offset > stream->size())
- break;
+ for (uint16 offset = 0; offset < stream->size(); ++count) {
+ stream->seek(2 * count);
+ offset = stream->readUint16LE();
stream->seek(offset);
- Common::String s = stream->readString();
+ s = stream->readString();
debugC(5, kDebugLoading, "Read string (size %d): %s", s.size(), s.c_str());
- nameList[i] = new char[s.size() + 1];
- Common::strlcpy(nameList[i], s.c_str(), s.size());
- nameList[i][s.size()] = '\0';
+ char *name = new char[s.size() + 1];
+ Common::strlcpy(name, s.c_str(), s.size());
+ name[s.size()] = '\0';
+ nameList.push_back(name);
}
+ nameListCount = count;
// Load the Object prototype table
@@ -2712,14 +2711,11 @@ void initPrototypes(void) {
// Cleanup the prototype lists
void cleanupPrototypes(void) {
- if (nameList) {
- for (uint i = 0; i < nameListCount; ++i) {
- if (nameList[i])
- delete nameList[i];
+ for (uint i = 0; i < nameListCount; ++i) {
+ if (nameList[i])
+ delete[] nameList[i];
- free(nameList);
- nameList = nullptr;
- }
+ nameList.clear();
}
if (actorProtos != nullptr) {
Commit: 193f61622586a43d67bad2dd12d96285132aa0af
https://github.com/scummvm/scummvm/commit/193f61622586a43d67bad2dd12d96285132aa0af
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:15+02:00
Commit Message:
SAGA2: Clean up vwpage.cpp
Changed paths:
R engines/saga2/vwpage.h
engines/saga2/vwpage.cpp
diff --git a/engines/saga2/vwpage.cpp b/engines/saga2/vwpage.cpp
index 8630e1bc37..a75c5b93aa 100644
--- a/engines/saga2/vwpage.cpp
+++ b/engines/saga2/vwpage.cpp
@@ -28,303 +28,13 @@
#include "graphics/surface.h"
#include "saga2/std.h"
#include "saga2/vdraw.h"
-#include "saga2/vwpage.h"
+#include "saga2/blitters.h"
namespace Saga2 {
-static CDDWindow *ddWindow = NULL;
-static CDDWindow *oldDDWindow = NULL;
-static int suspends = 0;
+vDisplayPage protoPage;
-void WriteToLogFile(char *, ...);
-
-/* ===================================================================== *
- DirectDraw display page class
- * ===================================================================== */
-
-#define vWDisplayPage vDisplayPage
-
-#ifndef KLUDGE
-static bool displayEnabled(void) {
- return true;
-}
-#endif
-
-/* ===================================================================== *
- Globals
- * ===================================================================== */
-
-vWDisplayPage displayPageList[2],
- *displayPage,
- protoPage;
-
-int16 displayPageCount,
- currentDisplayPage;
-
-/* ===================================================================== *
- GTools assembly-language function prototypes
- * ===================================================================== */
-
-// Assembly-language function to copy pixel to SVGA (opaque)
-
-#ifndef FTAASM_H
-extern void _BltPixels(uint8 *srcPtr, uint32 srcMod,
- uint8 *dstPtr, uint32 dstMod,
- uint32 width, uint32 height);
-
-// Assembly-language function to copy pixel to SVGA (transparent)
-
-extern void _BltPixelsT(uint8 *srcPtr, uint32 srcMod,
- uint8 *dstPtr, uint32 dstMod,
- uint32 width, uint32 height);
-
-// Assembly-language function to do rectangle fill (opaque)
-
-extern void _FillRect(uint8 *dstPtr, uint32 dstMod,
- uint32 width, uint32 height, uint32 color);
-
-// Assembly-language function to draw horizontal line (opaque)
-
-extern void _HLine(uint8 *dstPtr, uint32 width, uint32 color);
-
-
-#endif
-
-/*
-typedef struct _DDSURFACEDESC{
- DWORD dwSize; // size of the DDSURFACEDESC structure
- DWORD dwFlags; // determines what fields are valid
- DWORD dwHeight; // height of surface to be created
- DWORD dwWidth; // width of input surface
- LONG lPitch; // distance to start of next line (return value only)
- DWORD dwBackBufferCount; // number of back buffers requested
- DWORD dwZBufferBitDepth; // depth of Z buffer requested
- DWORD dwAlphaBitDepth; // depth of alpha buffer requested
-LPVOID lpSurface; // pointer to the associated surface memory
- DDCOLORKEY ddckCKDestOverlay; // color key for destination overlay use
- DDCOLORKEY ddckCKDestBlt; // color key for destination blt use
- DDCOLORKEY ddckCKSrcOverlay; // color key for source overlay use
- DDCOLORKEY ddckCKSrcBlt; // color key for source blt use
- DDPIXELFORMAT ddpfPixelFormat; // pixel format description of the surface
- DDSCAPS ddsCaps; // direct draw surface capabilities
-} DDSURFACEDESC, FAR* LPDDSURFACEDESC;
-*/
-
-/* ===================================================================== *
- Initialize graphics
- * ===================================================================== */
-
-void initDDGraphics(gDisplayPort &mainPort, CDDWindow *displayWin) {
- ddWindow = displayWin;
- suspends = 0;
- displayPageCount = 1;
- currentDisplayPage = 0;
-
- displayPageList[0] = displayPageList[1] = protoPage;
-
- displayPage = &displayPageList[0];
- drawPage = (vDisplayPage *)displayPage;
-
- // Set the size of the display page in pixels
-
-// gDisplaySize = Point16( mib->XResolution, mib->YResolution );
- gDisplaySize = Point16(640, 480);
- displayPageList[0].size = gDisplaySize;
- displayPageList[1].size = gDisplaySize;
-
- mainPort.setDisplayPage(drawPage); // set up display page
-}
-
-/* ===================================================================== *
- Clean up graphics
- * ===================================================================== */
-
-void cleanupDDGraphics(void) {
- /*
- restoreDisplay();
- */
- ddWindow = NULL;
- suspends = 0;
-}
-
-void suspendDDGraphics(void) {
- if (0 == suspends) {
- oldDDWindow = ddWindow;
- ddWindow = NULL;
- }
- suspends++;
-}
-
-void resumeDDGraphics(void) {
- suspends--;
- if (0 == suspends) {
- ddWindow = oldDDWindow;
- oldDDWindow = NULL;
- }
-}
-
-
-
-typedef void (* BlittingFunc)(uint8 *srcPtr, uint32 srcMod,
- uint8 *dstPtr, uint32 dstMod,
- uint32 width, uint32 height);
-
-void BltDDRect(Rect16 &r, uint8 *srcPtr, bool bTransparent, uint16 pixMod, bool BufferToVideo)
-//
-// General purpose DirectDraw blitter that takes in to account the limitation where there
-// is a video memory "page break". If you do a copy to video memory that spans memory
-// banks, DirectDraw hangs the computer! This routine is used for reads and writes using
-// the BufferToVideo flag.
-//
-{
-#if 0
- uint8 *dstPtr = NULL;
- uint8 *bltSrc, *bltDst;
- uint32 start;
- uint32 end;
- uint32 firstpage;
- uint32 lastpage;
- uint32 pagex, pagey;
- uint32 i;
- uint32 offy = r.y;
- bool show = false;
-
- if (!displayEnabled()) //ddWindow || !ddWindow->bIsActive )
- return;
-
- BlittingFunc ourBlitter;
-
- if (bTransparent)
- ourBlitter = _BltPixelsT;
- else {
- ourBlitter = _BltPixels;
- show = true;
- }
-
- start = r.x + (r.y * ddWindow->lPitch); // starting rect offset
- end = (r.x + r.width - 1) + ((r.y + r.height - 1) * ddWindow->lPitch);
-
- firstpage = (start >> 16);
- lastpage = (end >> 16);
-
- if ((ddWindow->lPitch == 1024) || (firstpage == lastpage)) { // || (((r.x & 3) == 0) && BufferToVideo))
- //
- // No special handling required here (doesn't span pages)
- //
- dstPtr = (uint8 *)ddWindow->LockBackBuffer(NULL);
- if (dstPtr) {
-
- bltSrc = srcPtr;
- bltDst = dstPtr + (r.y * ddWindow->lPitch) + r.x;
-
- if (BufferToVideo)
- ourBlitter(bltSrc, pixMod,
- bltDst, ddWindow->lPitch,
- r.width, r.height);
- else
- ourBlitter(bltDst, ddWindow->lPitch,
- bltSrc, pixMod,
- r.width, r.height);
-
- ddWindow->UnlockBackBuffer(dstPtr);
- dstPtr = NULL;
- } else {
- gError::warn("Failed buffer lock");
- }
- return;
- }
-
- dstPtr = (uint8 *)ddWindow->LockBackBuffer(NULL);
-
- if (dstPtr) {
-
-
- for (i = (start + 65536) & (0xFFFF0000); i <= end; i += 65536) {
- pagex = i % ddWindow->lPitch;
- pagey = i / ddWindow->lPitch;
-
- if ((pagex > r.x) && (pagex < (r.x + r.width)) &&
- (pagey >= r.y) && (pagey < (r.y + r.height))) {
- // Page break is in the middle of a rectangle row, so at least 2 blits are necessary
- //
- // First blit - top rectangle
-
- bltSrc = srcPtr + (offy - r.y) * pixMod;
- bltDst = dstPtr + (offy * ddWindow->lPitch) + r.x;
- if (pagey - offy) {
- if (BufferToVideo)
- ourBlitter(bltSrc, pixMod,
- bltDst, ddWindow->lPitch,
- r.width, (pagey - offy));
- else
- ourBlitter(bltDst, ddWindow->lPitch,
- bltSrc, pixMod,
- r.width, (pagey - offy));
- }
-
-
- // Second blit - broken line, left of boundary
- offy = pagey;
-
-
- bltSrc = srcPtr + (offy - r.y) * pixMod;
- bltDst = dstPtr + (offy * ddWindow->lPitch) + r.x;
- if (BufferToVideo)
- ourBlitter(bltSrc, pixMod,
- bltDst, ddWindow->lPitch,
- pagex - r.x, 1);
- else
- ourBlitter(bltDst, ddWindow->lPitch,
- bltSrc, pixMod,
- pagex - r.x, 1);
-
- //
- // Third blit - broken line, right of boundary
- //
-
- bltSrc = srcPtr + (offy - r.y) * pixMod + (pagex - r.x);
- bltDst = dstPtr + (offy * ddWindow->lPitch) + pagex;
- if (BufferToVideo)
- ourBlitter(bltSrc, pixMod,
- bltDst, ddWindow->lPitch,
- (r.x + r.width) - pagex, 1);
- else
- ourBlitter(bltDst, ddWindow->lPitch,
- bltSrc, pixMod,
- (r.x + r.width) - pagex, 1);
- offy++;
- }
- }
-
- bltSrc = srcPtr + (offy - r.y) * pixMod;
- bltDst = dstPtr + (offy * ddWindow->lPitch) + r.x;
- if (r.y + r.height - offy > 0) {
- if (BufferToVideo)
- ourBlitter(bltSrc, pixMod,
- bltDst, ddWindow->lPitch,
- r.width, (r.y + r.height) - offy);
- else
- ourBlitter(bltDst, ddWindow->lPitch,
- bltSrc, pixMod,
- r.width, (r.y + r.height) - offy);
- }
- ddWindow->UnlockBackBuffer(dstPtr);
- dstPtr = NULL;
- } else {
- gError::warn("Failed buffer lock");
- }
-#endif
- warning("STUB: BltDDRect");
-}
-
-
-/* ===================================================================== *
- Member functions for display page
- * ===================================================================== */
-
-// Fill a rectangle on the SVGA display. Note the rect must
-// be correct -- there is no clipping or error checking...
-void vWDisplayPage::fillRect(Rect16 r, uint8 color) {
+void vDisplayPage::fillRect(Rect16 r, uint8 color) {
Graphics::Surface *surf = g_system->lockScreen();
_FillRect((byte *)surf->getBasePtr(r.x, r.y), surf->pitch, r.width, r.height, color);
@@ -334,21 +44,14 @@ void vWDisplayPage::fillRect(Rect16 r, uint8 color) {
// Fill a rectangle on the SVGA display. Note the rect must
// be correct -- there is no clipping or error checking...
-void vWDisplayPage::invertRect(Rect16 r, uint8 color) {
+void vDisplayPage::invertRect(Rect16 r, uint8 color) {
}
-#define USE_BLTDDRECT
-// -- we'll want to use this when we figure out why bltDDRect doesnt work here
-#define USE_RECT
-
-void vWDisplayPage::writePixels(Rect16 &r, uint8 *pixPtr, uint16 pixMod) {
+void vDisplayPage::writePixels(Rect16 &r, uint8 *pixPtr, uint16 pixMod) {
g_system->copyRectToScreen(pixPtr, pixMod, r.x, r.y, r.width, r.height);
}
-void vWDisplayPage::writeTransPixels(Rect16 &r, uint8 *pixPtr, uint16 pixMod) {
- if (!displayEnabled()) //ddWindow || !ddWindow->bIsActive )
- return;
-
+void vDisplayPage::writeTransPixels(Rect16 &r, uint8 *pixPtr, uint16 pixMod) {
Graphics::Surface *surf = g_system->lockScreen();
_BltPixelsT(pixPtr, pixMod, (byte *)surf->getBasePtr(r.x, r.y), surf->pitch, r.width, r.height );
@@ -356,20 +59,20 @@ void vWDisplayPage::writeTransPixels(Rect16 &r, uint8 *pixPtr, uint16 pixMod) {
g_system->unlockScreen();
}
-void vWDisplayPage::readPixels(Rect16 &r, uint8 *pixPtr, uint16 pixMod) {
- BltDDRect(r, pixPtr, false, pixMod, false);
+void vDisplayPage::readPixels(Rect16 &r, uint8 *pixPtr, uint16 pixMod) {
+ warning("STUB: vWDisplayPage::readPixels()");
}
// Function to quickly transfer pixels from an off-screen
// buffer to a rectangle on the SVGA display;
-void vWDisplayPage::writeColorPixels(Rect16 r, uint8 *pixPtr, uint16 pixMod, uint8 color) {
+void vDisplayPage::writeColorPixels(Rect16 r, uint8 *pixPtr, uint16 pixMod, uint8 color) {
warning("STUB: writeColorPixels");
writePixels(r, pixPtr, pixMod);
}
// Function to quickly transfer pixels from an off-screen
// buffer to a rectangle on the SVGA display;
-void vWDisplayPage::writeComplementPixels(Rect16 r, uint8 *pixPtr, uint16 pixMod, uint8 color) {
+void vDisplayPage::writeComplementPixels(Rect16 r, uint8 *pixPtr, uint16 pixMod, uint8 color) {
warning("STUB: writeComplementPixels");
writePixels(r, pixPtr, pixMod);
}
diff --git a/engines/saga2/vwpage.h b/engines/saga2/vwpage.h
deleted file mode 100644
index 45848dbbbb..0000000000
--- a/engines/saga2/vwpage.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#ifndef SAGA2_VWPAGE_H
-#define SAGA2_VWPAGE_H
-
-namespace Saga2 {
-
-class gDisplayPort;
-
-#define CDDWindow void
-
-extern void initDDGraphics(gDisplayPort &mainPort, CDDWindow *displayWin);
-extern void cleanupDDGraphics(void);
-extern void suspendDDGraphics(void);
-extern void resumeDDGraphics(void);
-void setBlitter(bool isEasy);
-
-} // end of namespace Saga2
-
-#endif
Commit: 35a90c132ee93ab47db2ac6891d9f681d443d9ae
https://github.com/scummvm/scummvm/commit/35a90c132ee93ab47db2ac6891d9f681d443d9ae
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:15+02:00
Commit Message:
SAGA2: Merge vwdraw.cpp and vwpage.cpp
Changed paths:
R engines/saga2/vwpage.cpp
engines/saga2/module.mk
engines/saga2/vwdraw.cpp
diff --git a/engines/saga2/module.mk b/engines/saga2/module.mk
index 7f119420e7..f98ab09315 100644
--- a/engines/saga2/module.mk
+++ b/engines/saga2/module.mk
@@ -95,7 +95,6 @@ MODULE_OBJS := \
videobox.o \
vpal.o \
vwdraw.o \
- vwpage.o \
weapons.o
MODULE_DIRS += \
diff --git a/engines/saga2/vwdraw.cpp b/engines/saga2/vwdraw.cpp
index 3ee226f21c..995e21f847 100644
--- a/engines/saga2/vwdraw.cpp
+++ b/engines/saga2/vwdraw.cpp
@@ -24,19 +24,16 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#include "graphics/surface.h"
+
#include "saga2/std.h"
#include "saga2/vdraw.h"
+#include "saga2/blitters.h"
namespace Saga2 {
-Extent16 gDisplaySize;
-vDisplayPage *drawPage;
-
-/* ===================================================================== *
- Member functions for gDisplayPort
- * ===================================================================== */
-
-// Your basic rectfill operation -- but this time in SVGA
+vDisplayPage *drawPage;
+vDisplayPage protoPage;
void gDisplayPort::fillRect(const Rect16 r) {
Rect16 sect;
@@ -48,7 +45,8 @@ void gDisplayPort::fillRect(const Rect16 r) {
if (!sect.empty()) { // if result is non-empty
if (drawMode == drawModeComplement) // Complement drawing mode
displayPage->invertRect(sect, fgPen);
- else displayPage->fillRect(sect, fgPen); // regular drawing mode
+ else
+ displayPage->fillRect(sect, fgPen); // regular drawing mode
}
}
@@ -92,31 +90,20 @@ void gDisplayPort::bltPixels(
case drawModeComplement: // blit in complement mode
displayPage->writeComplementPixels(sect, src_line, src.size.x, fgPen);
break;
+ default:
+ error("bltPixels: Unknown drawMode: %d", drawMode);
}
}
}
-/********* vdraw.cpp/gDisplayPort::scrollPixels **********************
-*
-* NAME gDisplayPort::scrollPixels
-*
-* SYNOPSIS
-*
-* FUNCTION
-*
-* INPUTS
-*
-* RESULT
-*
-**********************************************************************
-*/
void gDisplayPort::scrollPixels(
const Rect16 r, // area to scroll
int dx, // amount to scroll by
int dy) {
Rect16 sect;
- if (dx == 0 && dy == 0) return; // quit of nothing to do
+ if (dx == 0 && dy == 0) // quit of nothing to do
+ return;
sect = intersect(clip, r); // apply cliping rect
@@ -147,7 +134,8 @@ void gDisplayPort::scrollPixels(
// Quit if all data is completely scrolled off
- if (srcRect.width <= 0 || srcRect.height <= 0) return;
+ if (srcRect.width <= 0 || srcRect.height <= 0)
+ return;
// Allocate temp map to hold scrolled pixels
@@ -172,6 +160,7 @@ void gDisplayPort::scrollPixels(
// Bresenham line-drawing functions
void gDisplayPort::line(int16 x1, int16 y1, int16 x2, int16 y2) {
+ warning("STUB: gDisplayPort::line()");
#if 0
bool clipNeeded = false;
@@ -407,19 +396,45 @@ void gDisplayPort::line(int16 x1, int16 y1, int16 x2, int16 y2) {
#endif
}
-/* These are the breakpoint values
+void vDisplayPage::fillRect(Rect16 r, uint8 color) {
+ Graphics::Surface *surf = g_system->lockScreen();
+
+ _FillRect((byte *)surf->getBasePtr(r.x, r.y), surf->pitch, r.width, r.height, color);
+
+ g_system->unlockScreen();
+}
+
+void vDisplayPage::invertRect(Rect16 r, uint8 color) {
+}
+
+void vDisplayPage::writePixels(Rect16 &r, uint8 *pixPtr, uint16 pixMod) {
+ g_system->copyRectToScreen(pixPtr, pixMod, r.x, r.y, r.width, r.height);
+}
+
+void vDisplayPage::writeTransPixels(Rect16 &r, uint8 *pixPtr, uint16 pixMod) {
+ Graphics::Surface *surf = g_system->lockScreen();
+
+ _BltPixelsT(pixPtr, pixMod, (byte *)surf->getBasePtr(r.x, r.y), surf->pitch, r.width, r.height );
- 0x10000 / 640 = 102
- 0x10000 % 640 = 256
+ g_system->unlockScreen();
+}
- 0x20000 / 640 = 204
- 0x20000 % 640 = 512
+void vDisplayPage::readPixels(Rect16 &r, uint8 *pixPtr, uint16 pixMod) {
+ warning("STUB: vWDisplayPage::readPixels()");
+}
- 0x30000 / 640 = 307
- 0x30000 % 640 = 128
+// Function to quickly transfer pixels from an off-screen
+// buffer to a rectangle on the SVGA display;
+void vDisplayPage::writeColorPixels(Rect16 r, uint8 *pixPtr, uint16 pixMod, uint8 color) {
+ warning("STUB: writeColorPixels");
+ writePixels(r, pixPtr, pixMod);
+}
- 0x40000 / 640 = 409
- 0x40000 % 640 = 384
-*/
+// Function to quickly transfer pixels from an off-screen
+// buffer to a rectangle on the SVGA display;
+void vDisplayPage::writeComplementPixels(Rect16 r, uint8 *pixPtr, uint16 pixMod, uint8 color) {
+ warning("STUB: writeComplementPixels");
+ writePixels(r, pixPtr, pixMod);
+}
} // end of namespace Saga2
diff --git a/engines/saga2/vwpage.cpp b/engines/saga2/vwpage.cpp
deleted file mode 100644
index a75c5b93aa..0000000000
--- a/engines/saga2/vwpage.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * aint32 with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#include "common/rect.h"
-#include "graphics/surface.h"
-#include "saga2/std.h"
-#include "saga2/vdraw.h"
-#include "saga2/blitters.h"
-
-namespace Saga2 {
-
-vDisplayPage protoPage;
-
-void vDisplayPage::fillRect(Rect16 r, uint8 color) {
- Graphics::Surface *surf = g_system->lockScreen();
-
- _FillRect((byte *)surf->getBasePtr(r.x, r.y), surf->pitch, r.width, r.height, color);
-
- g_system->unlockScreen();
-}
-
-// Fill a rectangle on the SVGA display. Note the rect must
-// be correct -- there is no clipping or error checking...
-void vDisplayPage::invertRect(Rect16 r, uint8 color) {
-}
-
-void vDisplayPage::writePixels(Rect16 &r, uint8 *pixPtr, uint16 pixMod) {
- g_system->copyRectToScreen(pixPtr, pixMod, r.x, r.y, r.width, r.height);
-}
-
-void vDisplayPage::writeTransPixels(Rect16 &r, uint8 *pixPtr, uint16 pixMod) {
- Graphics::Surface *surf = g_system->lockScreen();
-
- _BltPixelsT(pixPtr, pixMod, (byte *)surf->getBasePtr(r.x, r.y), surf->pitch, r.width, r.height );
-
- g_system->unlockScreen();
-}
-
-void vDisplayPage::readPixels(Rect16 &r, uint8 *pixPtr, uint16 pixMod) {
- warning("STUB: vWDisplayPage::readPixels()");
-}
-
-// Function to quickly transfer pixels from an off-screen
-// buffer to a rectangle on the SVGA display;
-void vDisplayPage::writeColorPixels(Rect16 r, uint8 *pixPtr, uint16 pixMod, uint8 color) {
- warning("STUB: writeColorPixels");
- writePixels(r, pixPtr, pixMod);
-}
-
-// Function to quickly transfer pixels from an off-screen
-// buffer to a rectangle on the SVGA display;
-void vDisplayPage::writeComplementPixels(Rect16 r, uint8 *pixPtr, uint16 pixMod, uint8 color) {
- warning("STUB: writeComplementPixels");
- writePixels(r, pixPtr, pixMod);
-}
-
-} // end of namespace Saga2
Commit: c35aef8ad2eb81066c4356e6d7c2dfa12471a544
https://github.com/scummvm/scummvm/commit/c35aef8ad2eb81066c4356e6d7c2dfa12471a544
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:15+02:00
Commit Message:
SAGA2: Fix accidental read in tile.cpp
Changed paths:
engines/saga2/tile.cpp
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 1a0216468b..b0b31ed650 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -1068,7 +1068,7 @@ Common::MemorySeekableReadWriteStream *TileActivityTaskList::archive(Common::Mem
taskCount++;
// Store the task count
- taskCount = stream->readSint16LE();
+ stream->writeSint16LE(taskCount);
for (tat = (TileActivityTask *)list.first();
tat != nullptr;
Commit: 6fe11531b6b36ac29a53d39ccbd0f6aafc11ed94
https://github.com/scummvm/scummvm/commit/6fe11531b6b36ac29a53d39ccbd0f6aafc11ed94
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:15+02:00
Commit Message:
SAGA2: Rename platform metric constants
Changed paths:
engines/saga2/automap.cpp
engines/saga2/beegee.cpp
engines/saga2/dispnode.cpp
engines/saga2/idtypes.h
engines/saga2/mapfeatr.cpp
engines/saga2/music.h
engines/saga2/objects.cpp
engines/saga2/objproto.cpp
engines/saga2/path.cpp
engines/saga2/property.cpp
engines/saga2/sensor.cpp
engines/saga2/spelcast.cpp
engines/saga2/target.cpp
engines/saga2/target.h
engines/saga2/terrain.cpp
engines/saga2/tile.cpp
engines/saga2/tile.h
engines/saga2/tileload.cpp
diff --git a/engines/saga2/automap.cpp b/engines/saga2/automap.cpp
index 4eb587dfd4..3d8f64aa40 100644
--- a/engines/saga2/automap.cpp
+++ b/engines/saga2/automap.cpp
@@ -200,7 +200,7 @@ void CAutoMap::locateRegion(void) {
assert(trRes != NULL);
regionCount = *trRes;
- centerCoords = trackPos >> (tileUVShift + platShift);
+ centerCoords = trackPos >> (tileUVShift + kPlatShift);
localAreaRegion.min.u = localAreaRegion.min.v = 0;
localAreaRegion.max.u = localAreaRegion.max.v = wMap->mapSize;
@@ -498,10 +498,10 @@ void CAutoMap::createSmallMap(void) {
&& centerCoords.v <= viewRegion.max.v) {
// Calculate the position of the cross-hairs showing the position of
// the center actor.
- centerPt = trackPos - (baseCoords << (tileUVShift + platShift));
+ centerPt = trackPos - (baseCoords << (tileUVShift + kPlatShift));
- x = ((centerPt.u - centerPt.v) >> (tileUVShift + platShift - 2)) + 261 + 4;
- y = 255 + 4 - ((centerPt.u + centerPt.v) >> (tileUVShift + platShift - 1));
+ x = ((centerPt.u - centerPt.v) >> (tileUVShift + kPlatShift - 2)) + 261 + 4;
+ y = 255 + 4 - ((centerPt.u + centerPt.v) >> (tileUVShift + kPlatShift - 1));
tPort.setColor(9 + 15); // black
tPort.fillRect(x - 3, y - 1, 7, 3);
diff --git a/engines/saga2/beegee.cpp b/engines/saga2/beegee.cpp
index 6b993d30ff..4b04346b12 100644
--- a/engines/saga2/beegee.cpp
+++ b/engines/saga2/beegee.cpp
@@ -189,13 +189,13 @@ void setAreaSound(const TilePoint &) {
Point32 themePos;
for (int r = 1; r < 5 && loopID == 0 ; r++) {
TileRegion regn;
- regn.max = baseCoords + ((AudibilityVector * r) << platShift) ; ///tileUVSize;
- regn.min = baseCoords - ((AudibilityVector * r) << platShift); ///tileUVSize;
+ regn.max = baseCoords + ((AudibilityVector * r) << kPlatShift) ; ///tileUVSize;
+ regn.min = baseCoords - ((AudibilityVector * r) << kPlatShift); ///tileUVSize;
MetaTileIterator mIter(currentMapNum, regn);
int i = 0;
int j = 0;
- TilePoint dist = AudibilityVector * r << (platShift + 1);
+ TilePoint dist = AudibilityVector * r << (kPlatShift + 1);
dist = dist << 4;
themePos.x = dist.u;
themePos.y = dist.v;
@@ -238,9 +238,9 @@ void setAreaSound(const TilePoint &) {
if (rippedRoofID) {
loopID = 0;
}
- audioEnvironmentUseSet(loopID, ss, themePos << platShift);
+ audioEnvironmentUseSet(loopID, ss, themePos << kPlatShift);
} else if (playingExternalLoop != -1) {
- audioEnvironmentUseSet(playingExternalLoop, 0, Point16(0, 0)); //themePos << platShift);
+ audioEnvironmentUseSet(playingExternalLoop, 0, Point16(0, 0)); //themePos << kPlatShift);
}
}
}
diff --git a/engines/saga2/dispnode.cpp b/engines/saga2/dispnode.cpp
index 1fa3671fb1..81ca081429 100644
--- a/engines/saga2/dispnode.cpp
+++ b/engines/saga2/dispnode.cpp
@@ -381,10 +381,10 @@ void DisplayNode::drawObject(void) {
MetaTile *mt;
RipTable *rt;
- tCoords.u = (objCoords.u >> tileUVShift) & platMask;
- tCoords.v = (objCoords.v >> tileUVShift) & platMask;
- mCoords.u = objCoords.u >> (tileUVShift + platShift);
- mCoords.v = objCoords.v >> (tileUVShift + platShift);
+ tCoords.u = (objCoords.u >> tileUVShift) & kPlatMask;
+ tCoords.v = (objCoords.v >> tileUVShift) & kPlatMask;
+ mCoords.u = objCoords.u >> (tileUVShift + kPlatShift);
+ mCoords.v = objCoords.v >> (tileUVShift + kPlatShift);
mCoords.z = 0;
// Do not display objects that are on a ripped roof
diff --git a/engines/saga2/idtypes.h b/engines/saga2/idtypes.h
index 14937a1a3c..bad4ba3d7f 100644
--- a/engines/saga2/idtypes.h
+++ b/engines/saga2/idtypes.h
@@ -297,17 +297,17 @@ enum {
};
// Plaftorm metrics
-const int platformWidth = 8; // width and height of platform
enum {
- platMask = platformWidth - 1,
- platShift = 3,
- platUVSize = tileUVSize * platformWidth
+ kPlatformWidth = 8,
+ kPlatMask = kPlatformWidth - 1,
+ kPlatShift = 3,
+ kPlatUVSize = tileUVSize * kPlatformWidth
};
// Metatile metrics
enum {
- metaTileWidth = kTileWidth * platformWidth,
- metaTileHeight = kTileHeight * platformWidth,
+ metaTileWidth = kTileWidth * kPlatformWidth,
+ metaTileHeight = kTileHeight * kPlatformWidth,
metaDX = metaTileWidth / 2,
metaDY = metaTileHeight / 2
};
diff --git a/engines/saga2/mapfeatr.cpp b/engines/saga2/mapfeatr.cpp
index f70ab54f8c..f9c97198e0 100644
--- a/engines/saga2/mapfeatr.cpp
+++ b/engines/saga2/mapfeatr.cpp
@@ -251,8 +251,8 @@ void updateMapFeatures(int16 cWorld) {
for (int i = 0; i < mapFeatureCount; i++) {
if (mapFeatures[i]->getWorld() == cWorld) {
uint16 *mapRow;
- mapRow = &mapData[(mapFeatures[i]->getU() >> (tileUVShift + platShift)) * wMap->mapSize];
- uint16 mtile = mapRow[(mapFeatures[i]->getV() >> (tileUVShift + platShift))];
+ mapRow = &mapData[(mapFeatures[i]->getU() >> (tileUVShift + kPlatShift)) * wMap->mapSize];
+ uint16 mtile = mapRow[(mapFeatures[i]->getV() >> (tileUVShift + kPlatShift))];
mapFeatures[i]->expose(mtile & metaTileVisited);
}
}
@@ -327,8 +327,8 @@ void CMapFeature::draw(TileRegion viewRegion,
if (world != inWorld) return;
update();
- //TilePoint centerCoords = featureCoords >> (tileUVShift + platShift);
- TilePoint fCoords = featureCoords >> (tileUVShift + platShift);
+ //TilePoint centerCoords = featureCoords >> (tileUVShift + kPlatShift);
+ TilePoint fCoords = featureCoords >> (tileUVShift + kPlatShift);
if (visible &&
fCoords.u >= viewRegion.min.u &&
fCoords.u <= viewRegion.max.u &&
@@ -338,10 +338,10 @@ void CMapFeature::draw(TileRegion viewRegion,
// Calculate the position of the cross-hairs showing the position of
// the center actor.
- centerPt = featureCoords - (baseCoords << (tileUVShift + platShift));
+ centerPt = featureCoords - (baseCoords << (tileUVShift + kPlatShift));
- x = ((centerPt.u - centerPt.v) >> (tileUVShift + platShift - 2)) + 261 + 4;
- y = 255 + 4 - ((centerPt.u + centerPt.v) >> (tileUVShift + platShift - 1));
+ x = ((centerPt.u - centerPt.v) >> (tileUVShift + kPlatShift - 2)) + 261 + 4;
+ y = 255 + 4 - ((centerPt.u + centerPt.v) >> (tileUVShift + kPlatShift - 1));
#ifdef DEBUG_FEATUREPOS
WriteStatusF(12, "draw at (%d,%d)", x, y);
#endif
@@ -368,7 +368,7 @@ bool CMapFeature::hitCheck(TileRegion viewRegion,
int32 x, y;
if (world != inWorld) return false;
- TilePoint fCoords = featureCoords >> (tileUVShift + platShift);
+ TilePoint fCoords = featureCoords >> (tileUVShift + kPlatShift);
if (visible &&
fCoords.u >= viewRegion.min.u &&
fCoords.u <= viewRegion.max.u &&
@@ -378,10 +378,10 @@ bool CMapFeature::hitCheck(TileRegion viewRegion,
// Calculate the position of the cross-hairs showing the position of
// the center actor.
- centerPt = featureCoords - (baseCoords << (tileUVShift + platShift));
+ centerPt = featureCoords - (baseCoords << (tileUVShift + kPlatShift));
- x = ((centerPt.u - centerPt.v) >> (tileUVShift + platShift - 2)) + 261 + 4;
- y = 255 + 4 - ((centerPt.u + centerPt.v) >> (tileUVShift + platShift - 1));
+ x = ((centerPt.u - centerPt.v) >> (tileUVShift + kPlatShift - 2)) + 261 + 4;
+ y = 255 + 4 - ((centerPt.u + centerPt.v) >> (tileUVShift + kPlatShift - 1));
TilePoint DisplayPoint = TilePoint(x, y, 0);
return isHit(DisplayPoint, comparePoint);
diff --git a/engines/saga2/music.h b/engines/saga2/music.h
index 362e3e4123..d9ee226bf7 100644
--- a/engines/saga2/music.h
+++ b/engines/saga2/music.h
@@ -105,7 +105,7 @@ inline TilePoint metaTileOffset(themeFrame tf) {
}
inline TilePoint coordsInMetaTile(TilePoint tp) {
- return TilePoint(tp.u % platShift, tp.v % platShift, 0);
+ return TilePoint(tp.u % kPlatShift, tp.v % kPlatShift, 0);
}
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 616acd02ca..d6153efe63 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -2341,7 +2341,7 @@ GameWorld::GameWorld(int16 map) {
int16 mapSize; // Size of map in MetaTiles
mapSize = tileRes->readU16LE();
- size.u = (mapSize << platShift) << tileUVShift;
+ size.u = (mapSize << kPlatShift) << tileUVShift;
size.v = size.u;
sectorArraySize = size.u / Saga2::sectorSize;
diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp
index 03398d8576..c404db5994 100644
--- a/engines/saga2/objproto.cpp
+++ b/engines/saga2/objproto.cpp
@@ -1038,7 +1038,7 @@ bool InventoryProto::canDropAt(
// enactor, fail
if (enactorPtr->IDParent() != loc.context
|| (loc - enactorPtr->getLocation()).quickHDistance()
- > tileUVSize * platformWidth * 4)
+ > tileUVSize * kPlatformWidth * 4)
return false;
return true;
@@ -2917,7 +2917,7 @@ void EncounterGeneratorProto::doBackgroundUpdate(GameObject *obj) {
if (actorLoc.context == generatorLoc.context) {
int32 dist,
mtRadius = obj->getHitPoints(),// Radius in metatiles
- ptRadius = mtRadius * tileUVSize * platformWidth,
+ ptRadius = mtRadius * tileUVSize * kPlatformWidth,
prob = obj->getExtra() * (256 * 256) / 100;
TilePoint diff = (TilePoint)actorLoc - (TilePoint)generatorLoc;
diff --git a/engines/saga2/path.cpp b/engines/saga2/path.cpp
index d1d7db5b23..fc856ffc8f 100644
--- a/engines/saga2/path.cpp
+++ b/engines/saga2/path.cpp
@@ -322,17 +322,17 @@ void PathTileRegion::fetchSubMeta(const TilePoint &subMeta) {
}
// Compute tile region relative to metatile
- tileReg.min.u = (tileReg.min.u + origin.u) & platMask;
+ tileReg.min.u = (tileReg.min.u + origin.u) & kPlatMask;
tileReg.max.u = tileReg.min.u + offset.u;
- tileReg.min.v = (tileReg.min.v + origin.v) & platMask;
+ tileReg.min.v = (tileReg.min.v + origin.v) & kPlatMask;
tileReg.max.v = tileReg.min.v + offset.v;
- assert(tileReg.max.u <= platformWidth);
- assert(tileReg.max.v <= platformWidth);
+ assert(tileReg.max.u <= kPlatformWidth);
+ assert(tileReg.max.v <= kPlatformWidth);
// Compute the offset of base tile in metatile to origin
- offset.u = ((subMeta.u >> 1) << platShift) - origin.u;
- offset.v = ((subMeta.v >> 1) << platShift) - origin.v;
+ offset.u = ((subMeta.u >> 1) << kPlatShift) - origin.u;
+ offset.v = ((subMeta.v >> 1) << kPlatShift) - origin.v;
for (int i = 0; i < maxPlatforms; i++) {
uint16 tpFlags = 0;
@@ -350,13 +350,13 @@ void PathTileRegion::fetchSubMeta(const TilePoint &subMeta) {
PathTilePosInfo *arrRow = &array[(u + offset.u) * area.v];
assert(u >= 0);
- assert(u < platformWidth);
+ assert(u < kPlatformWidth);
for (v = tileReg.min.v; v < tileReg.max.v; v++) {
int16 flagIndex = ((u & subMetaMask) << subMetaShift) | (v & subMetaMask);
assert(v >= 0);
- assert(v < platformWidth);
+ assert(v < kPlatformWidth);
if (!(tpFlags & (1 << flagIndex))) {
tpFlags |= (1 << flagIndex);
@@ -398,8 +398,8 @@ void PathTileRegion::fetchSubMeta(const TilePoint &subMeta) {
// Abspos is the absolute position of the
// group on the tile map.
- absPos.u = (mCoords.u << platShift) | tagU;
- absPos.v = (mCoords.v << platShift) | tagV;
+ absPos.u = (mCoords.u << kPlatShift) | tagU;
+ absPos.v = (mCoords.v << kPlatShift) | tagV;
absPos.z = height;
// Look up the group instance in the hash.
@@ -2751,7 +2751,7 @@ TilePoint selectDistantSite(
int metaProperties) {
GameWorld *world = (GameWorld *)GameObject::objectAddress(worldID);
int32 u, v;
- int32 mapSize = mapList[world->mapNum].mapSize * platformWidth;
+ int32 mapSize = mapList[world->mapNum].mapSize * kPlatformWidth;
int matchCount = 0;
// Make sure the location spec'd is within the bounds of the map
@@ -2767,8 +2767,8 @@ TilePoint selectDistantSite(
// convert to metatile coords
minCoords.u = minCoords.u >> platformShift;
minCoords.v = minCoords.v >> platformShift;
- maxCoords.u = (maxCoords.u + platformWidth - 1) >> platformShift;
- maxCoords.v = (maxCoords.v + platformWidth - 1) >> platformShift;
+ maxCoords.u = (maxCoords.u + kPlatformWidth - 1) >> platformShift;
+ maxCoords.v = (maxCoords.v + kPlatformWidth - 1) >> platformShift;
// Now, scan that area for metatiles...
for (u = minCoords.u; u < maxCoords.u; u++) {
diff --git a/engines/saga2/property.cpp b/engines/saga2/property.cpp
index f95ddb2cf0..5f0f48e660 100644
--- a/engines/saga2/property.cpp
+++ b/engines/saga2/property.cpp
@@ -234,7 +234,7 @@ static bool metaTileHasWater(
MetaTile *mt,
int16 mapNum,
const TilePoint &mCoords) {
- TilePoint origin = mCoords << platShift,
+ TilePoint origin = mCoords << kPlatShift,
tCoords;
tCoords.z = 0;
@@ -242,8 +242,8 @@ static bool metaTileHasWater(
Platform *p = mt->fetchPlatform(mapNum, i);
if (p) {
- for (tCoords.u = 0; tCoords.u < platformWidth; tCoords.u++) {
- for (tCoords.v = 0; tCoords.v < platformWidth; tCoords.v++) {
+ for (tCoords.u = 0; tCoords.u < kPlatformWidth; tCoords.u++) {
+ for (tCoords.v = 0; tCoords.v < kPlatformWidth; tCoords.v++) {
TileInfo *ti;
int16 height;
int16 trFlags;
diff --git a/engines/saga2/sensor.cpp b/engines/saga2/sensor.cpp
index 7c194f98b0..b53cd117c5 100644
--- a/engines/saga2/sensor.cpp
+++ b/engines/saga2/sensor.cpp
@@ -662,7 +662,7 @@ bool ObjectSensor::check(SenseInfo &info, uint32 senseFlags) {
CircularObjectIterator iter(
getObject()->world(),
getObject()->getLocation(),
- getRange() != 0 ? getRange() : tileUVSize * platformWidth * 8);
+ getRange() != 0 ? getRange() : tileUVSize * kPlatformWidth * 8);
for (iter.first(&objToTest);
objToTest != NULL;
diff --git a/engines/saga2/spelcast.cpp b/engines/saga2/spelcast.cpp
index dd2c991753..aa7b03bdd6 100644
--- a/engines/saga2/spelcast.cpp
+++ b/engines/saga2/spelcast.cpp
@@ -901,8 +901,8 @@ int16 tileNopeHeight(
// Calculate coordinates of tile, metatile, and subtile
TilePoint tileCoords = pt >> tileUVShift,
- metaCoords = tileCoords >> platShift,
- origin = metaCoords << platShift,
+ metaCoords = tileCoords >> kPlatShift,
+ origin = metaCoords << kPlatShift,
coords = tileCoords - origin,
subTile((pt.u >> subTileShift) & subTileMask,
(pt.v >> subTileShift) & subTileMask,
diff --git a/engines/saga2/target.cpp b/engines/saga2/target.cpp
index 1b685f246f..63142cc028 100644
--- a/engines/saga2/target.cpp
+++ b/engines/saga2/target.cpp
@@ -33,7 +33,7 @@
namespace Saga2 {
-const int metaTileUVSize = tileUVSize * platformWidth;
+const int metaTileUVSize = tileUVSize * kPlatformWidth;
/* ===================================================================== *
Target management functions
diff --git a/engines/saga2/target.h b/engines/saga2/target.h
index d9ad22db7d..15edfc8855 100644
--- a/engines/saga2/target.h
+++ b/engines/saga2/target.h
@@ -31,9 +31,9 @@ namespace Saga2 {
struct StandingTileInfo;
-const int maxObjDist = platformWidth * tileUVSize * 8;
-const int maxTileDist = platformWidth * tileUVSize * 2;
-const int maxMetaDist = platformWidth * tileUVSize * 8;
+const int maxObjDist = kPlatformWidth * tileUVSize * 8;
+const int maxTileDist = kPlatformWidth * tileUVSize * 2;
+const int maxMetaDist = kPlatformWidth * tileUVSize * 8;
enum TargetType {
locationTarget,
diff --git a/engines/saga2/terrain.cpp b/engines/saga2/terrain.cpp
index eb668433d8..df19fded67 100644
--- a/engines/saga2/terrain.cpp
+++ b/engines/saga2/terrain.cpp
@@ -115,8 +115,8 @@ uint32 tileTerrain(
int16 maxZ) {
WorldMapData *map = &mapList[mapNum];
- TilePoint metaCoords = pt >> platShift,
- origin = metaCoords << platShift,
+ TilePoint metaCoords = pt >> kPlatShift,
+ origin = metaCoords << kPlatShift,
coords = pt - origin;
MetaTilePtr metaPtr;
uint32 terrain = 0;
@@ -605,8 +605,8 @@ int16 tileSlopeHeight(
uint8 *platformResult) {
// Calculate coordinates of tile, metatile, and subtile
TilePoint tileCoords = pt >> tileUVShift,
- metaCoords = tileCoords >> platShift,
- origin = metaCoords << platShift,
+ metaCoords = tileCoords >> kPlatShift,
+ origin = metaCoords << kPlatShift,
coords = tileCoords - origin,
subTile((pt.u >> subTileShift) & subTileMask,
(pt.v >> subTileShift) & subTileMask,
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index b0b31ed650..2d4625e9cf 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -2315,8 +2315,8 @@ static void readPlatform(hResContext *con, Platform &plt) {
plt.highestPixel = con->readU16LE();
plt.flags = con->readU16LE();
- for (int j = 0; j < platformWidth; ++j) {
- for (int i = 0; i < platformWidth; ++i) {
+ for (int j = 0; j < kPlatformWidth; ++j) {
+ for (int i = 0; i < kPlatformWidth; ++i) {
plt.tiles[j][i].tile = con->readU16LE();
plt.tiles[j][i].flags = con->readByte();
plt.tiles[j][i].tileHeight = con->readByte();
@@ -2527,7 +2527,7 @@ MetaTile *MetaTileIterator::first(TilePoint *loc) {
mtRes = mapList[mapNum].lookupMeta(mCoords);
}
- if (loc) *loc = mCoords << platShift;
+ if (loc) *loc = mCoords << kPlatShift;
return mtRes;
}
@@ -2539,7 +2539,7 @@ MetaTile *MetaTileIterator::next(TilePoint *loc) {
mtRes = mapList[mapNum].lookupMeta(mCoords);
} while (mtRes == nullptr);
- if (loc) *loc = mCoords << platShift;
+ if (loc) *loc = mCoords << kPlatShift;
return mtRes;
}
@@ -2555,16 +2555,16 @@ bool TileIterator::iterate(void) {
if (platIndex >= maxPlatforms) {
if ((mt = metaIter.next(&origin)) != nullptr) {
tCoordsReg.min.u = tCoordsReg.min.v = 0;
- tCoordsReg.max.u = tCoordsReg.max.v = platformWidth;
+ tCoordsReg.max.u = tCoordsReg.max.v = kPlatformWidth;
if (origin.u < region.min.u)
- tCoordsReg.min.u = region.min.u & platMask;
- if (origin.u + platformWidth > region.max.u)
- tCoordsReg.max.u = region.max.u & platMask;
+ tCoordsReg.min.u = region.min.u & kPlatMask;
+ if (origin.u + kPlatformWidth > region.max.u)
+ tCoordsReg.max.u = region.max.u & kPlatMask;
if (origin.v < region.min.v)
- tCoordsReg.min.v = region.min.v & platMask;
- if (origin.v + platformWidth > region.max.v)
- tCoordsReg.max.v = region.max.v & platMask;
+ tCoordsReg.min.v = region.min.v & kPlatMask;
+ if (origin.v + kPlatformWidth > region.max.v)
+ tCoordsReg.max.v = region.max.v & kPlatMask;
} else
return false;
@@ -2603,16 +2603,16 @@ TileInfo *TileIterator::first(TilePoint *loc, StandingTileInfo *stiResult) {
}
tCoordsReg.min.u = tCoordsReg.min.v = 0;
- tCoordsReg.max.u = tCoordsReg.max.v = platformWidth;
+ tCoordsReg.max.u = tCoordsReg.max.v = kPlatformWidth;
if (origin.u < region.min.u)
- tCoordsReg.min.u = region.min.u & platMask;
- if (origin.u + platformWidth > region.max.u)
- tCoordsReg.max.u = region.max.u & platMask;
+ tCoordsReg.min.u = region.min.u & kPlatMask;
+ if (origin.u + kPlatformWidth > region.max.u)
+ tCoordsReg.max.u = region.max.u & kPlatMask;
if (origin.v < region.min.v)
- tCoordsReg.min.v = region.min.v & platMask;
- if (origin.v + platformWidth > region.max.v)
- tCoordsReg.max.v = region.max.v & platMask;
+ tCoordsReg.min.v = region.min.v & kPlatMask;
+ if (origin.v + kPlatformWidth > region.max.v)
+ tCoordsReg.max.v = region.max.v & kPlatMask;
tCoords = tCoordsReg.min;
tiRes = platform->fetchTAGInstance(
@@ -2663,8 +2663,8 @@ TileInfo *TileIterator::next(TilePoint *loc, StandingTileInfo *stiResult) {
inline void drawMetaRow(TilePoint coords, Point16 pos) {
WorldMapData *curMap = &mapList[currentMapNum];
- int16 uOrg = coords.u * platformWidth,
- vOrg = coords.v * platformWidth;
+ int16 uOrg = coords.u * kPlatformWidth,
+ vOrg = coords.v * kPlatformWidth;
Platform *drawList[maxPlatforms + 1],
**put = drawList;
@@ -2686,8 +2686,8 @@ inline void drawMetaRow(TilePoint coords, Point16 pos) {
pos.x < tileDrawMap.size.x + metaDX;
coords.u++,
coords.v--,
- uOrg += platformWidth,
- vOrg -= platformWidth,
+ uOrg += kPlatformWidth,
+ vOrg -= kPlatformWidth,
pos.x += metaTileWidth
) {
TilePoint clipCoords;
@@ -2747,7 +2747,7 @@ inline void drawMetaRow(TilePoint coords, Point16 pos) {
// REM: precompute this later, by scanning the platform
// for individual altitudes
- p->highestPixel = kTileHeight * (platformWidth - 1) + kMaxTileHeight * 2 + 64;
+ p->highestPixel = kTileHeight * (kPlatformWidth - 1) + kMaxTileHeight * 2 + 64;
if (pos.y <= 0
|| pos.y - p->highestPixel >= tileDrawMap.size.y)
@@ -2791,7 +2791,7 @@ void buildRipTable(
// Determine number of tile positions in meta tile for which to
// calculate object ripping altitude
- int16 tilesToGo = platformWidth * platformWidth;
+ int16 tilesToGo = kPlatformWidth * kPlatformWidth;
for (uint i = 0; i < maxPlatforms; i++) {
Platform *p;
@@ -2807,8 +2807,8 @@ void buildRipTable(
uint16 platHeight = p->height << 3;
int16 u, v;
- for (u = 0; u < platformWidth; u++)
- for (v = 0; v < platformWidth; v++)
+ for (u = 0; u < kPlatformWidth; u++)
+ for (v = 0; v < kPlatformWidth; v++)
if (ripTable->zTable[u][v] == maxint16) {
TileRef &tr = p->getTileRef(u, v);
@@ -2831,7 +2831,7 @@ void buildRipTable(
// the center view object
void buildRipTables(void) {
- const int16 regionRadius = tileUVSize * platformWidth * 2;
+ const int16 regionRadius = tileUVSize * kPlatformWidth * 2;
TilePoint actorCoords;
MetaTile *mt;
@@ -2841,8 +2841,8 @@ void buildRipTables(void) {
int16 mtTableSize = 0;
getViewTrackPos(actorCoords);
- ripTableCoords.u = actorCoords.u >> (tileUVShift + platShift);
- ripTableCoords.v = actorCoords.v >> (tileUVShift + platShift);
+ ripTableCoords.u = actorCoords.u >> (tileUVShift + kPlatShift);
+ ripTableCoords.v = actorCoords.v >> (tileUVShift + kPlatShift);
ripTableCoords.z = 0;
// Calculate the region of meta tile for which to build object
@@ -2950,8 +2950,8 @@ inline void drawMetaTiles(void) {
// coordinates of the view window on the map in X,Y (in 16 pixel units)
viewPos.x = (tileScroll.x >> kTileDXShift)
- - (platformWidth * mapList[currentMapNum].mapSize),
- viewPos.y = (platformWidth
+ - (kPlatformWidth * mapList[currentMapNum].mapSize),
+ viewPos.y = (kPlatformWidth
* mapList[currentMapNum].mapSize
* kTileDX)
- tileScroll.y;
@@ -2961,9 +2961,9 @@ inline void drawMetaTiles(void) {
// coordinates of the view window upper left corner in U,V
baseCoords.u = ((2 * (viewPos.y >> kTileDXShift) + metaDY / 16) + viewPos.x)
- / (platformWidth * 2);
+ / (kPlatformWidth * 2);
baseCoords.v = ((2 * (viewPos.y >> kTileDXShift) + metaDY / 16) - viewPos.x)
- / (platformWidth * 2);
+ / (kPlatformWidth * 2);
baseCoords.z = 0;
debugC(2, kDebugTiles, "baseCoords = (%d,%d,%d)", baseCoords.u, baseCoords.v, baseCoords.z);
@@ -3197,13 +3197,13 @@ void maskPlatform(
TilePoint rLoc;
TilePoint origin(uOrg, vOrg, 0);
- tilePos.y = screenPos.y - (platformWidth - 1) * kTileHeight;
+ tilePos.y = screenPos.y - (kPlatformWidth - 1) * kTileHeight;
- u = platformWidth - 1;
- v = platformWidth - 1;
+ u = kPlatformWidth - 1;
+ v = kPlatformWidth - 1;
- relLoc.u = - relLoc.u - (platformWidth - 1) * tileUVSize;
- relLoc.v = - relLoc.v - (platformWidth - 1) * tileUVSize;
+ relLoc.u = - relLoc.u - (kPlatformWidth - 1) * tileUVSize;
+ relLoc.v = - relLoc.v - (kPlatformWidth - 1) * tileUVSize;
for (int row = 0; row < 15; row++) {
if (tilePos.y > 0) {
@@ -3303,8 +3303,8 @@ void maskMetaRow(
uint16 roofID) {
WorldMapData *curMap = &mapList[currentMapNum];
- int16 uOrg = coords.u * platformWidth,
- vOrg = coords.v * platformWidth;
+ int16 uOrg = coords.u * kPlatformWidth,
+ vOrg = coords.v * kPlatformWidth;
Platform *drawList[maxPlatforms + 1],
**put = drawList;
@@ -3321,10 +3321,10 @@ void maskMetaRow(
pos.x < sMap.size.x + metaDX;
coords.u++,
coords.v--,
- relLoc.u += platUVSize,
- relLoc.v -= platUVSize,
- uOrg += platformWidth,
- vOrg -= platformWidth,
+ relLoc.u += kPlatUVSize,
+ relLoc.v -= kPlatUVSize,
+ uOrg += kPlatformWidth,
+ vOrg -= kPlatformWidth,
pos.x += metaTileWidth
) {
TilePoint clipCoords;
@@ -3382,7 +3382,7 @@ void maskMetaRow(
// REM: precompute this later, by scanning the platform
// for individual altitudes
- p->highestPixel = kTileHeight * (platformWidth - 1) + kMaxTileHeight + 192;
+ p->highestPixel = kTileHeight * (kPlatformWidth - 1) + kMaxTileHeight + 192;
if (pos.y <= 0
|| pos.y - p->highestPixel >= sMap.size.y)
@@ -3418,17 +3418,17 @@ void drawTileMask(
// coordinates of the view window on the map in X,Y (in 16 pixel units)
viewPos.x = (aPos.x >> kTileDXShift)
- - (platformWidth * mapList[currentMapNum].mapSize),
- viewPos.y = (platformWidth
+ - (kPlatformWidth * mapList[currentMapNum].mapSize),
+ viewPos.y = (kPlatformWidth
* mapList[currentMapNum].mapSize << kTileDXShift)
- aPos.y;
// coordinates of the view window upper left corner in U,V
baseCoords.u = ((2 * (viewPos.y >> kTileDXShift) + metaDY / 16) + viewPos.x)
- / (platformWidth * 2);
+ / (kPlatformWidth * 2);
baseCoords.v = ((2 * (viewPos.y >> kTileDXShift) + metaDY / 16) - viewPos.x)
- / (platformWidth * 2);
+ / (kPlatformWidth * 2);
baseCoords.z = 0;
// coordinates of current metatile (in X,Y), relative to screen
@@ -3441,8 +3441,8 @@ void drawTileMask(
// Compute where the object is relative to the metatile coords
- relLoc.u = (baseCoords.u * platUVSize) - loc.u;
- relLoc.v = (baseCoords.v * platUVSize) - loc.v;
+ relLoc.u = (baseCoords.u * kPlatUVSize) - loc.u;
+ relLoc.v = (baseCoords.v * kPlatUVSize) - loc.v;
relLoc.z = loc.z;
// Loop through each horizontal row of metatiles
@@ -3459,7 +3459,7 @@ void drawTileMask(
metaPos.y += metaDY;
metaPos.x -= metaDX;
- relLoc.u -= platUVSize;
+ relLoc.u -= kPlatUVSize;
maskMetaRow(sMap, TilePoint(baseCoords.u - 1, baseCoords.v, 0),
relLoc, metaPos, roofID);
@@ -3467,7 +3467,7 @@ void drawTileMask(
metaPos.y += metaDY;
metaPos.x += metaDX;
- relLoc.v -= platUVSize;
+ relLoc.v -= kPlatUVSize;
}
}
@@ -4041,16 +4041,16 @@ bool pointOnHiddenSurface(
adjSubMask = 0x0008 << (testCoords.u & ~subTileMask);
}
- mCoords = adjTCoords >> platShift;
+ mCoords = adjTCoords >> kPlatShift;
// If metatile of adjacent tile does not exist, the pick point
// is valid.
if ((mt = curMap->lookupMeta(mCoords)) == nullptr) return false;
- tCoords.u = adjTCoords.u & platMask;
- tCoords.v = adjTCoords.v & platMask;
+ tCoords.u = adjTCoords.u & kPlatMask;
+ tCoords.v = adjTCoords.v & kPlatMask;
tCoords.z = 0;
- origin = mCoords << platShift;
+ origin = mCoords << kPlatShift;
int i;
@@ -4174,11 +4174,11 @@ TilePoint pickTile(Point32 pos,
// Compute which metatile the click occured on, and the tile
// within that metatile, and the origin coords of the metatile
- mCoords = tileCoords >> platShift;
- tCoords.u = tileCoords.u & platMask;
- tCoords.v = tileCoords.v & platMask;
+ mCoords = tileCoords >> kPlatShift;
+ tCoords.u = tileCoords.u & kPlatMask;
+ tCoords.v = tileCoords.v & kPlatMask;
tCoords.z = 0;
- origin = mCoords << platShift;
+ origin = mCoords << kPlatShift;
// Lookup the metatile
mt = curMap->lookupMeta(mCoords);
@@ -4278,9 +4278,9 @@ TilePoint pickTile(Point32 pos,
tCoords.u--;
coords.u -= tileUVSize;
if (tCoords.u < 0) {
- tCoords.u = platformWidth - 1;
+ tCoords.u = kPlatformWidth - 1;
mCoords.u--;
- origin = mCoords << platShift;
+ origin = mCoords << kPlatShift;
mt = curMap->lookupMeta(mCoords);
}
relPos.x += kTileDX;
@@ -4288,9 +4288,9 @@ TilePoint pickTile(Point32 pos,
tCoords.v--;
coords.v -= tileUVSize;
if (tCoords.v < 0) {
- tCoords.v = platformWidth - 1;
+ tCoords.v = kPlatformWidth - 1;
mCoords.v--;
- origin = mCoords << platShift;
+ origin = mCoords << kPlatShift;
mt = curMap->lookupMeta(mCoords);
}
relPos.x -= kTileDX;
@@ -4505,10 +4505,10 @@ uint16 objRoofID(GameObject *obj, int16 objMapNum, const TilePoint &objCoords) {
debugC(3, kDebugTiles, "objTileReg = ((%d,%d), (%d,%d))", objTileReg.min.u, objTileReg.min.v, objTileReg.max.u, objTileReg.max.v);
- objMetaReg.min.u = objTileReg.min.u >> platShift;
- objMetaReg.min.v = objTileReg.min.v >> platShift;
- objMetaReg.max.u = (objTileReg.max.u + platMask) >> platShift;
- objMetaReg.max.v = (objTileReg.max.v + platMask) >> platShift;
+ objMetaReg.min.u = objTileReg.min.u >> kPlatShift;
+ objMetaReg.min.v = objTileReg.min.v >> kPlatShift;
+ objMetaReg.max.u = (objTileReg.max.u + kPlatMask) >> kPlatShift;
+ objMetaReg.max.v = (objTileReg.max.v + kPlatMask) >> kPlatShift;
debugC(3, kDebugTiles, "objMetaReg = ((%d,%d), (%d,%d))", objMetaReg.min.u, objMetaReg.min.v, objMetaReg.max.u, objMetaReg.max.v);
@@ -4528,15 +4528,15 @@ uint16 objRoofID(GameObject *obj, int16 objMapNum, const TilePoint &objCoords) {
TileRegion relTileReg;
int16 tileU, tileV;
- origin.u = metaU << platShift;
- origin.v = metaV << platShift;
+ origin.u = metaU << kPlatShift;
+ origin.v = metaV << kPlatShift;
// Compute the tile region relative to the origin of this
// meta tile clipped to this meta tile region
relTileReg.min.u = MAX(objTileReg.min.u - origin.u, 0);
relTileReg.min.v = MAX(objTileReg.min.v - origin.v, 0);
- relTileReg.max.u = MIN(objTileReg.max.u - origin.u, platformWidth);
- relTileReg.max.v = MIN(objTileReg.max.v - origin.v, platformWidth);
+ relTileReg.max.u = MIN(objTileReg.max.u - origin.u, (int)kPlatformWidth);
+ relTileReg.max.v = MIN(objTileReg.max.v - origin.v, (int)kPlatformWidth);
for (tileU = relTileReg.min.u;
tileU < relTileReg.max.u;
@@ -4661,8 +4661,8 @@ void updateMainDisplay(void) {
viewDiff = trackPos - lastViewLoc;
lastViewLoc = trackPos;
- if (abs(viewDiff.u) > 8 * platformWidth * tileUVSize
- || abs(viewDiff.v) > 8 * platformWidth * tileUVSize)
+ if (abs(viewDiff.u) > 8 * kPlatformWidth * tileUVSize
+ || abs(viewDiff.v) > 8 * kPlatformWidth * tileUVSize)
freeAllTileBanks();
// Add current coordinates to map if they have mapping
@@ -4715,8 +4715,8 @@ void updateMainDisplay(void) {
buildRoofTable();
- mCoords.u = trackPos.u >> (tileUVShift + platShift);
- mCoords.v = trackPos.v >> (tileUVShift + platShift);
+ mCoords.u = trackPos.u >> (tileUVShift + kPlatShift);
+ mCoords.v = trackPos.v >> (tileUVShift + kPlatShift);
mCoords.z = 0;
// If trackPos has crossed a metatile boundry, rebuild object
@@ -4908,7 +4908,7 @@ void markMetaAsVisited(const TilePoint &pt) {
WorldMapData *curMap = &mapList[currentMapNum];
uint16 *mapData = curMap->map->mapData;
- TilePoint metaCoords = pt >> (tileUVShift + platShift);
+ TilePoint metaCoords = pt >> (tileUVShift + kPlatShift);
int32 minU = MAX(metaCoords.u - mappingRadius, 0),
maxU = MIN(metaCoords.u + mappingRadius, curMap->mapSize - 1),
minV = MAX(metaCoords.v - mappingRadius, 0),
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index 5eda344d2b..f704f7f378 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -639,7 +639,7 @@ struct Platform {
uint16 height, // height above ground
highestPixel; // tallest tile upper extent
uint16 flags; // platform flags
- TileRef tiles[platformWidth][platformWidth];
+ TileRef tiles[kPlatformWidth][kPlatformWidth];
TileRef &getTileRef(const TilePoint p) {
return tiles[p.u][p.v];
@@ -741,7 +741,7 @@ typedef int16 RipTableID;
struct RipTable {
MetaTileID metaID;
uint16 ripID;
- int16 zTable[platformWidth][platformWidth];
+ int16 zTable[kPlatformWidth][kPlatformWidth];
// Constructor
RipTable(void) : metaID(NoMetaTile) {}
@@ -887,10 +887,10 @@ class MetaTileIterator {
public:
MetaTileIterator(int16 map, const TileRegion ®) : mapNum(map) {
- region.min.u = reg.min.u >> platShift;
- region.max.u = (reg.max.u + platMask) >> platShift;
- region.min.v = reg.min.v >> platShift;
- region.max.v = (reg.max.v + platMask) >> platShift;
+ region.min.u = reg.min.u >> kPlatShift;
+ region.max.u = (reg.max.u + kPlatMask) >> kPlatShift;
+ region.min.v = reg.min.v >> kPlatShift;
+ region.max.v = (reg.max.v + kPlatMask) >> kPlatShift;
region.min.z = region.max.z = 0;
}
diff --git a/engines/saga2/tileload.cpp b/engines/saga2/tileload.cpp
index cee7e9aba3..44e8ad9921 100644
--- a/engines/saga2/tileload.cpp
+++ b/engines/saga2/tileload.cpp
@@ -99,10 +99,10 @@ void drawPlatform(
int16 length = 1;
TilePoint origin(uOrg, vOrg, 0);
- tilePos.y = screenPos.y - (platformWidth - 1) * kTileHeight;
+ tilePos.y = screenPos.y - (kPlatformWidth - 1) * kTileHeight;
- int16 u = platformWidth - 1;
- int16 v = platformWidth - 1;
+ int16 u = kPlatformWidth - 1;
+ int16 v = kPlatformWidth - 1;
debugC(3, kDebugTiles, "drawPlatform: right = %d, bottom = %d, x = %d, x2 = %d, origin = %d,%d, tilePos.y=%d, u,v = %d,%d", right, bottom, x, x2, origin.u, origin.v,
tilePos.y, u, v);
Commit: cd48eeca192cb4dfec67eb66f74b941b707cc62f
https://github.com/scummvm/scummvm/commit/cd48eeca192cb4dfec67eb66f74b941b707cc62f
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:16+02:00
Commit Message:
SAGA2: Rename tile uv-coord constants
Changed paths:
engines/saga2/actor.cpp
engines/saga2/automap.cpp
engines/saga2/beegee.cpp
engines/saga2/dispnode.cpp
engines/saga2/idtypes.h
engines/saga2/mapfeatr.cpp
engines/saga2/motion.cpp
engines/saga2/objects.cpp
engines/saga2/objproto.cpp
engines/saga2/path.cpp
engines/saga2/sagafunc.cpp
engines/saga2/sensor.cpp
engines/saga2/spelcast.cpp
engines/saga2/speldefs.h
engines/saga2/target.cpp
engines/saga2/target.h
engines/saga2/task.cpp
engines/saga2/terrain.cpp
engines/saga2/tile.cpp
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 44535ad2c8..0a4137f9d0 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -1849,7 +1849,7 @@ int16 Actor::offenseScore(void) {
if (weapon != NULL) {
ProtoObj *proto = weapon->proto();
- score += proto->weaponDamage + (proto->maximumRange / tileUVSize);
+ score += proto->weaponDamage + (proto->maximumRange / kTileUVSize);
}
// Add average mana
diff --git a/engines/saga2/automap.cpp b/engines/saga2/automap.cpp
index 3d8f64aa40..0d042a67b0 100644
--- a/engines/saga2/automap.cpp
+++ b/engines/saga2/automap.cpp
@@ -200,7 +200,7 @@ void CAutoMap::locateRegion(void) {
assert(trRes != NULL);
regionCount = *trRes;
- centerCoords = trackPos >> (tileUVShift + kPlatShift);
+ centerCoords = trackPos >> (kTileUVShift + kPlatShift);
localAreaRegion.min.u = localAreaRegion.min.v = 0;
localAreaRegion.max.u = localAreaRegion.max.v = wMap->mapSize;
@@ -498,10 +498,10 @@ void CAutoMap::createSmallMap(void) {
&& centerCoords.v <= viewRegion.max.v) {
// Calculate the position of the cross-hairs showing the position of
// the center actor.
- centerPt = trackPos - (baseCoords << (tileUVShift + kPlatShift));
+ centerPt = trackPos - (baseCoords << (kTileUVShift + kPlatShift));
- x = ((centerPt.u - centerPt.v) >> (tileUVShift + kPlatShift - 2)) + 261 + 4;
- y = 255 + 4 - ((centerPt.u + centerPt.v) >> (tileUVShift + kPlatShift - 1));
+ x = ((centerPt.u - centerPt.v) >> (kTileUVShift + kPlatShift - 2)) + 261 + 4;
+ y = 255 + 4 - ((centerPt.u + centerPt.v) >> (kTileUVShift + kPlatShift - 1));
tPort.setColor(9 + 15); // black
tPort.fillRect(x - 3, y - 1, 7, 3);
diff --git a/engines/saga2/beegee.cpp b/engines/saga2/beegee.cpp
index 4b04346b12..4401ccd2d2 100644
--- a/engines/saga2/beegee.cpp
+++ b/engines/saga2/beegee.cpp
@@ -182,15 +182,15 @@ void setAreaSound(const TilePoint &) {
pct = (pct + 1) % 8;
if (pct == 0) {
if (!playingExternalLoop) {
- TilePoint baseCoords = centerActorCoords() >> tileUVShift;
+ TilePoint baseCoords = centerActorCoords() >> kTileUVShift;
TilePoint mtPos;
metaTileNoise loopID = 0;
soundSegment ss = 0;
Point32 themePos;
for (int r = 1; r < 5 && loopID == 0 ; r++) {
TileRegion regn;
- regn.max = baseCoords + ((AudibilityVector * r) << kPlatShift) ; ///tileUVSize;
- regn.min = baseCoords - ((AudibilityVector * r) << kPlatShift); ///tileUVSize;
+ regn.max = baseCoords + ((AudibilityVector * r) << kPlatShift) ; ///kTileUVSize;
+ regn.min = baseCoords - ((AudibilityVector * r) << kPlatShift); ///kTileUVSize;
MetaTileIterator mIter(currentMapNum, regn);
int i = 0;
int j = 0;
@@ -223,7 +223,7 @@ void setAreaSound(const TilePoint &) {
if (aats[i].active) {
Location loc = getCenterActor()->notGetWorldLocation();
if (aats[i].l.context == Nothing || loc.context == aats[i].l.context) {
- TilePoint tp = (aats[i].l >> tileUVShift) - baseCoords;
+ TilePoint tp = (aats[i].l >> kTileUVShift) - baseCoords;
if (tp.magnitude() < dist.magnitude()) {
dist = tp;
loopID = USEAUXTHEME;
diff --git a/engines/saga2/dispnode.cpp b/engines/saga2/dispnode.cpp
index 81ca081429..70c592c758 100644
--- a/engines/saga2/dispnode.cpp
+++ b/engines/saga2/dispnode.cpp
@@ -381,10 +381,10 @@ void DisplayNode::drawObject(void) {
MetaTile *mt;
RipTable *rt;
- tCoords.u = (objCoords.u >> tileUVShift) & kPlatMask;
- tCoords.v = (objCoords.v >> tileUVShift) & kPlatMask;
- mCoords.u = objCoords.u >> (tileUVShift + kPlatShift);
- mCoords.v = objCoords.v >> (tileUVShift + kPlatShift);
+ tCoords.u = (objCoords.u >> kTileUVShift) & kPlatMask;
+ tCoords.v = (objCoords.v >> kTileUVShift) & kPlatMask;
+ mCoords.u = objCoords.u >> (kTileUVShift + kPlatShift);
+ mCoords.v = objCoords.v >> (kTileUVShift + kPlatShift);
mCoords.z = 0;
// Do not display objects that are on a ripped roof
diff --git a/engines/saga2/idtypes.h b/engines/saga2/idtypes.h
index bad4ba3d7f..83b622bafb 100644
--- a/engines/saga2/idtypes.h
+++ b/engines/saga2/idtypes.h
@@ -281,18 +281,18 @@ enum {
// Size of a tile in ( U, V ) coords
enum {
- tileUVSize = 16,
- tileUVShift = 4,
- tileZSize = 8,
- tileZShift = 3,
- tileUVMask = (tileUVSize - 1)
+ kTileUVSize = 16,
+ kTileUVShift = 4,
+ kTileZSize = 8,
+ kTileZShift = 3,
+ kTileUVMask = (kTileUVSize - 1)
};
// Size of a map sector (4 metatiles x 4 metatiles)
enum {
- sectorSize = tileUVSize * 8 * 4,
- sectorShift = tileUVShift + 3 + 2,
+ sectorSize = kTileUVSize * 8 * 4,
+ sectorShift = kTileUVShift + 3 + 2,
sectorMask = (sectorSize - 1)
};
@@ -301,7 +301,7 @@ enum {
kPlatformWidth = 8,
kPlatMask = kPlatformWidth - 1,
kPlatShift = 3,
- kPlatUVSize = tileUVSize * kPlatformWidth
+ kPlatUVSize = kTileUVSize * kPlatformWidth
};
// Metatile metrics
diff --git a/engines/saga2/mapfeatr.cpp b/engines/saga2/mapfeatr.cpp
index f9c97198e0..db0ffdf2da 100644
--- a/engines/saga2/mapfeatr.cpp
+++ b/engines/saga2/mapfeatr.cpp
@@ -251,8 +251,8 @@ void updateMapFeatures(int16 cWorld) {
for (int i = 0; i < mapFeatureCount; i++) {
if (mapFeatures[i]->getWorld() == cWorld) {
uint16 *mapRow;
- mapRow = &mapData[(mapFeatures[i]->getU() >> (tileUVShift + kPlatShift)) * wMap->mapSize];
- uint16 mtile = mapRow[(mapFeatures[i]->getV() >> (tileUVShift + kPlatShift))];
+ mapRow = &mapData[(mapFeatures[i]->getU() >> (kTileUVShift + kPlatShift)) * wMap->mapSize];
+ uint16 mtile = mapRow[(mapFeatures[i]->getV() >> (kTileUVShift + kPlatShift))];
mapFeatures[i]->expose(mtile & metaTileVisited);
}
}
@@ -327,8 +327,8 @@ void CMapFeature::draw(TileRegion viewRegion,
if (world != inWorld) return;
update();
- //TilePoint centerCoords = featureCoords >> (tileUVShift + kPlatShift);
- TilePoint fCoords = featureCoords >> (tileUVShift + kPlatShift);
+ //TilePoint centerCoords = featureCoords >> (kTileUVShift + kPlatShift);
+ TilePoint fCoords = featureCoords >> (kTileUVShift + kPlatShift);
if (visible &&
fCoords.u >= viewRegion.min.u &&
fCoords.u <= viewRegion.max.u &&
@@ -338,10 +338,10 @@ void CMapFeature::draw(TileRegion viewRegion,
// Calculate the position of the cross-hairs showing the position of
// the center actor.
- centerPt = featureCoords - (baseCoords << (tileUVShift + kPlatShift));
+ centerPt = featureCoords - (baseCoords << (kTileUVShift + kPlatShift));
- x = ((centerPt.u - centerPt.v) >> (tileUVShift + kPlatShift - 2)) + 261 + 4;
- y = 255 + 4 - ((centerPt.u + centerPt.v) >> (tileUVShift + kPlatShift - 1));
+ x = ((centerPt.u - centerPt.v) >> (kTileUVShift + kPlatShift - 2)) + 261 + 4;
+ y = 255 + 4 - ((centerPt.u + centerPt.v) >> (kTileUVShift + kPlatShift - 1));
#ifdef DEBUG_FEATUREPOS
WriteStatusF(12, "draw at (%d,%d)", x, y);
#endif
@@ -368,7 +368,7 @@ bool CMapFeature::hitCheck(TileRegion viewRegion,
int32 x, y;
if (world != inWorld) return false;
- TilePoint fCoords = featureCoords >> (tileUVShift + kPlatShift);
+ TilePoint fCoords = featureCoords >> (kTileUVShift + kPlatShift);
if (visible &&
fCoords.u >= viewRegion.min.u &&
fCoords.u <= viewRegion.max.u &&
@@ -378,10 +378,10 @@ bool CMapFeature::hitCheck(TileRegion viewRegion,
// Calculate the position of the cross-hairs showing the position of
// the center actor.
- centerPt = featureCoords - (baseCoords << (tileUVShift + kPlatShift));
+ centerPt = featureCoords - (baseCoords << (kTileUVShift + kPlatShift));
- x = ((centerPt.u - centerPt.v) >> (tileUVShift + kPlatShift - 2)) + 261 + 4;
- y = 255 + 4 - ((centerPt.u + centerPt.v) >> (tileUVShift + kPlatShift - 1));
+ x = ((centerPt.u - centerPt.v) >> (kTileUVShift + kPlatShift - 2)) + 261 + 4;
+ y = 255 + 4 - ((centerPt.u + centerPt.v) >> (kTileUVShift + kPlatShift - 1));
TilePoint DisplayPoint = TilePoint(x, y, 0);
return isHit(DisplayPoint, comparePoint);
diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp
index 0d6a77cf52..2687a12412 100644
--- a/engines/saga2/motion.cpp
+++ b/engines/saga2/motion.cpp
@@ -1253,7 +1253,7 @@ TilePoint MotionTask::getImmediateTarget(void) {
dir = ((Actor *)object)->currentFacing;
return object->location
- + incDirTable[dir] * tileUVSize;
+ + incDirTable[dir] * kTileUVSize;
}
//-----------------------------------------------------------------------
@@ -1879,8 +1879,8 @@ void MotionTask::castSpell(Actor &a, SkillProto &spell, ActiveItem &target) {
mt->spellObj = &spell;
mt->targetTAG = ⌖
loc = Location(
- target.instance.u << tileUVShift,
- target.instance.v << tileUVShift,
+ target.instance.u << kTileUVShift,
+ target.instance.v << kTileUVShift,
target.instance.h,
a.world()->thisID());
mt->targetLoc = loc; //target;
@@ -3002,12 +3002,12 @@ void MotionTask::upLadderAction(void) {
loc.z += 6;
// Determine the tile region which the actor overlays
- actorTileReg.min.u = (loc.u - crossSection) >> tileUVShift;
- actorTileReg.min.v = (loc.v - crossSection) >> tileUVShift;
+ actorTileReg.min.u = (loc.u - crossSection) >> kTileUVShift;
+ actorTileReg.min.v = (loc.v - crossSection) >> kTileUVShift;
actorTileReg.max.u =
- (loc.u + crossSection + tileUVMask) >> tileUVShift;
+ (loc.u + crossSection + kTileUVMask) >> kTileUVShift;
actorTileReg.max.v =
- (loc.v + crossSection + tileUVMask) >> tileUVShift;
+ (loc.v + crossSection + kTileUVMask) >> kTileUVShift;
actorTileReg.min.z = actorTileReg.max.z = 0;
TileIterator iter(mapNum, actorTileReg);
@@ -3128,12 +3128,12 @@ void MotionTask::downLadderAction(void) {
loc.z -= 6;
- actorTileReg.min.u = (loc.u - crossSection) >> tileUVShift;
- actorTileReg.min.v = (loc.v - crossSection) >> tileUVShift;
+ actorTileReg.min.u = (loc.u - crossSection) >> kTileUVShift;
+ actorTileReg.min.v = (loc.v - crossSection) >> kTileUVShift;
actorTileReg.max.u =
- (loc.u + crossSection + tileUVMask) >> tileUVShift;
+ (loc.u + crossSection + kTileUVMask) >> kTileUVShift;
actorTileReg.max.v =
- (loc.v + crossSection + tileUVMask) >> tileUVShift;
+ (loc.v + crossSection + kTileUVMask) >> kTileUVShift;
actorTileReg.min.z = actorTileReg.max.z = 0;
TileIterator iter(mapNum, actorTileReg);
@@ -3191,7 +3191,7 @@ void MotionTask::downLadderAction(void) {
TilePoint newLoc;
- newLoc = loc - incDirTable[a->currentFacing] * tileUVSize;
+ newLoc = loc - incDirTable[a->currentFacing] * kTileUVSize;
newLoc.z = tileSlopeHeight(newLoc, a);
if (!checkBlocked(a, newLoc))
@@ -3199,7 +3199,7 @@ void MotionTask::downLadderAction(void) {
else {
newLoc = loc
- incDirTable[(a->currentFacing - 2) & 7]
- * tileUVSize;
+ * kTileUVSize;
newLoc.z = tileSlopeHeight(newLoc, a);
if (!checkBlocked(a, newLoc))
@@ -3207,7 +3207,7 @@ void MotionTask::downLadderAction(void) {
else {
newLoc = loc
- incDirTable[(a->currentFacing + 2) & 7]
- * tileUVSize;
+ * kTileUVSize;
newLoc.z = tileSlopeHeight(newLoc, a);
if (!checkBlocked(a, newLoc))
@@ -3215,7 +3215,7 @@ void MotionTask::downLadderAction(void) {
else {
newLoc = loc
- incDirTable[a->currentFacing]
- * tileUVSize;
+ * kTileUVSize;
newLoc.z = tileSlopeHeight(newLoc, a);
a->move(newLoc);
unstickObject(a);
@@ -4351,7 +4351,7 @@ void MotionTask::updatePositions(void) {
targetVector = mt->finalTarget - obj->location;
targetDist = targetVector.quickHDistance();
- if (targetDist > tileUVSize) {
+ if (targetDist > kTileUVSize) {
mt->motionType = mt->prevMotionType;
mt->flags |= reset;
nextMT = mt;
@@ -4428,12 +4428,12 @@ void MotionTask::updatePositions(void) {
ActiveItem *TAG = mt->o.TAI->getGroup();
// Compute in points the region of the TAI
- TAIReg.min.u = mt->o.TAI->instance.u << tileUVShift;
- TAIReg.min.v = mt->o.TAI->instance.v << tileUVShift;
+ TAIReg.min.u = mt->o.TAI->instance.u << kTileUVShift;
+ TAIReg.min.v = mt->o.TAI->instance.v << kTileUVShift;
TAIReg.max.u = TAIReg.min.u
- + (TAG->group.uSize << tileUVShift);
+ + (TAG->group.uSize << kTileUVShift);
TAIReg.max.v = TAIReg.min.v
- + (TAG->group.vSize << tileUVShift);
+ + (TAG->group.vSize << kTileUVShift);
TAIReg.min.z = TAIReg.max.z = 0;
// Find the point on the TAI closest to the actor
@@ -4488,12 +4488,12 @@ void MotionTask::updatePositions(void) {
ActiveItem *TAG = mt->o.TAI->getGroup();
// Compute in points the region of the TAI
- TAIReg.min.u = mt->o.TAI->instance.u << tileUVShift;
- TAIReg.min.v = mt->o.TAI->instance.v << tileUVShift;
+ TAIReg.min.u = mt->o.TAI->instance.u << kTileUVShift;
+ TAIReg.min.v = mt->o.TAI->instance.v << kTileUVShift;
TAIReg.max.u = TAIReg.min.u
- + (TAG->group.uSize << tileUVShift);
+ + (TAG->group.uSize << kTileUVShift);
TAIReg.max.v = TAIReg.min.v
- + (TAG->group.vSize << tileUVShift);
+ + (TAG->group.vSize << kTileUVShift);
TAIReg.min.z = TAIReg.max.z = 0;
// Find the point on the TAI closest to the actor
@@ -4853,10 +4853,10 @@ bool checkLadder(Actor *a, const TilePoint &loc) {
TilePoint tileLoc;
StandingTileInfo sti;
- actorTileReg.min.u = (loc.u - crossSection) >> tileUVShift;
- actorTileReg.min.v = (loc.v - crossSection) >> tileUVShift;
- actorTileReg.max.u = (loc.u + crossSection + tileUVMask) >> tileUVShift;
- actorTileReg.max.v = (loc.v + crossSection + tileUVMask) >> tileUVShift;
+ actorTileReg.min.u = (loc.u - crossSection) >> kTileUVShift;
+ actorTileReg.min.v = (loc.v - crossSection) >> kTileUVShift;
+ actorTileReg.max.u = (loc.u + crossSection + kTileUVMask) >> kTileUVShift;
+ actorTileReg.max.v = (loc.v + crossSection + kTileUVMask) >> kTileUVShift;
actorTileReg.min.z = actorTileReg.max.z = 0;
TileIterator iter(mapNum, actorTileReg);
@@ -4910,33 +4910,33 @@ bool checkLadder(Actor *a, const TilePoint &loc) {
a->currentFacing = 7;
a->move(
TilePoint(
- (tileLoc.u << tileUVShift)
- + tileUVSize
+ (tileLoc.u << kTileUVShift)
+ + kTileUVSize
- crossSection,
- (tileLoc.v << tileUVShift) + tileUVSize / 2,
+ (tileLoc.v << kTileUVShift) + kTileUVSize / 2,
loc.z));
} else if (!(~ladderMask & 0x000F)) {
a->currentFacing = 3;
a->move(
TilePoint(
- (tileLoc.u << tileUVShift) + crossSection,
- (tileLoc.v << tileUVShift) + tileUVSize / 2,
+ (tileLoc.u << kTileUVShift) + crossSection,
+ (tileLoc.v << kTileUVShift) + kTileUVSize / 2,
loc.z));
} else if (!(~ladderMask & 0x8888)) {
a->currentFacing = 1;
a->move(
TilePoint(
- (tileLoc.u << tileUVShift) + tileUVSize / 2,
- (tileLoc.v << tileUVShift)
- + tileUVSize
+ (tileLoc.u << kTileUVShift) + kTileUVSize / 2,
+ (tileLoc.v << kTileUVShift)
+ + kTileUVSize
- crossSection,
loc.z));
} else {
a->currentFacing = 3;
a->move(
TilePoint(
- (tileLoc.u << tileUVShift) + tileUVSize / 2,
- (tileLoc.v << tileUVShift) + crossSection,
+ (tileLoc.u << kTileUVShift) + kTileUVSize / 2,
+ (tileLoc.v << kTileUVShift) + crossSection,
loc.z));
}
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index d6153efe63..055bcd8b39 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -2341,7 +2341,7 @@ GameWorld::GameWorld(int16 map) {
int16 mapSize; // Size of map in MetaTiles
mapSize = tileRes->readU16LE();
- size.u = (mapSize << kPlatShift) << tileUVShift;
+ size.u = (mapSize << kPlatShift) << kTileUVShift;
size.v = size.u;
sectorArraySize = size.u / Saga2::sectorSize;
diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp
index c404db5994..9858af028f 100644
--- a/engines/saga2/objproto.cpp
+++ b/engines/saga2/objproto.cpp
@@ -1038,7 +1038,7 @@ bool InventoryProto::canDropAt(
// enactor, fail
if (enactorPtr->IDParent() != loc.context
|| (loc - enactorPtr->getLocation()).quickHDistance()
- > tileUVSize * kPlatformWidth * 4)
+ > kTileUVSize * kPlatformWidth * 4)
return false;
return true;
@@ -2917,7 +2917,7 @@ void EncounterGeneratorProto::doBackgroundUpdate(GameObject *obj) {
if (actorLoc.context == generatorLoc.context) {
int32 dist,
mtRadius = obj->getHitPoints(),// Radius in metatiles
- ptRadius = mtRadius * tileUVSize * kPlatformWidth,
+ ptRadius = mtRadius * kTileUVSize * kPlatformWidth,
prob = obj->getExtra() * (256 * 256) / 100;
TilePoint diff = (TilePoint)actorLoc - (TilePoint)generatorLoc;
@@ -2956,7 +2956,7 @@ void EncounterGeneratorProto::doBackgroundUpdate(GameObject *obj) {
scf.enactor = a->thisID();
scf.directObject = scf.invokedObject;
scf.indirectObject = Nothing;
- scf.value = dist / tileUVSize;
+ scf.value = dist / kTileUVSize;
// Call the SAGA script, if there is one.
runObjectMethod(obj->thisID(), Method_GameObject_onTrigger, scf);
diff --git a/engines/saga2/path.cpp b/engines/saga2/path.cpp
index fc856ffc8f..22b78550d0 100644
--- a/engines/saga2/path.cpp
+++ b/engines/saga2/path.cpp
@@ -227,18 +227,18 @@ void PathTileRegion::fetchTileSection(const TilePoint &org,
#if VISUAL4
TilePoint pt1, pt2;
- pt1 = pt2 = org << tileUVShift;
+ pt1 = pt2 = org << kTileUVShift;
pt1.z = pt2.z = 0;
- pt2.u += (a.u << tileUVShift);
+ pt2.u += (a.u << kTileUVShift);
TPLine(pt1, pt2);
pt1.u = pt2.u;
- pt1.v += (a.v << tileUVShift);
+ pt1.v += (a.v << kTileUVShift);
TPLine(pt1, pt2);
pt2.v = pt1.v;
- pt2.u -= (a.u << tileUVShift);
+ pt2.u -= (a.u << kTileUVShift);
TPLine(pt1, pt2);
pt1.u = pt2.u;
- pt1.v -= (a.v << tileUVShift);
+ pt1.v -= (a.v << kTileUVShift);
TPLine(pt1, pt2);
#endif
@@ -284,18 +284,18 @@ void PathTileRegion::fetchSubMeta(const TilePoint &subMeta) {
#if VISUAL5
TilePoint pt1, pt2;
- pt1 = pt2 = subMeta << (subMetaShift + tileUVShift);
+ pt1 = pt2 = subMeta << (subMetaShift + kTileUVShift);
pt1.z = pt2.z = 0;
- pt2.u += (subMetaSize << tileUVShift);
+ pt2.u += (subMetaSize << kTileUVShift);
TPLine(pt1, pt2);
pt1.u = pt2.u;
- pt1.v += (subMetaSize << tileUVShift);
+ pt1.v += (subMetaSize << kTileUVShift);
TPLine(pt1, pt2);
pt2.v = pt1.v;
- pt2.u -= (subMetaSize << tileUVShift);
+ pt2.u -= (subMetaSize << kTileUVShift);
TPLine(pt1, pt2);
pt1.u = pt2.u;
- pt1.v -= (subMetaSize << tileUVShift);
+ pt1.v -= (subMetaSize << kTileUVShift);
TPLine(pt1, pt2);
#endif
@@ -746,8 +746,8 @@ void DirMaskGroup::computeMask(uint8 objSection) {
// Calculate the area in subtiles the object occupies. Since U and
// V coordinates will alway equal each other, there is no need to
// calculate both.
- area.min = ((tileUVSize / 2) - objSection) >> subTileShift;
- area.max = ((tileUVSize / 2) + objSection + subTileMask) >> subTileShift;
+ area.min = ((kTileUVSize / 2) - objSection) >> subTileShift;
+ area.max = ((kTileUVSize / 2) + objSection + subTileMask) >> subTileShift;
// Determine if the cross section is wide enough that the diaginal
// masks need to be expanded outward one subtile
@@ -955,7 +955,7 @@ int16 tileSlopeHeight(
PathTileInfo *ptiResult,
uint8 *platformResult) {
// Calculate coordinates of tile and subtile
- TilePoint tileCoords = pt >> tileUVShift,
+ TilePoint tileCoords = pt >> kTileUVShift,
subTile(
(pt.u >> subTileShift) & subTileMask,
(pt.v >> subTileShift) & subTileMask,
@@ -1009,8 +1009,8 @@ int16 tileSlopeHeight(
} else
// calculate height of unraised surface
supportHeight = height +
- ptHeight(TilePoint(pt.u & tileUVMask,
- pt.v & tileUVMask,
+ ptHeight(TilePoint(pt.u & kTileUVMask,
+ pt.v & kTileUVMask,
0),
attrs.cornerHeight);
@@ -1120,10 +1120,10 @@ protected:
static void calcCenterPt(
const TilePoint &baseTileCoords,
const QueueItem &qi) {
- centerPt.u = ((baseTileCoords.u + qi.u) << tileUVShift)
- + tileUVSize / 2;
- centerPt.v = ((baseTileCoords.v + qi.v) << tileUVShift)
- + tileUVSize / 2;
+ centerPt.u = ((baseTileCoords.u + qi.u) << kTileUVShift)
+ + kTileUVSize / 2;
+ centerPt.v = ((baseTileCoords.v + qi.v) << kTileUVShift)
+ + kTileUVSize / 2;
centerPt.z = qi.z;
centerPlatform = qi.platform;
@@ -1444,7 +1444,7 @@ void PathRequest::initialize(void) {
timeLimit = /*flags & run ? ticksPerSecond / 4 :*/ ticksPerSecond;
fetchRadius =
- ((tileUVSize / 2 + pCross) >> tileUVShift) + 1;
+ ((kTileUVSize / 2 + pCross) >> kTileUVShift) + 1;
dirMasks = maskComp->computeMask(pCross);
@@ -1452,12 +1452,12 @@ void PathRequest::initialize(void) {
bestLoc = Nowhere;
// Calculate where search cells will be projected onto map
- baseTileCoords.u = (startingCoords.u >> tileUVShift) - searchCenter;
- baseTileCoords.v = (startingCoords.v >> tileUVShift) - searchCenter;
+ baseTileCoords.u = (startingCoords.u >> kTileUVShift) - searchCenter;
+ baseTileCoords.v = (startingCoords.v >> kTileUVShift) - searchCenter;
baseTileCoords.z = 0;
- baseCoords.u = baseTileCoords.u << tileUVShift;
- baseCoords.v = baseTileCoords.v << tileUVShift;
+ baseCoords.u = baseTileCoords.u << kTileUVShift;
+ baseCoords.v = baseTileCoords.v << kTileUVShift;
baseCoords.z = 0;
// Clear the priority queue
@@ -1487,9 +1487,9 @@ void PathRequest::initialize(void) {
baseCoords,
TilePoint(
baseCoords.u
- + (searchCenter << tileUVShift) * 2,
+ + (searchCenter << kTileUVShift) * 2,
baseCoords.v
- + (searchCenter << tileUVShift) * 2,
+ + (searchCenter << kTileUVShift) * 2,
0));
GameObject *obj;
@@ -1520,13 +1520,13 @@ void PathRequest::initialize(void) {
objRegion->max.z = objLoc.z + objProto->height;
// Compute the tile region which this object overlays
- minTileRegU = MAX(objRegion->min.u >> tileUVShift, 0);
+ minTileRegU = MAX(objRegion->min.u >> kTileUVShift, 0);
maxTileRegU = MIN(
- (objRegion->max.u + tileUVMask) >> tileUVShift,
+ (objRegion->max.u + kTileUVMask) >> kTileUVShift,
searchDiameter);
- minTileRegV = MAX(objRegion->min.v >> tileUVShift, 0);
+ minTileRegV = MAX(objRegion->min.v >> kTileUVShift, 0);
maxTileRegV = MIN(
- (objRegion->max.v + tileUVMask) >> tileUVShift,
+ (objRegion->max.v + kTileUVMask) >> kTileUVShift,
searchDiameter);
for (curTileRegU = minTileRegU;
@@ -1562,12 +1562,12 @@ void PathRequest::initialize(void) {
big_break:
// Compute the actor's tile region
- minTileRegU = (startingCoords.u - pCross) >> tileUVShift;
- minTileRegV = (startingCoords.v - pCross) >> tileUVShift;
- maxTileRegU = (startingCoords.u + pCross + tileUVMask)
- >> tileUVShift;
- maxTileRegV = (startingCoords.v + pCross + tileUVMask)
- >> tileUVShift;
+ minTileRegU = (startingCoords.u - pCross) >> kTileUVShift;
+ minTileRegV = (startingCoords.v - pCross) >> kTileUVShift;
+ maxTileRegU = (startingCoords.u + pCross + kTileUVMask)
+ >> kTileUVShift;
+ maxTileRegV = (startingCoords.v + pCross + kTileUVMask)
+ >> kTileUVShift;
for (curTileRegU = minTileRegU;
curTileRegU < maxTileRegU;
@@ -1583,8 +1583,8 @@ big_break:
cost;
// Quantize this tile position to the tile center
- quantizedCoords.u = (curTileRegU << tileUVShift) + tileUVSize / 2;
- quantizedCoords.v = (curTileRegV << tileUVShift) + tileUVSize / 2;
+ quantizedCoords.u = (curTileRegU << kTileUVShift) + kTileUVSize / 2;
+ quantizedCoords.v = (curTileRegV << kTileUVShift) + kTileUVSize / 2;
quantizedCoords.z = startingCoords.z;
quantizedCoords.z = tileSlopeHeight(
quantizedCoords,
@@ -1650,13 +1650,13 @@ void PathRequest::finish(void) {
if (res <= tempResult) break;
coords.u =
- (bestLoc.u << tileUVShift)
+ (bestLoc.u << kTileUVShift)
+ baseCoords.u
- + tileUVSize / 2;
+ + kTileUVSize / 2;
coords.v =
- (bestLoc.v << tileUVShift)
+ (bestLoc.v << kTileUVShift)
+ baseCoords.v
- + tileUVSize / 2;
+ + kTileUVSize / 2;
coords.z = cell->height;
*--res = coords;
@@ -2080,8 +2080,8 @@ bool PathRequest::timeLimitExceeded(void) {
DestinationPathRequest::DestinationPathRequest(Actor *a, int16 howSmart) :
PathRequest(a, howSmart) {
// Quantize the target destination to the nearest tile center.
- mTask->finalTarget.u = (mTask->finalTarget.u & ~tileUVMask) + tileUVSize / 2;
- mTask->finalTarget.v = (mTask->finalTarget.v & ~tileUVMask) + tileUVSize / 2;
+ mTask->finalTarget.u = (mTask->finalTarget.u & ~kTileUVMask) + kTileUVSize / 2;
+ mTask->finalTarget.v = (mTask->finalTarget.v & ~kTileUVMask) + kTileUVSize / 2;
mTask->finalTarget.z = tileSlopeHeight(
mTask->finalTarget,
a,
@@ -2099,8 +2099,8 @@ void DestinationPathRequest::initialize(void) {
bestDist = maxint16;
// Quantize the target coordinates to the nearest tile center.
- targetCoords.u = (destination.u & ~tileUVMask) + tileUVSize / 2;
- targetCoords.v = (destination.v & ~tileUVMask) + tileUVSize / 2;
+ targetCoords.u = (destination.u & ~kTileUVMask) + kTileUVSize / 2;
+ targetCoords.v = (destination.v & ~kTileUVMask) + kTileUVSize / 2;
targetCoords.z = destination.z;
targetPlatform = destPlatform;
}
@@ -2507,12 +2507,12 @@ TilePoint selectNearbySite(
bestLoc = Nowhere;
// Calculate where search cells will be projected onto map
- baseTileCoords.u = (startingCoords.u >> tileUVShift) - searchCenter;
- baseTileCoords.v = (startingCoords.v >> tileUVShift) - searchCenter;
+ baseTileCoords.u = (startingCoords.u >> kTileUVShift) - searchCenter;
+ baseTileCoords.v = (startingCoords.v >> kTileUVShift) - searchCenter;
baseTileCoords.z = 0;
- baseCoords.u = baseTileCoords.u << tileUVShift;
- baseCoords.v = baseTileCoords.v << tileUVShift;
+ baseCoords.u = baseTileCoords.u << kTileUVShift;
+ baseCoords.v = baseTileCoords.v << kTileUVShift;
baseCoords.z = 0;
// Clear the search array and the queue
@@ -2526,9 +2526,9 @@ TilePoint selectNearbySite(
baseCoords,
TilePoint(
baseCoords.u
- + (searchCenter << tileUVShift) * 2,
+ + (searchCenter << kTileUVShift) * 2,
baseCoords.v
- + (searchCenter << tileUVShift) * 2,
+ + (searchCenter << kTileUVShift) * 2,
0));
GameObject *obj;
@@ -2546,7 +2546,7 @@ TilePoint selectNearbySite(
}
// Calculate which tile actor is standing on.
- objLoc = (objLoc - baseCoords) >> tileUVShift;
+ objLoc = (objLoc - baseCoords) >> kTileUVShift;
// If that tile is in the search area, then mark it.
if (objLoc.u >= 0 && objLoc.u < searchDiameter
@@ -2585,8 +2585,8 @@ TilePoint selectNearbySite(
centerTileCoords.v = qi.v + baseTileCoords.v;
centerTileCoords.z = 0;
- centerPt.u = (centerTileCoords.u << tileUVShift) + tileUVSize / 2;
- centerPt.v = (centerTileCoords.v << tileUVShift) + tileUVSize / 2;
+ centerPt.u = (centerTileCoords.u << kTileUVShift) + kTileUVSize / 2;
+ centerPt.v = (centerTileCoords.v << kTileUVShift) + kTileUVSize / 2;
centerPt.z = qi.z;
// If this is the best cell found so far, and it is not
@@ -2719,8 +2719,8 @@ TilePoint selectNearbySite(
return bestLoc != Nowhere
? TilePoint(
- ((bestLoc.u + baseTileCoords.u) << tileUVShift) + tileUVSize / 2,
- ((bestLoc.v + baseTileCoords.v) << tileUVShift) + tileUVSize / 2,
+ ((bestLoc.u + baseTileCoords.u) << kTileUVShift) + kTileUVSize / 2,
+ ((bestLoc.v + baseTileCoords.v) << kTileUVShift) + kTileUVSize / 2,
bestLoc.z)
: Nowhere;
}
@@ -2811,17 +2811,17 @@ bool checkPath(
StandingTileInfo sti;
- startingTileCoords.u = startingCoords.u >> tileUVShift;
- startingTileCoords.v = startingCoords.v >> tileUVShift;
+ startingTileCoords.u = startingCoords.u >> kTileUVShift;
+ startingTileCoords.v = startingCoords.v >> kTileUVShift;
startingTileCoords.z = 0;
- destTileCoords.u = destCoords.u >> tileUVShift;
- destTileCoords.v = destCoords.v >> tileUVShift;
+ destTileCoords.u = destCoords.u >> kTileUVShift;
+ destTileCoords.v = destCoords.v >> kTileUVShift;
destTileCoords.z = 0;
// Quantize destination coords to nearest tile center
- destCoords.u = (destTileCoords.u << tileUVShift) + tileUVSize / 2;
- destCoords.v = (destTileCoords.v << tileUVShift) + tileUVSize / 2;
+ destCoords.u = (destTileCoords.u << kTileUVShift) + kTileUVSize / 2;
+ destCoords.v = (destTileCoords.v << kTileUVShift) + kTileUVSize / 2;
destCoords.z = tileSlopeHeight(destCoords, mapNum, height);
// Determine if destination is outside the search region
@@ -2841,8 +2841,8 @@ bool checkPath(
baseTileCoords.v = startingTileCoords.v - searchCenter;
baseTileCoords.z = 0;
- baseCoords.u = baseTileCoords.u << tileUVShift;
- baseCoords.v = baseTileCoords.v << tileUVShift;
+ baseCoords.u = baseTileCoords.u << kTileUVShift;
+ baseCoords.v = baseTileCoords.v << kTileUVShift;
baseCoords.z = 0;
// Clear the search array and the queue
@@ -2850,12 +2850,12 @@ bool checkPath(
squeue.clear();
// Push the starting location in the center of the array.
- minTileRegU = (startingCoords.u - tileUVSize / 2) >> tileUVShift;
- minTileRegV = (startingCoords.v - tileUVSize / 2) >> tileUVShift;
- maxTileRegU = (startingCoords.u + tileUVSize / 2 + tileUVMask)
- >> tileUVShift;
- maxTileRegV = (startingCoords.v + tileUVSize / 2 + tileUVMask)
- >> tileUVShift;
+ minTileRegU = (startingCoords.u - kTileUVSize / 2) >> kTileUVShift;
+ minTileRegV = (startingCoords.v - kTileUVSize / 2) >> kTileUVShift;
+ maxTileRegU = (startingCoords.u + kTileUVSize / 2 + kTileUVMask)
+ >> kTileUVShift;
+ maxTileRegV = (startingCoords.v + kTileUVSize / 2 + kTileUVMask)
+ >> kTileUVShift;
for (curTileRegU = minTileRegU;
curTileRegU < maxTileRegU;
@@ -2870,8 +2870,8 @@ bool checkPath(
cost;
// Quantize this tile position to the tile center
- quantizedCoords.u = (curTileRegU << tileUVShift) + tileUVSize / 2;
- quantizedCoords.v = (curTileRegV << tileUVShift) + tileUVSize / 2;
+ quantizedCoords.u = (curTileRegU << kTileUVShift) + kTileUVSize / 2;
+ quantizedCoords.v = (curTileRegV << kTileUVShift) + kTileUVSize / 2;
quantizedCoords.z = startingCoords.z;
quantizedCoords.z = tileSlopeHeight(quantizedCoords, mapNum, height);
@@ -2909,8 +2909,8 @@ bool checkPath(
centerTileCoords.v = qi.v + baseTileCoords.v;
centerTileCoords.z = 0;
- centerPt.u = (centerTileCoords.u << tileUVShift) + tileUVSize / 2;
- centerPt.v = (centerTileCoords.v << tileUVShift) + tileUVSize / 2;
+ centerPt.u = (centerTileCoords.u << kTileUVShift) + kTileUVSize / 2;
+ centerPt.v = (centerTileCoords.v << kTileUVShift) + kTileUVSize / 2;
centerPt.z = qi.z;
centerDistFromDest = (centerPt - destCoords).quickHDistance();
@@ -3012,7 +3012,7 @@ bool checkPath(
spush(TilePoint(qi.u + tDir->u,
qi.v + tDir->v,
testPt.z),
- qi.cost + (deltaDistFromDest + tileUVSize) / 4,
+ qi.cost + (deltaDistFromDest + kTileUVSize) / 4,
dir);
}
}
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index ae9904a6a0..5ac4200fdc 100644
--- a/engines/saga2/sagafunc.cpp
+++ b/engines/saga2/sagafunc.cpp
@@ -3073,8 +3073,8 @@ int16 scriptPlaySoundAt(int16 *args) {
MONOLOG(PlaySoundAt);
char *sID = STRING(args[0]);
args++;
- int16 u = *args++; // << tileUVShift;
- int16 v = *args++; // << tileUVShift;
+ int16 u = *args++; // << kTileUVShift;
+ int16 v = *args++; // << kTileUVShift;
int16 h = *args++;
Location l = Location(TilePoint(u, v, h), Nothing);
int32 soundID;
@@ -3117,8 +3117,8 @@ void PlayLoopAt(char IDstr[], Location l);
int16 scriptPlayLoopAt(int16 *args) {
MONOLOG(PlayLoop);
char *sID = STRING(args[0]);
- int16 u = *args++; // << tileUVShift;
- int16 v = *args++; // << tileUVShift;
+ int16 u = *args++; // << kTileUVShift;
+ int16 v = *args++; // << kTileUVShift;
int16 h = *args++;
Location l = Location(TilePoint(u, v, h), Nothing);
PlayLoopAt(sID, l);
@@ -3383,8 +3383,8 @@ int16 scriptCastSpellAtTile(int16 *args) {
MONOLOG(CastSpellAtTile);
GameObject *caster = GameObject::objectAddress(*args++);
SkillProto *spell = skillProtoFromID(*args++);
- int16 u = *args++; // << tileUVShift;
- int16 v = *args++; // << tileUVShift;
+ int16 u = *args++; // << kTileUVShift;
+ int16 v = *args++; // << kTileUVShift;
int16 h = *args++;
Location l = Location(TilePoint(u, v, h), Nothing);
assert(caster);
diff --git a/engines/saga2/sensor.cpp b/engines/saga2/sensor.cpp
index b53cd117c5..eb48c194a8 100644
--- a/engines/saga2/sensor.cpp
+++ b/engines/saga2/sensor.cpp
@@ -662,7 +662,7 @@ bool ObjectSensor::check(SenseInfo &info, uint32 senseFlags) {
CircularObjectIterator iter(
getObject()->world(),
getObject()->getLocation(),
- getRange() != 0 ? getRange() : tileUVSize * kPlatformWidth * 8);
+ getRange() != 0 ? getRange() : kTileUVSize * kPlatformWidth * 8);
for (iter.first(&objToTest);
objToTest != NULL;
diff --git a/engines/saga2/spelcast.cpp b/engines/saga2/spelcast.cpp
index aa7b03bdd6..9bc77d441a 100644
--- a/engines/saga2/spelcast.cpp
+++ b/engines/saga2/spelcast.cpp
@@ -900,7 +900,7 @@ int16 tileNopeHeight(
int16 mapNum = obj->getMapNum();
// Calculate coordinates of tile, metatile, and subtile
- TilePoint tileCoords = pt >> tileUVShift,
+ TilePoint tileCoords = pt >> kTileUVShift,
metaCoords = tileCoords >> kPlatShift,
origin = metaCoords << kPlatShift,
coords = tileCoords - origin,
@@ -966,8 +966,8 @@ int16 tileNopeHeight(
else
// calculate height of unraised surface
supportHeight = sti.surfaceHeight +
- ptHeight(TilePoint(pt.u & tileUVMask,
- pt.v & tileUVMask,
+ ptHeight(TilePoint(pt.u & kTileUVMask,
+ pt.v & kTileUVMask,
0),
ti->attrs.cornerHeight);
diff --git a/engines/saga2/speldefs.h b/engines/saga2/speldefs.h
index ae691728d7..08c64a9cb0 100644
--- a/engines/saga2/speldefs.h
+++ b/engines/saga2/speldefs.h
@@ -117,8 +117,8 @@ inline TilePoint TAGPos(ActiveItem *ai) {
if (ai == NULL) return Nowhere;
assert(ai->itemType == activeTypeInstance);
return TilePoint(
- ai->instance.u << tileUVShift,
- ai->instance.v << tileUVShift,
+ ai->instance.u << kTileUVShift,
+ ai->instance.v << kTileUVShift,
ai->instance.h);
}
diff --git a/engines/saga2/target.cpp b/engines/saga2/target.cpp
index 63142cc028..350bac647a 100644
--- a/engines/saga2/target.cpp
+++ b/engines/saga2/target.cpp
@@ -33,7 +33,7 @@
namespace Saga2 {
-const int metaTileUVSize = tileUVSize * kPlatformWidth;
+const int metaTileUVSize = kTileUVSize * kPlatformWidth;
/* ===================================================================== *
Target management functions
@@ -248,12 +248,12 @@ TilePoint TileTarget::where(GameWorld *world, const TilePoint &tp) const {
StandingTileInfo sti;
// Compute the tile region to search
- tileReg.min.u = (tp.u - maxTileDist) >> tileUVShift;
- tileReg.max.u = (tp.u + maxTileDist - 1 + tileUVMask)
- >> tileUVShift;
- tileReg.min.v = (tp.v - maxTileDist) >> tileUVShift;
- tileReg.max.v = (tp.v + maxTileDist - 1 + tileUVMask)
- >> tileUVShift;
+ tileReg.min.u = (tp.u - maxTileDist) >> kTileUVShift;
+ tileReg.max.u = (tp.u + maxTileDist - 1 + kTileUVMask)
+ >> kTileUVShift;
+ tileReg.min.v = (tp.v - maxTileDist) >> kTileUVShift;
+ tileReg.max.v = (tp.v + maxTileDist - 1 + kTileUVMask)
+ >> kTileUVShift;
TileIterator tIter(world->mapNum, tileReg);
@@ -264,18 +264,18 @@ TilePoint TileTarget::where(GameWorld *world, const TilePoint &tp) const {
if (isTarget(sti)) {
uint16 dist;
- tileCoords.u <<= tileUVShift;
- tileCoords.v <<= tileUVShift;
+ tileCoords.u <<= kTileUVShift;
+ tileCoords.v <<= kTileUVShift;
// Compute point on tile closest to center location
tileCoords.u = clamp(
tileCoords.u,
tp.u,
- tileCoords.u + tileUVSize - 1);
+ tileCoords.u + kTileUVSize - 1);
tileCoords.v = clamp(
tileCoords.v,
tp.v,
- tileCoords.v + tileUVSize - 1);
+ tileCoords.v + kTileUVSize - 1);
tileCoords.z = sti.surfaceHeight;
dist = (tileCoords - tp).quickHDistance();
@@ -303,12 +303,12 @@ int16 TileTarget::where(
StandingTileInfo sti;
// Compute the tile region to search
- tileReg.min.u = (tp.u - maxTileDist) >> tileUVShift;
- tileReg.max.u = (tp.u + maxTileDist - 1 + tileUVMask)
- >> tileUVShift;
- tileReg.min.v = (tp.v - maxTileDist) >> tileUVShift;
- tileReg.max.v = (tp.v + maxTileDist - 1 + tileUVMask)
- >> tileUVShift;
+ tileReg.min.u = (tp.u - maxTileDist) >> kTileUVShift;
+ tileReg.max.u = (tp.u + maxTileDist - 1 + kTileUVMask)
+ >> kTileUVShift;
+ tileReg.min.v = (tp.v - maxTileDist) >> kTileUVShift;
+ tileReg.max.v = (tp.v + maxTileDist - 1 + kTileUVMask)
+ >> kTileUVShift;
TileIterator tIter(world->mapNum, tileReg);
@@ -320,18 +320,18 @@ int16 TileTarget::where(
if (isTarget(sti)) {
uint16 dist;
- tileCoords.u <<= tileUVShift;
- tileCoords.v <<= tileUVShift;
+ tileCoords.u <<= kTileUVShift;
+ tileCoords.v <<= kTileUVShift;
// Compute point on tile closest to center location
tileCoords.u = clamp(
tileCoords.u,
tp.u,
- tileCoords.u + tileUVSize - 1);
+ tileCoords.u + kTileUVSize - 1);
tileCoords.v = clamp(
tileCoords.v,
tp.v,
- tileCoords.v + tileUVSize - 1);
+ tileCoords.v + kTileUVSize - 1);
tileCoords.z = sti.surfaceHeight;
dist = (tileCoords - tp).quickHDistance();
@@ -500,12 +500,12 @@ TilePoint MetaTileTarget::where(
TileRegion tileReg;
// Determine the tile region to search
- tileReg.min.u = (tp.u - maxMetaDist) >> tileUVShift;
- tileReg.max.u = (tp.u + maxMetaDist + tileUVMask)
- >> tileUVShift;
- tileReg.min.v = (tp.v - maxMetaDist) >> tileUVShift;
- tileReg.max.v = (tp.v + maxMetaDist + tileUVMask)
- >> tileUVShift;
+ tileReg.min.u = (tp.u - maxMetaDist) >> kTileUVShift;
+ tileReg.max.u = (tp.u + maxMetaDist + kTileUVMask)
+ >> kTileUVShift;
+ tileReg.min.v = (tp.v - maxMetaDist) >> kTileUVShift;
+ tileReg.max.v = (tp.v + maxMetaDist + kTileUVMask)
+ >> kTileUVShift;
MetaTileIterator mIter(world->mapNum, tileReg);
@@ -515,8 +515,8 @@ TilePoint MetaTileTarget::where(
if (isTarget(mt, world->mapNum, metaCoords)) {
uint16 dist;
- metaCoords.u <<= tileUVShift;
- metaCoords.v <<= tileUVShift;
+ metaCoords.u <<= kTileUVShift;
+ metaCoords.v <<= kTileUVShift;
// Determine point on metatile closest to center point
metaCoords.u = clamp(
@@ -554,12 +554,12 @@ int16 MetaTileTarget::where(
TileRegion tileReg;
// Compute the tile region to search
- tileReg.min.u = (tp.u - maxMetaDist) >> tileUVShift;
- tileReg.max.u = (tp.u + maxMetaDist + tileUVMask)
- >> tileUVShift;
- tileReg.min.v = (tp.v - maxMetaDist) >> tileUVShift;
- tileReg.max.v = (tp.v + maxMetaDist + tileUVMask)
- >> tileUVShift;
+ tileReg.min.u = (tp.u - maxMetaDist) >> kTileUVShift;
+ tileReg.max.u = (tp.u + maxMetaDist + kTileUVMask)
+ >> kTileUVShift;
+ tileReg.min.v = (tp.v - maxMetaDist) >> kTileUVShift;
+ tileReg.max.v = (tp.v + maxMetaDist + kTileUVMask)
+ >> kTileUVShift;
MetaTileIterator mIter(world->mapNum, tileReg);
@@ -569,8 +569,8 @@ int16 MetaTileTarget::where(
if (isTarget(mt, world->mapNum, metaCoords)) {
uint16 dist;
- metaCoords.u <<= tileUVShift;
- metaCoords.v <<= tileUVShift;
+ metaCoords.u <<= kTileUVShift;
+ metaCoords.v <<= kTileUVShift;
metaCoords.z = tp.z;
diff --git a/engines/saga2/target.h b/engines/saga2/target.h
index 15edfc8855..c443a314d0 100644
--- a/engines/saga2/target.h
+++ b/engines/saga2/target.h
@@ -31,9 +31,9 @@ namespace Saga2 {
struct StandingTileInfo;
-const int maxObjDist = kPlatformWidth * tileUVSize * 8;
-const int maxTileDist = kPlatformWidth * tileUVSize * 2;
-const int maxMetaDist = kPlatformWidth * tileUVSize * 8;
+const int maxObjDist = kPlatformWidth * kTileUVSize * 8;
+const int maxTileDist = kPlatformWidth * kTileUVSize * 2;
+const int maxMetaDist = kPlatformWidth * kTileUVSize * 8;
enum TargetType {
locationTarget,
diff --git a/engines/saga2/task.cpp b/engines/saga2/task.cpp
index 2ca1346b68..0d5141b328 100644
--- a/engines/saga2/task.cpp
+++ b/engines/saga2/task.cpp
@@ -1657,20 +1657,20 @@ TaskResult GotoTask::update(void) {
bool runState = run();
TilePoint motionTarget = actorMotion->getTarget();
- if ((actorLoc.u >> tileUVShift)
- == (immediateDest.u >> tileUVShift)
- && (actorLoc.v >> tileUVShift)
- == (immediateDest.v >> tileUVShift)) {
+ if ((actorLoc.u >> kTileUVShift)
+ == (immediateDest.u >> kTileUVShift)
+ && (actorLoc.v >> kTileUVShift)
+ == (immediateDest.v >> kTileUVShift)) {
if (motionTarget != immediateDest
|| runState != prevRunState)
actorMotion->changeDirectTarget(
immediateDest,
prevRunState = runState);
} else {
- if ((motionTarget.u >> tileUVShift)
- != (immediateDest.u >> tileUVShift)
- || (motionTarget.v >> tileUVShift)
- != (immediateDest.v >> tileUVShift)
+ if ((motionTarget.u >> kTileUVShift)
+ != (immediateDest.u >> kTileUVShift)
+ || (motionTarget.v >> kTileUVShift)
+ != (immediateDest.v >> kTileUVShift)
|| abs(motionTarget.z - immediateDest.z) > 16
|| runState != prevRunState)
actorMotion->changeTarget(
@@ -1678,10 +1678,10 @@ TaskResult GotoTask::update(void) {
prevRunState = runState);
}
} else {
- if ((actorLoc.u >> tileUVShift)
- == (immediateDest.u >> tileUVShift)
- && (actorLoc.v >> tileUVShift)
- == (immediateDest.v >> tileUVShift)) {
+ if ((actorLoc.u >> kTileUVShift)
+ == (immediateDest.u >> kTileUVShift)
+ && (actorLoc.v >> kTileUVShift)
+ == (immediateDest.v >> kTileUVShift)) {
MotionTask::walkToDirect(
*a,
immediateDest,
@@ -2201,7 +2201,7 @@ bool GotoActorTask::run(void) {
TilePoint actorLoc = stack->getActor()->getLocation(),
targetLoc = getTarget()->getLocation();
- return (actorLoc - targetLoc).quickHDistance() >= tileUVSize * 4;
+ return (actorLoc - targetLoc).quickHDistance() >= kTileUVSize * 4;
} else
return lastKnownLoc != Nowhere;
}
@@ -4410,7 +4410,7 @@ TaskResult BandTask::atTargetUpdate(void) {
//----------------------------------------------------------------------
int16 BandTask::getRunThreshold(void) {
- return tileUVSize * 3;
+ return kTileUVSize * 3;
}
//----------------------------------------------------------------------
@@ -4695,10 +4695,10 @@ TaskResult FollowPatrolRouteTask::handleFollowPatrolRoute(void) {
if (currentWayPoint == Nowhere) return taskSucceeded;
// Determine if the actor has reached the waypoint tile position
- if ((actorLoc.u >> tileUVShift)
- == (currentWayPoint.u >> tileUVShift)
- && (actorLoc.v >> tileUVShift)
- == (currentWayPoint.v >> tileUVShift)
+ if ((actorLoc.u >> kTileUVShift)
+ == (currentWayPoint.u >> kTileUVShift)
+ && (actorLoc.v >> kTileUVShift)
+ == (currentWayPoint.v >> kTileUVShift)
&& abs(actorLoc.z - currentWayPoint.z) <= maxStepHeight) {
// Delete the gotoWayPoint task
if (gotoWayPoint != NULL) {
diff --git a/engines/saga2/terrain.cpp b/engines/saga2/terrain.cpp
index df19fded67..4a68b25dc9 100644
--- a/engines/saga2/terrain.cpp
+++ b/engines/saga2/terrain.cpp
@@ -604,7 +604,7 @@ int16 tileSlopeHeight(
StandingTileInfo *stiResult,
uint8 *platformResult) {
// Calculate coordinates of tile, metatile, and subtile
- TilePoint tileCoords = pt >> tileUVShift,
+ TilePoint tileCoords = pt >> kTileUVShift,
metaCoords = tileCoords >> kPlatShift,
origin = metaCoords << kPlatShift,
coords = tileCoords - origin,
@@ -672,8 +672,8 @@ int16 tileSlopeHeight(
} else
// calculate height of unraised surface
supportHeight = sti.surfaceHeight +
- ptHeight(TilePoint(pt.u & tileUVMask,
- pt.v & tileUVMask,
+ ptHeight(TilePoint(pt.u & kTileUVMask,
+ pt.v & kTileUVMask,
0),
ti->attrs.cornerHeight);
@@ -866,8 +866,8 @@ int16 checkWalkable(
subTileV,
mask;
- subTileU = (loc.u & tileUVMask) >> subTileShift;
- subTileV = (loc.v & tileUVMask) >> subTileShift;
+ subTileU = (loc.u & kTileUVMask) >> subTileShift;
+ subTileV = (loc.v & kTileUVMask) >> subTileShift;
mask = 1 << ((subTileU << subTileShift) + subTileV);
// If the suporting subtile is funiture consider this blocked
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 2d4625e9cf..e7e6e64f6c 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -374,9 +374,9 @@ ObjectID ActiveItem::getInstanceContext(void) {
// Return the Location for a TAG
Location ActiveItem::getInstanceLocation(void) {
- return Location(instance.u << tileUVShift,
- instance.v << tileUVShift,
- instance.h << tileZShift,
+ return Location(instance.u << kTileUVShift,
+ instance.v << kTileUVShift,
+ instance.h << kTileZShift,
getInstanceContext());
}
@@ -486,7 +486,7 @@ void ActiveItem::playTAGNoise(ActiveItem *ai, int16 tagNoiseID) {
bool ActiveItem::use(ActiveItem *ins, ObjectID enactor) {
Actor *actor = (Actor *)GameObject::objectAddress(enactor);
- TilePoint actorLoc = actor->getLocation() >> tileUVShift;
+ TilePoint actorLoc = actor->getLocation() >> kTileUVShift;
int16 mapNum = getMapNum();
uint16 state = ins->getInstanceState(mapNum);
scriptCallFrame scf;
@@ -580,12 +580,12 @@ bool ActiveItem::trigger(ActiveItem *ins, ObjectID enactor, ObjectID objID) {
// Mark the object as triggering this TAG
obj->setTriggeringTAG(true);
- instanceRegion.min.u = ins->instance.u << tileUVShift;
- instanceRegion.min.v = ins->instance.v << tileUVShift;
+ instanceRegion.min.u = ins->instance.u << kTileUVShift;
+ instanceRegion.min.v = ins->instance.v << kTileUVShift;
instanceRegion.max.u = instanceRegion.min.u
- + (group.uSize << tileUVShift);
+ + (group.uSize << kTileUVShift);
instanceRegion.max.v = instanceRegion.min.v
- + (group.vSize << tileUVShift);
+ + (group.vSize << kTileUVShift);
RegionalObjectIterator iter(
world,
@@ -638,10 +638,10 @@ bool ActiveItem::trigger(ActiveItem *ins, ObjectID enactor, ObjectID objID) {
if (isActor(obj) && (a = (Actor *)obj) == getCenterActor()) {
transportCenterBand(
Location(
- (ins->instance.targetU << tileUVShift)
- + tileUVSize / 2,
- (ins->instance.targetV << tileUVShift)
- + tileUVSize / 2,
+ (ins->instance.targetU << kTileUVShift)
+ + kTileUVSize / 2,
+ (ins->instance.targetV << kTileUVShift)
+ + kTileUVSize / 2,
(int16)ins->instance.targetZ << 3,
ins->instance.worldNum + WorldBaseID));
}
@@ -668,12 +668,12 @@ bool ActiveItem::release(ActiveItem *ins, ObjectID enactor, ObjectID objID) {
if (obj->isTriggeringTAG()) obj->setTriggeringTAG(false);
- instanceRegion.min.u = ins->instance.u << tileUVShift;
- instanceRegion.min.v = ins->instance.v << tileUVShift;
+ instanceRegion.min.u = ins->instance.u << kTileUVShift;
+ instanceRegion.min.v = ins->instance.v << kTileUVShift;
instanceRegion.max.u = instanceRegion.min.u
- + (group.uSize << tileUVShift);
+ + (group.uSize << kTileUVShift);
instanceRegion.max.v = instanceRegion.min.v
- + (group.vSize << tileUVShift);
+ + (group.vSize << kTileUVShift);
RegionalObjectIterator iter(
world,
@@ -723,7 +723,7 @@ bool ActiveItem::release(ActiveItem *ins, ObjectID enactor, ObjectID objID) {
bool ActiveItem::acceptLockToggle(ActiveItem *ins, ObjectID enactor, uint8 keyCode) {
TilePoint actorLoc =
GameObject::objectAddress(enactor)->getLocation() >>
- tileUVShift;
+ kTileUVShift;
scriptCallFrame scf;
if (ins->scriptClassID != 0) {
@@ -781,12 +781,12 @@ TilePoint getClosestPointOnTAI(ActiveItem *TAI, GameObject *obj) {
ActiveItem *TAG = TAI->getGroup();
// Compute in points the region of the TAI
- TAIReg.min.u = TAI->instance.u << tileUVShift;
- TAIReg.min.v = TAI->instance.v << tileUVShift;
+ TAIReg.min.u = TAI->instance.u << kTileUVShift;
+ TAIReg.min.v = TAI->instance.v << kTileUVShift;
TAIReg.max.u = TAIReg.min.u
- + (TAG->group.uSize << tileUVShift);
+ + (TAG->group.uSize << kTileUVShift);
TAIReg.max.v = TAIReg.min.v
- + (TAG->group.vSize << tileUVShift);
+ + (TAG->group.vSize << kTileUVShift);
TAIReg.min.z = TAIReg.max.z = 0;
// Find the point on the TAI closest to the object
@@ -1934,14 +1934,14 @@ int16 ptHeight(const TilePoint &tp, uint8 *cornerHeight) {
return slopeHeight;
slopeHeight
- = (cornerHeight[0] * (tileUVSize - tp.u)
+ = (cornerHeight[0] * (kTileUVSize - tp.u)
+ cornerHeight[1] * tp.u)
- * (tileUVSize - tp.v)
- + (cornerHeight[3] * (tileUVSize - tp.u)
+ * (kTileUVSize - tp.v)
+ + (cornerHeight[3] * (kTileUVSize - tp.u)
+ cornerHeight[2] * tp.u)
* tp.v;
- return slopeHeight >> (tileUVShift + tileUVShift);
+ return slopeHeight >> (kTileUVShift + kTileUVShift);
}
/* ====================================================================== *
@@ -2831,7 +2831,7 @@ void buildRipTable(
// the center view object
void buildRipTables(void) {
- const int16 regionRadius = tileUVSize * kPlatformWidth * 2;
+ const int16 regionRadius = kTileUVSize * kPlatformWidth * 2;
TilePoint actorCoords;
MetaTile *mt;
@@ -2841,18 +2841,18 @@ void buildRipTables(void) {
int16 mtTableSize = 0;
getViewTrackPos(actorCoords);
- ripTableCoords.u = actorCoords.u >> (tileUVShift + kPlatShift);
- ripTableCoords.v = actorCoords.v >> (tileUVShift + kPlatShift);
+ ripTableCoords.u = actorCoords.u >> (kTileUVShift + kPlatShift);
+ ripTableCoords.v = actorCoords.v >> (kTileUVShift + kPlatShift);
ripTableCoords.z = 0;
// Calculate the region of meta tile for which to build object
// ripping table
- ripTableReg.min.u = (actorCoords.u - regionRadius) >> tileUVShift;
- ripTableReg.min.v = (actorCoords.v - regionRadius) >> tileUVShift;
+ ripTableReg.min.u = (actorCoords.u - regionRadius) >> kTileUVShift;
+ ripTableReg.min.v = (actorCoords.v - regionRadius) >> kTileUVShift;
ripTableReg.max.u =
- (actorCoords.u + regionRadius + tileUVMask) >> tileUVShift;
+ (actorCoords.u + regionRadius + kTileUVMask) >> kTileUVShift;
ripTableReg.max.v =
- (actorCoords.v + regionRadius + tileUVMask) >> tileUVShift;
+ (actorCoords.v + regionRadius + kTileUVMask) >> kTileUVShift;
MetaTileIterator mIter(currentMapNum, ripTableReg);
@@ -3093,8 +3093,8 @@ enum maskRules {
};
const int thresh1 = 0,
- thresh2 = tileUVSize / 4,
- thresh3 = tileUVSize - 1;
+ thresh2 = kTileUVSize / 4,
+ thresh3 = kTileUVSize - 1;
// l is the relative position of the character with repect
// to the tile in U,V coords.
@@ -3202,8 +3202,8 @@ void maskPlatform(
u = kPlatformWidth - 1;
v = kPlatformWidth - 1;
- relLoc.u = - relLoc.u - (kPlatformWidth - 1) * tileUVSize;
- relLoc.v = - relLoc.v - (kPlatformWidth - 1) * tileUVSize;
+ relLoc.u = - relLoc.u - (kPlatformWidth - 1) * kTileUVSize;
+ relLoc.v = - relLoc.v - (kPlatformWidth - 1) * kTileUVSize;
for (int row = 0; row < 15; row++) {
if (tilePos.y > 0) {
@@ -3218,8 +3218,8 @@ void maskPlatform(
pCoords.u += offset;
pCoords.v -= offset;
- rLoc.u -= offset * tileUVSize;
- rLoc.v += offset * tileUVSize;
+ rLoc.u -= offset * kTileUVSize;
+ rLoc.v += offset * kTileUVSize;
offset <<= 1;
col += offset;
tilePos.x += kTileDX * offset;
@@ -3230,14 +3230,14 @@ void maskPlatform(
col += 2,
pCoords.u++,
pCoords.v--,
- rLoc.u -= tileUVSize,
- rLoc.v += tileUVSize,
+ rLoc.u -= kTileUVSize,
+ rLoc.v += kTileUVSize,
tilePos.x += kTileWidth
) {
Platform **pGet;
if (tilePos.x < 0) continue;
- if (rLoc.u <= -tileUVSize || rLoc.v <= -tileUVSize)
+ if (rLoc.u <= -kTileUVSize || rLoc.v <= -kTileUVSize)
continue;
for (pGet = pList; *pGet; pGet++) {
@@ -3282,13 +3282,13 @@ void maskPlatform(
x2++;
length += 2;
u--;
- relLoc.u += tileUVSize;
+ relLoc.u += kTileUVSize;
} else {
x += kTileDX;
x2--;
length -= 2;
v--;
- relLoc.v += tileUVSize;
+ relLoc.v += kTileUVSize;
}
tilePos.y += kTileDY;
@@ -3676,7 +3676,7 @@ SurfaceType pointOnTile(TileInfo *ti,
subUVPoint.u < 16 &&
subUVPoint.v < 16) {
if (subUVPointRel < pointH + (subTileDY * 2) / subTileSize) {
- pickCoords = (tCoords << tileUVShift);
+ pickCoords = (tCoords << kTileUVShift);
pickCoords.u += subUVPoint.u;
pickCoords.v += subUVPoint.v;
pickCoords.z = h + pointH;
@@ -3740,7 +3740,7 @@ SurfaceType pointOnTile(TileInfo *ti,
// mouse is on side of raised section
if (subTileRel.y <
ti->attrs.terrainHeight + yBound) {
- pickCoords = (tCoords << tileUVShift);
+ pickCoords = (tCoords << kTileUVShift);
pickCoords.u += (subTile.u << subTileShift);
pickCoords.v += (subTile.v << subTileShift);
if (subTileRel.x > 1) {
@@ -3793,8 +3793,8 @@ SurfaceType pointOnTile(TileInfo *ti,
floorCoords.z = h;
else
floorCoords.z = h +
- ptHeight(TilePoint(floorCoords.u & tileUVMask,
- floorCoords.v & tileUVMask,
+ ptHeight(TilePoint(floorCoords.u & kTileUVMask,
+ floorCoords.v & kTileUVMask,
0),
ti->attrs.cornerHeight);
break;
@@ -3802,7 +3802,7 @@ SurfaceType pointOnTile(TileInfo *ti,
// mouse is on top of raised section
if (subTileRel.y <
ti->attrs.terrainHeight + subTileDY * 2 - yBound) {
- pickCoords = (tCoords << tileUVShift);
+ pickCoords = (tCoords << kTileUVShift);
y = subTileRel.y - ti->attrs.terrainHeight;
pickCoords.u += (subTile.u << subTileShift) +
(((subTileRel.x >> 1) + y) >> 1);
@@ -3836,7 +3836,7 @@ SurfaceType pointOnTile(TileInfo *ti,
subUVPoint.u < 4 &&
subUVPoint.v < 4) {
if (subUVPointRel < pointH + (subTileDY * 2) / subTileSize) {
- pickCoords = (tCoords << tileUVShift);
+ pickCoords = (tCoords << kTileUVShift);
pickCoords.u += (subTile.u << subTileShift) + subUVPoint.u;
pickCoords.v += (subTile.v << subTileShift) + subUVPoint.v;
pickCoords.z = h + pointH;
@@ -4017,8 +4017,8 @@ bool pointOnHiddenSurface(
// Determine pick point relative to base of tile
testCoords = pickCoords;
- testCoords.u &= tileUVMask;
- testCoords.v &= tileUVMask;
+ testCoords.u &= kTileUVMask;
+ testCoords.v &= kTileUVMask;
// If picked point is not along edge of tile, then its not hidden
if ((surfaceType == surfaceVertV && testCoords.u != 0)
@@ -4154,8 +4154,8 @@ TilePoint pickTile(Point32 pos,
coords.z = 0;
// Compute the coords of the middle of the current tile.
- coords.u = (coords.u & ~tileUVMask) + tileUVSize / 2;
- coords.v = (coords.v & ~tileUVMask) + tileUVSize / 2;
+ coords.u = (coords.u & ~kTileUVMask) + kTileUVSize / 2;
+ coords.v = (coords.v & ~kTileUVMask) + kTileUVSize / 2;
// Since the protagonist has a limited ability to "step" up or
// down levels, only search for surfaces which could be stepped
@@ -4165,7 +4165,7 @@ TilePoint pickTile(Point32 pos,
zMax = protagPos.z + maxPickHeight + mag;
// Compute the coords of the actual tile that they clicked on.
- tileCoords = coords >> tileUVShift;
+ tileCoords = coords >> kTileUVShift;
// Compute the X and Y offset of the exact mouse click point
// relative to the base of the tile.
@@ -4276,7 +4276,7 @@ TilePoint pickTile(Point32 pos,
// Crabwalk down through the tile positions
if (relPos.x < 0) {
tCoords.u--;
- coords.u -= tileUVSize;
+ coords.u -= kTileUVSize;
if (tCoords.u < 0) {
tCoords.u = kPlatformWidth - 1;
mCoords.u--;
@@ -4286,7 +4286,7 @@ TilePoint pickTile(Point32 pos,
relPos.x += kTileDX;
} else {
tCoords.v--;
- coords.v -= tileUVSize;
+ coords.v -= kTileUVSize;
if (tCoords.v < 0) {
tCoords.v = kPlatformWidth - 1;
mCoords.v--;
@@ -4313,8 +4313,8 @@ TilePoint pickTile(Point32 pos,
#ifdef DAVIDR
if (showTile) {
if (bestTile) {
- bestTP.u <<= tileUVShift;
- bestTP.v <<= tileUVShift;
+ bestTP.u <<= kTileUVShift;
+ bestTP.v <<= kTileUVShift;
showAbstractTile(bestTP, bestTile);
TilePoint pt1, pt2;
@@ -4498,10 +4498,10 @@ uint16 objRoofID(GameObject *obj, int16 objMapNum, const TilePoint &objCoords) {
objHeight = objCoords.z;
- objTileReg.min.u = (objCoords.u - subTileSize) >> tileUVShift;
- objTileReg.min.v = (objCoords.v - subTileSize) >> tileUVShift;
- objTileReg.max.u = (objCoords.u + subTileSize + tileUVMask) >> tileUVShift;
- objTileReg.max.v = (objCoords.v + subTileSize + tileUVMask) >> tileUVShift;
+ objTileReg.min.u = (objCoords.u - subTileSize) >> kTileUVShift;
+ objTileReg.min.v = (objCoords.v - subTileSize) >> kTileUVShift;
+ objTileReg.max.u = (objCoords.u + subTileSize + kTileUVMask) >> kTileUVShift;
+ objTileReg.max.v = (objCoords.v + subTileSize + kTileUVMask) >> kTileUVShift;
debugC(3, kDebugTiles, "objTileReg = ((%d,%d), (%d,%d))", objTileReg.min.u, objTileReg.min.v, objTileReg.max.u, objTileReg.max.v);
@@ -4661,8 +4661,8 @@ void updateMainDisplay(void) {
viewDiff = trackPos - lastViewLoc;
lastViewLoc = trackPos;
- if (abs(viewDiff.u) > 8 * kPlatformWidth * tileUVSize
- || abs(viewDiff.v) > 8 * kPlatformWidth * tileUVSize)
+ if (abs(viewDiff.u) > 8 * kPlatformWidth * kTileUVSize
+ || abs(viewDiff.v) > 8 * kPlatformWidth * kTileUVSize)
freeAllTileBanks();
// Add current coordinates to map if they have mapping
@@ -4715,8 +4715,8 @@ void updateMainDisplay(void) {
buildRoofTable();
- mCoords.u = trackPos.u >> (tileUVShift + kPlatShift);
- mCoords.v = trackPos.v >> (tileUVShift + kPlatShift);
+ mCoords.u = trackPos.u >> (kTileUVShift + kPlatShift);
+ mCoords.v = trackPos.v >> (kTileUVShift + kPlatShift);
mCoords.z = 0;
// If trackPos has crossed a metatile boundry, rebuild object
@@ -4908,7 +4908,7 @@ void markMetaAsVisited(const TilePoint &pt) {
WorldMapData *curMap = &mapList[currentMapNum];
uint16 *mapData = curMap->map->mapData;
- TilePoint metaCoords = pt >> (tileUVShift + kPlatShift);
+ TilePoint metaCoords = pt >> (kTileUVShift + kPlatShift);
int32 minU = MAX(metaCoords.u - mappingRadius, 0),
maxU = MIN(metaCoords.u + mappingRadius, curMap->mapSize - 1),
minV = MAX(metaCoords.v - mappingRadius, 0),
@@ -4959,7 +4959,7 @@ uint16 lineDist(
const TilePoint &p1,
const TilePoint &p2,
const TilePoint &m) {
- const int16 lineDistSlop = tileUVSize * 4;
+ const int16 lineDistSlop = kTileUVSize * 4;
const int16 lineFar = maxint16;
int16 u = m.u,
Commit: 6dad132e83ef71d891b54fadefc22126ac4bf945
https://github.com/scummvm/scummvm/commit/6dad132e83ef71d891b54fadefc22126ac4bf945
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:16+02:00
Commit Message:
SAGA2: Rename map sector constants
Changed paths:
engines/saga2/actor.h
engines/saga2/idtypes.h
engines/saga2/objects.cpp
engines/saga2/objects.h
engines/saga2/objproto.cpp
engines/saga2/tile.cpp
diff --git a/engines/saga2/actor.h b/engines/saga2/actor.h
index 7f9ab1af81..c293b17042 100644
--- a/engines/saga2/actor.h
+++ b/engines/saga2/actor.h
@@ -36,7 +36,7 @@ class Band;
class MotionTask;
class TaskStack;
-const int bandingDist = sectorSize * 2;
+const int bandingDist = kSectorSize * 2;
const int actorScriptVars = 4;
/* ===================================================================== *
diff --git a/engines/saga2/idtypes.h b/engines/saga2/idtypes.h
index 83b622bafb..15697516f8 100644
--- a/engines/saga2/idtypes.h
+++ b/engines/saga2/idtypes.h
@@ -291,9 +291,9 @@ enum {
// Size of a map sector (4 metatiles x 4 metatiles)
enum {
- sectorSize = kTileUVSize * 8 * 4,
- sectorShift = kTileUVShift + 3 + 2,
- sectorMask = (sectorSize - 1)
+ kSectorSize = kTileUVSize * 8 * 4,
+ kSectorShift = kTileUVShift + 3 + 2,
+ kSectorMask = (kSectorSize - 1)
};
// Plaftorm metrics
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 055bcd8b39..036def1240 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -377,8 +377,8 @@ ObjectID *GameObject::getHeadPtr(ObjectID parentID, TilePoint &l) {
GameWorld *world = (GameWorld *)parentObj;
TilePoint sectors = world->sectorSize();
- int16 u = clamp(0, l.u / sectorSize, sectors.u - 1),
- v = clamp(0, l.v / sectorSize, sectors.v - 1);
+ int16 u = clamp(0, l.u / kSectorSize, sectors.u - 1),
+ v = clamp(0, l.v / kSectorSize, sectors.v - 1);
return &(world->sectorArray)[
v * world->sectorArraySize + u].childID;
@@ -756,10 +756,10 @@ void GameObject::setLocation(const Location &l) {
GameWorld *world = (GameWorld *)objectAddress(l.context);
TilePoint sectors = world->sectorSize();
- int16 u0 = clamp(0, location.u / sectorSize, sectors.u - 1),
- v0 = clamp(0, location.v / sectorSize, sectors.v - 1),
- u1 = clamp(0, l.u / sectorSize, sectors.u - 1),
- v1 = clamp(0, l.v / sectorSize, sectors.v - 1);
+ int16 u0 = clamp(0, location.u / kSectorSize, sectors.u - 1),
+ v0 = clamp(0, location.v / kSectorSize, sectors.v - 1),
+ u1 = clamp(0, l.u / kSectorSize, sectors.u - 1),
+ v1 = clamp(0, l.v / kSectorSize, sectors.v - 1);
if (u0 != u1 || v0 != v1) { // If sector changed
remove(); // Remove from old list
@@ -780,10 +780,10 @@ void GameObject::setLocation(const TilePoint &tp) {
GameWorld *world = (GameWorld *)objectAddress(parentID);
TilePoint sectors = world->sectorSize();
- int16 u0 = clamp(0, location.u / sectorSize, sectors.u - 1),
- v0 = clamp(0, location.v / sectorSize, sectors.v - 1),
- u1 = clamp(0, tp.u / sectorSize, sectors.u - 1),
- v1 = clamp(0, tp.v / sectorSize, sectors.v - 1);
+ int16 u0 = clamp(0, location.u / kSectorSize, sectors.u - 1),
+ v0 = clamp(0, location.v / kSectorSize, sectors.v - 1),
+ u1 = clamp(0, tp.u / kSectorSize, sectors.u - 1),
+ v1 = clamp(0, tp.v / kSectorSize, sectors.v - 1);
if (u0 != u1 || v0 != v1) { // If sector changed
ObjectID saveParent = parentID;
@@ -966,8 +966,8 @@ void GameObject::updateImage(ObjectID oldParentID) {
}
}
- if (w->getSector(location.u >> sectorShift,
- location.v >> sectorShift)->isActivated()) {
+ if (w->getSector(location.u >> kSectorShift,
+ location.v >> kSectorShift)->isActivated()) {
activate();
}
} else {
@@ -2344,7 +2344,7 @@ GameWorld::GameWorld(int16 map) {
size.u = (mapSize << kPlatShift) << kTileUVShift;
size.v = size.u;
- sectorArraySize = size.u / Saga2::sectorSize;
+ sectorArraySize = size.u / kSectorSize;
sectorArray = new Sector[sectorArraySize * sectorArraySize]();
if (sectorArray == nullptr)
@@ -2372,7 +2372,7 @@ GameWorld::GameWorld(void **buf) {
if (size.u != 0) {
int32 sectorArrayBytes;
- sectorArraySize = size.u / Saga2::sectorSize;
+ sectorArraySize = size.u / kSectorSize;
sectorArrayBytes =
sectorArraySize * sectorArraySize * sizeof(Sector),
sectorArray = new Sector[sectorArrayBytes]();
@@ -3263,16 +3263,16 @@ void ActiveRegion::update(void) {
anchorLoc = loc;
// Determine the active region in points
- ptRegion.min.u = loc.u - sectorSize / 2;
- ptRegion.min.v = loc.v - sectorSize / 2;
- ptRegion.max.u = ptRegion.min.u + sectorSize;
- ptRegion.max.v = ptRegion.min.v + sectorSize;
+ ptRegion.min.u = loc.u - kSectorSize / 2;
+ ptRegion.min.v = loc.v - kSectorSize / 2;
+ ptRegion.max.u = ptRegion.min.u + kSectorSize;
+ ptRegion.max.v = ptRegion.min.v + kSectorSize;
// Convert to sector coordinates
- newRegion.min.u = ptRegion.min.u >> sectorShift;
- newRegion.min.v = ptRegion.min.v >> sectorShift;
- newRegion.max.u = (ptRegion.max.u + sectorMask) >> sectorShift;
- newRegion.max.v = (ptRegion.max.v + sectorMask) >> sectorShift;
+ newRegion.min.u = ptRegion.min.u >> kSectorShift;
+ newRegion.min.v = ptRegion.min.v >> kSectorShift;
+ newRegion.max.u = (ptRegion.max.u + kSectorMask) >> kSectorShift;
+ newRegion.max.v = (ptRegion.max.v + kSectorMask) >> kSectorShift;
if (region.min.u != newRegion.min.u
|| region.min.v != newRegion.min.v
@@ -3483,19 +3483,19 @@ TileRegion RadialObjectIterator::computeSectorRegion(
sectorRegion.min.u = clamp(
0,
- (center.u - radius) >> sectorShift,
+ (center.u - radius) >> kSectorShift,
sectors.u);
sectorRegion.min.v = clamp(
0,
- (center.v - radius) >> sectorShift,
+ (center.v - radius) >> kSectorShift,
sectors.v);
sectorRegion.max.u = clamp(
0,
- (center.u + radius + sectorMask) >> sectorShift,
+ (center.u + radius + kSectorMask) >> kSectorShift,
sectors.u);
sectorRegion.max.v = clamp(
0,
- (center.v + radius + sectorMask) >> sectorShift,
+ (center.v + radius + kSectorMask) >> kSectorShift,
sectors.v);
sectorRegion.min.z = sectorRegion.max.z = 0;
@@ -3617,19 +3617,19 @@ TileRegion RegionalObjectIterator::computeSectorRegion(
sectorRegion.min.u = clamp(
0,
- min.u >> sectorShift,
+ min.u >> kSectorShift,
sectors.u);
sectorRegion.min.v = clamp(
0,
- min.v >> sectorShift,
+ min.v >> kSectorShift,
sectors.v);
sectorRegion.max.u = clamp(
0,
- (max.u + sectorMask) >> sectorShift,
+ (max.u + kSectorMask) >> kSectorShift,
sectors.u);
sectorRegion.max.v = clamp(
0,
- (max.v + sectorMask) >> sectorShift,
+ (max.v + kSectorMask) >> kSectorShift,
sectors.v);
sectorRegion.min.z = sectorRegion.max.z = 0;
diff --git a/engines/saga2/objects.h b/engines/saga2/objects.h
index 9c1bb6d881..62c736baf6 100644
--- a/engines/saga2/objects.h
+++ b/engines/saga2/objects.h
@@ -842,10 +842,10 @@ public:
TileRegion getRegion(void) {
TileRegion tReg;
- tReg.min.u = region.min.u << sectorShift;
- tReg.min.v = region.min.v << sectorShift;
- tReg.max.u = region.max.u << sectorShift;
- tReg.max.v = region.max.v << sectorShift;
+ tReg.min.u = region.min.u << kSectorShift;
+ tReg.min.v = region.min.v << kSectorShift;
+ tReg.max.u = region.max.u << kSectorShift;
+ tReg.max.v = region.max.v << kSectorShift;
tReg.min.z = tReg.max.z = 0;
return tReg;
diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp
index 9858af028f..ce07faf522 100644
--- a/engines/saga2/objproto.cpp
+++ b/engines/saga2/objproto.cpp
@@ -978,8 +978,8 @@ void ProtoObj::doBackgroundUpdate(GameObject *obj) {
if (w == NULL
|| !w->getSector(
- location.u >> sectorShift,
- location.v >> sectorShift)->isActivated())
+ location.u >> kSectorShift,
+ location.v >> kSectorShift)->isActivated())
obj->deactivate();
}
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index e7e6e64f6c..508e50d6b5 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -4647,7 +4647,7 @@ void updateMainDisplay(void) {
scrollDistance;
int16 viewSize = tileRect.height;
- int16 mapSectors = curMap->mapSize * 8 * 16 / sectorSize;
+ int16 mapSectors = curMap->mapSize * 8 * 16 / kSectorSize;
TilePoint trackPos,
mCoords;
@@ -4708,10 +4708,10 @@ void updateMainDisplay(void) {
// Compute the largest U/V rectangle which completely
// encloses the view area, and convert to sector coords.
- minSector.u = clamp(0, (viewCenter.u - viewSize) / sectorSize, mapSectors - 1);
- minSector.v = clamp(0, (viewCenter.v - viewSize) / sectorSize, mapSectors - 1);
- maxSector.u = clamp(0, (viewCenter.u + viewSize) / sectorSize, mapSectors - 1);
- maxSector.v = clamp(0, (viewCenter.v + viewSize) / sectorSize, mapSectors - 1);
+ minSector.u = clamp(0, (viewCenter.u - viewSize) / kSectorSize, mapSectors - 1);
+ minSector.v = clamp(0, (viewCenter.v - viewSize) / kSectorSize, mapSectors - 1);
+ maxSector.u = clamp(0, (viewCenter.u + viewSize) / kSectorSize, mapSectors - 1);
+ maxSector.v = clamp(0, (viewCenter.v + viewSize) / kSectorSize, mapSectors - 1);
buildRoofTable();
Commit: 500a6ba4687da186fb6e5edebb8410c50281baea
https://github.com/scummvm/scummvm/commit/500a6ba4687da186fb6e5edebb8410c50281baea
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:16+02:00
Commit Message:
SAGA2: Rename metatile metric constants
Changed paths:
engines/saga2/idtypes.h
engines/saga2/motion.cpp
engines/saga2/objects.cpp
engines/saga2/path.cpp
engines/saga2/spelcast.cpp
engines/saga2/terrain.cpp
engines/saga2/tile.cpp
diff --git a/engines/saga2/idtypes.h b/engines/saga2/idtypes.h
index 15697516f8..c14b4c1344 100644
--- a/engines/saga2/idtypes.h
+++ b/engines/saga2/idtypes.h
@@ -306,32 +306,32 @@ enum {
// Metatile metrics
enum {
- metaTileWidth = kTileWidth * kPlatformWidth,
- metaTileHeight = kTileHeight * kPlatformWidth,
- metaDX = metaTileWidth / 2,
- metaDY = metaTileHeight / 2
+ kMetaTileWidth = kTileWidth * kPlatformWidth,
+ kMetaTileHeight = kTileHeight * kPlatformWidth,
+ kMetaDX = kMetaTileWidth / 2,
+ kMetaDY = kMetaTileHeight / 2
};
enum {
- subTileSize = 4,
- subTileMask = subTileSize - 1,
- subTileShift = 2,
- tileSubSize = 4,
- tileSubMask = tileSubSize - 1,
- tileSubShift = 2
+ kSubTileSize = 4,
+ kSubTileMask = kSubTileSize - 1,
+ kSubTileShift = 2,
+ kTileSubSize = 4,
+ kTileSubMask = kTileSubSize - 1,
+ kTileSubShift = 2
};
// Constants to convert an X,Y into subtile coordinates
enum {
- subTileDX = (kTileDX / 4),
- subTileDY = (kTileDY / 4),
- subTileDXShift = (kTileDXShift - 2),
- subTileDYShift = (kTileDYShift - 2)
+ kSubTileDX = (kTileDX / 4),
+ kSubTileDY = (kTileDY / 4),
+ kSubTileDXShift = (kTileDXShift - 2),
+ kSubTileDYShift = (kTileDYShift - 2)
};
enum {
- subTileMaskUShift = 4,
- subTileMaskVShift = 1
+ kSubTileMaskUShift = 4,
+ kSubTileMaskVShift = 1
};
// Maximum height that a character can climb w/o steps or ladders
diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp
index 2687a12412..53c02e5d5d 100644
--- a/engines/saga2/motion.cpp
+++ b/engines/saga2/motion.cpp
@@ -3028,17 +3028,17 @@ void MotionTask::upLadderAction(void) {
uint16 footPrintMask = 0xFFFF,
ladderMask;
TilePoint subTileLoc(
- tileLoc.u << tileSubShift,
- tileLoc.v << tileSubShift,
+ tileLoc.u << kTileSubShift,
+ tileLoc.v << kTileSubShift,
0);
TileRegion actorSubTileReg;
- actorSubTileReg.min.u = (loc.u - crossSection) >> subTileShift;
- actorSubTileReg.min.v = (loc.v - crossSection) >> subTileShift;
+ actorSubTileReg.min.u = (loc.u - crossSection) >> kSubTileShift;
+ actorSubTileReg.min.v = (loc.v - crossSection) >> kSubTileShift;
actorSubTileReg.max.u =
- (loc.u + crossSection + subTileMask) >> subTileShift;
+ (loc.u + crossSection + kSubTileMask) >> kSubTileShift;
actorSubTileReg.max.v =
- (loc.v + crossSection + subTileMask) >> subTileShift;
+ (loc.v + crossSection + kSubTileMask) >> kSubTileShift;
if (actorSubTileReg.min.u >= subTileLoc.u)
footPrintMask &=
@@ -3048,11 +3048,11 @@ void MotionTask::upLadderAction(void) {
footPrintMask &=
vMinMasks[actorSubTileReg.min.v - subTileLoc.v];
- if (actorSubTileReg.max.u < subTileLoc.u + tileSubSize)
+ if (actorSubTileReg.max.u < subTileLoc.u + kTileSubSize)
footPrintMask &=
uMaxMasks[actorSubTileReg.max.u - subTileLoc.u];
- if (actorSubTileReg.max.v < subTileLoc.v + tileSubSize)
+ if (actorSubTileReg.max.v < subTileLoc.v + kTileSubSize)
footPrintMask &=
vMaxMasks[actorSubTileReg.max.v - subTileLoc.v];
@@ -3150,17 +3150,17 @@ void MotionTask::downLadderAction(void) {
uint16 footPrintMask = 0xFFFF,
ladderMask;
TilePoint subTileLoc(
- tileLoc.u << tileSubShift,
- tileLoc.v << tileSubShift,
+ tileLoc.u << kTileSubShift,
+ tileLoc.v << kTileSubShift,
0);
TileRegion actorSubTileReg;
- actorSubTileReg.min.u = (loc.u - crossSection) >> subTileShift;
- actorSubTileReg.min.v = (loc.v - crossSection) >> subTileShift;
+ actorSubTileReg.min.u = (loc.u - crossSection) >> kSubTileShift;
+ actorSubTileReg.min.v = (loc.v - crossSection) >> kSubTileShift;
actorSubTileReg.max.u =
- (loc.u + crossSection + subTileMask) >> subTileShift;
+ (loc.u + crossSection + kSubTileMask) >> kSubTileShift;
actorSubTileReg.max.v =
- (loc.v + crossSection + subTileMask) >> subTileShift;
+ (loc.v + crossSection + kSubTileMask) >> kSubTileShift;
if (actorSubTileReg.min.u >= subTileLoc.u)
footPrintMask &=
@@ -3170,11 +3170,11 @@ void MotionTask::downLadderAction(void) {
footPrintMask &=
vMinMasks[actorSubTileReg.min.v - subTileLoc.v];
- if (actorSubTileReg.max.u < subTileLoc.u + tileSubSize)
+ if (actorSubTileReg.max.u < subTileLoc.u + kTileSubSize)
footPrintMask &=
uMaxMasks[actorSubTileReg.max.u - subTileLoc.u];
- if (actorSubTileReg.max.v < subTileLoc.v + tileSubSize)
+ if (actorSubTileReg.max.v < subTileLoc.v + kTileSubSize)
footPrintMask &=
vMaxMasks[actorSubTileReg.max.v - subTileLoc.v];
@@ -4873,17 +4873,17 @@ bool checkLadder(Actor *a, const TilePoint &loc) {
uint16 footPrintMask = 0xFFFF,
ladderMask;
TilePoint subTileLoc(
- tileLoc.u << tileSubShift,
- tileLoc.v << tileSubShift,
+ tileLoc.u << kTileSubShift,
+ tileLoc.v << kTileSubShift,
0);
TileRegion actorSubTileReg;
- actorSubTileReg.min.u = (loc.u - crossSection) >> subTileShift;
- actorSubTileReg.min.v = (loc.v - crossSection) >> subTileShift;
+ actorSubTileReg.min.u = (loc.u - crossSection) >> kSubTileShift;
+ actorSubTileReg.min.v = (loc.v - crossSection) >> kSubTileShift;
actorSubTileReg.max.u =
- (loc.u + crossSection + subTileMask) >> subTileShift;
+ (loc.u + crossSection + kSubTileMask) >> kSubTileShift;
actorSubTileReg.max.v =
- (loc.v + crossSection + subTileMask) >> subTileShift;
+ (loc.v + crossSection + kSubTileMask) >> kSubTileShift;
if (actorSubTileReg.min.u >= subTileLoc.u)
footPrintMask &=
@@ -4893,11 +4893,11 @@ bool checkLadder(Actor *a, const TilePoint &loc) {
footPrintMask &=
vMinMasks[actorSubTileReg.min.v - subTileLoc.v];
- if (actorSubTileReg.max.u < subTileLoc.u + tileSubSize)
+ if (actorSubTileReg.max.u < subTileLoc.u + kTileSubSize)
footPrintMask &=
uMaxMasks[actorSubTileReg.max.u - subTileLoc.u];
- if (actorSubTileReg.max.v < subTileLoc.v + tileSubSize)
+ if (actorSubTileReg.max.v < subTileLoc.v + kTileSubSize)
footPrintMask &=
vMaxMasks[actorSubTileReg.max.v - subTileLoc.v];
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 036def1240..ee190210ef 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -1415,8 +1415,8 @@ void GameObject::updateState(void) {
if (!(location.z >= 0 || prototype->height > 8 - location.z))
drown(this);
- TilePoint subTile((location.u >> subTileShift) & subTileMask,
- (location.v >> subTileShift) & subTileMask,
+ TilePoint subTile((location.u >> kSubTileShift) & kSubTileMask,
+ (location.v >> kSubTileShift) & kSubTileMask,
0);
diff --git a/engines/saga2/path.cpp b/engines/saga2/path.cpp
index 22b78550d0..1388d769bf 100644
--- a/engines/saga2/path.cpp
+++ b/engines/saga2/path.cpp
@@ -746,8 +746,8 @@ void DirMaskGroup::computeMask(uint8 objSection) {
// Calculate the area in subtiles the object occupies. Since U and
// V coordinates will alway equal each other, there is no need to
// calculate both.
- area.min = ((kTileUVSize / 2) - objSection) >> subTileShift;
- area.max = ((kTileUVSize / 2) + objSection + subTileMask) >> subTileShift;
+ area.min = ((kTileUVSize / 2) - objSection) >> kSubTileShift;
+ area.max = ((kTileUVSize / 2) + objSection + kSubTileMask) >> kSubTileShift;
// Determine if the cross section is wide enough that the diaginal
// masks need to be expanded outward one subtile
@@ -793,16 +793,16 @@ void DirMaskGroup::computeMask(uint8 objSection) {
ptMaskArea.min = baseMaskArea.min + tDirTable2[dir] * (ptNum + 1);
ptMaskArea.max = baseMaskArea.max + tDirTable2[dir] * (ptNum + 1);
- ptMask->offset.u = ptMaskArea.min.u >> tileSubShift;
- ptMask->offset.v = ptMaskArea.min.v >> tileSubShift;
+ ptMask->offset.u = ptMaskArea.min.u >> kTileSubShift;
+ ptMask->offset.v = ptMaskArea.min.v >> kTileSubShift;
- ptMaskArea.max.u -= ptMaskArea.min.u & ~subTileMask;
- ptMaskArea.min.u &= subTileMask;
- ptMaskArea.max.v -= ptMaskArea.min.v & ~subTileMask;
- ptMaskArea.min.v &= subTileMask;
+ ptMaskArea.max.u -= ptMaskArea.min.u & ~kSubTileMask;
+ ptMaskArea.min.u &= kSubTileMask;
+ ptMaskArea.max.v -= ptMaskArea.min.v & ~kSubTileMask;
+ ptMaskArea.min.v &= kSubTileMask;
- ptMask->size.u = (ptMaskArea.max.u + tileSubMask) >> tileSubShift;
- ptMask->size.v = (ptMaskArea.max.v + tileSubMask) >> tileSubShift;
+ ptMask->size.u = (ptMaskArea.max.u + kTileSubMask) >> kTileSubShift;
+ ptMask->size.v = (ptMaskArea.max.v + kTileSubMask) >> kTileSubShift;
memset(tempMask, 0, sizeof(tempMask));
@@ -957,8 +957,8 @@ int16 tileSlopeHeight(
// Calculate coordinates of tile and subtile
TilePoint tileCoords = pt >> kTileUVShift,
subTile(
- (pt.u >> subTileShift) & subTileMask,
- (pt.v >> subTileShift) & subTileMask,
+ (pt.u >> kSubTileShift) & kSubTileMask,
+ (pt.v >> kSubTileShift) & kSubTileMask,
0);
PathTileInfo highestTile,
@@ -2667,7 +2667,7 @@ TilePoint selectNearbySite(
// If it's too high to step, then don't continue
// if (testPt.z - qi.z > maxStepHeight) continue;
fromSubPt = centerPt;
- for (i = 0; i < tileSubSize; i++) {
+ for (i = 0; i < kTileSubSize; i++) {
int16 deltaZ;
// Next sub tile
@@ -2961,7 +2961,7 @@ bool checkPath(
testPt.z = tileSlopeHeight(testPt, mapNum, height, &sti);
fromSubPt = centerPt;
- for (i = 0; i < tileSubSize; i++) {
+ for (i = 0; i < kTileSubSize; i++) {
int16 deltaZ;
// Next sub tile
diff --git a/engines/saga2/spelcast.cpp b/engines/saga2/spelcast.cpp
index 9bc77d441a..a7da521749 100644
--- a/engines/saga2/spelcast.cpp
+++ b/engines/saga2/spelcast.cpp
@@ -904,8 +904,8 @@ int16 tileNopeHeight(
metaCoords = tileCoords >> kPlatShift,
origin = metaCoords << kPlatShift,
coords = tileCoords - origin,
- subTile((pt.u >> subTileShift) & subTileMask,
- (pt.v >> subTileShift) & subTileMask,
+ subTile((pt.u >> kSubTileShift) & kSubTileMask,
+ (pt.v >> kSubTileShift) & kSubTileMask,
0);
MetaTilePtr metaPtr;
diff --git a/engines/saga2/terrain.cpp b/engines/saga2/terrain.cpp
index 4a68b25dc9..04acf2eeae 100644
--- a/engines/saga2/terrain.cpp
+++ b/engines/saga2/terrain.cpp
@@ -224,24 +224,24 @@ uint32 volumeTerrain(int16 mapNum, const TileRegion &vol) {
volume;
// Convert to subtile coords
- volume.min.u = vol.min.u >> subTileShift;
- volume.min.v = vol.min.v >> subTileShift;
- volume.max.u = (vol.max.u + subTileMask) >> subTileShift;
- volume.max.v = (vol.max.v + subTileMask) >> subTileShift;
+ volume.min.u = vol.min.u >> kSubTileShift;
+ volume.min.v = vol.min.v >> kSubTileShift;
+ volume.max.u = (vol.max.u + kSubTileMask) >> kSubTileShift;
+ volume.max.v = (vol.max.v + kSubTileMask) >> kSubTileShift;
volume.min.z = vol.min.z;
volume.max.z = vol.max.z;
// Calculate the footprint of the object (in subtile coords)
- footprint.min.u = volume.min.u >> tileSubShift;
- footprint.min.v = volume.min.v >> tileSubShift;
- footprint.max.u = volume.max.u >> tileSubShift;
- footprint.max.v = volume.max.v >> tileSubShift;
+ footprint.min.u = volume.min.u >> kTileSubShift;
+ footprint.min.v = volume.min.v >> kTileSubShift;
+ footprint.max.u = volume.max.u >> kTileSubShift;
+ footprint.max.v = volume.max.v >> kTileSubShift;
// Calculate which subtiles the region falls upon.
- subPos.min.u = volume.min.u & subTileMask;
- subPos.min.v = volume.min.v & subTileMask;
- subPos.max.u = volume.max.u & subTileMask;
- subPos.max.v = volume.max.v & subTileMask;
+ subPos.min.u = volume.min.u & kSubTileMask;
+ subPos.min.v = volume.min.v & kSubTileMask;
+ subPos.max.u = volume.max.u & kSubTileMask;
+ subPos.max.v = volume.max.v & kSubTileMask;
tilePt.z = 0;
@@ -389,17 +389,17 @@ uint32 lineTerrain(
#endif
// Calculate starting subtile coordinates
- curSubTile.u = from.u >> subTileShift;
- curSubTile.v = from.v >> subTileShift;
+ curSubTile.u = from.u >> kSubTileShift;
+ curSubTile.v = from.v >> kSubTileShift;
curSubTile.z = tileStartZ = from.z;
// Calculate destination subtil coordinates
- destSubTile.u = to.u >> subTileShift;
- destSubTile.v = to.v >> subTileShift;
+ destSubTile.u = to.u >> kSubTileShift;
+ destSubTile.v = to.v >> kSubTileShift;
destSubTile.z = to.z;
- tilePt.u = curSubTile.u >> tileSubShift;
- tilePt.v = curSubTile.v >> tileSubShift;
+ tilePt.u = curSubTile.u >> kTileSubShift;
+ tilePt.v = curSubTile.v >> kTileSubShift;
tilePt.z = 0;
if (destSubTile.u > curSubTile.u) {
@@ -440,7 +440,7 @@ uint32 lineTerrain(
curSubTile.u += uStep) {
curZ += zStep;
- if ((curSubTile.u >> tileSubShift) != tilePt.u) {
+ if ((curSubTile.u >> kTileSubShift) != tilePt.u) {
curSubTile.z = curZ >> 16;
terrain |= tileTerrain(
@@ -451,16 +451,16 @@ uint32 lineTerrain(
*maxZ + 1);
if (terrain & opaqueTerrain) return terrain;
- tilePt.u = curSubTile.u >> tileSubShift;
+ tilePt.u = curSubTile.u >> kTileSubShift;
tileStartZ = curSubTile.z;
subTileMask_ = 0;
}
- subTileMask_ |= (uMask[curSubTile.u & subTileMask] &
- vMask[curSubTile.v & subTileMask]);
+ subTileMask_ |= (uMask[curSubTile.u & kSubTileMask] &
+ vMask[curSubTile.v & kSubTileMask]);
#if DEBUG && VISUAL2
- tempPoint.u = curSubTile.u << tileSubShift;
- tempPoint.v = curSubTile.v << tileSubShift;
+ tempPoint.u = curSubTile.u << kTileSubShift;
+ tempPoint.v = curSubTile.v << kTileSubShift;
tempPoint.z = curSubTile.z;
TPLine(prevPoint, tempPoint);
prevPoint = tempPoint;
@@ -471,7 +471,7 @@ uint32 lineTerrain(
errorTerm -= uDiff;
curSubTile.v += vStep;
- if ((curSubTile.v >> tileSubShift) != tilePt.z) {
+ if ((curSubTile.v >> kTileSubShift) != tilePt.z) {
curSubTile.z = curZ >> 16;
terrain |= tileTerrain(
@@ -482,16 +482,16 @@ uint32 lineTerrain(
*maxZ + 1);
if (terrain & opaqueTerrain) return terrain;
- tilePt.v = curSubTile.v >> tileSubShift;
+ tilePt.v = curSubTile.v >> kTileSubShift;
tileStartZ = curSubTile.z;
subTileMask_ = 0;
}
- subTileMask_ |= (uMask[curSubTile.u & subTileMask] &
- vMask[curSubTile.v & subTileMask]);
+ subTileMask_ |= (uMask[curSubTile.u & kSubTileMask] &
+ vMask[curSubTile.v & kSubTileMask]);
#if DEBUG && VISUAL2
- tempPoint.u = curSubTile.u << tileSubShift;
- tempPoint.v = curSubTile.v << tileSubShift;
+ tempPoint.u = curSubTile.u << kTileSubShift;
+ tempPoint.v = curSubTile.v << kTileSubShift;
tempPoint.z = curSubTile.z;
TPLine(prevPoint, tempPoint);
prevPoint = tempPoint;
@@ -509,7 +509,7 @@ uint32 lineTerrain(
curSubTile.v += vStep) {
curZ += zStep;
- if ((curSubTile.v >> tileSubShift) != tilePt.v) {
+ if ((curSubTile.v >> kTileSubShift) != tilePt.v) {
curSubTile.z = curZ >> 16;
terrain |= tileTerrain(
@@ -520,17 +520,17 @@ uint32 lineTerrain(
*maxZ + 1);
if (terrain & opaqueTerrain) return terrain;
- tilePt.v = curSubTile.v >> tileSubShift;
+ tilePt.v = curSubTile.v >> kTileSubShift;
tileStartZ = curSubTile.z;
subTileMask_ = 0;
}
- subTileMask_ |= (uMask[curSubTile.u & subTileMask] &
- vMask[curSubTile.v & subTileMask]);
+ subTileMask_ |= (uMask[curSubTile.u & kSubTileMask] &
+ vMask[curSubTile.v & kSubTileMask]);
#if DEBUG && VISUAL2
- tempPoint.u = curSubTile.u << tileSubShift;
- tempPoint.v = curSubTile.v << tileSubShift;
+ tempPoint.u = curSubTile.u << kTileSubShift;
+ tempPoint.v = curSubTile.v << kTileSubShift;
tempPoint.z = curSubTile.z;
TPLine(prevPoint, tempPoint);
prevPoint = tempPoint;
@@ -541,7 +541,7 @@ uint32 lineTerrain(
errorTerm -= vDiff;
curSubTile.u += uStep;
- if ((curSubTile.u >> tileSubShift) != tilePt.u) {
+ if ((curSubTile.u >> kTileSubShift) != tilePt.u) {
curSubTile.z = curZ >> 16;
terrain |= tileTerrain(
@@ -552,16 +552,16 @@ uint32 lineTerrain(
*maxZ + 1);
if (terrain & opaqueTerrain) return terrain;
- tilePt.u = curSubTile.u >> tileSubShift;
+ tilePt.u = curSubTile.u >> kTileSubShift;
tileStartZ = curSubTile.z;
subTileMask_ = 0;
}
- subTileMask_ |= (uMask[curSubTile.u & subTileMask] &
- vMask[curSubTile.v & subTileMask]);
+ subTileMask_ |= (uMask[curSubTile.u & kSubTileMask] &
+ vMask[curSubTile.v & kSubTileMask]);
#if DEBUG && VISUAL2
- tempPoint.u = curSubTile.u << tileSubShift;
- tempPoint.v = curSubTile.v << tileSubShift;
+ tempPoint.u = curSubTile.u << kTileSubShift;
+ tempPoint.v = curSubTile.v << kTileSubShift;
tempPoint.z = curSubTile.z;
TPLine(prevPoint, tempPoint);
prevPoint = tempPoint;
@@ -608,8 +608,8 @@ int16 tileSlopeHeight(
metaCoords = tileCoords >> kPlatShift,
origin = metaCoords << kPlatShift,
coords = tileCoords - origin,
- subTile((pt.u >> subTileShift) & subTileMask,
- (pt.v >> subTileShift) & subTileMask,
+ subTile((pt.u >> kSubTileShift) & kSubTileMask,
+ (pt.v >> kSubTileShift) & kSubTileMask,
0);
MetaTilePtr metaPtr;
@@ -866,9 +866,9 @@ int16 checkWalkable(
subTileV,
mask;
- subTileU = (loc.u & kTileUVMask) >> subTileShift;
- subTileV = (loc.v & kTileUVMask) >> subTileShift;
- mask = 1 << ((subTileU << subTileShift) + subTileV);
+ subTileU = (loc.u & kTileUVMask) >> kSubTileShift;
+ subTileV = (loc.v & kTileUVMask) >> kSubTileShift;
+ mask = 1 << ((subTileU << kSubTileShift) + subTileV);
// If the suporting subtile is funiture consider this blocked
if (sti.surfaceTile->attrs.testTerrain(mask) & terrainFurniture)
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 508e50d6b5..9296d5add4 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -1638,7 +1638,7 @@ void initMaps(void) {
mapData->mapSize = mapData->map->size;
// Compute the height of the map in pixels
- mapData->mapHeight = mapData->mapSize * metaTileHeight;
+ mapData->mapHeight = mapData->mapSize * kMetaTileHeight;
// Build an active item instance hash table
mapData->buildInstanceHash();
@@ -2683,12 +2683,12 @@ inline void drawMetaRow(TilePoint coords, Point16 pos) {
for (;
- pos.x < tileDrawMap.size.x + metaDX;
+ pos.x < tileDrawMap.size.x + kMetaDX;
coords.u++,
coords.v--,
uOrg += kPlatformWidth,
vOrg -= kPlatformWidth,
- pos.x += metaTileWidth
+ pos.x += kMetaTileWidth
) {
TilePoint clipCoords;
int16 mtile;
@@ -2960,9 +2960,9 @@ inline void drawMetaTiles(void) {
// coordinates of the view window upper left corner in U,V
- baseCoords.u = ((2 * (viewPos.y >> kTileDXShift) + metaDY / 16) + viewPos.x)
+ baseCoords.u = ((2 * (viewPos.y >> kTileDXShift) + kMetaDY / 16) + viewPos.x)
/ (kPlatformWidth * 2);
- baseCoords.v = ((2 * (viewPos.y >> kTileDXShift) + metaDY / 16) - viewPos.x)
+ baseCoords.v = ((2 * (viewPos.y >> kTileDXShift) + kMetaDY / 16) - viewPos.x)
/ (kPlatformWidth * 2);
baseCoords.z = 0;
@@ -2973,11 +2973,11 @@ inline void drawMetaTiles(void) {
updateHandleRefs(baseCoords); // viewPoint, &sti );
// coordinates of current metatile (in X,Y), relative to screen
- metaPos.x = (baseCoords.u - baseCoords.v) * metaDX
+ metaPos.x = (baseCoords.u - baseCoords.v) * kMetaDX
- viewPos.x * kTileDX;
metaPos.y = viewPos.y
- - (baseCoords.u + baseCoords.v) * metaDY;
+ - (baseCoords.u + baseCoords.v) * kMetaDY;
debugC(2, kDebugTiles, "metaPos = (%d,%d)", metaPos.x, metaPos.y);
@@ -2986,19 +2986,19 @@ inline void drawMetaTiles(void) {
// (replace 256 constant with better value)
for (;
- metaPos.y < tileDrawMap.size.y + metaTileHeight * 4 ;
+ metaPos.y < tileDrawMap.size.y + kMetaTileHeight * 4 ;
baseCoords.u--,
baseCoords.v--
) {
drawMetaRow(baseCoords, metaPos);
- metaPos.y += metaDY;
- metaPos.x -= metaDX;
+ metaPos.y += kMetaDY;
+ metaPos.x -= kMetaDX;
drawMetaRow(TilePoint(baseCoords.u - 1, baseCoords.v, 0), metaPos);
- metaPos.y += metaDY;
- metaPos.x += metaDX;
+ metaPos.y += kMetaDY;
+ metaPos.x += kMetaDX;
}
}
@@ -3318,14 +3318,14 @@ void maskMetaRow(
int16 layerLimit;
for (;
- pos.x < sMap.size.x + metaDX;
+ pos.x < sMap.size.x + kMetaDX;
coords.u++,
coords.v--,
relLoc.u += kPlatUVSize,
relLoc.v -= kPlatUVSize,
uOrg += kPlatformWidth,
vOrg -= kPlatformWidth,
- pos.x += metaTileWidth
+ pos.x += kMetaTileWidth
) {
TilePoint clipCoords;
int16 mtile;
@@ -3425,19 +3425,19 @@ void drawTileMask(
// coordinates of the view window upper left corner in U,V
- baseCoords.u = ((2 * (viewPos.y >> kTileDXShift) + metaDY / 16) + viewPos.x)
+ baseCoords.u = ((2 * (viewPos.y >> kTileDXShift) + kMetaDY / 16) + viewPos.x)
/ (kPlatformWidth * 2);
- baseCoords.v = ((2 * (viewPos.y >> kTileDXShift) + metaDY / 16) - viewPos.x)
+ baseCoords.v = ((2 * (viewPos.y >> kTileDXShift) + kMetaDY / 16) - viewPos.x)
/ (kPlatformWidth * 2);
baseCoords.z = 0;
// coordinates of current metatile (in X,Y), relative to screen
- metaPos.x = (baseCoords.u - baseCoords.v) * metaDX
+ metaPos.x = (baseCoords.u - baseCoords.v) * kMetaDX
- viewPos.x * kTileDX;
metaPos.y = viewPos.y
- - (baseCoords.u + baseCoords.v) * metaDY;
+ - (baseCoords.u + baseCoords.v) * kMetaDY;
// Compute where the object is relative to the metatile coords
@@ -3450,22 +3450,22 @@ void drawTileMask(
// (replace 256 constant with better value)
for (;
- metaPos.y < sMap.size.y + metaTileHeight * 4 ;
+ metaPos.y < sMap.size.y + kMetaTileHeight * 4 ;
baseCoords.u--,
baseCoords.v--
) {
maskMetaRow(sMap, baseCoords, relLoc, metaPos, roofID);
- metaPos.y += metaDY;
- metaPos.x -= metaDX;
+ metaPos.y += kMetaDY;
+ metaPos.x -= kMetaDX;
relLoc.u -= kPlatUVSize;
maskMetaRow(sMap, TilePoint(baseCoords.u - 1, baseCoords.v, 0),
relLoc, metaPos, roofID);
- metaPos.y += metaDY;
- metaPos.x += metaDX;
+ metaPos.y += kMetaDY;
+ metaPos.x += kMetaDX;
relLoc.v -= kPlatUVSize;
}
@@ -3675,7 +3675,7 @@ SurfaceType pointOnTile(TileInfo *ti,
while (subUVPointRel >= 0 &&
subUVPoint.u < 16 &&
subUVPoint.v < 16) {
- if (subUVPointRel < pointH + (subTileDY * 2) / subTileSize) {
+ if (subUVPointRel < pointH + (kSubTileDY * 2) / kSubTileSize) {
pickCoords = (tCoords << kTileUVShift);
pickCoords.u += subUVPoint.u;
pickCoords.v += subUVPoint.v;
@@ -3688,7 +3688,7 @@ SurfaceType pointOnTile(TileInfo *ti,
subUVPoint.u++;
subUVPoint.v++;
if (subUVPoint.u < 16 && subUVPoint.v < 16) {
- subUVPointRel -= (subTileDY * 2) / subTileSize;
+ subUVPointRel -= (kSubTileDY * 2) / kSubTileSize;
// Compute the terrain height of point
pointH = ptHeight(subUVPoint, ti->attrs.cornerHeight);
@@ -3698,7 +3698,7 @@ SurfaceType pointOnTile(TileInfo *ti,
// last point checked.
subUVPoint.u--;
subUVPoint.v--;
- subUVPointRel = pointH + ((subTileDY * 2) / subTileSize) - 1;
+ subUVPointRel = pointH + ((kSubTileDY * 2) / kSubTileSize) - 1;
}
}
@@ -3716,15 +3716,15 @@ SurfaceType pointOnTile(TileInfo *ti,
// relative to that subtile.
if (relPos.x > 0) {
- subTile.u = relPos.x >> subTileDXShift;
+ subTile.u = relPos.x >> kSubTileDXShift;
subTile.v = 0;
- subTileRel.x = relPos.x - (subTile.u << subTileDXShift);
- subTileRel.y = relPos.y - (subTile.u << subTileDYShift) - h;
+ subTileRel.x = relPos.x - (subTile.u << kSubTileDXShift);
+ subTileRel.y = relPos.y - (subTile.u << kSubTileDYShift) - h;
} else {
subTile.u = 0;
- subTile.v = (-relPos.x + 1) >> subTileDXShift;
- subTileRel.x = relPos.x + (subTile.v << subTileDXShift);
- subTileRel.y = relPos.y - (subTile.v << subTileDYShift) - h;
+ subTile.v = (-relPos.x + 1) >> kSubTileDXShift;
+ subTileRel.x = relPos.x + (subTile.v << kSubTileDXShift);
+ subTileRel.y = relPos.y - (subTile.v << kSubTileDYShift) - h;
}
// Compute the mask which represents the subtile
@@ -3741,8 +3741,8 @@ SurfaceType pointOnTile(TileInfo *ti,
if (subTileRel.y <
ti->attrs.terrainHeight + yBound) {
pickCoords = (tCoords << kTileUVShift);
- pickCoords.u += (subTile.u << subTileShift);
- pickCoords.v += (subTile.v << subTileShift);
+ pickCoords.u += (subTile.u << kSubTileShift);
+ pickCoords.v += (subTile.v << kSubTileShift);
if (subTileRel.x > 1) {
pickCoords.u += yBound;
type = surfaceVertU;
@@ -3801,12 +3801,12 @@ SurfaceType pointOnTile(TileInfo *ti,
}
// mouse is on top of raised section
if (subTileRel.y <
- ti->attrs.terrainHeight + subTileDY * 2 - yBound) {
+ ti->attrs.terrainHeight + kSubTileDY * 2 - yBound) {
pickCoords = (tCoords << kTileUVShift);
y = subTileRel.y - ti->attrs.terrainHeight;
- pickCoords.u += (subTile.u << subTileShift) +
+ pickCoords.u += (subTile.u << kSubTileShift) +
(((subTileRel.x >> 1) + y) >> 1);
- pickCoords.v += (subTile.v << subTileShift) +
+ pickCoords.v += (subTile.v << kSubTileShift) +
((y - (subTileRel.x >> 1)) >> 1);
pickCoords.z = h + ti->attrs.terrainHeight;
floorCoords = pickCoords;
@@ -3835,10 +3835,10 @@ SurfaceType pointOnTile(TileInfo *ti,
while (subUVPointRel >= 0 &&
subUVPoint.u < 4 &&
subUVPoint.v < 4) {
- if (subUVPointRel < pointH + (subTileDY * 2) / subTileSize) {
+ if (subUVPointRel < pointH + (kSubTileDY * 2) / kSubTileSize) {
pickCoords = (tCoords << kTileUVShift);
- pickCoords.u += (subTile.u << subTileShift) + subUVPoint.u;
- pickCoords.v += (subTile.v << subTileShift) + subUVPoint.v;
+ pickCoords.u += (subTile.u << kSubTileShift) + subUVPoint.u;
+ pickCoords.v += (subTile.v << kSubTileShift) + subUVPoint.v;
pickCoords.z = h + pointH;
floorCoords = pickCoords;
foundPoint = true;
@@ -3848,8 +3848,8 @@ SurfaceType pointOnTile(TileInfo *ti,
// Test next point on subtile
subUVPoint.u++;
subUVPoint.v++;
- subUVPointRel -= (subTileDY * 2) / subTileSize;
- pointH = ptHeight((subTile << subTileShift) + subUVPoint,
+ subUVPointRel -= (kSubTileDY * 2) / kSubTileSize;
+ pointH = ptHeight((subTile << kSubTileShift) + subUVPoint,
ti->attrs.cornerHeight);
}
if (foundPoint) break;
@@ -3859,21 +3859,21 @@ SurfaceType pointOnTile(TileInfo *ti,
if (subTileRel.x & 0xFFFE) { // if subTileRel.x != 0 or 1
// crabwalk up the subtiles
if (subTileRel.x > 0) {
- subTileRel.x -= subTileDX;
+ subTileRel.x -= kSubTileDX;
subTile.u++;
- sMask <<= subTileMaskUShift;
+ sMask <<= kSubTileMaskUShift;
} else {
- subTileRel.x += subTileDX;
+ subTileRel.x += kSubTileDX;
subTile.v++;
- sMask <<= subTileMaskVShift;
+ sMask <<= kSubTileMaskVShift;
}
- subTileRel.y -= subTileDY;
+ subTileRel.y -= kSubTileDY;
} else { // subTileRel.x == 0 or 1
// move up to the next vertical subtile
subTile.u++;
subTile.v++;
- sMask <<= subTileMaskUShift + subTileMaskVShift;
- subTileRel.y -= subTileDY * 2;
+ sMask <<= kSubTileMaskUShift + kSubTileMaskVShift;
+ subTileRel.y -= kSubTileDY * 2;
}
yBound = abs(subTileRel.x >> 1);
@@ -3887,8 +3887,8 @@ SurfaceType pointOnTile(TileInfo *ti,
subTile = lastRaisedSubTile;
subTileRel.x = relPos.x -
- ((subTile.u - subTile.v) << subTileDXShift);
- subTileRel.y = ti->attrs.terrainHeight + subTileDY * 2 -
+ ((subTile.u - subTile.v) << kSubTileDXShift);
+ subTileRel.y = ti->attrs.terrainHeight + kSubTileDY * 2 -
abs(subTileRel.x >> 1) - 1;
sMask = calcSubTileMask(subTile.u, subTile.v);
@@ -3904,20 +3904,20 @@ SurfaceType pointOnTile(TileInfo *ti,
raisedCol = -4;
- if (relPos.x & (subTileDX - 1) & 0xFFFE) {
+ if (relPos.x & (kSubTileDX - 1) & 0xFFFE) {
if (relPos.x > 0) {
- curSubTileCol = relPos.x >> subTileDXShift;
+ curSubTileCol = relPos.x >> kSubTileDXShift;
rightSubTileCol = curSubTileCol + 2;
leftSubTileCol = curSubTileCol - 1;
goto testLeft;
} else {
curSubTileCol =
- (relPos.x + subTileDX - 1) >> subTileDXShift;
+ (relPos.x + kSubTileDX - 1) >> kSubTileDXShift;
leftSubTileCol = curSubTileCol - 2;
rightSubTileCol = curSubTileCol + 1;
}
} else {
- curSubTileCol = relPos.x >> subTileDXShift;
+ curSubTileCol = relPos.x >> kSubTileDXShift;
rightSubTileCol = curSubTileCol + 1;
leftSubTileCol = curSubTileCol - 1;
}
@@ -3934,7 +3934,7 @@ SurfaceType pointOnTile(TileInfo *ti,
if (ti->attrs.testTerrain(colMask) & terrainRaised) {
raisedCol = rightSubTileCol;
- subTileRel.x = -subTileDX + 2;
+ subTileRel.x = -kSubTileDX + 2;
break;
}
@@ -3950,7 +3950,7 @@ testLeft:
if (ti->attrs.testTerrain(colMask) & terrainRaised) {
raisedCol = leftSubTileCol;
- subTileRel.x = subTileDX - 1;
+ subTileRel.x = kSubTileDX - 1;
break;
}
@@ -3963,7 +3963,7 @@ testLeft:
// compute the number of subtiles in column
int8 subsInCol = 4 - abs(raisedCol);
- relPos.x = (raisedCol << subTileDXShift) + subTileRel.x;
+ relPos.x = (raisedCol << kSubTileDXShift) + subTileRel.x;
if (raisedCol > 0) {
colMask = 0x0001 << (raisedCol << 2);
@@ -3986,7 +3986,7 @@ testLeft:
// subTile is now the first raised subtile in
// column
- subTileRel.y = relPos.y - ((subTile.u + subTile.v) * subTileDY) - h;
+ subTileRel.y = relPos.y - ((subTile.u + subTile.v) * kSubTileDY) - h;
sMask = calcSubTileMask(subTile.u, subTile.v);
yBound = abs(subTileRel.x >> 1);
}
@@ -4034,11 +4034,11 @@ bool pointOnHiddenSurface(
if (surfaceType == surfaceVertV) {
assert(testCoords.u == 0);
adjTCoords.u--;
- adjSubMask = 0x1000 << (testCoords.v >> subTileShift);
+ adjSubMask = 0x1000 << (testCoords.v >> kSubTileShift);
} else {
assert(testCoords.v == 0);
adjTCoords.v--;
- adjSubMask = 0x0008 << (testCoords.u & ~subTileMask);
+ adjSubMask = 0x0008 << (testCoords.u & ~kSubTileMask);
}
mCoords = adjTCoords >> kPlatShift;
@@ -4498,10 +4498,10 @@ uint16 objRoofID(GameObject *obj, int16 objMapNum, const TilePoint &objCoords) {
objHeight = objCoords.z;
- objTileReg.min.u = (objCoords.u - subTileSize) >> kTileUVShift;
- objTileReg.min.v = (objCoords.v - subTileSize) >> kTileUVShift;
- objTileReg.max.u = (objCoords.u + subTileSize + kTileUVMask) >> kTileUVShift;
- objTileReg.max.v = (objCoords.v + subTileSize + kTileUVMask) >> kTileUVShift;
+ objTileReg.min.u = (objCoords.u - kSubTileSize) >> kTileUVShift;
+ objTileReg.min.v = (objCoords.v - kSubTileSize) >> kTileUVShift;
+ objTileReg.max.u = (objCoords.u + kSubTileSize + kTileUVMask) >> kTileUVShift;
+ objTileReg.max.v = (objCoords.v + kSubTileSize + kTileUVMask) >> kTileUVShift;
debugC(3, kDebugTiles, "objTileReg = ((%d,%d), (%d,%d))", objTileReg.min.u, objTileReg.min.v, objTileReg.max.u, objTileReg.max.v);
Commit: 2ac1b6f55d6fd71236dff06a5aea6f6611c4c012
https://github.com/scummvm/scummvm/commit/2ac1b6f55d6fd71236dff06a5aea6f6611c4c012
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:16+02:00
Commit Message:
SAGA2: Rename more constants in idtypes.h
Changed paths:
engines/saga2/actor.cpp
engines/saga2/effects.cpp
engines/saga2/effects.h
engines/saga2/idtypes.h
engines/saga2/intrface.cpp
engines/saga2/motion.cpp
engines/saga2/objects.cpp
engines/saga2/objects.h
engines/saga2/objproto.cpp
engines/saga2/objproto.h
engines/saga2/path.cpp
engines/saga2/spelcast.cpp
engines/saga2/task.cpp
engines/saga2/terrain.cpp
engines/saga2/tile.cpp
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 0a4137f9d0..adb1549e28 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -419,9 +419,9 @@ bool ActorProto::acceptDamageAction(
return acceptHealing(dObj, enactor, -damage);
// Apply applicable armor adjustments
- if (dType == damageImpact
- || dType == damageSlash
- || dType == damageProjectile) {
+ if (dType == kDamageImpact
+ || dType == kDamageSlash
+ || dType == kDamageProjectile) {
ArmorAttributes armorAttribs;
a->totalArmorAttributes(armorAttribs);
diff --git a/engines/saga2/effects.cpp b/engines/saga2/effects.cpp
index a7dc59dde0..889c3ed14f 100644
--- a/engines/saga2/effects.cpp
+++ b/engines/saga2/effects.cpp
@@ -50,23 +50,23 @@ extern void updateIndicators(void); // Kludge, put in intrface.h later (go
int16 ProtoDamage::getRelevantStat(effectDamageTypes dt, Actor *a) {
switch (dt) {
- case damageImpact :
- case damageSlash :
- case damageProjectile :
+ case kDamageImpact :
+ case kDamageSlash :
+ case kDamageProjectile :
return a->getStats()->getSkillLevel(skillIDBrawn);
- case damageFire :
- case damageAcid :
- case damageHeat :
- case damageCold :
- case damageLightning :
- case damagePoison :
- case damageMental :
- case damageToUndead :
+ case kDamageFire :
+ case kDamageAcid :
+ case kDamageHeat :
+ case kDamageCold :
+ case kDamageLightning :
+ case kDamagePoison :
+ case kDamageMental :
+ case kDamageToUndead :
return a->getStats()->getSkillLevel(skillIDSpellcraft);
- case damageDirMagic :
- case damageOther :
- case damageStarve :
- case damageEnergy :
+ case kDamageDirMagic :
+ case kDamageOther :
+ case kDamageStarve :
+ case kDamageEnergy :
return 0;
}
return 0;
@@ -148,11 +148,11 @@ void ProtoDrainage::drainLevel(GameObject *cst, Actor *a, effectDrainsTypes edt,
{
int16 &maxVit = (a->getBaseStats())->vitality;
maxVit = clamp(0, maxVit - amt, absoluteMaximumVitality);
- a->acceptDamage(cst->thisID(), amt > 0 ? 1 : -1, damageOther);
+ a->acceptDamage(cst->thisID(), amt > 0 ? 1 : -1, kDamageOther);
}
break;
case drainsVitality:
- a->acceptDamage(cst->thisID(), amt, damageOther);
+ a->acceptDamage(cst->thisID(), amt, kDamageOther);
break;
default:
break;
@@ -437,7 +437,7 @@ SPECIALSPELL(DeathSpell) {
if (!a->makeSavingThrow()) {
a->acceptDamage(cst->thisID(),
a->effectiveStats.vitality,
- damageEnergy, 1, 2, 0);
+ kDamageEnergy, 1, 2, 0);
a->die();
}
}
diff --git a/engines/saga2/effects.h b/engines/saga2/effects.h
index 6faef28f75..8bef3484e7 100644
--- a/engines/saga2/effects.h
+++ b/engines/saga2/effects.h
@@ -83,26 +83,26 @@ enum effectTypes {
//
enum effectResistTypes {
- resistOther = damageOther,
+ resistOther = kDamageOther,
// Combat resist
- resistImpact = damageImpact,
- resistSlash = damageSlash,
- resistProjectile = damageProjectile,
+ resistImpact = kDamageImpact,
+ resistSlash = kDamageSlash,
+ resistProjectile = kDamageProjectile,
// Magic resist
- resistFire = damageFire,
- resistAcid = damageAcid,
- resistHeat = damageHeat,
- resistCold = damageCold,
- resistLightning = damageLightning,
- resistPoison = damagePoison,
+ resistFire = kDamageFire,
+ resistAcid = kDamageAcid,
+ resistHeat = kDamageHeat,
+ resistCold = kDamageCold,
+ resistLightning = kDamageLightning,
+ resistPoison = kDamagePoison,
// Other magic resist
- resistMental = damageMental,
- resistToUndead = damageToUndead,
- resistDirMagic = damageDirMagic,
+ resistMental = kDamageMental,
+ resistToUndead = kDamageToUndead,
+ resistDirMagic = kDamageDirMagic,
// Physiological Damage
- resistStarve = damageStarve,
+ resistStarve = kDamageStarve,
// other
- resistEnergy = damageEnergy,
+ resistEnergy = kDamageEnergy,
};
//
@@ -339,7 +339,7 @@ inline bool isSaveable(uint16 enchID) {
// Determine whether a damage type is magical
inline bool isMagicDamage(effectDamageTypes t) {
- return t >= damageFire && t <= damageDirMagic;
+ return t >= kDamageFire && t <= kDamageDirMagic;
}
#define Forever (255)
diff --git a/engines/saga2/idtypes.h b/engines/saga2/idtypes.h
index c14b4c1344..923e3428f7 100644
--- a/engines/saga2/idtypes.h
+++ b/engines/saga2/idtypes.h
@@ -241,26 +241,26 @@ enum {
//
enum effectDamageTypes {
// Generic
- damageOther = 0, // Healing, cause wounds
+ kDamageOther = 0, // Healing, cause wounds
// Combat damage
- damageImpact = 1, // hammers, maces
- damageSlash = 2, // swords
- damageProjectile = 3, // arrows, poin-ted sticks
+ kDamageImpact = 1, // hammers, maces
+ kDamageSlash = 2, // swords
+ kDamageProjectile = 3, // arrows, poin-ted sticks
// Magic damage
- damageFire = 4, // Yellow
- damageAcid = 5, // Violet
- damageHeat = 6, // Red
- damageCold = 7, // Blue
- damageLightning = 8, // Orange
- damagePoison = 9, // Green
+ kDamageFire = 4, // Yellow
+ kDamageAcid = 5, // Violet
+ kDamageHeat = 6, // Red
+ kDamageCold = 7, // Blue
+ kDamageLightning = 8, // Orange
+ kDamagePoison = 9, // Green
// Other magic damage
- damageMental = 10, // dain bramage
- damageToUndead = 11, // undead take this damage
- damageDirMagic = 12, // the plusses on swords etc.
+ kDamageMental = 10, // dain bramage
+ kDamageToUndead = 11, // undead take this damage
+ kDamageDirMagic = 12, // the plusses on swords etc.
// Physiological Damage
- damageStarve = 13, // You must eat!
+ kDamageStarve = 13, // You must eat!
// other
- damageEnergy = 14 // Generally hard to resist - god damage
+ kDamageEnergy = 14 // Generally hard to resist - god damage
};
// Tile metrics
@@ -336,10 +336,10 @@ enum {
// Maximum height that a character can climb w/o steps or ladders
enum {
- maxStepHeight = 16, // highest climbable step
- maxPickHeight = 64, // highest pickable step
- maxSmoothStep = 8, // highest smoothly climbable
- maxJumpStep = 64 // highest jump character likes
+ kMaxStepHeight = 16, // highest climbable step
+ kMaxPickHeight = 64, // highest pickable step
+ kMaxSmoothStep = 8, // highest smoothly climbable
+ kMaxJumpStep = 64 // highest jump character likes
};
} // end of namespace Saga2
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index aa063719eb..8d5465f7f9 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -2893,37 +2893,37 @@ void gEnchantmentDisplay::setValue(PlayerActorID pID) {
case effectResist:
switch (eSubType) {
- case damageImpact:
+ case kDamageImpact:
newIconFlags[iconResistImpact] = duration;
break;
- case damageSlash:
+ case kDamageSlash:
newIconFlags[iconResistSlash] = duration;
break;
- case damageProjectile:
+ case kDamageProjectile:
newIconFlags[iconResistProjectile] = duration;
break;
- case damageFire:
+ case kDamageFire:
newIconFlags[iconResistFire] = duration;
break;
- case damageAcid:
+ case kDamageAcid:
newIconFlags[iconResistAcid] = duration;
break;
- case damageHeat:
+ case kDamageHeat:
newIconFlags[iconResistHeat] = duration;
break;
- case damageCold:
+ case kDamageCold:
newIconFlags[iconResistCold] = duration;
break;
- case damageLightning:
+ case kDamageLightning:
newIconFlags[iconResistLightning] = duration;
break;
- case damagePoison:
+ case kDamagePoison:
newIconFlags[iconResistPoison] = duration;
break;
- case damageMental:
+ case kDamageMental:
newIconFlags[iconResistPsionic] = duration;
break;
- case damageDirMagic:
+ case kDamageDirMagic:
newIconFlags[iconResistDirectMagic] = duration;
break;
}
@@ -2931,31 +2931,31 @@ void gEnchantmentDisplay::setValue(PlayerActorID pID) {
case effectImmune:
switch (eSubType) {
- case damageImpact:
+ case kDamageImpact:
newIconFlags[iconIronskin] = duration;
break;
- case damageSlash:
+ case kDamageSlash:
newIconFlags[iconIronskin] = duration;
break;
- case damageFire:
+ case kDamageFire:
newIconFlags[iconImmuneFire] = duration;
break;
- case damageAcid:
+ case kDamageAcid:
newIconFlags[iconImmuneAcid] = duration;
break;
- case damageHeat:
+ case kDamageHeat:
newIconFlags[iconImmuneHeat] = duration;
break;
- case damageCold:
+ case kDamageCold:
newIconFlags[iconImmuneCold] = duration;
break;
- case damageLightning:
+ case kDamageLightning:
newIconFlags[iconImmuneLightning] = duration;
break;
- case damagePoison:
+ case kDamagePoison:
newIconFlags[iconImmunePoison] = duration;
break;
- case damageMental:
+ case kDamageMental:
newIconFlags[iconImmunePsionic] = duration;
break;
}
diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp
index 53c02e5d5d..be69eefc44 100644
--- a/engines/saga2/motion.cpp
+++ b/engines/saga2/motion.cpp
@@ -268,8 +268,8 @@ bool unstickObject(GameObject *obj) {
// If the surface height is too far away from the sample
// height, then ignore it.
- if (tHeight > pos.z + maxStepHeight
- || tHeight < pos.z - maxStepHeight * 4) continue;
+ if (tHeight > pos.z + kMaxStepHeight
+ || tHeight < pos.z - kMaxStepHeight * 4) continue;
// Recompute the coordinate
dz = tHeight - objZ;
@@ -324,8 +324,8 @@ bool unstickObject(GameObject *obj) {
int16 tHeight;
tHeight = tileSlopeHeight(pos, obj);
- if (tHeight <= pos.z + maxStepHeight
- && tHeight >= pos.z - maxStepHeight * 4) {
+ if (tHeight <= pos.z + kMaxStepHeight
+ && tHeight >= pos.z - kMaxStepHeight * 4) {
pos.z = tHeight;
obj->move(pos);
return true;
@@ -2466,7 +2466,7 @@ bool MotionTask::nextWayPoint(void) {
// use dumb pathfinding until the pathfinder finishes it's task.
if ((finalTarget - object->location).quickHDistance() > 0
- || abs(finalTarget.z - object->location.z) > maxStepHeight) {
+ || abs(finalTarget.z - object->location.z) > kMaxStepHeight) {
// If no pathfind in progress
if ((flags & pathFind)
&& !(flags & finalPath)
@@ -2621,7 +2621,7 @@ void MotionTask::walkAction(void) {
// If we're not already there, then proceed towards
// the target.
- if (targetDist > 0 || abs(targetVector.z) > maxStepHeight)
+ if (targetDist > 0 || abs(targetVector.z) > kMaxStepHeight)
break;
}
@@ -2681,7 +2681,7 @@ void MotionTask::walkAction(void) {
if (moveTaskDone || moveTaskWaiting) {
movementDirection = a->currentFacing;
- } else if (targetDist == 0 && abs(targetVector.z) > maxStepHeight) {
+ } else if (targetDist == 0 && abs(targetVector.z) > kMaxStepHeight) {
if (pathFindTask)
moveTaskWaiting = true;
else {
@@ -2712,7 +2712,7 @@ void MotionTask::walkAction(void) {
// Test the terrain to see if we can go there.
if ((blockageType = checkWalkable(object, newPos)) != false) {
// Try stepping up to a higher terrain too.
- newPos.z = object->location.z + maxStepHeight;
+ newPos.z = object->location.z + kMaxStepHeight;
if (checkWalkable(object, newPos) != blockageNone) {
// If there is a path find task pending, put the walk action
// on hold until it finishes, else, abort the walk action.
@@ -2749,7 +2749,7 @@ void MotionTask::walkAction(void) {
// Check the terrain in various directions.
// Check in the forward direction first, at various heights
- for (height = 0; height <= maxStepHeight; height += maxSmoothStep) {
+ for (height = 0; height <= kMaxStepHeight; height += kMaxSmoothStep) {
// This code has him move along the exact direction
// vector, even if it's not aligned with one of the
// cardinal directions.
@@ -2771,7 +2771,7 @@ void MotionTask::walkAction(void) {
int16 leftDir = spinLeft(movementDirection),
rightDir = spinRight(movementDirection);
- for (height = 0; height <= maxStepHeight; height += 8) {
+ for (height = 0; height <= kMaxStepHeight; height += 8) {
if (checkWalk(rightDir, speedScale, height, newPos)) {
movementDirection = rightDir;
foundPath = true;
@@ -2887,7 +2887,7 @@ void MotionTask::walkAction(void) {
// This is a kludge to keep the character from
// "jumping" as he climbs up a small step.
- if (tHeight >= object->location.z - maxSmoothStep
+ if (tHeight >= object->location.z - kMaxSmoothStep
* ((sti.surfaceTile != NULL
&& (sti.surfaceTile->combinedTerrainMask() & terrainStair))
? 4
@@ -4719,7 +4719,7 @@ supported:
if (motionType != motionTypeWalk
|| tHeight <= newPos.z
|| !(flags & inWater)) {
- if (tHeight > newPos.z + maxStepHeight) {
+ if (tHeight > newPos.z + kMaxStepHeight) {
unstickObject(object);
tHeight = tileSlopeHeight(newPos, object, &sti);
}
@@ -4791,7 +4791,7 @@ falling:
tPos.u += objCrossSection;
tHeight = tileSlopeHeight(tPos, object, &sti);
- if (tHeight <= tPos.z + maxStepHeight
+ if (tHeight <= tPos.z + kMaxStepHeight
&& tHeight >= tPos.z - gravity * 4) {
newPos = tPos;
goto supported;
@@ -4799,7 +4799,7 @@ falling:
tPos.u -= objCrossSection * 2;
tHeight = tileSlopeHeight(tPos, object, &sti);
- if (tHeight <= tPos.z + maxStepHeight
+ if (tHeight <= tPos.z + kMaxStepHeight
&& tHeight >= tPos.z - gravity * 4) {
newPos = tPos;
goto supported;
@@ -4808,7 +4808,7 @@ falling:
tPos.u += objCrossSection;
tPos.v += objCrossSection;
tHeight = tileSlopeHeight(tPos, object, &sti);
- if (tHeight <= tPos.z + maxStepHeight
+ if (tHeight <= tPos.z + kMaxStepHeight
&& tHeight >= tPos.z - gravity * 4) {
newPos = tPos;
goto supported;
@@ -4816,7 +4816,7 @@ falling:
tPos.v -= objCrossSection * 2;
tHeight = tileSlopeHeight(tPos, object, &sti);
- if (tHeight <= tPos.z + maxStepHeight
+ if (tHeight <= tPos.z + kMaxStepHeight
&& tHeight >= tPos.z - gravity * 4) {
newPos = tPos;
goto supported;
@@ -4941,7 +4941,7 @@ bool checkLadder(Actor *a, const TilePoint &loc) {
}
if (loc.z
- < tileSlopeHeight(a->getLocation(), a) + maxStepHeight)
+ < tileSlopeHeight(a->getLocation(), a) + kMaxStepHeight)
MotionTask::upLadder(*a);
else
MotionTask::downLadder(*a);
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index ee190210ef..0a3e0ebdf9 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -1442,7 +1442,7 @@ void GameObject::updateState(void) {
if (objectFlags & objectFloating) return;
- if (tHeight > location.z + maxStepHeight) {
+ if (tHeight > location.z + kMaxStepHeight) {
unstickObject(this);
tHeight = tileSlopeHeight(location, this, &sti);
}
@@ -4200,7 +4200,7 @@ GameObject *objectCollision(GameObject *obj, GameWorld *world, const TilePoint &
volume.max.z = loc.z + proto->height;
// Adjust MIN Z for the fact that they can step over obstacles.
- if (isActor(obj)) volume.min.z += maxStepHeight / 2;
+ if (isActor(obj)) volume.min.z += kMaxStepHeight / 2;
// Constructor
CircularObjectIterator iter(world, loc, proto->crossSection + 32);
diff --git a/engines/saga2/objects.h b/engines/saga2/objects.h
index 62c736baf6..9b483a0c94 100644
--- a/engines/saga2/objects.h
+++ b/engines/saga2/objects.h
@@ -393,7 +393,7 @@ public:
bool acceptDamage(
ObjectID enactor,
int8 absDamage,
- effectDamageTypes dType = damageOther,
+ effectDamageTypes dType = kDamageOther,
int8 dice = 0,
uint8 sides = 1,
int8 perDieMod = 0) {
diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp
index ce07faf522..a9fcfc5bf3 100644
--- a/engines/saga2/objproto.cpp
+++ b/engines/saga2/objproto.cpp
@@ -2787,7 +2787,7 @@ void EnchantmentProto::doBackgroundUpdate(GameObject *obj) {
int16 damage = getEnchantmentAmount(flags);
// apply the damage
- parentObj->acceptDamage(obj->thisID(), damage, damagePoison);
+ parentObj->acceptDamage(obj->thisID(), damage, kDamagePoison);
}
}
diff --git a/engines/saga2/objproto.h b/engines/saga2/objproto.h
index 963b7c31b5..0bfeba237c 100644
--- a/engines/saga2/objproto.h
+++ b/engines/saga2/objproto.h
@@ -446,7 +446,7 @@ public:
ObjectID dObj,
ObjectID enactor,
int8 absDamage,
- effectDamageTypes dType = damageOther,
+ effectDamageTypes dType = kDamageOther,
int8 dice = 0,
uint8 sides = 1,
int8 perDieMod = 0);
diff --git a/engines/saga2/path.cpp b/engines/saga2/path.cpp
index 1388d769bf..20aec1ebaf 100644
--- a/engines/saga2/path.cpp
+++ b/engines/saga2/path.cpp
@@ -917,7 +917,7 @@ uint32 tileTerrain(
// If only checking the top of raised terrain treat it
// as if it were normal terrain.
- if (minZ + maxStepHeight >= tileMaxZ) {
+ if (minZ + kMaxStepHeight >= tileMaxZ) {
if (tileFgdTerrain & terrainSupportingRaised)
tileFgdTerrain = terrainNormal;
if (tileBgdTerrain & terrainSupportingRaised)
@@ -934,7 +934,7 @@ uint32 tileTerrain(
// catwalks and other surfaces which have no bottom.
if ((terrainResult & terrainSolidSurface)
- && height > minZ + maxStepHeight) {
+ && height > minZ + kMaxStepHeight) {
terrainResult |= terrainStone;
}
@@ -1594,7 +1594,7 @@ big_break:
// If the height difference is too great skip this tile
// position
- if (abs(quantizedCoords.z - startingCoords.z) > maxStepHeight)
+ if (abs(quantizedCoords.z - startingCoords.z) > kMaxStepHeight)
continue;
// Compute initial cost based upon the distance from the
@@ -1646,7 +1646,7 @@ void PathRequest::finish(void) {
if (cell->direction != dirInvalid) {
if (cell->direction != prevDir
- || abs(cell->height - prevHeight) > maxStepHeight) {
+ || abs(cell->height - prevHeight) > kMaxStepHeight) {
if (res <= tempResult) break;
coords.u =
@@ -1871,7 +1871,7 @@ PathResult PathRequest::findPath(void) {
&testPlatform);
// Determine if elevation change is too great
- if (abs(testPt.z - prevZ) <= maxStepHeight)
+ if (abs(testPt.z - prevZ) <= kMaxStepHeight)
prevZ = testPt.z;
else
goto big_continue;
@@ -1917,7 +1917,7 @@ PathResult PathRequest::findPath(void) {
&& trv->min.v < actorVolume.max.v
&& actorVolume.min.v < trv->max.v
&& trv->min.z < actorVolume.max.z
- && actorVolume.min.z + maxStepHeight
+ && actorVolume.min.z + kMaxStepHeight
< trv->max.z)
goto big_continue;
}
@@ -2002,8 +2002,8 @@ PathResult PathRequest::findPath(void) {
// (i.e. don't jmup off of cliffs). Also we can
// only climb steps below a certain height.
-// if ( testPt.z < centerPt.z - maxJumpStep
-// || testPt.z > centerPt.z + maxStepHeight)
+// if ( testPt.z < centerPt.z - kMaxJumpStep
+// || testPt.z > centerPt.z + kMaxStepHeight)
// continue;
// Turns are expensive, the sharper turns are more so.
@@ -2136,7 +2136,7 @@ bool DestinationPathRequest::setCenter(
bestDist = centerCost;
// If we're at target square, then we're done!
- if (dist == 0 && zDist <= maxStepHeight) {
+ if (dist == 0 && zDist <= kMaxStepHeight) {
flags |= PathRequest::completed;
// Return true to indicate that the path finding is done.
@@ -2541,7 +2541,7 @@ TilePoint selectNearbySite(
// If the object is higher than the actor's head, or
// low enough to step over, then ignore it.
if (objLoc.z >= startingCoords.z + 80
- || objLoc.z + objProto->height <= startingCoords.z + maxStepHeight / 2) {
+ || objLoc.z + objProto->height <= startingCoords.z + kMaxStepHeight / 2) {
continue;
}
@@ -2665,7 +2665,7 @@ TilePoint selectNearbySite(
testPt.z = tileSlopeHeight(testPt, mapNum, 68, &sti);
// If it's too high to step, then don't continue
-// if (testPt.z - qi.z > maxStepHeight) continue;
+// if (testPt.z - qi.z > kMaxStepHeight) continue;
fromSubPt = centerPt;
for (i = 0; i < kTileSubSize; i++) {
int16 deltaZ;
@@ -2677,7 +2677,7 @@ TilePoint selectNearbySite(
deltaZ = toSubPt.z - fromSubPt.z;
// If it's too high to step, then don't continue
- if (deltaZ > maxStepHeight || deltaZ < -(maxStepHeight * 2)) {
+ if (deltaZ > kMaxStepHeight || deltaZ < -(kMaxStepHeight * 2)) {
traversable = false;
break;
}
@@ -2877,7 +2877,7 @@ bool checkPath(
// If the height difference is too great skip this tile
// position
- if (abs(quantizedCoords.z - startingCoords.z) > maxStepHeight)
+ if (abs(quantizedCoords.z - startingCoords.z) > kMaxStepHeight)
continue;
// Compute initial cost based upon the distance from the
@@ -2971,7 +2971,7 @@ bool checkPath(
deltaZ = toSubPt.z - fromSubPt.z;
// If it's too high to step, then don't continue
- if (deltaZ > maxStepHeight || deltaZ < -(maxStepHeight * 2)) {
+ if (deltaZ > kMaxStepHeight || deltaZ < -(kMaxStepHeight * 2)) {
traversable = false;
break;
}
@@ -3004,7 +3004,7 @@ bool checkPath(
// If the resulting height is significantly different
// from the destination height, assume we're on a
// different level and return false.
- return abs(testPt.z - destCoords.z) <= maxStepHeight;
+ return abs(testPt.z - destCoords.z) <= kMaxStepHeight;
}
diff --git a/engines/saga2/spelcast.cpp b/engines/saga2/spelcast.cpp
index a7da521749..0e834f3c7e 100644
--- a/engines/saga2/spelcast.cpp
+++ b/engines/saga2/spelcast.cpp
@@ -1018,7 +1018,7 @@ GameObject *objectNollision(Effectron *obj, const TilePoint &loc) {
volume.max.z = loc.z + obj->hgtCall();
// Adjust MIN Z for the fact that they can step over obstacles.
- //if ( isActor( obj )) volume.min.z += maxStepHeight / 2;
+ //if ( isActor( obj )) volume.min.z += kMaxStepHeight / 2;
// Constructor
CircularObjectIterator iter(obj->world(), loc, obj->brdCall() + 32);
diff --git a/engines/saga2/task.cpp b/engines/saga2/task.cpp
index 0d5141b328..d4f8f350be 100644
--- a/engines/saga2/task.cpp
+++ b/engines/saga2/task.cpp
@@ -4362,7 +4362,7 @@ bool BandTask::atTarget(void) {
TilePoint actorLoc = stack->getActor()->getLocation();
if ((actorLoc - currentTarget).quickHDistance() > 6
- || abs(actorLoc.z - currentTarget.z) > maxStepHeight) {
+ || abs(actorLoc.z - currentTarget.z) > kMaxStepHeight) {
if (attend != NULL) {
attend->abortTask();
delete attend;
@@ -4699,7 +4699,7 @@ TaskResult FollowPatrolRouteTask::handleFollowPatrolRoute(void) {
== (currentWayPoint.u >> kTileUVShift)
&& (actorLoc.v >> kTileUVShift)
== (currentWayPoint.v >> kTileUVShift)
- && abs(actorLoc.z - currentWayPoint.z) <= maxStepHeight) {
+ && abs(actorLoc.z - currentWayPoint.z) <= kMaxStepHeight) {
// Delete the gotoWayPoint task
if (gotoWayPoint != NULL) {
gotoWayPoint->abortTask();
diff --git a/engines/saga2/terrain.cpp b/engines/saga2/terrain.cpp
index 04acf2eeae..572e136255 100644
--- a/engines/saga2/terrain.cpp
+++ b/engines/saga2/terrain.cpp
@@ -64,7 +64,7 @@ void lavaDamage(GameObject *obj) {
return;
}
if (g_vm->_rnd->getRandomNumber(heatDamageOddsYes + heatDamageOddsNo - 1) > heatDamageOddsNo - 1) {
- obj->acceptDamage(obj->thisID(), heatDamagePerFrame, damageHeat, heatDamageDicePerFrame, 6);
+ obj->acceptDamage(obj->thisID(), heatDamagePerFrame, kDamageHeat, heatDamageDicePerFrame, 6);
}
}
@@ -75,19 +75,19 @@ void coldDamage(GameObject *obj) {
return;
}
if (g_vm->_rnd->getRandomNumber(coldDamageOddsYes + coldDamageOddsNo - 1) > coldDamageOddsNo - 1) {
- obj->acceptDamage(obj->thisID(), coldDamagePerFrame, damageCold, coldDamageDicePerFrame, 6);
+ obj->acceptDamage(obj->thisID(), coldDamagePerFrame, kDamageCold, coldDamageDicePerFrame, 6);
}
}
void terrainDamageSlash(GameObject *obj) {
if (g_vm->_rnd->getRandomNumber(terrainDamageOddsYes + terrainDamageOddsNo - 1) > terrainDamageOddsNo - 1) {
- obj->acceptDamage(obj->thisID(), terrainDamagePerFrame, damageSlash, terrainDamageDicePerFrame, 6);
+ obj->acceptDamage(obj->thisID(), terrainDamagePerFrame, kDamageSlash, terrainDamageDicePerFrame, 6);
}
}
void terrainDamageBash(GameObject *obj) {
if (g_vm->_rnd->getRandomNumber(terrainDamageOddsYes + terrainDamageOddsNo - 1) > terrainDamageOddsNo - 1) {
- obj->acceptDamage(obj->thisID(), terrainDamagePerFrame, damageImpact, terrainDamageDicePerFrame, 6);
+ obj->acceptDamage(obj->thisID(), terrainDamagePerFrame, kDamageImpact, terrainDamageDicePerFrame, 6);
}
}
@@ -195,7 +195,7 @@ uint32 tileTerrain(
// catwalks and other surfaces which have no bottom.
if ((terrainResult & terrainSolidSurface)
- && height > minZ + maxStepHeight) {
+ && height > minZ + kMaxStepHeight) {
terrainResult |= terrainStone;
}
@@ -858,7 +858,7 @@ int16 checkWalkable(
supportHeight = tileSlopeHeight(loc, obj, &sti);
- if (supportHeight < loc.z - maxStepHeight * 4)
+ if (supportHeight < loc.z - kMaxStepHeight * 4)
return blockageTerrain;
if (sti.surfaceTile != NULL) {
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 9296d5add4..eeab72e020 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -4161,8 +4161,8 @@ TilePoint pickTile(Point32 pos,
// down levels, only search for surfaces which could be stepped
// on by the protagonist.
mag = (coords - protagPos).quickHDistance();
- zMin = protagPos.z - maxPickHeight - mag;
- zMax = protagPos.z + maxPickHeight + mag;
+ zMin = protagPos.z - kMaxPickHeight - mag;
+ zMax = protagPos.z + kMaxPickHeight + mag;
// Compute the coords of the actual tile that they clicked on.
tileCoords = coords >> kTileUVShift;
@@ -4184,7 +4184,7 @@ TilePoint pickTile(Point32 pos,
mt = curMap->lookupMeta(mCoords);
// While we are less than the pick altitude
- while (relPos.y < zMax + kTileDX + maxStepHeight - abs(relPos.x >> 1)) {
+ while (relPos.y < zMax + kTileDX + kMaxStepHeight - abs(relPos.x >> 1)) {
// If there is a metatile on this spot
if (mt != nullptr) {
// Iterate through all platforms
@@ -4213,7 +4213,7 @@ TilePoint pickTile(Point32 pos,
continue;
// Reject the tile if it's too high.
- if (sti.surfaceHeight > zMax + maxStepHeight) continue;
+ if (sti.surfaceHeight > zMax + kMaxStepHeight) continue;
// Reject the tile if mouse position is below lower tile
// boundary
@@ -4299,8 +4299,8 @@ TilePoint pickTile(Point32 pos,
// Compute new altitude range based upon the tile position
// relative to the protaganist's position.
- zMin = protagPos.z - maxPickHeight - (coords - protagPos).quickHDistance();
- zMax = protagPos.z + maxPickHeight + (coords - protagPos).quickHDistance();
+ zMin = protagPos.z - kMaxPickHeight - (coords - protagPos).quickHDistance();
+ zMax = protagPos.z + kMaxPickHeight + (coords - protagPos).quickHDistance();
}
// If no tile was found, return the default.
Commit: 245f5869033724da2b007affcc548402f8d7cf45
https://github.com/scummvm/scummvm/commit/245f5869033724da2b007affcc548402f8d7cf45
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:16+02:00
Commit Message:
SAGA2: More details on address debugging
Changed paths:
engines/saga2/interp.cpp
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index abb3eba89a..79594ea69c 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -255,9 +255,11 @@ uint8 *byteAddress(Thread *th, uint8 **pcPtr) {
IMMED_WORD(offset);
arg = (uint16 *)(th->stackBase + th->framePtr + 8);
*pcPtr = pc;
- debugC(3, kDebugScripts, "byteAddress: this[%d]", offset);
- if (arg[0] == dataSegIndex)
+ if (arg[0] == dataSegIndex) {
+ debugC(3, kDebugScripts, "byteAddress: thisD[%d] = %d", offset, dataSegment[arg[1] + offset]);
return &dataSegment[arg[1] + offset];
+ }
+ debugC(3, kDebugScripts, "byteAddress: thisS[%d] = %d", offset, *segmentArrayAddress(arg[0], arg[1]) + offset);
return segmentArrayAddress(arg[0], arg[1]) + offset;
case addr_deref:
Commit: 2a093b51d217687fcdcec0bfa384cdb519347714
https://github.com/scummvm/scummvm/commit/2a093b51d217687fcdcec0bfa384cdb519347714
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:16+02:00
Commit Message:
SAGA2: Fix debug output
Changed paths:
engines/saga2/interp.cpp
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 79594ea69c..1b02b9b797 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -259,7 +259,7 @@ uint8 *byteAddress(Thread *th, uint8 **pcPtr) {
debugC(3, kDebugScripts, "byteAddress: thisD[%d] = %d", offset, dataSegment[arg[1] + offset]);
return &dataSegment[arg[1] + offset];
}
- debugC(3, kDebugScripts, "byteAddress: thisS[%d] = %d", offset, *segmentArrayAddress(arg[0], arg[1]) + offset);
+ debugC(3, kDebugScripts, "byteAddress: thisS[%d] = %d", offset, *(segmentArrayAddress(arg[0], arg[1]) + offset));
return segmentArrayAddress(arg[0], arg[1]) + offset;
case addr_deref:
Commit: ac62a48ace6fd44be24bf25af171d3c660c81ad2
https://github.com/scummvm/scummvm/commit/ac62a48ace6fd44be24bf25af171d3c660c81ad2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:16+02:00
Commit Message:
SAGA2: Improve stack debug output
Changed paths:
engines/saga2/interp.cpp
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 1b02b9b797..3f80668964 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -518,7 +518,7 @@ static void print_stack(int16 *stackBase, int16 *stack) {
end = stack + STACK_PRINT_DEPTH;
debugCN(2, kDebugScripts, "stack size: %d: [", size);
- for (int16 *i = stack; i <= end; i++)
+ for (int16 *i = stack; i < end; i++)
debugCN(2, kDebugScripts, "%d ", *i);
if (size > STACK_PRINT_DEPTH)
debugCN(2, kDebugScripts, "... ");
@@ -526,7 +526,7 @@ static void print_stack(int16 *stackBase, int16 *stack) {
debugC(2, kDebugScripts, "]");
}
-#define D_OP(x) debugC(1, kDebugScripts, "[%04ld]: %s", (pc - codeSeg), #x)
+#define D_OP(x) debugC(1, kDebugScripts, "[%04ld 0x%04x]: %s", (pc - codeSeg - 1), (pc - codeSeg - 1), #x)
bool Thread::interpret(void) {
uint8 *pc,
Commit: 23d841a04a1b8a77918abeeb32aae5cbace878cb
https://github.com/scummvm/scummvm/commit/23d841a04a1b8a77918abeeb32aae5cbace878cb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:16+02:00
Commit Message:
SAGA2: Make ActiveItem script-friendly
Changed paths:
engines/saga2/interp.cpp
engines/saga2/magic.cpp
engines/saga2/motion.cpp
engines/saga2/path.cpp
engines/saga2/sagafunc.cpp
engines/saga2/speldefs.h
engines/saga2/tile.cpp
engines/saga2/tile.h
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 3f80668964..4fa2e79de2 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -89,7 +89,7 @@ uint8 *builtinObjectAddress(int16 segment, uint16 index) {
return (uint8 *)GameObject::objectAddress(index);
case builtinTypeTAG:
- return (uint8 *)ActiveItem::activeItemAddress(index);
+ return (uint8 *)(&ActiveItem::activeItemAddress(index)->_data);
case builtinAbstract:
assert(index > 0);
@@ -138,7 +138,7 @@ uint16 *builtinVTableAddress(int16 btype, uint8 *addr, CallTable **callTab) {
case builtinTypeTAG:
aItem = (ActiveItem *)addr;
- script = aItem->scriptClassID;
+ script = aItem->_data.scriptClassID;
*callTab = &tagCFuncs;
if (script <= 0)
@@ -486,15 +486,12 @@ void print_script_name(uint8 *codePtr, char *descr = NULL) {
char *objectName(int16 segNum, uint16 segOff) {
//static nameBuf[64];
- uint8 *objAddr;
if (segNum >= 0)
return "SagaObject";
- objAddr = builtinObjectAddress(segNum, segOff);
-
switch (segNum) {
case builtinTypeObject:
- return ((GameObject *)objAddr)->objName();
+ return GameObject::objectAddress(segOff)->objName();
case builtinTypeTAG:
return "Tag";
@@ -526,7 +523,7 @@ static void print_stack(int16 *stackBase, int16 *stack) {
debugC(2, kDebugScripts, "]");
}
-#define D_OP(x) debugC(1, kDebugScripts, "[%04ld 0x%04x]: %s", (pc - codeSeg - 1), (pc - codeSeg - 1), #x)
+#define D_OP(x) debugC(1, kDebugScripts, "[%04ld 0x%04lx]: %s", (pc - codeSeg - 1), (pc - codeSeg - 1), #x)
bool Thread::interpret(void) {
uint8 *pc,
@@ -1922,10 +1919,10 @@ scriptResult runTagMethod(
ActiveItemPtr aItem;
assert(aItem = ActiveItem::activeItemAddress(index));
- if (!aItem->scriptClassID)
+ if (!aItem->_data.scriptClassID)
return scriptResultNoScript;
- return runMethod(aItem->scriptClassID,
+ return runMethod(aItem->_data.scriptClassID,
builtinTypeTAG,
index,
methodNum,
diff --git a/engines/saga2/magic.cpp b/engines/saga2/magic.cpp
index a4f4d3e75b..8b414b3c65 100644
--- a/engines/saga2/magic.cpp
+++ b/engines/saga2/magic.cpp
@@ -318,7 +318,7 @@ bool implementSpell(GameObject *enactor, ActiveItem *target, SkillProto *spell)
return implementSpell(enactor, l, spell);
}
assert(sProto.shouldTarget(spellApplyTAG));
- assert(target->itemType == activeTypeInstance);
+ assert(target->_data.itemType == activeTypeInstance);
ActorManaID ami = (ActorManaID)(sProto.getManaType());
diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp
index be69eefc44..85f4aa2fe1 100644
--- a/engines/saga2/motion.cpp
+++ b/engines/saga2/motion.cpp
@@ -1874,14 +1874,14 @@ void MotionTask::castSpell(Actor &a, SkillProto &spell, ActiveItem &target) {
if ((mt = mTaskList.newTask(&a)) != NULL) {
if (mt->motionType != type) {
Location loc;
- assert(target.itemType == activeTypeInstance);
+ assert(target._data.itemType == activeTypeInstance);
mt->motionType = type;
mt->spellObj = &spell;
mt->targetTAG = ⌖
loc = Location(
- target.instance.u << kTileUVShift,
- target.instance.v << kTileUVShift,
- target.instance.h,
+ target._data.instance.u << kTileUVShift,
+ target._data.instance.v << kTileUVShift,
+ target._data.instance.h,
a.world()->thisID());
mt->targetLoc = loc; //target;
mt->flags = reset | TAGTarg;
@@ -3690,7 +3690,7 @@ void MotionTask::castSpellAction(void) {
if (actionCounter == 0) {
if (spellObj) {
if (flags & TAGTarg) {
- assert(targetTAG->itemType == activeTypeInstance);
+ assert(targetTAG->_data.itemType == activeTypeInstance);
spellObj->implementAction(spellObj->getSpellID(), a->thisID(), targetTAG->thisID());
} else if (flags & LocTarg) {
spellObj->implementAction(spellObj->getSpellID(), a->thisID(), targetLoc);
@@ -4428,12 +4428,12 @@ void MotionTask::updatePositions(void) {
ActiveItem *TAG = mt->o.TAI->getGroup();
// Compute in points the region of the TAI
- TAIReg.min.u = mt->o.TAI->instance.u << kTileUVShift;
- TAIReg.min.v = mt->o.TAI->instance.v << kTileUVShift;
+ TAIReg.min.u = mt->o.TAI->_data.instance.u << kTileUVShift;
+ TAIReg.min.v = mt->o.TAI->_data.instance.v << kTileUVShift;
TAIReg.max.u = TAIReg.min.u
- + (TAG->group.uSize << kTileUVShift);
+ + (TAG->_data.group.uSize << kTileUVShift);
TAIReg.max.v = TAIReg.min.v
- + (TAG->group.vSize << kTileUVShift);
+ + (TAG->_data.group.vSize << kTileUVShift);
TAIReg.min.z = TAIReg.max.z = 0;
// Find the point on the TAI closest to the actor
@@ -4488,12 +4488,12 @@ void MotionTask::updatePositions(void) {
ActiveItem *TAG = mt->o.TAI->getGroup();
// Compute in points the region of the TAI
- TAIReg.min.u = mt->o.TAI->instance.u << kTileUVShift;
- TAIReg.min.v = mt->o.TAI->instance.v << kTileUVShift;
+ TAIReg.min.u = mt->o.TAI->_data.instance.u << kTileUVShift;
+ TAIReg.min.v = mt->o.TAI->_data.instance.v << kTileUVShift;
TAIReg.max.u = TAIReg.min.u
- + (TAG->group.uSize << kTileUVShift);
+ + (TAG->_data.group.uSize << kTileUVShift);
TAIReg.max.v = TAIReg.min.v
- + (TAG->group.vSize << kTileUVShift);
+ + (TAG->_data.group.vSize << kTileUVShift);
TAIReg.min.z = TAIReg.max.z = 0;
// Find the point on the TAI closest to the actor
diff --git a/engines/saga2/path.cpp b/engines/saga2/path.cpp
index 20aec1ebaf..5af53ffe5f 100644
--- a/engines/saga2/path.cpp
+++ b/engines/saga2/path.cpp
@@ -382,9 +382,9 @@ void PathTileRegion::fetchSubMeta(const TilePoint &subMeta) {
tagV = v - ((tr->flags >> 4) & 0x07);
subMetaTag.min.u = tagU;
- subMetaTag.max.u = tagU + groupItem->group.uSize;
+ subMetaTag.max.u = tagU + groupItem->_data.group.uSize;
subMetaTag.min.v = tagV;
- subMetaTag.max.v = tagV + groupItem->group.vSize;
+ subMetaTag.max.v = tagV + groupItem->_data.group.vSize;
if (subMetaTag.min.u < tileReg.min.u)
subMetaTag.min.u = tileReg.min.u;
@@ -407,11 +407,11 @@ void PathTileRegion::fetchSubMeta(const TilePoint &subMeta) {
if (instanceItem) state = instanceItem->getInstanceState(mapNum);
stateData = &(map->activeItemData)[
- groupItem->group.grDataOffset
- + state * groupItem->group.animArea];
+ groupItem->_data.group.grDataOffset
+ + state * groupItem->_data.group.animArea];
for (tempU = subMetaTag.min.u; tempU < subMetaTag.max.u; tempU++) {
- TileRef *rowData = &stateData[(tempU - tagU) * groupItem->group.vSize];
+ TileRef *rowData = &stateData[(tempU - tagU) * groupItem->_data.group.vSize];
PathTilePosInfo *tempArrRow = &array[(tempU + offset.u) * area.v];
for (tempV = subMetaTag.min.v; tempV < subMetaTag.max.v; tempV++) {
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index 5ac4200fdc..8ab77f1edb 100644
--- a/engines/saga2/sagafunc.cpp
+++ b/engines/saga2/sagafunc.cpp
@@ -2390,7 +2390,7 @@ int16 scriptTagNumAssoc(int16 *args) {
MONOLOG(TAG::NumAssoc);
ActiveItem *ai = (ActiveItem *)thisThread->thisObject;
- return ai->numAssociations;
+ return ai->_data.numAssociations;
}
//-----------------------------------------------------------------------
@@ -2403,11 +2403,11 @@ int16 scriptTagAssoc(int16 *args) {
int mapNum = ai->getMapNum();
assert(args[0] >= 0);
- assert(args[0] < ai->numAssociations);
+ assert(args[0] < ai->_data.numAssociations);
assert(mapNum >= 0);
assert(mapNum < 8);
- return (mapList[mapNum].assocList)[ai->associationOffset + args[0]];
+ return (mapList[mapNum].assocList)[ai->_data.associationOffset + args[0]];
}
//-----------------------------------------------------------------------
@@ -2418,7 +2418,7 @@ int16 scriptTagGetTargetU(int16 *args) {
MONOLOG(TAG::GetTargetU);
ActiveItem *ai = (ActiveItem *)thisThread->thisObject;
- return ai->instance.targetU;
+ return ai->_data.instance.targetU;
}
//-----------------------------------------------------------------------
@@ -2429,7 +2429,7 @@ int16 scriptTagGetTargetV(int16 *) {
MONOLOG(TAG::GetTargetV);
ActiveItem *ai = (ActiveItem *)thisThread->thisObject;
- return ai->instance.targetV;
+ return ai->_data.instance.targetV;
}
//-----------------------------------------------------------------------
@@ -2440,7 +2440,7 @@ int16 scriptTagGetTargetZ(int16 *) {
MONOLOG(TAG::GetTargetZ);
ActiveItem *ai = (ActiveItem *)thisThread->thisObject;
- return ai->instance.targetZ;
+ return ai->_data.instance.targetZ;
}
//-----------------------------------------------------------------------
@@ -2451,7 +2451,7 @@ int16 scriptTagGetTargetW(int16 *) {
MONOLOG(TAG::GetTargetW);
ActiveItem *ai = (ActiveItem *)thisThread->thisObject;
- return ai->instance.worldNum;
+ return ai->_data.instance.worldNum;
}
//-----------------------------------------------------------------------
@@ -2524,7 +2524,7 @@ int16 scriptTagSetAnimation(int16 *args) {
#endif
// Assert that the state is valid
assert(args[1] >= 0);
- assert(args[1] < ai->getGroup()->group.numStates);
+ assert(args[1] < ai->getGroup()->_data.group.numStates);
// If soundID is not NULL, then play the sound
if (soundID) playSoundAt(soundID, ail);
diff --git a/engines/saga2/speldefs.h b/engines/saga2/speldefs.h
index 08c64a9cb0..1e0f0e8398 100644
--- a/engines/saga2/speldefs.h
+++ b/engines/saga2/speldefs.h
@@ -115,11 +115,11 @@ typedef GameObject SpellCaster;
inline TilePoint TAGPos(ActiveItem *ai) {
if (ai == NULL) return Nowhere;
- assert(ai->itemType == activeTypeInstance);
+ assert(ai->_data.itemType == activeTypeInstance);
return TilePoint(
- ai->instance.u << kTileUVShift,
- ai->instance.v << kTileUVShift,
- ai->instance.h);
+ ai->_data.instance.u << kTileUVShift,
+ ai->_data.instance.v << kTileUVShift,
+ ai->_data.instance.h);
}
inline TilePoint objPos(GameObject *go) {
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index eeab72e020..f0be3c6b13 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -374,9 +374,9 @@ ObjectID ActiveItem::getInstanceContext(void) {
// Return the Location for a TAG
Location ActiveItem::getInstanceLocation(void) {
- return Location(instance.u << kTileUVShift,
- instance.v << kTileUVShift,
- instance.h << kTileZShift,
+ return Location(_data.instance.u << kTileUVShift,
+ _data.instance.v << kTileUVShift,
+ _data.instance.h << kTileZShift,
getInstanceContext());
}
@@ -414,7 +414,7 @@ bool ActiveItem::use(ObjectID enactor) {
ActiveItem *groupPtr = activeItemAddress(
ActiveItemID(
getMapNum(),
- instance.groupID));
+ _data.instance.groupID));
return groupPtr->use(this, enactor);
}
@@ -427,7 +427,7 @@ bool ActiveItem::trigger(ObjectID enactor, ObjectID objID) {
ActiveItem *groupPtr = activeItemAddress(
ActiveItemID(
getMapNum(),
- instance.groupID));
+ _data.instance.groupID));
return groupPtr->trigger(this, enactor, objID);
}
@@ -440,7 +440,7 @@ bool ActiveItem::release(ObjectID enactor, ObjectID objID) {
ActiveItem *groupPtr = activeItemAddress(
ActiveItemID(
getMapNum(),
- instance.groupID));
+ _data.instance.groupID));
return groupPtr->release(this, enactor, objID);
}
@@ -453,7 +453,7 @@ bool ActiveItem::acceptLockToggle(ObjectID enactor, uint8 keyCode) {
ActiveItem *groupPtr = activeItemAddress(
ActiveItemID(
getMapNum(),
- instance.groupID));
+ _data.instance.groupID));
return groupPtr->acceptLockToggle(this, enactor, keyCode);
}
@@ -466,12 +466,12 @@ bool ActiveItem::inRange(const TilePoint &loc, int16 range) {
ActiveItem *groupPtr = activeItemAddress(
ActiveItemID(
getMapNum(),
- instance.groupID));
+ _data.instance.groupID));
- return loc.u >= instance.u - range
- && loc.v >= instance.v - range
- && loc.u < instance.u + groupPtr->group.uSize + range
- && loc.v < instance.v + groupPtr->group.vSize + range;
+ return loc.u >= _data.instance.u - range
+ && loc.v >= _data.instance.v - range
+ && loc.u < _data.instance.u + groupPtr->_data.group.uSize + range
+ && loc.v < _data.instance.v + groupPtr->_data.group.vSize + range;
}
//-----------------------------------------------------------------------
@@ -491,7 +491,7 @@ bool ActiveItem::use(ActiveItem *ins, ObjectID enactor) {
uint16 state = ins->getInstanceState(mapNum);
scriptCallFrame scf;
- if (ins->scriptClassID != 0) {
+ if (ins->_data.scriptClassID != 0) {
// Set up the arguments we want to pass to the script
scf.invokedTAI = ins->thisID();
@@ -500,10 +500,10 @@ bool ActiveItem::use(ActiveItem *ins, ObjectID enactor) {
scf.indirectObject = Nothing;
// Fill in other params with data from TAG struct
- scf.value = ins->instance.worldNum;
- scf.coords.u = ins->instance.targetU;
- scf.coords.v = ins->instance.targetV;
- scf.coords.z = ins->instance.targetZ;
+ scf.value = ins->_data.instance.worldNum;
+ scf.coords.u = ins->_data.instance.targetU;
+ scf.coords.v = ins->_data.instance.targetV;
+ scf.coords.z = ins->_data.instance.targetZ;
if (runTagMethod(
scf.invokedTAI,
@@ -560,7 +560,7 @@ bool ActiveItem::trigger(ActiveItem *ins, ObjectID enactor, ObjectID objID) {
&& (!isActor(obj) || (Actor *)obj != getCenterActor()))
return true;
- if (ins->scriptClassID != 0) {
+ if (ins->_data.scriptClassID != 0) {
// Set up the arguments we want to pass to the script
scf.invokedTAI = ins->thisID();
@@ -580,12 +580,12 @@ bool ActiveItem::trigger(ActiveItem *ins, ObjectID enactor, ObjectID objID) {
// Mark the object as triggering this TAG
obj->setTriggeringTAG(true);
- instanceRegion.min.u = ins->instance.u << kTileUVShift;
- instanceRegion.min.v = ins->instance.v << kTileUVShift;
+ instanceRegion.min.u = ins->_data.instance.u << kTileUVShift;
+ instanceRegion.min.v = ins->_data.instance.v << kTileUVShift;
instanceRegion.max.u = instanceRegion.min.u
- + (group.uSize << kTileUVShift);
+ + (_data.group.uSize << kTileUVShift);
instanceRegion.max.v = instanceRegion.min.v
- + (group.vSize << kTileUVShift);
+ + (_data.group.vSize << kTileUVShift);
RegionalObjectIterator iter(
world,
@@ -604,7 +604,7 @@ bool ActiveItem::trigger(ActiveItem *ins, ObjectID enactor, ObjectID objID) {
// if ( proto->mass < group.triggerWeight ) return false;
- if (ins->scriptClassID != 0) {
+ if (ins->_data.scriptClassID != 0) {
// Set up the arguments we want to pass to the script
scf.invokedTAI = ins->thisID();
@@ -613,10 +613,10 @@ bool ActiveItem::trigger(ActiveItem *ins, ObjectID enactor, ObjectID objID) {
scf.indirectObject = objID;
// Fill in other params with data from TAG struct
- scf.value = ins->instance.worldNum;
- scf.coords.u = ins->instance.targetU;
- scf.coords.v = ins->instance.targetV;
- scf.coords.z = ins->instance.targetZ;
+ scf.value = ins->_data.instance.worldNum;
+ scf.coords.u = ins->_data.instance.targetU;
+ scf.coords.v = ins->_data.instance.targetV;
+ scf.coords.z = ins->_data.instance.targetZ;
if (runTagMethod(
scf.invokedTAI,
@@ -638,12 +638,12 @@ bool ActiveItem::trigger(ActiveItem *ins, ObjectID enactor, ObjectID objID) {
if (isActor(obj) && (a = (Actor *)obj) == getCenterActor()) {
transportCenterBand(
Location(
- (ins->instance.targetU << kTileUVShift)
+ (ins->_data.instance.targetU << kTileUVShift)
+ kTileUVSize / 2,
- (ins->instance.targetV << kTileUVShift)
+ (ins->_data.instance.targetV << kTileUVShift)
+ kTileUVSize / 2,
- (int16)ins->instance.targetZ << 3,
- ins->instance.worldNum + WorldBaseID));
+ (int16)ins->_data.instance.targetZ << 3,
+ ins->_data.instance.worldNum + WorldBaseID));
}
}
break;
@@ -668,12 +668,12 @@ bool ActiveItem::release(ActiveItem *ins, ObjectID enactor, ObjectID objID) {
if (obj->isTriggeringTAG()) obj->setTriggeringTAG(false);
- instanceRegion.min.u = ins->instance.u << kTileUVShift;
- instanceRegion.min.v = ins->instance.v << kTileUVShift;
+ instanceRegion.min.u = ins->_data.instance.u << kTileUVShift;
+ instanceRegion.min.v = ins->_data.instance.v << kTileUVShift;
instanceRegion.max.u = instanceRegion.min.u
- + (group.uSize << kTileUVShift);
+ + (_data.group.uSize << kTileUVShift);
instanceRegion.max.v = instanceRegion.min.v
- + (group.vSize << kTileUVShift);
+ + (_data.group.vSize << kTileUVShift);
RegionalObjectIterator iter(
world,
@@ -690,7 +690,7 @@ bool ActiveItem::release(ActiveItem *ins, ObjectID enactor, ObjectID objID) {
return true;
}
- if (ins->scriptClassID != 0) {
+ if (ins->_data.scriptClassID != 0) {
// Set up the arguments we want to pass to the script
scf.invokedTAI = ins->thisID();
@@ -699,10 +699,10 @@ bool ActiveItem::release(ActiveItem *ins, ObjectID enactor, ObjectID objID) {
scf.indirectObject = objID;
// Fill in other params with data from TAG struct
- scf.value = ins->instance.worldNum;
- scf.coords.u = ins->instance.targetU;
- scf.coords.v = ins->instance.targetV;
- scf.coords.z = ins->instance.targetZ;
+ scf.value = ins->_data.instance.worldNum;
+ scf.coords.u = ins->_data.instance.targetU;
+ scf.coords.v = ins->_data.instance.targetV;
+ scf.coords.z = ins->_data.instance.targetZ;
if (runTagMethod(
scf.invokedTAI,
@@ -726,7 +726,7 @@ bool ActiveItem::acceptLockToggle(ActiveItem *ins, ObjectID enactor, uint8 keyCo
kTileUVShift;
scriptCallFrame scf;
- if (ins->scriptClassID != 0) {
+ if (ins->_data.scriptClassID != 0) {
// Set up the arguments we want to pass to the script
scf.invokedTAI = ins->thisID();
@@ -773,7 +773,7 @@ bool ActiveItem::acceptLockToggle(ActiveItem *ins, ObjectID enactor, uint8 keyCo
//-----------------------------------------------------------------------
TilePoint getClosestPointOnTAI(ActiveItem *TAI, GameObject *obj) {
- assert(TAI->itemType == activeTypeInstance);
+ assert(TAI->_data.itemType == activeTypeInstance);
TilePoint objLoc = obj->getLocation(),
TAILoc;
@@ -781,18 +781,18 @@ TilePoint getClosestPointOnTAI(ActiveItem *TAI, GameObject *obj) {
ActiveItem *TAG = TAI->getGroup();
// Compute in points the region of the TAI
- TAIReg.min.u = TAI->instance.u << kTileUVShift;
- TAIReg.min.v = TAI->instance.v << kTileUVShift;
+ TAIReg.min.u = TAI->_data.instance.u << kTileUVShift;
+ TAIReg.min.v = TAI->_data.instance.v << kTileUVShift;
TAIReg.max.u = TAIReg.min.u
- + (TAG->group.uSize << kTileUVShift);
+ + (TAG->_data.group.uSize << kTileUVShift);
TAIReg.max.v = TAIReg.min.v
- + (TAG->group.vSize << kTileUVShift);
+ + (TAG->_data.group.vSize << kTileUVShift);
TAIReg.min.z = TAIReg.max.z = 0;
// Find the point on the TAI closest to the object
TAILoc.u = clamp(TAIReg.min.u - 1, objLoc.u, TAIReg.max.u);
TAILoc.v = clamp(TAIReg.min.v - 1, objLoc.v, TAIReg.max.v);
- TAILoc.z = TAI->instance.h + obj->proto()->height / 2;
+ TAILoc.z = TAI->_data.instance.h + obj->proto()->height / 2;
return TAILoc;
}
@@ -867,13 +867,13 @@ void saveActiveItemStates(SaveFileConstructor &saveGame) {
ActiveItem *activeItem = activeItemList->_items[j];
uint8 *statePtr;
- if (activeItem->itemType != activeTypeInstance)
+ if (activeItem->_data.itemType != activeTypeInstance)
continue;
// Get a pointer to the current active item's state
// data in the archive buffer
statePtr =
- &bufferedStateArray[activeItem->instance.stateIndex];
+ &bufferedStateArray[activeItem->_data.instance.stateIndex];
// Set the high bit of the state value based upon the
// active item's locked state
@@ -936,13 +936,13 @@ void loadActiveItemStates(SaveFileReader &saveGame) {
ActiveItem *activeItem = activeItemList->_items[j];
uint8 *statePtr;
- if (activeItem->itemType != activeTypeInstance)
+ if (activeItem->_data.itemType != activeTypeInstance)
continue;
// Get a pointer to the current active item's state
// data in the archive buffer
statePtr =
- &bufferedStateArray[activeItem->instance.stateIndex];
+ &bufferedStateArray[activeItem->_data.instance.stateIndex];
// Reset the locked state of the active item based
// upon the high bit of the buffered state value
@@ -1478,22 +1478,23 @@ MetaTileList::~MetaTileList() {
ActiveItem::ActiveItem(ActiveItemList *parent, int ind, Common::SeekableReadStream *stream) {
_parent = parent;
_index = ind;
- nextHash = nullptr;
+ _nextHash = nullptr;
stream->readUint32LE();
- scriptClassID = stream->readUint16LE();
- associationOffset = stream->readUint16LE();
- numAssociations = stream->readByte();
- itemType = stream->readByte();
- instance.groupID = stream->readUint16LE();
- instance.u = stream->readSint16LE();
- instance.v = stream->readSint16LE();
- instance.v = stream->readSint16LE();
- instance.stateIndex = stream->readUint16LE();
- instance.scriptFlags = stream->readUint16LE();
- instance.targetU = stream->readUint16LE();
- instance.targetV = stream->readUint16LE();
- instance.targetZ = stream->readByte();
- instance.worldNum = stream->readByte();
+ _data.nextHashDummy = 0;
+ _data.scriptClassID = stream->readUint16LE();
+ _data.associationOffset = stream->readUint16LE();
+ _data.numAssociations = stream->readByte();
+ _data.itemType = stream->readByte();
+ _data.instance.groupID = stream->readUint16LE();
+ _data.instance.u = stream->readSint16LE();
+ _data.instance.v = stream->readSint16LE();
+ _data.instance.v = stream->readSint16LE();
+ _data.instance.stateIndex = stream->readUint16LE();
+ _data.instance.scriptFlags = stream->readUint16LE();
+ _data.instance.targetU = stream->readUint16LE();
+ _data.instance.targetV = stream->readUint16LE();
+ _data.instance.targetZ = stream->readByte();
+ _data.instance.worldNum = stream->readByte();
}
ActiveItemList::ActiveItemList(WorldMapData *parent, int count, Common::SeekableReadStream *stream) {
@@ -1996,9 +1997,9 @@ TileInfo *Platform::fetchTile(
// Get the tile to be drawn from the tile group
tr = &(mapList[mapNum].activeItemData)[
- groupItem->group.grDataOffset
- + state * groupItem->group.animArea
- + relPos.u * groupItem->group.vSize
+ groupItem->_data.group.grDataOffset
+ + state * groupItem->_data.group.animArea
+ + relPos.u * groupItem->_data.group.vSize
+ relPos.v];
h += tr->tileHeight * 8;
@@ -2078,9 +2079,9 @@ TileInfo *Platform::fetchTAGInstance(
// Get the tile to be drawn from the tile group
tr = &(mapList[mapNum].activeItemData)[
- groupItem->group.grDataOffset
- + state * groupItem->group.animArea
- + relPos.u * groupItem->group.vSize
+ groupItem->_data.group.grDataOffset
+ + state * groupItem->_data.group.animArea
+ + relPos.u * groupItem->_data.group.vSize
+ relPos.v];
h += tr->tileHeight * 8;
@@ -2153,9 +2154,9 @@ TileInfo *Platform::fetchTile(
// Get the tile to be drawn from the tile group
tr = &(mapList[mapNum].activeItemData)[
- groupItem->group.grDataOffset
- + state * groupItem->group.animArea
- + relPos.u * groupItem->group.vSize
+ groupItem->_data.group.grDataOffset
+ + state * groupItem->_data.group.animArea
+ + relPos.u * groupItem->_data.group.vSize
+ relPos.v];
h += tr->tileHeight * 8;
@@ -2236,9 +2237,9 @@ TileInfo *Platform::fetchTAGInstance(
// Get the tile to be drawn from the tile group
tr = &(mapList[mapNum].activeItemData)[
- groupItem->group.grDataOffset
- + state * groupItem->group.animArea
- + relPos.u * groupItem->group.vSize
+ groupItem->_data.group.grDataOffset
+ + state * groupItem->_data.group.animArea
+ + relPos.u * groupItem->_data.group.vSize
+ relPos.v];
h += tr->tileHeight * 8;
@@ -2475,9 +2476,9 @@ void WorldMapData::buildInstanceHash(void) {
for (i = 0, ail = activeItemList->_items; i < activeCount; i++, ail++) {
ActiveItem *ai = *ail;
- if (ai->itemType == activeTypeInstance) {
- hashVal = (((ai->instance.u + ai->instance.h) << 4)
- + ai->instance.v + (ai->instance.groupID << 2))
+ if (ai->_data.itemType == activeTypeInstance) {
+ hashVal = (((ai->_data.instance.u + ai->_data.instance.h) << 4)
+ + ai->_data.instance.v + (ai->_data.instance.groupID << 2))
% elementsof(instHash);
itemHash.setVal(hashVal, ai);
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index f704f7f378..07482c96d7 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -339,20 +339,13 @@ extern byte **stateArray;
class ActiveItemList;
-class ActiveItem {
-public:
- ActiveItem *nextHash; // next item in hash chain
-
-// char name[32]; // name of this group
-// uint16 flags; // various flags
-// TileGroupID itemID; // unique # of this item
-
- uint16 scriptClassID; // associated script object
- uint16 associationOffset; // offset into association table
- uint8 numAssociations; // number of associated items
- uint8 itemType; // item type code.
- int _index;
- ActiveItemList *_parent;
+#include "common/pack-start.h"
+struct ActiveItemData {
+ uint32 nextHashDummy; // next item in hash chain
+ uint16 scriptClassID; // associated script object
+ uint16 associationOffset; // offset into association table
+ uint8 numAssociations; // number of associated items
+ uint8 itemType; // item type code.
union {
struct {
@@ -378,6 +371,15 @@ public:
worldNum; // Add 0xf000 to get world Object ID
} instance;
};
+};
+
+#include "common/pack-end.h"
+class ActiveItem {
+public:
+ ActiveItem *_nextHash; // next item in hash chain
+ int _index;
+ ActiveItemList *_parent;
+ ActiveItemData _data;
enum {
activeItemLocked = (1 << 8), // The door is locked
@@ -401,9 +403,8 @@ public:
// Return a pointer to this TAI's group
ActiveItem *getGroup(void) {
- assert(itemType == activeTypeInstance);
- return activeItemAddress(
- ActiveItemID(getMapNum(), instance.groupID));
+ assert(_data.itemType == activeTypeInstance);
+ return activeItemAddress(ActiveItemID(getMapNum(), _data.instance.groupID));
}
enum BuiltInBehaviorType {
@@ -415,38 +416,42 @@ public:
// Return the state number of this active item instance
uint8 getInstanceState(int16 mapNum) {
- return stateArray[mapNum][instance.stateIndex];
+ return stateArray[mapNum][_data.instance.stateIndex];
}
// Set the state number of this active item instance
void setInstanceState(int16 mapNum, uint8 state) {
- stateArray[mapNum][instance.stateIndex] = state;
+ stateArray[mapNum][_data.instance.stateIndex] = state;
}
uint8 builtInBehavior(void) {
- return (uint8)(instance.scriptFlags >> 13);
+ return (uint8)(_data.instance.scriptFlags >> 13);
}
// Access to the locked bit
bool isLocked(void) {
- return (bool)(instance.scriptFlags & activeItemLocked);
+ return (bool)(_data.instance.scriptFlags & activeItemLocked);
}
void setLocked(bool val) {
- if (val) instance.scriptFlags |= activeItemLocked;
- else instance.scriptFlags &= ~activeItemLocked;
+ if (val)
+ _data.instance.scriptFlags |= activeItemLocked;
+ else
+ _data.instance.scriptFlags &= ~activeItemLocked;
}
// Access to the exclusion semaphore
bool isExclusive(void) {
- return (bool)(instance.scriptFlags & activeItemExclusive);
+ return (bool)(_data.instance.scriptFlags & activeItemExclusive);
}
void setExclusive(bool val) {
- if (val) instance.scriptFlags |= activeItemExclusive;
- else instance.scriptFlags &= ~activeItemExclusive;
+ if (val)
+ _data.instance.scriptFlags |= activeItemExclusive;
+ else
+ _data.instance.scriptFlags &= ~activeItemExclusive;
}
uint8 lockType(void) {
- return (uint8)instance.scriptFlags;
+ return (uint8)_data.instance.scriptFlags;
}
// ActiveItem instance methods
@@ -464,10 +469,10 @@ public:
bool acceptLockToggle(ActiveItem *ins, ObjectID enactor, uint8 keyCode);
bool inRange(ActiveItem *ins, const TilePoint &loc, int16 range) {
- return loc.u >= ins->instance.u - range
- && loc.v >= ins->instance.v - range
- && loc.u < ins->instance.u + group.uSize + range
- && loc.v < ins->instance.v + group.vSize + range;
+ return loc.u >= ins->_data.instance.u - range
+ && loc.v >= ins->_data.instance.v - range
+ && loc.u < ins->_data.instance.u + _data.group.uSize + range
+ && loc.v < ins->_data.instance.v + _data.group.vSize + range;
}
ObjectID getInstanceContext(void);
Commit: 277245a49e92ec6e3d828cecafc4bc45a293c89b
https://github.com/scummvm/scummvm/commit/277245a49e92ec6e3d828cecafc4bc45a293c89b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:17+02:00
Commit Message:
SAGA2: Made ActiveMission script-friendly
Changed paths:
engines/saga2/interp.cpp
engines/saga2/mission.cpp
engines/saga2/mission.h
engines/saga2/tile.h
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 4fa2e79de2..c448a9654d 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -99,7 +99,7 @@ uint8 *builtinObjectAddress(int16 segment, uint16 index) {
return segmentAddress(segNum, segOff);
case builtinTypeMission:
- return (uint8 *)ActiveMission::missionAddress(index);
+ return (uint8 *)(&ActiveMission::missionAddress(index)->_data);
default:
error("Invalid builtin object segment number: %d\n", segment);
diff --git a/engines/saga2/mission.cpp b/engines/saga2/mission.cpp
index 28014a7470..9092eeddbc 100644
--- a/engines/saga2/mission.cpp
+++ b/engines/saga2/mission.cpp
@@ -43,7 +43,7 @@ ActiveMission *ActiveMission::newMission(ObjectID genID, uint16 script) {
ActiveMission *ms = NULL;
for (i = 0; i < elementsof(activeMissions); i++) {
- if (!(activeMissions[i].missionFlags & inUse)) {
+ if (!(activeMissions[i]._data.missionFlags & inUse)) {
ms = &activeMissions[i];
break;
}
@@ -53,14 +53,14 @@ ActiveMission *ActiveMission::newMission(ObjectID genID, uint16 script) {
GameObject *generator = GameObject::objectAddress(genID);
- ms->missionID = i;
- ms->generatorID = genID;
- ms->missionScript = script;
- ms->missionFlags |= inUse;
+ ms->_data.missionID = i;
+ ms->_data.generatorID = genID;
+ ms->_data.missionScript = script;
+ ms->_data.missionFlags |= inUse;
- ms->numKnowledgeIDs = ms->numObjectIDs = 0;
+ ms->_data.numKnowledgeIDs = ms->_data.numObjectIDs = 0;
- memset(ms->missionVars, 0, elementsof(ms->missionVars));
+ memset(ms->_data.missionVars, 0, elementsof(ms->_data.missionVars));
return ms;
}
@@ -72,8 +72,8 @@ int ActiveMission::findMission(ObjectID genID) {
int i;
for (i = 0; i < elementsof(activeMissions); i++) {
- if (activeMissions[i].missionFlags & inUse
- && activeMissions[i].generatorID == genID) {
+ if (activeMissions[i]._data.missionFlags & inUse
+ && activeMissions[i]._data.generatorID == genID) {
return i;
}
}
@@ -92,8 +92,8 @@ ActiveMission *ActiveMission::missionAddress(int index) {
// Add record of object creation to mission
bool ActiveMission::addObjectID(ObjectID objID) {
- if (numObjectIDs < elementsof(missionObjectList)) {
- missionObjectList[numObjectIDs++] = objID;
+ if (_data.numObjectIDs < elementsof(_data.missionObjectList)) {
+ _data.missionObjectList[_data.numObjectIDs++] = objID;
return true;
}
return false;
@@ -105,15 +105,17 @@ bool ActiveMission::addObjectID(ObjectID objID) {
bool ActiveMission::removeObjectID(ObjectID objID) {
bool found = false;
- for (int i = 0; i < numObjectIDs; i++) {
+ for (int i = 0; i < _data.numObjectIDs; i++) {
if (found) {
- missionObjectList[i - 1] = missionObjectList[i];
+ _data.missionObjectList[i - 1] = _data.missionObjectList[i];
} else {
- if (missionObjectList[i] == objID) found = true;
+ if (_data.missionObjectList[i] == objID)
+ found = true;
}
}
- if (found) numObjectIDs--;
+ if (found)
+ _data.numObjectIDs--;
return found;
}
@@ -124,13 +126,13 @@ bool ActiveMission::removeObjectID(ObjectID objID) {
bool ActiveMission::addKnowledgeID(ObjectID actor, uint16 knowledgeID) {
if (!isActor(actor)) return false;
- if (numKnowledgeIDs < elementsof(missionKnowledgeList)) {
+ if (_data.numKnowledgeIDs < elementsof(_data.missionKnowledgeList)) {
Actor *a = (Actor *)GameObject::objectAddress(actor);
if (!a->addKnowledge(knowledgeID)) return false;
- missionKnowledgeList[numKnowledgeIDs].id = actor;
- missionKnowledgeList[numKnowledgeIDs++].kID = knowledgeID;
+ _data.missionKnowledgeList[_data.numKnowledgeIDs].id = actor;
+ _data.missionKnowledgeList[_data.numKnowledgeIDs++].kID = knowledgeID;
return true;
}
return false;
@@ -142,18 +144,19 @@ bool ActiveMission::addKnowledgeID(ObjectID actor, uint16 knowledgeID) {
bool ActiveMission::removeKnowledgeID(ObjectID actor, uint16 knowledgeID) {
bool found = false;
- for (int i = 0; i < numKnowledgeIDs; i++) {
+ for (int i = 0; i < _data.numKnowledgeIDs; i++) {
if (found) {
- missionKnowledgeList[i - 1] = missionKnowledgeList[i];
+ _data.missionKnowledgeList[i - 1] = _data.missionKnowledgeList[i];
} else {
- if (missionKnowledgeList[i].id == actor
- && missionKnowledgeList[i].kID == knowledgeID) {
+ if (_data.missionKnowledgeList[i].id == actor
+ && _data.missionKnowledgeList[i].kID == knowledgeID) {
found = true;
}
}
}
- if (found) numKnowledgeIDs--;
+ if (found)
+ _data.numKnowledgeIDs--;
return found;
}
@@ -164,24 +167,24 @@ bool ActiveMission::removeKnowledgeID(ObjectID actor, uint16 knowledgeID) {
void ActiveMission::cleanup(void) {
int i;
- for (i = 0; i < numKnowledgeIDs; i++) {
+ for (i = 0; i < _data.numKnowledgeIDs; i++) {
Actor *a;
- a = (Actor *)GameObject::objectAddress(missionKnowledgeList[i].id);
+ a = (Actor *)GameObject::objectAddress(_data.missionKnowledgeList[i].id);
- a->removeKnowledge(missionKnowledgeList[i].kID);
+ a->removeKnowledge(_data.missionKnowledgeList[i].kID);
}
- for (i = 0; i < numObjectIDs; i++) {
+ for (i = 0; i < _data.numObjectIDs; i++) {
GameObject *obj;
- obj = GameObject::objectAddress(missionObjectList[i]);
+ obj = GameObject::objectAddress(_data.missionObjectList[i]);
obj->deleteObjectRecursive();
}
- numKnowledgeIDs = numObjectIDs = 0;
- missionFlags &= ~inUse;
+ _data.numKnowledgeIDs = _data.numObjectIDs = 0;
+ _data.missionFlags &= ~inUse;
}
//-----------------------------------------------------------------------
@@ -191,7 +194,7 @@ void initMissions(void) {
int i;
for (i = 0; i < elementsof(activeMissions); i++)
- activeMissions[i].missionFlags &= ~ActiveMission::inUse;
+ activeMissions[i]._data.missionFlags &= ~inUse;
}
//-----------------------------------------------------------------------
diff --git a/engines/saga2/mission.h b/engines/saga2/mission.h
index bc49413ee0..51ea1fb58a 100644
--- a/engines/saga2/mission.h
+++ b/engines/saga2/mission.h
@@ -31,23 +31,22 @@
namespace Saga2 {
-class ActiveMission {
-
- friend void initMissions(void);
- friend void saveMissions(SaveFileConstructor &saveGame);
- friend void loadMissions(SaveFileReader &saveGame);
- friend void cleanupMissions(void);
+// Used to store a record of mission knowledge that
+// has been added to an actor, and will be deleted after
+// the mission is destructed.
+struct KnowledgeID {
+ ObjectID id;
+ uint16 kID;
+};
-private:
+#include "common/pack-start.h"
- // Used to store a record of mission knowledge that
- // has been added to an actor, and will be deleted after
- // the mission is destructed.
- struct KnowledgeID {
- ObjectID id;
- uint16 kID;
- };
+// Mission flags
+enum missionFlags {
+ inUse = (1 << 0) // this mission struct in use
+};
+struct ActiveMissionData {
// Store the unique ID of this active mission, and the
// object ID of the generator.
uint16 missionID; // ID of this instance
@@ -55,11 +54,6 @@ private:
uint16 missionScript; // script for this mission
uint16 missionFlags; // various mission flags
- // Mission flags
- enum missionFlags {
- inUse = (1 << 0), // this mission struct in use
- };
-
// Specific variables relating to the mission which can
// be defined by the script writer.
uint8 missionVars[32];
@@ -69,6 +63,20 @@ private:
KnowledgeID missionKnowledgeList[32];
uint16 numObjectIDs,
numKnowledgeIDs;
+};
+
+#include "common/pack-end.h"
+
+class ActiveMission {
+
+ friend void initMissions(void);
+ friend void saveMissions(SaveFileConstructor &saveGame);
+ friend void loadMissions(SaveFileReader &saveGame);
+ friend void cleanupMissions(void);
+
+public:
+
+ ActiveMissionData _data;
public:
static ActiveMission *newMission(ObjectID genID, uint16 script);
@@ -78,7 +86,7 @@ public:
void cleanup(void);
bool spaceForObject(void) {
- return numObjectIDs < elementsof(missionObjectList);
+ return _data.numObjectIDs < elementsof(_data.missionObjectList);
}
// Add record of object creation to mission
@@ -94,11 +102,11 @@ public:
bool removeKnowledgeID(ObjectID actor, uint16 knowledgeID);
int16 getMissionID(void) {
- return missionID;
+ return _data.missionID;
}
uint16 getScript(void) {
- return missionScript;
+ return _data.missionScript;
}
};
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index 07482c96d7..26f51a789b 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -340,6 +340,7 @@ extern byte **stateArray;
class ActiveItemList;
#include "common/pack-start.h"
+
struct ActiveItemData {
uint32 nextHashDummy; // next item in hash chain
uint16 scriptClassID; // associated script object
@@ -374,6 +375,7 @@ struct ActiveItemData {
};
#include "common/pack-end.h"
+
class ActiveItem {
public:
ActiveItem *_nextHash; // next item in hash chain
Commit: c575ca2995f1f6f96407e4838d549255c7ca959e
https://github.com/scummvm/scummvm/commit/c575ca2995f1f6f96407e4838d549255c7ca959e
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:17+02:00
Commit Message:
SAGA2: Put GameObject data into a packed struct
Changed paths:
engines/saga2/actor.cpp
engines/saga2/dispnode.cpp
engines/saga2/motion.cpp
engines/saga2/objects.cpp
engines/saga2/objects.h
engines/saga2/objproto.cpp
engines/saga2/tile.cpp
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index adb1549e28..4a66a55f94 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -191,7 +191,7 @@ bool ActorProto::openAction(ObjectID dObj, ObjectID) {
cn = CreateContainerNode(dObj, false, openMindType);
cn->markForShow(); // Deferred open
- dObjPtr->objectFlags |= objectOpen; // Set open bit;
+ dObjPtr->_data.objectFlags |= objectOpen; // Set open bit;
return true;
}
@@ -211,7 +211,7 @@ bool ActorProto::closeAction(ObjectID dObj, ObjectID) {
cn->markForDelete();
// Clear open bit
- dObjPtr->objectFlags &= ~objectOpen;
+ dObjPtr->_data.objectFlags &= ~objectOpen;
return true;
}
@@ -994,11 +994,11 @@ void Actor::init(
// nameIndex = 0;
setNameIndex(nameIndex);
setScript(scriptIndex);
- parentID = siblingID = childID = Nothing;
- objectFlags = 0;
- massCount = 0;
- currentTAG = NoActiveItem;
- hitPoints = 0;
+ _data.parentID = _data.siblingID = _data.childID = Nothing;
+ _data.objectFlags = 0;
+ _data.massCount = 0;
+ _data.currentTAG = NoActiveItem;
+ _data.hitPoints = 0;
// Initialize actor field
faction = factionNum;
@@ -1389,7 +1389,7 @@ void Actor::deleteActor(void) {
}
// Place in limbo
- if (!(objectFlags & objectNoRecycle)) {
+ if (!(_data.objectFlags & objectNoRecycle)) {
append(ActorLimbo);
actorLimboCount++;
}
@@ -2087,8 +2087,8 @@ void Actor::dropInventory(void) {
GameObject *obj,
*nextObj;
- for (obj = childID != Nothing
- ? GameObject::objectAddress(childID)
+ for (obj = _data.childID != Nothing
+ ? GameObject::objectAddress(_data.childID)
: NULL;
obj != NULL;
obj = nextObj) {
@@ -2766,7 +2766,7 @@ void Actor::evaluateMeleeAttack(Actor *attacker) {
// Compute the attacker's direction relative to this actor's
// facing
- relativeDir = ((attacker->location - location).quickDir()
+ relativeDir = ((attacker->_data.location - _data.location).quickDir()
- currentFacing) & 0x7;
// Get pointers to this actors primary and secondary defensive
diff --git a/engines/saga2/dispnode.cpp b/engines/saga2/dispnode.cpp
index 70c592c758..b19f365f09 100644
--- a/engines/saga2/dispnode.cpp
+++ b/engines/saga2/dispnode.cpp
@@ -439,9 +439,9 @@ void DisplayNode::drawObject(void) {
obj->setObscured(false);
}
- obj->sightCtr = 5;
+ obj->_data.sightCtr = 5;
} else {
- if (--obj->sightCtr == 0) {
+ if (--obj->_data.sightCtr == 0) {
SenseInfo info;
if (getCenterActor()->canSenseSpecificObject(info, maxSenseRange, obj->thisID()))
@@ -451,7 +451,7 @@ void DisplayNode::drawObject(void) {
obj->setObscured(false);
}
- obj->sightCtr = 5;
+ obj->_data.sightCtr = 5;
}
}
@@ -553,9 +553,9 @@ void DisplayNode::drawObject(void) {
a->setObscured(false);
}
- a->sightCtr = 5;
+ a->_data.sightCtr = 5;
} else {
- if (--a->sightCtr == 0) {
+ if (--a->_data.sightCtr == 0) {
SenseInfo info;
if (getCenterActor()->canSenseSpecificActor(info, maxSenseRange, a))
@@ -565,7 +565,7 @@ void DisplayNode::drawObject(void) {
a->setObscured(false);
}
- a->sightCtr = 5;
+ a->_data.sightCtr = 5;
}
}
diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp
index 85f4aa2fe1..992ccd4b86 100644
--- a/engines/saga2/motion.cpp
+++ b/engines/saga2/motion.cpp
@@ -196,22 +196,22 @@ void setObjectSurface(GameObject *obj, StandingTileInfo &sti) {
if (!(sti.surfaceRef.flags & trTileSensitive))
tagID = NoActiveItem;
- if (obj->currentTAG != tagID) {
+ if (obj->_data.currentTAG != tagID) {
ObjectID objID = obj->thisID(),
enactorID = isActor(objID) ? objID : Nothing;
- if (obj->currentTAG != NoActiveItem) {
+ if (obj->_data.currentTAG != NoActiveItem) {
ActiveItem *oldTAG =
- ActiveItem::activeItemAddress(obj->currentTAG);
+ ActiveItem::activeItemAddress(obj->_data.currentTAG);
oldTAG->release(enactorID, objID);
- obj->currentTAG = NoActiveItem;
+ obj->_data.currentTAG = NoActiveItem;
}
if (tagID != NoActiveItem) {
if (sti.surfaceTAG->trigger(enactorID, objID))
- obj->currentTAG = tagID;
+ obj->_data.currentTAG = tagID;
}
}
}
@@ -260,7 +260,7 @@ bool unstickObject(GameObject *obj) {
int32 dist;
int16 tHeight;
- // Compute the actual location of the new point
+ // Compute the actual _data.location of the new point
pos = obj->getLocation() + TilePoint(dx, dy, dz);
// Get the surface height at that point
@@ -505,7 +505,7 @@ MotionTask *MotionTaskList::newTask(GameObject *obj) {
if (isActor(obj))((Actor *)obj)->moveTask = mt;
}
}
- obj->objectFlags |= objectMoving;
+ obj->_data.objectFlags |= objectMoving;
return mt;
}
@@ -546,7 +546,7 @@ void *MotionTask::restore(void *buf) {
if (motionType == motionTypeWalk
|| prevMotionType == motionTypeWalk) {
- // Restore the target locations
+ // Restore the target _data.locations
immediateLocation = *((TilePoint *)buf);
finalTarget = *((TilePoint *)buf + 1);
buf = (TilePoint *)buf + 2;
@@ -739,7 +739,7 @@ void *MotionTask::restore(void *buf) {
? ActiveItem::activeItemAddress(ttaid)
: NULL;
- // restore location target
+ // restore _data.location target
targetLoc = *((Location *)buf);
buf = (Location *)buf + 1;
}
@@ -958,7 +958,7 @@ void *MotionTask::archive(void *buf) {
if (motionType == motionTypeWalk
|| prevMotionType == motionTypeWalk) {
- // Store the target locations
+ // Store the target _data.locations
*((TilePoint *)buf) = immediateLocation;
*((TilePoint *)buf + 1) = finalTarget;
buf = (TilePoint *)buf + 2;
@@ -1141,7 +1141,7 @@ void *MotionTask::archive(void *buf) {
*((ActiveItemID *)buf) = ttaid;
buf = (ActiveItemID *)buf + 1;
- // Store location target
+ // Store _data.location target
*((Location *)buf) = targetLoc;
buf = (Location *)buf + 1;
@@ -1208,11 +1208,11 @@ void MotionTask::remove(int16 returnVal) {
if (nextMT == this)
nextMT = (MotionTask *)next();
- object->objectFlags &= ~objectMoving;
+ object->_data.objectFlags &= ~objectMoving;
if (objObscured(object))
- object->objectFlags |= objectObscured;
+ object->_data.objectFlags |= objectObscured;
else
- object->objectFlags &= ~objectObscured;
+ object->_data.objectFlags &= ~objectObscured;
if (isActor(object)) {
Actor *a = (Actor *)object;
@@ -1236,7 +1236,7 @@ void MotionTask::remove(int16 returnVal) {
}
//-----------------------------------------------------------------------
-// Determine the immediate target location
+// Determine the immediate target _data.location
TilePoint MotionTask::getImmediateTarget(void) {
if (immediateLocation != Nowhere)
@@ -1252,7 +1252,7 @@ TilePoint MotionTask::getImmediateTarget(void) {
else
dir = ((Actor *)object)->currentFacing;
- return object->location
+ return object->_data.location
+ incDirTable[dir] * kTileUVSize;
}
@@ -1336,7 +1336,7 @@ void MotionTask::throwObject(GameObject &obj, const TilePoint &velocity) {
MotionTask *mt;
if ((mt = mTaskList.newTask(&obj)) != NULL) {
- if (obj.isMissile()) obj.missileFacing = missileNoFacing;
+ if (obj.isMissile()) obj._data.missileFacing = missileNoFacing;
mt->velocity = velocity;
mt->motionType = motionTypeThrown;
}
@@ -1354,7 +1354,7 @@ void MotionTask::throwObjectTo(GameObject &obj, const TilePoint &where) {
const int16 turns = 15;
if ((mt = mTaskList.newTask(&obj)) != NULL) {
- if (obj.isMissile()) obj.missileFacing = missileNoFacing;
+ if (obj.isMissile()) obj._data.missileFacing = missileNoFacing;
mt->calcVelocity(where - obj.getLocation(), turns);
mt->motionType = motionTypeThrown;
}
@@ -1362,7 +1362,7 @@ void MotionTask::throwObjectTo(GameObject &obj, const TilePoint &where) {
//-----------------------------------------------------------------------
// This function initiates a ballistic motion towards a specified target
-// location at a specified horizontal speed.
+// _data.location at a specified horizontal speed.
void MotionTask::shootObject(
GameObject &obj,
@@ -1393,7 +1393,7 @@ void MotionTask::shootObject(
mt->calcVelocity(vector, turns);
if (obj.isMissile())
- obj.missileFacing = missileDir(mt->velocity);
+ obj._data.missileFacing = missileDir(mt->velocity);
mt->motionType = motionTypeShot;
mt->o.enactor = &doer;
@@ -2145,7 +2145,7 @@ void MotionTask::finishWalk(void) {
// If there is currently a path finding request, abort it.
/* abortPathFind( this );
- // Simply set actor's target location to "here".
+ // Simply set actor's target _data.location to "here".
finalTarget = immediateLocation = object->getLocation();
pathList[0] = finalTarget;
flags = reset;
@@ -2198,7 +2198,7 @@ void MotionTask::ballisticAction(void) {
}
location = obj->getLocation();
-// WriteStatusF( 6, "%d %d %d", location.u, location.v, location.z );
+// WriteStatusF( 6, "%d %d %d", _data.location.u, _data.location.v, _data.location.z );
// Because we live in a point-sampled universe, we need to make
// sure that objects which are moving extremely fast don't
@@ -2318,21 +2318,21 @@ void MotionTask::ballisticAction(void) {
if (checkBlocked(obj,
TilePoint(newPos.u,
- obj->location.v,
- obj->location.z))) {
+ obj->_data.location.v,
+ obj->_data.location.z))) {
probe |= (1 << 0);
}
if (checkBlocked(obj,
- TilePoint(obj->location.u,
+ TilePoint(obj->_data.location.u,
newPos.v,
- obj->location.z))) {
+ obj->_data.location.z))) {
probe |= (1 << 1);
}
if (checkContact(obj,
- TilePoint(obj->location.u,
- obj->location.v,
+ TilePoint(obj->_data.location.u,
+ obj->_data.location.v,
newPos.z))) {
probe |= (1 << 2);
}
@@ -2371,7 +2371,7 @@ void MotionTask::ballisticAction(void) {
}
uFrac = vFrac = 0;
if (motionType == motionTypeShot && obj->isMissile())
- obj->missileFacing = missileDir(velocity);
+ obj->_data.missileFacing = missileDir(velocity);
// If the ballistic object is an actor hitting the
// ground, then instead of bouncing, we'll just have
@@ -2400,7 +2400,7 @@ void MotionTask::ballisticAction(void) {
setObjectSurface(obj, sti);
// If the object is falling, then
// freeFall will have already modified the
- // object's location
+ // object's _data.location
return;
}
} else if (velocity.u < 2 && velocity.u > -2
@@ -2446,7 +2446,7 @@ bool MotionTask::nextWayPoint(void) {
TilePoint wayPointVector(0, 0, 0);
if (pathIndex > 0)
- wayPointVector = immediateLocation - object->location;
+ wayPointVector = immediateLocation - object->_data.location;
if (wayPointVector.quickHDistance() == 0)
// Next vertex in path polyline
@@ -2465,8 +2465,8 @@ bool MotionTask::nextWayPoint(void) {
// and we're not at the target yet, request more waypoints then
// use dumb pathfinding until the pathfinder finishes it's task.
- if ((finalTarget - object->location).quickHDistance() > 0
- || abs(finalTarget.z - object->location.z) > kMaxStepHeight) {
+ if ((finalTarget - object->_data.location).quickHDistance() > 0
+ || abs(finalTarget.z - object->_data.location.z) > kMaxStepHeight) {
// If no pathfind in progress
if ((flags & pathFind)
&& !(flags & finalPath)
@@ -2498,8 +2498,8 @@ bool MotionTask::checkWalk(
// Check the terrain in various directions.
// Check in the forward direction first, at various heights
- newPos = object->location + (dirTable[direction] * speed) / 2;
- newPos.z = object->location.z + stepUp;
+ newPos = object->_data.location + (dirTable[direction] * speed) / 2;
+ newPos.z = object->_data.location.z + stepUp;
if (checkWalkable(object, newPos)) return false;
@@ -2616,7 +2616,7 @@ void MotionTask::walkAction(void) {
if (!(flags & reset)) {
// Compute the vector and distance of the current
// position to the next "immediate" target.
- targetVector = immediateTarget - object->location;
+ targetVector = immediateTarget - object->_data.location;
targetDist = targetVector.quickHDistance();
// If we're not already there, then proceed towards
@@ -2696,10 +2696,10 @@ void MotionTask::walkAction(void) {
movementDirection = targetVector.quickDir();
// movementDirection = a->currentFacing;
- // Set the new location to the character's location.
+ // Set the new _data.location to the character's _data.location.
newPos.u = immediateTarget.u;
newPos.v = immediateTarget.v;
- newPos.z = object->location.z;
+ newPos.z = object->_data.location.z;
// Determine the direction the character must spin
// to be at the correct movement angle.
@@ -2712,7 +2712,7 @@ void MotionTask::walkAction(void) {
// Test the terrain to see if we can go there.
if ((blockageType = checkWalkable(object, newPos)) != false) {
// Try stepping up to a higher terrain too.
- newPos.z = object->location.z + kMaxStepHeight;
+ newPos.z = object->_data.location.z + kMaxStepHeight;
if (checkWalkable(object, newPos) != blockageNone) {
// If there is a path find task pending, put the walk action
// on hold until it finishes, else, abort the walk action.
@@ -2726,7 +2726,7 @@ void MotionTask::walkAction(void) {
{
moveBlocked = true;
flags |= blocked;
- newPos.z = object->location.z;
+ newPos.z = object->_data.location.z;
}*/
}
@@ -2739,11 +2739,11 @@ void MotionTask::walkAction(void) {
movementDirection = targetVector.quickDir();
// Calculate new object position along direction vector.
- TilePoint pos = object->location
+ TilePoint pos = object->_data.location
+ targetVector * speed / targetDist;
#if DEBUG*0
- TPLine(object->location, pos);
+ TPLine(object->_data.location, pos);
#endif
// Check the terrain in various directions.
@@ -2754,7 +2754,7 @@ void MotionTask::walkAction(void) {
// vector, even if it's not aligned with one of the
// cardinal directions.
- pos.z = object->location.z + height;
+ pos.z = object->_data.location.z + height;
if (!checkWalkable(object, pos)) {
newPos = pos;
@@ -2848,7 +2848,7 @@ void MotionTask::walkAction(void) {
} else if (moveBlocked) {
a->setAction(actionStand, 0);
if (flags & agitatable) {
- if (freeFall(object->location, sti)) return;
+ if (freeFall(object->_data.location, sti)) return;
// When he starts running again, then have him walk only.
runCount = MAX<int16>(runCount, 8);
@@ -2873,7 +2873,7 @@ void MotionTask::walkAction(void) {
runCount = MAX<int16>(runCount, 8);
a->setAction(actionStand, 0);
- freeFall(object->location, sti);
+ freeFall(object->_data.location, sti);
} else {
if (a == getCenterActor() && checkLadder(a, newPos)) return;
@@ -2887,7 +2887,7 @@ void MotionTask::walkAction(void) {
// This is a kludge to keep the character from
// "jumping" as he climbs up a small step.
- if (tHeight >= object->location.z - kMaxSmoothStep
+ if (tHeight >= object->_data.location.z - kMaxSmoothStep
* ((sti.surfaceTile != NULL
&& (sti.surfaceTile->combinedTerrainMask() & terrainStair))
? 4
@@ -4209,7 +4209,7 @@ void MotionTask::updatePositions(void) {
&& a->isInterruptable())
continue;
- if (obj->location.z < -(proto->height >> 2))
+ if (obj->_data.location.z < -(proto->height >> 2))
mt->flags |= inWater;
else
mt->flags &= ~inWater;
@@ -4293,7 +4293,7 @@ void MotionTask::updatePositions(void) {
(mt->flags & requestRun) != 0);
}
nextMT = mt;
- } else if (mt->freeFall(obj->location, sti) == false)
+ } else if (mt->freeFall(obj->_data.location, sti) == false)
moveTaskDone = true;
} else {
// If actor was running, go through an abreviated
@@ -4342,13 +4342,13 @@ void MotionTask::updatePositions(void) {
case motionTypeRise:
- if (a->location.z < mt->immediateLocation.z) {
- a->location.z++;
+ if (a->_data.location.z < mt->immediateLocation.z) {
+ a->_data.location.z++;
if (mt->flags & nextAnim)
a->nextAnimationFrame();
mt->flags ^= nextAnim;
} else {
- targetVector = mt->finalTarget - obj->location;
+ targetVector = mt->finalTarget - obj->_data.location;
targetDist = targetVector.quickHDistance();
if (targetDist > kTileUVSize) {
@@ -4704,11 +4704,11 @@ bool MotionTask::freeFall(TilePoint &newPos, StandingTileInfo &sti) {
tHeight = tileSlopeHeight(newPos, object, &sti);
- if (object->objectFlags & objectFloating) return false;
+ if (object->_data.objectFlags & objectFloating) return false;
- velocity.u = (newPos.u - object->location.u) * 2 / 3;
- velocity.v = (newPos.v - object->location.v) * 2 / 3;
- velocity.z = (newPos.z - object->location.z) * 2 / 3;
+ velocity.u = (newPos.u - object->_data.location.u) * 2 / 3;
+ velocity.v = (newPos.v - object->_data.location.v) * 2 / 3;
+ velocity.z = (newPos.z - object->_data.location.z) * 2 / 3;
// velocity.z = 0;
// If terrain is HIGHER (or even sligtly lower) than we are
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 0a3e0ebdf9..0be96d011c 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -195,20 +195,22 @@ struct GameObjectArchive {
GameObject::GameObject(void) {
prototype = nullptr;
- location = Nowhere;
- nameIndex = 0;
- parentID = Nothing;
- siblingID = Nothing;
- childID = Nothing;
- script = 0;
- objectFlags = 0;
- hitPoints = 0;
- bParam = 0;
- massCount = 0;
- missileFacing = missileRt;
- currentTAG = NoActiveItem;
- sightCtr = 0;
- memset(&reserved, 0, sizeof(reserved));
+ _data.location = Nowhere;
+ _data.nameIndex = 0;
+ _data.parentID = Nothing;
+ _data.siblingID = Nothing;
+ _data.childID = Nothing;
+ _data.script = 0;
+ _data.objectFlags = 0;
+ _data.hitPoints = 0;
+ _data.bParam = 0;
+ _data.massCount = 0;
+ _data.missileFacing = missileRt;
+ _data.currentTAG = NoActiveItem;
+ _data.sightCtr = 0;
+ memset(&_data.reserved, 0, sizeof(_data.reserved));
+
+ _data.obj = this;
}
//-----------------------------------------------------------------------
@@ -216,20 +218,22 @@ GameObject::GameObject(void) {
GameObject::GameObject(const ResourceGameObject &res) {
prototype = &objectProtos[res.protoIndex];
- location = res.location;
- nameIndex = res.nameIndex;
- parentID = res.parentID;
- siblingID = Nothing;
- childID = Nothing;
- script = res.script;
- objectFlags = res.objectFlags;
- hitPoints = res.hitPoints;
- bParam = prototype->getChargeType() ? prototype->maxCharges : 0;
- massCount = res.misc; //prototype->getInitialItemCount();
- missileFacing = missileRt;
- currentTAG = NoActiveItem;
- sightCtr = 0;
- memset(&reserved, 0, sizeof(reserved));
+ _data.location = res.location;
+ _data.nameIndex = res.nameIndex;
+ _data.parentID = res.parentID;
+ _data.siblingID = Nothing;
+ _data.childID = Nothing;
+ _data.script = res.script;
+ _data.objectFlags = res.objectFlags;
+ _data.hitPoints = res.hitPoints;
+ _data.bParam = prototype->getChargeType() ? prototype->maxCharges : 0;
+ _data.massCount = res.misc; //prototype->getInitialItemCount();
+ _data.missileFacing = missileRt;
+ _data.currentTAG = NoActiveItem;
+ _data.sightCtr = 0;
+ memset(&_data.reserved, 0, sizeof(_data.reserved));
+
+ _data.obj = this;
}
//-----------------------------------------------------------------------
@@ -243,20 +247,22 @@ GameObject::GameObject(void **buf) {
? &objectProtos[a->protoIndex]
: nullptr;
- location = a->location;
- nameIndex = a->nameIndex;
- parentID = a->parentID;
- siblingID = a->siblingID;
- childID = a->childID;
- script = a->script;
- objectFlags = a->objectFlags;
- hitPoints = a->hitPoints;
- bParam = a->bParam;
- massCount = a->misc;
- missileFacing = a->missileFacing;
- currentTAG = a->currentTAG;
- sightCtr = a->sightCtr;
- memset(&reserved, 0, sizeof(reserved));
+ _data.location = a->location;
+ _data.nameIndex = a->nameIndex;
+ _data.parentID = a->parentID;
+ _data.siblingID = a->siblingID;
+ _data.childID = a->childID;
+ _data.script = a->script;
+ _data.objectFlags = a->objectFlags;
+ _data.hitPoints = a->hitPoints;
+ _data.bParam = a->bParam;
+ _data.massCount = a->misc;
+ _data.missileFacing = a->missileFacing;
+ _data.currentTAG = a->currentTAG;
+ _data.sightCtr = a->sightCtr;
+ memset(&_data.reserved, 0, sizeof(_data.reserved));
+
+ _data.obj = this;
*buf = &a[1];
}
@@ -278,19 +284,19 @@ void *GameObject::archive(void *buf) {
// Convert the prototype pointer to a prototype index
a->protoIndex = prototype != nullptr ? prototype - objectProtos : -1;
- a->location = location;
- a->nameIndex = nameIndex;
- a->parentID = parentID;
- a->siblingID = siblingID;
- a->childID = childID;
- a->script = script;
- a->objectFlags = objectFlags;
- a->hitPoints = hitPoints;
- a->bParam = bParam;
- a->misc = massCount;
- a->missileFacing = missileFacing;
- a->currentTAG = currentTAG;
- a->sightCtr = sightCtr;
+ a->location = _data.location;
+ a->nameIndex = _data.nameIndex;
+ a->parentID = _data.parentID;
+ a->siblingID = _data.siblingID;
+ a->childID = _data.childID;
+ a->script = _data.script;
+ a->objectFlags = _data.objectFlags;
+ a->hitPoints = _data.hitPoints;
+ a->bParam = _data.bParam;
+ a->misc = _data.massCount;
+ a->missileFacing = _data.missileFacing;
+ a->currentTAG = _data.currentTAG;
+ a->sightCtr = _data.sightCtr;
return &a[1];
}
@@ -365,8 +371,8 @@ ObjectID GameObject::thisID(void) { // calculate our own id
}
// Since Worlds have more than one object chain, we need a function
-// to calculate which object chain to use, based on a location.
-// This function returns the address of the appropriate "childID"
+// to calculate which object chain to use, based on a _data.location.
+// This function returns the address of the appropriate "_data.childID"
// pointer (i.e. the ObjectID of the first object in the chain
// of child objects) for any type of object.
@@ -382,7 +388,7 @@ ObjectID *GameObject::getHeadPtr(ObjectID parentID, TilePoint &l) {
return &(world->sectorArray)[
v * world->sectorArraySize + u].childID;
- } else return &parentObj->childID;
+ } else return &parentObj->_data.childID;
}
// Removes an object from it's chain.
@@ -392,12 +398,12 @@ void GameObject::remove(void) { // removes from old list
*headPtr;
// If object has not parent, then it's not on a list
- if (parentID == Nothing) return;
+ if (_data.parentID == Nothing) return;
if (id >= Nothing && id <= ImportantLimbo) return;
// Get the head of the object chain. Worlds have more than
// one, so we need to get the right one.
- headPtr = getHeadPtr(parentID, location);
+ headPtr = getHeadPtr(_data.parentID, _data.location);
// Search the chain until we find ourself.
while (*headPtr != id) {
@@ -405,15 +411,15 @@ void GameObject::remove(void) { // removes from old list
if (*headPtr == Nothing)
error("Inconsistant Object Chain! ('%s#%d' not on parent %s#%d chain)",
- objName(), id, objectAddress(parentID)->objName(), parentID);
+ objName(), id, objectAddress(_data.parentID)->objName(), _data.parentID);
obj = objectAddress(*headPtr);
- headPtr = &obj->siblingID;
+ headPtr = &obj->_data.siblingID;
}
// Remove us from the chain
- *headPtr = siblingID;
- parentID = Nothing;
+ *headPtr = _data.siblingID;
+ _data.parentID = Nothing;
}
// Add an object to a new chain.
@@ -426,14 +432,14 @@ void GameObject::append(ObjectID newParent) {
// Get the head of the object chain. Worlds have more than
// one, so we need to get the right one.
- headPtr = getHeadPtr(newParent, location);
+ headPtr = getHeadPtr(newParent, _data.location);
GameObject *parent = GameObject::objectAddress(newParent);
// Link us in to the parent's chain
- parentID = newParent;
- siblingID = *headPtr;
+ _data.parentID = newParent;
+ _data.siblingID = *headPtr;
*headPtr = thisID();
}
@@ -450,26 +456,26 @@ void GameObject::insert(ObjectID newPrev) {
if (newPrev == Nothing) return;
// Link us in to the parent's chain
- siblingID = obj->siblingID;
- obj->siblingID = thisID();
- parentID = obj->parentID;
+ _data.siblingID = obj->_data.siblingID;
+ obj->_data.siblingID = thisID();
+ _data.parentID = obj->_data.parentID;
}
// Returns the identity of the actor possessing the object
ObjectID GameObject::possessor(void) {
GameObject *obj;
- ObjectID id = parentID;
+ ObjectID id = _data.parentID;
while (id != Nothing && isObject(id)) {
obj = objectAddress(id);
- id = obj->parentID;
+ id = obj->_data.parentID;
}
return isActor(id) ? id : Nothing ;
}
-// A different version of getWorldLocation that fills in a location
+// A different version of getWorldLocation that fills in a _data.location
// structure.
bool GameObject::getWorldLocation(Location &loc) {
@@ -478,9 +484,9 @@ bool GameObject::getWorldLocation(Location &loc) {
uint8 objHeight = prototype->height;
for (;;) {
- id = obj->parentID;
+ id = obj->_data.parentID;
if (isWorld(id)) {
- loc = obj->location;
+ loc = obj->_data.location;
loc.z += (obj->prototype->height - objHeight) / 2;
loc.context = id;
return true;
@@ -504,12 +510,12 @@ Location GameObject::notGetWorldLocation(void) {
uint8 objHeight = prototype->height;
for (;;) {
- id = obj->parentID;
+ id = obj->_data.parentID;
if (isWorld(id)) {
- TilePoint loc = obj->location;
+ TilePoint loc = obj->_data.location;
loc.z += (obj->prototype->height - objHeight) / 2;
- return Location(loc, obj->parentID);
+ return Location(loc, obj->_data.parentID);
} else if (id == Nothing) return Location(Nowhere, Nothing);
obj = objectAddress(id);
@@ -533,8 +539,8 @@ void GameObject::objCursorText(char nameBuf[], const int8 size, int16 count) {
// display charges if item is a chargeable item
if (prototype->chargeType != 0
&& prototype->maxCharges != Permanent
- && bParam != Permanent) {
- uint16 charges = bParam;
+ && _data.bParam != Permanent) {
+ uint16 charges = _data.bParam;
if (charges == 1) {
sprintf(nameBuf, SINGLE_CHARGE, objName(), charges);
@@ -547,13 +553,13 @@ void GameObject::objCursorText(char nameBuf[], const int8 size, int16 count) {
// make a buffer that contains the name of
// the object and it's count
// add only if a mergable item
- if (massCount != 1) {
+ if (_data.massCount != 1) {
if (count != -1) {
if (count != 1) {
sprintf(nameBuf, PLURAL_DESC, count, objName()); // get the count
}
} else {
- sprintf(nameBuf, PLURAL_DESC, massCount, objName()); // get the count
+ sprintf(nameBuf, PLURAL_DESC, _data.massCount, objName()); // get the count
}
}
}
@@ -626,16 +632,16 @@ bool GameObject::isTrueSkill(void) {
return false;
}
-// Returns the location of an object within the world
+// Returns the _data.location of an object within the world
TilePoint GameObject::getWorldLocation(void) {
GameObject *obj = this;
ObjectID id;
uint8 objHeight = prototype->height;
for (;;) {
- id = obj->parentID;
+ id = obj->_data.parentID;
if (isWorld(id)) {
- TilePoint loc = obj->location;
+ TilePoint loc = obj->_data.location;
loc.z += (obj->prototype->height - objHeight) / 2;
return loc;
@@ -653,7 +659,7 @@ GameWorld *GameObject::world(void) {
ObjectID id;
for (;;) {
- id = obj->parentID;
+ id = obj->_data.parentID;
if (isWorld(id)) return &worldList[id - WorldBaseID];
else if (id == Nothing) return nullptr;
@@ -677,7 +683,7 @@ int32 GameObject::getSprOffset(int16 num) {
if (num != -1) {
units = (int32)num;
} else {
- units = (int32)massCount;
+ units = (int32)_data.massCount;
}
// if this is a mergeable object
@@ -711,7 +717,7 @@ bool GameObject::unstack(void) {
if (isWorld(this)
|| isWorld(parent())
|| IDParent() == Nothing
- || location.z == 1
+ || _data.location.z == 1
|| prototype == nullptr
|| (prototype->containmentSet() & ProtoObj::isIntangible)) return false;
@@ -721,11 +727,11 @@ bool GameObject::unstack(void) {
// Count how many objects are in this stack
// Also, check to find the base item, and any non-base item
while (iter.next(&item) != Nothing) {
- if (item->location.u == location.u
- && item->location.v == location.v
+ if (item->_data.location.u == _data.location.u
+ && item->_data.location.v == _data.location.v
&& item->prototype == prototype) {
count++;
- if (item->location.z != 0) base = item;
+ if (item->_data.location.z != 0) base = item;
else zero = item;
}
}
@@ -737,72 +743,72 @@ bool GameObject::unstack(void) {
// Else if this item is not the base item, then decrement the base
// item's count by setting it to all but one of the count of items.
if (this == base && zero != nullptr)
- zero->location.z = count - 1;
- else if (base != nullptr) base->location.z = count - 1;
+ zero->_data.location.z = count - 1;
+ else if (base != nullptr) base->_data.location.z = count - 1;
// Set this item's count to 1
- location.z = 1;
+ _data.location.z = 1;
return true;
}
-// Move the object to a new location, and change context if needed.
+// Move the object to a new _data.location, and change context if needed.
void GameObject::setLocation(const Location &l) {
- if (l.context != parentID) {
+ if (l.context != _data.parentID) {
unstack(); // if it's in a stack, unstack it.
remove(); // remove from old list
- location = (TilePoint)l; // change location
+ _data.location = (TilePoint)l; // change _data.location
append(l.context); // append to new list
} else if (isWorld(l.context)) {
GameWorld *world = (GameWorld *)objectAddress(l.context);
TilePoint sectors = world->sectorSize();
- int16 u0 = clamp(0, location.u / kSectorSize, sectors.u - 1),
- v0 = clamp(0, location.v / kSectorSize, sectors.v - 1),
+ int16 u0 = clamp(0, _data.location.u / kSectorSize, sectors.u - 1),
+ v0 = clamp(0, _data.location.v / kSectorSize, sectors.v - 1),
u1 = clamp(0, l.u / kSectorSize, sectors.u - 1),
v1 = clamp(0, l.v / kSectorSize, sectors.v - 1);
if (u0 != u1 || v0 != v1) { // If sector changed
remove(); // Remove from old list
- location = (TilePoint)l; // Set object coords
+ _data.location = (TilePoint)l; // Set object coords
append(l.context); // append to appropriate list
} else {
- location = (TilePoint)l; // Set object coords
+ _data.location = (TilePoint)l; // Set object coords
}
} else {
unstack(); // if it's in a stack, unstack it.
- location = (TilePoint)l; // Set object coords
+ _data.location = (TilePoint)l; // Set object coords
}
}
// Move the object without changing worlds...
void GameObject::setLocation(const TilePoint &tp) {
- if (isWorld(parentID)) {
- GameWorld *world = (GameWorld *)objectAddress(parentID);
+ if (isWorld(_data.parentID)) {
+ GameWorld *world = (GameWorld *)objectAddress(_data.parentID);
TilePoint sectors = world->sectorSize();
- int16 u0 = clamp(0, location.u / kSectorSize, sectors.u - 1),
- v0 = clamp(0, location.v / kSectorSize, sectors.v - 1),
+ int16 u0 = clamp(0, _data.location.u / kSectorSize, sectors.u - 1),
+ v0 = clamp(0, _data.location.v / kSectorSize, sectors.v - 1),
u1 = clamp(0, tp.u / kSectorSize, sectors.u - 1),
v1 = clamp(0, tp.v / kSectorSize, sectors.v - 1);
if (u0 != u1 || v0 != v1) { // If sector changed
- ObjectID saveParent = parentID;
+ ObjectID saveParent = _data.parentID;
remove(); // Remove from old list
- location = tp; // Set object coords
- parentID = saveParent; // restore parent (cleared by remove())
- append(parentID); // append to appropriate list
+ _data.location = tp; // Set object coords
+ _data.parentID = saveParent; // restore parent (cleared by remove())
+ append(_data.parentID); // append to appropriate list
} else {
- location = tp; // Set object coords
+ _data.location = tp; // Set object coords
}
} else {
- location = tp; // Set object coords
+ _data.location = tp; // Set object coords
}
}
void GameObject::move(const Location &location) {
// move as usual
- ObjectID oldParentID = parentID;
+ ObjectID oldParentID = _data.parentID;
setLocation(location);
@@ -817,7 +823,7 @@ void GameObject::move(const Location &location, int16 num) {
// do a normal move
move(location);
} else {
- ObjectID oldParentID = parentID;
+ ObjectID oldParentID = _data.parentID;
// update panel after move
updateImage(oldParentID);
@@ -844,7 +850,7 @@ void GameObject::recharge(void) {
if (getChargeType()) {
ProtoObj *po = GameObject::protoAddress(thisID());
assert(po);
- bParam = po->maxCharges;
+ _data.bParam = po->maxCharges;
}
}
@@ -858,7 +864,7 @@ bool GameObject::deductCharge(ActorManaID manaID, uint16 manaCost) {
return false;
}
- if (po->maxCharges == Permanent || bParam == Permanent) {
+ if (po->maxCharges == Permanent || _data.bParam == Permanent) {
return true;
}
@@ -870,13 +876,13 @@ bool GameObject::deductCharge(ActorManaID manaID, uint16 manaCost) {
}
}
- if (bParam == 0) {
+ if (_data.bParam == 0) {
// not enough mana to use item
return false;
}
- if (bParam > 0 && bParam < Permanent) {
- bParam--;
+ if (_data.bParam > 0 && _data.bParam < Permanent) {
+ _data.bParam--;
}
return true;
@@ -891,7 +897,7 @@ bool GameObject::hasCharge(ActorManaID manaID, uint16 manaCost) {
return false;
}
- if (bParam == Permanent) {
+ if (_data.bParam == Permanent) {
return true;
}
@@ -903,7 +909,7 @@ bool GameObject::hasCharge(ActorManaID manaID, uint16 manaCost) {
}
}
- if (bParam == 0) {
+ if (_data.bParam == 0) {
// not enough mana to use item
return false;
}
@@ -916,7 +922,7 @@ void GameObject::move(const TilePoint &tilePoint) {
// I'm making the assumption that only objects in containers
// can be merged or stacked
// move as usual
- ObjectID oldParentID = parentID;
+ ObjectID oldParentID = _data.parentID;
setLocation(tilePoint);
@@ -927,7 +933,7 @@ void GameObject::updateImage(ObjectID oldParentID) {
GameObject *parent,
*oldParent;
- parent = objectAddress(parentID);
+ parent = objectAddress(_data.parentID);
oldParent = objectAddress(oldParentID);
if ((isActor(oldParentID)
@@ -937,7 +943,7 @@ void GameObject::updateImage(ObjectID oldParentID) {
globalContainerList.setUpdate(oldParentID);
}
- if (parentID != oldParentID && isActor(oldParentID)) {
+ if (_data.parentID != oldParentID && isActor(oldParentID)) {
ObjectID id = thisID();
Actor *a = (Actor *)oldParent;
int i;
@@ -955,36 +961,36 @@ void GameObject::updateImage(ObjectID oldParentID) {
}
}
- if (isWorld(parentID)) {
+ if (isWorld(_data.parentID)) {
GameWorld *w = world();
if (!isMoving()) {
if (objObscured(this)) {
- objectFlags |= objectObscured;
+ _data.objectFlags |= objectObscured;
} else {
- objectFlags &= ~objectObscured;
+ _data.objectFlags &= ~objectObscured;
}
}
- if (w->getSector(location.u >> kSectorShift,
- location.v >> kSectorShift)->isActivated()) {
+ if (w->getSector(_data.location.u >> kSectorShift,
+ _data.location.v >> kSectorShift)->isActivated()) {
activate();
}
} else {
- objectFlags &= ~objectObscured;
+ _data.objectFlags &= ~objectObscured;
- if ((isActor(parentID)
+ if ((isActor(_data.parentID)
&& isPlayerActor((Actor *)parent))
- || (isObject(parentID) && parent->isOpen())
+ || (isObject(_data.parentID) && parent->isOpen())
) {
- globalContainerList.setUpdate(parentID);
+ globalContainerList.setUpdate(_data.parentID);
}
}
}
bool GameObject::moveMerged(const Location &loc, int16 num) {
- if (num < massCount
- && !extractMerged(Location(location, parentID), massCount - num))
+ if (num < _data.massCount
+ && !extractMerged(Location(_data.location, _data.parentID), _data.massCount - num))
return false;
move(loc);
return true;
@@ -1000,20 +1006,20 @@ ObjectID GameObject::extractMerged(const Location &loc, int16 num) {
// with duplicates of it's kind
if (prototype->flags & ResourceObjectPrototype::objPropMergeable) {
// get the number requested or all that's there...
- int16 moveCount = MIN<uint16>(num, massCount);
+ int16 moveCount = MIN<uint16>(num, _data.massCount);
// make a new pile with that many items in it.
if ((extractedID = copy(loc, moveCount)) != Nothing) {
// and subtract that amount from the currect pile
- massCount -= moveCount;
+ _data.massCount -= moveCount;
// delete object if count goes to zero
- if (massCount == 0) {
+ if (_data.massCount == 0) {
this->deleteObject();
}
- // massCount should never go negitive
- assert(massCount >= 0);
+ // _data.massCount should never go negitive
+ assert(_data.massCount >= 0);
} else
return Nothing;
} else {
@@ -1033,20 +1039,20 @@ GameObject *GameObject::extractMerged(int16 num) {
Location loc(0, 0, 0, 0);
// get the number requested or all that's there...
- int16 moveCount = MIN<uint16>(num, massCount);
+ int16 moveCount = MIN<uint16>(num, _data.massCount);
// make a new pile with that many items in it.
if ((extractedID = copy(loc, moveCount)) != Nothing) {
// and subtract that amount from the currect pile
- massCount -= moveCount;
+ _data.massCount -= moveCount;
// delete object if count goes to zero
- if (massCount == 0) {
+ if (_data.massCount == 0) {
this->deleteObject();
}
- // massCount should never go negitive
- assert(massCount >= 0);
+ // _data.massCount should never go negitive
+ assert(_data.massCount >= 0);
} else
return nullptr;
} else {
@@ -1057,7 +1063,7 @@ GameObject *GameObject::extractMerged(int16 num) {
return GameObject::objectAddress(extractedID);
}
-// Move the object to a new random location
+// Move the object to a new random _data.location
void GameObject::moveRandom(const TilePoint &minLoc, const TilePoint &maxLoc) {
//We Should Also Send Flags For Conditional Movements
//One Consideration Is Whether We Should Get One Random Location
@@ -1070,7 +1076,7 @@ void GameObject::moveRandom(const TilePoint &minLoc, const TilePoint &maxLoc) {
for (int i = 0; i < maxMoveAttempts; i++) {
newLoc.u = GetRandomBetween(minLoc.u, maxLoc.u);
newLoc.v = GetRandomBetween(minLoc.v, maxLoc.v);
- newLoc.z = location.z; //For Now Keep Z Coord Same
+ newLoc.z = _data.location.z; //For Now Keep Z Coord Same
//If Flags == Collision Check
if (objectCollision(this, world(), newLoc) == nullptr) { //If No Collision
move(newLoc);//Move It Else Try Again
@@ -1080,7 +1086,7 @@ void GameObject::moveRandom(const TilePoint &minLoc, const TilePoint &maxLoc) {
}
// this will need another method to let it know about multiple
// object moves.
-// Copy the object to a new location.
+// Copy the object to a new _data.location.
ObjectID GameObject::copy(const Location &l) {
GameObject *newObj;
// ObjectID id = thisID();
@@ -1098,14 +1104,14 @@ ObjectID GameObject::copy(const Location &l) {
if ((newObj = newObject()) == nullptr) return Nothing;
newObj->prototype = prototype;
- newObj->nameIndex = nameIndex;
- newObj->script = script;
- newObj->objectFlags = objectFlags;
- newObj->hitPoints = hitPoints;
- newObj->massCount = massCount;
- newObj->bParam = bParam;
- newObj->missileFacing = missileFacing;
- newObj->currentTAG = currentTAG;
+ newObj->_data.nameIndex = _data.nameIndex;
+ newObj->_data.script = _data.script;
+ newObj->_data.objectFlags = _data.objectFlags;
+ newObj->_data.hitPoints = _data.hitPoints;
+ newObj->_data.massCount = _data.massCount;
+ newObj->_data.bParam = _data.bParam;
+ newObj->_data.missileFacing = _data.missileFacing;
+ newObj->_data.currentTAG = _data.currentTAG;
newObj->move(l); //>>> could this cause the same problem as below?
}
@@ -1131,12 +1137,12 @@ ObjectID GameObject::copy(const Location &l, int16 num) {
newObj->prototype = prototype;
- newObj->nameIndex = nameIndex;
- newObj->script = script;
- newObj->objectFlags = objectFlags;
- newObj->hitPoints = hitPoints;
- newObj->massCount = massCount;
- newObj->massCount = num;
+ newObj->_data.nameIndex = _data.nameIndex;
+ newObj->_data.script = _data.script;
+ newObj->_data.objectFlags = _data.objectFlags;
+ newObj->_data.hitPoints = _data.hitPoints;
+ newObj->_data.massCount = _data.massCount;
+ newObj->_data.massCount = num;
// this did occur before any of the assignments
// but that caused a crash when the it tried to update
@@ -1155,7 +1161,7 @@ ObjectID GameObject::makeAlias(const Location &l) {
if (newObjID != Nothing) {
GameObject *newObject = objectAddress(newObjID);
- newObject->objectFlags |= objectAlias;
+ newObject->_data.objectFlags |= objectAlias;
}
return newObjID;
@@ -1167,7 +1173,7 @@ GameObject *GameObject::newObject(void) { // get a newly created object
GameObject *limbo = objectAddress(ObjectLimbo),
*obj;
- if (limbo->childID == Nothing) {
+ if (limbo->_data.childID == Nothing) {
int16 i;
// Search object list for the first scavengable object we can find
@@ -1191,14 +1197,14 @@ GameObject *GameObject::newObject(void) { // get a newly created object
obj->remove();
obj->prototype = nullptr;
- obj->nameIndex = 0;
- obj->script = 0;
- obj->objectFlags = 0;
- obj->hitPoints = 0;
- obj->massCount = 0;
- obj->bParam = 0;
- obj->missileFacing = 0;
- obj->currentTAG = NoActiveItem;
+ obj->_data.nameIndex = 0;
+ obj->_data.script = 0;
+ obj->_data.objectFlags = 0;
+ obj->_data.hitPoints = 0;
+ obj->_data.massCount = 0;
+ obj->_data.bParam = 0;
+ obj->_data.missileFacing = 0;
+ obj->_data.currentTAG = NoActiveItem;
return obj;
}
@@ -1232,9 +1238,9 @@ void GameObject::deleteObject(void) {
while ((cn = globalContainerList.find(dObj)) != nullptr)
delete cn;
- if (isActor(parentID)) {
+ if (isActor(_data.parentID)) {
ObjectID id = thisID();
- Actor *a = (Actor *)objectAddress(parentID);
+ Actor *a = (Actor *)objectAddress(_data.parentID);
int i;
if (a->leftHandObject == id) a->leftHandObject = Nothing;
@@ -1256,16 +1262,16 @@ void GameObject::deleteObject(void) {
if (isActor(this))
((Actor *)this)->deleteActor();
- else if (objectFlags & objectImportant) {
+ else if (_data.objectFlags & objectImportant) {
append(ImportantLimbo);
- parentID = ImportantLimbo;
+ _data.parentID = ImportantLimbo;
importantLimboCount++;
- } else if (!(objectFlags & objectNoRecycle)) {
+ } else if (!(_data.objectFlags & objectNoRecycle)) {
append(ObjectLimbo);
- parentID = ObjectLimbo;
+ _data.parentID = ObjectLimbo;
objectLimboCount++;
} else
- parentID = Nothing;
+ _data.parentID = Nothing;
}
// Delete this object and every object it contains
@@ -1277,10 +1283,10 @@ void GameObject::deleteObjectRecursive(void) {
assert((prototype->containmentSet() & ProtoObj::isTangible) != 0);
// If the object is already in a world there's nothing to do.
- if (isWorld(parentID))
+ if (isWorld(_data.parentID))
return;
else {
- ObjectID ancestorID = parentID;
+ ObjectID ancestorID = _data.parentID;
// Search up the parent chain
while (ancestorID > ImportantLimbo) {
@@ -1288,31 +1294,31 @@ void GameObject::deleteObjectRecursive(void) {
// If this ancestor is in a world, drop the object and
// we're done.
- if (isWorld(ancestor->parentID)) {
+ if (isWorld(ancestor->_data.parentID)) {
ancestor->dropInventoryObject(
this,
isMergeable()
- ? massCount
+ ? _data.massCount
: 1);
return;
}
- ancestorID = ancestor->parentID;
+ ancestorID = ancestor->_data.parentID;
}
}
}
// The object is not important so recursively call this function
// for all of its children.
else {
- if (childID != Nothing) {
+ if (_data.childID != Nothing) {
GameObject *childObj,
*nextChildObj;
- for (childObj = objectAddress(childID);
+ for (childObj = objectAddress(_data.childID);
childObj != nullptr;
childObj = nextChildObj) {
- nextChildObj = childObj->siblingID != Nothing
- ? objectAddress(childObj->siblingID)
+ nextChildObj = childObj->_data.siblingID != Nothing
+ ? objectAddress(childObj->_data.siblingID)
: nullptr;
childObj->deleteObjectRecursive();
}
@@ -1327,12 +1333,12 @@ void GameObject::deleteObjectRecursive(void) {
// Activate this object
void GameObject::activate(void) {
- if (objectFlags & objectActivated) return;
+ if (_data.objectFlags & objectActivated) return;
ObjectID dObj = thisID();
scriptCallFrame scf;
- objectFlags |= objectActivated;
+ _data.objectFlags |= objectActivated;
scf.invokedObject = dObj;
scf.enactor = dObj;
@@ -1349,13 +1355,13 @@ void GameObject::activate(void) {
// Deactivate this object
void GameObject::deactivate(void) {
- if (!(objectFlags & objectActivated)) return;
+ if (!(_data.objectFlags & objectActivated)) return;
ObjectID dObj = thisID();
scriptCallFrame scf;
// Clear activated flag
- objectFlags &= ~objectActivated;
+ _data.objectFlags &= ~objectActivated;
scf.invokedObject = dObj;
scf.enactor = dObj;
@@ -1380,7 +1386,7 @@ bool GameObject::isContaining(GameObject *item) {
while (iter.next(&containedObj) != Nothing) {
if (containedObj == item) return true;
- if (containedObj->childID != Nothing)
+ if (containedObj->_data.childID != Nothing)
if (containedObj->isContaining(item)) return true;
}
@@ -1396,7 +1402,7 @@ bool GameObject::isContaining(ObjectTarget *objTarget) {
while (iter.next(&containedObj) != Nothing) {
if (objTarget->isTarget(containedObj)) return true;
- if (containedObj->childID != Nothing)
+ if (containedObj->_data.childID != Nothing)
if (containedObj->isContaining(objTarget)) return true;
}
@@ -1410,13 +1416,13 @@ void GameObject::updateState(void) {
static TilePoint nullVelocity(0, 0, 0);
StandingTileInfo sti;
- tHeight = tileSlopeHeight(location, this, &sti);
+ tHeight = tileSlopeHeight(_data.location, this, &sti);
- if (!(location.z >= 0 || prototype->height > 8 - location.z))
+ if (!(_data.location.z >= 0 || prototype->height > 8 - _data.location.z))
drown(this);
- TilePoint subTile((location.u >> kSubTileShift) & kSubTileMask,
- (location.v >> kSubTileShift) & kSubTileMask,
+ TilePoint subTile((_data.location.u >> kSubTileShift) & kSubTileMask,
+ (_data.location.v >> kSubTileShift) & kSubTileMask,
0);
@@ -1440,15 +1446,15 @@ void GameObject::updateState(void) {
// currently at, then raise us up a bit.
if (isMoving()) return;
- if (objectFlags & objectFloating) return;
+ if (_data.objectFlags & objectFloating) return;
- if (tHeight > location.z + kMaxStepHeight) {
+ if (tHeight > _data.location.z + kMaxStepHeight) {
unstickObject(this);
- tHeight = tileSlopeHeight(location, this, &sti);
+ tHeight = tileSlopeHeight(_data.location, this, &sti);
}
- if (tHeight >= location.z - gravity * 4) {
+ if (tHeight >= _data.location.z - gravity * 4) {
setObjectSurface(this, sti);
- location.z = tHeight;
+ _data.location.z = tHeight;
return;
}
@@ -1526,7 +1532,7 @@ TilePoint GameObject::getFirstEmptySlot(GameObject *obj) {
}
//-----------------------------------------------------------------------
-// Return the location of the first available slot within this object
+// Return the _data.location of the first available slot within this object
// in which to place the specified object
bool GameObject::getAvailableSlot(
@@ -1550,7 +1556,7 @@ bool GameObject::getAvailableSlot(
== (ProtoObj::isContainer | ProtoObj::isIntangible)) {
// assert( isActor( obj ) );
- // Set intangible container locations to -1, -1.
+ // Set intangible container _data.locations to -1, -1.
tp->u = -1;
tp->v = -1;
return true;
@@ -1614,10 +1620,10 @@ bool GameObject::placeObject(
}
//-----------------------------------------------------------------------
-// Drop the specified object on the ground in a semi-random location
+// Drop the specified object on the ground in a semi-random _data.location
void GameObject::dropInventoryObject(GameObject *obj, int16 count) {
- assert(isWorld(parentID));
+ assert(isWorld(_data.parentID));
int16 dist;
int16 mapNum = getMapNum();
@@ -1635,26 +1641,26 @@ void GameObject::dropInventoryObject(GameObject *obj, int16 count) {
TilePoint probeLoc;
StandingTileInfo sti;
- // Compute a location to place the object
- probeLoc = location + incDirTable[dir] * dist;
+ // Compute a _data.location to place the object
+ probeLoc = _data.location + incDirTable[dir] * dist;
probeLoc.u += (rand() & 0x3) - 2;
probeLoc.v += (rand() & 0x3) - 2;
probeLoc.z = tileSlopeHeight(probeLoc, mapNum, obj, &sti);
- // If location is not blocked, drop the object
+ // If _data.location is not blocked, drop the object
if (checkBlocked(obj, mapNum, probeLoc) == blockageNone) {
// If we're dropping the object on a TAI, make sure
// we call the correct drop function
if (sti.surfaceTAG == nullptr) {
obj->drop(
thisID(),
- Location(probeLoc, parentID),
+ Location(probeLoc, _data.parentID),
count);
} else {
obj->dropOn(
thisID(),
sti.surfaceTAG,
- Location(probeLoc, parentID),
+ Location(probeLoc, _data.parentID),
count);
}
@@ -2155,7 +2161,7 @@ void GameObject::setProtoNum(int32 nProto) {
if (isActor(this))
prototype = &actorProtos[nProto];
else {
- ObjectID oldParentID = parentID;
+ ObjectID oldParentID = _data.parentID;
bool wasStacked = unstack(); // Unstack if it was in a stack
prototype = &objectProtos[nProto];
@@ -2206,7 +2212,7 @@ int32 GameObject::canStackOrMerge(GameObject *dropObj, GameObject *target) {
if (dropObj->proto()->flags & ResourceObjectPrototype::objPropMergeable) {
// If the flags are the same, and neither object has children,
// then we can merge
- if (((dropObj->objectFlags & noMergeFlags) == (target->objectFlags & noMergeFlags))
+ if (((dropObj->_data.objectFlags & noMergeFlags) == (target->_data.objectFlags & noMergeFlags))
&& dropObj->IDChild() == Nothing
&& target->IDChild() == Nothing) {
return canMerge;
@@ -2270,7 +2276,7 @@ bool GameObject::stack(ObjectID enactor, ObjectID objToStackID) {
if (objToStack->drop(enactor, loc)) {
if (!objToStack->isMoving()) {
// Increase the stack count
- location.z++;
+ _data.location.z++;
globalContainerList.setUpdate(IDParent());
}
@@ -2299,7 +2305,7 @@ uint16 GameObject::totalContainedMass(void) {
objMass *= childObj->getExtra();
total += objMass;
- if (childObj->childID != Nothing)
+ if (childObj->_data.childID != Nothing)
total += childObj->totalContainedMass();
}
@@ -3031,27 +3037,27 @@ void initObjects(void) {
// Objects which are inside other objects need to have their
// Z-coords initially forced to be 1 so that stacking works OK.
- if (!isWorld(obj->parentID)) obj->location.z = 1;
+ if (!isWorld(obj->_data.parentID)) obj->_data.location.z = 1;
- parent = GameObject::objectAddress(obj->parentID);
+ parent = GameObject::objectAddress(obj->_data.parentID);
if (parent->getAvailableSlot(obj, &slot))
- obj->move(Location(slot, obj->parentID));
+ obj->move(Location(slot, obj->_data.parentID));
// Add object to world.
- if (obj->parentID == Nothing) {
+ if (obj->_data.parentID == Nothing) {
obj->append(ObjectLimbo);
- obj->parentID = ObjectLimbo;
+ obj->_data.parentID = ObjectLimbo;
objectLimboCount++;
} else
- obj->append(obj->parentID);
+ obj->append(obj->_data.parentID);
}
for (; i < objectCount; i++) {
GameObject *obj = &objectList[i];
- obj->siblingID = obj->childID = Nothing;
+ obj->_data.siblingID = obj->_data.childID = Nothing;
obj->append(ObjectLimbo);
- obj->parentID = ObjectLimbo;
+ obj->_data.parentID = ObjectLimbo;
objectLimboCount++;
}
@@ -3060,11 +3066,11 @@ void initObjects(void) {
for (i = 0; i < actorCount; i++) {
Actor *a = &actorList[i];
- if (a->parentID == Nothing) {
+ if (a->_data.parentID == Nothing) {
a->append(ActorLimbo);
actorLimboCount++;
} else
- a->append(a->parentID);
+ a->append(a->_data.parentID);
}
#if DEBUG
@@ -3259,7 +3265,7 @@ void ActiveRegion::update(void) {
TileRegion ptRegion,
newRegion;
- // Update the anchor location
+ // Update the anchor _data.location
anchorLoc = loc;
// Determine the active region in points
@@ -4066,7 +4072,7 @@ ObjectID ActiveRegionObjectIterator::next(GameObject **obj) {
ContainerIterator::ContainerIterator(GameObject *container) {
// Get the ID of the 1st object in the sector list
- nextID = &container->childID;
+ nextID = &container->_data.childID;
object = nullptr;
}
@@ -4076,7 +4082,7 @@ ObjectID ContainerIterator::next(GameObject **obj) {
if (id == Nothing) return Nothing;
object = GameObject::objectAddress(id);
- nextID = &object->siblingID;
+ nextID = &object->_data.siblingID;
if (obj) *obj = object;
return id;
@@ -4296,7 +4302,7 @@ bool lineOfSight(GameObject *obj1, GameObject *obj2, uint32 terrainMask) {
}
/* ======================================================================= *
- Test for line of sight between object and location
+ Test for line of sight between object and _data.location
* ======================================================================= */
bool lineOfSight(GameObject *obj, const TilePoint &loc, uint32 terrainMask) {
@@ -4318,7 +4324,7 @@ bool lineOfSight(GameObject *obj, const TilePoint &loc, uint32 terrainMask) {
/* ======================================================================= *
- Test for line of sight between two locations
+ Test for line of sight between two _data.locations
* ======================================================================= */
bool lineOfSight(
@@ -4583,26 +4589,26 @@ void doBackgroundSimulation(void) {
// Debug code to verify the validity of the limbo counts
#if DEBUG
int16 count;
- ObjectID childID;
+ ObjectID _data.childID;
count = 0;
- for (childID = GameObject::objectAddress(ObjectLimbo)->IDChild();
- childID != Nothing;
- childID = GameObject::objectAddress(childID)->IDNext())
+ for (_data.childID = GameObject::objectAddress(ObjectLimbo)->IDChild();
+ _data.childID != Nothing;
+ _data.childID = GameObject::objectAddress(_data.childID)->IDNext())
count++;
assert(objectLimboCount == count);
count = 0;
- for (childID = GameObject::objectAddress(ActorLimbo)->IDChild();
- childID != Nothing;
- childID = GameObject::objectAddress(childID)->IDNext())
+ for (_data.childID = GameObject::objectAddress(ActorLimbo)->IDChild();
+ _data.childID != Nothing;
+ _data.childID = GameObject::objectAddress(_data.childID)->IDNext())
count++;
assert(actorLimboCount == count);
count = 0;
- for (childID = GameObject::objectAddress(ImportantLimbo)->IDChild();
- childID != Nothing;
- childID = GameObject::objectAddress(childID)->IDNext())
+ for (_data.childID = GameObject::objectAddress(ImportantLimbo)->IDChild();
+ _data.childID != Nothing;
+ _data.childID = GameObject::objectAddress(_data.childID)->IDNext())
count++;
assert(importantLimboCount == count);
#endif
diff --git a/engines/saga2/objects.h b/engines/saga2/objects.h
index 9b483a0c94..c3e3b5e71c 100644
--- a/engines/saga2/objects.h
+++ b/engines/saga2/objects.h
@@ -76,6 +76,14 @@ struct ResourceGameObject {
uint16 objectFlags;
uint8 hitPoints;
uint16 misc;
+ union {
+ uint16 massCount; // for mergeables, object count
+ uint16 textStringID; // inscription for documents
+ uint16 enchantmentType; // for enchantments
+ uint16 generatorFrequency; // for encounter and mission generators
+ };
+
+ uint8 missileFacing;
};
// Base class of all objects
@@ -84,6 +92,38 @@ struct ResourceGameObject {
// the actor subclass, which is kept in an entirely seperate table.
// This allows all objects to be kept in an array (indexed by ID number)
+#include "common/pack-start.h"
+
+struct ObjectData {
+ uint32 projectDummy;
+ TilePoint location; // where object is located.
+ uint16 nameIndex; // object's proper name, if any
+ ObjectID parentID, // ID of parent object
+ siblingID, // ID of next in chain
+ childID; // ID of 1st child
+ uint16 script; // script attached to this object
+ uint16 objectFlags; // various flags
+ uint8 hitPoints; // object hit points
+ uint8 bParam; // number of spell charges an object has
+ // (also generator radius in metatiles)
+ union {
+ uint16 massCount; // for mergeables, object count
+ uint16 textStringID; // inscription for documents
+ uint16 enchantmentType; // for enchantments
+ uint16 generatorFrequency; // for encounter and mission generators
+ };
+
+ uint8 missileFacing;
+ ActiveItemID currentTAG; // ActiveItem object is on
+ uint8 sightCtr; // Line of sight counter
+
+ uint8 reserved[2];
+
+ GameObject *obj;
+};
+
+#include "common/pack-end.h"
+
void initActors(void);
void saveActors(SaveFileConstructor &);
void loadActors(SaveFileReader &);
@@ -146,31 +186,8 @@ protected:
void protoAddressToOffset(void); // converts proto address to offset in resource file
ProtoObj *prototype; // object that defines our behavior
- TilePoint location; // where object is located.
- uint16 nameIndex; // object's proper name, if any
- ObjectID parentID, // ID of parent object
- siblingID, // ID of next in chain
- childID; // ID of 1st child
- uint16 script; // script attached to this object
- uint16 objectFlags; // various flags
- uint8 hitPoints; // object hit points
- uint8 bParam; // number of spell charges an object has
- // (also generator radius in metatiles)
- union {
- uint16 massCount; // for mergeables, object count
- uint16 textStringID; // inscription for documents
- uint16 enchantmentType; // for enchantments
- uint16 generatorFrequency; // for encounter and mission generators
- };
-
- uint8 missileFacing;
-
public:
- ActiveItemID currentTAG; // ActiveItem object is on
- uint8 sightCtr; // Line of sight counter
-
- uint8 reserved[2];
-
+ ObjectData _data;
// Default constructor
GameObject(void);
@@ -202,24 +219,24 @@ public:
// Return pointer to parent/child/next sibling object, if any
GameObject *parent(void) {
- return parentID == Nothing ? NULL : objectAddress(parentID);
+ return _data.parentID == Nothing ? NULL : objectAddress(_data.parentID);
}
GameObject *next(void) {
- return siblingID == Nothing ? NULL : objectAddress(siblingID);
+ return _data.siblingID == Nothing ? NULL : objectAddress(_data.siblingID);
}
GameObject *child(void) {
- return childID == Nothing ? NULL : objectAddress(childID);
+ return _data.childID == Nothing ? NULL : objectAddress(_data.childID);
}
// Return ID of parent/child/next sibling object, if any
ObjectID IDParent(void) {
- return parentID ;
+ return _data.parentID ;
}
ObjectID IDNext(void) {
- return siblingID;
+ return _data.siblingID;
}
ObjectID IDChild(void) {
- return childID ;
+ return _data.childID ;
}
// Return a pointer to the world on which this object resides
@@ -289,7 +306,7 @@ public:
// Determine if this object is an alias for another object
bool isAlias() {
- return (objectFlags & objectAlias) != 0;
+ return (_data.objectFlags & objectAlias) != 0;
}
// check to see if item can be contained by this object
@@ -440,7 +457,7 @@ public:
return prototype;
}
TilePoint getLocation(void) {
- return location;
+ return _data.location;
}
TilePoint getWorldLocation(void);
bool getWorldLocation(Location &loc);
@@ -450,7 +467,7 @@ public:
// Return the name of this object (proper noun if it has one)
char *objName(void) {
return nameText((int16)(
- nameIndex > 0 ? nameIndex : prototype->nameIndex));
+ _data.nameIndex > 0 ? _data.nameIndex : prototype->nameIndex));
}
// return name of object, and it's quantity if merged
@@ -461,10 +478,10 @@ public:
// Access functions for name index
uint16 getNameIndex(void) {
- return nameIndex;
+ return _data.nameIndex;
}
void setNameIndex(uint16 n) {
- nameIndex = n;
+ _data.nameIndex = n;
}
// Return the name of this type of object
@@ -478,77 +495,77 @@ public:
// Flag test functions
bool isOpen(void) {
- return (int16)(objectFlags & objectOpen);
+ return (int16)(_data.objectFlags & objectOpen);
}
bool isLocked(void) {
- return (int16)(objectFlags & objectLocked);
+ return (int16)(_data.objectFlags & objectLocked);
}
bool isImportant(void) {
- return (int16)(objectFlags & objectImportant);
+ return (int16)(_data.objectFlags & objectImportant);
}
bool isGhosted(void) {
- return (objectFlags & objectGhosted)
+ return (_data.objectFlags & objectGhosted)
|| (prototype->flags & ResourceObjectPrototype::objPropGhosted);
}
bool isInvisible(void) {
- return (objectFlags & objectInvisible)
+ return (_data.objectFlags & objectInvisible)
|| (prototype->flags & ResourceObjectPrototype::objPropHidden);
}
bool isMoving(void) {
- return (int16)(objectFlags & objectMoving);
+ return (int16)(_data.objectFlags & objectMoving);
}
bool isActivated(void) {
- return (int16)(objectFlags & objectActivated);
+ return (int16)(_data.objectFlags & objectActivated);
}
void setScavengable(bool val) {
if (val)
- objectFlags |= objectScavengable;
+ _data.objectFlags |= objectScavengable;
else
- objectFlags &= ~objectScavengable;
+ _data.objectFlags &= ~objectScavengable;
}
bool isScavengable(void) {
- return (objectFlags & objectScavengable) != 0;
+ return (_data.objectFlags & objectScavengable) != 0;
}
void setObscured(bool val) {
if (val)
- objectFlags |= objectObscured;
+ _data.objectFlags |= objectObscured;
else
- objectFlags &= ~objectObscured;
+ _data.objectFlags &= ~objectObscured;
}
bool isObscured(void) {
- return (objectFlags & objectObscured) != 0;
+ return (_data.objectFlags & objectObscured) != 0;
}
void setTriggeringTAG(bool val) {
if (val)
- objectFlags |= objectTriggeringTAG;
+ _data.objectFlags |= objectTriggeringTAG;
else
- objectFlags &= ~objectTriggeringTAG;
+ _data.objectFlags &= ~objectTriggeringTAG;
}
bool isTriggeringTAG(void) {
- return (objectFlags & objectTriggeringTAG) != 0;
+ return (_data.objectFlags & objectTriggeringTAG) != 0;
}
void setOnScreen(bool val) {
if (val)
- objectFlags |= objectOnScreen;
+ _data.objectFlags |= objectOnScreen;
else
- objectFlags &= ~objectOnScreen;
+ _data.objectFlags &= ~objectOnScreen;
}
bool isOnScreen(void) {
- return (objectFlags & objectOnScreen) != 0;
+ return (_data.objectFlags & objectOnScreen) != 0;
}
void setSightedByCenter(bool val) {
if (val)
- objectFlags |= objectSightedByCenter;
+ _data.objectFlags |= objectSightedByCenter;
else
- objectFlags &= ~objectSightedByCenter;
+ _data.objectFlags &= ~objectSightedByCenter;
}
bool isSightedByCenter(void) {
- return (objectFlags & objectSightedByCenter) != 0;
+ return (_data.objectFlags & objectSightedByCenter) != 0;
}
bool isMissile(void) {
@@ -563,8 +580,8 @@ public:
uint16 containmentSet(void);
uint16 scriptClass(void) {
- if (script)
- return script;
+ if (_data.script)
+ return _data.script;
if (prototype)
return prototype->script;
return 0;
@@ -574,25 +591,25 @@ public:
// Script access functions
uint16 getScript(void) {
- return script;
+ return _data.script;
}
void setScript(uint16 scr) {
- script = scr;
+ _data.script = scr;
}
// access function to set object flags
void setFlags(uint8 newval, uint8 changeMask) {
// Only change the flags spec'd by changeFlags
- objectFlags = (newval & changeMask)
- | (objectFlags & ~changeMask);
+ _data.objectFlags = (newval & changeMask)
+ | (_data.objectFlags & ~changeMask);
}
// Access functions for hit points
uint8 getHitPoints(void) {
- return hitPoints;
+ return _data.hitPoints;
}
void setHitPoints(uint8 hp) {
- hitPoints = hp;
+ _data.hitPoints = hp;
}
// Builds the color remapping for this object based on the
@@ -607,10 +624,10 @@ public:
// Acess functions for extra data
uint16 getExtra(void) {
- return massCount;
+ return _data.massCount;
}
void setExtra(uint16 x) {
- massCount = x;
+ _data.massCount = x;
}
// Function to evaluate the effects of all enchantments
diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp
index a9fcfc5bf3..49f906533c 100644
--- a/engines/saga2/objproto.cpp
+++ b/engines/saga2/objproto.cpp
@@ -815,13 +815,13 @@ ObjectSpriteInfo ProtoObj::getSprite(GameObject *obj, enum spriteTypes spr, int1
// sprite
if (obj->isMoving()
&& obj->isMissile()
- && obj->missileFacing < 16) {
+ && obj->_data.missileFacing < 16) {
int16 sprIndex;
- if (obj->missileFacing < 8)
- sprIndex = obj->missileFacing;
+ if (obj->_data.missileFacing < 8)
+ sprIndex = obj->_data.missileFacing;
else {
- sprIndex = 16 - obj->missileFacing;
+ sprIndex = 16 - obj->_data.missileFacing;
sprInfo.flipped = true;
}
@@ -1066,10 +1066,10 @@ bool InventoryProto::dropAction(
}
*/
// If this object is on a TAG release it
- if (dObjPtr->currentTAG != NoActiveItem) {
- ActiveItem::activeItemAddress(dObjPtr->currentTAG)->release(
+ if (dObjPtr->_data.currentTAG != NoActiveItem) {
+ ActiveItem::activeItemAddress(dObjPtr->_data.currentTAG)->release(
enactor, dObj);
- dObjPtr->currentTAG = NoActiveItem;
+ dObjPtr->_data.currentTAG = NoActiveItem;
}
if (isWorld(loc.context)) {
@@ -1160,7 +1160,7 @@ bool InventoryProto::dropOnAction(
// If we weren't thrown, try triggering the TAG
if (!dObjPtr->isMoving() && target->trigger(enactor, dObj))
- dObjPtr->currentTAG = target->thisID();
+ dObjPtr->_data.currentTAG = target->thisID();
return true;
}
@@ -1242,7 +1242,7 @@ bool PhysicalContainerProto::useAction(ObjectID dObj, ObjectID enactor) {
bool result;
GameObject *dObjPtr = GameObject::objectAddress(dObj);
- if (dObjPtr->objectFlags & objectOpen)
+ if (dObjPtr->_data.objectFlags & objectOpen)
result = close(dObj, enactor);
else
result = open(dObj, enactor);
@@ -1267,7 +1267,7 @@ bool PhysicalContainerProto::openAction(ObjectID dObj, ObjectID) {
cn = CreateContainerNode(dObj, false);
cn->markForShow(); // Deferred open
- dObjPtr->objectFlags |= objectOpen; // Set open bit;
+ dObjPtr->_data.objectFlags |= objectOpen; // Set open bit;
globalContainerList.setUpdate(dObjPtr->IDParent());
return true;
}
@@ -1283,7 +1283,7 @@ bool PhysicalContainerProto::closeAction(ObjectID dObj, ObjectID) {
cn->markForDelete();
// Clear open bit
- dObjPtr->objectFlags &= ~objectOpen;
+ dObjPtr->_data.objectFlags &= ~objectOpen;
globalContainerList.setUpdate(dObjPtr->IDParent());
return true;
}
@@ -1305,7 +1305,7 @@ bool PhysicalContainerProto::acceptLockToggleAction(
GameObject *dObjPtr = GameObject::objectAddress(dObj);
// Toggle locked bit
- dObjPtr->objectFlags ^= objectLocked;
+ dObjPtr->_data.objectFlags ^= objectLocked;
return true;
}
@@ -1323,7 +1323,7 @@ bool PhysicalContainerProto::acceptInsertionAction(
GameObject *itemPtr = GameObject::objectAddress(item);
// Place the object in the container (if possible)
- if ((dObjPtr->objectFlags & objectLocked)
+ if ((dObjPtr->_data.objectFlags & objectLocked)
|| !dObjPtr->placeObject(enactor, item, true, num)) {
if (isWorld(dObjPtr->IDParent()))
dObjPtr->dropInventoryObject(itemPtr, num);
@@ -1456,7 +1456,7 @@ bool KeyProto::useOnAction(ObjectID dObj, ObjectID enactor, ObjectID withObj) {
GameObject *container = GameObject::objectAddress(withObj),
*thisKey = GameObject::objectAddress(dObj);
- int16 keyID = thisKey->massCount > 0 ? thisKey->massCount : lockType;
+ int16 keyID = thisKey->_data.massCount > 0 ? thisKey->_data.massCount : lockType;
if (!container->acceptLockToggle(enactor, lockType)) {
// WriteStatusF( 3, "%s doesn't work", thisKey->objName() );
@@ -1470,7 +1470,7 @@ bool KeyProto::useOnAction(ObjectID dObj, ObjectID enactor, ObjectID withObj) {
bool KeyProto::useOnAction(ObjectID dObj, ObjectID enactor, ActiveItem *withTAI) {
GameObject *thisKey = GameObject::objectAddress(dObj);
- int16 keyID = thisKey->massCount > 0 ? thisKey->massCount : lockType;
+ int16 keyID = thisKey->_data.massCount > 0 ? thisKey->_data.massCount : lockType;
if (!withTAI->acceptLockToggle(enactor, keyID)) {
// WriteStatusF( 3, "%s doesn't work", thisKey->objName() );
@@ -2990,7 +2990,7 @@ bool IntangibleContainerProto::useAction(ObjectID dObj, ObjectID enactor) {
bool result;
GameObject *dObjPtr = GameObject::objectAddress(dObj);
- if (dObjPtr->objectFlags & objectOpen)
+ if (dObjPtr->_data.objectFlags & objectOpen)
result = close(dObj, enactor);
else
result = open(dObj, enactor);
@@ -3014,7 +3014,7 @@ bool IntangibleContainerProto::openAction(ObjectID dObj, ObjectID enactor) {
// Perform appropriate opening tasks
cn = CreateContainerNode(enactor, false);
cn->markForShow();
-// dObjPtr->objectFlags |= GameObject::objectOpen; // Set open bit;
+// dObjPtr->_data.objectFlags |= GameObject::objectOpen; // Set open bit;
return true;
}
@@ -3029,7 +3029,7 @@ bool IntangibleContainerProto::closeAction(ObjectID dObj, ObjectID) {
cn->markForDelete();
// Clear open bit
-// dObjPtr->objectFlags &= ~GameObject::objectOpen;
+// dObjPtr->_data.objectFlags &= ~GameObject::objectOpen;
return true;
}
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index f0be3c6b13..86aeaa3944 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -597,7 +597,7 @@ bool ActiveItem::trigger(ActiveItem *ins, ObjectID enactor, ObjectID objID) {
testObject != nullptr;
iter.next(&testObject)) {
if (testObject != obj
- && testObject->currentTAG == instanceID
+ && testObject->_data.currentTAG == instanceID
&& testObject->isTriggeringTAG())
return true;
}
@@ -685,7 +685,7 @@ bool ActiveItem::release(ActiveItem *ins, ObjectID enactor, ObjectID objID) {
testObject != nullptr;
iter.next(&testObject)) {
if (testObject != obj
- && testObject->currentTAG == instanceID
+ && testObject->_data.currentTAG == instanceID
&& testObject->isTriggeringTAG())
return true;
}
Commit: baa7cbb498f56eece8258849463fcbb56e7f5f4d
https://github.com/scummvm/scummvm/commit/baa7cbb498f56eece8258849463fcbb56e7f5f4d
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:17+02:00
Commit Message:
SAGA2: Make GameObject script-friendly
Changed paths:
engines/saga2/interp.cpp
engines/saga2/objects.h
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index c448a9654d..9ad1f3b819 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -86,7 +86,7 @@ uint8 *builtinObjectAddress(int16 segment, uint16 index) {
switch (segment) {
case builtinTypeObject:
- return (uint8 *)GameObject::objectAddress(index);
+ return (uint8 *)(&GameObject::objectAddress(index)->_data);
case builtinTypeTAG:
return (uint8 *)(&ActiveItem::activeItemAddress(index)->_data);
diff --git a/engines/saga2/objects.h b/engines/saga2/objects.h
index c3e3b5e71c..fb8dfac90d 100644
--- a/engines/saga2/objects.h
+++ b/engines/saga2/objects.h
@@ -120,7 +120,7 @@ struct ObjectData {
uint8 reserved[2];
GameObject *obj;
-};
+} PACKED_STRUCT;
#include "common/pack-end.h"
Commit: 260a82c3e0d3edd7db55f70c0d652e0ee3a57109
https://github.com/scummvm/scummvm/commit/260a82c3e0d3edd7db55f70c0d652e0ee3a57109
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:17+02:00
Commit Message:
SAGA2: Reenable game timers
Changed paths:
engines/saga2/timers.cpp
diff --git a/engines/saga2/timers.cpp b/engines/saga2/timers.cpp
index 222d46334e..727fdcd439 100644
--- a/engines/saga2/timers.cpp
+++ b/engines/saga2/timers.cpp
@@ -48,7 +48,7 @@ void timerCallback(void *refCon) {
void initTimer(void) {
gameTime = 0;
- //g_vm->getTimerManager()->installTimerProc(&timerCallback, 1000 / 72, nullptr, "saga2");
+ g_vm->getTimerManager()->installTimerProc(&timerCallback, 1000 / 72, nullptr, "saga2");
}
void pauseTimer() {
Commit: b5359d7202ce39d6f3550c435e0f9138890c00cb
https://github.com/scummvm/scummvm/commit/b5359d7202ce39d6f3550c435e0f9138890c00cb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:17+02:00
Commit Message:
SAGA2: Fix incorrect object accesses
Changed paths:
engines/saga2/interp.cpp
engines/saga2/sagafunc.cpp
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 9ad1f3b819..9296129a7d 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -127,7 +127,7 @@ uint16 *builtinVTableAddress(int16 btype, uint8 *addr, CallTable **callTab) {
case builtinTypeObject:
// Get the address of a game object using the ID
- obj = (GameObject *)addr;
+ obj = ((ObjectData *)addr)->obj;
script = obj->scriptClass();
*callTab = &actorCFuncs;
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index 8ab77f1edb..006f29c0b2 100644
--- a/engines/saga2/sagafunc.cpp
+++ b/engines/saga2/sagafunc.cpp
@@ -58,7 +58,7 @@ void drawMainDisplay(void);
#endif
#define MONOLOG(s) {debugC(2, kDebugScripts, "cfunc: " #s );}
-#define OBJLOG(s) {debugC(2, kDebugScripts, "cfunc: [%s]." #s , ((GameObject *)thisThread->thisObject)->objName() );}
+#define OBJLOG(s) {debugC(2, kDebugScripts, "cfunc: [%s]." #s , ((ObjectData *)thisThread->thisObject)->obj->objName() );}
namespace Saga2 {
Commit: 5b1671fb69985e526a38e30bcee02b29b6b6fdd6
https://github.com/scummvm/scummvm/commit/5b1671fb69985e526a38e30bcee02b29b6b6fdd6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:17+02:00
Commit Message:
SAGA2: Fix overridden methods
Changed paths:
engines/saga2/automap.cpp
engines/saga2/display.cpp
engines/saga2/floating.cpp
engines/saga2/floating.h
engines/saga2/msgbox.cpp
engines/saga2/panel.cpp
engines/saga2/panel.h
engines/saga2/playmode.cpp
engines/saga2/uidialog.cpp
engines/saga2/videobox.cpp
diff --git a/engines/saga2/automap.cpp b/engines/saga2/automap.cpp
index 0d042a67b0..9d2c60fe80 100644
--- a/engines/saga2/automap.cpp
+++ b/engines/saga2/automap.cpp
@@ -577,7 +577,7 @@ int16 openAutoMap() {
decRes = NULL;
// clean up the backwindow
- mainWindow->invalidate(autoMapRect);
+ mainWindow->invalidate(&autoMapRect);
return rInfo.result;
}
diff --git a/engines/saga2/display.cpp b/engines/saga2/display.cpp
index e17c7f5513..9bdaf5ec0c 100644
--- a/engines/saga2/display.cpp
+++ b/engines/saga2/display.cpp
@@ -242,7 +242,7 @@ void reDrawScreen(void) {
if (mainWindow && displayEnabled()) {
//updateAllUserControls();
drawMainDisplay();
- mainWindow->invalidate(r);
+ mainWindow->invalidate(&r);
delayReDraw = false;
if (paletteMayHaveChanged) {
paletteMayHaveChanged = false;
diff --git a/engines/saga2/floating.cpp b/engines/saga2/floating.cpp
index a86a4e6f86..cbc7143021 100644
--- a/engines/saga2/floating.cpp
+++ b/engines/saga2/floating.cpp
@@ -213,9 +213,9 @@ BackWindow::BackWindow(const Rect16 &r, uint16 ident, AppFunc *cmd)
: DecoratedWindow(r, ident, "", cmd) {
}
-void BackWindow::invalidate(Rect16 &area) {
+void BackWindow::invalidate(Rect16 *area) {
if (displayEnabled())
- window.update(area);
+ window.update(*area);
}
// Return true if window floats above animated are
diff --git a/engines/saga2/floating.h b/engines/saga2/floating.h
index bf17824aff..06c5e88262 100644
--- a/engines/saga2/floating.h
+++ b/engines/saga2/floating.h
@@ -246,7 +246,7 @@ class BackWindow : public DecoratedWindow {
public:
BackWindow(const Rect16 &, uint16, AppFunc *cmd = NULL);
- void invalidate(Rect16 &area);
+ void invalidate(Rect16 *area);
virtual bool isBackdrop(void);
};
diff --git a/engines/saga2/msgbox.cpp b/engines/saga2/msgbox.cpp
index e3a58215b2..af1748e8b2 100644
--- a/engines/saga2/msgbox.cpp
+++ b/engines/saga2/msgbox.cpp
@@ -184,7 +184,7 @@ int16 ErrorWindow::getResult(void) {
}
ErrorWindow::~ErrorWindow() {
- mainWindow->invalidate(mbWindowRect);
+ mainWindow->invalidate(&mbWindowRect);
}
diff --git a/engines/saga2/panel.cpp b/engines/saga2/panel.cpp
index f556fea53d..35d107696d 100644
--- a/engines/saga2/panel.cpp
+++ b/engines/saga2/panel.cpp
@@ -160,7 +160,7 @@ void gPanel::makeActive(void) {
G_BASE.setActive(this);
}
-void gPanel::invalidate(void) {
+void gPanel::invalidate(Rect16 *) {
assert(displayEnabled());
window.update(extent);
}
@@ -273,7 +273,7 @@ void gPanelList::enable(bool abled) {
gPanel::enable(abled);
}
-void gPanelList::invalidate(void) {
+void gPanelList::invalidate(Rect16 *) {
gControl *ctl;
Rect16 invArea;
diff --git a/engines/saga2/panel.h b/engines/saga2/panel.h
index ad0867d131..0d8747ff52 100644
--- a/engines/saga2/panel.h
+++ b/engines/saga2/panel.h
@@ -179,7 +179,7 @@ public:
virtual void enable(bool abled);
virtual void select(bool selected);
virtual void ghost(bool ghosted);
- virtual void invalidate(void);
+ virtual void invalidate(Rect16 *area = nullptr);
virtual void setMousePoll(bool abled) {
wantMousePoll = abled ? 1 : 0;
}
@@ -210,7 +210,8 @@ public:
}
void show(bool shown = true, bool inval = true) {
enable(shown);
- if (inval) invalidate();
+ if (inval)
+ invalidate();
}
void moveToFront(gPanelList &l);
@@ -268,7 +269,7 @@ public:
void removeControls(void);
public:
- void invalidate(void);
+ void invalidate(Rect16 *area = nullptr);
void draw(void); // redraw the controls
void drawClipped(
gPort &port,
diff --git a/engines/saga2/playmode.cpp b/engines/saga2/playmode.cpp
index fa2d364909..f29a355026 100644
--- a/engines/saga2/playmode.cpp
+++ b/engines/saga2/playmode.cpp
@@ -165,7 +165,7 @@ void clearTileAreaPort(void) {
}
Rect16 rect(0, 0, 640, 480);
- mainWindow->invalidate(rect);
+ mainWindow->invalidate(&rect);
}
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index a79b6cec7a..4ee2a5c152 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -773,7 +773,7 @@ int16 FileDialog(int16 fileProcess) {
destroyFileFields(fieldStrings);
// replace the damaged area
- mainWindow->invalidate(saveLoadWindowRect);
+ mainWindow->invalidate(&saveLoadWindowRect);
// return the result code
return rInfo.result;
@@ -983,7 +983,7 @@ int16 OptionsDialog(bool disableSaveResume) {
saveGameState(deferredLoadID, deferredSaveName);
#endif
}
- mainWindow->invalidate(optionsWindowRect);
+ mainWindow->invalidate(&optionsWindowRect);
}
// return the result code
@@ -1272,7 +1272,7 @@ int16 userDialog(const char *title, const char *msg, const char *bMsg1,
decRes = nullptr;
// replace the damaged area
- mainWindow->invalidate(messageWindowRect);
+ mainWindow->invalidate(&messageWindowRect);
// return the result code
return rInfo.result % 10;
@@ -1607,7 +1607,7 @@ void placardWindow(int8 type, char *text) {
if (resContext) resFile->disposeContext(resContext);
// replace the damaged area
- mainWindow->invalidate(plaqRectBrass); // brass just happens to be the largest rect....
+ mainWindow->invalidate(&plaqRectBrass); // brass just happens to be the largest rect....
// return the result code
//return rInfo.result;
diff --git a/engines/saga2/videobox.cpp b/engines/saga2/videobox.cpp
index f236be3891..168d4272b2 100644
--- a/engines/saga2/videobox.cpp
+++ b/engines/saga2/videobox.cpp
@@ -184,7 +184,7 @@ int16 openVidBox(char *fileName) {
quickRestorePalette();
// replace the damaged area
- mainWindow->invalidate(area);
+ mainWindow->invalidate(&area);
// return the result code
return result;
Commit: 1919ef1f5e88524e2ff496e1244cb928f16a9a10
https://github.com/scummvm/scummvm/commit/1919ef1f5e88524e2ff496e1244cb928f16a9a10
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:17+02:00
Commit Message:
SAGA2: Fix GameObject referencing in sagafunc.cpp
Changed paths:
engines/saga2/interp.cpp
engines/saga2/objects.cpp
engines/saga2/sagafunc.cpp
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 9296129a7d..6c535bd3bb 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -305,12 +305,14 @@ uint8 *objectAddress(
IMMED_WORD(index);
seg = dataSegIndex;
addr = &dataSegment[index];
+ debugC(3, kDebugScripts, "data [%d] (%p)", index, addr);
break;
case addr_far:
IMMED_WORD(seg);
IMMED_WORD(index);
addr = segmentAddress(seg, index);
+ debugC(3, kDebugScripts, "far [%d, %d] (%p)", seg, index, addr);
break;
case addr_array:
@@ -318,6 +320,7 @@ uint8 *objectAddress(
IMMED_WORD(index);
IMMED_WORD(offset);
addr = segmentArrayAddress(seg, index) + offset;
+ debugC(3, kDebugScripts, "array [%d, %d, %d] (%p)", seg, index, offset, addr);
break;
case addr_this:
@@ -325,9 +328,12 @@ uint8 *objectAddress(
arg = (uint16 *)(th->stackBase + th->framePtr + 8);
seg = arg[0];
index = arg[1];
- if (seg == dataSegIndex)
+ if (seg == dataSegIndex) {
+ debugC(3, kDebugScripts, "this (D) [%d, %d] (%p)", index, offset, &dataSegment[index + offset]);
return &dataSegment[index + offset];
+ }
addr = segmentArrayAddress(seg, index) + offset;
+ debugC(3, kDebugScripts, "this (S) [%d, %d, %d] (%p)", seg, index, offset, addr);
break;
case addr_deref:
@@ -347,6 +353,7 @@ uint8 *objectAddress(
// Compute address of object
addr = segmentAddress(seg, index) + offset;
+ debugC(3, kDebugScripts, "deref [%d, %d, %d] (%p)", seg, index, offset, addr);
break;
default:
@@ -820,7 +827,7 @@ bool Thread::interpret(void) {
error("Invalid member function number");
// Set up thread-specific vars
- thisObject = addr;
+ thisObject = ((ObjectData *)addr)->obj;
argCount = n;
threadArgs.invokedObject = offset;
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 0be96d011c..37adca28e0 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -195,6 +195,7 @@ struct GameObjectArchive {
GameObject::GameObject(void) {
prototype = nullptr;
+ _data.projectDummy = 0;
_data.location = Nowhere;
_data.nameIndex = 0;
_data.parentID = Nothing;
@@ -218,6 +219,7 @@ GameObject::GameObject(void) {
GameObject::GameObject(const ResourceGameObject &res) {
prototype = &objectProtos[res.protoIndex];
+ _data.projectDummy = 0;
_data.location = res.location;
_data.nameIndex = res.nameIndex;
_data.parentID = res.parentID;
@@ -247,6 +249,7 @@ GameObject::GameObject(void **buf) {
? &objectProtos[a->protoIndex]
: nullptr;
+ _data.projectDummy = 0;
_data.location = a->location;
_data.nameIndex = a->nameIndex;
_data.parentID = a->parentID;
@@ -3017,7 +3020,10 @@ void initObjects(void) {
GameObject *obj = &objectList[i];
// Use the default constructor for the extra actors
- new (obj) GameObject;
+ if (i == 4970)
+ new (obj) GameObject;
+ else
+ new (obj) GameObject;
}
delete[] resourceObjectList;
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index 006f29c0b2..8ab77f1edb 100644
--- a/engines/saga2/sagafunc.cpp
+++ b/engines/saga2/sagafunc.cpp
@@ -58,7 +58,7 @@ void drawMainDisplay(void);
#endif
#define MONOLOG(s) {debugC(2, kDebugScripts, "cfunc: " #s );}
-#define OBJLOG(s) {debugC(2, kDebugScripts, "cfunc: [%s]." #s , ((ObjectData *)thisThread->thisObject)->obj->objName() );}
+#define OBJLOG(s) {debugC(2, kDebugScripts, "cfunc: [%s]." #s , ((GameObject *)thisThread->thisObject)->objName() );}
namespace Saga2 {
Commit: 189b558e94685c80351def87719c51cdf5af1a73
https://github.com/scummvm/scummvm/commit/189b558e94685c80351def87719c51cdf5af1a73
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:17+02:00
Commit Message:
SAGA2: Remove unnecessary if
Changed paths:
engines/saga2/objects.cpp
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 37adca28e0..6dad9fc545 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -3020,10 +3020,7 @@ void initObjects(void) {
GameObject *obj = &objectList[i];
// Use the default constructor for the extra actors
- if (i == 4970)
- new (obj) GameObject;
- else
- new (obj) GameObject;
+ new (obj) GameObject;
}
delete[] resourceObjectList;
Commit: 7fe61635e0722ce54135eb8c352d9bf491b1a31e
https://github.com/scummvm/scummvm/commit/7fe61635e0722ce54135eb8c352d9bf491b1a31e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:18+02:00
Commit Message:
SAGA2: Fix more override warnings
Changed paths:
engines/saga2/button.cpp
engines/saga2/button.h
engines/saga2/intrface.cpp
engines/saga2/intrface.h
diff --git a/engines/saga2/button.cpp b/engines/saga2/button.cpp
index 22ef2b463d..3fa7d1e392 100644
--- a/engines/saga2/button.cpp
+++ b/engines/saga2/button.cpp
@@ -210,7 +210,7 @@ void gCompImage::enable(bool abled) {
gPanel::enable(abled);
}
-void gCompImage::invalidate(void) {
+void gCompImage::invalidate(Rect16 *) {
window.update(extent);
}
@@ -564,7 +564,7 @@ void gCompButton::enable(bool abled) {
gPanel::enable(abled);
}
-void gCompButton::invalidate(void) {
+void gCompButton::invalidate(Rect16 *) {
window.update(extent);
}
diff --git a/engines/saga2/button.h b/engines/saga2/button.h
index 67e19fbd04..b3bbb2154e 100644
--- a/engines/saga2/button.h
+++ b/engines/saga2/button.h
@@ -129,7 +129,7 @@ public:
void pointerMove(gPanelMessage &msg);
void enable(bool);
- void invalidate(void); // invalidates the drawing
+ void invalidate(Rect16 *unused = nullptr); // invalidates the drawing
int16 getCurrent(void) {
return currentImage;
}
@@ -229,7 +229,7 @@ public:
void deactivate(void);
void enable(bool);
- void invalidate(void); // invalidates the drawing
+ void invalidate(Rect16 *unused = nullptr); // invalidates the drawing
// area for this button
void draw(void); // redraw the panel.
void dim(bool);
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index 8d5465f7f9..6bcf46f1ed 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -460,7 +460,7 @@ void CPlaqText::enable(bool abled) {
gPanel::enable(abled);
}
-void CPlaqText::invalidate(void) {
+void CPlaqText::invalidate(Rect16 *) {
window.update(extent);
}
diff --git a/engines/saga2/intrface.h b/engines/saga2/intrface.h
index 6db8dae92d..1d12fa8df6 100644
--- a/engines/saga2/intrface.h
+++ b/engines/saga2/intrface.h
@@ -205,7 +205,7 @@ public:
int16, textPallete &, int16, AppFunc *cmd = NULL);
void enable(bool);
- void invalidate(void);
+ void invalidate(Rect16 *unused = nullptr);
void draw(void);
virtual void drawClipped(gPort &,
@@ -343,7 +343,7 @@ private:
public:
- void invalidate(void) {
+ void invalidate(Rect16 *unused = nullptr) {
pieMass->invalidate();
pieBulk->invalidate();
}
Commit: 10d527d5ccb598c0915cb1c3761d634aee9b2b4a
https://github.com/scummvm/scummvm/commit/10d527d5ccb598c0915cb1c3761d634aee9b2b4a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:18+02:00
Commit Message:
SAGA2: Fix warnings
Changed paths:
engines/saga2/intrface.cpp
engines/saga2/intrface.h
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index 6bcf46f1ed..25e8f1b546 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -925,17 +925,17 @@ void CMassWeightIndicator::update(void) {
// setup the mana color tables
static uint8 manaColorMap[CManaIndicator::numManaTypes][CManaIndicator::numManaColors + 9] = {
// each row has 9 leading zero's to acount for windows colors
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x74, 0x73, 0x72, 0x80, 0x84, 0x83, 0x82, 0x82, 0x81, 0x81, 0xF4, 0xE9, // Red
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x74, 0x73, 0x72, 0x80, 0x84, 0x83, 0x82, 0x82, 0x81, 0x81, 0xF4, 0xE9 }, // Red
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x74, 0x73, 0x72, 0x78, 0x77, 0x76, 0x75, 0x6B, 0x6A, 0x69, 0x3A, 0x39, // Orange
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x74, 0x73, 0x72, 0x78, 0x77, 0x76, 0x75, 0x6B, 0x6A, 0x69, 0x3A, 0x39 }, // Orange
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x64, 0x63, 0x62, 0x61, 0x60, 0x5F, 0x5E, 0x5D, 0x5C, 0x5B, 0x5A, 0x59, // Yellow
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x64, 0x63, 0x62, 0x61, 0x60, 0x5F, 0x5E, 0x5D, 0x5C, 0x5B, 0x5A, 0x59 }, // Yellow
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0xE8, 0xE7, 0xE6, 0xE5, 0xE4, 0xE3, 0xE2, 0xE1, 0xE0, 0xDF, 0xDE, 0xC9, // Green
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0xE8, 0xE7, 0xE6, 0xE5, 0xE4, 0xE3, 0xE2, 0xE1, 0xE0, 0xDF, 0xDE, 0xC9 }, // Green
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0xA0, 0x9F, 0x9E, 0xB2, 0xB1, 0xB0, 0xAF, 0xAE, 0xAD, 0xAC, 0xAA, 0xA9, // Blue
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0xA0, 0x9F, 0x9E, 0xB2, 0xB1, 0xB0, 0xAF, 0xAE, 0xAD, 0xAC, 0xAA, 0xA9 }, // Blue
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0xA0, 0x98, 0x97, 0x96, 0x95, 0x94, 0x93, 0x93, 0x92, 0x92, 0x91, 0x0C, // Violet
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0xA0, 0x98, 0x97, 0x96, 0x95, 0x94, 0x93, 0x93, 0x92, 0x92, 0x91, 0x0C } // Violet
};
@@ -1004,7 +1004,6 @@ CManaIndicator::CManaIndicator(gPanelList &list) : gCompImage(list,
// init the save map
savedMap.size = Extent16(xSize, ySize);
savedMap.data = new uint8[savedMap.bytes()];
- checkAlloc(savedMap.data);
}
CManaIndicator::~CManaIndicator(void) {
@@ -1134,7 +1133,6 @@ void CManaIndicator::drawClipped(gPort &port,
if (starHdr->compress) {
// allocation of the temp buffer
starMap.data = new uint8[starMap.bytes()]();
- checkAlloc(starMap.data);
// if it is then upack it to spec'ed coords.
unpackImage(&starMap, starMap.size.x, starMap.size.y, starHdr->data);
@@ -1144,7 +1142,6 @@ void CManaIndicator::drawClipped(gPort &port,
if (ringHdr->compress) {
// allocation of the temp buffer
ringMap.data = new uint8[ringMap.bytes()]();
- checkAlloc(ringMap.data);
// if it is then upack it to spec'ed coords.
unpackImage(&ringMap, ringMap.size.x, ringMap.size.y, ringHdr->data);
@@ -1224,7 +1221,6 @@ bool CManaIndicator::needUpdate(PlayerActor *player) {
int16 manaAmount;
int16 baseManaAmount;
uint16 i;
- bool newData = false;
// this could do more array checking, but
// the number of mana type should remain stable
@@ -2308,6 +2304,9 @@ APPFUNC(cmdPortrait) {
}
}
break;
+
+ default:
+ break;
}
}
@@ -2675,7 +2674,8 @@ APPFUNC(cmdManaInd) {
break;
case -1:
- sprintf(textBuffer, "\0");
+ textBuffer[0] = 0;
+ textBuffer[1] = 0;
break;
default:
@@ -2842,7 +2842,6 @@ void gEnchantmentDisplay::pointerMove(gPanelMessage &msg) {
void gEnchantmentDisplay::setValue(PlayerActorID pID) {
Actor *a = playerList[pID].getActor();
uint8 newIconFlags[iconCount];
- GameObject *wornObj;
EnchantmentIterator iter(a);
ContainerIterator cIter(a);
diff --git a/engines/saga2/intrface.h b/engines/saga2/intrface.h
index 1d12fa8df6..19d0bc10c3 100644
--- a/engines/saga2/intrface.h
+++ b/engines/saga2/intrface.h
@@ -164,9 +164,6 @@ const int16 optBtnResNum = 20;
-// portrait resource indexes
-extern int16 portResNum[];
-
// standard number of images for push-buttons
const int16 numBtnImages = 2;
Commit: 47ea8aa5d7d67492a285b9849713827d6d79fb2b
https://github.com/scummvm/scummvm/commit/47ea8aa5d7d67492a285b9849713827d6d79fb2b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:18+02:00
Commit Message:
SAGA2: Replace DList with Common::List in intrface.h
Changed paths:
engines/saga2/intrface.cpp
engines/saga2/intrface.h
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index 25e8f1b546..cf3c231610 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -787,7 +787,7 @@ void CStatusLine::clear(void) {
/* ===================================================================== *
CMassWeightInterface: Static list of indicators
* ===================================================================== */
-DList CMassWeightIndicator::indList;
+Common::List<CMassWeightIndicator *> CMassWeightIndicator::indList;
/* ===================================================================== *
CMassWeightInterface: mass and weight allowence indicators
@@ -865,11 +865,11 @@ CMassWeightIndicator::CMassWeightIndicator(gPanelList *panel, const Point16 &pos
containerObject = nullptr;
}
- indList.addHead(*this);
+ indList.push_back(this);
}
CMassWeightIndicator::~CMassWeightIndicator(void) {
- remove();
+ indList.remove(this);
unloadImageRes(pieIndImag, numPieIndImages);
ImageCache.releaseImage(massBulkImag);
@@ -907,11 +907,9 @@ void CMassWeightIndicator::update(void) {
CMassWeightIndicator *indNode = nullptr;
if (bRedraw == true) {
- for (indNode = (CMassWeightIndicator *)indList.first();
- indNode;
- indNode = (CMassWeightIndicator *)indNode->next()) {
- indNode->recalculate();
- indNode->invalidate();
+ for (Common::List<CMassWeightIndicator *>::iterator it = indList.begin(); it != indList.end(); ++it) {
+ (*it)->recalculate();
+ (*it)->invalidate();
}
bRedraw = false;
diff --git a/engines/saga2/intrface.h b/engines/saga2/intrface.h
index 19d0bc10c3..b4d2c03dd7 100644
--- a/engines/saga2/intrface.h
+++ b/engines/saga2/intrface.h
@@ -292,9 +292,9 @@ public:
CInterface: Class that handles indicators for the interface
* ===================================================================== */
-class CMassWeightIndicator : public DNode {
+class CMassWeightIndicator {
private:
- static DList indList;
+ static Common::List<CMassWeightIndicator *> indList;
GameObject *containerObject;
public:
Commit: c92315fca698d6c98444cbdcd07be4e7928bb922
https://github.com/scummvm/scummvm/commit/c92315fca698d6c98444cbdcd07be4e7928bb922
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:18+02:00
Commit Message:
SAGA2: More warning fixes
Changed paths:
engines/saga2/contain.h
engines/saga2/intrface.cpp
engines/saga2/intrface.h
engines/saga2/playmode.cpp
diff --git a/engines/saga2/contain.h b/engines/saga2/contain.h
index 27c18df4e3..9c9bc20f11 100644
--- a/engines/saga2/contain.h
+++ b/engines/saga2/contain.h
@@ -320,8 +320,6 @@ private:
CMassWeightIndicator *massWeightIndicator;
Rect16 objRect;
- void **pieImag;
- uint16 pieImagNum;
bool deathFlag;
private:
@@ -344,7 +342,6 @@ protected:
friend void setMindContainer(int index, IntangibleContainerWindow &cw);
private:
gMultCompButton *mindSelectorCompButton;
- void **mindImage;
public:
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index cf3c231610..4756a095e4 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -401,14 +401,6 @@ uint16 indivBrother;
bool isBrotherDead(PlayerActorID brotherID);
-/* ===================================================================== *
- ui indicators
- * ===================================================================== */
-
-// status line rect
-Rect16 statusLineArea(49, 445, 407, 15);
-
-
/* ===================================================================== *
Global class declarations
* ===================================================================== */
diff --git a/engines/saga2/intrface.h b/engines/saga2/intrface.h
index b4d2c03dd7..22eb445855 100644
--- a/engines/saga2/intrface.h
+++ b/engines/saga2/intrface.h
@@ -109,7 +109,6 @@ const uint32 mentGroupID = MKTAG('C', 'O', 'N', 'T');
/* ===================================================================== *
Exports
* ===================================================================== */
-extern Rect16 statusLineArea;
extern uint16 indivBrother;
/* ===================================================================== *
diff --git a/engines/saga2/playmode.cpp b/engines/saga2/playmode.cpp
index f29a355026..953bad2ad1 100644
--- a/engines/saga2/playmode.cpp
+++ b/engines/saga2/playmode.cpp
@@ -217,7 +217,7 @@ void PlayModeSetup(void) {
// activate the status line
// this will get deleted by parent panel
StatusLine = new CStatusLine(*playControls,
- statusLineArea,
+ Rect16(49, 445, 407, 15),
"",
&Script10Font,
0,
Commit: 8c47310314c349da5f614dd9c92f451ce6b840b6
https://github.com/scummvm/scummvm/commit/8c47310314c349da5f614dd9c92f451ce6b840b6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:18+02:00
Commit Message:
SAGA2: Fix thread deletion
Changed paths:
engines/saga2/interp.cpp
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 6c535bd3bb..b0657025d0 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -1262,7 +1262,6 @@ void ThreadList::cleanup(void) {
void ThreadList::deleteThread(Thread *p) {
for (uint i = 0; i < kNumThreads; i++) {
if (_list[i] == p) {
- delete _list[i];
_list[i] = nullptr;
}
}
@@ -1498,9 +1497,7 @@ Thread::~Thread() {
// Deallocate the thread stack
free(stackBase);
- // XXX: Deleting like this causes a crash
- warning("STUB: Thread::~Thread()");
- //deleteThread(this);
+ deleteThread(this);
}
//-----------------------------------------------------------------------
Commit: 50868e26087838d985e587b0ba3bea7f9553e046
https://github.com/scummvm/scummvm/commit/50868e26087838d985e587b0ba3bea7f9553e046
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:18+02:00
Commit Message:
SAGA2: Removed DList from Task and TaskList
Changed paths:
engines/saga2/task.cpp
engines/saga2/task.h
diff --git a/engines/saga2/task.cpp b/engines/saga2/task.cpp
index d4f8f350be..a96b7046c3 100644
--- a/engines/saga2/task.cpp
+++ b/engines/saga2/task.cpp
@@ -106,29 +106,7 @@ const int numTaskStacks = 32;
// Manages the memory used for the TaskStack's. There will
// only be one global instantiation of this class
class TaskStackList {
-#if DEBUG
- friend void checkTaskListIntegrity(void);
-#endif
-
- struct TaskStackPlaceHolder : public DNode {
- uint8 buf[sizeof(TaskStack)];
-
- TaskStackPlaceHolder *nextDeletion; // Pointer to next in lazy deletion list
- bool deleted; // Deletion indicator
-
- TaskStack *getTaskStack(void) {
- return (TaskStack *)&buf;
- }
- };
-
- DList list, // active TaskStacks
- free; // inactive TaskStacks
-
- TaskStackPlaceHolder array[numTaskStacks];
-
- bool lazyDelete; // Flag indicating lazy deletion mode
- TaskStackPlaceHolder *deletionList; // Singly linked list of all task stack
- // placed holders marked for deletion
+ TaskStack *_list[numTaskStacks];
public:
// Constructor -- initial construction
@@ -149,27 +127,24 @@ public:
// Place a TaskStack from the inactive list into the active
// list.
- void *newTaskStack(void);
- void *newTaskStack(TaskStackID id);
+ void newTaskStack(TaskStack *p);
// Place a TaskStack back into the inactive list.
- void deleteTaskStack(void *p);
+ void deleteTaskStack(TaskStack *p);
// Return the specified TaskStack's ID
TaskStackID getTaskStackID(TaskStack *ts) {
- TaskStackPlaceHolder *tsp;
+ for (int i = 0; i < numTaskStacks; i++)
+ if (_list[i] == ts)
+ return i;
- warning("FIXME: TaskStackList::getTaskStackID(): unsafe pointer arithmetics");
- tsp = ((TaskStackPlaceHolder *)(
- (uint8 *)ts
- - offsetof(TaskStackPlaceHolder, buf)));
- return tsp - array;
+ error("getTaskStackID(): Unknown stack %p", (void *)ts);
}
// Return a pointer to a TaskStack given a TaskStackID
TaskStack *getTaskStackAddress(TaskStackID id) {
assert(id >= 0 && id < numTaskStacks);
- return array[id].getTaskStack();
+ return _list[id];
}
// Run through the TaskStacks in the active list and update
@@ -182,40 +157,24 @@ public:
// the inactive list
TaskStackList::TaskStackList(void) {
- int i;
-
- for (i = 0; i < elementsof(array); i++) {
- array[i].deleted = false;
- free.addTail(array[i]);
- }
-
- lazyDelete = false;
- deletionList = NULL;
+ for (int i = 0; i < numTaskStacks; i++)
+ _list[i] = nullptr;
}
//----------------------------------------------------------------------
// TaskStackList destructor
TaskStackList::~TaskStackList(void) {
- assert(!lazyDelete);
-
- TaskStackPlaceHolder *tsp;
- TaskStackPlaceHolder *nextTsp;
-
- for (tsp = (TaskStackPlaceHolder *)list.first();
- tsp != NULL;
- tsp = nextTsp) {
- // Save the address of the next in the list
- nextTsp = (TaskStackPlaceHolder *)tsp->next();
-
- delete tsp->getTaskStack();
- }
+ for (int i = 0; i < numTaskStacks; i++)
+ delete _list[i];
}
//----------------------------------------------------------------------
// Reconstruct the TaskStackList from an archive buffer
void *TaskStackList::restore(void *buf) {
+ warning("STUB: TaskStackList::restore()");
+#if 0
int16 i,
taskStackCount;
@@ -237,7 +196,7 @@ void *TaskStackList::restore(void *buf) {
// Plug this TaskStack into the Actor
ts->getActor()->curTask = ts;
}
-
+#endif
return buf;
}
@@ -245,13 +204,14 @@ void *TaskStackList::restore(void *buf) {
// Return the number of bytes necessary to archive this TaskStackList
int32 TaskStackList::archiveSize(void) {
- int32 size = sizeof(int16);
- TaskStackPlaceHolder *tsp;
+ int32 size = sizeof(int16);
- for (tsp = (TaskStackPlaceHolder *)list.first();
- tsp != NULL;
- tsp = (TaskStackPlaceHolder *)tsp->next())
- size += sizeof(TaskStackID) + tsp->getTaskStack()->archiveSize();
+ for (int i = 0; i < numTaskStacks; i++) {
+ size += sizeof(TaskStackID);
+
+ if (_list[i])
+ size += _list[i]->archiveSize();
+ }
return size;
}
@@ -260,6 +220,9 @@ int32 TaskStackList::archiveSize(void) {
// Make an archive of the TaskStackList in an archive buffer
void *TaskStackList::archive(void *buf) {
+ warning("STUB: TaskStackList::archive()");
+
+#if 0
int16 taskStackCount = 0;
TaskStackPlaceHolder *tsp;
@@ -285,73 +248,32 @@ void *TaskStackList::archive(void *buf) {
buf = ts->archive(buf);
}
-
+#endif
return buf;
}
//----------------------------------------------------------------------
// Place a TaskStack into the active list and return its address
-void *TaskStackList::newTaskStack(void) {
- TaskStackPlaceHolder *tsp;
-
- // Grab a stack place holder from the inactive list
- tsp = (TaskStackPlaceHolder *)free.remHead();
-
- if (tsp != NULL) {
- // Link the stack place holder into the active list
- list.addTail(*tsp);
-
- return tsp->buf;
- }
-
- return NULL;
-}
-
-//----------------------------------------------------------------------
-// Place a specific TaskStack into the active list and return its address
-
-void *TaskStackList::newTaskStack(TaskStackID id) {
- assert(id >= 0 && id < elementsof(array));
-
- TaskStackPlaceHolder *tsp;
+void TaskStackList::newTaskStack(TaskStack *p) {
+ for (int i = 0; i < numTaskStacks; i++)
+ if (!_list[i]) {
+ _list[i] = p;
- // Grab the stack place holder from the inactive list
- tsp = (TaskStackPlaceHolder *)&array[id];
- tsp->remove();
-
- // Place the stack place holder into the active list
- list.addTail(*tsp);
-
- return tsp->buf;
+ return;
+ }
}
//----------------------------------------------------------------------
// Remove the specified TaskStack from the active list and place it
// back into the inactive list
-void TaskStackList::deleteTaskStack(void *p) {
- TaskStackPlaceHolder *tsp;
-
- warning("FIXME: TaskStackList::deleteTaskStack(): unsafe pointer arithmetics");
-
- // Convert the pointer to the TaskStack to a pointer to the
- // TaskStackPlaceHolder
- tsp = (TaskStackPlaceHolder *)(
- (uint8 *)p
- - offsetof(TaskStackPlaceHolder, buf));
-
- if (lazyDelete) {
- tsp->deleted = true;
- tsp->nextDeletion = deletionList;
- deletionList = tsp;
- } else {
- // Remove the stack place holder from the active list
- tsp->remove();
-
- // Place it into the inactive list
- free.addTail(*tsp);
- }
+void TaskStackList::deleteTaskStack(TaskStack *p) {
+ for (int i = 0; i < numTaskStacks; i++)
+ if (_list[i] == p) {
+ delete _list[i];
+ _list[i] = nullptr;
+ }
}
//----------------------------------------------------------------------
@@ -359,47 +281,20 @@ void TaskStackList::deleteTaskStack(void *p) {
// their update function
void TaskStackList::updateTaskStacks(void) {
- TaskStackPlaceHolder *tsp;
-
- // Make sure all deletions during task processing are lazy
- lazyDelete = true;
-
- for (tsp = (TaskStackPlaceHolder *)list.first();
- tsp != NULL;
- tsp = (TaskStackPlaceHolder *)tsp->next()) {
- // Skip all task stacks which have been marked as deleted
- if (tsp->deleted)
- continue;
+ for (int i = 0; i < numTaskStacks; i++) {
+ if (_list[i]) {
+ TaskStack *ts = _list[i];
+ TaskResult result;
- TaskStack *ts = tsp->getTaskStack();
- TaskResult result;
+ // Update the task stack and delete it if it is done
+ if ((result = ts->update()) != taskNotDone) {
+ Actor *a = ts->getActor();
+ assert(a != NULL);
- // Update the task stack and delete it if it is done
- if ((result = ts->update()) != taskNotDone) {
- Actor *a = ts->getActor();
- assert(a != NULL);
-
- a->handleTaskCompletion(result);
+ a->handleTaskCompletion(result);
+ }
}
}
-
- // Process all lazy deletions
- lazyDelete = false;
- while (deletionList != NULL) {
- TaskStackPlaceHolder *nextDeletion = deletionList->nextDeletion;
-
- // Remove the stack place holder from the active list
- deletionList->remove();
-
- // Place it into the inactive list
- free.addTail(*deletionList);
-
- // Now that the real deletion has taken place reset the deleted
- // flag
- deletionList->deleted = false;
-
- deletionList = nextDeletion;
- }
}
/* ===================================================================== *
@@ -414,9 +309,7 @@ void TaskStackList::updateTaskStacks(void) {
// call will simply return a pointer to the stackListBuffer in order
// to construct the TaskStackList in place.
-static uint8 stackListBuffer[sizeof(TaskStackList)];
-
-static TaskStackList &stackList = *((TaskStackList *)stackListBuffer);
+static TaskStackList stackList;
/* ===================================================================== *
Misc. task stack management functions
@@ -427,10 +320,8 @@ static TaskStackList &stackList = *((TaskStackList *)stackListBuffer);
// updateTaskStacks().
void updateActorTasks(void) {
- if (!actorTasksPaused) stackList.updateTaskStacks();
-#if DEBUG
- checkTaskListIntegrity();
-#endif
+ if (!actorTasksPaused)
+ stackList.updateTaskStacks();
}
void pauseActorTasks(void) {
@@ -444,18 +335,15 @@ void resumeActorTasks(void) {
// Call the stackList member function newTaskStack() to get a pointer
// to a new TaskStack
-void *newTaskStack(void) {
- return stackList.newTaskStack();
-}
-void *newTaskStack(TaskStackID id) {
- return stackList.newTaskStack(id);
+void newTaskStack(TaskStack *p) {
+ return stackList.newTaskStack(p);
}
//----------------------------------------------------------------------
// Call the stackList member function deleteTaskStack() to dispose of
// a previously allocated TaskStack
-void deleteTaskStack(void *p) {
+void deleteTaskStack(TaskStack *p) {
stackList.deleteTaskStack(p);
}
@@ -477,8 +365,6 @@ TaskStack *getTaskStackAddress(TaskStackID id) {
// Initialize the stackList
void initTaskStacks(void) {
- // Simply call the TaskStackList default constructor
- new (&stackList) TaskStackList;
}
//----------------------------------------------------------------------
@@ -555,23 +441,7 @@ const int numTasks = 64;
// global instantiation of this class
class TaskList {
- struct TaskPlaceHolder : public DNode {
-#if DEBUG
- char *fileName;
- int lineNo;
- bool marked;
-#endif
- uint8 buf[maxTaskSize];
-
- Task *getTask(void) {
- return (Task *)&buf;
- }
- };
-
- DList list, // active Tasks
- free; // inactive Tasks
-
- TaskPlaceHolder array[numTasks];
+ Task *_list[numTasks];
public:
// Constructor -- initial construction
@@ -590,56 +460,28 @@ public:
// Create an archive of the task list in an archive buffer
void *archive(void *buf);
-#if DEBUG
- // Place a Task from the inactive list into the active
- // list.
- void *newTask(char *file, int line);
- void *newTask(char *file, int line, TaskID id);
-#else
// Place a Task from the inactive list into the active
// list.
- void *newTask(void);
- void *newTask(TaskID id);
-#endif
+ void newTask(Task *t);
+ void newTask(Task *t, TaskID id);
// Place a Task back into the inactive list.
- void deleteTask(void *t);
+ void deleteTask(Task *t);
// Return the specified Task's ID
TaskID getTaskID(Task *t) {
- TaskPlaceHolder *tp;
+ for (int i = 0; i < numTasks; i++)
+ if (_list[i] == t)
+ return i;
- warning("FIXME: TaskList::getTaskID(): unsafe pointer arithmetics");
- tp = ((TaskPlaceHolder *)(
- (uint8 *)t
- - offsetof(TaskPlaceHolder, buf)));
- return tp - array;
+ error("getTaskID: unknown task %p", (void *)t);
}
// Return a pointer to a Task given a TaskID
Task *getTaskAddress(TaskID id) {
assert(id >= 0 && id < numTasks);
- return array[id].getTask();
+ return _list[id];
}
-
-#if DEBUG
- // Mark the specified task
- void markTask(Task *t) {
- TaskPlaceHolder *tp;
-
- warning("FIXME: TaskList::markTask(): unsafe pointer arithmetics");
- tp = ((TaskPlaceHolder *)(
- (uint8 *)t
- - offsetof(TaskPlaceHolder, buf)));
- tp->marked = true;
- }
-
- // Verify that all allocated tasks are marked
- void checkMarks(void);
-
- // Clear all debugging marks
- void clearMarks(void);
-#endif
};
//----------------------------------------------------------------------
@@ -647,33 +489,24 @@ public:
// the inactive list
TaskList::TaskList(void) {
- int i;
-
- for (i = 0; i < elementsof(array); i++)
- free.addTail(array[i]);
+ for (int i = 0; i < numTasks; i++)
+ _list[i] = nullptr;
}
//----------------------------------------------------------------------
// TaskList destructor
TaskList::~TaskList(void) {
- TaskPlaceHolder *tp;
- TaskPlaceHolder *nextTP;
-
- for (tp = (TaskPlaceHolder *)list.first();
- tp != NULL;
- tp = nextTP) {
- // Save the address of the next in the list
- nextTP = (TaskPlaceHolder *)tp->next();
-
- delete tp->getTask();
- }
+ for (int i = 0; i < numTasks; i++)
+ delete _list[i];
}
//----------------------------------------------------------------------
// Reconstruct from an archive buffer
void *TaskList::restore(void *buf) {
+ warning("STUB: TaskList::restore");
+#if 0
assert(list.first() == NULL);
int16 i,
@@ -700,7 +533,7 @@ void *TaskList::restore(void *buf) {
tp != NULL;
tp = (TaskPlaceHolder *)tp->next())
tp->getTask()->fixup();
-
+#endif
return buf;
}
@@ -708,13 +541,14 @@ void *TaskList::restore(void *buf) {
// Return the number of bytes necessary to archive this TaskList
int32 TaskList::archiveSize(void) {
- int32 size = sizeof(int16);
- TaskPlaceHolder *tp;
+ int32 size = sizeof(int16);
- for (tp = (TaskPlaceHolder *)list.first();
- tp != NULL;
- tp = (TaskPlaceHolder *)tp->next())
- size += sizeof(TaskID) + taskArchiveSize(tp->getTask());
+ for (int i = 0; i < numTasks; i++) {
+ size += sizeof(TaskID);
+
+ if (_list[i])
+ size += taskArchiveSize(_list[i]);
+ }
return size;
}
@@ -723,6 +557,8 @@ int32 TaskList::archiveSize(void) {
// Make an archive of the TaskList in an archive buffer
void *TaskList::archive(void *buf) {
+ warning("STUB: TaskList::archive()");
+#if 0
int16 taskCount = 0;
TaskPlaceHolder *tp;
@@ -748,168 +584,56 @@ void *TaskList::archive(void *buf) {
buf = archiveTask(t, buf);
}
-
+#endif
return buf;
}
-//----------------------------------------------------------------------
-// Place a Task into the active list and return its address
-
-#if DEBUG
-void *TaskList::newTask(char *file, int line)
-#else
-void *TaskList::newTask(void)
-#endif
-{
- TaskPlaceHolder *tp;
-
- // Grab a task holder from the inactive list
- tp = (TaskPlaceHolder *)free.remHead();
-
- if (tp != NULL) {
-#if DEBUG
- tp->fileName = file;
- tp->lineNo = line;
- tp->marked = false;
-#endif
- // Place the place holder into the active list
- list.addTail(*tp);
+void TaskList::newTask(Task *t) {
+ for (int i = 0; i < numTasks; i++)
+ if (!_list[i]) {
+ _list[i] = t;
- return tp->buf;
- }
-
- return NULL;
+ return;
+ }
}
-//----------------------------------------------------------------------
-// Place a specific Task into the active list and return its address
-
-#if DEBUG
-void *TaskList::newTask(char *file, int line, TaskID id)
-#else
-void *TaskList::newTask(TaskID id)
-#endif
-{
- assert(id >= 0 && id < elementsof(array));
-
- TaskPlaceHolder *tp;
-
- // Grab the task place holder from the inactive list
- tp = (TaskPlaceHolder *)&array[id];
- tp->remove();
-
-#if DEBUG
- tp->fileName = file;
- tp->lineNo = line;
- tp->marked = false;
-#endif
- // Place the place holder into the active list
- list.addTail(*tp);
-
- return tp->buf;
+void TaskList::newTask(Task *t, TaskID id) {
+ _list[id] = t;
}
//----------------------------------------------------------------------
// Remove the specified Task from the active list and place it back
// into the inactive list
-void TaskList::deleteTask(void *p) {
- TaskPlaceHolder *tp;
-
- warning("FIXME: TaskList::deleteTask(): unsafe pointer arithmetics");
- // Convert the pointer to the Task to a pointer to the
- // TaskPlaceHolder
- tp = (TaskPlaceHolder *)(
- (uint8 *)p
- - offsetof(TaskPlaceHolder, buf));
-
- // Remove the task place holder from the active list
- tp->remove();
-
- // Place it into the inactive list
- free.addTail(*tp);
-}
-
-#if DEBUG
-//----------------------------------------------------------------------
-// Verify that all allocated tasks are marked
-
-void TaskList::checkMarks(void) {
- TaskPlaceHolder *tp;
-
- for (tp = (TaskPlaceHolder *)list.first();
- tp != NULL;
- tp = (TaskPlaceHolder *)tp->next()) {
- if (!tp->marked)
- throw gError(
- "Task leak detected: %05.5d \"%s\"\n",
- tp->lineNo,
- tp->fileName);
- }
-}
-
-//----------------------------------------------------------------------
-// Clear all debugging marks
-
-void TaskList::clearMarks(void) {
- TaskPlaceHolder *tp;
-
- for (tp = (TaskPlaceHolder *)list.first();
- tp != NULL;
- tp = (TaskPlaceHolder *)tp->next())
- tp->marked = false;
+void TaskList::deleteTask(Task *p) {
+ for (int i = 0; i < numTasks; i++)
+ if (_list[i] == p)
+ _list[i] = nullptr;
}
-#endif
/* ===================================================================== *
Global TaskList instantiation
* ===================================================================== */
-// This is a statically allocated buffer large enough to hold a TaskList.
-// The taskList is a TaskList reference to this area of memory. The
-// reason that I did this in this manner is to prevent the TaskList
-// constructor from being called until it is expicitly called using an
-// overloaded new call. The overloaded new call will simply return a
-// pointer to the taskListBuffer in order to construct the TaskList in
-// place.
-
-static uint8 taskListBuffer[sizeof(TaskList)];
-
-static TaskList &taskList = *((TaskList *)taskListBuffer);
+static TaskList taskList;
/* ===================================================================== *
Misc. task management functions
* ===================================================================== */
-//----------------------------------------------------------------------
-// Call the taskList member function newTask() to get a pointer to a
-// new TaskStack
-
-#if DEBUG
-void *newTask(char *file, int line) {
- return taskList.newTask(file, line);
+void newTask(Task *t) {
+ return taskList.newTask(t);
}
-#else
-void *newTask(void) {
- return taskList.newTask();
-}
-#endif
-#if DEBUG
-void *newTask(char *file, int line, TaskID id) {
- return taskList.newTask(file, line, id);
-}
-#else
-void *newTask(TaskID id) {
- return taskList.newTask(id);
+void newTask(Task *t, TaskID id) {
+ return taskList.newTask(t, id);
}
-#endif
//----------------------------------------------------------------------
// Call the taskList member function deleteTask() to dispose of a
// previously allocated TaskStack
-void deleteTask(void *p) {
+void deleteTask(Task *p) {
taskList.deleteTask(p);
}
@@ -1017,86 +741,76 @@ void *constructTask(TaskID id, void *buf) {
// Reconstruct the Task based upon the type
switch (type) {
case wanderTask:
- new(id) WanderTask(&buf);
+ new WanderTask(&buf, id);
break;
case tetheredWanderTask:
- new(id) TetheredWanderTask(&buf);
+ new TetheredWanderTask(&buf, id);
break;
case gotoLocationTask:
- new(id) GotoLocationTask(&buf);
+ new GotoLocationTask(&buf, id);
break;
case gotoRegionTask:
- new(id) GotoRegionTask(&buf);
+ new GotoRegionTask(&buf, id);
break;
case gotoObjectTask:
- new(id) GotoObjectTask(&buf);
+ new GotoObjectTask(&buf, id);
break;
case gotoActorTask:
- new(id) GotoActorTask(&buf);
+ new GotoActorTask(&buf, id);
break;
case goAwayFromObjectTask:
- new(id) GoAwayFromObjectTask(&buf);
+ new GoAwayFromObjectTask(&buf, id);
break;
case goAwayFromActorTask:
- new(id) GoAwayFromActorTask(&buf);
+ new GoAwayFromActorTask(&buf, id);
break;
case huntToBeNearLocationTask:
- new(id) HuntToBeNearLocationTask(&buf);
+ new HuntToBeNearLocationTask(&buf, id);
break;
case huntToBeNearObjectTask:
- new(id) HuntToBeNearObjectTask(&buf);
+ new HuntToBeNearObjectTask(&buf, id);
break;
case huntToPossessTask:
- new(id) HuntToPossessTask(&buf);
+ new HuntToPossessTask(&buf, id);
break;
case huntToBeNearActorTask:
- new(id) HuntToBeNearActorTask(&buf);
+ new HuntToBeNearActorTask(&buf, id);
break;
case huntToKillTask:
- new(id) HuntToKillTask(&buf);
+ new HuntToKillTask(&buf, id);
break;
case huntToGiveTask:
- new(id) HuntToGiveTask(&buf);
+ new HuntToGiveTask(&buf, id);
break;
case bandTask:
- new(id) BandTask(&buf);
+ new BandTask(&buf, id);
break;
case bandAndAvoidEnemiesTask:
- new(id) BandAndAvoidEnemiesTask(&buf);
+ new BandAndAvoidEnemiesTask(&buf, id);
break;
case followPatrolRouteTask:
- new(id) FollowPatrolRouteTask(&buf);
+ new FollowPatrolRouteTask(&buf, id);
break;
case attendTask:
- new(id) AttendTask(&buf);
+ new AttendTask(&buf, id);
break;
-
-#if 0
- case defendTask:
- new(id) DefendTask(&buf);
- break;
-
- case parryTask:
- new(id) ParryTask(&buf);
- break;
-#endif
}
return buf;
@@ -1125,29 +839,6 @@ void *archiveTask(Task *t, void *buf) {
return buf;
}
-#if DEBUG
-//----------------------------------------------------------------------
-// Debugging function used to check the integrity of the global task
-// list
-
-void checkTaskListIntegrity(void) {
- TaskStackList::TaskStackPlaceHolder *tsp;
-
- // Clear all task marks
- taskList.clearMarks();
-
- // Iterate through all active task stacks and mark their associated
- // tasks
- for (tsp = (TaskStackList::TaskStackPlaceHolder *)stackList.list.first();
- tsp != NULL;
- tsp = (TaskStackList::TaskStackPlaceHolder *)tsp->next())
- tsp->getTaskStack()->mark();
-
- // Check the task marks
- taskList.checkMarks();
-}
-#endif
-
/* ===================================================================== *
Task member functions
* ===================================================================== */
@@ -1155,7 +846,7 @@ void checkTaskListIntegrity(void) {
//----------------------------------------------------------------------
// Constructor -- reconstruct from an archive buffer
-Task::Task(void **buf) {
+Task::Task(void **buf, TaskID id) {
void *bufferPtr = *buf;
// Place the stack ID into the stack pointer field
@@ -1189,29 +880,6 @@ void *Task::archive(void *buf) const {
return (TaskStackID *)buf + 1;
}
-
-#if DEBUG
-void *Task::operator new (size_t sz, char *file, int line) {
- assert(sz <= maxTaskSize);
- return newTask(file, line);
-}
-
-void *Task::operator new (size_t sz, char *file, int line, TaskID id) {
- assert(sz <= maxTaskSize);
- return newTask(file, line, id);
-}
-#endif
-
-#if DEBUG
-//----------------------------------------------------------------------
-// Debugging function used to mark this task and any sub tasks as being
-// used. This is used to find task leaks.
-
-void Task::mark(void) {
- taskList.markTask(this);
-}
-#endif
-
/* ===================================================================== *
WanderTask member functions
* ===================================================================== */
@@ -1219,7 +887,7 @@ void Task::mark(void) {
//----------------------------------------------------------------------
// Constructor -- reconstruct from archive buffer
-WanderTask::WanderTask(void **buf) : Task(buf) {
+WanderTask::WanderTask(void **buf, TaskID id) : Task(buf, id) {
void *bufferPtr = *buf;
// Restore the paused flag
@@ -1346,7 +1014,7 @@ void WanderTask::wander(void) {
//----------------------------------------------------------------------
// Constructor -- reconstruct from archive buffer
-TetheredWanderTask::TetheredWanderTask(void **buf) : WanderTask(buf) {
+TetheredWanderTask::TetheredWanderTask(void **buf, TaskID id) : WanderTask(buf, id) {
int16 *bufferPtr = (int16 *)*buf;
// Restore the tether coordinates
@@ -1528,7 +1196,7 @@ TaskResult TetheredWanderTask::handleWander(void) {
//----------------------------------------------------------------------
// Constructor -- reconstruct from archive buffer
-GotoTask::GotoTask(void **buf) : Task(buf) {
+GotoTask::GotoTask(void **buf, TaskID id) : Task(buf, id) {
void *bufferPtr = *buf;
// Get the wander TaskID
@@ -1712,7 +1380,7 @@ TaskResult GotoTask::update(void) {
//----------------------------------------------------------------------
// Constructor -- reconstruct from archive buffer
-GotoLocationTask::GotoLocationTask(void **buf) : GotoTask(buf) {
+GotoLocationTask::GotoLocationTask(void **buf, TaskID id) : GotoTask(buf, id) {
void *bufferPtr = *buf;
// Restore the target location
@@ -1813,7 +1481,7 @@ bool GotoLocationTask::run(void) {
//----------------------------------------------------------------------
// Constructor -- reconstruct from archive buffer
-GotoRegionTask::GotoRegionTask(void **buf) : GotoTask(buf) {
+GotoRegionTask::GotoRegionTask(void **buf, TaskID id) : GotoTask(buf, id) {
int16 *bufferPtr = (int16 *)*buf;
// Restore the region coordinates
@@ -1910,7 +1578,7 @@ bool GotoRegionTask::run(void) {
//----------------------------------------------------------------------
// Constructor -- reconstruct from archive buffer
-GotoObjectTargetTask::GotoObjectTargetTask(void **buf) : GotoTask(buf) {
+GotoObjectTargetTask::GotoObjectTargetTask(void **buf, TaskID id) : GotoTask(buf, id) {
void *bufferPtr = *buf;
// Restore lastTestedLoc and increment pointer
@@ -2060,8 +1728,8 @@ bool GotoObjectTargetTask::lineOfSight(void) {
//----------------------------------------------------------------------
// Constructor -- reconstruct from archive buffer
-GotoObjectTask::GotoObjectTask(void **buf) :
- GotoObjectTargetTask(buf) {
+GotoObjectTask::GotoObjectTask(void **buf, TaskID id) :
+ GotoObjectTargetTask(buf, id) {
ObjectID *bufferPtr = (ObjectID *)*buf;
// Restore the targetObj pointer
@@ -2134,8 +1802,8 @@ bool GotoObjectTask::run(void) {
//----------------------------------------------------------------------
// Constructor -- reconstruct from archive buffer
-GotoActorTask::GotoActorTask(void **buf) :
- GotoObjectTargetTask(buf) {
+GotoActorTask::GotoActorTask(void **buf, TaskID id) :
+ GotoObjectTargetTask(buf, id) {
ObjectID *bufferPtr = (ObjectID *)*buf;
// Restore the targetObj pointer
@@ -2210,7 +1878,7 @@ bool GotoActorTask::run(void) {
GoAwayFromTask member functions
* ===================================================================== */
-GoAwayFromTask::GoAwayFromTask(void **buf) : Task(buf) {
+GoAwayFromTask::GoAwayFromTask(void **buf, TaskID id) : Task(buf, id) {
void *bufferPtr = *buf;
// Get the subtask ID
@@ -2352,8 +2020,8 @@ TaskResult GoAwayFromTask::update(void) {
//----------------------------------------------------------------------
// Constructor -- reconstruct from archive buffer
-GoAwayFromObjectTask::GoAwayFromObjectTask(void **buf) :
- GoAwayFromTask(buf) {
+GoAwayFromObjectTask::GoAwayFromObjectTask(void **buf, TaskID id) :
+ GoAwayFromTask(buf, id) {
ObjectID *bufferPtr = (ObjectID *)*buf;
ObjectID objectID;
@@ -2449,7 +2117,7 @@ GoAwayFromActorTask::GoAwayFromActorTask(
//----------------------------------------------------------------------
// Constructor -- reconstruct from archive buffer
-GoAwayFromActorTask::GoAwayFromActorTask(void **buf) : GoAwayFromTask(buf) {
+GoAwayFromActorTask::GoAwayFromActorTask(void **buf, TaskID id) : GoAwayFromTask(buf, id) {
// Restore the target
*buf = constructTarget(targetMem, *buf);
}
@@ -2530,7 +2198,7 @@ TilePoint GoAwayFromActorTask::getRepulsionVector(void) {
//----------------------------------------------------------------------
// Constructor -- reconstruct from archive buffer
-HuntTask::HuntTask(void **buf) : Task(buf) {
+HuntTask::HuntTask(void **buf, TaskID id) : Task(buf, id) {
void *bufferPtr = *buf;
// Restore the flags
@@ -2720,7 +2388,7 @@ HuntLocationTask::HuntLocationTask(TaskStack *ts, const Target &t) :
//----------------------------------------------------------------------
// Constructor -- reconstruct from archive buffer
-HuntLocationTask::HuntLocationTask(void **buf) : HuntTask(buf) {
+HuntLocationTask::HuntLocationTask(void **buf, TaskID id) : HuntTask(buf, id) {
void *bufferPtr = *buf;
// Restore the currentTarget location
@@ -2787,8 +2455,8 @@ TilePoint HuntLocationTask::currentTargetLoc(void) {
//----------------------------------------------------------------------
// Constructor -- reconstruct from archive buffer
-HuntToBeNearLocationTask::HuntToBeNearLocationTask(void **buf) :
- HuntLocationTask(buf) {
+HuntToBeNearLocationTask::HuntToBeNearLocationTask(void **buf, TaskID id) :
+ HuntLocationTask(buf, id) {
void *bufferPtr = *buf;
// Restore the range
@@ -2909,7 +2577,7 @@ HuntObjectTask::HuntObjectTask(TaskStack *ts, const ObjectTarget &ot) :
//----------------------------------------------------------------------
// Constructor -- reconstruct from archive buffer
-HuntObjectTask::HuntObjectTask(void **buf) : HuntTask(buf) {
+HuntObjectTask::HuntObjectTask(void **buf, TaskID id) : HuntTask(buf, id) {
void *bufferPtr = *buf;
ObjectID currentTargetID;
@@ -2992,8 +2660,8 @@ TilePoint HuntObjectTask::currentTargetLoc(void) {
//----------------------------------------------------------------------
// Constructor -- reconstruct from archive buffer
-HuntToBeNearObjectTask::HuntToBeNearObjectTask(void **buf) :
- HuntObjectTask(buf) {
+HuntToBeNearObjectTask::HuntToBeNearObjectTask(void **buf, TaskID id) :
+ HuntObjectTask(buf, id) {
void *bufferPtr = *buf;
// Restore the range
@@ -3133,7 +2801,7 @@ TaskResult HuntToBeNearObjectTask::atTargetUpdate(void) {
//----------------------------------------------------------------------
// Constructor -- reconstruct from archive buffer
-HuntToPossessTask::HuntToPossessTask(void **buf) : HuntObjectTask(buf) {
+HuntToPossessTask::HuntToPossessTask(void **buf, TaskID id) : HuntObjectTask(buf, id) {
void *bufferPtr = *buf;
// Restore evaluation counter
@@ -3287,7 +2955,7 @@ HuntActorTask::HuntActorTask(
//----------------------------------------------------------------------
// Constructor -- reconstruct from archive buffer
-HuntActorTask::HuntActorTask(void **buf) : HuntTask(buf) {
+HuntActorTask::HuntActorTask(void **buf, TaskID id) : HuntTask(buf, id) {
void *bufferPtr = *buf;
ObjectID currentTargetID;
@@ -3388,8 +3056,8 @@ TilePoint HuntActorTask::currentTargetLoc(void) {
//----------------------------------------------------------------------
// Constructor -- reconstruct from archive buffer
-HuntToBeNearActorTask::HuntToBeNearActorTask(void **buf) :
- HuntActorTask(buf) {
+HuntToBeNearActorTask::HuntToBeNearActorTask(void **buf, TaskID id) :
+ HuntActorTask(buf, id) {
void *bufferPtr = *buf;
// Get the goAway task ID
@@ -3639,7 +3307,7 @@ HuntToKillTask::HuntToKillTask(
//----------------------------------------------------------------------
// Constructor -- reconstruct from archive buffer
-HuntToKillTask::HuntToKillTask(void **buf) : HuntActorTask(buf) {
+HuntToKillTask::HuntToKillTask(void **buf, TaskID id) : HuntActorTask(buf, id) {
uint8 *bufferPtr = (uint8 *)*buf;
// Restore the evaluation counter
@@ -4005,7 +3673,7 @@ void HuntToKillTask::evaluateWeapon(void) {
//----------------------------------------------------------------------
// Constructor -- reconstruct from archive buffer
-HuntToGiveTask::HuntToGiveTask(void **buf) : HuntActorTask(buf) {
+HuntToGiveTask::HuntToGiveTask(void **buf, TaskID id) : HuntActorTask(buf, id) {
ObjectID *bufferPtr = (ObjectID *)*buf;
ObjectID objToGiveID;
@@ -4152,7 +3820,7 @@ bool BandTask::BandingRepulsorIterator::next(
//----------------------------------------------------------------------
// Constructor -- reconstruct from archive buffer
-BandTask::BandTask(void **buf) : HuntTask(buf) {
+BandTask::BandTask(void **buf, TaskID id) : HuntTask(buf, id) {
void *bufferPtr = *buf;
*((TaskID *)&attend) = *((TaskID *)bufferPtr);
@@ -4538,7 +4206,7 @@ BandTask::RepulsorIterator *BandAndAvoidEnemiesTask::getNewRepulsorIterator(void
//----------------------------------------------------------------------
// Constructor -- reconstruct from archive buffer
-FollowPatrolRouteTask::FollowPatrolRouteTask(void **buf) : Task(buf) {
+FollowPatrolRouteTask::FollowPatrolRouteTask(void **buf, TaskID id) : Task(buf, id) {
void *bufferPtr = *buf;
// Get the gotoWayPoint TaskID
@@ -4769,7 +4437,7 @@ void FollowPatrolRouteTask::pause(void) {
//----------------------------------------------------------------------
// Constructor -- reconstruct from archive buffer
-AttendTask::AttendTask(void **buf) : Task(buf) {
+AttendTask::AttendTask(void **buf, TaskID id) : Task(buf, id) {
ObjectID *bufferPtr = (ObjectID *)*buf;
ObjectID objID;
@@ -4870,7 +4538,7 @@ bool AttendTask::operator == (const Task &t) const {
//----------------------------------------------------------------------
// Constructor -- reconstruct from archive buffer
-DefendTask::DefendTask(void **buf) : Task(buf) {
+DefendTask::DefendTask(void **buf, TaskID id) : Task(buf, id) {
void *bufferPtr = *buf;
ObjectID attackerID;
@@ -5034,7 +4702,7 @@ bool DefendTask::operator == (const Task &t) const {
//----------------------------------------------------------------------
// Constructor -- reconstruct from archive buffer
-ParryTask::ParryTask(void **buf) : Task(buf) {
+ParryTask::ParryTask(void **buf, TaskID id) : Task(buf, id) {
void *bufferPtr = *buf;
ObjectID attackerID,
diff --git a/engines/saga2/task.h b/engines/saga2/task.h
index d52eeb4c3e..f4f07f5ab8 100644
--- a/engines/saga2/task.h
+++ b/engines/saga2/task.h
@@ -76,11 +76,10 @@ void pauseActorTasks(void);
void resumeActorTasks(void);
// Allocate a new task stack
-void *newTaskStack(void);
-void *newTaskStack(TaskStackID id);
+void newTaskStack(TaskStack *p);
// Dispose of a previously allocated task stack
-void deleteTaskStack(void *p);
+void deleteTaskStack(TaskStack *p);
// Return the ID number of a specified task stack
TaskStackID getTaskStackID(TaskStack *ts);
@@ -101,17 +100,11 @@ void loadTaskStacks(SaveFileReader &saveGame);
void cleanupTaskStacks(void);
-// Allocate a new task
-#if DEBUG
-void *newTask(char *file, int line);
-void *newTask(char *file, int line, TaskID id);
-#else
-void *newTask(void);
-void *newTask(TaskID id);
-#endif
+void newTask(Task *t);
+void newTask(Task *t, TaskID id);
// Dispose of a previously allocated task
-void deleteTask(void *p);
+void deleteTask(Task *p);
// Return a task's ID number
TaskID getTaskID(Task *t);
@@ -145,10 +138,16 @@ protected:
public:
// Constructor -- initial construction
- Task(TaskStack *ts) : stack(ts) {}
+ Task(TaskStack *ts) : stack(ts) {
+ newTask(this);
+ }
+
+ Task(TaskStack *ts, TaskID id) : stack(ts) {
+ newTask(this, id);
+ }
// Constructor -- reconstruct from archive buffer
- Task(void **buf);
+ Task(void **buf, TaskID id);
// Virtual destructor -- do nothing
virtual ~Task(void) {}
@@ -163,29 +162,6 @@ public:
// Create an archive of this task in a buffer
virtual void *archive(void *buf) const;
- // Overloaded memory management functions
-#if DEBUG
- void *operator new (size_t sz, char *file, int line);
- void *operator new (size_t sz, char *file, int line, TaskID id);
-#else
- void *operator new (size_t) {
- return newTask();
- }
- void *operator new (size_t, TaskID id) {
- return newTask(id);
- }
-#endif
-
- void operator delete (void *p) {
- deleteTask(p);
- }
-
-#if DEBUG
- // Debugging function used to mark this task and any sub tasks as
- // being used. This is used to find task leaks.
- virtual void mark(void);
-#endif
-
// Return an integer representing the type of this task
virtual int16 getType(void) const = 0;
@@ -217,7 +193,7 @@ public:
}
// Constructor -- reconstruct from archive buffer
- WanderTask(void **buf);
+ WanderTask(void **buf, TaskID id);
// Return the number of bytes needed to archive this object in
// a buffer
@@ -287,7 +263,7 @@ public:
}
// Constructor -- reconstruct from archive buffer
- TetheredWanderTask(void **buf);
+ TetheredWanderTask(void **buf, TaskID id);
// Fixup the subtask pointers
void fixup(void);
@@ -334,7 +310,7 @@ public:
}
// Constructor -- reconstruct from archive buffer
- GotoTask(void **buf);
+ GotoTask(void **buf, TaskID id);
// Fixup the subtask pointer
void fixup(void);
@@ -383,7 +359,7 @@ public:
}
// Constructor -- reconstruct from archive buffer
- GotoLocationTask(void **buf);
+ GotoLocationTask(void **buf, TaskID id);
// Return the number of bytes needed to archive this object in
// a buffer
@@ -439,7 +415,7 @@ public:
}
// Constructor -- reconstruct from archive buffer
- GotoRegionTask(void **buf);
+ GotoRegionTask(void **buf, TaskID id);
// Return the number of bytes needed to archive this object in
// a buffer
@@ -496,7 +472,7 @@ public:
}
// Constructor -- reconstruct from archive buffer
- GotoObjectTargetTask(void **buf);
+ GotoObjectTargetTask(void **buf, TaskID id);
// Return the number of bytes needed to archive this object in
// a buffer
@@ -541,7 +517,7 @@ public:
}
// Constructor -- reconstruct from archive buffer
- GotoObjectTask(void **buf);
+ GotoObjectTask(void **buf, TaskID id);
// Return the number of bytes needed to archive this object in
// a buffer
@@ -579,7 +555,7 @@ public:
targetActor(a) {
}
// Constructor -- reconstruct from archive buffer
- GotoActorTask(void **buf);
+ GotoActorTask(void **buf, TaskID id);
// Return the number of bytes needed to archive this object in
// a buffer
@@ -631,7 +607,7 @@ public:
}
// Constructor -- reconstruct from archive buffer
- GoAwayFromTask(void **buf);
+ GoAwayFromTask(void **buf, TaskID id);
// Fixup the subtask pointer
void fixup(void);
@@ -672,7 +648,7 @@ public:
}
// Constructor -- reconstruct from archive buffer
- GoAwayFromObjectTask(void **buf);
+ GoAwayFromObjectTask(void **buf, TaskID id);
// Return the number of bytes needed to archive this object in
// a buffer
@@ -710,7 +686,7 @@ public:
bool runFlag = false);
// Constructor -- reconstruct from archive buffer
- GoAwayFromActorTask(void **buf);
+ GoAwayFromActorTask(void **buf, TaskID id);
// Return the number of bytes needed to archive this object in
// a buffer
@@ -755,7 +731,7 @@ public:
}
// Constructor -- reconstruct from archive buffer
- HuntTask(void **buf);
+ HuntTask(void **buf, TaskID id);
// Fixup the subtask pointer
void fixup(void);
@@ -809,7 +785,7 @@ public:
HuntLocationTask(TaskStack *ts, const Target &t);
// Constructor -- reconstruct from archive buffer
- HuntLocationTask(void **buf);
+ HuntLocationTask(void **buf, TaskID id);
// Return the number of bytes needed to archive this object in
// a buffer
@@ -852,7 +828,7 @@ public:
}
// Constructor -- reconstruct from archive buffer
- HuntToBeNearLocationTask(void **buf);
+ HuntToBeNearLocationTask(void **buf, TaskID id);
// Return the number of bytes needed to archive this object in
// a buffer
@@ -898,7 +874,7 @@ public:
HuntObjectTask(TaskStack *ts, const ObjectTarget &ot);
// Constructor -- reconstruct from archive buffer
- HuntObjectTask(void **buf);
+ HuntObjectTask(void **buf, TaskID id);
// Return the number of bytes needed to archive this object in
// a buffer
@@ -943,7 +919,7 @@ public:
}
// Constructor -- reconstruct from archive buffer
- HuntToBeNearObjectTask(void **buf);
+ HuntToBeNearObjectTask(void **buf, TaskID id);
// Return the number of bytes needed to archive this object in
// a buffer
@@ -997,7 +973,7 @@ public:
}
// Constructor -- reconstruct from archive buffer
- HuntToPossessTask(void **buf);
+ HuntToPossessTask(void **buf, TaskID id);
// Return the number of bytes needed to archive this object in
// a buffer
@@ -1046,7 +1022,7 @@ public:
bool trackFlag);
// Constructor -- reconstruct from archive buffer
- HuntActorTask(void **buf);
+ HuntActorTask(void **buf, TaskID id);
// Return the number of bytes needed to archive this object in
// a buffer
@@ -1103,7 +1079,7 @@ public:
}
// Constructor -- reconstruct from archive buffer
- HuntToBeNearActorTask(void **buf);
+ HuntToBeNearActorTask(void **buf, TaskID id);
// Fixup the subtask pointer
void fixup(void);
@@ -1174,7 +1150,7 @@ public:
bool trackFlag = false);
// Constructor -- reconstruct from archive buffer
- HuntToKillTask(void **buf);
+ HuntToKillTask(void **buf, TaskID id);
// Return the number of bytes needed to archive this object in
// a buffer
@@ -1230,7 +1206,7 @@ public:
}
// Constructor -- reconstruct from archive buffer
- HuntToGiveTask(void **buf);
+ HuntToGiveTask(void **buf, TaskID id);
// Return the number of bytes needed to archive this object in
// a buffer
@@ -1351,7 +1327,7 @@ public:
}
// Constructor -- reconstruct from archive buffer
- BandTask(void **buf);
+ BandTask(void **buf, TaskID id);
// Fixup the subtask pointer
void fixup(void);
@@ -1436,7 +1412,7 @@ public:
BandAndAvoidEnemiesTask(TaskStack *ts) : BandTask(ts) {}
// Constructor -- reconstruct from archive buffer
- BandAndAvoidEnemiesTask(void **buf) : BandTask(buf) {}
+ BandAndAvoidEnemiesTask(void **buf, TaskID id) : BandTask(buf, id) {}
// Return an integer representing the type of this task
int16 getType(void) const;
@@ -1478,7 +1454,7 @@ public:
}
// Constructor -- reconstruct from archive buffer
- FollowPatrolRouteTask(void **buf);
+ FollowPatrolRouteTask(void **buf, TaskID id);
// Fixup the subtask pointer
void fixup(void);
@@ -1533,7 +1509,7 @@ public:
AttendTask(TaskStack *ts, GameObject *o) : Task(ts), obj(o) {}
// Constructor -- reconstruct from archive buffer
- AttendTask(void **buf);
+ AttendTask(void **buf, TaskID id);
// Return the number of bytes needed to archive this object in
// a buffer
@@ -1575,7 +1551,7 @@ public:
}
// Constructor -- reconstruct from archive buffer
- DefendTask(void **buf);
+ DefendTask(void **buf, TaskID id);
// Fixup the subtask pointer
void fixup(void);
@@ -1623,7 +1599,7 @@ public:
}
// Constructor -- reconstruct from archive buffer
- ParryTask(void **buf);
+ ParryTask(void **buf, TaskID id);
// Return the number of bytes needed to archive this object in
// a buffer
@@ -1665,13 +1641,17 @@ public:
actor(a),
evalCount(defaultEvalRate),
evalRate(defaultEvalRate) {
+
+ newTaskStack(this);
}
// Constructor -- reconstruct from archive buffer
TaskStack(void **buf);
// Destructor
- ~TaskStack(void) {}
+ ~TaskStack(void) {
+ deleteTaskStack(this);
+ }
// Return the number of bytes necessary to archive this TaskStack
// in a buffer
@@ -1685,23 +1665,6 @@ public:
// Create an archive of this TaskStack in a buffer
void *archive(void *buf);
- void *operator new (size_t) {
- return newTaskStack();
- }
- void *operator new (size_t, TaskStackID id) {
- return newTaskStack(id);
- }
-
- void operator delete (void *p) {
- deleteTaskStack(p);
- }
-
-#if DEBUG
- // Debugging function used to mark this task and any sub tasks as
- // being used. This is used to find task leaks.
- void mark(void);
-#endif
-
// Set the bottom task of this task stack
void setTask(Task *t);
Commit: 36e9a264c815c38639d55050b453d3c92eeced6d
https://github.com/scummvm/scummvm/commit/36e9a264c815c38639d55050b453d3c92eeced6d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:19+02:00
Commit Message:
SAGA2: Reworked ActorAssignment to not use dirty pointer hacks
Changed paths:
engines/saga2/actor.cpp
engines/saga2/actor.h
engines/saga2/assign.cpp
engines/saga2/assign.h
engines/saga2/sagafunc.cpp
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 4a66a55f94..58541d5057 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -1033,7 +1033,7 @@ void Actor::init(
curTask = NULL;
currentGoal = actorGoalFollowAssignment;
deactivationCounter = 0;
- memset(assignmentBuf, 0, sizeof(assignmentBuf));
+ _assignment = nullptr;
memcpy(
&effectiveStats,
@@ -1100,7 +1100,7 @@ Actor::Actor(const ResourceActor &res) : GameObject(res) {
curTask = NULL;
currentGoal = actorGoalFollowAssignment;
deactivationCounter = 0;
- memset(assignmentBuf, 0, sizeof(assignmentBuf));
+ _assignment = nullptr;
memcpy(
&effectiveStats,
@@ -1187,7 +1187,7 @@ Actor::Actor(void **buf) : GameObject(buf) {
bufferPtr = &a[1];
if (flags & hasAssignment) {
- freeAssignment();
+ delete _assignment;
bufferPtr = constructAssignment(this, bufferPtr);
}
@@ -1205,11 +1205,7 @@ Actor::Actor(void **buf) : GameObject(buf) {
Actor::~Actor(void) {
if (appearance != NULL) ReleaseActorAppearance(appearance);
- ActorAssignment *assign = getAssignment();
- // I don't know why I have to specify the ActorAssignment delete
- // operator, but "delete assign" will crash the program
- if (assign != NULL) ActorAssignment::operator delete (assign);
-
+ delete _assignment;
}
//-----------------------------------------------------------------------
diff --git a/engines/saga2/actor.h b/engines/saga2/actor.h
index c293b17042..7f0c0fe184 100644
--- a/engines/saga2/actor.h
+++ b/engines/saga2/actor.h
@@ -610,7 +610,7 @@ public:
uint8 deactivationCounter;
// Assignment
- uint8 assignmentBuf[24]; // memory reserved for actor
+ ActorAssignment *_assignment;
// assignments
// Current effective stats
@@ -721,25 +721,10 @@ public:
// Lobotomize this actor
void lobotomize(void);
- // Allocate the assignment buffer for a new assignment
- void *allocAssignment(size_t sz) {
- assert(sz <= sizeof(assignmentBuf));
- if (!(flags & hasAssignment)) {
- flags |= hasAssignment;
- return &assignmentBuf;
- } else
- return NULL;
- }
-
- // Free the emmbedded assignment buffer
- void freeAssignment(void) {
- flags &= ~hasAssignment;
- }
-
// Return a pointer to the actor's current assignment
ActorAssignment *getAssignment(void) {
return flags & hasAssignment
- ? (ActorAssignment *)&assignmentBuf
+ ? _assignment
: NULL;
}
diff --git a/engines/saga2/assign.cpp b/engines/saga2/assign.cpp
index 27fbfb3220..3243e15a9a 100644
--- a/engines/saga2/assign.cpp
+++ b/engines/saga2/assign.cpp
@@ -40,21 +40,26 @@ const uint16 indefinitely = CalenderTime::framesPerDay;
* ===================================================================== */
// Constructor
-ActorAssignment::ActorAssignment(uint16 until) :
+ActorAssignment::ActorAssignment(Actor *a, uint16 until) :
startFrame(calender.frameInDay()),
endFrame(until) {
+ _actor = a;
+ a->_assignment = this;
}
//----------------------------------------------------------------------
// Constructor -- reconstruct from archive buffer
-ActorAssignment::ActorAssignment(void **buf) {
+ActorAssignment::ActorAssignment(Actor *ac, void **buf) {
uint16 *a = (uint16 *)*buf;
startFrame = *a++;
endFrame = *a++;
*buf = a;
+
+ _actor = ac;
+ ac->_assignment = this;
}
//----------------------------------------------------------------------
@@ -93,23 +98,6 @@ void *ActorAssignment::archive(void *buf) const {
return a;
}
-//----------------------------------------------------------------------
-// Return a pointer to the specified actor's reserved memory for
-// assignments if it is not already being used.
-
-void *ActorAssignment::operator new (
- size_t bytes,
- Actor *a) {
- return a->allocAssignment(bytes);
-}
-
-//----------------------------------------------------------------------
-// Simply mark the actor's assignment as not being used.
-
-void ActorAssignment::operator delete (void *p) {
- ((ActorAssignment *)p)->getActor()->freeAssignment();
-}
-
//----------------------------------------------------------------------
// Determine if the time limit for this assignment has been exceeded
@@ -144,9 +132,7 @@ TaskStack *ActorAssignment::createTask(void) {
}
Actor *ActorAssignment::getActor(void) const {
- // FIXME: This is utterly evil
- warning("FIXME: ActorAssignment::getActor(): unsafe pointer arithmetics");
- return (Actor *)(this - offsetof(Actor, assignmentBuf));
+ return _actor;
}
@@ -184,12 +170,13 @@ bool ActorAssignment::taskNeeded(void) {
// Constructor -- initial object construction
PatrolRouteAssignment::PatrolRouteAssignment(
+ Actor *a,
uint16 until,
int16 rteNo,
uint8 patrolFlags,
int16 start,
int16 end) :
- ActorAssignment(until),
+ ActorAssignment(a, until),
routeNo(rteNo),
startingWayPoint(start),
endingWayPoint(end),
@@ -200,8 +187,8 @@ PatrolRouteAssignment::PatrolRouteAssignment(
//----------------------------------------------------------------------
// Restore the data for this object from a buffer
-PatrolRouteAssignment::PatrolRouteAssignment(void **buf) :
- ActorAssignment(buf) {
+PatrolRouteAssignment::PatrolRouteAssignment(Actor *a, void **buf) :
+ ActorAssignment(a, buf) {
void *bufferPtr = *buf;
// Restore route number
@@ -336,14 +323,14 @@ Task *PatrolRouteAssignment::getTask(TaskStack *ts) {
HuntToBeNearLocationAssignment member functions
* ===================================================================== */
-HuntToBeNearLocationAssignment::HuntToBeNearLocationAssignment(const TilePoint &tp, uint16 r) :
- ActorAssignment(indefinitely) {
+HuntToBeNearLocationAssignment::HuntToBeNearLocationAssignment(Actor *a, const TilePoint &tp, uint16 r) :
+ ActorAssignment(a, indefinitely) {
initialize(LocationTarget(tp), r);
}
// Construct with no time limit and an abstract target
-HuntToBeNearLocationAssignment::HuntToBeNearLocationAssignment(const Target &targ, uint16 r) :
- ActorAssignment(indefinitely) {
+HuntToBeNearLocationAssignment::HuntToBeNearLocationAssignment(Actor *a, const Target &targ, uint16 r) :
+ ActorAssignment(a, indefinitely) {
initialize(targ, r);
}
@@ -364,8 +351,8 @@ void HuntToBeNearLocationAssignment::initialize(
//----------------------------------------------------------------------
// Constructor -- constructs from archive buffer
-HuntToBeNearLocationAssignment::HuntToBeNearLocationAssignment(void **buf) :
- ActorAssignment(buf) {
+HuntToBeNearLocationAssignment::HuntToBeNearLocationAssignment(Actor *a, void **buf) :
+ ActorAssignment(a, buf) {
void *bufferPtr = *buf;
// Restore the target
@@ -438,17 +425,18 @@ HuntToBeNearActorAssignment::HuntToBeNearActorAssignment(
Actor *a,
uint16 r,
bool trackFlag) :
- ActorAssignment(indefinitely) {
+ ActorAssignment(a, indefinitely) {
assert(isActor(a) && a != getActor());
initialize(SpecificActorTarget(a), r, trackFlag);
}
// Construct with no time limit and abstract actor target
HuntToBeNearActorAssignment::HuntToBeNearActorAssignment(
+ Actor *a,
const ActorTarget &at,
uint16 r,
bool trackFlag) :
- ActorAssignment(indefinitely) {
+ ActorAssignment(a, indefinitely) {
initialize(at, r, trackFlag);
}
@@ -472,8 +460,8 @@ void HuntToBeNearActorAssignment::initialize(
//----------------------------------------------------------------------
// Constructor -- constructs from archive buffer
-HuntToBeNearActorAssignment::HuntToBeNearActorAssignment(void **buf) :
- ActorAssignment(buf) {
+HuntToBeNearActorAssignment::HuntToBeNearActorAssignment(Actor *a, void **buf) :
+ ActorAssignment(a, buf) {
void *bufferPtr = *buf;
// Restore the target
@@ -560,16 +548,17 @@ Task *HuntToBeNearActorAssignment::getTask(TaskStack *ts) {
// Construct with no time limit and specific actor
HuntToKillAssignment::HuntToKillAssignment(Actor *a, bool trackFlag) :
- ActorAssignment(indefinitely) {
+ ActorAssignment(a, indefinitely) {
assert(isActor(a) && a != getActor());
initialize(SpecificActorTarget(a), trackFlag, true);
}
// Construct with no time limit and abstract actor target
HuntToKillAssignment::HuntToKillAssignment(
+ Actor *a,
const ActorTarget &at,
bool trackFlag) :
- ActorAssignment(indefinitely) {
+ ActorAssignment(a, indefinitely) {
initialize(at, trackFlag, false);
}
@@ -594,8 +583,8 @@ void HuntToKillAssignment::initialize(
//----------------------------------------------------------------------
// Constructor -- constructs from archive buffer
-HuntToKillAssignment::HuntToKillAssignment(void **buf) :
- ActorAssignment(buf) {
+HuntToKillAssignment::HuntToKillAssignment(Actor *a, void **buf) :
+ ActorAssignment(a, buf) {
void *bufferPtr = *buf;
// Restore the target
@@ -694,7 +683,7 @@ Task *HuntToKillAssignment::getTask(TaskStack *ts) {
//----------------------------------------------------------------------
// Constructor -- constructs from archive buffer
-TetheredAssignment::TetheredAssignment(void **buf) : ActorAssignment(buf) {
+TetheredAssignment::TetheredAssignment(Actor *ac, void **buf) : ActorAssignment(ac, buf) {
int16 *a = (int16 *)*buf;
// Read data from buffer
@@ -745,9 +734,10 @@ void *TetheredAssignment::archive(void *buf) const {
// Constructor -- initial assignment construction
TetheredWanderAssignment::TetheredWanderAssignment(
+ Actor *a,
uint16 until,
const TileRegion ®) :
- TetheredAssignment(until, reg) {
+ TetheredAssignment(a, until, reg) {
}
//----------------------------------------------------------------------
@@ -772,15 +762,15 @@ Task *TetheredWanderAssignment::getTask(TaskStack *ts) {
//----------------------------------------------------------------------
// Constructor -- initial assignment construction
-AttendAssignment::AttendAssignment(uint16 until, GameObject *o) :
- ActorAssignment(until),
+AttendAssignment::AttendAssignment(Actor *a, uint16 until, GameObject *o) :
+ ActorAssignment(a, until),
obj(o) {
}
//----------------------------------------------------------------------
// Constructor -- constructs from archive buffer
-AttendAssignment::AttendAssignment(void **buf) : ActorAssignment(buf) {
+AttendAssignment::AttendAssignment(Actor *a, void **buf) : ActorAssignment(a, buf) {
ObjectID *bufferPtr = (ObjectID *)*buf;
ObjectID objID;
@@ -852,23 +842,23 @@ void *constructAssignment(Actor *a, void *buf) {
// Based upon the type, call the correct constructor
switch (type) {
case patrolRouteAssignment:
- new (a) PatrolRouteAssignment(&buf);
+ new PatrolRouteAssignment(a, &buf);
break;
case huntToBeNearActorAssignment:
- new (a) HuntToBeNearActorAssignment(&buf);
+ new HuntToBeNearActorAssignment(a, &buf);
break;
case huntToBeNearLocationAssignment:
- new (a) HuntToBeNearLocationAssignment(&buf);
+ new HuntToBeNearLocationAssignment(a, &buf);
break;
case tetheredWanderAssignment:
- new (a) TetheredWanderAssignment(&buf);
+ new TetheredWanderAssignment(a, &buf);
break;
case attendAssignment:
- new (a) AttendAssignment(&buf);
+ new AttendAssignment(a, &buf);
break;
}
diff --git a/engines/saga2/assign.h b/engines/saga2/assign.h
index 6320ed2022..39ab595629 100644
--- a/engines/saga2/assign.h
+++ b/engines/saga2/assign.h
@@ -53,12 +53,14 @@ class ActorAssignment {
uint16 startFrame, // Time in day when this was constructed
endFrame; // End time of the assignment
+ Actor *_actor;
+
public:
// Constructor
- ActorAssignment(uint16 until);
+ ActorAssignment(Actor *a, uint16 until);
// Constructor -- reconstruct from archive buffer
- ActorAssignment(void **buf);
+ ActorAssignment(Actor *a, void **buf);
// Destructor
virtual ~ActorAssignment(void);
@@ -71,12 +73,6 @@ public:
// to save it on disk
virtual void *archive(void *buf) const;
- // Allocate memory embedded in the Actor structure
- void *operator new (size_t, Actor *a);
-
- // Deallocate memory from the Actor structure
- void operator delete (void *p);
-
// Construct a TaskStack for this assignment
TaskStack *createTask(void);
@@ -123,6 +119,7 @@ class PatrolRouteAssignment : public ActorAssignment {
public:
// Constructor -- initial object construction
PatrolRouteAssignment(
+ Actor *a,
uint16 until,
int16 rteNo,
uint8 patrolFlags,
@@ -130,7 +127,7 @@ public:
int16 end = -1);
// Constructor -- constructs from archive buffer
- PatrolRouteAssignment(void **buf);
+ PatrolRouteAssignment(Actor *a, void **buf);
// Return the number of bytes need to archive the data in this
// assignment
@@ -174,32 +171,34 @@ public:
// Constructors -- initial assignment construction
// Construct with no time limit and a specific TilePoint
- HuntToBeNearLocationAssignment(const TilePoint &tp, uint16 r);
+ HuntToBeNearLocationAssignment(Actor *a, const TilePoint &tp, uint16 r);
// Construct with time limit and a specific TilePoint
HuntToBeNearLocationAssignment(
+ Actor *a,
uint16 until,
const TilePoint &tp,
uint16 r) :
- ActorAssignment(until) {
+ ActorAssignment(a, until) {
initialize(LocationTarget(tp), r);
}
// Construct with no time limit and an abstract target
- HuntToBeNearLocationAssignment(const Target &targ, uint16 r);
+ HuntToBeNearLocationAssignment(Actor *a, const Target &targ, uint16 r);
// Construct with time limit and an abstract target
HuntToBeNearLocationAssignment(
+ Actor *a,
uint16 until,
const Target &targ,
uint16 r) :
- ActorAssignment(until) {
+ ActorAssignment(a, until) {
initialize(targ, r);
}
// Constructor -- constructs from archive buffer
- HuntToBeNearLocationAssignment(void **buf);
+ HuntToBeNearLocationAssignment(Actor *a, void **buf);
// Return the number of bytes need to archive the data in this
// assignment
@@ -252,33 +251,36 @@ public:
// Construct with time limit and specific actor
HuntToBeNearActorAssignment(
+ Actor *ac,
uint16 until,
Actor *a,
uint16 r,
bool trackFlag = false) :
- ActorAssignment(until) {
+ ActorAssignment(ac, until) {
assert(isActor(a) && a != getActor());
initialize(SpecificActorTarget(a), r, trackFlag);
}
// Construct with no time limit and abstract actor target
HuntToBeNearActorAssignment(
+ Actor *a,
const ActorTarget &at,
uint16 r,
bool trackFlag = false);
// Construct with time limit and abstract actor target
HuntToBeNearActorAssignment(
+ Actor *a,
uint16 until,
const ActorTarget &at,
uint16 r,
bool trackFlag = false) :
- ActorAssignment(until) {
+ ActorAssignment(a, until) {
initialize(at, r, trackFlag);
}
// Constructor -- reconstructs from archive buffer
- HuntToBeNearActorAssignment(void **buf);
+ HuntToBeNearActorAssignment(Actor *a, void **buf);
// Return the number of bytes need to archive the data in this
// assignment
@@ -328,30 +330,33 @@ public:
// Construct with time limit and specific actor
HuntToKillAssignment(
+ Actor *ac,
uint16 until,
Actor *a,
bool trackFlag = false) :
- ActorAssignment(until) {
+ ActorAssignment(ac, until) {
assert(isActor(a) && a != getActor());
initialize(SpecificActorTarget(a), trackFlag, true);
}
// Construct with no time limit and abstract actor target
HuntToKillAssignment(
+ Actor *a,
const ActorTarget &at,
bool trackFlag = false);
// Construct with time limit and abstract actor target
HuntToKillAssignment(
+ Actor *a,
uint16 until,
const ActorTarget &at,
bool trackFlag = false) :
- ActorAssignment(until) {
+ ActorAssignment(a, until) {
initialize(at, trackFlag, false);
}
// Constructor -- reconstructs from archive buffer
- HuntToKillAssignment(void **buf);
+ HuntToKillAssignment(Actor *a, void **buf);
// Return the number of bytes need to archive the data in this
// assignment
@@ -391,15 +396,15 @@ protected:
public:
// Constructor -- initial assignment construction
- TetheredAssignment(uint16 until, const TileRegion ®) :
- ActorAssignment(until),
+ TetheredAssignment(Actor *a, uint16 until, const TileRegion ®) :
+ ActorAssignment(a, until),
minU(reg.min.u),
minV(reg.min.v),
maxU(reg.max.u),
maxV(reg.max.v) {
}
- TetheredAssignment(void **buf);
+ TetheredAssignment(Actor *a, void **buf);
// Return the number of bytes need to archive the data in this
// assignment
@@ -417,10 +422,10 @@ public:
class TetheredWanderAssignment : public TetheredAssignment {
public:
// Constructor -- initial assignment construction
- TetheredWanderAssignment(uint16 until, const TileRegion ®);
+ TetheredWanderAssignment(Actor *a, uint16 until, const TileRegion ®);
// Constructor -- constructs from archive buffer
- TetheredWanderAssignment(void **buf) : TetheredAssignment(buf) {}
+ TetheredWanderAssignment(Actor *a, void **buf) : TetheredAssignment(a, buf) {}
// Return an integer representing the type of this assignment
int16 type(void) const;
@@ -439,10 +444,10 @@ class AttendAssignment : public ActorAssignment {
public:
// Constructor -- initial assignment construction
- AttendAssignment(uint16 until, GameObject *o);
+ AttendAssignment(Actor *a, uint16 until, GameObject *o);
// Constructor -- constructs from archive buffer
- AttendAssignment(void **buf);
+ AttendAssignment(Actor *a, void **buf);
// Return the number of bytes need to archive the data in this
// assignment
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index 8ab77f1edb..d103a379f7 100644
--- a/engines/saga2/sagafunc.cpp
+++ b/engines/saga2/sagafunc.cpp
@@ -1674,7 +1674,7 @@ int16 scriptActorAssignPatrolRoute(int16 *args) {
// Delete the actor's current assignment
if (a->getAssignment() != NULL) delete a->getAssignment();
- if (new (a) PatrolRouteAssignment(
+ if (new PatrolRouteAssignment(a,
(uint16)args[0]
* CalenderTime::framesPerHour,
args[1],
@@ -1706,7 +1706,7 @@ int16 scriptActorAssignPartialPatrolRoute(int16 *args) {
// Delete the actor's current assignment
if (a->getAssignment() != NULL) delete a->getAssignment();
- if (new (a) PatrolRouteAssignment(
+ if (new PatrolRouteAssignment(a,
(uint16)args[0]
* CalenderTime::framesPerHour,
args[1],
@@ -1739,7 +1739,7 @@ int16 scriptActorAssignBeNearLocation(int16 *args) {
// Delete the actor's current assignment
if (a->getAssignment() != NULL) delete a->getAssignment();
- if (new (a) HuntToBeNearLocationAssignment(
+ if (new HuntToBeNearLocationAssignment(a,
args[0],
targetLoc,
args[4])
@@ -1772,7 +1772,7 @@ int16 scriptActorAssignBeNearActor(int16 *args) {
// Delete the actor's current assignment
if (a->getAssignment() != NULL) delete a->getAssignment();
- if (new (a) HuntToBeNearActorAssignment(
+ if (new HuntToBeNearActorAssignment(a,
args[0],
targetActor,
args[2],
@@ -1801,7 +1801,7 @@ int16 scriptActorAssignKillActor(int16 *args) {
// Delete the actor's current assignment
if (a->getAssignment() != NULL) delete a->getAssignment();
- if (new (a) HuntToKillAssignment(
+ if (new HuntToKillAssignment(a,
args[0],
targetActor,
args[2])
@@ -1850,7 +1850,7 @@ int16 scriptActorAssignTetheredWander(int16 *args) {
tetherReg.min = TilePoint(minU, minV, 0);
tetherReg.max = TilePoint(maxU, maxV, 0);
- if (new (a) TetheredWanderAssignment(
+ if (new TetheredWanderAssignment(a,
(uint16)args[0]
* CalenderTime::framesPerHour,
tetherReg)
@@ -1873,7 +1873,7 @@ int16 scriptActorAssignAttend(int16 *args) {
// Delete the actor's current assignment
if (a->getAssignment() != NULL) delete a->getAssignment();
- if (new (a) AttendAssignment(
+ if (new AttendAssignment(a,
(calender.frameInDay()
+ (uint16)args[0])
% CalenderTime::framesPerDay,
Commit: 9565ea67a3ec8aebd004a6ef137e40f245ddce1c
https://github.com/scummvm/scummvm/commit/9565ea67a3ec8aebd004a6ef137e40f245ddce1c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:19+02:00
Commit Message:
SAGA2: Added safeguards to sprite unpacking
Changed paths:
engines/saga2/blitters.cpp
engines/saga2/main.cpp
diff --git a/engines/saga2/blitters.cpp b/engines/saga2/blitters.cpp
index 3ceb6cb4a5..53ee29b37c 100644
--- a/engines/saga2/blitters.cpp
+++ b/engines/saga2/blitters.cpp
@@ -110,6 +110,11 @@ void unpackSprite(gPixelMap *map, uint8 *sprData) {
while (true) {
byte trans = *sprData++;
+ if (bytes < trans) {
+ warning("unpackSprite: too many trans %d < %d", bytes, trans);
+ trans = bytes;
+ break;
+ }
memset(dst, 0, trans);
dst += trans;
bytes -= trans;
@@ -118,6 +123,10 @@ void unpackSprite(gPixelMap *map, uint8 *sprData) {
break;
byte fill = *sprData++;
+ if (bytes < fill) {
+ warning("unpackSprite: too many bytes %d < %d", bytes, fill);
+ fill = bytes;
+ }
memcpy(dst, sprData, fill);
dst += fill;
bytes -= fill;
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 712d8a621f..be10ebfe44 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -530,11 +530,11 @@ void *LoadResource(hResContext *con, uint32 id, const char desc[]) {
idString[0] = id;
idString[1] = 0;
- debugC(3, kDebugResources, "Loading resource %d (%s, %s)", id, tag2str(id), desc);
+ debugC(3, kDebugResources, "LoadResource(): Loading resource %d (%s, %s)", id, tag2str(id), desc);
size = con->size(id);
if (size <= 0 || !con->seek(id)) {
- error("Error reading resource ID '%s'.", &idString);
+ error("LoadResource(): Error reading resource ID '%s'.", &idString);
}
// Allocate the buffer
@@ -552,11 +552,11 @@ Common::SeekableReadStream *loadResourceToStream(hResContext *con, uint32 id, co
idString[0] = id;
idString[1] = 0;
- debugC(3, kDebugResources, "Loading resource %d (%s, %s)", id, tag2str(id), desc);
+ debugC(3, kDebugResources, "loadResourceToStream(): Loading resource %d (%s, %s)", id, tag2str(id), desc);
size = con->size(id);
if (size <= 0 || !con->seek(id)) {
- error("Error reading resource ID '%s'.", &idString);
+ error("loadResourceToStream(): Error reading resource ID '%s'.", &idString);
}
// Allocate the buffer
@@ -577,10 +577,11 @@ RHANDLE LoadResourceToHandle(hResContext *con, uint32 id, const char desc[]) {
idString[0] = id;
idString[1] = 0;
+ debugC(3, kDebugResources, "LoadResourceToHandle(): Loading resource %d (%s, %s)", id, tag2str(id), desc);
size = con->size(id);
if (size <= 0 || !con->seek(id)) {
- error("Error reading resource ID '%s'.", &idString);
+ error("LoadResourceToHandle(): Error reading resource ID '%s'.", &idString);
}
// Allocate the buffer
@@ -978,6 +979,9 @@ APPFUNC(cmdWindowFunc) {
GameMode::modeStackPtr[GameMode::modeStackCtr - 1]->handleKey(key, qual);
break;
+
+ default:
+ break;
}
}
Commit: a445537f484376c23ecac800f0eba2d8433df667
https://github.com/scummvm/scummvm/commit/a445537f484376c23ecac800f0eba2d8433df667
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:19+02:00
Commit Message:
SAGA2: Fix stack overflow
Changed paths:
engines/saga2/task.cpp
diff --git a/engines/saga2/task.cpp b/engines/saga2/task.cpp
index a96b7046c3..80ea420b85 100644
--- a/engines/saga2/task.cpp
+++ b/engines/saga2/task.cpp
@@ -271,7 +271,6 @@ void TaskStackList::newTaskStack(TaskStack *p) {
void TaskStackList::deleteTaskStack(TaskStack *p) {
for (int i = 0; i < numTaskStacks; i++)
if (_list[i] == p) {
- delete _list[i];
_list[i] = nullptr;
}
}
Commit: ac8c438dac6605f68795b747f19c5ca46d8f0337
https://github.com/scummvm/scummvm/commit/ac8c438dac6605f68795b747f19c5ca46d8f0337
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:19+02:00
Commit Message:
SAGA2: Non-fatal warning on failed resource load
Changed paths:
engines/saga2/main.cpp
engines/saga2/sprite.cpp
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index be10ebfe44..cdc10c1904 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -556,7 +556,8 @@ Common::SeekableReadStream *loadResourceToStream(hResContext *con, uint32 id, co
size = con->size(id);
if (size <= 0 || !con->seek(id)) {
- error("loadResourceToStream(): Error reading resource ID '%s'.", &idString);
+ warning("loadResourceToStream(): Error reading resource ID '%s'.", &idString);
+ return nullptr;
}
// Allocate the buffer
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index 1ca2466c67..d24d1cd7fa 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -596,8 +596,10 @@ void ActorAppearance::loadSpriteBanks(int16 banksNeeded) {
// Load the sprite handle...
if (spriteBanks[bank] == nullptr && (banksNeeded & (1 << bank))) {
Common::SeekableReadStream *stream = loadResourceToStream(spriteRes, id + MKTAG(0, 0, 0, bank), "sprite bank");
- spriteBanks[bank] = new SpriteSet(stream);
- delete stream;
+ if (stream) {
+ spriteBanks[bank] = new SpriteSet(stream);
+ delete stream;
+ }
}
}
}
@@ -693,20 +695,23 @@ ActorAppearance *LoadActorAppearance(uint32 id, int16 banksNeeded) {
// Load in new frame lists and sprite banks
aa->loadSpriteBanks(banksNeeded);
- if(poseRes->seek(id) == 0)
- error("Could not load pose list");
-
- poseListSize = poseRes->size(id) / actorAnimSetSize;
- aa->poseList = new ActorAnimSet[poseListSize];
- for (int i = 0; i < poseListSize; ++i)
- readActorAnimSet(poseRes, aa->poseList[i]);
+ if (poseRes->seek(id) == 0) {
+ warning("LoadActorAppearance: Could not load pose list");
+ } else {
+ poseListSize = poseRes->size(id) / actorAnimSetSize;
+ aa->poseList = new ActorAnimSet[poseListSize];
+ for (int i = 0; i < poseListSize; ++i)
+ readActorAnimSet(poseRes, aa->poseList[i]);
+ }
- if(schemeRes->seek(id) == 0)
- error("Could not load scheme list");
+ if (schemeRes->seek(id) == 0) {
+ warning("LoadActorAppearance: Could not load scheme list");
+ } else {
+ schemeListSize = schemeRes->size(id) / colorSchemeSize;
+ stream = loadResourceToStream(schemeRes, id, "scheme list");
+ aa->schemeList = new ColorSchemeList(schemeListSize, stream);
+ }
- schemeListSize = schemeRes->size(id) / colorSchemeSize;
- stream = loadResourceToStream(schemeRes, id, "scheme list");
- aa->schemeList = new ColorSchemeList(schemeListSize, stream);
delete stream;
return aa;
Commit: 9649d168f84924a4e659d88f259eeacc9ddbab26
https://github.com/scummvm/scummvm/commit/9649d168f84924a4e659d88f259eeacc9ddbab26
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:19+02:00
Commit Message:
SAGA2: Disable audio
Changed paths:
engines/saga2/noise.cpp
diff --git a/engines/saga2/noise.cpp b/engines/saga2/noise.cpp
index 75f6fd488b..583b0af9f6 100644
--- a/engines/saga2/noise.cpp
+++ b/engines/saga2/noise.cpp
@@ -567,6 +567,8 @@ bool sayVoice(uint32 s[]) {
// main loop playback
void _playLoop(uint32 s) {
+ warning("STUB: _playLoop(%d)", s);
+ return;
#ifndef AUDIO_DISABLED
currentLoop = s;
if (currentLoop == audio->currentLoop())
Commit: 4f363da2438629860f4e11d19eaa100ae1179076
https://github.com/scummvm/scummvm/commit/4f363da2438629860f4e11d19eaa100ae1179076
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:19+02:00
Commit Message:
SAGA2: Accommodate for resource loading errors
Changed paths:
engines/saga2/actor.cpp
engines/saga2/sprite.cpp
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 58541d5057..90a64f8386 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -1980,6 +1980,9 @@ int16 Actor::animationFrames(int16 actionType, Direction dir) {
anim = appearance->poseList->animation(actionType);
+ if (!anim)
+ return 0;
+
return anim->count[dir];
}
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index d24d1cd7fa..9ac3ebdb48 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -710,10 +710,9 @@ ActorAppearance *LoadActorAppearance(uint32 id, int16 banksNeeded) {
schemeListSize = schemeRes->size(id) / colorSchemeSize;
stream = loadResourceToStream(schemeRes, id, "scheme list");
aa->schemeList = new ColorSchemeList(schemeListSize, stream);
+ delete stream;
}
- delete stream;
-
return aa;
}
Commit: a532e97f3e453c6ba5ef9fb5f3282e7c7cbb203f
https://github.com/scummvm/scummvm/commit/a532e97f3e453c6ba5ef9fb5f3282e7c7cbb203f
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:19+02:00
Commit Message:
SAGA2: Fix Actor void initialization
Changed paths:
engines/saga2/actor.cpp
engines/saga2/actor.h
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 90a64f8386..2e488e305f 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -1061,6 +1061,60 @@ void Actor::init(
// Actor constructor -- copies the resource fields and simply NULL's most
// of the rest of the data members
+Actor::Actor(void) {
+ prototype = nullptr;
+ faction = 0;
+ colorScheme = 0;
+ appearanceID = 0;
+ attitude = 0;
+ mood = 0;
+ disposition = 0;
+ currentFacing = 0;
+ tetherLocU = 0;
+ tetherLocV = 0;
+ tetherDist = 0;
+ leftHandObject = 0;
+ rightHandObject = 0;
+ schedule = 0;
+ for (int i = 0; i < 16; ++i)
+ knowledge[i] = 0;
+
+ // Initialize the rest of the data members
+ for (int i = 0; i < 4; ++i)
+ conversationMemory[i] = 0;
+
+ currentAnimation = actionStand;
+ currentPose = 0;
+ animationFlags = 0;
+ flags = 0;
+ memset(&poseInfo, 0, sizeof(poseInfo));
+ appearance = nullptr;
+ cycleCount = 0;
+ kludgeCount = 0;
+ moveTask = nullptr;
+ enchantmentFlags = 0L;
+ curTask = nullptr;
+ currentGoal = actorGoalFollowAssignment;
+ deactivationCounter = 0;
+ _assignment = nullptr;
+
+ memset(&effectiveStats, 0, sizeof(effectiveStats));
+ effectiveStats.vitality = MAX<uint16>(effectiveStats.vitality, 1);
+
+ actionCounter = 0;
+ effectiveResistance = 0;
+ effectiveImmunity = 0;
+ recPointsPerUpdate = BASE_REC_RATE;
+ currentRecoveryPoints = 0;
+ leader = nullptr;
+ followers = nullptr;
+ for (int i = 0; i < ARMOR_COUNT; i++)
+ armorObjects[i] = Nothing;
+ currentTarget = nullptr;
+ for (int i = 0; i < actorScriptVars; i++)
+ scriptVar[i] = 0;
+}
+
Actor::Actor(const ResourceActor &res) : GameObject(res) {
int i;
diff --git a/engines/saga2/actor.h b/engines/saga2/actor.h
index 7f0c0fe184..691ed8637a 100644
--- a/engines/saga2/actor.h
+++ b/engines/saga2/actor.h
@@ -654,7 +654,7 @@ private:
public:
// Default constructor
- Actor(void) {}
+ Actor(void);
// Constructor - initial actor construction
Actor(const ResourceActor &res);
Commit: 8aca55e10ba0db665e7179d7e766f4e76c8c9108
https://github.com/scummvm/scummvm/commit/8aca55e10ba0db665e7179d7e766f4e76c8c9108
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:19+02:00
Commit Message:
SAGA2: Fix animation access
Changed paths:
engines/saga2/actor.cpp
engines/saga2/dispnode.cpp
engines/saga2/sprite.h
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 2e488e305f..5dabfb9ce7 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -1968,7 +1968,7 @@ void Actor::getColorTranslation(ColorTable map) {
int16 Actor::setAction(int16 newState, int16 flags) {
ActorAnimation *anim;
- int16 numPoses;
+ int16 numPoses = 0;
// Refresh the handles
// RLockHandle( appearance->animations );
@@ -1977,8 +1977,9 @@ int16 Actor::setAction(int16 newState, int16 flags) {
if (appearance == NULL) return 0;
// If this animation has no frames, then return false
- anim = appearance->poseList->animation(newState);
- numPoses = anim->count[currentFacing];
+ anim = appearance->animation(newState);
+ if (anim)
+ numPoses = anim->count[currentFacing];
if (numPoses <= 0) return 0;
// Set up the animation
@@ -2007,10 +2008,13 @@ bool Actor::isActionAvailable(int16 newState, bool anyDir) {
// RLockHandle( appearance->animations );
// RUnlockHandle( appearance->animations );
- if (appearance == NULL) return false;
+ if (appearance == nullptr)
+ return false;
// If this animation has no frames, then return false
- anim = appearance->poseList->animation(newState);
+ anim = appearance->animation(newState);
+ if (anim == nullptr)
+ return false;
if (anyDir) {
for (int i = 0; i < numPoseFacings; i++) {
@@ -2028,11 +2032,12 @@ bool Actor::isActionAvailable(int16 newState, bool anyDir) {
// specified direction
int16 Actor::animationFrames(int16 actionType, Direction dir) {
- if (appearance == NULL) return 0;
+ if (appearance == nullptr)
+ return 0;
ActorAnimation *anim;
- anim = appearance->poseList->animation(actionType);
+ anim = appearance->animation(actionType);
if (!anim)
return 0;
@@ -2065,7 +2070,7 @@ bool Actor::nextAnimationFrame(void) {
} else animationFlags &= ~animateOnHold;
// Get the number of frames in the animation
- anim = appearance->poseList->animation(currentAnimation);
+ anim = appearance->animation(currentAnimation);
numPoses = anim->count[currentFacing];
if (numPoses <= 0) {
animationFlags |= animateFinished;
diff --git a/engines/saga2/dispnode.cpp b/engines/saga2/dispnode.cpp
index b19f365f09..28849c3da4 100644
--- a/engines/saga2/dispnode.cpp
+++ b/engines/saga2/dispnode.cpp
@@ -571,14 +571,16 @@ void DisplayNode::drawObject(void) {
aa = a->appearance;
- if (aa == NULL) return;
+ if (aa == nullptr)
+ return;
// Fetch the animation series, and determine which
// pose in the series is the current one.
- anim = aa->poseList->animation(a->currentAnimation);
- pose = aa->poseList->pose(anim,
- a->currentFacing,
- a->currentPose);
+ anim = aa->animation(a->currentAnimation);
+ pose = aa->pose(anim, a->currentFacing, a->currentPose);
+
+ if (anim == nullptr)
+ return
assert(anim->start[0] >= 0);
assert(anim->start[0] < 10000);
diff --git a/engines/saga2/sprite.h b/engines/saga2/sprite.h
index 3f61408653..554b02069e 100644
--- a/engines/saga2/sprite.h
+++ b/engines/saga2/sprite.h
@@ -152,17 +152,6 @@ struct ActorAnimation {
struct ActorAnimSet {
uint32 numAnimations, // number of animations
poseOffset; // offset to poses table
-
- // FIXME: Pointer Arithmetic
- ActorAnimation *animation(int num) {
- return (ActorAnimation *)(this + 1) + num;
- }
-
- ActorPose *pose(ActorAnimation *anim, int dir, int num) {
- if (num < 0 || num >= anim->count[dir]) num = 0;
- num += anim->start[dir];
- return (ActorPose *)((uint8 *)this + poseOffset) + num;
- }
};
/* ===================================================================== *
@@ -299,6 +288,24 @@ public:
loadSpriteBanks((int16)(1 << bank));
}
+ // FIXME: Pointer Arithmetic
+ ActorAnimation *animation(int num) {
+ warning("STUB: ActorAppearance::animation: Pointer Arithmetics");
+ if (poseList)
+ return (ActorAnimation *)(poseList + 1) + num;
+
+ return nullptr;
+ }
+
+ ActorPose *pose(ActorAnimation *anim, int dir, int num) {
+ warning("STUB: ActorAppearance::pose: Pointer Arithmetics");
+ if (poseList == nullptr)
+ return nullptr;
+
+ if (num < 0 || num >= anim->count[dir]) num = 0;
+ num += anim->start[dir];
+ return (ActorPose *)((uint8 *)poseList + poseList->poseOffset) + num;
+ }
};
/* ===================================================================== *
Commit: 291add3cd64158fcfc990e6a6d7c62104d6f7845
https://github.com/scummvm/scummvm/commit/291add3cd64158fcfc990e6a6d7c62104d6f7845
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:19+02:00
Commit Message:
SAGA2: Fix player iterator access in player.cpp
Changed paths:
engines/saga2/player.cpp
diff --git a/engines/saga2/player.cpp b/engines/saga2/player.cpp
index 74baa76a55..eff0701cb3 100644
--- a/engines/saga2/player.cpp
+++ b/engines/saga2/player.cpp
@@ -1112,14 +1112,18 @@ PlayerActor *LivingPlayerActorIterator::first(void) {
}
PlayerActor *LivingPlayerActorIterator::next(void) {
+ if (index >= playerActors)
+ return nullptr;
+
Actor *a = playerList[index].getActor();
- while (a == NULL || a->isDead()) {
- if (++index >= playerActors) break;
+ while (a == nullptr || a->isDead()) {
+ if (++index >= playerActors)
+ break;
a = playerList[index].getActor();
}
- return (index < playerActors) ? &playerList[index++] : NULL;
+ return (index < playerActors) ? &playerList[index++] : nullptr;
}
} // end of namespace Saga2
Commit: 5e599dfb6e9101cd1cbafa280ed7ecf6a52a58bc
https://github.com/scummvm/scummvm/commit/5e599dfb6e9101cd1cbafa280ed7ecf6a52a58bc
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:20+02:00
Commit Message:
SAGA2: Fix unsafe world access on objObscured
Changed paths:
engines/saga2/objects.cpp
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 6dad9fc545..431a6ad0dc 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -4356,11 +4356,15 @@ bool objObscured(GameObject *testObj) {
bool obscured = false;
if (isObject(testObj)) {
+ debug(3, "STUB: objObscured");
Point16 drawPos,
org;
ObjectSpriteInfo objSprInfo;
ColorTable objColors;
ProtoObj *proto = testObj->proto();
+ ObjectID parent = testObj->_data.parentID;
+ if (isWorld(parent) == false)
+ return false;
// Calculate X, Y coordinates of the sprite
TileToScreenCoords(testObj->getLocation(), drawPos);
Commit: ca6530a60186e03a1111ac4abbdf69e576a8d91c
https://github.com/scummvm/scummvm/commit/ca6530a60186e03a1111ac4abbdf69e576a8d91c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:20+02:00
Commit Message:
SAGA2: Improve address methods debug output
Changed paths:
engines/saga2/interp.cpp
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index b0657025d0..ee4fd48ef9 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -78,6 +78,25 @@ void script_error(char *msg) {
WriteStatusF(0, msg);
}
+static Common::String seg2str(int16 segment) {
+ switch (segment) {
+ case builtinTypeObject:
+ return "GameObject";
+
+ case builtinTypeTAG:
+ return "TAG";
+
+ case builtinAbstract:
+ return Common::String::format("Abstract%d", segment);
+
+ case builtinTypeMission:
+ return "Mission";
+
+ default:
+ return Common::String::format("%d", segment);
+ }
+}
+
//-----------------------------------------------------------------------
// Return the address of a builtin object, such as an Actor or a TAG,
// given a segment number and an index
@@ -226,7 +245,7 @@ uint8 *byteAddress(Thread *th, uint8 **pcPtr) {
case addr_far:
IMMED_WORD(seg);
IMMED_WORD(offset);
- debugC(3, kDebugScripts, "byteAddress: far[%d:%d] = %d", seg, offset, *segmentAddress(seg, offset));
+ debugC(3, kDebugScripts, "byteAddress: far[%s:%d] = %d", seg2str(seg).c_str(), offset, *segmentAddress(seg, offset));
*pcPtr = pc;
return segmentAddress(seg, offset);
@@ -235,7 +254,7 @@ uint8 *byteAddress(Thread *th, uint8 **pcPtr) {
IMMED_WORD(offset);
addr = segmentArrayAddress(seg, offset);
IMMED_WORD(offset2);
- debugC(3, kDebugScripts, "byteAddress: array[%d:%d:%d] = %d", seg, offset, offset2, addr[offset2]);
+ debugC(3, kDebugScripts, "byteAddress: array[%s:%d:%d] = %d", seg2str(seg).c_str(), offset, offset2, addr[offset2]);
*pcPtr = pc;
return addr + offset2;
@@ -256,10 +275,10 @@ uint8 *byteAddress(Thread *th, uint8 **pcPtr) {
arg = (uint16 *)(th->stackBase + th->framePtr + 8);
*pcPtr = pc;
if (arg[0] == dataSegIndex) {
- debugC(3, kDebugScripts, "byteAddress: thisD[%d] = %d", offset, dataSegment[arg[1] + offset]);
+ debugC(3, kDebugScripts, "byteAddress: thisD[%d:%d] = %d", arg[1], offset, dataSegment[arg[1] + offset]);
return &dataSegment[arg[1] + offset];
}
- debugC(3, kDebugScripts, "byteAddress: thisS[%d] = %d", offset, *(segmentArrayAddress(arg[0], arg[1]) + offset));
+ debugC(3, kDebugScripts, "byteAddress: thisS[%s:%d:%d] = %d", seg2str(arg[0]).c_str(), arg[1], offset, *(segmentArrayAddress(arg[0], arg[1]) + offset));
return segmentArrayAddress(arg[0], arg[1]) + offset;
case addr_deref:
@@ -276,7 +295,7 @@ uint8 *byteAddress(Thread *th, uint8 **pcPtr) {
// within the object.
IMMED_WORD(seg);
IMMED_WORD(offset);
- debugC(3, kDebugScripts, "byteAddress: deref[%d:%d:%d] = %d", seg, index, offset, *(segmentAddress(seg, index) + offset));
+ debugC(3, kDebugScripts, "byteAddress: deref[%s:%d:%d] = %d", seg2str(seg).c_str(), index, offset, *(segmentAddress(seg, index) + offset));
*pcPtr = pc;
// Compute address of object
@@ -305,14 +324,14 @@ uint8 *objectAddress(
IMMED_WORD(index);
seg = dataSegIndex;
addr = &dataSegment[index];
- debugC(3, kDebugScripts, "data [%d] (%p)", index, addr);
+ debugC(3, kDebugScripts, "objectAddress: data[%s:%d] = %d", seg2str(seg).c_str(), index, *addr);
break;
case addr_far:
IMMED_WORD(seg);
IMMED_WORD(index);
addr = segmentAddress(seg, index);
- debugC(3, kDebugScripts, "far [%d, %d] (%p)", seg, index, addr);
+ debugC(3, kDebugScripts, "objectAddress: far[%s:%d] = %d", seg2str(seg).c_str(), index, *addr);
break;
case addr_array:
@@ -320,7 +339,7 @@ uint8 *objectAddress(
IMMED_WORD(index);
IMMED_WORD(offset);
addr = segmentArrayAddress(seg, index) + offset;
- debugC(3, kDebugScripts, "array [%d, %d, %d] (%p)", seg, index, offset, addr);
+ debugC(3, kDebugScripts, "objectAddress: array[%s:%d:%d] = %d", seg2str(seg).c_str(), index, offset, *addr);
break;
case addr_this:
@@ -329,11 +348,11 @@ uint8 *objectAddress(
seg = arg[0];
index = arg[1];
if (seg == dataSegIndex) {
- debugC(3, kDebugScripts, "this (D) [%d, %d] (%p)", index, offset, &dataSegment[index + offset]);
+ debugC(3, kDebugScripts, "objectAddress: thisD[%d:%d] = %d", index, offset, dataSegment[index + offset]);
return &dataSegment[index + offset];
}
addr = segmentArrayAddress(seg, index) + offset;
- debugC(3, kDebugScripts, "this (S) [%d, %d, %d] (%p)", seg, index, offset, addr);
+ debugC(3, kDebugScripts, "objectAddress: thisS[%s:%d:%d] = %d", seg2str(seg).c_str(), index, offset, *addr);
break;
case addr_deref:
@@ -353,7 +372,7 @@ uint8 *objectAddress(
// Compute address of object
addr = segmentAddress(seg, index) + offset;
- debugC(3, kDebugScripts, "deref [%d, %d, %d] (%p)", seg, index, offset, addr);
+ debugC(3, kDebugScripts, "objectAddress: deref[%s:%d:%d] = %d", seg2str(seg).c_str(), index, offset, *addr);
break;
default:
@@ -378,12 +397,14 @@ uint8 *bitAddress(Thread *th, uint8 **pcPtr, int16 *mask) {
IMMED_WORD(offset);
*pcPtr = pc;
*mask = (1 << (offset & 7));
+ debugC(3, kDebugScripts, "bitAddress: data[%d] = %d", offset, (dataSegment[offset >> 3] & *mask) != 0);
return &dataSegment[(offset >> 3)];
case addr_near:
IMMED_WORD(offset);
*pcPtr = pc;
*mask = (1 << (offset & 7));
+ debugC(3, kDebugScripts, "bitAddress: near[%d] = %d", offset, (*(th->codeSeg + (offset >> 3)) & *mask) != 0);
return th->codeSeg + (offset >> 3);
case addr_far:
@@ -391,6 +412,7 @@ uint8 *bitAddress(Thread *th, uint8 **pcPtr, int16 *mask) {
IMMED_WORD(offset);
*pcPtr = pc;
*mask = (1 << (offset & 7));
+ debugC(3, kDebugScripts, "bitAddress: far[%s:%d] = %d", seg2str(seg).c_str(), offset, (*segmentAddress(seg, offset >> 3) & *mask) != 0);
return segmentAddress(seg, (offset >> 3));
case addr_array:
@@ -400,18 +422,21 @@ uint8 *bitAddress(Thread *th, uint8 **pcPtr, int16 *mask) {
IMMED_WORD(offset);
*pcPtr = pc;
*mask = (1 << (offset & 7));
+ debugC(3, kDebugScripts, "bitAddress: array[%s:%d:%d] = %d", seg2str(seg).c_str(), offset, offset, (addr[offset >> 3] & *mask) != 0);
return addr + (offset >> 3);
case addr_stack:
IMMED_WORD(offset);
*pcPtr = pc;
*mask = (1 << (offset & 7));
+ debugC(3, kDebugScripts, "bitAddress: stack[%d] = %d", offset, (*(th->stackBase + th->framePtr + (offset >>3)) & *mask) != 0);
return th->stackBase + th->framePtr + (offset >> 3);
case addr_thread:
IMMED_WORD(offset);
*pcPtr = pc;
*mask = (1 << (offset & 7));
+ debugC(3, kDebugScripts, "bitAddress: thread[%d] = %d", offset, (*((uint8 *)&th->threadArgs + (offset >> 3)) & *mask) != 0);
return (uint8 *)&th->threadArgs + (offset >> 3);
case addr_this:
Commit: e0a94761456b6a1d09b0c34c3f4adf9e538e6d27
https://github.com/scummvm/scummvm/commit/e0a94761456b6a1d09b0c34c3f4adf9e538e6d27
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:20+02:00
Commit Message:
SAGA2: Fix warning
Changed paths:
engines/saga2/saga2.h
diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h
index ac2ad626dc..12ddafdd79 100644
--- a/engines/saga2/saga2.h
+++ b/engines/saga2/saga2.h
@@ -33,7 +33,7 @@
namespace Video {
class SmackerDecoder;
-};
+}
namespace Saga2 {
Commit: b585f1bb03ace5895a459b82964ed6210e31070b
https://github.com/scummvm/scummvm/commit/b585f1bb03ace5895a459b82964ed6210e31070b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:20+02:00
Commit Message:
SAGA2: Fix copy/paste error in resource loading
Changed paths:
engines/saga2/tile.cpp
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 86aeaa3944..62858f0ea4 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -1488,7 +1488,7 @@ ActiveItem::ActiveItem(ActiveItemList *parent, int ind, Common::SeekableReadStre
_data.instance.groupID = stream->readUint16LE();
_data.instance.u = stream->readSint16LE();
_data.instance.v = stream->readSint16LE();
- _data.instance.v = stream->readSint16LE();
+ _data.instance.h = stream->readSint16LE();
_data.instance.stateIndex = stream->readUint16LE();
_data.instance.scriptFlags = stream->readUint16LE();
_data.instance.targetU = stream->readUint16LE();
Commit: ffa1c98eea06b2c7fa04120ea60656b42938380b
https://github.com/scummvm/scummvm/commit/ffa1c98eea06b2c7fa04120ea60656b42938380b
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:20+02:00
Commit Message:
SAGA2: Increase level of noisy warning
Changed paths:
engines/saga2/objproto.cpp
diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp
index 49f906533c..7798c9c4c7 100644
--- a/engines/saga2/objproto.cpp
+++ b/engines/saga2/objproto.cpp
@@ -972,7 +972,7 @@ void ProtoObj::doBackgroundUpdate(GameObject *obj) {
// XXX: Temporary crash prevention
// We should properly solve the problem
- warning("XXX: doBackgroundUpdate");
+ debug(3, "XXX: doBackgroundUpdate");
if (location.u == -1 && location.v == -1)
return;
Commit: efda4028a9c77b85e92f07fbebd8bb7cd2afd28d
https://github.com/scummvm/scummvm/commit/efda4028a9c77b85e92f07fbebd8bb7cd2afd28d
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:20+02:00
Commit Message:
SAGA2: Fix some warnings
Changed paths:
engines/saga2/fta.h
engines/saga2/oncall.h
engines/saga2/tile.cpp
diff --git a/engines/saga2/fta.h b/engines/saga2/fta.h
index 549047e16a..a9c8c64f2c 100644
--- a/engines/saga2/fta.h
+++ b/engines/saga2/fta.h
@@ -43,7 +43,7 @@ class hResource;
// For GameMode Stack
const int Max_Modes = 8, //Max Game Mode Objects
- End_List = NULL; //Variable To Indicate End Of Arg List
+ End_List = 0; //Variable To Indicate End Of Arg List
// Width and height of full screen
const int screenWidth = 640,
diff --git a/engines/saga2/oncall.h b/engines/saga2/oncall.h
index bfd8c5c74d..83c36c5a3f 100644
--- a/engines/saga2/oncall.h
+++ b/engines/saga2/oncall.h
@@ -47,7 +47,7 @@ public:
}
void flush() {
- for (int i = 0; i < _handles.size(); ++i) {
+ for (unsigned int i = 0; i < _handles.size(); ++i) {
if (_handles[i]) {
free(_handles[i]);
_handles[i] = nullptr;
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 62858f0ea4..293041d411 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -61,7 +61,6 @@ void initBackPanel();
* ===================================================================== */
const uint32 tileTerrainID = MKTAG('T', 'E', 'R', 0),
- tileImageID = MKTAG('T', 'I', 'L', 0),
platformID = MKTAG('P', 'L', 'T', 0),
metaID = MKTAG('M', 'E', 'T', 0),
mapID = MKTAG('M', 'A', 'P', 0),
@@ -74,16 +73,12 @@ const uint32 tileTerrainID = MKTAG('T', 'E', 'R', 0),
// Scrolling Speed constants
const int slowScrollSpeed = 6,
- fastScrollSpeed = 16,
snapScrollSpeed = maxint32,
slowThreshhold = 16,
// fastThreshhold = 100,
fastThreshhold = 16,
snapThreshhold = 400;
-const int32 maxOffset = 2048 * 1024;
-
-
const TilePoint Nowhere((int16)minint16, (int16)minint16, (int16)minint16);
const MetaTileID NoMetaTile(nullID, nullID);
@@ -485,8 +480,6 @@ void ActiveItem::playTAGNoise(ActiveItem *ai, int16 tagNoiseID) {
// use() function for ActiveItem group
bool ActiveItem::use(ActiveItem *ins, ObjectID enactor) {
- Actor *actor = (Actor *)GameObject::objectAddress(enactor);
- TilePoint actorLoc = actor->getLocation() >> kTileUVShift;
int16 mapNum = getMapNum();
uint16 state = ins->getInstanceState(mapNum);
scriptCallFrame scf;
@@ -550,7 +543,6 @@ bool ActiveItem::trigger(ActiveItem *ins, ObjectID enactor, ObjectID objID) {
GameObject *obj = GameObject::objectAddress(objID);
GameWorld *world = (GameWorld *)GameObject::objectAddress(
mapList[getMapNum()].worldID);
- ProtoObj *proto = obj->proto();
TileRegion instanceRegion;
ActiveItemID instanceID = ins->thisID();
scriptCallFrame scf;
@@ -721,9 +713,6 @@ bool ActiveItem::release(ActiveItem *ins, ObjectID enactor, ObjectID objID) {
// acceptLockToggle() function for ActiveItem group
bool ActiveItem::acceptLockToggle(ActiveItem *ins, ObjectID enactor, uint8 keyCode) {
- TilePoint actorLoc =
- GameObject::objectAddress(enactor)->getLocation() >>
- kTileUVShift;
scriptCallFrame scf;
if (ins->_data.scriptClassID != 0) {
@@ -1809,8 +1798,7 @@ void saveAutoMap(SaveFileConstructor &saveGame) {
//-----------------------------------------------------------------------
void loadAutoMap(SaveFileReader &saveGame) {
- int32 totalMapSize = 0,
- totalMapIndex = 0;
+ int32 totalMapIndex = 0;
int16 i;
uint8 *archiveBuffer;
@@ -2911,10 +2899,10 @@ void buildRipTables(void) {
// If rip table has a valid metatile, remove that meta tile's
// reference to its rip table
if (ripTableList[j].metaID != NoMetaTile) {
- MetaTile *mt = MetaTile::metaTileAddress(
+ MetaTile *rip_mt = MetaTile::metaTileAddress(
ripTableList[j].metaID);
- RipTableID &rt = mt->ripTableID(currentMapNum);
+ RipTableID &rt = rip_mt->ripTableID(currentMapNum);
// Assign -1 to the meta tile's rip table ID
if (RipTable::ripTableAddress(rt) == &ripTableList[j])
@@ -3673,9 +3661,8 @@ SurfaceType pointOnTile(TileInfo *ti,
// Compute the terrain hieght of the first point
pointH = ptHeight(subUVPoint, ti->attrs.cornerHeight);
- while (subUVPointRel >= 0 &&
- subUVPoint.u < 16 &&
- subUVPoint.v < 16) {
+ while (subUVPoint.u < 16 &&
+ subUVPoint.v < 16) {
if (subUVPointRel < pointH + (kSubTileDY * 2) / kSubTileSize) {
pickCoords = (tCoords << kTileUVShift);
pickCoords.u += subUVPoint.u;
@@ -3833,9 +3820,8 @@ SurfaceType pointOnTile(TileInfo *ti,
// Compute the terrain hieght of the first point
pointH = ptHeight((subTile << 2) + subUVPoint, ti->attrs.cornerHeight);
- while (subUVPointRel >= 0 &&
- subUVPoint.u < 4 &&
- subUVPoint.v < 4) {
+ while (subUVPoint.u < 4 &&
+ subUVPoint.v < 4) {
if (subUVPointRel < pointH + (kSubTileDY * 2) / kSubTileSize) {
pickCoords = (tCoords << kTileUVShift);
pickCoords.u += (subTile.u << kSubTileShift) + subUVPoint.u;
@@ -4449,7 +4435,7 @@ void loadTileCyclingStates(SaveFileReader &saveGame) {
initTileCyclingStates();
- assert(saveGame.getChunkSize() == sizeof(TileCycleArchive) * cycleCount);
+ assert(saveGame.getChunkSize() == (int)sizeof(TileCycleArchive) * cycleCount);
archiveBuffer = new TileCycleArchive[cycleCount]();
if (archiveBuffer == nullptr)
Commit: 1ab3ffa869af82a93fd9a197cf220abaef7a2252
https://github.com/scummvm/scummvm/commit/1ab3ffa869af82a93fd9a197cf220abaef7a2252
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:20+02:00
Commit Message:
SAGA2: Fix more warnings
Changed paths:
engines/saga2/objects.cpp
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 431a6ad0dc..0eeaa34818 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -58,7 +58,6 @@ APPFUNC(cmdControl);
const uint32 nameListID = MKTAG('N', 'A', 'M', 'E'),
objListID = MKTAG('O', 'B', 'J', 'E'),
- worldListID = MKTAG('W', 'R', 'L', 'D'),
objProtoID = MKTAG('P', 'R', 'O', 0),
actorProtoID = MKTAG('P', 'R', 'O', 1);
@@ -4218,16 +4217,16 @@ GameObject *objectCollision(GameObject *obj, GameWorld *world, const TilePoint &
obstacle != nullptr;
iter.next(&obstacle)) {
TilePoint tp = obstacle->getLocation();
- ProtoObj *proto = obstacle->proto();
+ ProtoObj *obstacleProto = obstacle->proto();
if (obstacle == obj) continue;
if (tp.z < volume.max.z
- && tp.z + proto->height > volume.min.z
- && tp.u - proto->crossSection < volume.max.u
- && tp.u + proto->crossSection > volume.min.u
- && tp.v - proto->crossSection < volume.max.v
- && tp.v + proto->crossSection > volume.min.v) {
+ && tp.z + obstacleProto->height > volume.min.z
+ && tp.u - obstacleProto->crossSection < volume.max.u
+ && tp.u + obstacleProto->crossSection > volume.min.u
+ && tp.v - obstacleProto->crossSection < volume.max.v
+ && tp.v + obstacleProto->crossSection > volume.min.v) {
// If the actor is dead, then it is not an obstacle.
if (isActor(obstacle) && ((Actor *)obstacle)->isDead()) continue;
Commit: 1776549073f11f42a542cdbd96cc3f7b8a86a519
https://github.com/scummvm/scummvm/commit/1776549073f11f42a542cdbd96cc3f7b8a86a519
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:21+02:00
Commit Message:
SAGA2: Properly read ActorAnimations
Changed paths:
engines/saga2/sprite.cpp
engines/saga2/sprite.h
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index 9ac3ebdb48..1a8545bc74 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -604,9 +604,34 @@ void ActorAppearance::loadSpriteBanks(int16 banksNeeded) {
}
}
-static void readActorAnimSet(hResContext *con, ActorAnimSet &ani) {
- ani.numAnimations = con->readU32LE();
- ani.poseOffset = con->readU32LE();
+ActorAnimation::ActorAnimation(Common::SeekableReadStream *stream) {
+ for (int i = 0; i < numPoseFacings; i++)
+ start[i] = stream->readUint16LE();
+
+ for (int i = 0; i < numPoseFacings; i++)
+ count[i] = stream->readUint16LE();
+
+ for (int i = 0; i < numPoseFacings; i++)
+ debugC(2, kDebugLoading, "anim%d: start: %d count: %d", i, start[i], count[i]);
+}
+
+ActorPose::ActorPose() {
+ flags = 0;
+
+ actorFrameIndex = actorFrameBank = leftObjectIndex = rightObjectIndex = 0;
+}
+
+
+ActorPose::ActorPose(Common::SeekableReadStream *stream) {
+ flags = stream->readUint16LE();
+
+ actorFrameIndex = stream->readByte();
+ actorFrameBank = stream->readByte();
+ leftObjectIndex = stream->readByte();
+ rightObjectIndex = stream->readByte();
+
+ leftObjectOffset.load(stream);
+ rightObjectOffset.load(stream);
}
static void readColorScheme(hResContext *con, ColorScheme &col) {
@@ -680,12 +705,24 @@ ActorAppearance *LoadActorAppearance(uint32 id, int16 banksNeeded) {
aa->spriteBanks[bank] = nullptr;
}
- if (aa->poseList)
- delete[] aa->poseList;
+ if (aa->poseList) {
+ for (uint i = 0; i < aa->poseList->numPoses; i++)
+ delete aa->poseList->poses[i];
+
+ free(aa->poseList->poses);
+
+ for (uint i = 0; i < aa->poseList->numAnimations; i++)
+ delete aa->poseList->animations[i];
+
+ free(aa->poseList->animations);
+
+ delete aa->poseList;
+ }
aa->poseList = nullptr;
- if (aa->schemeList)
+ if (aa->schemeList) {
delete aa->schemeList;
+ }
aa->schemeList = nullptr;
// Set ID and use count
@@ -695,13 +732,36 @@ ActorAppearance *LoadActorAppearance(uint32 id, int16 banksNeeded) {
// Load in new frame lists and sprite banks
aa->loadSpriteBanks(banksNeeded);
- if (poseRes->seek(id) == 0) {
+ Common::SeekableReadStream *poseStream = loadResourceToStream(poseRes, id, "pose list");
+
+ if (poseStream == nullptr) {
warning("LoadActorAppearance: Could not load pose list");
} else {
- poseListSize = poseRes->size(id) / actorAnimSetSize;
- aa->poseList = new ActorAnimSet[poseListSize];
- for (int i = 0; i < poseListSize; ++i)
- readActorAnimSet(poseRes, aa->poseList[i]);
+ ActorAnimSet *as = new ActorAnimSet;
+ aa->poseList = as;
+ as->numAnimations = poseStream->readUint32LE();
+ as->poseOffset = poseStream->readUint32LE();
+
+ // compute number of ActorPoses
+ uint32 poseBytes = poseStream->size() - as->poseOffset;
+
+ debugC(1, kDebugLoading, "Pose List: bytes: %d numAnimations: %d poseOffset: %d calculated offset: %d numPoses: %d",
+ poseStream->size(), as->numAnimations, as->poseOffset, 8 + as->numAnimations * 32, poseBytes / 14);
+
+ if (poseBytes % 14 != 0)
+ warning("Incorrect number of poses, %d bytes more", poseBytes % 14);
+
+ as->numPoses = poseBytes / 14;
+
+ as->animations = (ActorAnimation **)malloc(as->numAnimations * sizeof(ActorAnimation));
+
+ for (uint i = 0; i < as->numAnimations; i++)
+ as->animations[i] = new ActorAnimation(poseStream);
+
+ as->poses = (ActorPose **)malloc(as->numPoses * sizeof(ActorPose));
+
+ for (uint i = 0; i < as->numPoses; i++)
+ as->poses[i] = new ActorPose(poseStream);
}
if (schemeRes->seek(id) == 0) {
@@ -717,14 +777,7 @@ ActorAppearance *LoadActorAppearance(uint32 id, int16 banksNeeded) {
}
void ReleaseActorAppearance(ActorAppearance *aa) {
- if (--aa->useCount == 0) {
- }
-
-#ifndef WINKLUDGE // jeffkludge -- causes crash
-#if DEBUG
- WriteStatusF(2, "Release");
-#endif
-#endif
+ aa->useCount--;
}
/* ===================================================================== *
diff --git a/engines/saga2/sprite.h b/engines/saga2/sprite.h
index 554b02069e..d18fd653d1 100644
--- a/engines/saga2/sprite.h
+++ b/engines/saga2/sprite.h
@@ -135,6 +135,9 @@ struct ActorPose {
rightObjectOffset; // offset of right-hand obj.
// 14 bytes
+
+ ActorPose();
+ ActorPose(Common::SeekableReadStream *stream);
};
// A choreographed sequence of frames
@@ -145,13 +148,22 @@ struct ActorAnimation {
// table of poses for that sequence, and the number of poses
// in the sequence.
- uint16 start[numPoseFacings],
- count[numPoseFacings];
+ uint16 start[numPoseFacings];
+ uint16 count[numPoseFacings];
+
+ ActorAnimation(Common::SeekableReadStream *stream);
+
+ // 32 bytes
};
struct ActorAnimSet {
- uint32 numAnimations, // number of animations
- poseOffset; // offset to poses table
+ uint32 numAnimations; // number of animations
+ uint32 poseOffset; // offset to poses table
+
+ ActorAnimation **animations;
+ ActorPose **poses;
+
+ uint32 numPoses;
};
/* ===================================================================== *
@@ -258,7 +270,7 @@ enum spriteBankBits {
// There is an LRU cache of these structures maintained by
// the sprite coordinator.
-class ActorAppearance : public DNode {
+class ActorAppearance {
public:
int16 useCount; // how many actors using this
uint32 id;
@@ -266,14 +278,8 @@ public:
ActorAnimSet *poseList; // list of action sequences
ColorSchemeList *schemeList; // color remapping info
- // Table of sprite sets. Each entry in the table
- // represents a different "bank" of sprites
- // REM: How do we determine what frames are NEEDED in the
- // near future?
-
SpriteSet *spriteBanks[sprBankCount];
-// Member functions:
void loadSpriteBanks(int16 banksNeeded);
// Determine if this bank is loaded
@@ -290,21 +296,27 @@ public:
// FIXME: Pointer Arithmetic
ActorAnimation *animation(int num) {
- warning("STUB: ActorAppearance::animation: Pointer Arithmetics");
if (poseList)
- return (ActorAnimation *)(poseList + 1) + num;
+ return poseList->animations[num];
return nullptr;
}
ActorPose *pose(ActorAnimation *anim, int dir, int num) {
- warning("STUB: ActorAppearance::pose: Pointer Arithmetics");
if (poseList == nullptr)
return nullptr;
- if (num < 0 || num >= anim->count[dir]) num = 0;
+ if (num < 0 || num >= anim->count[dir])
+ num = 0;
+
num += anim->start[dir];
- return (ActorPose *)((uint8 *)poseList + poseList->poseOffset) + num;
+
+ if (num >= poseList->numPoses) {
+ warning("ActorPose::pose(), pose number is too high, %d >= %d", num, poseList->numPoses);
+ return nullptr;
+ }
+
+ return poseList->poses[num];
}
};
Commit: e1869af2c4276b41cd5d44b7f7a1e9f305008035
https://github.com/scummvm/scummvm/commit/e1869af2c4276b41cd5d44b7f7a1e9f305008035
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:21+02:00
Commit Message:
SAGA2: Cleanup and more sanity checks for resource loading
Changed paths:
engines/saga2/sprite.cpp
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index 1a8545bc74..3b443bfa35 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -664,8 +664,6 @@ ColorSchemeList::ColorSchemeList(int count, Common::SeekableReadStream *stream)
ActorAppearance *LoadActorAppearance(uint32 id, int16 banksNeeded) {
int16 bank;
- const int actorAnimSetSize = 8;
- const int colorSchemeSize = 44;
int poseListSize;
int schemeListSize;
Common::SeekableReadStream *stream;
@@ -744,14 +742,15 @@ ActorAppearance *LoadActorAppearance(uint32 id, int16 banksNeeded) {
// compute number of ActorPoses
uint32 poseBytes = poseStream->size() - as->poseOffset;
+ const int poseSize = 14;
debugC(1, kDebugLoading, "Pose List: bytes: %d numAnimations: %d poseOffset: %d calculated offset: %d numPoses: %d",
- poseStream->size(), as->numAnimations, as->poseOffset, 8 + as->numAnimations * 32, poseBytes / 14);
+ poseStream->size(), as->numAnimations, as->poseOffset, 8 + as->numAnimations * 32, poseBytes / poseSize);
- if (poseBytes % 14 != 0)
- warning("Incorrect number of poses, %d bytes more", poseBytes % 14);
+ if (poseBytes % poseSize != 0)
+ warning("Incorrect number of poses, %d bytes more", poseBytes % poseSize);
- as->numPoses = poseBytes / 14;
+ as->numPoses = poseBytes / poseSize;
as->animations = (ActorAnimation **)malloc(as->numAnimations * sizeof(ActorAnimation));
@@ -762,14 +761,22 @@ ActorAppearance *LoadActorAppearance(uint32 id, int16 banksNeeded) {
for (uint i = 0; i < as->numPoses; i++)
as->poses[i] = new ActorPose(poseStream);
+
+ delete poseStream;
}
if (schemeRes->seek(id) == 0) {
warning("LoadActorAppearance: Could not load scheme list");
} else {
+ const int colorSchemeSize = 44;
+
+ if (schemeRes->size(id) % colorSchemeSize != 0)
+ warning("Incorrect number of colorschemes, %d bytes more", schemeRes->size(id) % colorSchemeSize);
+
schemeListSize = schemeRes->size(id) / colorSchemeSize;
stream = loadResourceToStream(schemeRes, id, "scheme list");
aa->schemeList = new ColorSchemeList(schemeListSize, stream);
+
delete stream;
}
Commit: 9fa23205d647b58bd1cc475fb7d1f380cc724ffe
https://github.com/scummvm/scummvm/commit/9fa23205d647b58bd1cc475fb7d1f380cc724ffe
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:21+02:00
Commit Message:
SAGA2: Added more sanity checking
Changed paths:
engines/saga2/dispnode.cpp
engines/saga2/sprite.h
diff --git a/engines/saga2/dispnode.cpp b/engines/saga2/dispnode.cpp
index 28849c3da4..879f8139bb 100644
--- a/engines/saga2/dispnode.cpp
+++ b/engines/saga2/dispnode.cpp
@@ -580,7 +580,7 @@ void DisplayNode::drawObject(void) {
pose = aa->pose(anim, a->currentFacing, a->currentPose);
if (anim == nullptr)
- return
+ return;
assert(anim->start[0] >= 0);
assert(anim->start[0] < 10000);
diff --git a/engines/saga2/sprite.h b/engines/saga2/sprite.h
index d18fd653d1..bcd3ef9124 100644
--- a/engines/saga2/sprite.h
+++ b/engines/saga2/sprite.h
@@ -296,6 +296,14 @@ public:
// FIXME: Pointer Arithmetic
ActorAnimation *animation(int num) {
+ if (poseList == nullptr)
+ return nullptr;
+
+ if (num >= poseList->numAnimations) {
+ warning("ActorPose:animation(), animation number is too high, %d >= %d", num, poseList->numAnimations);
+ return nullptr;
+ }
+
if (poseList)
return poseList->animations[num];
Commit: 9b76670b4589cd4df4ae36c61f87bd580c9c94e4
https://github.com/scummvm/scummvm/commit/9b76670b4589cd4df4ae36c61f87bd580c9c94e4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:21+02:00
Commit Message:
SAGA2: Made sprite unpacking more robust
Changed paths:
engines/saga2/blitters.cpp
engines/saga2/blitters.h
engines/saga2/sprite.cpp
engines/saga2/sprite.h
diff --git a/engines/saga2/blitters.cpp b/engines/saga2/blitters.cpp
index 53ee29b37c..c8ce1d163f 100644
--- a/engines/saga2/blitters.cpp
+++ b/engines/saga2/blitters.cpp
@@ -25,6 +25,7 @@
*/
#include "common/debug.h"
+#include "common/memstream.h"
#include "graphics/surface.h"
#include "saga2/std.h"
@@ -104,12 +105,25 @@ void unpackImage(gPixelMap *map, int32 width, int32 rowCount, int8 *srcData) {
unpackImage(*map, (int16)width, (int16)rowCount, srcData);
}
-void unpackSprite(gPixelMap *map, uint8 *sprData) {
+void unpackSprite(gPixelMap *map, uint8 *sprData, uint32 dataSize) {
byte *dst = map->data;
int bytes = map->size.x * map->size.y;
+ if (!sprData) {
+ warning("unpackSprite(): empty sprData");
+ return;
+ }
+
+ Common::MemoryReadStream stream(sprData, dataSize);
+
while (true) {
- byte trans = *sprData++;
+ byte trans = stream.readByte();
+
+ if (stream.eos()) {
+ warning("unpackSprite: premature end of data");
+ return;
+ }
+
if (bytes < trans) {
warning("unpackSprite: too many trans %d < %d", bytes, trans);
trans = bytes;
@@ -122,15 +136,25 @@ void unpackSprite(gPixelMap *map, uint8 *sprData) {
if (bytes < 0)
break;
- byte fill = *sprData++;
+ byte fill = stream.readByte();
+
+ if (stream.eos()) {
+ warning("unpackSprite: premature end of data");
+ return;
+ }
if (bytes < fill) {
warning("unpackSprite: too many bytes %d < %d", bytes, fill);
fill = bytes;
}
- memcpy(dst, sprData, fill);
+ if (stream.read(dst, fill) != fill) {
+ warning("unpackSprite: premature end of data");
+ return;
+ }
dst += fill;
bytes -= fill;
- sprData += fill;
+
+ if (bytes <= 0)
+ break;
}
}
diff --git a/engines/saga2/blitters.h b/engines/saga2/blitters.h
index 955ab1984c..a6809ea883 100644
--- a/engines/saga2/blitters.h
+++ b/engines/saga2/blitters.h
@@ -42,7 +42,7 @@ void _HLine(uint8 *dstPtr, uint32 width, uint32 color);
void unpackImage(gPixelMap *map, int32 width, int32 rowCount, int8 *srcData);
void unpackImage(gPixelMap &map, int16 width, int16 rowCount, int8 *srcData);
-void unpackSprite(gPixelMap *map, uint8 *sprData);
+void unpackSprite(gPixelMap *map, uint8 *sprData, uint32 dataSize);
void compositePixels(gPixelMap *compMap, gPixelMap *sprMap, int32 xpos, int32 ypos, uint8 *lookup);
void compositePixelsRvs(gPixelMap *compMap, gPixelMap *sprMap, int32 xpos, int32 ypos, uint8 *lookup);
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index 3b443bfa35..8100599405 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -44,26 +44,6 @@ const uint32 spriteGroupID = MKTAG('S', 'P', 'R', 'I'),
weaponSpriteBaseID = MKTAG('W', 'P', 'N', 0),
missileSpriteID = MKTAG('M', 'I', 'S', 'S');
-/* ===================================================================== *
- Prototypes
- * ===================================================================== */
-
-#ifndef FTAASM_H
-extern void unpackSprite(gPixelMap *map, uint8 *sprData);
-extern void compositePixels(
- gPixelMap *compMap,
- gPixelMap *sprMap,
- int32 xpos,
- int32 ypos,
- uint8 *lookup);
-extern void compositePixelsRvs(
- gPixelMap *compMap,
- gPixelMap *sprMap,
- int32 xpos,
- int32 ypos,
- uint8 *lookup);
-#endif
-
extern uint16 rippedRoofID;
extern void drawTileMask(
const Point16 &sPos,
@@ -250,7 +230,7 @@ void DrawCompositeMaskedSprite(
// Unpack the sprite into the temp map
- unpackSprite(&sprMap, sp->_data);
+ unpackSprite(&sprMap, sp->_data, sp->_dataSize);
// Blit the temp map onto the composite map
@@ -361,7 +341,7 @@ void DrawSprite(
sprMap.data = (uint8 *)getQuickMem(sprMap.bytes());
// Unpack the sprite into the temp map
- unpackSprite(&sprMap, sp->_data);
+ unpackSprite(&sprMap, sp->_data, sp->_dataSize);
// Blit to the port
port.setMode(drawModeMatte);
@@ -391,7 +371,7 @@ void DrawColorMappedSprite(
sprReMap.data = (uint8 *)getQuickMem(sprReMap.bytes());
// Unpack the sprite into the temp map
- unpackSprite(&sprMap, sp->_data);
+ unpackSprite(&sprMap, sp->_data, sp->_dataSize);
memset(sprReMap.data, 0, sprReMap.bytes());
@@ -429,7 +409,7 @@ void ExpandColorMappedSprite(
sprMap.data = (uint8 *)getQuickMem(sprMap.bytes());
// Unpack the sprite into the temp map
- unpackSprite(&sprMap, sp->_data);
+ unpackSprite(&sprMap, sp->_data, sp->_dataSize);
// remap the sprite to the color table given
compositePixels(
@@ -458,7 +438,7 @@ uint8 GetSpritePixel(
sprMap.data = (uint8 *)getQuickMem(sprMap.bytes());
// Unpack the sprite into the temp map
- unpackSprite(&sprMap, sp->_data);
+ unpackSprite(&sprMap, sp->_data, sp->_dataSize);
// Map the coords to the bitmap and return the pixel
if (flipped) {
@@ -513,7 +493,7 @@ uint16 visiblePixelsInSprite(
sprMap.size = sp->size;
sprMap.data = (uint8 *)getQuickMem(sprMap.bytes());
- unpackSprite(&sprMap, sp->_data);
+ unpackSprite(&sprMap, sp->_data, sp->_dataSize);
org.x = drawPos.x - xMin;
org.y = drawPos.y - yMin;
@@ -795,9 +775,9 @@ Sprite::Sprite(Common::SeekableReadStream *stream) {
size.load(stream);
offset.load(stream);
- int data_size = size.x * size.y;
- _data = (byte *)malloc(data_size * sizeof(byte));
- stream->read(_data, data_size);
+ _dataSize = size.x * size.y;
+ _data = (byte *)malloc(_dataSize);
+ stream->read(_data, _dataSize);
}
Sprite::~Sprite() {
diff --git a/engines/saga2/sprite.h b/engines/saga2/sprite.h
index bcd3ef9124..a282915430 100644
--- a/engines/saga2/sprite.h
+++ b/engines/saga2/sprite.h
@@ -50,6 +50,7 @@ struct Sprite {
Extent16 size; // size of sprite
Point16 offset; // sprite origin point
byte *_data;
+ uint32 _dataSize;
Sprite(Common::SeekableReadStream *stream);
~Sprite();
Commit: 0bfaddc55b470a0abe7f5f16a6204ea2c4eb30a4
https://github.com/scummvm/scummvm/commit/0bfaddc55b470a0abe7f5f16a6204ea2c4eb30a4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:21+02:00
Commit Message:
SAGA2: Cleanip includes in sprite.h
Changed paths:
engines/saga2/band.cpp
engines/saga2/motion.h
engines/saga2/sensor.h
engines/saga2/speech.h
engines/saga2/sprite.h
diff --git a/engines/saga2/band.cpp b/engines/saga2/band.cpp
index f8a3df3c11..7d9d7c2da6 100644
--- a/engines/saga2/band.cpp
+++ b/engines/saga2/band.cpp
@@ -30,6 +30,8 @@
#include "saga2/actor.h"
#include "saga2/band.h"
#include "saga2/savefile.h"
+#include "saga2/dlist.h"
+#include "saga2/rmem.h"
namespace Saga2 {
diff --git a/engines/saga2/motion.h b/engines/saga2/motion.h
index 2fcbebd1e7..65ab1dd70e 100644
--- a/engines/saga2/motion.h
+++ b/engines/saga2/motion.h
@@ -28,6 +28,7 @@
#define SAGA2_MOTION_H
#include "saga2/actor.h"
+#include "saga2/dlist.h"
namespace Saga2 {
diff --git a/engines/saga2/sensor.h b/engines/saga2/sensor.h
index e27f3631a0..4c64a24b14 100644
--- a/engines/saga2/sensor.h
+++ b/engines/saga2/sensor.h
@@ -27,6 +27,8 @@
#ifndef SAGA2_SENSOR_H
#define SAGA2_SENSOR_H
+#include "saga2/dlist.h"
+
namespace Saga2 {
const uint32 nonActorSenseFlags = actorSeeInvis;
diff --git a/engines/saga2/speech.h b/engines/saga2/speech.h
index ac7dd43eaa..bca3b5f38f 100644
--- a/engines/saga2/speech.h
+++ b/engines/saga2/speech.h
@@ -28,6 +28,7 @@
#define SAGA2_SPEECH_H
#include "saga2/objects.h"
+#include "saga2/dlist.h"
namespace Saga2 {
diff --git a/engines/saga2/sprite.h b/engines/saga2/sprite.h
index a282915430..8845f31157 100644
--- a/engines/saga2/sprite.h
+++ b/engines/saga2/sprite.h
@@ -28,8 +28,6 @@
#define SAGA2_SPRITE_H
#include "saga2/rect.h"
-#include "saga2/dlist.h"
-#include "saga2/rmem.h"
namespace Saga2 {
Commit: 91882aca4e61b18a97b93ac19bcb3ea6d1576efd
https://github.com/scummvm/scummvm/commit/91882aca4e61b18a97b93ac19bcb3ea6d1576efd
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:21+02:00
Commit Message:
SAGA2: Fix platform fetching
Changed paths:
engines/saga2/tile.cpp
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 293041d411..76ed793e37 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -2314,6 +2314,7 @@ static void readPlatform(hResContext *con, Platform &plt) {
}
Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
+ const int cacheFlag = 0x8000;
uint16 plIndex = _stack[layer];
PlatformCacheEntry *pce;
@@ -2322,44 +2323,63 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
if (plIndex == nullID) {
return nullptr;
- }
+ } else if (plIndex & cacheFlag) {
+ plIndex &= ~cacheFlag;
+
+ assert(plIndex < platformCacheSize);
+
+ // Get the address of the pce from the cache
+ pce = &platformCache[plIndex];
- debugC(2, kDebugLoading, "Fetching platform (%d,%d)", mapNum, layer);
-
- // Since the platform is not in the cache, we need to
- // dump something from the cache. Dump the one that
- // was least recently used.
- // Get head of LRU chain.
- int cacheIndex = platformLRU.front();
- platformLRU.pop_front();
- platformLRU.push_back(cacheIndex);
-
- pce = &platformCache[cacheIndex];
-
- // Compute the layer of this entry in the cache
- assert(cacheIndex < platformCacheSize);
- assert(cacheIndex >= 0);
-
- // Initialize the cache entry to the new platform data.
- pce->platformNum = plIndex;
- pce->layerNum = layer;
- pce->metaID = thisID(mapNum);
- _stack[layer] = (cacheIndex);
-
- assert(plIndex >= 0);
- assert(plIndex * sizeof(Platform) < tileRes->size(platformID + mapNum));
- debugC(3, kDebugLoading, "- plIndex: %d", plIndex);
-
- // Now, load the actual metatile data...
- if (tileRes->seek(platformID + mapNum)) {
- if (tileRes->skip(plIndex * sizeof(Platform))) {
- readPlatform(tileRes, pce->pl);
- return &pce->pl;
+ assert(pce->platformNum >= 0);
+ assert(pce->metaID != NoMetaTile);
+ assert(pce->metaID == thisID(mapNum));
+
+ // Move to the end of the LRU
+ platformLRU.push_back(plIndex);
+
+ // return the address of the platform
+ return &pce->pl;
+ } else {
+ debugC(2, kDebugLoading, "Fetching platform (%d,%d)", mapNum, layer);
+ if (mapNum == 0 && layer == 6)
+ debug("");
+
+ // Since the platform is not in the cache, we need to
+ // dump something from the cache. Dump the one that
+ // was least recently used.
+ // Get head of LRU chain.
+ int cacheIndex = platformLRU.front();
+ platformLRU.pop_front();
+ platformLRU.push_back(cacheIndex);
+
+ pce = &platformCache[cacheIndex];
+
+ // Compute the layer of this entry in the cache
+ assert(cacheIndex < platformCacheSize);
+ assert(cacheIndex >= 0);
+
+ // Initialize the cache entry to the new platform data.
+ pce->platformNum = plIndex;
+ pce->layerNum = layer;
+ pce->metaID = thisID(mapNum);
+ _stack[layer] = (cacheIndex | cacheFlag);
+
+ assert(plIndex >= 0);
+ assert(plIndex * sizeof(Platform) < tileRes->size(platformID + mapNum));
+ debugC(3, kDebugLoading, "- plIndex: %d", plIndex);
+
+ // Now, load the actual metatile data...
+ if (tileRes->seek(platformID + mapNum)) {
+ if (tileRes->skip(plIndex * sizeof(Platform))) {
+ readPlatform(tileRes, pce->pl);
+ return &pce->pl;
+ }
}
- }
- error("Unable to read Platform %d of map %d", plIndex, mapNum);
- return nullptr;
+ error("Unable to read Platform %d of map %d", plIndex, mapNum);
+ return nullptr;
+ }
}
//-----------------------------------------------------------------------
Commit: 12535d74bcf5ef094182ce02deee4624f6542bcd
https://github.com/scummvm/scummvm/commit/12535d74bcf5ef094182ce02deee4624f6542bcd
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:21+02:00
Commit Message:
SAGA2: Add fallback for invalid sector access
Changed paths:
engines/saga2/objects.h
engines/saga2/objproto.cpp
diff --git a/engines/saga2/objects.h b/engines/saga2/objects.h
index fb8dfac90d..d14b09cbfc 100644
--- a/engines/saga2/objects.h
+++ b/engines/saga2/objects.h
@@ -794,6 +794,12 @@ public:
void cleanup(void);
Sector *getSector(int16 u, int16 v) {
+ if (v * sectorArraySize + u >= sectorArraySize * sectorArraySize ||
+ v * sectorArraySize + u < 0) {
+ warning("Sector::getSector: Invalid sector: (%d, %d)", u, v);
+ return nullptr;
+ }
+
return &(sectorArray)[v * sectorArraySize + u];
}
diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp
index 7798c9c4c7..1bcb634b4e 100644
--- a/engines/saga2/objproto.cpp
+++ b/engines/saga2/objproto.cpp
@@ -969,18 +969,27 @@ uint8 ProtoObj::getDamageSound(const ObjectSoundFXs &) {
void ProtoObj::doBackgroundUpdate(GameObject *obj) {
TilePoint location = obj->getLocation();
GameWorld *w = obj->world();
+ int u = location.u >> kSectorShift;
+ int v = location.v >> kSectorShift;
// XXX: Temporary crash prevention
// We should properly solve the problem
debug(3, "XXX: doBackgroundUpdate");
- if (location.u == -1 && location.v == -1)
+
+ if (w == nullptr) {
+ obj->deactivate();
+ return;
+ }
+
+ Sector *sect = w->getSector(u, v);
+
+ if (sect == nullptr)
return;
- if (w == NULL
- || !w->getSector(
- location.u >> kSectorShift,
- location.v >> kSectorShift)->isActivated())
+ if (!sect->isActivated()) {
obj->deactivate();
+ return;
+ }
}
// ------------------------------------------------------------------------
Commit: cbff8ad38e8b8060bcef9e7fdc5d162fd4687da6
https://github.com/scummvm/scummvm/commit/cbff8ad38e8b8060bcef9e7fdc5d162fd4687da6
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:21+02:00
Commit Message:
SAGA2: Revert updateFrameCount
Changed paths:
engines/saga2/gamerate.h
diff --git a/engines/saga2/gamerate.h b/engines/saga2/gamerate.h
index 20d90b537e..9153d4b470 100644
--- a/engines/saga2/gamerate.h
+++ b/engines/saga2/gamerate.h
@@ -52,8 +52,8 @@ public:
~frameCounter() {}
virtual void updateFrameCount(void) {
- int32 frameTime = g_system->getMillis() - lastTime;
- lastTime = g_system->getMillis();
+ int32 frameTime = gameTime - lastTime;
+ lastTime = gameTime;
frames++;
instantFrameCount = frameTime ? ticksPerSecond / frameTime : 100;
}
Commit: 949904de3a74ca6b16ea4da4c49314aa5ffe66da
https://github.com/scummvm/scummvm/commit/949904de3a74ca6b16ea4da4c49314aa5ffe66da
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:22+02:00
Commit Message:
SAGA2: Stub updatePerfStats
Changed paths:
engines/saga2/main.cpp
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index cdc10c1904..82ac792118 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -908,6 +908,8 @@ int32 currentGamePerformance(void) {
void updatePerfStats(void) {
+ warning("STUB: updatePerfStats");
+#if 0
char bigmess[512];
frate.whatDoYouKnow(bigmess);
@@ -916,6 +918,7 @@ void updatePerfStats(void) {
(*ratemess[1])("Enginge: %s", bigmess);
irate.whatDoYouKnow(bigmess);
(*ratemess[2])("Message: %s", bigmess);
+#endif
}
void updateFrameCount(void) {
Commit: d19784fc9145bbcb401c6573410b9f2fe5baae0a
https://github.com/scummvm/scummvm/commit/d19784fc9145bbcb401c6573410b9f2fe5baae0a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:22+02:00
Commit Message:
SAGA2: Remove FPS counters
Changed paths:
engines/saga2/main.cpp
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 82ac792118..ea6de877c1 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -194,9 +194,6 @@ int16 OptionsDialog(bool disableSaveResume = false);
static void mainLoop(bool &cleanExit, int argc, char *argv[]);
void displayUpdate(void);
-//EO//#if DEBUG
-void updatePerfStats(void);
-//EO//#endif
void testTiles();
@@ -392,11 +389,6 @@ void displayUpdate(void) {
// Call the asynchronous path finder
debugC(1, kDebugEventLoop, "EventLoop: pathfinder update");
runPathFinder();
-
- // Hows the game running?
- debugC(1, kDebugEventLoop, "EventLoop: updating stats");
- updatePerfStats();
-
}
}
@@ -907,20 +899,6 @@ int32 currentGamePerformance(void) {
}
-void updatePerfStats(void) {
- warning("STUB: updatePerfStats");
-#if 0
- char bigmess[512];
-
- frate.whatDoYouKnow(bigmess);
- (*ratemess[0])("Display: %s", bigmess);
- lrate.whatDoYouKnow(bigmess);
- (*ratemess[1])("Enginge: %s", bigmess);
- irate.whatDoYouKnow(bigmess);
- (*ratemess[2])("Message: %s", bigmess);
-#endif
-}
-
void updateFrameCount(void) {
frate.updateFrameCount();
}
@@ -928,29 +906,6 @@ void updateFrameCount(void) {
int32 eloopsPerSecond = 0;
int32 framesPerSecond = 0;
-void updatePerfStats(void);
-void oldUpdatePerfStats(void) {
- static uint32 prevMem = 0;
- static float f, lastF = 0.0;
- static float l, lastL = 0.0;
- if (elapsed > 0) {
- f = ((float)frames * (float)TICKSPERSECOND) / (float)elapsed;
- f = f + lastF / 2;
- l = ((float)loops * (float)TICKSPERSECOND) / (float)elapsed;
- l = l + lastL / 2;
- if (elapsed > 10 * TICKSPERSECOND) {
- elapsed = 0;
- frames = 0;
- loops = 0;
- lastF = f;
- lastL = l;
- }
- }
- eloopsPerSecond = int(l);
- framesPerSecond = int(f);
-}
-
-
int32 gamePerformance(void) {
if (framesPerSecond < frameRate) {
return (100 * framesPerSecond) / frameRate;
Commit: b34ee434dd586b45e2e04f8f1fa606f40efc62d0
https://github.com/scummvm/scummvm/commit/b34ee434dd586b45e2e04f8f1fa606f40efc62d0
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:22+02:00
Commit Message:
SAGA2: Fix in-game timer frequency
Changed paths:
engines/saga2/timers.cpp
diff --git a/engines/saga2/timers.cpp b/engines/saga2/timers.cpp
index 727fdcd439..4f72bdd8ae 100644
--- a/engines/saga2/timers.cpp
+++ b/engines/saga2/timers.cpp
@@ -48,7 +48,7 @@ void timerCallback(void *refCon) {
void initTimer(void) {
gameTime = 0;
- g_vm->getTimerManager()->installTimerProc(&timerCallback, 1000 / 72, nullptr, "saga2");
+ g_vm->getTimerManager()->installTimerProc(&timerCallback, 1000000 / 72, nullptr, "saga2");
}
void pauseTimer() {
Commit: d6a2b6a8e020bce76de4e4f32c0905eb3a801f02
https://github.com/scummvm/scummvm/commit/d6a2b6a8e020bce76de4e4f32c0905eb3a801f02
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:22+02:00
Commit Message:
SAGA2: Rewrite Sensors to use Common::List
Changed paths:
engines/saga2/objects.cpp
engines/saga2/sensor.cpp
engines/saga2/sensor.h
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 0eeaa34818..9cb63eb4a2 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -1882,21 +1882,19 @@ bool GameObject::addSensor(Sensor *newSensor) {
// Search the list to see if there is already a sensor with same
// ID as the new sensor. If so, remove it and delete it.
- for (sensorInList = (Sensor *)sensorList->first();
- sensorInList != nullptr;
- sensorInList = (Sensor *)sensorInList->next()) {
- assert(sensorInList->getObject() == this);
+ for (Common::List<Sensor *>::iterator it = sensorList->_list.begin(); it != sensorList->_list.end(); ++it) {
+ assert((*it)->getObject() == this);
- if (newSensor->thisID() == sensorInList->thisID()) {
- sensorInList->remove();
- delete sensorInList;
+ if (newSensor->thisID() == (*it)->thisID()) {
+ sensorList->_list.remove(*it);
+ delete *it;
break;
}
}
// Put the new sensor into the list
- sensorList->addTail(*newSensor);
+ sensorList->_list.push_back(newSensor);
return true;
}
@@ -2017,19 +2015,19 @@ void GameObject::removeSensor(SensorID id) {
// Get this object's sensor list
if ((sensorList = fetchSensorList(this)) != nullptr) {
- Sensor *sensor;
-
// Search the sensor list for a sensor with the specified ID
- for (sensor = (Sensor *)sensorList->first();
- sensor != nullptr;
- sensor = (Sensor *)sensor->next()) {
- if (sensor->thisID() == id) {
+ for (Common::List<Sensor *>::iterator it = sensorList->_list.begin(); it != sensorList->_list.end(); ++it) {
+ if ((*it)->thisID() == id) {
// Remove the sensor, then delete it
- sensor->remove();
- delete sensor;
+ sensorList->_list.remove(*it);
+ deleteSensor(*it);
+ delete *it;
// If the list is now empty, delete it
- if (sensorList->empty()) delete sensorList;
+ if (sensorList->_list.empty()) {
+ deleteSensorList(sensorList);
+ delete sensorList;
+ }
break;
}
@@ -2045,22 +2043,13 @@ void GameObject::removeAllSensors(void) {
// Get this object's sensor list
if ((sensorList = fetchSensorList(this)) != nullptr) {
- Sensor *sensor,
- *nextSensor;
-
// Iterate through the sensors
- for (sensor = (Sensor *)sensorList->first();
- sensor != nullptr;
- sensor = nextSensor) {
- // Save the pointer to the next sensor
- nextSensor = (Sensor *)sensor->next();
-
- // Remove the sensor, then delete it
- sensor->remove();
- delete sensor;
+ for (Common::List<Sensor *>::iterator it = sensorList->_list.begin(); it != sensorList->_list.end(); ++it) {
+ deleteSensor(*it);
+ delete *it;
}
- // Delete this actor's sensor list
+ deleteSensorList(sensorList);
delete sensorList;
}
}
diff --git a/engines/saga2/sensor.cpp b/engines/saga2/sensor.cpp
index eb48c194a8..ac6143efa8 100644
--- a/engines/saga2/sensor.cpp
+++ b/engines/saga2/sensor.cpp
@@ -29,49 +29,14 @@
#include "saga2/std.h"
#include "saga2/objects.h"
#include "saga2/sensor.h"
-#include "saga2/pool.h"
#include "saga2/player.h"
#include "saga2/tile.h"
#include "saga2/savefile.h"
namespace Saga2 {
-struct SensorListHolder : public DNode {
- uint8 sensorListBuffer[sizeof(SensorList)];
-
- SensorList *getSensorList(void) {
- return (SensorList *)&sensorListBuffer;
- }
-};
-
-/* ===================================================================== *
- SensorHolder class
- * ===================================================================== */
-
-struct SensorHolder : public DNode {
- int16 checkCtr;
- uint8 sensorBuffer[maxSensorSize];
-
- Sensor *getSensor(void) {
- return (Sensor *)&sensorBuffer;
- }
-};
-
-/* ===================================================================== *
- Globals
- * ===================================================================== */
-
-// A pool of ActorSensorListHolders
-static RPool< SensorListHolder, 64 > sensorListPool;
-
-// The list of active ActorSensorLists
-static DList sensorListList;
-
-// A pool of SensorHolders
-static RPool< SensorHolder, 128 > sensorPool;
-
-// The list of all active Sensors
-static DList sensorList;
+Common::List<SensorList *> sensorListList;
+Common::List<Sensor *> sensorList;
/* ===================================================================== *
SensorList management functions
@@ -80,34 +45,15 @@ static DList sensorList;
//----------------------------------------------------------------------
// Allocate a new SensorList
-void *newSensorList(void) {
- SensorListHolder *newSensorListHolder;
-
- if ((newSensorListHolder
- = (SensorListHolder *)sensorListPool.alloc())
- == NULL)
- return NULL;
-
- sensorListList.addTail(*newSensorListHolder);
-
- return &newSensorListHolder->sensorListBuffer;
+void newSensorList(SensorList *s) {
+ sensorListList.push_back(s);
}
//----------------------------------------------------------------------
// Deallocate an SensorList
-void deleteSensorList(void *p) {
- SensorListHolder *listHolderToDelete;
-
- warning("FIXME: deleteSensorList(): unsafe pointer arithmetics");
- listHolderToDelete =
- (SensorListHolder *)((uint8 *)p
- - offsetof(
- SensorListHolder,
- sensorListBuffer));
-
- listHolderToDelete->remove();
- sensorListPool.free(listHolderToDelete);
+void deleteSensorList(SensorList *s) {
+ sensorListList.remove(s);
}
/* ===================================================================== *
@@ -117,45 +63,26 @@ void deleteSensorList(void *p) {
//----------------------------------------------------------------------
// Allocate a new Sensor
-void *newSensor(void) {
- SensorHolder *newSensorHolder;
+void newSensor(Sensor *s) {
+ sensorList.push_back(s);
- if ((newSensorHolder = (SensorHolder *)sensorPool.alloc()) == NULL)
- return NULL;
-
- sensorList.addTail(*newSensorHolder);
- newSensorHolder->checkCtr = sensorCheckRate;
-
- return &newSensorHolder->sensorBuffer;
+ s->checkCtr = sensorCheckRate;
}
//----------------------------------------------------------------------
// Allocate a new Sensor with a specified starting check counter
-void *newSensor(int16 ctr) {
- SensorHolder *newSensorHolder;
-
- if ((newSensorHolder = (SensorHolder *)sensorPool.alloc()) == NULL)
- return NULL;
+void newSensor(Sensor *s, int16 ctr) {
+ newSensor(s);
- sensorList.addTail(*newSensorHolder);
- newSensorHolder->checkCtr = ctr;
-
- return &newSensorHolder->sensorBuffer;
+ s->checkCtr = ctr;
}
//----------------------------------------------------------------------
// Deallocate a Sensor
-void deleteSensor(void *p) {
- SensorHolder *sensorHolderToDelete;
-
- warning("FIXME: deleteSensor(): unsafe pointer arithmetics");
- sensorHolderToDelete =
- (SensorHolder *)((uint8 *)p - offsetof(SensorHolder, sensorBuffer));
-
- sensorHolderToDelete->remove();
- sensorPool.free(sensorHolderToDelete);
+void deleteSensor(Sensor *p) {
+ sensorList.remove(p);
}
//----------------------------------------------------------------------
@@ -164,7 +91,7 @@ void deleteSensor(void *p) {
void *constructSensor(int16 ctr, void *buf) {
int16 type;
Sensor *sensor;
- SensorList *sensorList;
+ SensorList *sl;
// Get the sensor type
type = *((int16 *)buf);
@@ -172,39 +99,39 @@ void *constructSensor(int16 ctr, void *buf) {
switch (type) {
case protaganistSensor:
- sensor = new (ctr) ProtaganistSensor(&buf);
+ sensor = new ProtaganistSensor(&buf, ctr);
break;
case specificObjectSensor:
- sensor = new (ctr) SpecificObjectSensor(&buf);
+ sensor = new SpecificObjectSensor(&buf, ctr);
break;
case objectPropertySensor:
- sensor = new (ctr) ObjectPropertySensor(&buf);
+ sensor = new ObjectPropertySensor(&buf, ctr);
break;
case specificActorSensor:
- sensor = new (ctr) SpecificActorSensor(&buf);
+ sensor = new SpecificActorSensor(&buf, ctr);
break;
case actorPropertySensor:
- sensor = new (ctr) ActorPropertySensor(&buf);
+ sensor = new ActorPropertySensor(&buf, ctr);
break;
case eventSensor:
- sensor = new (ctr) EventSensor(&buf);
+ sensor = new EventSensor(&buf, ctr);
break;
}
assert(sensor != NULL);
// Get the sensor list
- sensorList = fetchSensorList(sensor->getObject());
+ sl = fetchSensorList(sensor->getObject());
- assert(sensorList != NULL);
+ assert(sl != NULL);
// Append this Sensor to the sensor list
- sensorList->addTail(*sensor);
+ sl->_list.push_back(sensor);
return buf;
}
@@ -239,38 +166,28 @@ void *archiveSensor(Sensor *sensor, void *buf) {
//----------------------------------------------------------------------
void checkSensors(void) {
- SensorHolder *sensorHolder,
- *nextSensorHolder;
+ for (Common::List<Sensor *>::iterator it = sensorList.begin(); it != sensorList.end(); ++it) {
+ Sensor *sensor = *it;
- for (sensorHolder = (SensorHolder *)sensorList.first();
- sensorHolder != NULL;
- sensorHolder = nextSensorHolder) {
- nextSensorHolder = (SensorHolder *)sensorHolder->next();
+ if (--sensor->checkCtr <= 0) {
+ assert(sensor->checkCtr == 0);
- if (--sensorHolder->checkCtr <= 0) {
- assert(sensorHolder->checkCtr == 0);
-
- Sensor *sensor = sensorHolder->getSensor();
SenseInfo info;
GameObject *senseobj = sensor->getObject();
uint32 sFlags = nonActorSenseFlags;
if (isActor(senseobj)) {
- Actor *a = (Actor *) senseobj;
+ Actor *a = (Actor *)senseobj;
sFlags = a->enchantmentFlags;
}
-
if (sensor->check(info, sFlags)) {
assert(info.sensedObject != NULL);
- assert(isObject(info.sensedObject)
- || isActor(info.sensedObject));
+ assert(isObject(info.sensedObject) || isActor(info.sensedObject));
- sensor->getObject()->senseObject(
- sensor->thisID(),
- info.sensedObject->thisID());
+ sensor->getObject()->senseObject(sensor->thisID(), info.sensedObject->thisID());
}
- sensorHolder->checkCtr = sensorCheckRate;
+ sensor->checkCtr = sensorCheckRate;
}
}
}
@@ -281,15 +198,8 @@ void assertEvent(const GameEvent &ev) {
assert(ev.directObject != NULL);
assert(isObject(ev.directObject) || isActor(ev.directObject));
- SensorHolder *sensorHolder,
- *nextSensorHolder;
-
- for (sensorHolder = (SensorHolder *)sensorList.first();
- sensorHolder != NULL;
- sensorHolder = nextSensorHolder) {
- nextSensorHolder = (SensorHolder *)sensorHolder->next();
-
- Sensor *sensor = sensorHolder->getSensor();
+ for (Common::List<Sensor *>::iterator it = sensorList.begin(); it != sensorList.end(); ++it) {
+ Sensor *sensor = *it;
if (sensor->evaluateEvent(ev)) {
sensor->getObject()->senseEvent(
@@ -320,6 +230,8 @@ void initSensors(void) {
// Save all active sensors in a save file
void saveSensors(SaveFileConstructor &saveGame) {
+ warning("STUB: saveSensort()");
+#if 0
int16 sensorListCount = 0,
sensorCount = 0;
@@ -343,12 +255,9 @@ void saveSensors(SaveFileConstructor &saveGame) {
archiveBufSize += sensorListCount * SensorList::archiveSize();
// Tally the sensors and add the archive size of each
- for (sensorHolder = (SensorHolder *)sensorList.first();
- sensorHolder != NULL;
- sensorHolder = (SensorHolder *)sensorHolder->next()) {
+ for (Common::List<Sensor *>::iterator it = sensorList.begin(); it != sensorList.end(); ++it) {
sensorCount++;
- archiveBufSize += sizeof(sensorHolder->checkCtr)
- + sensorArchiveSize(sensorHolder->getSensor());
+ archiveBufSize += sizeof((*it)->checkCtr) + sensorArchiveSize(*it);
}
// Allocate an archive buffer
@@ -364,19 +273,15 @@ void saveSensors(SaveFileConstructor &saveGame) {
bufferPtr = (int16 *)bufferPtr + 2;
// Archive all sensor lists
- for (listHolder = (SensorListHolder *)sensorListList.first();
- listHolder != NULL;
- listHolder = (SensorListHolder *)listHolder->next())
- bufferPtr = listHolder->getSensorList()->archive(bufferPtr);
+ for (Common::List<SensorList *>::iterator it = sensorListList.begin(); it != sensorListList.end(); ++it) {
+ bufferPtr = (*it)->archive(bufferPtr);
// Archive all sensors
- for (sensorHolder = (SensorHolder *)sensorList.first();
- sensorHolder != NULL;
- sensorHolder = (SensorHolder *)sensorHolder->next()) {
- *((int16 *)bufferPtr) = sensorHolder->checkCtr;
+ for (Common::List<Sensor *>::iterator it = sensorList.begin(); it != sensorList.end(); ++it) {
+ *((int16 *)bufferPtr) = (*it)->checkCtr;
bufferPtr = (int16 *)bufferPtr + 1;
- bufferPtr = archiveSensor(sensorHolder->getSensor(), bufferPtr);
+ bufferPtr = archiveSensor(*it, bufferPtr);
}
assert(bufferPtr == &((uint8 *)archiveBuffer)[archiveBufSize]);
@@ -388,12 +293,15 @@ void saveSensors(SaveFileConstructor &saveGame) {
archiveBufSize);
RDisposePtr(archiveBuffer);
+#endif
}
//----------------------------------------------------------------------
// Load sensors from a save file
void loadSensors(SaveFileReader &saveGame) {
+ warning("STUB: loadSensort()");
+#if 0
int16 i,
sensorListCount,
sensorCount;
@@ -433,47 +341,31 @@ void loadSensors(SaveFileReader &saveGame) {
assert(bufferPtr == &((uint8 *)archiveBuffer)[saveGame.getChunkSize()]);
RDisposePtr(archiveBuffer);
+#endif
}
//----------------------------------------------------------------------
// Cleanup the active sensors
void cleanupSensors(void) {
- SensorListHolder *listHolder,
- *nextListHolder;
- SensorHolder *sensorHolder,
- *nextSensorHolder;
-
- // Delete all sensor lists
- for (listHolder = (SensorListHolder *)sensorListList.first();
- listHolder != NULL;
- listHolder = nextListHolder) {
- nextListHolder = (SensorListHolder *)listHolder->next();
+ for (Common::List<SensorList *>::iterator it = sensorListList.begin(); it != sensorListList.end(); ++it)
+ delete *it;
- delete listHolder->getSensorList();
- }
+ sensorListList.clear();
- // Delete all sensors
- for (sensorHolder = (SensorHolder *)sensorList.first();
- sensorHolder != NULL;
- sensorHolder = nextSensorHolder) {
- nextSensorHolder = (SensorHolder *)sensorHolder->next();
+ for (Common::List<Sensor *>::iterator it = sensorList.begin(); it != sensorList.end(); ++it)
+ delete *it;
- delete sensorHolder->getSensor();
- }
+ sensorList.clear();
}
//----------------------------------------------------------------------
// Fetch a specified object's SensorList
SensorList *fetchSensorList(GameObject *obj) {
- SensorListHolder *listHolder;
-
- for (listHolder = (SensorListHolder *)sensorListList.first();
- listHolder != NULL;
- listHolder = (SensorListHolder *)listHolder->next()) {
- if (listHolder->getSensorList()->getObject() == obj)
- return listHolder->getSensorList();
+ for (Common::List<SensorList *>::iterator it = sensorListList.begin(); it != sensorListList.end(); ++it) {
+ if ((*it)->getObject() == obj)
+ return *it;
}
return NULL;
@@ -494,6 +386,8 @@ SensorList::SensorList(void **buf) {
obj = GameObject::objectAddress(*bufferPtr);
*buf = bufferPtr + 1;
+
+ newSensorList(this);
}
//----------------------------------------------------------------------
@@ -513,7 +407,7 @@ void *SensorList::archive(void *buf) {
//----------------------------------------------------------------------
// Constructor -- reconstruct from an archive buffer
-Sensor::Sensor(void **buf) {
+Sensor::Sensor(void **buf, int16 ctr) {
void *bufferPtr = *buf;
assert(isObject(*((ObjectID *)bufferPtr))
@@ -532,6 +426,8 @@ Sensor::Sensor(void **buf) {
bufferPtr = (int16 *)bufferPtr + 1;
*buf = bufferPtr;
+
+ newSensor(this, ctr);
}
//----------------------------------------------------------------------
@@ -562,20 +458,6 @@ void *Sensor::archive(void *buf) {
return buf;
}
-#if DEBUG
-void *Sensor::operator new (size_t sz) {
- assert(sz <= maxSensorSize);
-
- return newSensor();
-}
-
-void *Sensor::operator new (size_t sz, int16 ctr) {
- assert(sz <= maxSensorSize);
-
- return newSensor(ctr);
-}
-#endif
-
/* ===================================================================== *
ProtaganistSensor member functions
* ===================================================================== */
@@ -718,8 +600,8 @@ bool ObjectSensor::evaluateEvent(const GameEvent &) {
//----------------------------------------------------------------------
// Constructor -- reconstruct from an archive buffer
-SpecificObjectSensor::SpecificObjectSensor(void **buf) :
- ObjectSensor(buf) {
+SpecificObjectSensor::SpecificObjectSensor(void **buf, int16 ctr) :
+ ObjectSensor(buf, ctr) {
ObjectID *bufferPtr = (ObjectID *)*buf;
// Restore the sought object's ID
@@ -812,8 +694,8 @@ bool SpecificObjectSensor::isObjectSought(GameObject *obj) {
//----------------------------------------------------------------------
// Constructor -- reconstruct from an archive buffer
-ObjectPropertySensor::ObjectPropertySensor(void **buf) :
- ObjectSensor(buf) {
+ObjectPropertySensor::ObjectPropertySensor(void **buf, int16 ctr) :
+ ObjectSensor(buf, ctr) {
ObjectPropertyID *bufferPtr = (ObjectPropertyID *)*buf;
// Restore the object property ID
@@ -880,7 +762,7 @@ bool ActorSensor::isObjectSought(GameObject *obj) {
//----------------------------------------------------------------------
// Constructor -- reconstruct from an archive buffer
-SpecificActorSensor::SpecificActorSensor(void **buf) : ActorSensor(buf) {
+SpecificActorSensor::SpecificActorSensor(void **buf, int16 ctr) : ActorSensor(buf, ctr) {
ObjectID *bufferPtr = (ObjectID *)*buf;
assert(isActor(*bufferPtr));
@@ -966,7 +848,7 @@ bool SpecificActorSensor::isActorSought(Actor *a) {
//----------------------------------------------------------------------
// Constructor -- reconstruct from an archive buffer
-ActorPropertySensor::ActorPropertySensor(void **buf) : ActorSensor(buf) {
+ActorPropertySensor::ActorPropertySensor(void **buf, int16 ctr) : ActorSensor(buf, ctr) {
ActorPropertyID *bufferPtr = (ActorPropertyID *)*buf;
// Restore the actor property's ID
@@ -1029,7 +911,7 @@ EventSensor::EventSensor(
//----------------------------------------------------------------------
// Constructor -- reconstruct from an archive buffer
-EventSensor::EventSensor(void **buf) : Sensor(buf) {
+EventSensor::EventSensor(void **buf, int16 ctr) : Sensor(buf, ctr) {
int16 *bufferPtr = (int16 *)*buf;
// Restore the event type
diff --git a/engines/saga2/sensor.h b/engines/saga2/sensor.h
index 4c64a24b14..829274dff2 100644
--- a/engines/saga2/sensor.h
+++ b/engines/saga2/sensor.h
@@ -27,8 +27,6 @@
#ifndef SAGA2_SENSOR_H
#define SAGA2_SENSOR_H
-#include "saga2/dlist.h"
-
namespace Saga2 {
const uint32 nonActorSenseFlags = actorSeeInvis;
@@ -60,19 +58,19 @@ const int16 sensorCheckRate = 5;
struct GameEvent;
// Allocate a new SensorList
-void *newSensorList(void);
+void newSensorList(SensorList *s);
// Deallocate an SensorList
-void deleteSensorList(void *p);
+void deleteSensorList(SensorList *p);
// Fetch a specified object's SensorList
SensorList *fetchSensorList(GameObject *obj);
// Allocate a new Sensor
-void *newSensor(void);
+void newSensor(Sensor *s);
// Allocate a new Sensor with a specified starting check counter
-void *newSensor(int16 ctr);
+void newSensor(Sensor *s, int16 ctr);
// Deallocate a Sensor
-void deleteSensor(void *p);
+void deleteSensor(Sensor *p);
// Check all active sensors
void checkSensors(void);
@@ -110,11 +108,21 @@ struct SenseInfo {
SensorList Class
* ===================================================================== */
-class SensorList : public DList {
+class SensorList {
GameObject *obj;
+
+public:
+ Common::List<Sensor *> _list;
+
public:
// Constructor -- initial construction
- SensorList(GameObject *o) : obj(o) {}
+ SensorList(GameObject *o) : obj(o) {
+ newSensorList(this);
+ }
+
+ ~SensorList() {
+ deleteSensorList(this);
+ }
// Constructor -- reconstruct from archive buffer
SensorList(void **buf);
@@ -128,13 +136,6 @@ public:
// Archive this object in a buffer
void *archive(void *buf);
- void *operator new (size_t) {
- return newSensorList();
- }
- void operator delete (void *p) {
- deleteSensorList(p);
- }
-
GameObject *getObject(void) {
return obj;
}
@@ -144,24 +145,27 @@ public:
Sensor Class
* ===================================================================== */
-class Sensor : public DNode {
+class Sensor {
+public:
GameObject *obj;
SensorID id;
int16 range;
+ int16 checkCtr;
+
public:
// Constructor -- initial construction
- Sensor(GameObject *o, SensorID sensorID, int16 rng) :
- obj(o),
- id(sensorID),
- range(rng) {
+ Sensor(GameObject *o, SensorID sensorID, int16 rng) : obj(o), id(sensorID), range(rng) {
+ newSensor(this);
}
// Constructor -- reconstruct from an archive buffer
- Sensor(void **buf);
+ Sensor(void **buf, int16 ctr);
// Virtural destructor
- virtual ~Sensor(void) {}
+ virtual ~Sensor(void) {
+ deleteSensor(this);
+ }
// Return the number of bytes needed to archive this object in
// a buffer
@@ -173,21 +177,6 @@ public:
// Return an integer representing the type of this sensor
virtual int16 getType(void) = 0;
-#if DEBUG
- void *operator new (size_t sz);
- void *operator new (size_t sz, int16 ctr);
-#else
- void *operator new (size_t) {
- return newSensor();
- }
- void *operator new (size_t, int16 ctr) {
- return newSensor(ctr);
- }
-#endif
- void operator delete (void *p) {
- deleteSensor(p);
- }
-
GameObject *getObject(void) {
return obj;
}
@@ -217,7 +206,7 @@ public:
}
// Constructor -- reconstruct from an archive buffer
- ProtaganistSensor(void **buf) : Sensor(buf) {}
+ ProtaganistSensor(void **buf, int16 ctr) : Sensor(buf, ctr) {}
// Return an integer representing the type of this sensor
int16 getType(void);
@@ -241,7 +230,7 @@ public:
}
// Constructor -- reconstruct from an archive buffer
- ObjectSensor(void **buf) : Sensor(buf) {}
+ ObjectSensor(void **buf, int16 ctr) : Sensor(buf, ctr) {}
// Determine if the object can sense what it's looking for
bool check(SenseInfo &info, uint32 senseFlags);
@@ -273,7 +262,7 @@ public:
}
// Constructor -- reconstruct from an archive buffer
- SpecificObjectSensor(void **buf);
+ SpecificObjectSensor(void **buf, int16 ctr);
// Return the number of bytes needed to archive this object in
// a buffer
@@ -312,7 +301,7 @@ public:
}
// Constructor -- reconstruct from an archive buffer
- ObjectPropertySensor(void **buf);
+ ObjectPropertySensor(void **buf, int16 ctr);
// Return the number of bytes needed to archive this object in
// a buffer
@@ -341,7 +330,7 @@ public:
}
// Constructor -- reconstruct from an archive buffer
- ActorSensor(void **buf) : ObjectSensor(buf) {}
+ ActorSensor(void **buf, int16 ctr) : ObjectSensor(buf, ctr) {}
private:
// Determine if an object meets the search criteria
@@ -370,7 +359,7 @@ public:
}
// Constructor -- reconstruct from an archive buffer
- SpecificActorSensor(void **buf);
+ SpecificActorSensor(void **buf, int16 ctr);
// Return the number of bytes needed to archive this object in
// a buffer
@@ -409,7 +398,7 @@ public:
}
// Constructor -- reconstruct from an archive buffer
- ActorPropertySensor(void **buf);
+ ActorPropertySensor(void **buf, int16 ctr);
// Return the number of bytes needed to archive this object in
// a buffer
@@ -442,7 +431,7 @@ public:
int16 type);
// Constructor -- reconstruct from an archive buffer
- EventSensor(void **buf);
+ EventSensor(void **buf, int16 ctr);
// Return the number of bytes needed to archive this object in
// a buffer
Commit: e60a181b8e4d8d6a73e106ef9334c01b713d9ac5
https://github.com/scummvm/scummvm/commit/e60a181b8e4d8d6a73e106ef9334c01b713d9ac5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:22+02:00
Commit Message:
SAGA2: Remove RPool usage from path
Changed paths:
engines/saga2/path.cpp
diff --git a/engines/saga2/path.cpp b/engines/saga2/path.cpp
index 5af53ffe5f..159226fbbc 100644
--- a/engines/saga2/path.cpp
+++ b/engines/saga2/path.cpp
@@ -29,7 +29,6 @@
#include "saga2/tile.h"
#include "saga2/motion.h"
#include "saga2/player.h"
-#include "saga2/pool.h"
#include "saga2/cmisc.h"
#include "saga2/priqueue.h"
@@ -1055,16 +1054,6 @@ int16 tileSlopeHeight(
return 0;
}
-/* ===================================================================== *
- PathRequest management function prototypes
- * ===================================================================== */
-
-// Allocate a new path request
-void *newPathRequest(void);
-
-// Deallocate a path request
-void deletePathRequest(void *p);
-
/* ===================================================================== *
PathRequest Class
* ===================================================================== */
@@ -1137,13 +1126,6 @@ public:
flags |= aborted;
}
- void *operator new (size_t) {
- return newPathRequest();
- }
- void operator delete (void *p) {
- deletePathRequest(p);
- }
-
virtual void initialize(void);
virtual void finish(void); // completion method
virtual void abortReq(void); // abnormal termination method
@@ -1281,10 +1263,7 @@ public:
const int numPathRequests = 32; // up to 32 messages allowed
-typedef uint8 PathRequestPlaceHolder[sizeof(WanderPathRequest)];
-typedef RPool< PathRequestPlaceHolder, numPathRequests > PathRequestPool;
-
-PathRequestPool pathRequestPool;
+Common::List<WanderPathRequest *> pathRequestPool;
DList pathQueue;
PathRequest *currentRequest = nullptr;
@@ -2294,18 +2273,6 @@ int16 WanderPathRequest::evaluateMove(const TilePoint &testPt, uint8) {
return (centerCost - (dist + zDist)) >> 1;
}
-/* ===================================================================== *
- Misc. functions
- * ===================================================================== */
-
-void *newPathRequest(void) {
- return pathRequestPool.alloc();
-}
-
-void deletePathRequest(void *p) {
- pathRequestPool.free(p);
-}
-
void runPathFinder(void) {
if (currentRequest == nullptr) {
currentRequest = (PathRequest *)pathQueue.first();
Commit: 868a77f1e94d49364d4be8be96de496896f5931d
https://github.com/scummvm/scummvm/commit/868a77f1e94d49364d4be8be96de496896f5931d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:22+02:00
Commit Message:
SAGA2: Fix double free in number of places
Changed paths:
engines/saga2/objects.cpp
engines/saga2/task.cpp
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 9cb63eb4a2..b4b97f27bf 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -1835,7 +1835,6 @@ void GameObject::removeTimer(TimerID id) {
for (Common::List<Timer *>::iterator it = timerList->_timers.begin(); it != timerList->_timers.end(); ++it) {
if ((*it)->thisID() == id) {
timerList->_timers.remove(*it);
- delete *it;
if (timerList->_timers.empty())
delete timerList;
@@ -2020,8 +2019,6 @@ void GameObject::removeSensor(SensorID id) {
if ((*it)->thisID() == id) {
// Remove the sensor, then delete it
sensorList->_list.remove(*it);
- deleteSensor(*it);
- delete *it;
// If the list is now empty, delete it
if (sensorList->_list.empty()) {
diff --git a/engines/saga2/task.cpp b/engines/saga2/task.cpp
index 80ea420b85..e3cf039226 100644
--- a/engines/saga2/task.cpp
+++ b/engines/saga2/task.cpp
@@ -2365,7 +2365,6 @@ void HuntTask::removeWanderTask(void) {
void HuntTask::removeGotoTask(void) {
subTask->abortTask();
- delete subTask;
huntFlags &= ~huntGoto;
}
@@ -4942,7 +4941,6 @@ void TaskStack::abortTask(void) {
Task *stackBottom = getTaskAddress(stackBottomID);
stackBottom->abortTask();
- delete stackBottom;
}
}
Commit: 6a8aadb1fac6d409250b8fc1bc49b62acd102f87
https://github.com/scummvm/scummvm/commit/6a8aadb1fac6d409250b8fc1bc49b62acd102f87
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:22+02:00
Commit Message:
SAGA2: Remove pool.*
Changed paths:
R engines/saga2/pool.cpp
R engines/saga2/pool.h
engines/saga2/module.mk
engines/saga2/timers.cpp
diff --git a/engines/saga2/module.mk b/engines/saga2/module.mk
index f98ab09315..6d7cfb397e 100644
--- a/engines/saga2/module.mk
+++ b/engines/saga2/module.mk
@@ -56,7 +56,6 @@ MODULE_OBJS := \
patrol.o \
player.o \
playmode.o \
- pool.o \
property.o \
pt2angle.o \
rect.o \
diff --git a/engines/saga2/pool.cpp b/engines/saga2/pool.cpp
deleted file mode 100644
index a42197a8cc..0000000000
--- a/engines/saga2/pool.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * aint32 with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#include "saga2/std.h"
-#include "saga2/dlist.h"
-#include "saga2/pool.h"
-
-namespace Saga2 {
-
-_Pool::_Pool(void *nodeArray, int nodes, size_t nodeSize) {
- int i;
-
- // Link all of the nodes into the free list
- for (i = 0; i < nodes; i++) {
- free.addTail(*((DNode *)nodeArray));
- nodeArray = (uint8 *)nodeArray + nodeSize;
- }
-}
-
-//----------------------------------------------------------------------
-// Place a non-allocated node on the allocated list and return its
-// address
-
-void *_Pool::_alloc(void) {
- DNode *node = free.remHead();
-
- if (node != NULL) list.addTail(*node);
-
- return node;
-}
-
-//----------------------------------------------------------------------
-// Place an allocated node back on the non-allocated list
-
-void _Pool::_free(void *p) {
- DNode *node = (DNode *)p;
-
- node->remove();
- free.addTail(*node);
-}
-
-} // end of namespace Saga2
diff --git a/engines/saga2/pool.h b/engines/saga2/pool.h
deleted file mode 100644
index 40c8856e0f..0000000000
--- a/engines/saga2/pool.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#ifndef SAGA2_POOL_H
-#define SAGA2_POOL_H
-
-namespace Saga2 {
-
-/* ===================================================================== *
- _Pool class
- * ===================================================================== */
-
-// This is the base class for the resource pool template classes. This
-// class contains all of the non-inline functions in order to keep the
-// template instantiations from generating unneeded redundant code.
-
-class _Pool {
- DList free, // List of non-allocated nodes
- list; // List of allocated nodes
-
-protected:
- // Constructor
- _Pool(void *nodeArray, int nodes, size_t nodeSize);
-
- // Place a non-allocated node on the allocated list and return
- // its address
- void *_alloc(void);
-
- // Place an allocated node back on the non-allocated list
- void _free(void *p);
-};
-
-/* ===================================================================== *
- Pool class template
- * ===================================================================== */
-
-// This is the direct base class of the RPool class. This class is aware
-// of the type of the objects in the pool but is unaware of the number of
-// available nodes and is not responsible for allocating the node array.
-// This class is useful for creating a pointer or reference to an RPool
-// without having to specify the size of the node array.
-
-template <class T>
-class Pool : public _Pool {
-protected:
-
- // The base node type
- struct PoolNode : public DNode {
- uint8 buf[sizeof(T)]; // Defines a buffer large enough to
- // contain an object of type T.
- };
-
- // Constructor
- Pool(void *nodeArray, int nodes) :
- _Pool(nodeArray, nodes, sizeof(PoolNode)) {
- }
-
-public:
-
- // Allocate a new object of type T and return its address
- void *alloc(void) {
- PoolNode *node = (PoolNode *)_alloc();
- return node != NULL ? node->buf : NULL;
- }
-
- // Deallocate an object of type T given its address
- void free(void *p) {
- warning("FIXME: Pool::free(): unsafe pointer arithmetics");
- _free((uint8 *)p - offsetof(PoolNode, buf));
- }
-};
-
-/* ===================================================================== *
- RPool class template
- * ===================================================================== */
-
-// The is the resource allocator pool which may be instantiated. This class
-// is responsible for allocating the node array and calling the base
-// class constructor. All other functionality is provided through the
-// base classes.
-
-template <class T, int s>
-class RPool : public Pool<T> {
- typename Pool<T>::PoolNode array[s]; // The node array
-
-public:
- // Constructor
- RPool(void) : Pool<T>(array, s) {}
-};
-
-} // end of namespace Saga2
-
-#endif
diff --git a/engines/saga2/timers.cpp b/engines/saga2/timers.cpp
index 4f72bdd8ae..5c2265fd23 100644
--- a/engines/saga2/timers.cpp
+++ b/engines/saga2/timers.cpp
@@ -31,7 +31,6 @@
#include "saga2/std.h"
#include "saga2/fta.h"
#include "saga2/timers.h"
-#include "saga2/pool.h"
#include "saga2/objects.h"
#include "saga2/savefile.h"
Commit: fee6fb6ead91e42a3e72534de2cb3c0635fa57ae
https://github.com/scummvm/scummvm/commit/fee6fb6ead91e42a3e72534de2cb3c0635fa57ae
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:22+02:00
Commit Message:
SAGA2: Fix another double free
Changed paths:
engines/saga2/task.cpp
diff --git a/engines/saga2/task.cpp b/engines/saga2/task.cpp
index e3cf039226..5bb8b23e4a 100644
--- a/engines/saga2/task.cpp
+++ b/engines/saga2/task.cpp
@@ -496,8 +496,6 @@ TaskList::TaskList(void) {
// TaskList destructor
TaskList::~TaskList(void) {
- for (int i = 0; i < numTasks; i++)
- delete _list[i];
}
//----------------------------------------------------------------------
@@ -594,6 +592,7 @@ void TaskList::newTask(Task *t) {
return;
}
+ warning("Too many tasks in the list, > %d", numTasks);
}
void TaskList::newTask(Task *t, TaskID id) {
Commit: 34ae4988f75bc7d11c77b0020b2c3158204be1c2
https://github.com/scummvm/scummvm/commit/34ae4988f75bc7d11c77b0020b2c3158204be1c2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:22+02:00
Commit Message:
SAGA2: Added more debug output
Changed paths:
engines/saga2/blitters.cpp
engines/saga2/task.cpp
diff --git a/engines/saga2/blitters.cpp b/engines/saga2/blitters.cpp
index c8ce1d163f..a2aa6a290f 100644
--- a/engines/saga2/blitters.cpp
+++ b/engines/saga2/blitters.cpp
@@ -125,7 +125,7 @@ void unpackSprite(gPixelMap *map, uint8 *sprData, uint32 dataSize) {
}
if (bytes < trans) {
- warning("unpackSprite: too many trans %d < %d", bytes, trans);
+ warning("unpackSprite: too many trans %d < %d for %dx%d (src %d bytes)", bytes, trans, map->size.x, map->size.y, dataSize);
trans = bytes;
break;
}
@@ -143,7 +143,7 @@ void unpackSprite(gPixelMap *map, uint8 *sprData, uint32 dataSize) {
return;
}
if (bytes < fill) {
- warning("unpackSprite: too many bytes %d < %d", bytes, fill);
+ warning("unpackSprite: too many fill %d < %d for %dx%d (src %d bytes)", bytes, fill, map->size.x, map->size.y, dataSize);
fill = bytes;
}
if (stream.read(dst, fill) != fill) {
diff --git a/engines/saga2/task.cpp b/engines/saga2/task.cpp
index 5bb8b23e4a..6b8a73a86c 100644
--- a/engines/saga2/task.cpp
+++ b/engines/saga2/task.cpp
@@ -586,6 +586,7 @@ void *TaskList::archive(void *buf) {
}
void TaskList::newTask(Task *t) {
+ warning("List: %p Adding task %p", (void *)this, (void *)t);
for (int i = 0; i < numTasks; i++)
if (!_list[i]) {
_list[i] = t;
@@ -604,9 +605,12 @@ void TaskList::newTask(Task *t, TaskID id) {
// into the inactive list
void TaskList::deleteTask(Task *p) {
+ warning("List: %p Deleting task %p", (void *)this, (void *)p);
for (int i = 0; i < numTasks; i++)
- if (_list[i] == p)
+ if (_list[i] == p) {
_list[i] = nullptr;
+ warning("Deleted");
+ }
}
/* ===================================================================== *
Commit: 4119efb93a222bc8f30690c773b0bcee7641ecbe
https://github.com/scummvm/scummvm/commit/4119efb93a222bc8f30690c773b0bcee7641ecbe
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:23+02:00
Commit Message:
SAGA2: More debug output to unpackSprite() and disabled most of it
Changed paths:
engines/saga2/blitters.cpp
diff --git a/engines/saga2/blitters.cpp b/engines/saga2/blitters.cpp
index a2aa6a290f..cf7caf1dc5 100644
--- a/engines/saga2/blitters.cpp
+++ b/engines/saga2/blitters.cpp
@@ -105,9 +105,12 @@ void unpackImage(gPixelMap *map, int32 width, int32 rowCount, int8 *srcData) {
unpackImage(*map, (int16)width, (int16)rowCount, srcData);
}
+#define DEBUGPACK 0
+
void unpackSprite(gPixelMap *map, uint8 *sprData, uint32 dataSize) {
byte *dst = map->data;
int bytes = map->size.x * map->size.y;
+ bool fail = false;
if (!sprData) {
warning("unpackSprite(): empty sprData");
@@ -121,12 +124,16 @@ void unpackSprite(gPixelMap *map, uint8 *sprData, uint32 dataSize) {
if (stream.eos()) {
warning("unpackSprite: premature end of data");
- return;
+ fail = true;
+ break;
}
if (bytes < trans) {
+#if DEBUGPACK
warning("unpackSprite: too many trans %d < %d for %dx%d (src %d bytes)", bytes, trans, map->size.x, map->size.y, dataSize);
+#endif
trans = bytes;
+ fail = true;
break;
}
memset(dst, 0, trans);
@@ -140,15 +147,20 @@ void unpackSprite(gPixelMap *map, uint8 *sprData, uint32 dataSize) {
if (stream.eos()) {
warning("unpackSprite: premature end of data");
- return;
+ fail = true;
+ break;
}
if (bytes < fill) {
+#if DEBUGPACK
warning("unpackSprite: too many fill %d < %d for %dx%d (src %d bytes)", bytes, fill, map->size.x, map->size.y, dataSize);
+#endif
fill = bytes;
+ fail = true;
}
if (stream.read(dst, fill) != fill) {
warning("unpackSprite: premature end of data");
- return;
+ fail = true;
+ break;
}
dst += fill;
bytes -= fill;
@@ -156,6 +168,27 @@ void unpackSprite(gPixelMap *map, uint8 *sprData, uint32 dataSize) {
if (bytes <= 0)
break;
}
+
+ if (!stream.eos()) {
+#if DEBUGPACK
+ warning("unpackSprite: %d bytes left", stream.size() - stream.pos());
+#endif
+ fail = true;
+ }
+
+#if DEBUGPACK
+ if (fail) {
+ Graphics::Surface surf;
+ surf.w = map->size.x;
+ surf.h = map->size.y;
+ surf.pitch = map->size.x;
+ surf.format = Graphics::PixelFormat::createFormatCLUT8();
+
+ surf.setPixels(map->data);
+
+ surf.debugPrint();
+ }
+#endif
}
void drawTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData, bool mask) {
Commit: a0b9425f9e654237c20e03ee4b04436511f26510
https://github.com/scummvm/scummvm/commit/a0b9425f9e654237c20e03ee4b04436511f26510
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:23+02:00
Commit Message:
SAGA2: Fix alloc-dealloc mismatch in spriteBanks
Changed paths:
engines/saga2/sprite.cpp
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index 8100599405..4723ed6d1f 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -679,7 +679,7 @@ ActorAppearance *LoadActorAppearance(uint32 id, int16 banksNeeded) {
// Dump the sprites being stored
for (bank = 0; bank < (long)elementsof(aa->spriteBanks); bank++) {
if (aa->spriteBanks[bank])
- free(aa->spriteBanks[bank]);
+ delete aa->spriteBanks[bank];
aa->spriteBanks[bank] = nullptr;
}
Commit: bdf005cac1cdea627f3fc68353477794706f784a
https://github.com/scummvm/scummvm/commit/bdf005cac1cdea627f3fc68353477794706f784a
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:23+02:00
Commit Message:
SAGA2: Fix invalid sector activation
Changed paths:
engines/saga2/objects.cpp
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index b4b97f27bf..bff0abd795 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -965,6 +965,7 @@ void GameObject::updateImage(ObjectID oldParentID) {
if (isWorld(_data.parentID)) {
GameWorld *w = world();
+ Sector *sect;
if (!isMoving()) {
if (objObscured(this)) {
@@ -973,11 +974,16 @@ void GameObject::updateImage(ObjectID oldParentID) {
_data.objectFlags &= ~objectObscured;
}
}
+ int u = _data.location.u >> kSectorShift;
+ int v = _data.location.v >> kSectorShift;
- if (w->getSector(_data.location.u >> kSectorShift,
- _data.location.v >> kSectorShift)->isActivated()) {
- activate();
+ sect = w->getSector(u, v);
+ if (sect) {
+ if (sect->isActivated())
+ sect->activate();
}
+ else
+ warning("GameObject::updateImage: Invalid Sector (%d, %d))", u, v);
} else {
_data.objectFlags &= ~objectObscured;
@@ -3299,8 +3305,13 @@ void ActiveRegion::update(void) {
for (v = newRegion.min.v; v < newRegion.max.v; v++) {
if (uOutOfRange
|| v < region.min.v
- || v >= region.max.v)
- world->getSector(u, v)->activate();
+ || v >= region.max.v) {
+
+ if(Sector *sect = world->getSector(u, v))
+ sect->activate();
+ else
+ warning("ActiveRegion::update: Invalid Sector (%d, %d)", u, v);
+ }
}
}
Commit: 8bae7aa52befe0c4f2990c2bb7888a1410c289d5
https://github.com/scummvm/scummvm/commit/8bae7aa52befe0c4f2990c2bb7888a1410c289d5
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:23+02:00
Commit Message:
SAGA2: Add more debug output
Changed paths:
engines/saga2/detection.cpp
engines/saga2/saga2.h
engines/saga2/timers.cpp
engines/saga2/timers.h
diff --git a/engines/saga2/detection.cpp b/engines/saga2/detection.cpp
index 2c4277fe63..9cfa174cc5 100644
--- a/engines/saga2/detection.cpp
+++ b/engines/saga2/detection.cpp
@@ -35,6 +35,7 @@ static const DebugChannelDef debugFlagList[] = {
{Saga2::kDebugTiles, "tiles", "Debug the tiles"},
{Saga2::kDebugPalettes, "palettes", "Debug the palettes"},
{Saga2::kDebugLoading, "loading", "Debug the loading"},
+ {Saga2::kDebugTimers, "timers", "Debug the timers"},
DEBUG_CHANNEL_END
};
diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h
index 12ddafdd79..f4f17a23aa 100644
--- a/engines/saga2/saga2.h
+++ b/engines/saga2/saga2.h
@@ -48,7 +48,8 @@ enum {
kDebugInit = 1 << 4,
kDebugTiles = 1 << 5,
kDebugPalettes = 1 << 6,
- kDebugLoading = 1 << 7
+ kDebugLoading = 1 << 7,
+ kDebugTimers = 1 << 8
};
#define TICKSPERSECOND (728L/10L)
diff --git a/engines/saga2/timers.cpp b/engines/saga2/timers.cpp
index 5c2265fd23..373d41b375 100644
--- a/engines/saga2/timers.cpp
+++ b/engines/saga2/timers.cpp
@@ -269,6 +269,8 @@ void cleanupTimers(void) {
* ===================================================================== */
TimerList::TimerList(GameObject *o) : _obj(o) {
+ debugC(1, kDebugTimers, "Creating timer list %p (obj %p)",
+ (void *)this, (void *)o);
g_vm->_timerLists.push_back(this);
}
@@ -288,6 +290,8 @@ TimerList::TimerList(void **buf) {
}
TimerList::~TimerList() {
+ debugC(1, kDebugTimers, "Deleting timer list %p (obj %p)",
+ (void *)this, (void *)_obj);
g_vm->_timerLists.remove(this);
}
@@ -338,6 +342,8 @@ Timer::Timer(void **buf) {
}
Timer::~Timer() {
+ debugC(1, kDebugTimers, "Deleting timer %p (obj %p)",
+ (void *)this, (void *)_obj);
g_vm->_timers.remove(this);
}
diff --git a/engines/saga2/timers.h b/engines/saga2/timers.h
index 71dc8f2484..15da6c8fe5 100644
--- a/engines/saga2/timers.h
+++ b/engines/saga2/timers.h
@@ -97,6 +97,8 @@ public:
// Constructor -- initial construction
Timer(GameObject *o, TimerID timerID, int16 frameInterval) : _obj(o), _id(timerID), _interval(frameInterval) {
_alarm.set(_interval);
+ debugC(1, kDebugTimers, "Creating timer %p (obj %p)",
+ (void *)this, (void *)o);
g_vm->_timers.push_back(this);
}
Commit: eac033d227e83fa7aa1da97510aba94d40323238
https://github.com/scummvm/scummvm/commit/eac033d227e83fa7aa1da97510aba94d40323238
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:23+02:00
Commit Message:
SAGA2: Call deleteTask on task destruction
Changed paths:
engines/saga2/task.h
diff --git a/engines/saga2/task.h b/engines/saga2/task.h
index f4f07f5ab8..a1e18d64ed 100644
--- a/engines/saga2/task.h
+++ b/engines/saga2/task.h
@@ -150,7 +150,9 @@ public:
Task(void **buf, TaskID id);
// Virtual destructor -- do nothing
- virtual ~Task(void) {}
+ virtual ~Task(void) {
+ deleteTask(this);
+ }
// Fixup any subtask pointers
virtual void fixup(void);
Commit: 054c920251da69633ed199be14ef183627130e0c
https://github.com/scummvm/scummvm/commit/054c920251da69633ed199be14ef183627130e0c
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:23+02:00
Commit Message:
SAGA2: Change assert to warning in fetchPlatforms
Changed paths:
engines/saga2/tile.cpp
engines/saga2/tile.h
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 76ed793e37..53b709b960 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -1433,7 +1433,8 @@ MapHeader::~MapHeader() {
delete[] mapData;
}
-MetaTile::MetaTile(int ind, Common::SeekableReadStream *stream) {
+MetaTile::MetaTile(MetaTileList *parent, int ind, Common::SeekableReadStream *stream) {
+ _parent = parent;
_index = ind;
_highestPixel = stream->readUint16LE();
_banksNeeded._b[0] = stream->readUint32LE();
@@ -1449,7 +1450,7 @@ MetaTileList::MetaTileList(int count, Common::SeekableReadStream *stream) {
_count = count;
_tiles = (MetaTile **)malloc(_count * sizeof(MetaTile *));
for (int i = 0; i < _count; ++i) {
- _tiles[i] = new MetaTile(i, stream);
+ _tiles[i] = new MetaTile(this, i, stream);
}
}
@@ -2319,7 +2320,7 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
PlatformCacheEntry *pce;
assert(layer >= 0);
- assert(_index != -1);
+ assert(_parent == mapList[mapNum].metaList);
if (plIndex == nullID) {
return nullptr;
@@ -2333,7 +2334,10 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
assert(pce->platformNum >= 0);
assert(pce->metaID != NoMetaTile);
- assert(pce->metaID == thisID(mapNum));
+ if (pce->metaID != thisID(mapNum))
+ warning("fetchPlatform: pce->metaID (%d, %d) != thisID(mapNum) (%d, %d)",
+ pce->metaID.index, pce->metaID.map,
+ thisID(mapNum).index, thisID(mapNum).map);
// Move to the end of the LRU
platformLRU.push_back(plIndex);
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index 26f51a789b..742a96b151 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -772,15 +772,18 @@ typedef uint16 metaTileNoise;
// A "Metatile" is a larger tile made up of smaller tiles.
+class MetaTileList;
+
class MetaTile {
public:
uint16 _highestPixel; // more drawing optimization
BankBits _banksNeeded; // which banks are needed
uint16 _stack[maxPlatforms]; // pointer to platforms
uint32 _properties; // more drawing optimization
- int _index = -1;
+ int _index;
+ MetaTileList *_parent;
- MetaTile(int ind, Common::SeekableReadStream *stream);
+ MetaTile(MetaTileList *parent, int ind, Common::SeekableReadStream *stream);
// Return a pointer to a meta tile given its ID
static MetaTile *metaTileAddress(MetaTileID id);
Commit: 90b82851f29b520f3727f53277dffaa674f773e3
https://github.com/scummvm/scummvm/commit/90b82851f29b520f3727f53277dffaa674f773e3
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:23+02:00
Commit Message:
SAGA2: Update cycleList usage in sagafunc.cpp
Changed paths:
engines/saga2/sagafunc.cpp
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index d103a379f7..c064e63e61 100644
--- a/engines/saga2/sagafunc.cpp
+++ b/engines/saga2/sagafunc.cpp
@@ -3484,9 +3484,9 @@ int16 scriptFindMission(int16 *args) {
int16 scriptSetTileCycleSpeed(int16 *args) {
MONOLOG(SetTileCycleSpeed);
- extern CycleHandle cycleList; // list of tile cycling info
+ extern CyclePtr cycleList; // list of tile cycling info
- TileCycleData &tcd = (*cycleList)[args[0]];
+ TileCycleData &tcd = cycleList[args[0]];
tcd.cycleSpeed = args[1];
@@ -3499,9 +3499,9 @@ int16 scriptSetTileCycleSpeed(int16 *args) {
int16 scriptSetTileCycleState(int16 *args) {
MONOLOG(SetTileCycleState);
- extern CycleHandle cycleList; // list of tile cycling info
+ extern CyclePtr cycleList; // list of tile cycling info
- TileCycleData &tcd = (*cycleList)[args[0]];
+ TileCycleData &tcd = cycleList[args[0]];
tcd.currentState = args[1];
tcd.counter = 0;
Commit: cee4f07c1b28d1b6a19bdd321949a4774d81b825
https://github.com/scummvm/scummvm/commit/cee4f07c1b28d1b6a19bdd321949a4774d81b825
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:24+02:00
Commit Message:
SAGA2: Remove DNode from PlatformCacheEntry
Changed paths:
engines/saga2/tile.cpp
engines/saga2/tile.h
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 53b709b960..bb7605396a 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -2340,6 +2340,7 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
thisID(mapNum).index, thisID(mapNum).map);
// Move to the end of the LRU
+ platformLRU.remove(plIndex);
platformLRU.push_back(plIndex);
// return the address of the platform
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index 742a96b151..a51917b2d6 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -730,7 +730,7 @@ enum platformFlags {
PlatformCacheEntry struct
* ======================================================================= */
-struct PlatformCacheEntry : public DNode {
+struct PlatformCacheEntry {
uint16 platformNum, // original platform num
layerNum; // index of this plat in mt.
MetaTileID metaID; // pointer to parent metatile
Commit: 46f14c4f1e3a8ebf1e93b8dfdf9eb2f4d117e3d8
https://github.com/scummvm/scummvm/commit/46f14c4f1e3a8ebf1e93b8dfdf9eb2f4d117e3d8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:24+02:00
Commit Message:
SAGA2: Fix warnings in actor.cpp
Changed paths:
engines/saga2/actor.cpp
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 5dabfb9ce7..e9e8a6caaf 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -547,12 +547,10 @@ bool ActorProto::acceptStrikeAction(
Actor *a = (Actor *)GameObject::objectAddress(dObj);
ActorAttributes *effStats = a->getStats();
- WeaponProto *weaponProto = (WeaponProto *)GameObject::protoAddress(strikingObj);
GameObject *weapon = GameObject::objectAddress(strikingObj);
assert(weapon->proto()->containmentSet() & ProtoObj::isWeapon);
- WeaponStuff &ws = getWeapon(weaponProto->getWeaponID());
Actor *enactorPtr = (Actor *)GameObject::objectAddress(enactor);
ArmorAttributes armorAttribs;
@@ -734,6 +732,9 @@ bool ActorProto::acceptInsertionAtAction(
case worn:
a->wear(item, wornWhere);
break;
+
+ default:
+ break;
}
}
@@ -1966,7 +1967,7 @@ void Actor::getColorTranslation(ColorTable map) {
// Each time the nextAnimationFrame() is called, it will increment
// to the next frame in the sequence.
-int16 Actor::setAction(int16 newState, int16 flags) {
+int16 Actor::setAction(int16 newState, int16 flags_) {
ActorAnimation *anim;
int16 numPoses = 0;
@@ -1984,11 +1985,11 @@ int16 Actor::setAction(int16 newState, int16 flags) {
// Set up the animation
currentAnimation = newState;
- animationFlags = flags;
+ animationFlags = flags_;
// If they haven't set the "no reset" flag, then
- if (!(flags & animateNoRestart)) {
- if (flags & animateReverse) currentPose = numPoses - 1;
+ if (!(flags_ & animateNoRestart)) {
+ if (flags_ & animateReverse) currentPose = numPoses - 1;
else currentPose = 0;
} else {
currentPose = clamp(0, currentPose, numPoses - 1);
@@ -2298,15 +2299,15 @@ void Actor::updateAppearance(int32) {
}// End if (appearance)
}
-bool Actor::SetAvailableAction(int16 flags, ...) {
+bool Actor::SetAvailableAction(int16 flags_, ...) {
bool result = false;
va_list Actions;
- va_start(Actions, flags); //Initialize To First Argument Even Though We Dont Use It In The Loop
+ va_start(Actions, flags_); //Initialize To First Argument Even Though We Dont Use It In The Loop
for (;;) { //Infinite Loop
int thisAction = va_arg(Actions, int); //Increment To Second Argument Ignoring Flags
if (thisAction < 0) break; //Check If Last Parameter Since Last Always Should Be -1
- if (setAction(thisAction, flags)) { //Try To Set This Action
+ if (setAction(thisAction, flags_)) { //Try To Set This Action
result = true; //If Successful
break;
}
@@ -2374,7 +2375,7 @@ void Actor::evaluateNeeds(void) {
&& appearance != NULL
&& !hasEffect(actorNotDefenseless)) {
GameObject *obj;
- bool foundWeapon;;
+ bool foundWeapon = false;
ContainerIterator iter(this);
while (iter.next(&obj) != Nothing) {
@@ -2674,8 +2675,6 @@ void Actor::handleDamageTaken(uint8 damage) {
if (combatBehavior == behaviorHungry) return;
- GameObject *weapon = offensiveObject();
-
if (offensiveObject() == this
&& !isActionAvailable(actionSwingHigh)
&& !isActionAvailable(actionTwoHandSwingHigh)
@@ -3324,8 +3323,6 @@ int16 GetRandomBetween(int start, int end) {
}
-static int useLine = 0;
-
void updateActorStates(void) {
if (actorStatesPaused) return;
Commit: 07d27868e73120e8a6608b3662494652c535c438
https://github.com/scummvm/scummvm/commit/07d27868e73120e8a6608b3662494652c535c438
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:24+02:00
Commit Message:
SAGA2: Fix warnings in spellio.cpp
Changed paths:
engines/saga2/spellio.cpp
diff --git a/engines/saga2/spellio.cpp b/engines/saga2/spellio.cpp
index 4ae66403e9..40662604ce 100644
--- a/engines/saga2/spellio.cpp
+++ b/engines/saga2/spellio.cpp
@@ -40,8 +40,6 @@
namespace Saga2 {
const ChunkID spellInstCountID = MakeID('S', 'P', 'E', 'L');
-const ChunkID spellInstID = MakeID('S', 'P', 'I', 'N');
-const ChunkID spellEffectronID = MakeID('S', 'P', 'E', 'F');
/* ===================================================================== *
Imports
@@ -243,23 +241,27 @@ void cleanupSpellState(void) {
// cleanup active spells
StorageSpellTarget::StorageSpellTarget(SpellTarget &st) {
- GameObject *go;
+ GameObject *go = NULL;
ActiveItem *ai;
type = st.getType();
loc = st.getPoint();
- if (type == SpellTarget::spellTargetObject)
+ if (type == SpellTarget::spellTargetObject) {
if (type == SpellTarget::spellTargetObject)
go = st.getObject();
else
go = NULL;
+ }
+
if (go)
obj = go->thisID();
else
obj = Nothing;
+
if (type == SpellTarget::spellTargetTAG)
ai = st.getTAG();
else
ai = NULL;
+
if (ai)
tag = ai->thisID();
else
@@ -339,14 +341,12 @@ size_t SpellDisplayList::saveSize(void) {
void SpellDisplayList::save(SaveFileConstructor &saveGame) {
size_t chunkSize = saveSize();
- size_t offset = 0;
saveGame.newChunk(spellInstCountID, chunkSize);
saveGame.write(&count, sizeof(count));
if (count) {
for (int i = 0; i < count; i++) {
- int j = 0;
StorageSpellInstance ssi = StorageSpellInstance(*spells[i]);
saveGame.write(&ssi, sizeof(ssi));
spells[i]->saveEffect(saveGame);
Commit: 634732e42fbc9fb9c25f91bdd730867cc56719dc
https://github.com/scummvm/scummvm/commit/634732e42fbc9fb9c25f91bdd730867cc56719dc
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:24+02:00
Commit Message:
SAGA2: Remove residual debug code
Changed paths:
engines/saga2/tile.cpp
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index bb7605396a..b78103103c 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -2347,8 +2347,6 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
return &pce->pl;
} else {
debugC(2, kDebugLoading, "Fetching platform (%d,%d)", mapNum, layer);
- if (mapNum == 0 && layer == 6)
- debug("");
// Since the platform is not in the cache, we need to
// dump something from the cache. Dump the one that
Commit: 751a6d086a2cccb3513656d8aea594f7c986a47e
https://github.com/scummvm/scummvm/commit/751a6d086a2cccb3513656d8aea594f7c986a47e
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:24+02:00
Commit Message:
SAGA2: Get rid of rmem in speech.cpp
Changed paths:
engines/saga2/speech.cpp
diff --git a/engines/saga2/speech.cpp b/engines/saga2/speech.cpp
index c4e0f83a9a..7b6d252da1 100644
--- a/engines/saga2/speech.cpp
+++ b/engines/saga2/speech.cpp
@@ -368,7 +368,7 @@ bool Speech::setupActive(void) {
// Blit to temp bitmap
speechImage.size.x = bounds.width;
speechImage.size.y = bounds.height;
- speechImage.data = (uint8 *) RNewClearPtr(speechImage.bytes(), NULL, "speech text image");
+ speechImage.data = new uint8[speechImage.bytes()]();
tempTextPort.setMap(&speechImage);
y = outlineWidth; // Plus 2 for Outlines
@@ -550,7 +550,7 @@ void Speech::dispose(void) {
wakeUpThread(thread, selectedButton);
// De-allocate the speech data
- RDisposePtr(speechImage.data);
+ delete[] speechImage.data;
speechImage.data = NULL;
// Clear the number of active buttons
@@ -1284,7 +1284,7 @@ void saveSpeechTasks(SaveFileConstructor &saveGame) {
archiveBufSize = speechList.archiveSize();
- archiveBuffer = RNewPtr(archiveBufSize, NULL, "archive buffer");
+ archiveBuffer = malloc(archiveBufSize);
if (archiveBuffer == NULL)
error("Unable to allocate speech task archive buffer");
@@ -1295,7 +1295,7 @@ void saveSpeechTasks(SaveFileConstructor &saveGame) {
archiveBuffer,
archiveBufSize);
- RDisposePtr(archiveBuffer);
+ free(archiveBuffer);
}
//-----------------------------------------------------------------------
@@ -1311,7 +1311,7 @@ void loadSpeechTasks(SaveFileReader &saveGame) {
void *archiveBuffer;
void *bufferPtr;
- archiveBuffer = RNewPtr(saveGame.getChunkSize(), NULL, "archive buffer");
+ archiveBuffer = malloc(saveGame.getChunkSize());
if (archiveBuffer == NULL)
error("Unable to allocate speech task archive buffer");
@@ -1323,7 +1323,7 @@ void loadSpeechTasks(SaveFileReader &saveGame) {
// Reconstruct stackList from archived data
new (&speechList) SpeechTaskList(&bufferPtr);
- RDisposePtr(archiveBuffer);
+ free(archiveBuffer);
}
//-----------------------------------------------------------------------
Commit: f0fe90c2677dd0e96b251989a92b10e8c936e329
https://github.com/scummvm/scummvm/commit/f0fe90c2677dd0e96b251989a92b10e8c936e329
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:24+02:00
Commit Message:
SAGA2: Fix overridden methods
Changed paths:
engines/saga2/panel.cpp
engines/saga2/panel.h
diff --git a/engines/saga2/panel.cpp b/engines/saga2/panel.cpp
index 35d107696d..db2cbf2739 100644
--- a/engines/saga2/panel.cpp
+++ b/engines/saga2/panel.cpp
@@ -122,7 +122,7 @@ void gPanel::enable(bool abled) {
enabled = abled ? 1 : 0;
}
-void gPanel::select(bool sel) {
+void gPanel::select(uint16 sel) {
selected = sel ? 1 : 0;
}
@@ -582,7 +582,7 @@ void gWindow::enable(bool abled) {
draw();
}
-void gWindow::select(bool sel) {
+void gWindow::select(uint16 sel) {
gPanel::select(sel);
draw();
}
@@ -636,7 +636,7 @@ void gControl::enable(bool abled) {
}
}
-void gControl::select(bool sel) {
+void gControl::select(uint16 sel) {
if (!sel != !isSelected()) { // Use '!' to insure boolean-ness
gPanel::select(sel);
invalidate();
diff --git a/engines/saga2/panel.h b/engines/saga2/panel.h
index 0d8747ff52..ef7b6126ce 100644
--- a/engines/saga2/panel.h
+++ b/engines/saga2/panel.h
@@ -177,7 +177,7 @@ public:
virtual void deactivate(void); // deactivate the control
virtual void draw(void); // redraw the panel.
virtual void enable(bool abled);
- virtual void select(bool selected);
+ virtual void select(uint16 selected);
virtual void ghost(bool ghosted);
virtual void invalidate(Rect16 *area = nullptr);
virtual void setMousePoll(bool abled) {
@@ -379,7 +379,7 @@ public:
// const Rect16 &r );
void enable(bool abled);
- void select(bool sel); // activate the window
+ void select(uint16 sel); // activate the window
virtual bool open(void);
virtual void close(void);
@@ -407,7 +407,7 @@ public:
gPanel *keyTest(int16 key);
void enable(bool abled); // enable the control
- void select(bool sel); // selecte the control
+ void select(uint16 sel); // selecte the control
void ghost(bool ghosted);
// virtual void newValue( void );
Commit: ccc350d400a35f0737354177f4bcb97efb4f38c7
https://github.com/scummvm/scummvm/commit/ccc350d400a35f0737354177f4bcb97efb4f38c7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:24+02:00
Commit Message:
SAGA2: Fix more warnings in actor.cpp
Changed paths:
engines/saga2/assign.h
engines/saga2/objects.h
engines/saga2/target.cpp
engines/saga2/target.h
engines/saga2/task.h
diff --git a/engines/saga2/assign.h b/engines/saga2/assign.h
index 39ab595629..9e052f3723 100644
--- a/engines/saga2/assign.h
+++ b/engines/saga2/assign.h
@@ -215,8 +215,8 @@ protected:
Task *getTask(TaskStack *ts);
- Target *getTarget(void) const {
- return (Target *)targetMem;
+ const Target *getTarget(void) const {
+ return (const Target *)targetMem;
}
};
@@ -297,8 +297,8 @@ protected:
Task *getTask(TaskStack *ts);
- ActorTarget *getTarget(void) const {
- return (ActorTarget *)targetMem;
+ const ActorTarget *getTarget(void) const {
+ return (const ActorTarget *)targetMem;
}
};
@@ -377,8 +377,8 @@ protected:
Task *getTask(TaskStack *ts);
- ActorTarget *getTarget(void) const {
- return (ActorTarget *)targetMem;
+ const ActorTarget *getTarget(void) const {
+ return (const ActorTarget *)targetMem;
}
};
diff --git a/engines/saga2/objects.h b/engines/saga2/objects.h
index d14b09cbfc..62b2d8e65c 100644
--- a/engines/saga2/objects.h
+++ b/engines/saga2/objects.h
@@ -456,7 +456,7 @@ public:
ProtoObj *proto(void) {
return prototype;
}
- TilePoint getLocation(void) {
+ TilePoint getLocation(void) const {
return _data.location;
}
TilePoint getWorldLocation(void);
diff --git a/engines/saga2/target.cpp b/engines/saga2/target.cpp
index 350bac647a..941c842406 100644
--- a/engines/saga2/target.cpp
+++ b/engines/saga2/target.cpp
@@ -89,11 +89,11 @@ void *constructTarget(void *mem, void *buf) {
return buf;
}
-int32 targetArchiveSize(Target *t) {
+int32 targetArchiveSize(const Target *t) {
return sizeof(int16) + t->archiveSize();
}
-void *archiveTarget(Target *t, void *buf) {
+void *archiveTarget(const Target *t, void *buf) {
*((int16 *)buf) = t->getType();
buf = (int16 *)buf + 1;
diff --git a/engines/saga2/target.h b/engines/saga2/target.h
index c443a314d0..32959abaad 100644
--- a/engines/saga2/target.h
+++ b/engines/saga2/target.h
@@ -57,8 +57,8 @@ class Target;
void deleteTarget(Target *t);
void *constructTarget(void *mem, void *buf);
-int32 targetArchiveSize(Target *t);
-void *archiveTarget(Target *t, void *buf);
+int32 targetArchiveSize(const Target *t);
+void *archiveTarget(const Target *t, void *buf);
/* ===================================================================== *
TargetLocationArray structure
diff --git a/engines/saga2/task.h b/engines/saga2/task.h
index a1e18d64ed..cd17c40987 100644
--- a/engines/saga2/task.h
+++ b/engines/saga2/task.h
@@ -376,7 +376,7 @@ public:
// Determine if the specified task is equivalent to this task
bool operator == (const Task &t) const;
- TilePoint getTarget(void) const {
+ const TilePoint getTarget(void) const {
return targetLoc;
}
@@ -534,7 +534,7 @@ public:
// Determine if the specified task is equivalent to this task
bool operator == (const Task &t) const;
- GameObject *getTarget(void) const {
+ const GameObject *getTarget(void) const {
return targetObj;
}
@@ -572,7 +572,7 @@ public:
// Determine if the specified task is equivalent to this task
bool operator == (const Task &t) const;
- Actor *getTarget(void) const {
+ const Actor *getTarget(void) const {
return targetActor;
}
@@ -706,8 +706,8 @@ public:
private:
TilePoint getRepulsionVector(void);
- ActorTarget *getTarget(void) const {
- return (ActorTarget *)targetMem;
+ const ActorTarget *getTarget(void) const {
+ return (const ActorTarget *)targetMem;
}
};
@@ -801,8 +801,8 @@ protected:
GotoTask *setupGoto(void);
TilePoint currentTargetLoc(void);
- Target *getTarget(void) const {
- return (Target *)targetMem;
+ const Target *getTarget(void) const {
+ return (const Target *)targetMem;
}
};
@@ -890,8 +890,8 @@ protected:
GotoTask *setupGoto(void);
TilePoint currentTargetLoc(void);
- ObjectTarget *getTarget(void) const {
- return (ObjectTarget *)targetMem;
+ const ObjectTarget *getTarget(void) const {
+ return (const ObjectTarget *)targetMem;
}
};
@@ -1038,8 +1038,8 @@ protected:
GotoTask *setupGoto(void);
TilePoint currentTargetLoc(void);
- ActorTarget *getTarget(void) const {
- return (ActorTarget *)targetMem;
+ const ActorTarget *getTarget(void) const {
+ return (const ActorTarget *)targetMem;
}
bool tracking(void) const {
Commit: 1cc521808f1426426f7d6592642daa54bb77f900
https://github.com/scummvm/scummvm/commit/1cc521808f1426426f7d6592642daa54bb77f900
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:24+02:00
Commit Message:
SAGA2: Fix double free
Changed paths:
engines/saga2/objects.cpp
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index bff0abd795..2a92794fd8 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -1817,8 +1817,7 @@ bool GameObject::addTimer(TimerID id, int16 frameInterval) {
assert((*it)->getObject() == this);
if (newTimer->thisID() == (*it)->thisID()) {
- timerList->_timers.remove(*it);
- delete *it;
+ timerList->_timers.erase(it);
break;
}
@@ -1840,7 +1839,7 @@ void GameObject::removeTimer(TimerID id) {
if ((timerList = fetchTimerList(this)) != nullptr) {
for (Common::List<Timer *>::iterator it = timerList->_timers.begin(); it != timerList->_timers.end(); ++it) {
if ((*it)->thisID() == id) {
- timerList->_timers.remove(*it);
+ timerList->_timers.erase(it);
if (timerList->_timers.empty())
delete timerList;
Commit: d2958083637f0dd3e8f9e5cbffe6a8fd8e7cbdf5
https://github.com/scummvm/scummvm/commit/d2958083637f0dd3e8f9e5cbffe6a8fd8e7cbdf5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:25+02:00
Commit Message:
SAGA2: Fix warnings in objects.cpp
Changed paths:
engines/saga2/interp.cpp
engines/saga2/objects.cpp
engines/saga2/objects.h
engines/saga2/sagafunc.cpp
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index ee4fd48ef9..eb572cbac8 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -501,7 +501,7 @@ int16 RRandom(int16 c, int16 s, int16 id) {
/* ============================================================================ *
Main interpreter
* ============================================================================ */
-void print_script_name(uint8 *codePtr, char *descr = NULL) {
+void print_script_name(uint8 *codePtr, const char *descr = NULL) {
char scriptName[32];
uint8 *sym = codePtr - 1;
uint8 length = MIN<uint>(*sym, sizeof scriptName - 1);
@@ -515,7 +515,7 @@ void print_script_name(uint8 *codePtr, char *descr = NULL) {
debugC(1, kDebugScripts, "Scripts: %d op_enter: ::%s ", lastExport, scriptName);
}
-char *objectName(int16 segNum, uint16 segOff) {
+const char *objectName(int16 segNum, uint16 segOff) {
//static nameBuf[64];
if (segNum >= 0)
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 2a92794fd8..9678554d7e 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -436,8 +436,6 @@ void GameObject::append(ObjectID newParent) {
// one, so we need to get the right one.
headPtr = getHeadPtr(newParent, _data.location);
- GameObject *parent = GameObject::objectAddress(newParent);
-
// Link us in to the parent's chain
_data.parentID = newParent;
@@ -1474,8 +1472,9 @@ void GameObject::updateState(void) {
Object Names
* ======================================================================= */
-char *GameObject::nameText(uint16 index) {
- if (index < 0 || index >= nameListCount) return "Bad Name Index";
+const char *GameObject::nameText(uint16 index) {
+ if (index < 0 || index >= nameListCount)
+ return "Bad Name Index";
return nameList[index];
}
@@ -1483,7 +1482,6 @@ char *GameObject::nameText(uint16 index) {
#define INTANGIBLE_MASK (ProtoObj::isEnchantment|ProtoObj::isSpell|ProtoObj::isSkill)
TilePoint GameObject::getFirstEmptySlot(GameObject *obj) {
- int16 slotCount = 0;
ObjectID objID;
GameObject *item;
TilePoint newLoc, temp;
@@ -1795,8 +1793,7 @@ bool GameObject::addTimer(TimerID id) {
bool GameObject::addTimer(TimerID id, int16 frameInterval) {
TimerList *timerList;
- Timer *newTimer,
- *timerInList;
+ Timer *newTimer;
// Create the new timer
if ((newTimer = new Timer(this, id, frameInterval)) == nullptr)
@@ -1874,7 +1871,6 @@ void GameObject::removeAllTimers(void) {
bool GameObject::addSensor(Sensor *newSensor) {
SensorList *sensorList;
- Sensor *sensorInList;
// Fetch the existing sensor list for this object or allocate a
// new one
@@ -2078,11 +2074,11 @@ bool GameObject::canSenseSpecificActor(
SenseInfo &info,
int16 range,
Actor *a) {
- SpecificActorSensor sensor(this, 0, range, a);
+ SpecificActorSensor sensor(this, 0, range, a);
if (isActor(this)) {
- Actor *a = (Actor *) this;
- return sensor.check(info, a->enchantmentFlags);
+ Actor *ac = (Actor *)this;
+ return sensor.check(info, ac->enchantmentFlags);
}
return sensor.check(info, nonActorSenseFlags);
}
diff --git a/engines/saga2/objects.h b/engines/saga2/objects.h
index 62b2d8e65c..e6763e4ea6 100644
--- a/engines/saga2/objects.h
+++ b/engines/saga2/objects.h
@@ -173,7 +173,7 @@ public:
ObjectID thisID(void); // calculate our own ID value
- static char *nameText(uint16 index);
+ static const char *nameText(uint16 index);
protected:
// get address of head-of-chain id.
@@ -465,7 +465,7 @@ public:
Location notGetWorldLocation(void);
// Return the name of this object (proper noun if it has one)
- char *objName(void) {
+ const char *objName(void) {
return nameText((int16)(
_data.nameIndex > 0 ? _data.nameIndex : prototype->nameIndex));
}
@@ -485,7 +485,7 @@ public:
}
// Return the name of this type of object
- char *protoName(void) {
+ const char *protoName(void) {
return nameText(prototype->nameIndex);
}
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index c064e63e61..97b6c0f5cf 100644
--- a/engines/saga2/sagafunc.cpp
+++ b/engines/saga2/sagafunc.cpp
@@ -114,8 +114,8 @@ int stringf(char *buffer, long maxlen, int formatStr, int16 *args) {
GameObject *obj = GameObject::objectAddress(*args++);
// Obtain SAGA string, copy to buffer (if it fits)
- for (dptr = obj->objName(); *dptr && buffer < bufEnd;) {
- *buffer++ = *dptr++;
+ for (const char *dptr1 = obj->objName(); *dptr1 && buffer < bufEnd;) {
+ *buffer++ = *dptr1++;
}
} else {
// Write the character after the '%' to the buffer
Commit: 7e73510bb4760b22a305f7403ab01dc30f592d25
https://github.com/scummvm/scummvm/commit/7e73510bb4760b22a305f7403ab01dc30f592d25
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:25+02:00
Commit Message:
SAGA2: Fix object name loading
Changed paths:
engines/saga2/objects.cpp
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 9678554d7e..668242605c 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -2524,8 +2524,7 @@ void initPrototypes(void) {
debugC(5, kDebugLoading, "Read string (size %d): %s", s.size(), s.c_str());
char *name = new char[s.size() + 1];
- Common::strlcpy(name, s.c_str(), s.size());
- name[s.size()] = '\0';
+ Common::strlcpy(name, s.c_str(), s.size() + 1);
nameList.push_back(name);
}
nameListCount = count;
Commit: 6819c2ae159d881efac7f9133824680a5e037615
https://github.com/scummvm/scummvm/commit/6819c2ae159d881efac7f9133824680a5e037615
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:25+02:00
Commit Message:
SAGA2: Cleanup string copying
Changed paths:
engines/saga2/grabinfo.cpp
engines/saga2/mouseimg.cpp
engines/saga2/objects.cpp
engines/saga2/objects.h
diff --git a/engines/saga2/grabinfo.cpp b/engines/saga2/grabinfo.cpp
index 83146cb279..8a337d77e9 100644
--- a/engines/saga2/grabinfo.cpp
+++ b/engines/saga2/grabinfo.cpp
@@ -322,8 +322,7 @@ void GrabInfo::replaceObject(void) {
// text pointer will simply be saved.
void GrabInfo::setText(const char *txt) {
if ((txt != nullptr) && strlen(txt)) {
- strncpy(textBuf, txt, bufSize);
- textBuf[bufSize - 1] = '\0';
+ Common::strlcpy(textBuf, txt, bufSize);
if (grabObj == nullptr)
setMouseText(textBuf);
} else {
diff --git a/engines/saga2/mouseimg.cpp b/engines/saga2/mouseimg.cpp
index 15c187264a..384ca01330 100644
--- a/engines/saga2/mouseimg.cpp
+++ b/engines/saga2/mouseimg.cpp
@@ -296,8 +296,7 @@ void setNewText(char *text) {
// Dispose of old text image
disposeText();
- strncpy(mouseText, text, maxMouseTextLen - 1);
- mouseText[maxMouseTextLen - 1] = '\0';
+ Common::strlcpy(mouseText, text, maxMouseTextLen);
// Compute the size of the text bitmap
textImage.size.y = mainFont->height + 2;
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 668242605c..0cbfdd5473 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -527,9 +527,7 @@ void GameObject::objCursorText(char nameBuf[], const int8 size, int16 count) {
const int addTextSize = 10;
// put the object name into the buffer as a default value
- strncpy(nameBuf, objName(), size - 1);
- nameBuf[size - 1] = 0;
-
+ Common::strlcpy(nameBuf, objName(), size);
assert(strlen(objName()) < size - addTextSize);
diff --git a/engines/saga2/objects.h b/engines/saga2/objects.h
index e6763e4ea6..1441d04f74 100644
--- a/engines/saga2/objects.h
+++ b/engines/saga2/objects.h
@@ -466,8 +466,7 @@ public:
// Return the name of this object (proper noun if it has one)
const char *objName(void) {
- return nameText((int16)(
- _data.nameIndex > 0 ? _data.nameIndex : prototype->nameIndex));
+ return nameText((int16)(_data.nameIndex > 0 ? _data.nameIndex : prototype->nameIndex));
}
// return name of object, and it's quantity if merged
Commit: d858e593c02a301255342df3670f257761008290
https://github.com/scummvm/scummvm/commit/d858e593c02a301255342df3670f257761008290
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:25+02:00
Commit Message:
SAGA2: Fix tile draw offset
Changed paths:
engines/saga2/blitters.cpp
diff --git a/engines/saga2/blitters.cpp b/engines/saga2/blitters.cpp
index cf7caf1dc5..40c111d743 100644
--- a/engines/saga2/blitters.cpp
+++ b/engines/saga2/blitters.cpp
@@ -201,7 +201,7 @@ void drawTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData, bo
int bgRunCount;
int fgRunCount;
const int32 SAGA_ISOTILE_WIDTH = 64;
- Point16 point(x, y);
+ Point16 point(x - 32, y);
if (point.x + SAGA_ISOTILE_WIDTH < 0)
return;
Commit: 96f883650f099fbad3e418b303e1ba382e83bc6d
https://github.com/scummvm/scummvm/commit/96f883650f099fbad3e418b303e1ba382e83bc6d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:25+02:00
Commit Message:
SAGA2: Cleanup mouseimg.cpp
Changed paths:
engines/saga2/mouseimg.cpp
diff --git a/engines/saga2/mouseimg.cpp b/engines/saga2/mouseimg.cpp
index 384ca01330..fe864e8158 100644
--- a/engines/saga2/mouseimg.cpp
+++ b/engines/saga2/mouseimg.cpp
@@ -32,13 +32,15 @@
namespace Saga2 {
-const int gaugeWidth = 46,
- gaugeImageWidth = gaugeWidth + 2,
- gaugeImageHeight = 5,
- gaugeOneThird = gaugeWidth / 3,
- gaugeTwoThirds = gaugeWidth * 2 / 3;
+enum {
+ gaugeWidth = 46,
+ gaugeImageWidth = gaugeWidth + 2,
+ gaugeImageHeight = 5,
+ gaugeOneThird = gaugeWidth / 3,
+ gaugeTwoThirds = gaugeWidth * 2 / 3
+};
-extern gFont *mainFont;
+extern gFont *mainFont;
extern uint8 *closeBx1ImageData;
extern uint8 *closeBx2ImageData;
@@ -60,29 +62,29 @@ extern uint8 *gaugeImageData;
Globals
* ===================================================================== */
-const int maxMouseTextLen = 80;
+const int maxMouseTextLen = 80;
-static char mouseText[maxMouseTextLen] = { "" }; // Current mouse text string
+static char mouseText[maxMouseTextLen] = { "" }; // Current mouse text string
-static Point16 mouseImageOffset; // Hotspot on mouse image
+static Point16 mouseImageOffset; // Hotspot on mouse image
-static gPixelMap *mouseImage = mouseCursors[kMouseArrowImage]; // Current mouse cursor image
+static gPixelMap *mouseImage = mouseCursors[kMouseArrowImage]; // Current mouse cursor image
static gStaticImage textImage(0, 0, nullptr), // Current mouse text image
combinedImage(0, 0, nullptr); // Combine mouse text
// and image
-static int textImageCenteredCol; // The pixel column in the text
+static int textImageCenteredCol; // The pixel column in the text
// image to be centered under
// the mouse pointer
-static int gaugeNumerator, // Current mouse gauge values
+static int gaugeNumerator, // Current mouse gauge values
gaugeDenominator;
-static uint8 gaugeGrayMap[7] =
+static uint8 gaugeGrayMap[7] =
{ 0x00, 0x18, 0x14, 0x12, 0x16, 0x17, 0x0E }; // Gray
-static uint8 gaugeColorMapArray[3][7] = {
+static uint8 gaugeColorMapArray[3][7] = {
{ 0x00, 0x18, 0xE2, 0xD1, 0xE5, 0xE7, 0xC9 }, // Green
{ 0x00, 0x18, 0x5C, 0x5A, 0x5E, 0x60, 0x49 }, // Yellow
{ 0x00, 0x18, 0x83, 0x81, 0x86, 0x72, 0x39 }, // Red
@@ -111,10 +113,10 @@ static struct MouseCurosrs {
gStaticImage *mouseCursors[kMouseMax];
-static uint8 gaugeImageBuffer[gaugeImageWidth * gaugeImageHeight];
+static uint8 gaugeImageBuffer[gaugeImageWidth * gaugeImageHeight];
static gStaticImage gaugeImage(gaugeImageWidth, gaugeImageHeight, gaugeImageBuffer);
-static bool showGauge = false;
+static bool showGauge = false;
/* ===================================================================== *
Functions
@@ -133,57 +135,43 @@ void freeCursors() {
delete mouseCursors[i];
}
-
-void createStackedImage(
- gPixelMap *newImage,
- int *newImageCenter,
- gPixelMap **imageArray,
- int *imageCenterArray,
- int images) {
+void createStackedImage(gPixelMap *newImage, int *newImageCenter, gPixelMap **imageArray, int *imageCenterArray, int images) {
assert(images != 0);
assert(newImage->data == nullptr);
- int i;
- int newImageBytes,
- newImageRow;
-
newImage->size.x = 0;
newImage->size.y = 0;
*newImageCenter = 0;
- for (i = 0; i < images; i++) {
+ for (int i = 0; i < images; i++) {
if (imageCenterArray[i] > *newImageCenter)
*newImageCenter = imageCenterArray[i];
}
- for (i = 0; i < images; i++) {
- int16 rightImageBoundary;
+ for (int i = 0; i < images; i++) {
+ int16 rightImageBoundary;
newImage->size.y += imageArray[i]->size.y;
- rightImageBoundary = *newImageCenter
- + (imageArray[i]->size.x
- - imageCenterArray[i]);
+ rightImageBoundary = *newImageCenter + (imageArray[i]->size.x - imageCenterArray[i]);
+
if (rightImageBoundary > newImage->size.x)
newImage->size.x = rightImageBoundary;
}
newImage->size.y += images - 1;
- newImageBytes = newImage->bytes();
+
+ int newImageBytes = newImage->bytes();
newImage->data = (uint8 *)malloc(newImageBytes) ;
memset(newImage->data, 0, newImageBytes);
- newImageRow = 0;
- for (i = 0; i < images; i++) {
- gPixelMap *currentImage = imageArray[i];
+ int newImageRow = 0;
+ for (int i = 0; i < images; i++) {
+ gPixelMap *currentImage = imageArray[i];
- TBlit(
- newImage,
- currentImage,
- *newImageCenter - imageCenterArray[i],
- newImageRow);
+ TBlit(newImage, currentImage, *newImageCenter - imageCenterArray[i], newImageRow);
newImageRow += currentImage->size.y + 1;
}
@@ -210,19 +198,21 @@ void cleanupMousePointer(void) {
}
void setupMousePointer(void) {
- int imageIndex = 1;
- gPixelMap *imageArray[3];
- int imageCenterArray[3];
- Point16 imageOffset; // mouse image offset
- int combinedImageCenter;
+ int imageIndex = 1;
+ gPixelMap *imageArray[3];
+ int imageCenterArray[3];
+ Point16 imageOffset; // mouse image offset
+ int combinedImageCenter;
imageArray[0] = mouseImage;
imageCenterArray[0] = mouseImage->size.x / 2;
+
if (mouseText[0] != '\0') {
imageArray[imageIndex] = &textImage;
imageCenterArray[imageIndex] = textImageCenteredCol;
imageIndex++;
}
+
if (showGauge) {
imageArray[imageIndex] = &gaugeImage;
imageCenterArray[imageIndex] = gaugeImage.size.x / 2;
@@ -232,22 +222,14 @@ void setupMousePointer(void) {
if (combinedImage.data != nullptr)
disposeStackedImage(&combinedImage);
- createStackedImage(
- &combinedImage,
- &combinedImageCenter,
- imageArray,
- imageCenterArray,
- imageIndex);
+ createStackedImage(&combinedImage, &combinedImageCenter, imageArray, imageCenterArray, imageIndex);
imageOffset.x = combinedImageCenter - mouseImage->size.x / 2;
imageOffset.y = 0;
// Set the combined image as the new mouse cursor
pointer.hide();
- pointer.setImage(
- combinedImage,
- mouseImageOffset.x - imageOffset.x,
- mouseImageOffset.y - imageOffset.y);
+ pointer.setImage(combinedImage, mouseImageOffset.x - imageOffset.x, mouseImageOffset.y - imageOffset.y);
pointer.show();
}
@@ -289,10 +271,6 @@ inline void disposeText(void) {
// Build a new text image
void setNewText(char *text) {
- Point16 mousePos;
- int16 textImageBytes; // Bytes needed to hold the text image bitmap
- int mouseImageCenter;
-
// Dispose of old text image
disposeText();
@@ -303,11 +281,12 @@ void setNewText(char *text) {
textImage.size.x = TextWidth(mainFont, text, -1, 0) + 2;
// Allocate a new buffer for the text image bitmap
- textImageBytes = textImage.bytes();
+ int16 textImageBytes = textImage.bytes();
+
textImage.data = (uint8 *)malloc(textImageBytes);
memset(textImage.data, 0, textImageBytes);
- gPort textImagePort; // gPort used to draw text onto bitmap
+ gPort textImagePort; // gPort used to draw text onto bitmap
// Intialize the text image port
textImagePort.setMap(&textImage);
@@ -322,16 +301,15 @@ void setNewText(char *text) {
textImagePort.drawText(text, -1);
// Compute relative position of text
+ Point16 mousePos;
pointer.getImageCurPos(mousePos);
- mouseImageCenter = mousePos.x + mouseImageOffset.x + mouseImage->size.x / 2;
+
+ int mouseImageCenter = mousePos.x + mouseImageOffset.x + mouseImage->size.x / 2;
textImageCenteredCol = textImage.size.x / 2;
if (mouseImageCenter - textImageCenteredCol < 5) {
textImageCenteredCol = mouseImageCenter - 5;
- } else if (mouseImageCenter
- + (textImage.size.x - textImageCenteredCol)
- >= screenWidth - 5) {
- textImageCenteredCol = textImage.size.x
- - ((screenWidth - 5) - mouseImageCenter);
+ } else if (mouseImageCenter + (textImage.size.x - textImageCenteredCol) >= screenWidth - 5) {
+ textImageCenteredCol = textImage.size.x - ((screenWidth - 5) - mouseImageCenter);
}
}
@@ -353,7 +331,7 @@ void setMouseText(char *text) {
// Formatted version of setMouseText, for gTools use...
void setMouseTextF(char *format, ...) {
- extern gToolBase G_BASE;
+ extern gToolBase G_BASE;
if (format == nullptr) {
setMouseText(nullptr);
@@ -379,20 +357,15 @@ void setMouseGauge(int numerator, int denominator) {
assert(denominator != 0);
assert(numerator <= denominator);
- if (showGauge
- && numerator == gaugeNumerator
- && denominator == gaugeDenominator)
+ if (showGauge && numerator == gaugeNumerator && denominator == gaugeDenominator)
return;
- int gaugePos,
- x, y,
- gaugeImageIndex = 0;
- uint8 *gaugeColorMap;
-
gaugeNumerator = numerator;
gaugeDenominator = denominator;
- gaugePos = (numerator * gaugeWidth + denominator - 1) / denominator;
+ int gaugePos = (numerator * gaugeWidth + denominator - 1) / denominator;
+
+ uint8 *gaugeColorMap;
if (gaugePos <= gaugeOneThird)
gaugeColorMap = gaugeColorMapArray[2];
@@ -401,14 +374,13 @@ void setMouseGauge(int numerator, int denominator) {
else
gaugeColorMap = gaugeColorMapArray[0];
- for (y = 0; y < gaugeImageHeight; y++) {
- for (x = 0; x < gaugeImageWidth; x++) {
- uint8 *gaugeMap;
+ int gaugeImageIndex = 0;
- gaugeMap = x < gaugePos + 1 ? gaugeColorMap : gaugeGrayMap;
+ for (int y = 0; y < gaugeImageHeight; y++) {
+ for (int x = 0; x < gaugeImageWidth; x++) {
+ uint8 *gaugeMap = x < gaugePos + 1 ? gaugeColorMap : gaugeGrayMap;
- gaugeImageBuffer[gaugeImageIndex] =
- gaugeMap[mouseCursors[kMouseGaugeImage]->data[gaugeImageIndex]];
+ gaugeImageBuffer[gaugeImageIndex] = gaugeMap[mouseCursors[kMouseGaugeImage]->data[gaugeImageIndex]];
gaugeImageIndex++;
}
Commit: 254540bc9d580e1f23cf38d9842bad599cc3d09f
https://github.com/scummvm/scummvm/commit/254540bc9d580e1f23cf38d9842bad599cc3d09f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:25+02:00
Commit Message:
SAGA2: Remove mouse polling warning
Changed paths:
engines/saga2/tile.cpp
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index b78103103c..ee8a33d2c6 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -2689,11 +2689,6 @@ inline void drawMetaRow(TilePoint coords, Point16 pos) {
int16 layerLimit;
- // Poll the mouse so that we can detect double-clicks
- //PollMouse();
- warning("STUB: Check if we need to poll mouse here");
-
-
for (;
pos.x < tileDrawMap.size.x + kMetaDX;
coords.u++,
Commit: e49f37f2300be099534fb70c175599d9cce7cf26
https://github.com/scummvm/scummvm/commit/e49f37f2300be099534fb70c175599d9cce7cf26
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:25+02:00
Commit Message:
SAGA2: Fix platform cacheing
Changed paths:
engines/saga2/tile.cpp
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index ee8a33d2c6..21aa237929 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -2334,10 +2334,7 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
assert(pce->platformNum >= 0);
assert(pce->metaID != NoMetaTile);
- if (pce->metaID != thisID(mapNum))
- warning("fetchPlatform: pce->metaID (%d, %d) != thisID(mapNum) (%d, %d)",
- pce->metaID.index, pce->metaID.map,
- thisID(mapNum).index, thisID(mapNum).map);
+ assert(pce->metaID == thisID(mapNum));
// Move to the end of the LRU
platformLRU.remove(plIndex);
@@ -2362,6 +2359,15 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
assert(cacheIndex < platformCacheSize);
assert(cacheIndex >= 0);
+ if (pce->metaID != NoMetaTile)
+ {
+ MetaTile *oldMeta = metaTileAddress(pce->metaID);
+
+ assert(pce->layerNum < maxPlatforms);
+ assert(oldMeta->_stack[pce->layerNum] == (cacheFlag | cacheIndex));
+ oldMeta->_stack[pce->layerNum] = pce->platformNum;
+ }
+
// Initialize the cache entry to the new platform data.
pce->platformNum = plIndex;
pce->layerNum = layer;
Commit: f7fcec7b62b4982747a66ff07e9e90ae630191d8
https://github.com/scummvm/scummvm/commit/f7fcec7b62b4982747a66ff07e9e90ae630191d8
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:25+02:00
Commit Message:
SAGA2: Fix code formatting
Changed paths:
engines/saga2/tile.cpp
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 21aa237929..56b0df913b 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -2359,8 +2359,7 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
assert(cacheIndex < platformCacheSize);
assert(cacheIndex >= 0);
- if (pce->metaID != NoMetaTile)
- {
+ if (pce->metaID != NoMetaTile) {
MetaTile *oldMeta = metaTileAddress(pce->metaID);
assert(pce->layerNum < maxPlatforms);
Commit: 054f0d487057b0626a22ee7f0e942465f951204f
https://github.com/scummvm/scummvm/commit/054f0d487057b0626a22ee7f0e942465f951204f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:26+02:00
Commit Message:
SAGA2: Fix warnings in tile.cpp
Changed paths:
engines/saga2/idtypes.h
engines/saga2/tile.cpp
diff --git a/engines/saga2/idtypes.h b/engines/saga2/idtypes.h
index 923e3428f7..4d013b15ae 100644
--- a/engines/saga2/idtypes.h
+++ b/engines/saga2/idtypes.h
@@ -50,7 +50,7 @@ const ObjectID Nothing = 0, // a reference to no object
typedef uint16 TileID;
-const int nullID = 0xffff;
+const int16 nullID = -1;
/* ===================================================================== *
PlayerActorID
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 56b0df913b..5faf49c181 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -1947,7 +1947,7 @@ TileInfo *Platform::fetchTile(
int16 mapNum,
const TilePoint &pt,
const TilePoint &origin,
- int16 &height,
+ int16 &height_,
int16 &trFlags) {
TileRef *tr = &tiles[pt.u][pt.v];
TileInfo *ti;
@@ -2005,7 +2005,7 @@ TileInfo *Platform::fetchTile(
if ((ti = TileInfo::tileAddress(tr->tile)) == nullptr) return nullptr;
trFlags = tr->flags;
- height = h;
+ height_ = h;
#if DEBUG
if (ti->offset > maxOffset
@@ -2104,7 +2104,7 @@ TileInfo *Platform::fetchTile(
const TilePoint &pt,
const TilePoint &origin,
uint8 **imageData,
- int16 &height,
+ int16 &height_,
int16 &trFlags) {
TileRef *tr = &tiles[pt.u][pt.v];
TileInfo *ti;
@@ -2162,7 +2162,7 @@ TileInfo *Platform::fetchTile(
if ((ti = TileInfo::tileAddress(tr->tile, imageData)) == nullptr) return nullptr;
trFlags = tr->flags;
- height = h;
+ height_ = h;
#if DEBUG
if (ti->offset > maxOffset
@@ -2322,7 +2322,7 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
assert(layer >= 0);
assert(_parent == mapList[mapNum].metaList);
- if (plIndex == nullID) {
+ if (plIndex == (uint16)nullID) {
return nullptr;
} else if (plIndex & cacheFlag) {
plIndex &= ~cacheFlag;
Commit: 92a0ec784b4f3fdf6c2252d2651a2e143cea00b6
https://github.com/scummvm/scummvm/commit/92a0ec784b4f3fdf6c2252d2651a2e143cea00b6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:26+02:00
Commit Message:
SAGA2: Fix warnings in target.cpp
Changed paths:
engines/saga2/target.cpp
diff --git a/engines/saga2/target.cpp b/engines/saga2/target.cpp
index 941c842406..a10f5255cd 100644
--- a/engines/saga2/target.cpp
+++ b/engines/saga2/target.cpp
@@ -214,7 +214,7 @@ void LocationTarget::clone(void *mem) const {
bool LocationTarget::operator == (const Target &t) const {
if (t.getType() != locationTarget) return false;
- LocationTarget *targetPtr = (LocationTarget *)&t;
+ const LocationTarget *targetPtr = (const LocationTarget *)&t;
return *this == *targetPtr;
}
@@ -241,7 +241,7 @@ int16 LocationTarget::where(
TilePoint TileTarget::where(GameWorld *world, const TilePoint &tp) const {
uint16 bestDist = maxuint16;
- TileInfo *ti;
+ TileInfo *ti;
TilePoint tileCoords,
bestTCoords = Nowhere;
TileRegion tileReg;
@@ -297,7 +297,7 @@ int16 TileTarget::where(
GameWorld *world,
const TilePoint &tp,
TargetLocationArray &tla) const {
- TileInfo *ti;
+ TileInfo *ti;
TilePoint tileCoords;
TileRegion tileReg;
StandingTileInfo sti;
@@ -408,7 +408,7 @@ void SpecificTileTarget::clone(void *mem) const {
bool SpecificTileTarget::operator == (const Target &t) const {
if (t.getType() != specificTileTarget) return false;
- SpecificTileTarget *targetPtr = (SpecificTileTarget *)&t;
+ const SpecificTileTarget *targetPtr = (const SpecificTileTarget *)&t;
return tile == targetPtr->tile;
}
@@ -477,7 +477,7 @@ void TilePropertyTarget::clone(void *mem) const {
bool TilePropertyTarget::operator == (const Target &t) const {
if (t.getType() != tilePropertyTarget) return false;
- TilePropertyTarget *targetPtr = (TilePropertyTarget *)&t;
+ const TilePropertyTarget *targetPtr = (const TilePropertyTarget *)&t;
return tileProp == targetPtr->tileProp;
}
@@ -494,7 +494,7 @@ TilePoint MetaTileTarget::where(
GameWorld *world,
const TilePoint &tp) const {
uint16 bestDist = maxuint16;
- MetaTile *mt;
+ MetaTile *mt;
TilePoint metaCoords,
bestMCoords = Nowhere;
TileRegion tileReg;
@@ -549,7 +549,7 @@ int16 MetaTileTarget::where(
GameWorld *world,
const TilePoint &tp,
TargetLocationArray &tla) const {
- MetaTile *mt;
+ MetaTile *mt;
TilePoint metaCoords;
TileRegion tileReg;
@@ -660,7 +660,7 @@ void SpecificMetaTileTarget::clone(void *mem) const {
bool SpecificMetaTileTarget::operator == (const Target &t) const {
if (t.getType() != specificMetaTileTarget) return false;
- SpecificMetaTileTarget *targetPtr = (SpecificMetaTileTarget *)&t;
+ const SpecificMetaTileTarget *targetPtr = (const SpecificMetaTileTarget *)&t;
return meta == targetPtr->meta;
}
@@ -733,7 +733,7 @@ void MetaTilePropertyTarget::clone(void *mem) const {
bool MetaTilePropertyTarget::operator == (const Target &t) const {
if (t.getType() != metaTilePropertyTarget) return false;
- MetaTilePropertyTarget *targetPtr = (MetaTilePropertyTarget *)&t;
+ const MetaTilePropertyTarget *targetPtr = (const MetaTilePropertyTarget *)&t;
return metaProp == targetPtr->metaProp;
}
@@ -795,7 +795,7 @@ void ObjectTarget::searchObject(
// objects
if (objPtr->IDChild() != Nothing) {
ContainerIterator iter(objPtr);
- GameObject *childPtr;
+ GameObject *childPtr;
while (iter.next(&childPtr) != Nothing)
searchObject(childPtr, dist, toa);
@@ -815,7 +815,7 @@ void ObjectTarget::searchObject(
// objects
if (objPtr->IDChild() != Nothing) {
ContainerIterator iter(objPtr);
- GameObject *childPtr;
+ GameObject *childPtr;
while (iter.next(&childPtr) != Nothing)
searchObject(childPtr, tp, dist, tla);
@@ -829,7 +829,7 @@ bool ObjectTarget::isObjectTarget(void) const {
TilePoint ObjectTarget::where(GameWorld *world, const TilePoint &tp) const {
int16 dist,
bestDist = maxint16;
- GameObject *objPtr;
+ GameObject *objPtr;
TilePoint objCoords,
bestOCoords = Nowhere;
CircularObjectIterator iter(world, tp, maxObjDist);
@@ -876,7 +876,7 @@ int16 ObjectTarget::where(
TargetLocationArray &tla) const {
CircularObjectIterator objIter(world, tp, maxObjDist);
- GameObject *objPtr;
+ GameObject *objPtr;
ObjectID id;
int16 dist;
@@ -896,8 +896,8 @@ GameObject *ObjectTarget::object(
const TilePoint &tp) const {
CircularObjectIterator objIter(world, tp, maxObjDist);
- GameObject *objPtr,
- *bestObj = NULL;
+ GameObject *objPtr,
+ *bestObj = NULL;
int16 dist,
bestDist = maxint16;
@@ -942,7 +942,7 @@ int16 ObjectTarget::object(
TargetObjectArray &toa) const {
CircularObjectIterator objIter(world, tp, maxObjDist);
- GameObject *objPtr;
+ GameObject *objPtr;
ObjectID id;
int16 dist;
@@ -1018,7 +1018,7 @@ void SpecificObjectTarget::clone(void *mem) const {
bool SpecificObjectTarget::operator == (const Target &t) const {
if (t.getType() != specificObjectTarget) return false;
- SpecificObjectTarget *targetPtr = (SpecificObjectTarget *)&t;
+ const SpecificObjectTarget *targetPtr = (const SpecificObjectTarget *)&t;
return obj == targetPtr->obj;
}
@@ -1038,7 +1038,7 @@ bool SpecificObjectTarget::isTarget(GameObject *testObj) const {
TilePoint SpecificObjectTarget::where(
GameWorld *world,
const TilePoint &tp) const {
- GameObject *o = GameObject::objectAddress(obj);
+ GameObject *o = GameObject::objectAddress(obj);
if (o->world() == world) {
TilePoint objLoc = o->getLocation();
@@ -1058,7 +1058,7 @@ int16 SpecificObjectTarget::where(
GameWorld *world,
const TilePoint &tp,
TargetLocationArray &tla) const {
- GameObject *o = GameObject::objectAddress(obj);
+ GameObject *o = GameObject::objectAddress(obj);
if (tla.size > 0 && o->world() == world) {
TilePoint objLoc = o->getLocation();
@@ -1083,7 +1083,7 @@ int16 SpecificObjectTarget::where(
GameObject *SpecificObjectTarget::object(
GameWorld *world,
const TilePoint &tp) const {
- GameObject *o = GameObject::objectAddress(obj);
+ GameObject *o = GameObject::objectAddress(obj);
if (o->world() == world) {
if ((tp - o->getLocation()).quickHDistance() < maxObjDist)
@@ -1101,7 +1101,7 @@ int16 SpecificObjectTarget::object(
GameWorld *world,
const TilePoint &tp,
TargetObjectArray &toa) const {
- GameObject *o = GameObject::objectAddress(obj);
+ GameObject *o = GameObject::objectAddress(obj);
if (toa.size > 0 && o->world() == world) {
int16 dist = (tp - o->getLocation()).quickHDistance();
@@ -1179,7 +1179,7 @@ void ObjectPropertyTarget::clone(void *mem) const {
bool ObjectPropertyTarget::operator == (const Target &t) const {
if (t.getType() != objectPropertyTarget) return false;
- ObjectPropertyTarget *targetPtr = (ObjectPropertyTarget *)&t;
+ const ObjectPropertyTarget *targetPtr = (const ObjectPropertyTarget *)&t;
return objProp == targetPtr->objProp;
}
@@ -1290,7 +1290,7 @@ void SpecificActorTarget::clone(void *mem) const {
bool SpecificActorTarget::operator == (const Target &t) const {
if (t.getType() != specificActorTarget) return false;
- SpecificActorTarget *targetPtr = (SpecificActorTarget *)&t;
+ const SpecificActorTarget *targetPtr = (const SpecificActorTarget *)&t;
return a == targetPtr->a;
}
@@ -1428,7 +1428,7 @@ int16 SpecificActorTarget::actor(
// Constructor -- reconstruct from archive buffer
ActorPropertyTarget::ActorPropertyTarget(void **buf) {
- ActorPropertyID *bufferPtr = (ActorPropertyID *)*buf;
+ ActorPropertyID *bufferPtr = (ActorPropertyID *)*buf;
// Restore the ActorPropertyID
actorProp = *bufferPtr;
@@ -1481,7 +1481,7 @@ void ActorPropertyTarget::clone(void *mem) const {
bool ActorPropertyTarget::operator == (const Target &t) const {
if (t.getType() != actorPropertyTarget) return false;
- ActorPropertyTarget *targetPtr = (ActorPropertyTarget *)&t;
+ const ActorPropertyTarget *targetPtr = (const ActorPropertyTarget *)&t;
return actorProp == targetPtr->actorProp;
}
Commit: 485cdce8eb277639bad69113ac6f28e579abd0dc
https://github.com/scummvm/scummvm/commit/485cdce8eb277639bad69113ac6f28e579abd0dc
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:26+02:00
Commit Message:
SAGA2: Fix more warnings
Changed paths:
engines/saga2/task.cpp
engines/saga2/tower.cpp
diff --git a/engines/saga2/task.cpp b/engines/saga2/task.cpp
index 6b8a73a86c..e939db0bd1 100644
--- a/engines/saga2/task.cpp
+++ b/engines/saga2/task.cpp
@@ -1123,7 +1123,7 @@ void TetheredWanderTask::abortTask(void) {
bool TetheredWanderTask::operator == (const Task &t) const {
if (t.getType() != tetheredWanderTask) return false;
- TetheredWanderTask *taskPtr = (TetheredWanderTask *)&t;
+ const TetheredWanderTask *taskPtr = (const TetheredWanderTask *)&t;
return minU == taskPtr->minU && minV == taskPtr->minV
&& maxU == taskPtr->maxU && maxV == taskPtr->maxV;
@@ -1157,12 +1157,12 @@ TaskResult TetheredWanderTask::handleWander(void) {
MotionTask *actorMotion = a->moveTask;
if (actorMotion) {
- TileRegion motionTether = actorMotion->getTether();
+ TileRegion motionTeth = actorMotion->getTether();
startWander = ((!actorMotion->isWander())
- || motionTether.min.u != minU
- || motionTether.min.v != minV
- || motionTether.max.u != maxU
- || motionTether.max.v != maxV);
+ || motionTeth.min.u != minU
+ || motionTeth.min.v != minV
+ || motionTeth.max.u != maxU
+ || motionTeth.max.v != maxV);
} else
startWander = true;
@@ -1437,7 +1437,7 @@ int16 GotoLocationTask::getType(void) const {
bool GotoLocationTask::operator == (const Task &t) const {
if (t.getType() != gotoLocationTask) return false;
- GotoLocationTask *taskPtr = (GotoLocationTask *)&t;
+ const GotoLocationTask *taskPtr = (const GotoLocationTask *)&t;
return targetLoc == taskPtr->targetLoc
&& runThreshold == taskPtr->runThreshold;
@@ -1538,7 +1538,7 @@ int16 GotoRegionTask::getType(void) const {
bool GotoRegionTask::operator == (const Task &t) const {
if (t.getType() != gotoRegionTask) return false;
- GotoRegionTask *taskPtr = (GotoRegionTask *)&t;
+ const GotoRegionTask *taskPtr = (const GotoRegionTask *)&t;
return regionMinU == taskPtr->regionMinU
&& regionMinV == taskPtr->regionMinV
@@ -1777,7 +1777,7 @@ int16 GotoObjectTask::getType(void) const {
bool GotoObjectTask::operator == (const Task &t) const {
if (t.getType() != gotoObjectTask) return false;
- GotoObjectTask *taskPtr = (GotoObjectTask *)&t;
+ const GotoObjectTask *taskPtr = (const GotoObjectTask *)&t;
return tracking() == taskPtr->tracking()
&& targetObj == taskPtr->targetObj;
@@ -1851,7 +1851,7 @@ int16 GotoActorTask::getType(void) const {
bool GotoActorTask::operator == (const Task &t) const {
if (t.getType() != gotoActorTask) return false;
- GotoActorTask *taskPtr = (GotoActorTask *)&t;
+ const GotoActorTask *taskPtr = (const GotoActorTask *)&t;
return tracking() == taskPtr->tracking()
&& targetActor == taskPtr->targetActor;
@@ -1985,7 +1985,6 @@ TaskResult GoAwayFromTask::update(void) {
};
Actor *a = stack->getActor();
- MotionTask *actorMotion = a->moveTask;
TilePoint actorLoc = a->getLocation(),
repulsionVector = getRepulsionVector(),
dest;
@@ -2078,7 +2077,7 @@ int16 GoAwayFromObjectTask::getType(void) const {
bool GoAwayFromObjectTask::operator == (const Task &t) const {
if (t.getType() != goAwayFromObjectTask) return false;
- GoAwayFromObjectTask *taskPtr = (GoAwayFromObjectTask *)&t;
+ const GoAwayFromObjectTask *taskPtr = (const GoAwayFromObjectTask *)&t;
return obj == taskPtr->obj;
}
@@ -2158,7 +2157,7 @@ int16 GoAwayFromActorTask::getType(void) const {
bool GoAwayFromActorTask::operator == (const Task &t) const {
if (t.getType() != goAwayFromActorTask) return false;
- GoAwayFromActorTask *taskPtr = (GoAwayFromActorTask *)&t;
+ const GoAwayFromActorTask *taskPtr = (const GoAwayFromActorTask *)&t;
return *getTarget() == *taskPtr->getTarget();
}
@@ -2510,7 +2509,7 @@ int16 HuntToBeNearLocationTask::getType(void) const {
bool HuntToBeNearLocationTask::operator == (const Task &t) const {
if (t.getType() != huntToBeNearLocationTask) return false;
- HuntToBeNearLocationTask *taskPtr = (HuntToBeNearLocationTask *)&t;
+ const HuntToBeNearLocationTask *taskPtr = (const HuntToBeNearLocationTask *)&t;
return *getTarget() == *taskPtr->getTarget()
&& range == taskPtr->range;
@@ -2715,7 +2714,7 @@ int16 HuntToBeNearObjectTask::getType(void) const {
bool HuntToBeNearObjectTask::operator == (const Task &t) const {
if (t.getType() != huntToBeNearObjectTask) return false;
- HuntToBeNearObjectTask *taskPtr = (HuntToBeNearObjectTask *)&t;
+ const HuntToBeNearObjectTask *taskPtr = (const HuntToBeNearObjectTask *)&t;
return *getTarget() == *taskPtr->getTarget()
&& range == taskPtr->range;
@@ -2855,7 +2854,7 @@ int16 HuntToPossessTask::getType(void) const {
bool HuntToPossessTask::operator == (const Task &t) const {
if (t.getType() != huntToPossessTask) return false;
- HuntToPossessTask *taskPtr = (HuntToPossessTask *)&t;
+ const HuntToPossessTask *taskPtr = (const HuntToPossessTask *)&t;
return *getTarget() == *taskPtr->getTarget();
}
@@ -3152,7 +3151,7 @@ int16 HuntToBeNearActorTask::getType(void) const {
bool HuntToBeNearActorTask::operator == (const Task &t) const {
if (t.getType() != huntToBeNearActorTask) return false;
- HuntToBeNearActorTask *taskPtr = (HuntToBeNearActorTask *)&t;
+ const HuntToBeNearActorTask *taskPtr = (const HuntToBeNearActorTask *)&t;
return *getTarget() == *taskPtr->getTarget()
&& tracking() ? taskPtr->tracking() : !taskPtr->tracking()
@@ -3359,7 +3358,7 @@ int16 HuntToKillTask::getType(void) const {
bool HuntToKillTask::operator == (const Task &t) const {
if (t.getType() != huntToKillTask) return false;
- HuntToKillTask *taskPtr = (HuntToKillTask *)&t;
+ const HuntToKillTask *taskPtr = (const HuntToKillTask *)&t;
return *getTarget() == *taskPtr->getTarget()
&& tracking() ? taskPtr->tracking() : !taskPtr->tracking();
@@ -3729,7 +3728,7 @@ int16 HuntToGiveTask::getType(void) const {
bool HuntToGiveTask::operator == (const Task &t) const {
if (t.getType() != huntToGiveTask) return false;
- HuntToGiveTask *taskPtr = (HuntToGiveTask *)&t;
+ const HuntToGiveTask *taskPtr = (const HuntToGiveTask *)&t;
return *getTarget() == *taskPtr->getTarget()
&& tracking() ? taskPtr->tracking() : !taskPtr->tracking()
@@ -4348,7 +4347,7 @@ TaskResult FollowPatrolRouteTask::update(void) {
bool FollowPatrolRouteTask::operator == (const Task &t) const {
if (t.getType() != followPatrolRouteTask) return false;
- FollowPatrolRouteTask *taskPtr = (FollowPatrolRouteTask *)&t;
+ const FollowPatrolRouteTask *taskPtr = (const FollowPatrolRouteTask *)&t;
return patrolIter == taskPtr->patrolIter
&& lastWayPointNum == taskPtr->lastWayPointNum;
@@ -4523,341 +4522,11 @@ TaskResult AttendTask::update(void) {
bool AttendTask::operator == (const Task &t) const {
if (t.getType() != attendTask) return false;
- AttendTask *taskPtr = (AttendTask *)&t;
+ const AttendTask *taskPtr = (const AttendTask *)&t;
return obj == taskPtr->obj;
}
-#if 0
-
-// This code should no longer be necessary
-
-/* ===================================================================== *
- DefendTask member functions
- * ===================================================================== */
-
-//----------------------------------------------------------------------
-// Constructor -- reconstruct from archive buffer
-
-DefendTask::DefendTask(void **buf, TaskID id) : Task(buf, id) {
- void *bufferPtr = *buf;
-
- ObjectID attackerID;
-
- // Get the attacker's ID
- attackerID = *((ObjectID *)bufferPtr);
- bufferPtr = (ObjectID *)bufferPtr + 1;
-
- // Convert the ID to a pointer
- attacker = attackerID != Nothing
- ? (Actor *)GameObject::objectAddress(attackerID)
- : NULL;
-
- // Get the subTask id
- *((TaskID *)&subTask) = *((TaskID *)bufferPtr);
- bufferPtr = (TaskID *)bufferPtr + 1;
-
- *buf = bufferPtr;
-}
-
-//----------------------------------------------------------------------
-// Fixup the subtask pointer
-
-void DefendTask::fixup(void) {
- // Let the base class fixup its pointers
- Task::fixup();
-
- TaskID subTaskID = *((TaskID *)&subTask);
-
- // Convert the subTaskID to a pointer
- subTask = subTaskID != NoTask ? getTaskAddress(subTaskID) : NULL;
-}
-
-//----------------------------------------------------------------------
-// Return the number of bytes needed to archive this object in
-// a buffer
-
-inline int32 DefendTask::archiveSize(void) const {
- return Task::archiveSize() + sizeof(ObjectID) + sizeof(TaskID);
-}
-
-//----------------------------------------------------------------------
-// Create an archive of this object in a buffer
-
-void *DefendTask::archive(void *buf) const {
- // Let the base class archive its data
- buf = Task::archive(buf);
-
- ObjectID attackerID;
- TaskID subTaskID;
-
- // Convert the attacker pointer to an ID
- attackerID = attacker != NULL ? attacker->thisID() : Nothing;
-
- // Store the attacker's ID
- *((ObjectID *)buf) = attackerID;
- buf = (ObjectID *)buf + 1;
-
- // Convert the subtask pointer to an ID
- subTaskID = subTask != NULL ? getTaskID(subTask) : NoTask;
-
- // Store the subtask ID
- *((TaskID *)buf) = subTaskID;
- buf = (TaskID *)buf + 1;
-
- return buf;
-}
-
-//----------------------------------------------------------------------
-// Return an integer representing the type of this task
-
-int16 DefendTask::getType(void) const {
- return defendTask;
-}
-
-//----------------------------------------------------------------------
-
-void DefendTask::abortTask(void) {
- // If we have a sub-task, kill it
- if (subTask != NULL) {
- subTask->abortTask();
- delete subTask;
- subTask = NULL;
- }
-}
-
-//----------------------------------------------------------------------
-
-TaskResult DefendTask::evaluate(void) {
- // If there currently is no sub-task and the attacker is no longer
- // attacking, we're done
- if (subTask == NULL
- && (attacker->moveTask == NULL
- || !attacker->moveTask->isAttack()))
- return taskSucceeded;
-
- return taskNotDone;
-}
-
-//----------------------------------------------------------------------
-
-TaskResult DefendTask::update(void) {
- Actor *a = stack->getActor();
-
- // If there is no sub-task, try to set up a new one
- if (subTask == NULL) {
- GameObject *defensiveObj;
-
- a->defensiveObject(&defensiveObj);
-
- if (defensiveObj != NULL) {
- Direction relDir;
-
- relDir = ((attacker->getLocation() - a->getLocation()).quickDir()
- - a->currentFacing)
- & 0x7;
-
- if (relDir == 7 || relDir <= 1)
- subTask = new ParryTask(stack, attacker, defensiveObj);
- else
- return taskFailed;
- }
- }
-
- if (subTask != NULL) {
- TaskResult result;
-
- // Run the sub-task until its done
- if ((result = subTask->update()) != taskNotDone) {
- delete subTask;
- subTask = NULL;
- return result;
- }
- }
-
- // If there currently is no sub-task and the attacker is no longer
- // attacking, we're done
- if (subTask == NULL
- && (attacker->moveTask == NULL
- || !attacker->moveTask->isMeleeAttack()))
- return taskSucceeded;
-
- return taskNotDone;
-}
-
-//----------------------------------------------------------------------
-// Determine if the specified task is equivalent to this task
-
-bool DefendTask::operator == (const Task &t) const {
- if (t.getType() != defendTask) return false;
-
- DefendTask *taskPtr = (DefendTask *)&t;
-
- return attacker == taskPtr->attacker;
-}
-
-/* ===================================================================== *
- ParryTask Class
- * ===================================================================== */
-
-//----------------------------------------------------------------------
-// Constructor -- reconstruct from archive buffer
-
-ParryTask::ParryTask(void **buf, TaskID id) : Task(buf, id) {
- void *bufferPtr = *buf;
-
- ObjectID attackerID,
- defenseObjID;
-
- // Get the attacker ID and the defense object ID
- attackerID = *((ObjectID *)bufferPtr);
- defenseObjID = *((ObjectID *)bufferPtr + 1);
- bufferPtr = (ObjectID *)bufferPtr + 2;
-
- // Convert the attacker ID to a pointer
- attacker = attackerID != Nothing
- ? (Actor *)GameObject::objectAddress(attackerID)
- : NULL;
-
- // Convert the defense object ID to a pointer
- defenseObj = defenseObjID != Nothing
- ? GameObject::objectAddress(defenseObjID)
- : NULL;
-
- // Restore the flags
- flags = *((uint8 *)bufferPtr);
- bufferPtr = (uint8 *)bufferPtr + 1;
-
- *buf = bufferPtr;
-}
-
-//----------------------------------------------------------------------
-// Return the number of bytes needed to archive this object in
-// a buffer
-
-int32 ParryTask::archiveSize(void) const {
- return Task::archiveSize()
- + sizeof(ObjectID) // attacker ID
- + sizeof(ObjectID) // defenseObj ID
- + sizeof(flags);
-}
-
-//----------------------------------------------------------------------
-// Create an archive of this object in a buffer
-
-void *ParryTask::archive(void *buf) const {
- // Let the base class archive its data
- buf = Task::archive(buf);
-
- ObjectID attackerID,
- defenseObjID;
-
- // Convert the attacker pointer to an ID
- attackerID = attacker != NULL ? attacker->thisID() : Nothing;
-
- // Convert the defense object pointer to an ID
- defenseObjID = defenseObj != NULL ? defenseObj->thisID() : Nothing;
-
- // Store the attacker ID and the defense object ID
- *((ObjectID *)buf) = attackerID;
- *((ObjectID *)buf + 1) = defenseObjID;
- buf = (ObjectID *)buf + 2;
-
- // Store the flags
- *((uint8 *)buf) = flags;
- buf = (uint8 *)buf + 1;
-
- return buf;
-}
-
-//----------------------------------------------------------------------
-// Return an integer representing the type of this task
-
-int16 ParryTask::getType(void) const {
- return parryTask;
-}
-
-//----------------------------------------------------------------------
-
-void ParryTask::abortTask(void) {
- MotionTask *actorMotion = stack->getActor()->moveTask;
-
- // Kill the defense motion, if there is one
- if ((flags & motionStarted)
- && actorMotion != NULL
- && actorMotion->isDefense())
- actorMotion->finishDefense();
-}
-
-//----------------------------------------------------------------------
-
-TaskResult ParryTask::evaluate(void) {
- Actor *a = stack->getActor();
- MotionTask *defenderMotion = a->moveTask,
- *attackerMotion = attacker->moveTask;
-
- // If the attacker is no longer attacking and we are no longer
- // defending, we're done
- if (attackerMotion == NULL || !attackerMotion->isMeleeAttack()
- && (!(flags & blockStarted)
- || defenderMotion == NULL || !defenderMotion->isDefense()))
- return taskSucceeded;
-
- return taskNotDone;
-}
-
-//----------------------------------------------------------------------
-
-TaskResult ParryTask::update(void) {
- Actor *a = stack->getActor();
- MotionTask *defenderMotion = a->moveTask,
- *attackerMotion = attacker->moveTask;
-
- // If the attacker is no longer attacking and we are no longer
- // defending, we're done
- if (attackerMotion == NULL || !attackerMotion->isMeleeAttack()
- && (!(flags & blockStarted)
- || defenderMotion == NULL || !defenderMotion->isDefense()))
- return taskSucceeded;
-
- // Try to start a parry motion with the specified defensive object
- if (!(flags & motionStarted)) {
- ProtoObj *defenseObjProto = defenseObj->proto();
-
- defenseObjProto->initiateDefense(a->thisID(), attacker->thisID());
-
- if ((defenderMotion = a->moveTask) != NULL)
- flags |= motionStarted;
- else
- return taskNotDone;
- }
-
- assert(defenderMotion != NULL);
-
- // If the blow is about to strike, start the actual block
- if (!(flags & blockStarted)
- && attackerMotion->framesUntilStrike() < 1) {
- defenderMotion->startBlock();
- flags |= blockStarted;
- }
-
- return taskNotDone;
-}
-
-//----------------------------------------------------------------------
-// Determine if the specified task is equivalent to this task
-
-bool ParryTask::operator == (const Task &t) const {
- if (t.getType() != parryTask) return false;
-
- ParryTask *taskPtr = (ParryTask *)&t;
-
- return attacker == taskPtr->attacker
- && defenseObj == taskPtr->defenseObj;
-}
-
-#endif
-
/* ===================================================================== *
TaskStack member functions
* ===================================================================== */
diff --git a/engines/saga2/tower.cpp b/engines/saga2/tower.cpp
index 90c7287a2d..5929f76d98 100644
--- a/engines/saga2/tower.cpp
+++ b/engines/saga2/tower.cpp
@@ -70,8 +70,6 @@ static bool initTowerLayer(int is) {
return r;
}
-static bool cleanupErr = false;
-
static void termTowerLayer(int is) {
tower[is].term();
}
Commit: 5f1d4e1c73dcb37f4bc1ab5e88cb9a73620e7bf9
https://github.com/scummvm/scummvm/commit/5f1d4e1c73dcb37f4bc1ab5e88cb9a73620e7bf9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:26+02:00
Commit Message:
SAGA2: Fixing bug in the original. If there is no weapon, actor itself is a weapon
Changed paths:
engines/saga2/task.cpp
diff --git a/engines/saga2/task.cpp b/engines/saga2/task.cpp
index e939db0bd1..ac2210583b 100644
--- a/engines/saga2/task.cpp
+++ b/engines/saga2/task.cpp
@@ -3614,7 +3614,7 @@ void HuntToKillTask::evaluateWeapon(void) {
if (currentWeapon == NULL
|| weaponProto->weaponRating(
- obj->thisID(),
+ a->thisID(),
actorID,
currentTarget->thisID())
!= 0)
Commit: 3979138f249c95da572b7f2bb5452aac3eeac82e
https://github.com/scummvm/scummvm/commit/3979138f249c95da572b7f2bb5452aac3eeac82e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:26+02:00
Commit Message:
SAGA2: Rename PortraitType enum
Changed paths:
engines/saga2/intrface.cpp
engines/saga2/intrface.h
engines/saga2/player.cpp
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index 4756a095e4..7cc5af87ac 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -515,7 +515,7 @@ CPortrait::CPortrait(gMultCompButton **portraits,
// start off in a normal facial state
for (uint16 i = 0; i < _numViews + 1; i++) {
- currentState[i] = normal;
+ currentState[i] = kPortraitNormal;
}
}
@@ -544,7 +544,7 @@ void CPortrait::ORset(uint16 brotherID, PortraitType type) { // brotherID = post
assert(brotherID < _numViews + 1);
if (type == currentState[brotherID]) {
- currentState[brotherID] = normal;
+ currentState[brotherID] = kPortraitNormal;
} else {
currentState[brotherID] = type;
}
diff --git a/engines/saga2/intrface.h b/engines/saga2/intrface.h
index 22eb445855..1ff8ef7b57 100644
--- a/engines/saga2/intrface.h
+++ b/engines/saga2/intrface.h
@@ -254,14 +254,14 @@ public:
* ===================================================================== */
enum PortraitType {
- normal,
- angry,
- confused,
- ouch,
- sick,
- wounded,
- asleep,
- dead
+ kPortraitNormal,
+ kPortraitAngry,
+ kPortraitConfused,
+ kPortraitOuch,
+ kPortraitSick,
+ kPortraitWounded,
+ kPortraitAsleep,
+ kPortraitDead
};
class CPortrait {
diff --git a/engines/saga2/player.cpp b/engines/saga2/player.cpp
index eff0701cb3..f89600a05a 100644
--- a/engines/saga2/player.cpp
+++ b/engines/saga2/player.cpp
@@ -113,20 +113,21 @@ void PlayerActor::recalcPortraitType(void) {
ActorAttributes &stats = getBaseStats();
if (a->isDead())
- pType = dead;
+ pType = kPortraitDead;
else if (a->enchantmentFlags & (1 << actorAsleep))
- pType = asleep;
+ pType = kPortraitAsleep;
else if (stats.vitality >= a->effectiveStats.vitality * 3)
- pType = wounded;
+ pType = kPortraitWounded;
else if (a->enchantmentFlags & ((1 << actorDiseased) | (1 << actorPoisoned)))
- pType = sick;
+ pType = kPortraitSick;
else if (stats.vitality * 2 > a->effectiveStats.vitality * 3)
- pType = ouch;
+ pType = kPortraitOuch;
else if (a->enchantmentFlags & ((1 << actorParalyzed) | (1 << actorFear) | (1 << actorBlind)))
- pType = confused;
+ pType = kPortraitConfused;
else if (isAggressive())
- pType = angry;
- else pType = normal;
+ pType = kPortraitAngry;
+ else
+ pType = kPortraitNormal;
if (pType != portraitType)
updateBrotherPortrait(getPlayerActorID(this), portraitType = pType);
@@ -913,7 +914,7 @@ void initPlayerActors(void) {
ActorProto *proto = (ActorProto *)a->proto();
// Set the portrait type
- p->portraitType = normal;
+ p->portraitType = kPortraitNormal;
// Clear all flags
p->flags = 0;
Commit: 2af306a60ac4ff6536a0561f78754e9277279e0a
https://github.com/scummvm/scummvm/commit/2af306a60ac4ff6536a0561f78754e9277279e0a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:26+02:00
Commit Message:
SAGA2: Fix warnings in player.cpp
Changed paths:
engines/saga2/player.cpp
diff --git a/engines/saga2/player.cpp b/engines/saga2/player.cpp
index f89600a05a..b895592898 100644
--- a/engines/saga2/player.cpp
+++ b/engines/saga2/player.cpp
@@ -87,7 +87,7 @@ PlayerActor playerList[playerActors] = {
void PlayerActor::resolveBanding(void) {
Actor *follower = getActor();
- Actor *centerActor = getCenterActor();
+ Actor *centerActor_ = getCenterActor();
// if already following, tell the actor to cease and desist
if (follower->leader) {
@@ -97,10 +97,10 @@ void PlayerActor::resolveBanding(void) {
// do not allow actor to follow it's self
if (brotherBandingEnabled
&& isBanded()
- && follower != centerActor) {
+ && follower != centerActor_) {
// create a new follow assignment
- follower->bandWith(centerActor);
+ follower->bandWith(centerActor_);
}
}
@@ -334,7 +334,7 @@ void PlayerActor::skillAdvance(uint8 stat,
ActorAttributes::skillMaxLevel);
if (baseStats.skill(stat) / ActorAttributes::skillFracPointsPerLevel != oldValue) {
- static char *skillNames[] = {
+ static const char *skillNames[] = {
ARCHERY_SKILL,
SWORD_SKILL,
SHIELD_SKILL,
@@ -353,8 +353,6 @@ void PlayerActor::skillAdvance(uint8 stat,
}
void PlayerActor::vitalityAdvance(uint8 points) {
- char buffer[64];
-
while (points-- > 0) {
if (rand() % ActorAttributes::vitalityLimit > baseStats.vitality) {
if (++vitalityMemory >= vitalityLevelBump) {
@@ -411,9 +409,6 @@ uint8 PlayerActor::getStatIndex(SkillProto *proto) {
SpellID skillID = proto->getSpellID();
uint16 stat;
- // get the current stats for this player actor
- ActorAttributes *effStats = getEffStats();
-
// now map the id gotten from spellid to the
// attributeskilll enum for the allSkills array
switch (skillID) {
Commit: c5efa4fd804ec7b8b0dfc6e4dfe600bcead1dd85
https://github.com/scummvm/scummvm/commit/c5efa4fd804ec7b8b0dfc6e4dfe600bcead1dd85
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:26+02:00
Commit Message:
SAGA2: Fix warnings in panel.cpp
Changed paths:
engines/saga2/gdraw.cpp
engines/saga2/gdraw.h
engines/saga2/panel.cpp
engines/saga2/vdraw.h
engines/saga2/vwdraw.cpp
diff --git a/engines/saga2/gdraw.cpp b/engines/saga2/gdraw.cpp
index b5e09a4ff3..4aa14e7ea9 100644
--- a/engines/saga2/gdraw.cpp
+++ b/engines/saga2/gdraw.cpp
@@ -598,7 +598,7 @@ void gPort::line(int16 x1, int16 y1, int16 x2, int16 y2) {
**********************************************************************
*/
void gPort::bltPixels(
- gPixelMap &src,
+ const gPixelMap &src,
int src_x,
int src_y,
int dst_x,
diff --git a/engines/saga2/gdraw.h b/engines/saga2/gdraw.h
index 906bdf2fab..4888e49526 100644
--- a/engines/saga2/gdraw.h
+++ b/engines/saga2/gdraw.h
@@ -367,7 +367,7 @@ public:
// Blitting functions
- virtual void bltPixels(gPixelMap &src,
+ virtual void bltPixels(const gPixelMap &src,
int src_x, int src_y,
int dst_x, int dst_y,
int width, int height);
diff --git a/engines/saga2/panel.cpp b/engines/saga2/panel.cpp
index db2cbf2739..b2b668dc16 100644
--- a/engines/saga2/panel.cpp
+++ b/engines/saga2/panel.cpp
@@ -169,12 +169,12 @@ void gPanel::invalidate(Rect16 *) {
void gPanel::drawTitle(enum text_positions placement) {
gPort &port = window.windowPort;
Rect16 r = extent;
- gPixelMap *img;
+ const gPixelMap *img;
if (title == NULL) return;
if (imageLabel) {
- img = (gPixelMap *)title;
+ img = (const gPixelMap *)title;
r.width = img->size.x;
r.height = img->size.y;
} else {
@@ -280,7 +280,7 @@ void gPanelList::invalidate(Rect16 *) {
assert(displayEnabled());
if (displayEnabled())
- if (ctl = (gControl *)contents.last()) {
+ if ((ctl = (gControl *)contents.last())) {
invArea = ctl->getExtent();
for (ctl = (gControl *)ctl->prev();
@@ -440,7 +440,8 @@ void gWindow::close(void) {
// Don't close a window that is being dragged (should never happen,
// but just in case).
- if (DragBar::dragWindow == (FloatingWindow *)this) return;
+ if (DragBar::dragWindow == (FloatingWindow *)this)
+ return;
openFlag = false;
@@ -448,27 +449,8 @@ void gWindow::close(void) {
remove();
- /* if (backSave)
- {
- pointer.hide( *globalPort, extent );
- backSave->restore( *globalPort );
- pointer.show( *globalPort, extent );
- }
- */
- G_BASE.mouseWindow =
- G_BASE.activeWindow = (gWindow *)G_BASE.windowList.first();
+ G_BASE.mouseWindow = G_BASE.activeWindow = (gWindow *)G_BASE.windowList.first();
G_BASE.mousePanel = G_BASE.activePanel = NULL;
-
- gWindow *w = G_BASE.activeWindow;
- /* if (w)
- {
- pointer.hide();
- pointer.setImage( *w->pointerImage,
- w->pointerOffset.x,
- w->pointerOffset.y );
- pointer.show();
- }
- */
}
// Move the window to the front...
diff --git a/engines/saga2/vdraw.h b/engines/saga2/vdraw.h
index ff1f14fc8e..e0a03fcf5e 100644
--- a/engines/saga2/vdraw.h
+++ b/engines/saga2/vdraw.h
@@ -54,7 +54,7 @@ public:
// Blitting functions
// NOTE: svga port cannot be used a source!!!
- void bltPixels(gPixelMap &src,
+ void bltPixels(const gPixelMap &src,
int src_x, int src_y,
int dst_x, int dst_y,
int width, int height);
diff --git a/engines/saga2/vwdraw.cpp b/engines/saga2/vwdraw.cpp
index 995e21f847..1f332cae59 100644
--- a/engines/saga2/vwdraw.cpp
+++ b/engines/saga2/vwdraw.cpp
@@ -53,7 +53,7 @@ void gDisplayPort::fillRect(const Rect16 r) {
// movePixels
void gDisplayPort::bltPixels(
- gPixelMap &src,
+ const gPixelMap &src,
int src_x,
int src_y,
int dst_x,
Commit: a67ed67448d3e984fbe4621a44512af0dc770098
https://github.com/scummvm/scummvm/commit/a67ed67448d3e984fbe4621a44512af0dc770098
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:26+02:00
Commit Message:
SAGA2: Fix warnings in sprite.cpp
Changed paths:
engines/saga2/sprite.cpp
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index 4723ed6d1f..62bceeefb5 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -73,7 +73,7 @@ extern gPort backPort;
// Remap table for colors which are not remapped.
-extern uint8 fixedColors[] = {
+const uint8 fixedColors[] = {
0, 10, 12, 14, 16, 18, 21, 24,
101, 104, 130, 132, 197, 199, 228, 230
};
@@ -142,7 +142,6 @@ void DrawCompositeMaskedSprite(
int16 effects, // effects flags
bool *obscured) { // set if object obscured by terrain
SpriteComponent *sc; // sprite component
- int i;
int16 xMax, // extent of composite
xMin,
yMax,
@@ -158,7 +157,9 @@ void DrawCompositeMaskedSprite(
// First, determine the enclosing rectangle which
// surrounds all of the sprites.
- for (i = 0, sc = scList; i < numParts; i++, sc++) {
+ sc = scList;
+
+ for (int i = 0; i < numParts; i++, sc++) {
Sprite *sp = sc->sp;
int16 left,
right,
@@ -218,8 +219,8 @@ void DrawCompositeMaskedSprite(
// First, determine the enclosing rectangle which
// surrounds all of the sprites.
-
- for (i = 0, sc = scList; i < numParts; i++, sc++) {
+ sc = scList;
+ for (int i = 0; i < numParts; i++, sc++) {
Sprite *sp = sc->sp;
// Create a temp map for the sprite to unpack in
@@ -262,7 +263,6 @@ void DrawCompositeMaskedSprite(
} else {
gPixelMap tempMap;
int32 compMapBytes = compMap.bytes(),
- i,
visiblePixels;
bool isObscured;
@@ -277,7 +277,7 @@ void DrawCompositeMaskedSprite(
loc);
visiblePixels = 0;
- for (i = 0; i < compMapBytes; i++) {
+ for (int i = 0; i < compMapBytes; i++) {
if (compMap.data[i] != 0) {
visiblePixels++;
if (visiblePixels > 10) break;
@@ -614,16 +614,6 @@ ActorPose::ActorPose(Common::SeekableReadStream *stream) {
rightObjectOffset.load(stream);
}
-static void readColorScheme(hResContext *con, ColorScheme &col) {
- for (int i = 0; i < 11; ++i)
- col.bank[i] = con->readByte();
-
- col.speechColor = con->readByte();
-
- for (int i = 0; i < 32; ++i)
- col.name[i] = con->readSByte();
-}
-
ColorScheme::ColorScheme(Common::SeekableReadStream *stream) {
for (int i = 0; i < 11; ++i)
bank[i] = stream->readByte();
@@ -644,7 +634,6 @@ ColorSchemeList::ColorSchemeList(int count, Common::SeekableReadStream *stream)
ActorAppearance *LoadActorAppearance(uint32 id, int16 banksNeeded) {
int16 bank;
- int poseListSize;
int schemeListSize;
Common::SeekableReadStream *stream;
Commit: 83fad9d0f198893cca719d4553770854055532c0
https://github.com/scummvm/scummvm/commit/83fad9d0f198893cca719d4553770854055532c0
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:26+02:00
Commit Message:
SAGA2: Fix warnings in moton.cpp
Changed paths:
engines/saga2/motion.cpp
diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp
index 992ccd4b86..4134f3e6c2 100644
--- a/engines/saga2/motion.cpp
+++ b/engines/saga2/motion.cpp
@@ -51,9 +51,6 @@ bool interruptableMotionsPaused;
// Used to track the next motion task to process
static MotionTask *nextMT;
-const int32 pathFindIQ = 400;
-
-
/* ===================================================================== *
Test Functions
* ===================================================================== */
@@ -230,9 +227,6 @@ bool unstickObject(GameObject *obj) {
assert(isObject(obj) || isActor(obj));
TilePoint pos;
- int height,
- dist,
- dir;
int16 mapNum;
bool outside;
@@ -257,7 +251,6 @@ bool unstickObject(GameObject *obj) {
int32 dx = rand() % (radius * 2 + 1) - radius,
dy = rand() % (radius * 2 + 1) - radius,
dz = rand() % (radius * 2 + 1) - radius;
- int32 dist;
int16 tHeight;
// Compute the actual _data.location of the new point
@@ -458,13 +451,13 @@ void *MotionTaskList::archive(void *buf) {
void MotionTaskList::cleanup(void) {
MotionTask *mt;
- MotionTask *nextMT;
+ MotionTask *nextMT_;
// Remove all of the active motion tasks
for (mt = (MotionTask *)list.first();
mt;
- mt = nextMT) {
- nextMT = (MotionTask *)mt->next();
+ mt = nextMT_) {
+ nextMT_ = (MotionTask *)mt->next();
mt->remove();
}
}
@@ -2489,7 +2482,7 @@ bool MotionTask::nextWayPoint(void) {
// Test to see if actor can walk in a given direction
bool MotionTask::checkWalk(
- int16 direction,
+ int16 dir,
int16 speed,
int16 stepUp,
TilePoint &pos) {
@@ -2498,7 +2491,7 @@ bool MotionTask::checkWalk(
// Check the terrain in various directions.
// Check in the forward direction first, at various heights
- newPos = object->_data.location + (dirTable[direction] * speed) / 2;
+ newPos = object->_data.location + (dirTable[dir] * speed) / 2;
newPos.z = object->_data.location.z + stepUp;
if (checkWalkable(object, newPos)) return false;
@@ -2533,7 +2526,6 @@ void MotionTask::walkAction(void) {
StandingTileInfo sti;
ProtoObj *proto;
- int16 impact = 0;
bool moveTaskWaiting = false,
moveTaskDone = false;
WalkType walkType = walkNormal;
@@ -2682,9 +2674,10 @@ void MotionTask::walkAction(void) {
if (moveTaskDone || moveTaskWaiting) {
movementDirection = a->currentFacing;
} else if (targetDist == 0 && abs(targetVector.z) > kMaxStepHeight) {
- if (pathFindTask)
+ if (pathFindTask) {
+ movementDirection = a->currentFacing;
moveTaskWaiting = true;
- else {
+ } else {
movementDirection = a->currentFacing;
moveBlocked = true;
}
@@ -3118,8 +3111,7 @@ void MotionTask::downLadderAction(void) {
flags &= ~reset;
} else {
TilePoint loc = a->getLocation();
- uint8 crossSection = a->proto()->crossSection,
- height = a->proto()->height;
+ uint8 crossSection = a->proto()->crossSection;
int16 mapNum = a->getMapNum();
TileRegion actorTileReg;
TileInfo *ti;
@@ -4192,9 +4184,7 @@ void MotionTask::updatePositions(void) {
GameObject *obj = mt->object;
ProtoObj *proto = obj->proto();
Actor *a = (Actor *)obj;
- int16 impact = 0;
- bool moveTaskWaiting = false,
- moveTaskDone = false;
+ bool moveTaskDone = false;
nextMT = (MotionTask *)mt->next();
Commit: 405b8cc2303fd45f9ce9247034d81bc787faa929
https://github.com/scummvm/scummvm/commit/405b8cc2303fd45f9ce9247034d81bc787faa929
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:27+02:00
Commit Message:
SAGA2: Fix bugs in the original with the combat action in the savegame
Changed paths:
engines/saga2/motion.cpp
diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp
index 4134f3e6c2..73a4625128 100644
--- a/engines/saga2/motion.cpp
+++ b/engines/saga2/motion.cpp
@@ -772,7 +772,7 @@ void *MotionTask::restore(void *buf) {
actionCounter = *((int16 *)buf);
buf = (int16 *)buf + 1;
- if (motionType = motionTypeOneHandedParry) {
+ if (motionType == motionTypeOneHandedParry) {
// Restore the combat sub-motion type
combatMotionType = *((uint8 *)buf);
buf = (uint8 *)buf + 1;
@@ -911,7 +911,7 @@ int32 MotionTask::archiveSize(void) {
+ sizeof(d.defenseFlags)
+ sizeof(actionCounter);
- if (motionType = motionTypeOneHandedParry)
+ if (motionType == motionTypeOneHandedParry)
size += sizeof(combatMotionType);
} else if (motionType == motionTypeDodge
|| motionType == motionTypeAcceptHit
@@ -1170,7 +1170,7 @@ void *MotionTask::archive(void *buf) {
*((int16 *)buf) = actionCounter;
buf = (int16 *)buf + 1;
- if (motionType = motionTypeOneHandedParry) {
+ if (motionType == motionTypeOneHandedParry) {
// Store the combat sub-motion type
*((uint8 *)buf) = combatMotionType;
buf = (uint8 *)buf + 1;
Commit: aa8d7544ab2ed8520788f5d1e1030298599e9be5
https://github.com/scummvm/scummvm/commit/aa8d7544ab2ed8520788f5d1e1030298599e9be5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:27+02:00
Commit Message:
SAGA2: Fix warnings in main.cpp
Changed paths:
engines/saga2/gamerate.h
engines/saga2/hresmgr.cpp
engines/saga2/hresmgr.h
engines/saga2/magic.cpp
engines/saga2/main.cpp
engines/saga2/messager.cpp
engines/saga2/messager.h
engines/saga2/mission.cpp
engines/saga2/modal.cpp
engines/saga2/msgbox.cpp
engines/saga2/msgbox.h
diff --git a/engines/saga2/gamerate.h b/engines/saga2/gamerate.h
index 9153d4b470..4f844e3698 100644
--- a/engines/saga2/gamerate.h
+++ b/engines/saga2/gamerate.h
@@ -49,7 +49,7 @@ public:
instantFrameCount = 0;
}
- ~frameCounter() {}
+ virtual ~frameCounter() {}
virtual void updateFrameCount(void) {
int32 frameTime = gameTime - lastTime;
@@ -154,7 +154,7 @@ public:
frameSmoother(int32 fps, uint32 perSec, uint32 now);
- ~frameSmoother() {
+ virtual ~frameSmoother() {
if (frameHistory) delete[] frameHistory;
frameHistory = nullptr;
}
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index c501193f6d..5740328174 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -546,7 +546,7 @@ void hResource::readResource(hResEntry &element) {
debugC(3, kDebugResources, "%s, offset: %x, size: %d", tag2str(id), element.offset, element.size);
}
-hResource::hResource(char *resname, char *extname, const char desc[]) {
+hResource::hResource(const char *resname, const char *extname, const char desc[]) {
hResEntry origin;
int32 tableSize;
const int32 resourceSize = 4 + 4 + 4; // id, offset, size
diff --git a/engines/saga2/hresmgr.h b/engines/saga2/hresmgr.h
index 08fd390bc3..6b4e74de9d 100644
--- a/engines/saga2/hresmgr.h
+++ b/engines/saga2/hresmgr.h
@@ -193,7 +193,7 @@ class hResource : public hResContext {
hResEntry *_table;
public:
- hResource(char *resname, char *extname, const char []);
+ hResource(const char *resname, const char *extname, const char []);
~hResource();
hResContext *newContext(hResID id, const char []);
diff --git a/engines/saga2/magic.cpp b/engines/saga2/magic.cpp
index 8b414b3c65..f968136841 100644
--- a/engines/saga2/magic.cpp
+++ b/engines/saga2/magic.cpp
@@ -50,7 +50,6 @@ namespace Saga2 {
#define RANGE_CHECKING 0
#define NPC_MANA_CHECK 0
-const int32 maxSpells = 128;
const int32 spellFailSound = 42;
/* ===================================================================== *
@@ -105,7 +104,7 @@ SkillProto *skillProtoFromID(int16 spellOrObjectID) {
//-----------------------------------------------------------------------
// initialization call to connect skill prototypes with their spells
void initializeSkill(SkillProto *oNo, SpellID sNo) {
- if (sNo > 0 && sNo < MAX_SPELLS) {
+ if (sNo > 0 && sNo <= MAX_SPELLS - 1) {
if (spellBook[sNo].getProto() != NULL)
error("Duplicate prototype for spell %d", sNo);
spellBook[sNo].setProto(oNo);
@@ -190,7 +189,7 @@ bool canCast(GameObject *enactor, SkillProto *spell) {
ActorManaID ami = (ActorManaID)(sProto.getManaType());
int amt = sProto.getManaAmt();
- if (ami == sManaIDSkill)
+ if (ami == numManas)
return true;
#if NPC_MANA_CHECK
if (isActor(enactor)) {
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index ea6de877c1..8d0c72879a 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -58,16 +58,6 @@ namespace Saga2 {
// enable the following to display event loop processing
#define DEBUG_LOOP 0
-/* ===================================================================== *
- Constants
- * ===================================================================== */
-
-const uint32 gameTimeID = MKTAG('T', 'I', 'M', 'E');
-
-/* ===================================================================== *
- Imports
- * ===================================================================== */
-
extern WindowDecoration autoMapDecorations[];
extern gToolBase G_BASE;
extern configuration globalConfig;
@@ -238,7 +228,7 @@ void main_saga2() {
// __try{} __except(){} blocks
void updateActiveRegions(void);
-static void mainLoop(bool &cleanExit, int argc, char *argv[]) {
+static void mainLoop(bool &cleanExit_, int argc, char *argv[]) {
const char *exeFile = getExeFromCommandLine(argc, argv);
if (displayEnabled())
displayUpdate();
@@ -301,8 +291,6 @@ void dumpGBASE(char *msg);
void processEventLoop(bool updateScreen) {
- int key, qual;
-
debugC(1, kDebugEventLoop, "EventLoop: starting event loop");
irate.updateFrameCount();
@@ -397,8 +385,6 @@ void displayUpdate(void) {
* ===================================================================== */
void SystemEventLoop(void) {
- int key, qual;
-
if (
#ifdef DO_OUTRO_IN_CLEANUP
whichOutro == -1 &&
@@ -516,17 +502,14 @@ void *LoadFile(char *filename, const char desc[]) {
// Loads a resource into a buffer and returns a pointer
void *LoadResource(hResContext *con, uint32 id, const char desc[]) {
- uint32 idString[2];
int32 size;
uint8 *buffer; // allocated buffer
- idString[0] = id;
- idString[1] = 0;
debugC(3, kDebugResources, "LoadResource(): Loading resource %d (%s, %s)", id, tag2str(id), desc);
size = con->size(id);
if (size <= 0 || !con->seek(id)) {
- error("LoadResource(): Error reading resource ID '%s'.", &idString);
+ error("LoadResource(): Error reading resource ID '%s'.", tag2str(id));
}
// Allocate the buffer
@@ -538,17 +521,14 @@ void *LoadResource(hResContext *con, uint32 id, const char desc[]) {
}
Common::SeekableReadStream *loadResourceToStream(hResContext *con, uint32 id, const char desc[]) {
- uint32 idString[2];
int32 size;
uint8 *buffer; // allocated buffer
- idString[0] = id;
- idString[1] = 0;
debugC(3, kDebugResources, "loadResourceToStream(): Loading resource %d (%s, %s)", id, tag2str(id), desc);
size = con->size(id);
if (size <= 0 || !con->seek(id)) {
- warning("loadResourceToStream(): Error reading resource ID '%s'.", &idString);
+ warning("loadResourceToStream(): Error reading resource ID '%s'.", tag2str(id));
return nullptr;
}
@@ -564,17 +544,14 @@ Common::SeekableReadStream *loadResourceToStream(hResContext *con, uint32 id, co
// Loads a resource into a relocatable buffer and returns a handle
RHANDLE LoadResourceToHandle(hResContext *con, uint32 id, const char desc[]) {
- uint32 idString[2];
int32 size;
RHANDLE buffer; // allocated buffer
- idString[0] = id;
- idString[1] = 0;
debugC(3, kDebugResources, "LoadResourceToHandle(): Loading resource %d (%s, %s)", id, tag2str(id), desc);
size = con->size(id);
if (size <= 0 || !con->seek(id)) {
- error("LoadResourceToHandle(): Error reading resource ID '%s'.", &idString);
+ error("LoadResourceToHandle(): Error reading resource ID '%s'.", tag2str(id));
}
// Allocate the buffer
@@ -596,10 +573,10 @@ inline char drive(char *path) {
static bool openResource(
pHResource &hr, // resource to initialize
- char *basePath, // path to data file
- char *defaultPath, // backup path
- char *fileName, // file name & extension
- char *description) {
+ const char *basePath, // path to data file
+ const char *defaultPath, // backup path
+ const char *fileName, // file name & extension
+ const char *description) {
if (hr) delete hr;
hr = NULL;
diff --git a/engines/saga2/messager.cpp b/engines/saga2/messager.cpp
index 437f048fab..9358ce8a9f 100644
--- a/engines/saga2/messager.cpp
+++ b/engines/saga2/messager.cpp
@@ -48,7 +48,7 @@ size_t Messager::va(const char *format, va_list argptr) {
return 0;
}
-size_t Messager::operator()(char *format, ...) {
+size_t Messager::operator()(const char *format, ...) {
if (enabled) {
size_t size;
va_list argptr;
@@ -85,7 +85,7 @@ int StatusLineMessager::dumpit(char *s, size_t size) {
return 0;
}
-StatusLineMessager::StatusLineMessager(char *entry, int lineno, gDisplayPort *mp, int32 x, int32 y, int32 w, int16 color)
+StatusLineMessager::StatusLineMessager(const char *entry, int lineno, gDisplayPort *mp, int32 x, int32 y, int32 w, int16 color)
: Messager(entry) {
line = lineno;
textPort = mp;
diff --git a/engines/saga2/messager.h b/engines/saga2/messager.h
index 61c187b32e..22a3368d8f 100644
--- a/engines/saga2/messager.h
+++ b/engines/saga2/messager.h
@@ -70,12 +70,12 @@ public:
Messager() {
enabled = true;
}
- Messager(char *entry) {
+ Messager(const char *entry) {
enabled = true;
}
virtual ~Messager() {}
- size_t operator()(char *format, ...);
+ size_t operator()(const char *format, ...);
size_t va(const char *format, va_list argptr);
void enable() {
@@ -111,7 +111,7 @@ protected:
public:
StatusLineMessager(int line, gDisplayPort *mp, int32 x = -1, int32 y = -1, int32 w = -1, int16 color = -1);
- StatusLineMessager(char *entry, int line, gDisplayPort *mp, int32 x = -1, int32 y = -1, int32 w = -1, int16 color = -1);
+ StatusLineMessager(const char *entry, int line, gDisplayPort *mp, int32 x = -1, int32 y = -1, int32 w = -1, int16 color = -1);
~StatusLineMessager();
};
diff --git a/engines/saga2/mission.cpp b/engines/saga2/mission.cpp
index 9092eeddbc..6332b27d1e 100644
--- a/engines/saga2/mission.cpp
+++ b/engines/saga2/mission.cpp
@@ -51,8 +51,6 @@ ActiveMission *ActiveMission::newMission(ObjectID genID, uint16 script) {
if (!ms) return NULL;
- GameObject *generator = GameObject::objectAddress(genID);
-
ms->_data.missionID = i;
ms->_data.generatorID = genID;
ms->_data.missionScript = script;
diff --git a/engines/saga2/modal.cpp b/engines/saga2/modal.cpp
index 5f6d637a39..ddf00fd35d 100644
--- a/engines/saga2/modal.cpp
+++ b/engines/saga2/modal.cpp
@@ -52,6 +52,7 @@ GameMode ModalMode = {
ModalModeCleanup,
ModalModeHandleTask,
ModalModeHandleKey,
+ nullptr
};
extern void updateWindowSection(const Rect16 &r);
diff --git a/engines/saga2/msgbox.cpp b/engines/saga2/msgbox.cpp
index af1748e8b2..9a586e58ba 100644
--- a/engines/saga2/msgbox.cpp
+++ b/engines/saga2/msgbox.cpp
@@ -61,7 +61,7 @@ extern BackWindow *mainWindow;
* ===================================================================== */
APPFUNC(cmdDialogQuit);
-int16 MsgBox(char *msg, char *btnMsg1, char *btnMsg2);
+int16 MsgBox(const char *msg, const char *btnMsg1, const char *btnMsg2);
void writePlaqText(gPort &port,
const Rect16 &r,
gFont *font,
@@ -84,19 +84,10 @@ int16 userDialog(const char *title, const char *msg, const char *btnMsg1, const
// ------------------------------------------------------------------------
// Wrapper to avoid errors
-int16 FTAMessageBox(char *msg,
- char *btnMsg1,
- char *btnMsg2)
-
-{
+int16 FTAMessageBox(const char *msg, const char *btnMsg1, const char *btnMsg2) {
int16 rv = -1;
if (userDialogAvailable()) {
- char *b1 = btnMsg1;
- char *b2 = btnMsg2;
- //if (b1[0]=='_') b1++;
- //if (b2[0]=='_') b2++;
-
- rv = (0 == userDialog(ERROR_HEADING, msg, b1, b2, NULL));
+ rv = (0 == userDialog(ERROR_HEADING, msg, btnMsg1, btnMsg2, NULL));
} else
rv = MsgBox(msg, btnMsg1, btnMsg2);
return rv;
@@ -105,9 +96,7 @@ int16 FTAMessageBox(char *msg,
// ------------------------------------------------------------------------
// Very primitive message box
-int16 MsgBox(char *msg,
- char *btnMsg1,
- char *btnMsg2) {
+int16 MsgBox(const char *msg, const char *btnMsg1, const char *btnMsg2) {
ErrorWindow *win = new ErrorWindow(msg, btnMsg1, btnMsg2);
int16 res = win->getResult();
delete win;
@@ -135,7 +124,7 @@ APPFUNC(ErrorWindow::cmdMessageWindow) {
}
-ErrorWindow::ErrorWindow(char *msg, char *btnMsg1, char *btnMsg2)
+ErrorWindow::ErrorWindow(const char *msg, const char *btnMsg1, const char *btnMsg2)
: SimpleWindow(mbWindowRect, 0, msg, cmdMessageWindow) {
const int maxBtns = 2;
@@ -151,7 +140,7 @@ ErrorWindow::ErrorWindow(char *msg, char *btnMsg1, char *btnMsg2)
strcpy(mbChs1Text, "\x13");
strcpy(mbChs2Text, "\x1B");
- char *eq;
+ const char *eq;
// button one
if (btnMsg1) {
new SimpleButton(*this, butBox(numBtns, 0), btnMsg1, 0, cmdMessageWindow);
@@ -225,7 +214,7 @@ GameMode SimpleMode = {
SimpleWindow::SimpleWindow(const Rect16 &r,
uint16 ident,
- char *stitle,
+ const char *stitle,
AppFunc *cmd)
: gWindow(r, ident, "", cmd) {
prevModeStackCtr = GameMode::getStack(prevModeStackPtr);
@@ -359,7 +348,7 @@ void SimpleWindow::DrawOutlineFrame(gPort &port, const Rect16 &r, int16 fillColo
SimpleButton
* ===================================================================== */
-SimpleButton::SimpleButton(gWindow &win, const Rect16 &box, char *title, uint16 ident,
+SimpleButton::SimpleButton(gWindow &win, const Rect16 &box, const char *title, uint16 ident,
AppFunc *cmd)
: gControl(win, box, title, ident, cmd) {
window = &win;
diff --git a/engines/saga2/msgbox.h b/engines/saga2/msgbox.h
index bf5a7730ca..d32a0052c8 100644
--- a/engines/saga2/msgbox.h
+++ b/engines/saga2/msgbox.h
@@ -55,7 +55,7 @@ public:
SimpleWindow(const Rect16 &r,
uint16 ident,
- char *title,
+ const char *title,
AppFunc *cmd);
~SimpleWindow();
@@ -77,7 +77,7 @@ public:
class SimpleButton : public gControl {
gWindow *window;
public:
- SimpleButton(gWindow &, const Rect16 &, char *, uint16, AppFunc *cmd = NULL);
+ SimpleButton(gWindow &, const Rect16 &, const char *, uint16, AppFunc *cmd = NULL);
void draw(void); // redraw the panel.
void drawClipped(gPort &port, const Point16 &offset, const Rect16 &r);
@@ -97,9 +97,7 @@ class ErrorWindow : public SimpleWindow {
public:
static requestInfo rInfo;
- ErrorWindow(char *msg,
- char *btnMsg1,
- char *btnMsg2);
+ ErrorWindow(const char *msg, const char *btnMsg1, const char *btnMsg2);
~ErrorWindow();
int16 getResult(void);
static APPFUNC(cmdMessageWindow);
@@ -110,31 +108,7 @@ public:
};
-
-struct MBErr {
- int16 errNo;
- MBErr(int16 e) {
- errNo = e;
- }
-};
-
-#define assert_alloc(e,p) if (NULL==p) throw MBErr(e)
-
-
-
-int16 FTAMessageBox(char *msg, char *btnMsg1, char *btnMsg2);
-
-#if 0
-class SystemErrorMessager : public Messager {
-protected:
- int dumpit(char *s, size_t size) ;
-
-public:
- SystemErrorMessager() {}
- ~SystemErrorMessager() {}
- int16 getAnswer(const char *b1, const char *b2, const char fmt[], ...);
-};
-#endif
+int16 FTAMessageBox(const char *msg, const char *btnMsg1, const char *btnMsg2);
} // end of namespace Saga2
Commit: 6cda95cefc7554ad272734e5c8a7357879157d76
https://github.com/scummvm/scummvm/commit/6cda95cefc7554ad272734e5c8a7357879157d76
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:27+02:00
Commit Message:
SAGA2: Fix more warnings
Changed paths:
engines/saga2/msgbox.cpp
engines/saga2/sagafunc.cpp
diff --git a/engines/saga2/msgbox.cpp b/engines/saga2/msgbox.cpp
index 9a586e58ba..046f46b7cc 100644
--- a/engines/saga2/msgbox.cpp
+++ b/engines/saga2/msgbox.cpp
@@ -126,8 +126,6 @@ APPFUNC(ErrorWindow::cmdMessageWindow) {
ErrorWindow::ErrorWindow(const char *msg, const char *btnMsg1, const char *btnMsg2)
: SimpleWindow(mbWindowRect, 0, msg, cmdMessageWindow) {
- const int maxBtns = 2;
-
numBtns = 0;
if (btnMsg1) numBtns++;
@@ -205,6 +203,7 @@ GameMode SimpleMode = {
ErrorWindow::ErrorModeCleanup,
ErrorWindow::ErrorModeHandleTask,
ErrorWindow::ErrorModeHandleKey,
+ nullptr
};
/* ===================================================================== *
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index 97b6c0f5cf..3ec4cad37e 100644
--- a/engines/saga2/sagafunc.cpp
+++ b/engines/saga2/sagafunc.cpp
@@ -984,9 +984,6 @@ int16 scriptGameObjectSetMass(int16 *args) {
OBJLOG(SetMass);
GameObject *obj = (GameObject *)thisThread->thisObject;
-// assert( args[0] > 0 );
- assert(args[0] < maxuint16);
-
if (obj->proto()->flags & ResourceObjectPrototype::objPropMergeable) {
obj->setExtra(args[0]);
if (obj->proto()->flags & ResourceObjectPrototype::objPropMergeable) {
@@ -1041,7 +1038,7 @@ int16 deepCopy(GameObject *src, ObjectID parentID, TilePoint tp) {
// Now, recursively copy all the children of this object.
ContainerIterator iter(src);
- while (childID = iter.next(&childObj))
+ while ((childID = iter.next(&childObj)))
deepCopy(childObj, newID, childObj->getLocation());
// Return the ID of the object just copied.
@@ -2513,15 +2510,10 @@ int16 scriptTagSetAnimation(int16 *args) {
MONOLOG(TAG::SetAnimation);
extern uint32 parse_res_id(char IDstr[]);
ActiveItem *ai = (ActiveItem *)thisThread->thisObject;
- Actor *a = getCenterActor();
//TilePoint tagLoc;
int32 soundID = parse_res_id(STRING(args[2]));
Location ail = ai->getInstanceLocation();
-#if 0
- tagLoc.u = ai->instance.u - a->getLocation().u;
- tagLoc.v = ai->instance.v - a->getLocation().v;
- tagLoc.z = ai->instance.h * 8 - a->getLocation().z;
-#endif
+
// Assert that the state is valid
assert(args[1] >= 0);
assert(args[1] < ai->getGroup()->_data.group.numStates);
@@ -2787,11 +2779,11 @@ void writeObject(char *str) {
int16 scriptWriteLog(int16 *args) {
MONOLOG(WriteLog);
- char buffer[256];
-#if DEBUG
+ char buffer[256];
+
stringf(buffer, sizeof buffer, args[0], &args[1]);
- writeLog(buffer);
-#endif
+ debugC(2, kDebugScripts, "%s", buffer);
+
return 0;
}
@@ -3106,8 +3098,6 @@ int16 scriptPlayMusic(int16 *args) {
int16 scriptPlayLoop(int16 *args) {
MONOLOG(PlayLoop);
- char *sID = STRING(args[0]);
- //PlayLoop(sID);
return 0;
}
@@ -3408,7 +3398,6 @@ int16 scriptCastSpellAtTile(int16 *args) {
int16 scriptSelectNearbySite(int16 *args) {
MONOLOG(SelectNearbySite);
TilePoint tp;
- Actor *center = getCenterActor();
tp = selectNearbySite(args[3],
TilePoint(args[0], args[1], args[2]),
@@ -3612,8 +3601,6 @@ int16 scriptSwapRegions(int16 *args) {
worldID2 = args[3];
GameWorld *worldPtr1,
*worldPtr2;
- ObjectID searchObj;
- int objNum;
ObjectID *objArray1,
*objArray2;
int objCount1,
Commit: 10ea74f5d9187a0546194f413554132e817822aa
https://github.com/scummvm/scummvm/commit/10ea74f5d9187a0546194f413554132e817822aa
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:27+02:00
Commit Message:
SAGA2: Attempt to fix another original bug
Changed paths:
engines/saga2/sensor.cpp
diff --git a/engines/saga2/sensor.cpp b/engines/saga2/sensor.cpp
index ac6143efa8..e3e46249e3 100644
--- a/engines/saga2/sensor.cpp
+++ b/engines/saga2/sensor.cpp
@@ -539,12 +539,13 @@ bool ProtaganistSensor::evaluateEvent(const GameEvent &) {
bool ObjectSensor::check(SenseInfo &info, uint32 senseFlags) {
bool objIsActor = isActor(getObject());
- GameObject *objToTest;
- bool objToTestIsActor = isActor(objToTest);
CircularObjectIterator iter(
getObject()->world(),
getObject()->getLocation(),
getRange() != 0 ? getRange() : kTileUVSize * kPlatformWidth * 8);
+ GameObject *objToTest;
+ iter.first(&objToTest);
+ bool objToTestIsActor = isActor(objToTest);
for (iter.first(&objToTest);
objToTest != NULL;
Commit: 963791245e00d54b5675c6ef327f3890ae93dd64
https://github.com/scummvm/scummvm/commit/963791245e00d54b5675c6ef327f3890ae93dd64
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:27+02:00
Commit Message:
SAGA2: Fix warnings in speech.cpp
Changed paths:
engines/saga2/speech.cpp
diff --git a/engines/saga2/speech.cpp b/engines/saga2/speech.cpp
index 7b6d252da1..0747267887 100644
--- a/engines/saga2/speech.cpp
+++ b/engines/saga2/speech.cpp
@@ -61,11 +61,8 @@ extern configuration globalConfig;
const int maxWidth = 420;
const int defaultWidth = 380;
-const int maxPhraseLength = 1000;
const int actorHeight = 80; // Assume 80
-const int buttonColor = 1 + 9; // color for button text.
-
const int lineLeading = 2; // space between lines
const int outlineWidth = 2; // width of character outline
const int bulletWidth = 13; // width of bullet symbol
@@ -452,27 +449,27 @@ bool Speech::setupActive(void) {
//This Function Sets Up Width And Height For A Speech
void Speech::setWidth() {
- TextSpan speechLineList[32], // list of speech lines
- speechButtonList[32]; // list of speech buttons
- int16 speechLineCount, // count of speech lines
- speechButtonCount; // count of speech buttons
+ TextSpan speechLineList_[32], // list of speech lines
+ speechButtonList_[32]; // list of speech buttons
+ int16 speechLineCount_, // count of speech lines
+ speechButtonCount_; // count of speech buttons
// How many word-wrapped lines does the speech take up if we word-wrap
// it to the default line width?
- speechLineCount = buttonWrap(speechLineList,
- speechButtonList,
- speechButtonCount,
+ speechLineCount_ = buttonWrap(speechLineList_,
+ speechButtonList_,
+ speechButtonCount_,
speechBuffer,
defaultWidth,
!globalConfig.speechText && (speechFlags & spHasVoice));
// If it's more than 3 lines, then use the max line width.
- if (speechLineCount > 3) {
- speechLineCount = buttonWrap(speechLineList,
- speechButtonList,
- speechButtonCount,
+ if (speechLineCount_ > 3) {
+ speechLineCount_ = buttonWrap(speechLineList_,
+ speechButtonList_,
+ speechButtonCount_,
speechBuffer,
maxWidth,
!globalConfig.speechText && (speechFlags & spHasVoice));
@@ -482,8 +479,8 @@ void Speech::setWidth() {
// The actual width of the bounds is the widest of the lines.
bounds.width = 0;
- for (int i = 0; i < speechLineCount; i++) {
- bounds.width = MAX(bounds.width, speechLineList[i].pixelWidth);
+ for (int i = 0; i < speechLineCount_; i++) {
+ bounds.width = MAX(bounds.width, speechLineList_[i].pixelWidth);
}
bounds.width += outlineWidth * 2 + 4; // Some padding just in case.
}
@@ -1260,6 +1257,9 @@ APPFUNC(cmdClickSpeech) {
#endif
}
break;
+
+ default:
+ break;
}
}
Commit: ce490339dbbacf4823ba0e734b0c4926e11d1f5b
https://github.com/scummvm/scummvm/commit/ce490339dbbacf4823ba0e734b0c4926e11d1f5b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:27+02:00
Commit Message:
SAGA2: Fix another warning
Changed paths:
engines/saga2/spelcast.cpp
diff --git a/engines/saga2/spelcast.cpp b/engines/saga2/spelcast.cpp
index 0e834f3c7e..89ae68fe89 100644
--- a/engines/saga2/spelcast.cpp
+++ b/engines/saga2/spelcast.cpp
@@ -161,6 +161,8 @@ void SpellStuff::implement(GameObject *enactor, SpellTarget *target) {
case SpellTarget::spellTargetTAG:
implement(enactor, target->getTAG());
break;
+ default:
+ break;
}
}
Commit: 415277d19ec68b2d671de0f2300f4dc2ba97aea8
https://github.com/scummvm/scummvm/commit/415277d19ec68b2d671de0f2300f4dc2ba97aea8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:27+02:00
Commit Message:
SAGA2: Fix more warnings
Changed paths:
engines/saga2/assign.cpp
engines/saga2/audiobuf.cpp
engines/saga2/audiodec.h
engines/saga2/audiosys.h
diff --git a/engines/saga2/assign.cpp b/engines/saga2/assign.cpp
index 3243e15a9a..d67f8c849c 100644
--- a/engines/saga2/assign.cpp
+++ b/engines/saga2/assign.cpp
@@ -632,7 +632,7 @@ bool HuntToKillAssignment::isValid(void) {
// If the target actor is already dead, then this is not a valid
// assignment
if (flags & specificActor) {
- SpecificActorTarget *sat = (SpecificActorTarget *)getTarget();
+ const SpecificActorTarget *sat = (const SpecificActorTarget *)getTarget();
if (sat->getTargetActor()->isDead()) return false;
}
@@ -657,7 +657,7 @@ bool HuntToKillAssignment::taskNeeded(void) {
// If we're hunting a specific actor, we only need a task if that
// actor is still alive.
if (flags & specificActor) {
- SpecificActorTarget *sat = (SpecificActorTarget *)getTarget();
+ const SpecificActorTarget *sat = (const SpecificActorTarget *)getTarget();
return !sat->getTargetActor()->isDead();
}
diff --git a/engines/saga2/audiobuf.cpp b/engines/saga2/audiobuf.cpp
index 32ed66852b..ffd48419a5 100644
--- a/engines/saga2/audiobuf.cpp
+++ b/engines/saga2/audiobuf.cpp
@@ -163,7 +163,7 @@ singleBuffer::singleBuffer(size_t newSize, audioInterface *sd, int16 newID)
targetSated = false;
ailSampleHandle = AIL_allocate_sample_handle(sd->dig);
if (ailSampleHandle == NULL)
- audioFatal("Unable to allocate audio handle");
+ error("Unable to allocate audio handle");
AIL_init_sample(ailSampleHandle);
AILLOCated = -1;
audioSet = 0;
@@ -194,7 +194,7 @@ musicBuffer::musicBuffer(size_t newSize, audioInterface *sd, int16 newID)
targetSated = false;
ailSampleHandle = AIL_allocate_sequence_handle(sd->mid);
if (ailSampleHandle == NULL)
- audioFatal("Unable to allocate music handle");
+ error("Unable to allocate music handle");
data[1] = NULL;
audioSet = 0;
}
diff --git a/engines/saga2/audiodec.h b/engines/saga2/audiodec.h
index bc45305635..79e3ddcfce 100644
--- a/engines/saga2/audiodec.h
+++ b/engines/saga2/audiodec.h
@@ -155,7 +155,8 @@ public:
soundDecoder(const soundDecoder &src);
bool operator==(const soundDecoder &src2) const;
inline operator bool() const {
- return (bool) readf != NULL;
+ warning("STUB: soundDecoder::bool()");
+ return true;
}
void setNext(soundDecoder *sd) {
diff --git a/engines/saga2/audiosys.h b/engines/saga2/audiosys.h
index 12e9bb2cf9..c576d14bbd 100644
--- a/engines/saga2/audiosys.h
+++ b/engines/saga2/audiosys.h
@@ -282,7 +282,7 @@ public:
// volume and enabled calls
bool active(void);
bool activeDIG(void) {
- return dig != NULL;
+ return true;
}
bool enabled(volumeTarget i);
void enable(volumeTarget i, bool onOff);
Commit: ca1831e4c0e9400480b65f2f4af8fd4353a85387
https://github.com/scummvm/scummvm/commit/ca1831e4c0e9400480b65f2f4af8fd4353a85387
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:28+02:00
Commit Message:
SAGA2: Cleanup in audiobuf.cpp
Changed paths:
engines/saga2/audiobuf.cpp
engines/saga2/audiobuf.h
diff --git a/engines/saga2/audiobuf.cpp b/engines/saga2/audiobuf.cpp
index ffd48419a5..7a99e67079 100644
--- a/engines/saga2/audiobuf.cpp
+++ b/engines/saga2/audiobuf.cpp
@@ -45,10 +45,7 @@ extern audioInterface *audio;
/* Buffer Classes */
/* Buffer : base class */
/* workBuffer : temporary work buffer */
-/* soundBuffer : AIL double buffered sound */
-/* singleBuffer : AIL single buffered sound */
/* musicBuffer : AIL XMIDI song */
-/* cacheBuffer : in memory storage */
/* */
/* Member functions */
/* ctor, dtor : constructors & destructors */
@@ -101,85 +98,6 @@ workBuffer::workBuffer(size_t newSize, int16 newID)
workBuffer::~workBuffer(void) {
}
-/***********************************/
-
-cacheBuffer::cacheBuffer(size_t newSize, int16 newID)
- : Buffer(newSize) {
- bufID = newID;
- hasData = 0;
-}
-
-cacheBuffer::~cacheBuffer(void) {
-}
-
-/***********************************/
-
-
-doubleBuffer::doubleBuffer(size_t newSize, audioInterface *sd, int16 newID)
- : Buffer(newSize) {
- if (sd && sd->enabled(volVoice)) {
- assert(sd);
- //assert( sd->dig );
-
- bufID = newID;
- fillBuffer = 0;
- targetPos = 0;
- targetSated = false;
- ailSampleHandle = AIL_allocate_sample_handle(sd->dig);
- if (ailSampleHandle == NULL)
- error("Unable to allocate audio handle");
- AIL_init_sample(ailSampleHandle);
- AILLOCated = -1;
- audioSet = 0;
-
- data[1] = (void *)malloc(newSize);
- //drain( 1 );
- }
-}
-
-doubleBuffer::~doubleBuffer(void) {
- assert(ailSampleHandle);
- if (data[1]) {
- free(data[1]);
- data[1] = NULL;
- }
- if (ailSampleHandle) {
- AIL_release_sample_handle(ailSampleHandle);
- }
-}
-
-
-/***********************************/
-
-
-singleBuffer::singleBuffer(size_t newSize, audioInterface *sd, int16 newID)
- : Buffer(newSize) {
- if (sd && sd->enabled(volSound)) {
- assert(sd);
- assert(sd->dig);
-
- bufID = newID;
- fillBuffer = 0;
- targetSated = false;
- ailSampleHandle = AIL_allocate_sample_handle(sd->dig);
- if (ailSampleHandle == NULL)
- error("Unable to allocate audio handle");
- AIL_init_sample(ailSampleHandle);
- AILLOCated = -1;
- audioSet = 0;
- data[1] = NULL;
- lastRSize = 0;
- }
-}
-
-singleBuffer::~singleBuffer(void) {
- assert(ailSampleHandle);
- if (ailSampleHandle) {
- AIL_release_sample_handle(ailSampleHandle);
- }
-}
-
-
/***********************************/
@@ -193,7 +111,7 @@ musicBuffer::musicBuffer(size_t newSize, audioInterface *sd, int16 newID)
fillBuffer = 0;
targetSated = false;
ailSampleHandle = AIL_allocate_sequence_handle(sd->mid);
- if (ailSampleHandle == NULL)
+ if (ailSampleHandle == 0)
error("Unable to allocate music handle");
data[1] = NULL;
audioSet = 0;
@@ -251,37 +169,8 @@ void Buffer::format(soundSample *) {
void workBuffer::format(soundSample *) {
}
-// work buffers could care less about format
-
-void cacheBuffer::format(soundSample *) {
-
-}
-
// sound buffers need to let AIL know about the formatting
-void doubleBuffer::format(soundSample *ss) {
- if (audioSet == 0) {
- assert(ailSampleHandle);
- AIL_init_sample(ailSampleHandle);
- AIL_set_sample_type(ailSampleHandle, ss->format(), ss->flags());
- AIL_set_sample_playback_rate(ailSampleHandle, ss->speed);
- AIL_set_sample_volume(ailSampleHandle, ss->getVolume());
- activate(washed());
- targetPos = 0;
- audioSet = 1;
- }
-}
-
-void singleBuffer::format(soundSample *ss) {
- assert(ailSampleHandle);
- AIL_init_sample(ailSampleHandle);
- AIL_set_sample_type(ailSampleHandle, ss->format(), ss->flags());
- AIL_set_sample_playback_rate(ailSampleHandle, ss->speed);
- AIL_set_sample_volume(ailSampleHandle, ss->getVolume());
- activate(washed());
- audioSet = 1;
-}
-
void musicBuffer::format(soundSample *) {
}
@@ -306,36 +195,12 @@ bool workBuffer::laden(void) {
// sound buffers need to find out from AIL whether a buffer is free
-bool doubleBuffer::laden(void) {
- assert(ailSampleHandle);
- if (-1 == washed())
- return true;
- else if (targetSated)
- activate(fillBuffer);
- return (false);
-}
-
-bool singleBuffer::laden(void) {
- assert(ailSampleHandle);
- if (targetSated)
- activate(0);
- return (false);
-}
-
bool musicBuffer::laden(void) {
if (targetSated)
activate(0);
return (false);
}
-bool cacheBuffer::laden(void) {
- if (-1 == washed())
- return true;
- activate(0);
- return false;
-}
-
-
/*******************************************************************/
/* */
/* sample_status - find out whats going on with abuffer */
@@ -349,32 +214,10 @@ uint32 workBuffer::sample_status(void) {
}
-uint32 doubleBuffer::sample_status(void) {
- assert(ailSampleHandle);
-#if 0
- int32 newPos = AIL_sample_position(ailSampleHandle);
- if (targetPos == 0 || newPos >= targetPos) { //( newPos==lastPos && lastPos==distPos)
- return (SMP_DONE);
- }
- distPos = lastPos;
- lastPos = newPos;
-#endif
- return (AIL_sample_status(ailSampleHandle));
-}
-
-uint32 singleBuffer::sample_status(void) {
- assert(ailSampleHandle);
- return (AIL_sample_status(ailSampleHandle));
-}
-
uint32 musicBuffer::sample_status(void) {
return (AIL_sequence_status(ailSampleHandle));
}
-uint32 cacheBuffer::sample_status(void) {
- return (SMP_DONE);
-}
-
/*******************************************************************/
/* */
/* washed() used internally to find a buffer with writeable */
@@ -404,26 +247,10 @@ int16 workBuffer::washed(void) {
return 0;
}
-int16 doubleBuffer::washed(void) {
- assert(ailSampleHandle);
- if (AILLOCated > -1) return AILLOCated;
- AILLOCated = AIL_sample_buffer_ready(ailSampleHandle);
- return AILLOCated;
-}
-
-int16 singleBuffer::washed(void) {
- return 0;
-}
-
int16 musicBuffer::washed(void) {
return 0;
}
-int16 cacheBuffer::washed(void) {
- return 0;
-}
-
-
/*******************************************************************/
/* */
/* gave() notifies a buffer that it has been written to */
@@ -451,33 +278,6 @@ void workBuffer::gave(size_t dSize) {
// when sound buffers get full they automatically trigger AIL
-void doubleBuffer::gave(size_t dSize) {
- assert(ailSampleHandle);
- assert(dSize <= wSize);
- wSize -= dSize;
- rSize += dSize;
- if (wSize) {
- wData = (void *)(((char *) data[fillBuffer]) + (size - wSize));
- } else {
- assert(AILLOCated >= 0);
- play(AILLOCated);
- activate(1 - fillBuffer);
- }
-}
-
-void singleBuffer::gave(size_t dSize) {
- assert(ailSampleHandle);
- assert(dSize <= wSize);
- lastRSize = rSize;
- wSize -= dSize;
- rSize += dSize;
- if (wSize) {
- wData = (void *)(((char *) data[fillBuffer]) + (size - wSize));
- } else {
- play(0);
- }
-}
-
void musicBuffer::gave(size_t dSize) {
assert(ailSampleHandle);
assert(dSize <= wSize);
@@ -491,16 +291,6 @@ void musicBuffer::gave(size_t dSize) {
}
}
-void cacheBuffer::gave(size_t dSize) {
- assert(dSize <= wSize);
- wSize -= dSize;
- rSize += dSize;
- if (wSize) {
- wData = (void *)(((char *) data[0]) + (size - wSize));
- }
-
-}
-
// when work buffers get fully drained they reset themselves
void Buffer::took(size_t dSize) {
@@ -523,21 +313,6 @@ void workBuffer::took(size_t dSize) {
}
}
-void doubleBuffer::took(size_t dSize) {
- assert(dSize <= rSize);
- rSize -= dSize;
- if (rSize > 0)
- rData = (void *)(((char *) rData) + dSize);
-}
-
-void singleBuffer::took(size_t dSize) {
- assert(dSize <= rSize);
- lastRSize = rSize;
- rSize -= dSize;
- if (rSize > 0)
- rData = (void *)(((char *) rData) + dSize);
-}
-
void musicBuffer::took(size_t dSize) {
assert(dSize <= rSize);
rSize -= dSize;
@@ -545,10 +320,6 @@ void musicBuffer::took(size_t dSize) {
rData = (void *)(((char *) rData) + dSize);
}
-void cacheBuffer::took(size_t dSize) {
- assert(dSize <= rSize);
-}
-
/*******************************************************************/
/* */
/* fill() - notify the buffer that it should deal with */
@@ -572,35 +343,11 @@ void workBuffer::fill(void) {
// sound buffers pass what they have to AIL
-void doubleBuffer::fill(void) {
- assert(ailSampleHandle);
- assert(AILLOCated >= 0);
- if (rSize) {
- play(AILLOCated);
- activate(1 - fillBuffer);
- } else {
- play(AILLOCated);
- }
-}
-
-void singleBuffer::fill(void) {
- assert(ailSampleHandle);
- if (rSize) {
- play(0);
- }
-}
-
void musicBuffer::fill(void) {
assert(ailSampleHandle);
play(0);
}
-void cacheBuffer::fill(void) {
- if (rSize) {
- hasData = 1;
- }
-}
-
/*******************************************************************/
/* */
/* When a buffer is no longer needed this call resets it. */
@@ -620,46 +367,6 @@ void workBuffer::abortsound(void) {
void workBuffer::release(void) {
}
-void doubleBuffer::abortsound(void) {
- if (rSize)
- took(rSize);
- release();
- targetPos = 0;
-}
-
-void doubleBuffer::release(void) {
- assert(ailSampleHandle);
- assert(rSize == 0);
-
- if (washed() <= -1) {
- if (sample_status() != SMP_STOPPED)
- AIL_end_sample(ailSampleHandle);
- } else if (AILLOCated >= 0) {
- AIL_load_sample_buffer(ailSampleHandle, AILLOCated, rData, rSize);
- AILLOCated = -1;
- }
-
- AIL_end_sample(ailSampleHandle);
- audioSet = 0;
- audio->resetState((audioInterface::BufferRequest) ID());
- assert(AILLOCated == -1);
-}
-
-void singleBuffer::abortsound(void) {
- AIL_end_sample(ailSampleHandle);
- if (rSize)
- took(rSize);
- release();
-}
-
-void singleBuffer::release(void) {
- assert(ailSampleHandle);
- assert(rSize == 0);
-// AIL_end_sample( ailSampleHandle );
- audioSet = 0;
- assert(AILLOCated == -1);
-}
-
void musicBuffer::abortsound(void) {
if (rSize)
took(rSize);
@@ -673,12 +380,6 @@ void musicBuffer::release(void) {
audioSet = 0;
}
-void cacheBuffer::abortsound(void) {
-}
-
-void cacheBuffer::release(void) {
-}
-
/*******************************************************************/
/* */
/* Used internally - for sound buffers this is the call that */
@@ -693,34 +394,6 @@ void workBuffer::play(int16 bufNo) {
took(rSize);
}
-void doubleBuffer::play(int16 bufNo) {
- assert(bufNo >= 0 && bufNo <= 1);
- assert(ailSampleHandle);
- targetPos = (int32)((char *) rData - (char *)data[AILLOCated]) + rSize;
- AIL_load_sample_buffer(ailSampleHandle, AILLOCated, rData, rSize);
- took(rSize);
- AILLOCated = -1;
-}
-
-void singleBuffer::play(int16 bufNo) {
- assert(bufNo == 0);
- assert(ailSampleHandle);
- AIL_set_sample_address(ailSampleHandle, rData, rSize);
- AIL_set_sample_loop_count(ailSampleHandle, loopCount);
- AIL_start_sample(ailSampleHandle);
- took(rSize);
-}
-
-void singleBuffer::replay(void) {
- assert(ailSampleHandle);
- rSize = lastRSize; //((uint8 *)rData)-((uint8 *)data[0]) ;
- rData = data[0];
- assert(rSize);
- AIL_set_sample_address(ailSampleHandle, rData, rSize);
- AIL_set_sample_loop_count(ailSampleHandle, loopCount);
- AIL_start_sample(ailSampleHandle);
-}
-
void musicBuffer::play(int16 bufNo) {
assert(bufNo == 0);
assert(ailSampleHandle);
@@ -733,10 +406,6 @@ void musicBuffer::play(int16 bufNo) {
took(rSize);
}
-void cacheBuffer::play(int16) {
- hasData = 1;
-}
-
/*******************************************************************/
/* */
/* Used internally to keep track of and prepare buffers for writing*/
@@ -762,39 +431,6 @@ void workBuffer::activate(int16 bufNo) {
}
}
-void doubleBuffer::activate(int16 bufNo) {
- int32 n;
- assert(ailSampleHandle);
- n = bufNo;
- if (washed() > -1) {
- targetSated = false;
- fillBuffer = AILLOCated;
- wSize = size;
- wData = data[fillBuffer];
- rSize = 0;
- rData = data[fillBuffer];
- } else {
- fillBuffer = AILLOCated;
- wSize = 0;
- wData = data[0];
- rSize = 0;
- rData = data[0];
- targetSated = true;
- }
-}
-
-void singleBuffer::activate(int16 bufNo) {
- int32 n;
- assert(ailSampleHandle);
- n = bufNo;
- targetSated = false;
- fillBuffer = 0;
- wSize = size;
- wData = data[fillBuffer];
- rSize = 0;
- rData = data[fillBuffer];
-}
-
void musicBuffer::activate(int16 bufNo) {
int32 n;
assert(ailSampleHandle);
@@ -817,10 +453,6 @@ void musicBuffer::activate(int16 bufNo) {
}
}
-void cacheBuffer::activate(int16 bufNo) {
- assert(bufNo == 0);
-}
-
/*******************************************************************/
/* Initializes a buffer */
@@ -837,30 +469,12 @@ void workBuffer::reset(void) {
activate(0);
}
-void doubleBuffer::reset(void) {
- assert(AILLOCated == -1);
- AIL_init_sample(ailSampleHandle);
- audioSet = 0;
- targetPos = 0;
-}
-
-void singleBuffer::reset(void) {
-// assert( AILLOCated==-1 );
- AIL_init_sample(ailSampleHandle);
- audioSet = 0;
-}
-
void musicBuffer::reset(void) {
AIL_end_sequence(ailSampleHandle);
audioSet = 0;
activate(0);
}
-void cacheBuffer::reset(void) {
- assert(rSize == 0);
- activate(0);
-}
-
/*******************************************************************/
/* Initializes a buffer */
@@ -870,22 +484,6 @@ void Buffer::setVolume(int8) {
void workBuffer::setVolume(int8) {
}
-void doubleBuffer::setVolume(int8 v) {
- if (AIL_sample_volume(ailSampleHandle) != v) {
- AIL_lock();
- AIL_set_sample_volume(ailSampleHandle, v);
- AIL_unlock();
- }
-}
-
-void singleBuffer::setVolume(int8 v) {
- if (AIL_sample_volume(ailSampleHandle) != v) {
- AIL_lock();
- AIL_set_sample_volume(ailSampleHandle, v);
- AIL_unlock();
- }
-}
-
void musicBuffer::setVolume(int8 v) {
if (audioSet) {
if (AIL_sequence_volume(ailSampleHandle) != v) {
@@ -896,9 +494,6 @@ void musicBuffer::setVolume(int8 v) {
}
}
-void cacheBuffer::setVolume(int8) {
-}
-
void musicBuffer::fadeUp(int16 time, int8 volume) {
if (audioSet) {
AIL_lock();
diff --git a/engines/saga2/audiobuf.h b/engines/saga2/audiobuf.h
index 8d485dd7d6..6ff21bffa5 100644
--- a/engines/saga2/audiobuf.h
+++ b/engines/saga2/audiobuf.h
@@ -136,97 +136,6 @@ protected:
void play(int16 bufNo = 0); // internal: use the data
void activate(int16 bufNo); // set buffer to fill & play
};
-
-
-class doubleBuffer : public Buffer {
-private:
- int16 bufID; // for buffer manager
- int16 AILLOCated; // last buffer ( 0, 1 ) reported free
- int16 fillBuffer, // buffer being filled
- targetSated; // target full
- int32 lastPos, distPos; // workaround for AIL sample status
- int32 targetPos;
-
-public:
- HSAMPLE ailSampleHandle; // sample handle
- int audioSet;
-
-
-public:
- int16 ID(void) {
- return bufID; // for buffer Manager
- }
- void abortsound(void); // abort playback
-
- doubleBuffer(size_t newSize, audioInterface *sd, int16 newID);
- ~doubleBuffer(void);
-
- uint32 sample_status(void); // gives the status of the buffer as a whole
- void reset(void); // initialize buffer
- void format(soundSample *ss); // set various sound attribs.
- bool laden(void); // check for full targets
-
- void gave(size_t dSize); // notify amount written
- void took(size_t dSize); // notify amount read
- void fill(void); // convince buffer it is full
-// void abort( void ); // kill sound & return buffer to its heap
- void release(void); // return buffer to its heap
- void setVolume(int8 val); // internal : set buffer to fill & play
-
-protected:
- int16 washed(void); // check for a clean buffer
- void play(int16 bufNo = 0); // internal: use the data
- void activate(int16 bufNo); // set buffer to fill & play
-};
-
-
-class singleBuffer : public Buffer {
-private:
- int16 bufID; // for buffer manager
- int16 AILLOCated; // last buffer ( 0, 1 ) reported free
- int16 fillBuffer, // buffer being filled
- targetSated; // target full
- int16 loopCount;
-
-public:
- HSAMPLE ailSampleHandle; // sample handle
- int16 audioSet;
- uint32 lastRSize; // virtual remaining read size
-
-public:
- int16 ID(void) {
- return bufID; // for buffer Manager
- }
-
- singleBuffer(size_t newSize, audioInterface *sd, int16 newID);
- ~singleBuffer(void);
-
- uint32 sample_status(void); // gives the status of the buffer as a whole
- void reset(void); // initialize buffer
- void format(soundSample *ss); // set various sound attribs.
- bool laden(void); // check for full targets
-
- void gave(size_t dSize); // notify amount written
- void took(size_t dSize); // notify amount read
- void fill(void); // convince buffer it is full
- void replay(void); // kill sound & return buffer to its heap
- void abortsound(void); // kill sound & return buffer to its heap
- void release(void); // return buffer to its heap
- void setVolume(int8 val); // internal : set buffer to fill & play
-
- void setLoopCount(int16 loops) {
- loopCount = loops;
- }
- int16 getLoopCount(void) {
- return loopCount;
- }
-
-protected:
- int16 washed(void); // check for a clean buffer
- void play(int16 bufNo = 0); // internal: use the data
- void activate(int16 bufNo); // set buffer to fill & play
-};
-
class musicBuffer : public Buffer {
private:
int16 bufID; // for buffer manager
@@ -277,38 +186,6 @@ public:
void fadeDown(int16 time);
};
-class cacheBuffer : public Buffer {
-private:
- int16 bufID; // for buffer manager
- soundSample *sformat;
- int16 hasData;
-
-public:
- int16 ID(void) {
- return bufID; // for buffer Manager
- }
-
- cacheBuffer(size_t newSize, int16 newID);
- ~cacheBuffer(void);
-
- uint32 sample_status(void); // gives the status of the buffer as a whole
- void reset(void); // initialize buffer
- void format(soundSample *ss); // set various sound attribs.
- bool laden(void); // check for full targets
-
- void gave(size_t dSize); // notify amount written
- void took(size_t dSize); // notify amount read
- void fill(void); // convince buffer it is full
- void abortsound(void); // kill sound & return buffer to its heap
- void release(void); // return buffer to its heap
- void setVolume(int8 val); // internal : set buffer to fill & play
-
-protected:
- int16 washed(void); // check for a clean buffer
- void play(int16 bufNo = 0); // internal: use the data
- void activate(int16 bufNo); // set buffer to fill & play
-};
-
} // end of namespace Saga2
#endif
Commit: 16ce00056d7e3f1748a1ce3ecf56eae3fc341775
https://github.com/scummvm/scummvm/commit/16ce00056d7e3f1748a1ce3ecf56eae3fc341775
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:28+02:00
Commit Message:
SAGA2: Fix warnings in noise.cpp
Changed paths:
engines/saga2/beegee.cpp
engines/saga2/noise.cpp
diff --git a/engines/saga2/beegee.cpp b/engines/saga2/beegee.cpp
index 4401ccd2d2..5f954c26d5 100644
--- a/engines/saga2/beegee.cpp
+++ b/engines/saga2/beegee.cpp
@@ -163,7 +163,7 @@ void killAllAuxThemes(void) {
//-----------------------------------------------------------------------
// Hooks to allow other loops to play
-void disableBGLoop(int32 s) {
+void disableBGLoop(bool s) {
playingExternalLoop = s;
}
@@ -239,7 +239,7 @@ void setAreaSound(const TilePoint &) {
loopID = 0;
}
audioEnvironmentUseSet(loopID, ss, themePos << kPlatShift);
- } else if (playingExternalLoop != -1) {
+ } else if (!playingExternalLoop) {
audioEnvironmentUseSet(playingExternalLoop, 0, Point16(0, 0)); //themePos << kPlatShift);
}
}
diff --git a/engines/saga2/noise.cpp b/engines/saga2/noise.cpp
index 583b0af9f6..d7f89ff99e 100644
--- a/engines/saga2/noise.cpp
+++ b/engines/saga2/noise.cpp
@@ -37,6 +37,7 @@
#include "saga2/audqueue.h"
#include "saga2/audiosys.h"
#include "saga2/config.h"
+#include "saga2/hresmgr.h"
namespace Saga2 {
@@ -122,7 +123,7 @@ static audioAttenuationFunction oldAttenuator;
#define killIt(p) if (p) delete p; p=NULL
bool haveKillerSoundCard(void);
void writeConfig(void);
-void disableBGLoop(int32 s = -1);
+void disableBGLoop(bool s = true);
void enableBGLoop(void);
void audioStressTest(void);
extern GameObject *getViewCenterObject(void);
@@ -225,7 +226,6 @@ static ATTENUATOR(volumeFromDist) {
// after system initialization - startup code
void startAudio(void) {
- bool disVoice, disMusic, disSound, disLoops;
audioInterfaceSettings audioBufferSizes = audioInterfaceSettings(
(int16) 2, // number of sound buffers
(uint32) 32768, // voice buffer size 32k
@@ -234,14 +234,18 @@ void startAudio(void) {
(uint32) 400000 // sound buffer size
);
+ bool disVoice = false, disMusic= false, disSound= false, disLoops= false;
warning("STUB: startAudio, sync sound settings");
#if 0
+
disMusic = !GetPrivateProfileInt("Sound", "Music", 1, iniFile);
disVoice = !GetPrivateProfileInt("Sound", "Voice", 1, iniFile);
disLoops = !GetPrivateProfileInt("Sound", "Loops", 1, iniFile);
disSound = !GetPrivateProfileInt("Sound", "Sound", 1, iniFile);
+#endif
+
+ return;
- assert(audio);
if (audio->active()) {
voiceDec = new decoderSet();
voiceDec->addDecoder(new soundDecoder(&readVoice, &seekVoice, &flushVoice));
@@ -262,9 +266,7 @@ void startAudio(void) {
memDec = new decoderSet();
memDec->addDecoder(new soundDecoder(&readMemSound, &seekMemSound, &flushMemSound));
- uint32 musicID =
- haveKillerSoundCard() ? goodMusicID :
- baseMusicID;
+ uint32 musicID = haveKillerSoundCard() ? goodMusicID : baseMusicID;
if (!disMusic) {
musicRes = soundResFile->newContext(musicID, "music resource");
@@ -318,14 +320,6 @@ void startAudio(void) {
clickData[2] = (uint8 *) LoadResource(soundRes, MKTAG('C', 'L', 'K', 2), "Click 2");
}
-#if 0
- disMusic = !GetPrivateProfileInt("Sound", "Music", 1, iniFile);
- disVoice = !GetPrivateProfileInt("Sound", "Voice", 1, iniFile);
- disLoops = !GetPrivateProfileInt("Sound", "Loops", 1, iniFile);
- disSound = !GetPrivateProfileInt("Sound", "Sound", 1, iniFile);
-#endif
- warning("STUB: startAudio, sync sound settings");
-
#if DEBUG
if (debugStatuses) {
WriteStatusF(5, audio->statusMessage());
@@ -341,7 +335,6 @@ void startAudio(void) {
audio->disable(volLoops);
if (disSound)
audio->disable(volSound);
-#endif
}
//-----------------------------------------------------------------------
@@ -388,13 +381,8 @@ char msg[80];
// check for higher quality MIDI card
bool haveKillerSoundCard(void) {
-#ifndef _WIN32
- if (audio && audio->mid != NULL)
- return audio->goodMIDICard();
- return false;
-#else
- return GetPrivateProfileInt("Sound", "WavetableMIDI", 1, iniFile);
-#endif
+ warning("STUB: haveKillerSoundCard()"); // Check here for sound card type
+ return true;
}
//-----------------------------------------------------------------------
@@ -420,7 +408,7 @@ HDIGDRIVER &digitalAudioDriver(void) {
void suspendLoops(void) {
- disableBGLoop(0);
+ disableBGLoop(false);
}
void resumeLoops(void) {
@@ -540,11 +528,12 @@ void playLongSound(uint32 s) {
void playVoice(uint32 s) {
#ifndef AUDIO_DISABLED
- if (hResCheckResID(voiceRes, s))
+ if (hResCheckResID(voiceRes, s)) {
if (s)
audio->queueVoice(s, voiceDec, Here);
else
audio->stopVoice();
+ }
#endif
}
@@ -692,7 +681,7 @@ bool stillDoingVoice(uint32 sampno) {
uint32 parse_res_id(char IDstr[]) {
uint32 a[5] = {0, 0, 0, 0, 0};
- uint32 a2, res = 0;
+ uint32 a2;
uint32 i, j;
assert(IDstr != NULL);
if (strlen(IDstr)) {
Commit: 5e519d2ca54f3f476b834e99037e60618ae04ea9
https://github.com/scummvm/scummvm/commit/5e519d2ca54f3f476b834e99037e60618ae04ea9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:28+02:00
Commit Message:
SAGA2: Remove errors.h
Changed paths:
R engines/saga2/errors.h
engines/saga2/automap.cpp
engines/saga2/button.cpp
engines/saga2/document.cpp
engines/saga2/gdraw.cpp
engines/saga2/gdraw.h
engines/saga2/gtextbox.cpp
engines/saga2/intrface.cpp
diff --git a/engines/saga2/automap.cpp b/engines/saga2/automap.cpp
index 9d2c60fe80..686097c22e 100644
--- a/engines/saga2/automap.cpp
+++ b/engines/saga2/automap.cpp
@@ -164,7 +164,7 @@ CAutoMap::CAutoMap(const Rect16 box,
summaryData = summary;
// init the temporary blit surface port
- if (NewTempPort(tPort, sumMapArea.width, sumMapArea.height) != errOK) {
+ if (!NewTempPort(tPort, sumMapArea.width, sumMapArea.height)) {
return;
}
diff --git a/engines/saga2/button.cpp b/engines/saga2/button.cpp
index 3fa7d1e392..fb1b3965ba 100644
--- a/engines/saga2/button.cpp
+++ b/engines/saga2/button.cpp
@@ -356,8 +356,8 @@ void gSpriteImage::drawClipped(gPort &port,
void gCompButton::loadImages(hResContext *con, hResID res1, hResID res2) {
if (con) {
- checkAlloc(forImage = LoadResource(con, res1, "CBtn fore image"));
- checkAlloc(resImage = LoadResource(con, res2, "CBtn res image"));
+ forImage = LoadResource(con, res1, "CBtn fore image");
+ resImage = LoadResource(con, res2, "CBtn res image");
dimImage = NULL;
} else {
forImage = NULL;
@@ -690,8 +690,6 @@ gMultCompButton::gMultCompButton(gPanelList &list, const Rect16 &box, hResContex
for (i = 0, k = resStart; i < numRes; i++, k++) {
images[i] = LoadResource(con, MKTAG(a, b, c, k), "Multi btn image");
-
- checkAlloc(images[i]);
}
response = true;
diff --git a/engines/saga2/document.cpp b/engines/saga2/document.cpp
index 095323e500..1388cf9d19 100644
--- a/engines/saga2/document.cpp
+++ b/engines/saga2/document.cpp
@@ -735,7 +735,7 @@ void CDocument::renderText(void) {
Rect16 bltRect(0, 0, extent.width, extent.height);
- if (NewTempPort(tPort, bltRect.width, bltRect.height) == errOK) {
+ if (NewTempPort(tPort, bltRect.width, bltRect.height)) {
// clear out the text buffer
int16 i, k;
uint8 *buffer = (uint8 *)tPort.map->data;
diff --git a/engines/saga2/errors.h b/engines/saga2/errors.h
deleted file mode 100644
index 255bd7a42a..0000000000
--- a/engines/saga2/errors.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * aint32 with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#ifndef SAGA2_ERRORS_H
-#define SAGA2_ERRORS_H
-
-namespace Saga2 {
-
-enum errorCodes {
- errOK = 0, // no error
- errUnknown, // unspecified error
- errNoMemory, // couldn't get memory
- errNoMouse, // couldn't find mouse driver
- errNoFont, // couldn't load a font
- errNoFile, // file or directory not found
- errNoAccess, // Access denied
-
- // hardware error codes
- errDeviceError,
- errWriteProtect,
- errDriveNotReady,
- errDiskError
-};
-
-const int errDosError = (1 << 15); // an error from 'errno'
-
-typedef int16 errorCode; // typedef for errors
-
-/* ===================================================================== *
- Error Functions
- * ===================================================================== */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void fatal(char *msg, ...);
-void memerr(void);
-void checkAlloc(void *ptr);
-errorCode dosErrCode(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-} // end of namespace Saga2
-
-#endif
diff --git a/engines/saga2/gdraw.cpp b/engines/saga2/gdraw.cpp
index 4aa14e7ea9..c7fdb8cf3e 100644
--- a/engines/saga2/gdraw.cpp
+++ b/engines/saga2/gdraw.cpp
@@ -965,7 +965,7 @@ void mapImage(gPort &from, gPort &to, gPen map[]) {
*
**********************************************************************
*/
-errorCode NewTempPort(gPort &port, int width, int height) {
+bool NewTempPort(gPort &port, int width, int height) {
gPixelMap *map;
map = (gPixelMap *)TempAlloc(width * height + sizeof(gPixelMap));
@@ -974,9 +974,9 @@ errorCode NewTempPort(gPort &port, int width, int height) {
map->size.x = width;
map->size.y = height;
port.setMap(map);
- return errOK;
+ return true;
} else
- return errNoMemory;
+ return false;
}
/****** gdraw.cpp/DisposeTempPort *********************************
diff --git a/engines/saga2/gdraw.h b/engines/saga2/gdraw.h
index 4888e49526..60ea66933f 100644
--- a/engines/saga2/gdraw.h
+++ b/engines/saga2/gdraw.h
@@ -28,7 +28,6 @@
#define SAGA2_GDRAW_H
#include "saga2/rect.h"
-#include "saga2/errors.h"
namespace Saga2 {
@@ -408,7 +407,7 @@ public:
void mapImage(gPort &from, gPort &to, gPen map[]);
void mapImage(gPixelMap &from, gPixelMap &to, gPen map[]);
-errorCode NewTempPort(gPort &, int width, int height);
+bool NewTempPort(gPort &, int width, int height);
void DisposeTempPort(gPort &);
/* ============================================================================ *
diff --git a/engines/saga2/gtextbox.cpp b/engines/saga2/gtextbox.cpp
index 544e76ddc4..a1ac25d64f 100644
--- a/engines/saga2/gtextbox.cpp
+++ b/engines/saga2/gtextbox.cpp
@@ -907,7 +907,7 @@ void gTextBox::drawContents(void) {
aPos = MAX(cursorPos, anchorPos);
// Allocate a temporary pixel map and render into it.
- if (NewTempPort(tPort, editRect.width, editRect.height) == errOK) {
+ if (NewTempPort(tPort, editRect.width, editRect.height)) {
int16 cursorX,
anchorX,
hiliteX,
@@ -1053,7 +1053,7 @@ void gTextBox::drawAll(gPort &port,
bufRect.height = editBaseRect.height;
// Allocate a temporary pixel map and render into it.
- if (NewTempPort(tempPort, bufRect.width, bufRect.height) == errOK) {
+ if (NewTempPort(tempPort, bufRect.width, bufRect.height)) {
Rect16 workRect;
workRect = bufRect;
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index 7cc5af87ac..8f5e59f213 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -1087,7 +1087,8 @@ void CManaIndicator::drawClipped(gPort &port,
gPixelMap ringMap, starMap, mixMap, tempMap;
- if (NewTempPort(tempPort, xSize, ySize) != errOK) return;
+ if (!NewTempPort(tempPort, xSize, ySize))
+ return;
// set the blit surface to a flat black
memset(tempPort.map->data, 24, tempPort.map->bytes());
Commit: bf9154a01ac6a0dd0978b34d1a85fb746881669b
https://github.com/scummvm/scummvm/commit/bf9154a01ac6a0dd0978b34d1a85fb746881669b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:28+02:00
Commit Message:
SAGA2: Fix warnings in path.cpp
Changed paths:
engines/saga2/path.cpp
diff --git a/engines/saga2/path.cpp b/engines/saga2/path.cpp
index 159226fbbc..cdf5775830 100644
--- a/engines/saga2/path.cpp
+++ b/engines/saga2/path.cpp
@@ -76,8 +76,6 @@ const int straightBaseCost = 4,
diagNormalCost = diagBaseCost + 6,
diagHardCost = diagBaseCost + 12;
-const int maskSize = 4;
-
const int subMetaSize = 4,
subMetaShift = 2,
subMetaMask = subMetaSize - 1;
@@ -1016,16 +1014,14 @@ int16 tileSlopeHeight(
// See if the tile is a potential supporting surface
if (tileBase < pt.z + objProtHt
&& supportHeight >= highestSupportHeight
- && (ti->combinedTerrainMask() &
- terrainSurface | terrainRaised)) {
+ && (ti->combinedTerrainMask() & (terrainSurface | terrainRaised))) {
highestTileFlag = true;
highestTile = *pti;
highestSupportHeight = supportHeight;
highestSupportPlatform = i;
} else if (!highestTileFlag &&
supportHeight <= lowestSupportHeight &&
- (ti->combinedTerrainMask() &
- terrainSurface | terrainRaised)) {
+ (ti->combinedTerrainMask() & (terrainSurface | terrainRaised))) {
lowestTileFlag = true;
lowestTile = *pti;
lowestSupportHeight = supportHeight;
@@ -1106,12 +1102,10 @@ protected:
// Calculates the center point given the base coordinate of the
// cell array and a queue item which contains cell coordinates.
- static void calcCenterPt(
- const TilePoint &baseTileCoords,
- const QueueItem &qi) {
- centerPt.u = ((baseTileCoords.u + qi.u) << kTileUVShift)
+ static void calcCenterPt(const TilePoint &baseTileCoords_, const QueueItem &qi) {
+ centerPt.u = ((baseTileCoords_.u + qi.u) << kTileUVShift)
+ kTileUVSize / 2;
- centerPt.v = ((baseTileCoords.v + qi.v) << kTileUVShift)
+ centerPt.v = ((baseTileCoords_.v + qi.v) << kTileUVShift)
+ kTileUVSize / 2;
centerPt.z = qi.z;
@@ -1122,6 +1116,8 @@ protected:
PathRequest(Actor *a, int16 howSmart);
public:
+ virtual ~PathRequest() {}
+
void requestAbort(void) {
flags |= aborted;
}
@@ -1261,8 +1257,6 @@ public:
Globals
* ===================================================================== */
-const int numPathRequests = 32; // up to 32 messages allowed
-
Common::List<WanderPathRequest *> pathRequestPool;
DList pathQueue;
@@ -1683,22 +1677,18 @@ void PathRequest::abortReq(void) {
}
-static uint32 severePathFinderOverruns = 0;
-
PathResult PathRequest::findPath(void) {
assert(cellArray != nullptr);
- static const uint8 costTable[] =
- { 4, 10, 12, 16, 12, 10, 4, 0, 4, 10, 12, 16, 12, 10, 4, 0 };
+ static const uint8 costTable[] = { 4, 10, 12, 16, 12, 10, 4, 0, 4, 10, 12, 16, 12, 10, 4, 0 };
- int32 lastTick;
ProtoObj *proto = actor->proto();
QueueItem qi;
uint8 pCross = proto->crossSection;
if (flags & aborted) return pathAborted;
- lastTick = gameTime;
+ int32 lastTick_ = gameTime;
while (queue.remove(qi)) {
assert(cellArray->getCell(qi.platform, qi.u, qi.v) != nullptr);
@@ -2024,7 +2014,7 @@ big_continue:
;
}
- if ((gameTime - lastTick) >= 4) { // JEFFKLUDGE
+ if ((gameTime - lastTick_) >= 4) { // JEFFKLUDGE
if (timeLimitExceeded())
return pathDone;
}
@@ -2462,13 +2452,10 @@ TilePoint selectNearbySite(
int32 bestRating = -100,
bestPossible = (maxDist - minDist) / 2;
- SimpleCellArray *cellArray;
-
QueueItem qi;
// Allocate the array of cells
- cellArray = (SimpleCellArray *)
- malloc(sizeof * cellArray);
+ SimpleCellArray *cellArray1 = (SimpleCellArray *)malloc(sizeof * cellArray1);
// Nowhere indicates failure of the algorithm.
bestLoc = Nowhere;
@@ -2483,7 +2470,7 @@ TilePoint selectNearbySite(
baseCoords.z = 0;
// Clear the search array and the queue
- memset(cellArray, cellUnvisited, sizeof(*cellArray));
+ memset(cellArray1, cellUnvisited, sizeof(*cellArray1));
squeue.clear();
// Iterate through all actors in the region and mark areas
@@ -2518,7 +2505,7 @@ TilePoint selectNearbySite(
// If that tile is in the search area, then mark it.
if (objLoc.u >= 0 && objLoc.u < searchDiameter
&& objLoc.v >= 0 && objLoc.v < searchDiameter) {
- (*cellArray)[objLoc.u][objLoc.v] = cellOccupied;
+ (*cellArray1)[objLoc.u][objLoc.v] = cellOccupied;
}
}
@@ -2559,7 +2546,7 @@ TilePoint selectNearbySite(
// If this is the best cell found so far, and it is not
// occupied, then mark it as the best cell.
if (rating > bestRating
- && !((*cellArray)[qi.u][qi.v] & cellOccupied)) {
+ && !((*cellArray1)[qi.u][qi.v] & cellOccupied)) {
bool cellOK = true;
// if this point is on-screen, we might want to reject it...
@@ -2607,7 +2594,7 @@ TilePoint selectNearbySite(
uint16 *moveMask = &sTerrainMasks[dir - 1];
tDir = &tDirTable2[dir];
- cell = &(*cellArray)[qi.u + tDir->u][qi.v + tDir->v];
+ cell = &(*cellArray1)[qi.u + tDir->u][qi.v + tDir->v];
// Only visit each cell once. Do this before terrain
// is checked, to save time.
@@ -2682,7 +2669,7 @@ TilePoint selectNearbySite(
}
}
- free(cellArray);
+ free(cellArray1);
return bestLoc != Nowhere
? TilePoint(
@@ -2692,65 +2679,6 @@ TilePoint selectNearbySite(
: Nowhere;
}
-#if 0
-
-// Put a and b in ascending order.
-
-inline void order(int16 &a, int16 &b) {
- if (a > b) {
- int16 t = a;
- a = b;
- b = t;
- }
-}
-
-/*
-template<class T> inline void order( T &a, T &b )
-{
- if (a > b) { T t = a; a = b; b = t; }
-}
-*/
-
-TilePoint selectDistantSite(
- Object worldID,
- TilePoint minCoords, // coords in tiles (ul of rect)
- TilePoint maxCoords, // coords in tiles (lr of rect)
- int metaProperties) {
- GameWorld *world = (GameWorld *)GameObject::objectAddress(worldID);
- int32 u, v;
- int32 mapSize = mapList[world->mapNum].mapSize * kPlatformWidth;
- int matchCount = 0;
-
- // Make sure the location spec'd is within the bounds of the map
- minCoords.u = clamp(0, minCoords.u, mapSize);
- minCoords.v = clamp(0, minCoords.v, mapSize);
- maxCoords.u = clamp(0, maxCoords.u, mapSize);
- maxCoords.v = clamp(0, maxCoords.v, mapSize);
-
- // Make sure that the coords are in order
- order(minCoords.u, maxCoords.u);
- order(minCoords.v, maxCoords.v);
-
- // convert to metatile coords
- minCoords.u = minCoords.u >> platformShift;
- minCoords.v = minCoords.v >> platformShift;
- maxCoords.u = (maxCoords.u + kPlatformWidth - 1) >> platformShift;
- maxCoords.v = (maxCoords.v + kPlatformWidth - 1) >> platformShift;
-
- // Now, scan that area for metatiles...
- for (u = minCoords.u; u < maxCoords.u; u++) {
- for (v = minCoords.v; v < maxCoords.v; v++) {
- // Check the metatile at this location,
- // and determine if it has the correct properties.
-
- // Need to ask David R. how to use meta properties...
- }
- }
-}
-
-
-#endif
-
bool checkPath(
ObjectID worldID,
uint8 height,
@@ -2772,8 +2700,6 @@ bool checkPath(
int16 mapNum = GameWorld::IDtoMapNum(worldID);
- SimpleCellArray *cellArray;
-
QueueItem qi;
StandingTileInfo sti;
@@ -2799,8 +2725,8 @@ bool checkPath(
return false;
// Allocate the array of cells
- cellArray = (SimpleCellArray *)malloc(sizeof * cellArray);
- if (cellArray == nullptr)
+ SimpleCellArray *cellArray1 = (SimpleCellArray *)malloc(sizeof(*cellArray1));
+ if (cellArray1 == nullptr)
return false;
// Calculate where search cells will be projected onto map
@@ -2813,7 +2739,7 @@ bool checkPath(
baseCoords.z = 0;
// Clear the search array and the queue
- memset(cellArray, cellUnvisited, sizeof(*cellArray));
+ memset(cellArray1, cellUnvisited, sizeof(* cellArray1));
squeue.clear();
// Push the starting location in the center of the array.
@@ -2904,7 +2830,7 @@ bool checkPath(
testTileCoords.v = centerTileCoords.v + tDir->v;
testTileCoords.z = 0;
- cell = &(*cellArray)[qi.u + tDir->u][qi.v + tDir->v];
+ cell = &(*cellArray1)[qi.u + tDir->u][qi.v + tDir->v];
// Only visit each cell once..
if (*cell & cellVisited) continue;
@@ -2966,7 +2892,7 @@ bool checkPath(
// If we're there, we're done
if (testTileCoords == destTileCoords) {
- free(cellArray);
+ free(cellArray1);
// If the resulting height is significantly different
// from the destination height, assume we're on a
@@ -2984,7 +2910,7 @@ bool checkPath(
}
}
- free(cellArray);
+ free(cellArray1);
// If we're here we've haven't found a path
return false;
Commit: cfb64ca4d628ed5d4df42aa7b7152d1613ebb43b
https://github.com/scummvm/scummvm/commit/cfb64ca4d628ed5d4df42aa7b7152d1613ebb43b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:28+02:00
Commit Message:
SAGA2: Fix warnings in button.cpp
Changed paths:
engines/saga2/button.cpp
diff --git a/engines/saga2/button.cpp b/engines/saga2/button.cpp
index fb1b3965ba..a99aa67ddb 100644
--- a/engines/saga2/button.cpp
+++ b/engines/saga2/button.cpp
@@ -826,7 +826,7 @@ void *gSlider::getCurrentCompImage(void) {
}
int16 gSlider::getSliderLenVal(void) {
- int16 val;
+ int16 val = 0;
if (slValMin < 0 && slValMax < 0) {
val = slValMax - slValMin;
@@ -843,7 +843,6 @@ int16 gSlider::getSliderLenVal(void) {
void gSlider::draw(void) {
gPort &port = window.windowPort;
- Rect16 rect = window.getExtent();
Point16 offset = Point16(0, 0);
SAVE_GPORT_STATE(port); // save pen color, etc.
Commit: f4203b3d277c5cad597eba96901eeb2b05e30074
https://github.com/scummvm/scummvm/commit/f4203b3d277c5cad597eba96901eeb2b05e30074
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:28+02:00
Commit Message:
SAGA2: Get rid of checkAlloc()
Changed paths:
engines/saga2/automap.cpp
engines/saga2/contain.cpp
engines/saga2/document.cpp
engines/saga2/fta.h
engines/saga2/imagcach.cpp
engines/saga2/intrface.cpp
engines/saga2/uidialog.cpp
diff --git a/engines/saga2/automap.cpp b/engines/saga2/automap.cpp
index 686097c22e..e4ef13e2b6 100644
--- a/engines/saga2/automap.cpp
+++ b/engines/saga2/automap.cpp
@@ -538,21 +538,17 @@ int16 openAutoMap() {
decRes = resFile->newContext(MKTAG('A', 'M', 'A', 'P'), "Automap Resources");
// debug
- checkAlloc(summaryData = LoadResource(decRes,
- MKTAG('S', 'U', 'M', currentMapNum),
- "summary data"));
+ summaryData = LoadResource(decRes, MKTAG('S', 'U', 'M', currentMapNum), "summary data");
// get the graphics associated with the buttons
- checkAlloc(closeBtnImage = loadButtonRes(decRes, closeButtonResID, numBtnImages));
- checkAlloc(scrollBtnImage = loadButtonRes(decRes, scrollButtonResID, 2));
+ closeBtnImage = loadButtonRes(decRes, closeButtonResID, numBtnImages);
+ scrollBtnImage = loadButtonRes(decRes, scrollButtonResID, 2);
pAutoMap = new CAutoMap(autoMapRect, (uint8 *)summaryData, 0, NULL);
- checkAlloc(closeAutoMap = new gCompButton(*pAutoMap, closeAutoMapBtnRect,
- closeBtnImage, numBtnImages, 0, cmdAutoMapQuit));
+ closeAutoMap = new gCompButton(*pAutoMap, closeAutoMapBtnRect, closeBtnImage, numBtnImages, 0, cmdAutoMapQuit);
- checkAlloc(scrollBtn = new gCompButton(*pAutoMap, scrollBtnRect,
- scrollBtnImage, numBtnImages, 0, cmdAutoMapScroll));
+ scrollBtn = new gCompButton(*pAutoMap, scrollBtnRect, scrollBtnImage, numBtnImages, 0, cmdAutoMapScroll);
pAutoMap->setDecorations(autoMapDecorations,
elementsof(autoMapDecorations),
diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index d1ba065f54..710ae7801c 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -1274,8 +1274,6 @@ TangibleContainerWindow::TangibleContainerWindow(
Point16(app.massRect.x, app.massRect.y),
weightIndicatorType,
deathFlag);
- checkAlloc(massWeightIndicator);
-
}
}
@@ -1768,9 +1766,8 @@ ContainerNode *OpenMindContainer(PlayerActorID player, int16 open, int16 type) {
void initContainers(void) {
if (containerRes == NULL)
containerRes = resFile->newContext(MKTAG('C', 'O', 'N', 'T'), "cont.resources");
- checkAlloc(containerRes);
- checkAlloc(selImage = ImageCache.requestImage(imageRes, MKTAG('A', 'M', 'N', 'T')));
+ selImage = ImageCache.requestImage(imageRes, MKTAG('A', 'M', 'N', 'T'));
}
void cleanupContainers(void) {
diff --git a/engines/saga2/document.cpp b/engines/saga2/document.cpp
index 1388cf9d19..4601954437 100644
--- a/engines/saga2/document.cpp
+++ b/engines/saga2/document.cpp
@@ -918,18 +918,13 @@ int16 openScroll(uint16 textScript) {
decRes = resFile->newContext(MKTAG('S', 'C', 'R', 'L'), "book resources");
// get the graphics associated with the buttons
- checkAlloc(closeBtnImage = loadButtonRes(decRes, buttonResID, numBtnImages));
+ closeBtnImage = loadButtonRes(decRes, buttonResID, numBtnImages);
// create the window
- checkAlloc(win = new CDocument(scrollAppearance,
- bookText,
- &Script10Font,
- 0,
- NULL));
+ win = new CDocument(scrollAppearance, bookText, &Script10Font, 0, NULL);
// make the quit button
- checkAlloc(closeScroll = new gCompButton(*win, scrollAppearance.closeRect,
- closeBtnImage, numBtnImages, 0, cmdDocumentQuit));
+ closeScroll = new gCompButton(*win, scrollAppearance.closeRect, closeBtnImage, numBtnImages, 0, cmdDocumentQuit);
closeScroll->accelKey = 0x1B;
@@ -973,16 +968,11 @@ int16 openBook(uint16 textScript) {
CDocument *win = NULL;
// create the window
- checkAlloc(win = new CDocument(bookAppearance,
- bookText,
- &Script10Font,
- 0,
- NULL));
+ win = new CDocument(bookAppearance, bookText, &Script10Font, 0, NULL);
gCompButton *t;
// make the quit button
- checkAlloc(t = new gCompButton(*win, bookAppearance.closeRect,
- "doc close", 0, cmdDocumentQuit));
+ t = new gCompButton(*win, bookAppearance.closeRect, "doc close", 0, cmdDocumentQuit);
t->accelKey = 0x1B;
// attach the structure to the book, open the book
@@ -1018,15 +1008,10 @@ int16 openParchment(uint16 textScript) {
CDocument *win = NULL;
// create the window
- checkAlloc(win = new CDocument(parchAppearance,
- bookText,
- &Script10Font,
- 0,
- NULL));
+ win = new CDocument(parchAppearance, bookText, &Script10Font, 0, NULL);
gCompButton *t;
// make the quit button
- checkAlloc(t = new gCompButton(*win, parchAppearance.closeRect,
- "doc close", 0, cmdDocumentQuit));
+ t = new gCompButton(*win, parchAppearance.closeRect, "doc close", 0, cmdDocumentQuit);
t->accelKey = 0x1B;
// attach the structure to the book, open the book
diff --git a/engines/saga2/fta.h b/engines/saga2/fta.h
index a9c8c64f2c..fe247abe4c 100644
--- a/engines/saga2/fta.h
+++ b/engines/saga2/fta.h
@@ -192,8 +192,6 @@ void restoreProgramDir(void); // chdir() to program directory
void *mustAlloc(uint32 size, const char desc[]); // alloc 'size' bytes or fail
RHANDLE mustAllocHandle(uint32 size, const char desc[]); // as above, but relocatable
-//void checkAlloc( void *ptr ); // check allocation
-#define checkAlloc(ptr) (ptr)
// Returns Random Number
diff --git a/engines/saga2/imagcach.cpp b/engines/saga2/imagcach.cpp
index ce0a6bbcf5..f0918184ef 100644
--- a/engines/saga2/imagcach.cpp
+++ b/engines/saga2/imagcach.cpp
@@ -176,7 +176,6 @@ void *CImageCache::requestImage(hResContext *con, uint32 resID) {
// ptr to the new image resource
// creates node and loads in the resource
imageNode = new CImageNode(con, resID);
- checkAlloc(imageNode);
// add this node to the list
nodes.addTail(*imageNode);
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index 8f5e59f213..f2ab3cd5b1 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -806,40 +806,40 @@ CMassWeightIndicator::CMassWeightIndicator(gPanelList *panel, const Point16 &pos
// setup mass/bulk indicator imagery
if (death) {
- checkAlloc(massBulkImag = ImageCache.requestImage(containerRes, MKTAG('D', 'J', 'B', massBulkResNum)));
+ massBulkImag = ImageCache.requestImage(containerRes, MKTAG('D', 'J', 'B', massBulkResNum));
- checkAlloc(pieIndImag = loadImageRes(containerRes, pieIndResNum, numPieIndImages, 'D', 'A', 'J'));
+ pieIndImag = loadImageRes(containerRes, pieIndResNum, numPieIndImages, 'D', 'A', 'J');
} else {
- checkAlloc(massBulkImag = ImageCache.requestImage(containerRes, MKTAG('G', 'J', 'B', massBulkResNum)));
+ massBulkImag = ImageCache.requestImage(containerRes, MKTAG('G', 'J', 'B', massBulkResNum));
- checkAlloc(pieIndImag = loadImageRes(containerRes, pieIndResNum, numPieIndImages, 'G', 'A', 'J'));
+ pieIndImag = loadImageRes(containerRes, pieIndResNum, numPieIndImages, 'G', 'A', 'J');
}
// attach controls to the indivControls panel
// these butttons will get deactivated along with the panel
- checkAlloc(pieMass = new gCompImage(*panel,
+ pieMass = new gCompImage(*panel,
Rect16(massPiePos.x, massPiePos.y, pieXSize, pieYSize),
pieIndImag,
numPieIndImages,
0,
type,
- cmdMassInd));
+ cmdMassInd);
- checkAlloc(pieBulk = new gCompImage(*panel,
+ pieBulk = new gCompImage(*panel,
Rect16(bulkPiePos.x, bulkPiePos.y, pieXSize, pieYSize),
pieIndImag,
numPieIndImages,
0,
type,
- cmdBulkInd));
+ cmdBulkInd);
// mass/bulk back image
- checkAlloc(new gCompImage(*panel,
+ new gCompImage(*panel,
Rect16(backImagePos.x, backImagePos.y, backImageXSize, backImageYSize),
massBulkImag,
uiIndiv,
- nullptr));
+ nullptr);
// release resource context
if (containerRes) {
@@ -937,24 +937,17 @@ CManaIndicator::CManaIndicator(gPanelList &list) : gCompImage(list,
assert(resFile);
// init the resource handle with the mana resource group
- resContext = resFile->newContext(MKTAG('M', 'A', 'N', 'A'),
- "mana context");
+ resContext = resFile->newContext(MKTAG('M', 'A', 'N', 'A'), "mana context");
// load star images
- checkAlloc(starImages = loadImageRes(resContext,
- starResNum,
- numStars,
- 'S', 'T', 'A'));
+ starImages = loadImageRes(resContext, starResNum, numStars, 'S', 'T', 'A');
// load in the ring images
- checkAlloc(ringImages = loadImageRes(resContext,
- ringResNum,
- numRings,
- 'R', 'N', 'G'));
+ ringImages = loadImageRes(resContext, ringResNum, numRings, 'R', 'N', 'G');
- checkAlloc(backImage = ImageCache.requestImage(resContext, MKTAG('B', 'A', 'C', 'K')));
+ backImage = ImageCache.requestImage(resContext, MKTAG('B', 'A', 'C', 'K'));
- checkAlloc(wellImage = ImageCache.requestImage(resContext, MKTAG('W', 'E', 'L', 'L')));
+ wellImage = ImageCache.requestImage(resContext, MKTAG('W', 'E', 'L', 'L'));
// hmm this could be cleaner...
starRingEndPos[0] = Point16(redEndX, redEndY);
@@ -1322,10 +1315,10 @@ CHealthIndicator::CHealthIndicator(AppFunc *cmd) {
healthRes = resFile->newContext(imageGroupID, "health imagery context");
// load in health star imagery
- checkAlloc(starImag = loadButtonRes(healthRes, starStart, starNum, 'S', 'T', 'A'));
+ starImag = loadButtonRes(healthRes, starStart, starNum, 'S', 'T', 'A');
// load in the health star border
- checkAlloc(starFrameImag = ImageCache.requestImage(healthRes, MKTAG('B', 'T', 'N', starFrameResNum)));
+ starFrameImag = ImageCache.requestImage(healthRes, MKTAG('B', 'T', 'N', starFrameResNum));
// set the image indexes to nominal startup values
for (i = 0; i < numControls + 1; i++) {
@@ -1341,7 +1334,7 @@ CHealthIndicator::CHealthIndicator(AppFunc *cmd) {
// health controls for the trio view
// deallocated with panel
for (i = 0; i < numControls; i++) {
- checkAlloc(starBtns[i] = new gCompImage(*trioControls,
+ starBtns[i] = new gCompImage(*trioControls,
Rect16(starXPos,
starYPos + starYOffset * i,
starXSize,
@@ -1350,24 +1343,24 @@ CHealthIndicator::CHealthIndicator(AppFunc *cmd) {
starNum,
starInitial,
starIDs[i],
- cmd));
+ cmd);
// image control for the star border/frame trio mode
- checkAlloc(new gCompImage(*trioControls,
+ new gCompImage(*trioControls,
Rect16(frameXPos,
frameYPos + starYOffset * i,
frameXSize,
frameYSize),
starFrameImag,
0,
- nullptr));
+ nullptr);
}
// health control for individual mode
// deallocated with panel
- checkAlloc(indivStarBtn = new gCompImage(*indivControls,
+ indivStarBtn = new gCompImage(*indivControls,
Rect16(starXPos,
starYPos,
starXSize,
@@ -1376,17 +1369,17 @@ CHealthIndicator::CHealthIndicator(AppFunc *cmd) {
starNum,
starInitial,
uiIndiv,
- cmd));
+ cmd);
// image control for the star border/frame indiv mode
- checkAlloc(new gCompImage(*indivControls,
+ new gCompImage(*indivControls,
Rect16(frameXPos,
frameYPos,
frameXSize,
frameYSize),
starFrameImag,
0,
- nullptr));
+ nullptr);
// release resource context
if (healthRes) {
@@ -1646,31 +1639,31 @@ void SetupUserControls(void) {
imageRes = resFile->newContext(imageGroupID, "image context");
- // set up the control button images >>> move checkAlloc to *(new) check
- checkAlloc(aggressImag = loadButtonRes(imageRes, aggressResNum, numBtnImages));
-// checkAlloc( jumpImag = loadButtonRes( imageRes, jumpResNum, numBtnImages ) );
- checkAlloc(centerImag = loadButtonRes(imageRes, centerResNum, numBtnImages));
- checkAlloc(bandingImag = loadButtonRes(imageRes, bandingResNum, numBtnImages));
- checkAlloc(menConBtnImag = loadButtonRes(imageRes, menConBtnResNum, numBtnImages));
+ // set up the control button images
+ aggressImag = loadButtonRes(imageRes, aggressResNum, numBtnImages);
+
+ centerImag = loadButtonRes(imageRes, centerResNum, numBtnImages);
+ bandingImag = loadButtonRes(imageRes, bandingResNum, numBtnImages);
+ menConBtnImag = loadButtonRes(imageRes, menConBtnResNum, numBtnImages);
// setup the options button imagery
- checkAlloc(optBtnImag = loadButtonRes(imageRes, optBtnResNum, numBtnImages));
+ optBtnImag = loadButtonRes(imageRes, optBtnResNum, numBtnImages);
// setup the brother selector button imagery and button frame
- checkAlloc(julBtnImag = loadButtonRes(imageRes, julBtnResNum, numBtnImages));
- checkAlloc(phiBtnImag = loadButtonRes(imageRes, phiBtnResNum, numBtnImages));
- checkAlloc(kevBtnImag = loadButtonRes(imageRes, kevBtnResNum, numBtnImages));
- checkAlloc(broBtnFrameImag = ImageCache.requestImage(imageRes, MKTAG('F', 'R', 'A', 'M')));
+ julBtnImag = loadButtonRes(imageRes, julBtnResNum, numBtnImages);
+ phiBtnImag = loadButtonRes(imageRes, phiBtnResNum, numBtnImages);
+ kevBtnImag = loadButtonRes(imageRes, kevBtnResNum, numBtnImages);
+ broBtnFrameImag = ImageCache.requestImage(imageRes, MKTAG('F', 'R', 'A', 'M'));
// set up the portrait name plates
for (n = 0; n < kNumViews; n++) {
- checkAlloc(namePlateImages[n] = ImageCache.requestImage(imageRes, MKTAG('B', 'T', 'N', namePlateResNum[n])));
+ namePlateImages[n] = ImageCache.requestImage(imageRes, MKTAG('B', 'T', 'N', namePlateResNum[n]));
}
// get the frame image
- checkAlloc(namePlateFrameImag = ImageCache.requestImage(imageRes, MKTAG('B', 'T', 'N', 15)));
- checkAlloc(armorImag = ImageCache.requestImage(imageRes, MKTAG('B', 'T', 'N', 34)));
+ namePlateFrameImag = ImageCache.requestImage(imageRes, MKTAG('B', 'T', 'N', 15));
+ armorImag = ImageCache.requestImage(imageRes, MKTAG('B', 'T', 'N', 34));
// clean out the old context
if (imageRes) resFile->disposeContext(imageRes);
@@ -1681,51 +1674,46 @@ void SetupUserControls(void) {
// set up the portrait button images
for (n = 0; n < kNumViews; n++) {
- checkAlloc(portImag[n] = loadButtonRes(imageRes, portResNum[n], numPortImages, broNames[n].a, broNames[n].b, broNames[n].c));
+ portImag[n] = loadButtonRes(imageRes, portResNum[n], numPortImages, broNames[n].a, broNames[n].b, broNames[n].c);
}
// setup stand alone controls
- checkAlloc(optBtn = new gCompButton(*playControls, optBtnRect, optBtnImag,
- numBtnImages, 0, cmdOptions));
+ optBtn = new gCompButton(*playControls, optBtnRect, optBtnImag, numBtnImages, 0, cmdOptions);
- checkAlloc(enchDisp = new gEnchantmentDisplay(*playControls, 0));
+ enchDisp = new gEnchantmentDisplay(*playControls, 0);
// setup the trio user cntl buttons
for (n = 0; n < kNumViews; n++) {
// portrait button
- checkAlloc(portBtns[n] = new gMultCompButton(*trioControls, views[n][index++],
- portImag[n], numPortImages, 0, false, brotherIDs[n], cmdPortrait));
+ portBtns[n] = new gMultCompButton(*trioControls, views[n][index++],
+ portImag[n], numPortImages, 0, false, brotherIDs[n], cmdPortrait);
portBtns[n]->setMousePoll(true);
// aggressive button
- checkAlloc(aggressBtns[n] = new gOwnerSelCompButton(*trioControls, views[n][index++],
- aggressImag, numBtnImages, brotherIDs[n], cmdAggressive));
-
- // jump button
-// checkAlloc( jumpBtns[n] = new gCompButton( *trioControls, views[n][index++],
-// jumpImag, numBtnImages, brotherIDs[n], cmdJump ) );
+ aggressBtns[n] = new gOwnerSelCompButton(*trioControls, views[n][index++],
+ aggressImag, numBtnImages, brotherIDs[n], cmdAggressive);
// name plates that go under the portraits
- checkAlloc(armorInd[n] = new gArmorIndicator(*trioControls, views[n][index++],
- armorImag, brotherIDs[n], cmdArmor));
+ armorInd[n] = new gArmorIndicator(*trioControls, views[n][index++],
+ armorImag, brotherIDs[n], cmdArmor);
// center on brother
- checkAlloc(centerBtns[n] = new gOwnerSelCompButton(*trioControls, views[n][index++],
- centerImag, numBtnImages, brotherIDs[n], cmdCenter));
+ centerBtns[n] = new gOwnerSelCompButton(*trioControls, views[n][index++],
+ centerImag, numBtnImages, brotherIDs[n], cmdCenter);
// banding
- checkAlloc(bandingBtns[n] = new gOwnerSelCompButton(*trioControls, views[n][index++],
- bandingImag, numBtnImages, brotherIDs[n], cmdBand));
+ bandingBtns[n] = new gOwnerSelCompButton(*trioControls, views[n][index++],
+ bandingImag, numBtnImages, brotherIDs[n], cmdBand);
// name plates that go under the portraits
- checkAlloc(namePlates[n] = new gCompImage(*trioControls, views[n][index++],
- namePlateImages[n], 0, nullptr));
+ namePlates[n] = new gCompImage(*trioControls, views[n][index++],
+ namePlateImages[n], 0, nullptr);
// the frames for the name plates
- checkAlloc(namePlateFrames[n] = new gCompImage(*trioControls, views[n][index++],
- namePlateFrameImag, 0, nullptr));
+ namePlateFrames[n] = new gCompImage(*trioControls, views[n][index++],
+ namePlateFrameImag, 0, nullptr);
index = 0;
}
@@ -1733,63 +1721,52 @@ void SetupUserControls(void) {
// individual control buttons
// portrait button
- checkAlloc(indivPortBtn = new gMultCompButton(*indivControls, views[0][index++],
- portImag[0], numPortImages, 0, false, uiIndiv, cmdPortrait));
+ indivPortBtn = new gMultCompButton(*indivControls, views[0][index++],
+ portImag[0], numPortImages, 0, false, uiIndiv, cmdPortrait);
indivPortBtn->setMousePoll(true);
// aggressive button
- checkAlloc(indivAggressBtn = new gOwnerSelCompButton(*indivControls, views[0][index++],
- aggressImag, numBtnImages, uiIndiv, cmdAggressive));
-
- // jump button
-// checkAlloc( indivJumpBtn = new gCompButton( *indivControls, views[0][index++],
-// jumpImag, numBtnImages, uiIndiv, cmdJump ) );
+ indivAggressBtn = new gOwnerSelCompButton(*indivControls, views[0][index++],
+ aggressImag, numBtnImages, uiIndiv, cmdAggressive);
- checkAlloc(indivArmorInd = new gArmorIndicator(*indivControls, views[0][index++],
- armorImag, uiIndiv, cmdArmor));
+ indivArmorInd = new gArmorIndicator(*indivControls, views[0][index++],
+ armorImag, uiIndiv, cmdArmor);
// center on brother
- checkAlloc(indivCenterBtn = new gOwnerSelCompButton(*indivControls, views[0][index++],
- centerImag, numBtnImages, uiIndiv, cmdCenter));
+ indivCenterBtn = new gOwnerSelCompButton(*indivControls, views[0][index++],
+ centerImag, numBtnImages, uiIndiv, cmdCenter);
// banding
- checkAlloc(indivBandingBtn = new gOwnerSelCompButton(*indivControls, views[0][index++],
- bandingImag, numBtnImages, uiIndiv, cmdBand));
+ indivBandingBtn = new gOwnerSelCompButton(*indivControls, views[0][index++],
+ bandingImag, numBtnImages, uiIndiv, cmdBand);
// name plates that go under the portraits
- checkAlloc(indivNamePlate = new gCompImage(*indivControls, views[0][index++],
- namePlateImages[0], 0, nullptr));
+ indivNamePlate = new gCompImage(*indivControls, views[0][index++],
+ namePlateImages[0], 0, nullptr);
// the frames for the name plates
- checkAlloc(indivNamePlateFrame = new gCompImage(*indivControls, views[0][index++],
- namePlateFrameImag, 0, nullptr));
+ indivNamePlateFrame = new gCompImage(*indivControls, views[0][index++],
+ namePlateFrameImag, 0, nullptr);
// setup the portrait object
- checkAlloc(Portrait = new CPortrait(portBtns, // portrait buttons
+ Portrait = new CPortrait(portBtns, // portrait buttons
indivPortBtn,
numPortImages,// num of images per button
- kNumViews)); // number of brothers
+ kNumViews); // number of brothers
// mental container button
- checkAlloc(menConBtn = new gCompButton(*indivControls, menConBtnRect,
- menConBtnImag, numBtnImages, uiIndiv, cmdBrain));
+ menConBtn = new gCompButton(*indivControls, menConBtnRect, menConBtnImag, numBtnImages, uiIndiv, cmdBrain);
// brother selection buttons >>> need to replace these with sticky buttons
- checkAlloc(julBtn = new gOwnerSelCompButton(*indivControls, julBtnRect,
- julBtnImag, numBtnImages, uiJulian, cmdBroChange));
-
- checkAlloc(phiBtn = new gOwnerSelCompButton(*indivControls, phiBtnRect,
- phiBtnImag, numBtnImages, uiPhillip, cmdBroChange));
-
- checkAlloc(kevBtn = new gOwnerSelCompButton(*indivControls, kevBtnRect,
- kevBtnImag, numBtnImages, uiKevin, cmdBroChange));
+ julBtn = new gOwnerSelCompButton(*indivControls, julBtnRect, julBtnImag, numBtnImages, uiJulian, cmdBroChange);
+ phiBtn = new gOwnerSelCompButton(*indivControls, phiBtnRect, phiBtnImag, numBtnImages, uiPhillip, cmdBroChange);
+ kevBtn = new gOwnerSelCompButton(*indivControls, kevBtnRect, kevBtnImag, numBtnImages, uiKevin, cmdBroChange);
// frame for brother buttons
- checkAlloc(broBtnFrame = new gCompImage(*indivControls, broBtnRect,
- broBtnFrameImag, uiIndiv, nullptr));
+ broBtnFrame = new gCompImage(*indivControls, broBtnRect, broBtnFrameImag, uiIndiv, nullptr);
// make the mana indicator
- checkAlloc(ManaIndicator = new CManaIndicator(*indivControls));
+ ManaIndicator = new CManaIndicator(*indivControls);
ManaIndicator->setMousePoll(true);
// get rid of the resource contexts
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index 4ee2a5c152..0f0d4b093d 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -697,45 +697,42 @@ int16 FileDialog(int16 fileProcess) {
// get the graphics associated with the buttons
- checkAlloc(pushBtnIm = loadButtonRes(decRes, dialogPushResNum, numBtnImages));
- checkAlloc(arrowUpIm = loadButtonRes(decRes, upArrowResNum, numBtnImages));
- checkAlloc(arrowDnIm = loadButtonRes(decRes, dnArrowResNum, numBtnImages));
+ pushBtnIm = loadButtonRes(decRes, dialogPushResNum, numBtnImages);
+ arrowUpIm = loadButtonRes(decRes, upArrowResNum, numBtnImages);
+ arrowDnIm = loadButtonRes(decRes, dnArrowResNum, numBtnImages);
// create the window
- checkAlloc(win = new ModalWindow(saveLoadWindowRect,
- 0,
- nullptr));
+ win = new ModalWindow(saveLoadWindowRect, 0, nullptr);
gCompButton *t;
// make the quit button
- checkAlloc(t = new gCompButton(*win, saveLoadButtonRects[0],
- pushBtnIm, numBtnImages, btnStrings[stringIndex][0], pal, 0, cmdDialogQuit));
+ t = new gCompButton(*win, saveLoadButtonRects[0], pushBtnIm, numBtnImages, btnStrings[stringIndex][0], pal, 0, cmdDialogQuit);
//t->accelKey=0x1B;
// make the Save/Load button
- checkAlloc(t = new gCompButton(*win, saveLoadButtonRects[1],
- pushBtnIm, numBtnImages, btnStrings[stringIndex][1], pal, fileProcess, fileCommands[fileProcess]));
+ t = new gCompButton(*win, saveLoadButtonRects[1],
+ pushBtnIm, numBtnImages, btnStrings[stringIndex][1], pal, fileProcess, fileCommands[fileProcess]);
//t->accelKey=0x0D;
// make the up arrow
- checkAlloc(t = new gCompButton(*win, saveLoadButtonRects[2],
- arrowUpIm, numBtnImages, 0, cmdSaveDialogUp));
+ t = new gCompButton(*win, saveLoadButtonRects[2],
+ arrowUpIm, numBtnImages, 0, cmdSaveDialogUp);
//t->accelKey=33+0x80;
// make the down arrow
- checkAlloc(t = new gCompButton(*win, saveLoadButtonRects[3],
- arrowDnIm, numBtnImages, 0, cmdSaveDialogDown));
+ t = new gCompButton(*win, saveLoadButtonRects[3],
+ arrowDnIm, numBtnImages, 0, cmdSaveDialogDown);
//t->accelKey=34+0x80;
// attach the title
- checkAlloc(new CPlaqText(*win, saveLoadTextRects[0],
- textStrings[stringIndex][0], &Plate18Font, 0, pal, 0, nullptr));
+ new CPlaqText(*win, saveLoadTextRects[0],
+ textStrings[stringIndex][0], &Plate18Font, 0, pal, 0, nullptr);
// attach the text box editing field object
- checkAlloc(textBox = new gTextBox(*win, editBaseRect, &Onyx10Font,
+ textBox = new gTextBox(*win, editBaseRect, &Onyx10Font,
textHeight, textPen, textBackground, textHilite, textBackHilite, cursorColor,
nullptr, "Error out", fieldStrings, editLen, 0, (uint16) - 1, displayOnly, nullptr,
- fileCommands[fileProcess], cmdDialogQuit));
+ fileCommands[fileProcess], cmdDialogQuit);
win->setDecorations(saveWindowDecorations,
@@ -853,77 +850,74 @@ int16 OptionsDialog(bool disableSaveResume) {
decRes = resFile->newContext(dialogGroupID, "dialog resources");
// get the graphics associated with the buttons
- checkAlloc(dialogPushImag = loadButtonRes(decRes, dialogPushResNum, numBtnImages));
- checkAlloc(checkImag = loadButtonRes(decRes, checkResNum, numBtnImages));
- checkAlloc(slideFaceImag = loadButtonRes(decRes, slideFaceResNum, numSlideFace));
+ dialogPushImag = loadButtonRes(decRes, dialogPushResNum, numBtnImages);
+ checkImag = loadButtonRes(decRes, checkResNum, numBtnImages);
+ slideFaceImag = loadButtonRes(decRes, slideFaceResNum, numSlideFace);
// create the window
- checkAlloc(win = new ModalWindow(optionsWindowRect,
- 0,
- nullptr));
+ win = new ModalWindow(optionsWindowRect, 0, nullptr);
gCompButton *t;
// buttons
if (!disableSaveResume) {
- checkAlloc(t = new gCompButton(*win, optionsButtonRects[0],
- dialogPushImag, numBtnImages, btnStrings[0], pal, 0, cmdDialogQuit));
+ t = new gCompButton(*win, optionsButtonRects[0],
+ dialogPushImag, numBtnImages, btnStrings[0], pal, 0, cmdDialogQuit);
t->accelKey = 0x1B;
- checkAlloc(t = new gCompButton(*win, optionsButtonRects[1],
- dialogPushImag, numBtnImages, btnStrings[1], pal, 0, cmdOptionsSaveGame)); // make the quit button
+ t = new gCompButton(*win, optionsButtonRects[1],
+ dialogPushImag, numBtnImages, btnStrings[1], pal, 0, cmdOptionsSaveGame); // make the quit button
t->accelKey = 'S';
} else {
- checkAlloc(t = new gCompButton(*win, optionsButtonRects[1],
- dialogPushImag, numBtnImages, OPTN_DIALOG_BUTTON6, pal, 0, cmdOptionsNewGame));
+ t = new gCompButton(*win, optionsButtonRects[1],
+ dialogPushImag, numBtnImages, OPTN_DIALOG_BUTTON6, pal, 0, cmdOptionsNewGame);
t->accelKey = 'N';
}
- checkAlloc(t = new gCompButton(*win, optionsButtonRects[2],
- dialogPushImag, numBtnImages, btnStrings[2], pal, 0, cmdOptionsLoadGame)); // make the quit button
+ t = new gCompButton(*win, optionsButtonRects[2],
+ dialogPushImag, numBtnImages, btnStrings[2], pal, 0, cmdOptionsLoadGame); // make the quit button
t->accelKey = 'L';
- checkAlloc(t = new gCompButton(*win, optionsButtonRects[3],
- dialogPushImag, numBtnImages, btnStrings[3], pal, 0, cmdQuitGame));
+ t = new gCompButton(*win, optionsButtonRects[3],
+ dialogPushImag, numBtnImages, btnStrings[3], pal, 0, cmdQuitGame);
t->accelKey = 'Q';
- checkAlloc(t = new gCompButton(*win, optionsButtonRects[4],
- dialogPushImag, numBtnImages, btnStrings[4], pal, 0, cmdCredits));
+ t = new gCompButton(*win, optionsButtonRects[4],
+ dialogPushImag, numBtnImages, btnStrings[4], pal, 0, cmdCredits);
t->accelKey = 'C';
- checkAlloc(autoAggressBtn = new gOwnerSelCompButton(*win, optionsButtonRects[5],
- checkImag, numBtnImages, 0, cmdAutoAggression));
+ autoAggressBtn = new gOwnerSelCompButton(*win, optionsButtonRects[5],
+ checkImag, numBtnImages, 0, cmdAutoAggression);
autoAggressBtn->select(isAutoAggressionSet());
- checkAlloc(autoWeaponBtn = new gOwnerSelCompButton(*win, optionsButtonRects[6],
- checkImag, numBtnImages, 0, cmdAutoWeapon));
+ autoWeaponBtn = new gOwnerSelCompButton(*win, optionsButtonRects[6],
+ checkImag, numBtnImages, 0, cmdAutoWeapon);
autoWeaponBtn->select(isAutoWeaponSet());
- checkAlloc(speechTextBtn = new gOwnerSelCompButton(*win, optionsButtonRects[7],
- checkImag, numBtnImages, 0, cmdSpeechText));
+ speechTextBtn = new gOwnerSelCompButton(*win, optionsButtonRects[7],
+ checkImag, numBtnImages, 0, cmdSpeechText);
speechTextBtn->select(globalConfig.speechText);
- checkAlloc(nightBtn = new gOwnerSelCompButton(*win, optionsButtonRects[8],
- checkImag, numBtnImages, 0, cmdNight));
+ nightBtn = new gOwnerSelCompButton(*win, optionsButtonRects[8],
+ checkImag, numBtnImages, 0, cmdNight);
nightBtn->select(globalConfig.showNight);
- checkAlloc(new gSlider(*win, optTopSliderRect, optTopFaceRect, 0,
+ new gSlider(*win, optTopSliderRect, optTopFaceRect, 0,
127, slideFaceImag, numSlideFace, globalConfig.soundVolume,
- 0, cmdSetSoundVolume));
+ 0, cmdSetSoundVolume);
- checkAlloc(new gSlider(*win, optMidSliderRect, optMidFaceRect, 0,
+ new gSlider(*win, optMidSliderRect, optMidFaceRect, 0,
127, slideFaceImag, numSlideFace, globalConfig.voiceVolume,
- 0, cmdSetSpeechVolume));
+ 0, cmdSetSpeechVolume);
- checkAlloc(new gSlider(*win, optBotSliderRect, optBotFaceRect, 0,
+ new gSlider(*win, optBotSliderRect, optBotFaceRect, 0,
127, slideFaceImag, numSlideFace, globalConfig.musicVolume,
- 0, cmdSetMIDIVolume));
+ 0, cmdSetMIDIVolume);
- checkAlloc(new CPlaqText(*win, optionsTextRects[0],
- textStrings[0], &Plate18Font, 0, pal, 0, nullptr));
+ new CPlaqText(*win, optionsTextRects[0],
+ textStrings[0], &Plate18Font, 0, pal, 0, nullptr);
for (int i = 1; i < numOptionsTexts; i++) {
- checkAlloc(new CPlaqText(*win, optionsTextRects[i],
- textStrings[i], &SmallFont, textPosLeft, pal, 0, nullptr));
+ new CPlaqText(*win, optionsTextRects[i], textStrings[i], &SmallFont, textPosLeft, pal, 0, nullptr);
}
win->setDecorations(optionsDecorations,
@@ -1034,12 +1028,10 @@ bool initUserDialog(void) {
// get the graphics associated with the buttons
- checkAlloc(udDialogPushImag = loadButtonRes(udDecRes, dialogPushResNum, numBtnImages));
+ udDialogPushImag = loadButtonRes(udDecRes, dialogPushResNum, numBtnImages);
// create the window
- checkAlloc(udWin = new ModalWindow(messageWindowRect,
- 0,
- nullptr));
+ udWin = new ModalWindow(messageWindowRect, 0 nullptr);
udWin->setDecorations(messageDecorations,
elementsof(messageDecorations),
@@ -1103,32 +1095,30 @@ int16 userDialog(const char *title, const char *msg, const char *bMsg1,
// button one
if (numBtns >= 1) {
- checkAlloc(t = new gCompButton(*udWin, messageButtonRects[0],
- udDialogPushImag, numBtnImages, btnMsg1, pal, 10, cmdDialogQuit));
+ t = new gCompButton(*udWin, messageButtonRects[0],
+ udDialogPushImag, numBtnImages, btnMsg1, pal, 10, cmdDialogQuit);
t->accel = k1;
}
// button two
if (numBtns >= 2) {
- checkAlloc(t = new gCompButton(*udWin, messageButtonRects[1],
- udDialogPushImag, numBtnImages, btnMsg2, pal, 11, cmdDialogQuit));
+ t = new gCompButton(*udWin, messageButtonRects[1],
+ udDialogPushImag, numBtnImages, btnMsg2, pal, 11, cmdDialogQuit);
t->accel = k2;
}
// button three
if (numBtns >= 3) {
- checkAlloc(t = new gCompButton(*udWin, messageButtonRects[2],
- udDialogPushImag, numBtnImages, btnMsg3, pal, 12, cmdDialogQuit));
+ t = new gCompButton(*udWin, messageButtonRects[2],
+ udDialogPushImag, numBtnImages, btnMsg3, pal, 12, cmdDialogQuit);
t->accel = k3;
}
// title for the box
- checkAlloc(new CPlaqText(*udWin, messageTextRects[0],
- title, &Plate18Font, nullptr, pal, 0, nullptr));
+ new CPlaqText(*udWin, messageTextRects[0], title, &Plate18Font, nullptr, pal, 0, nullptr);
// message for box
- checkAlloc(new CPlacardPanel(*udWin, messageTextRects[1],
- msg, &Onyx10Font, nullptr, pal, 0, nullptr));
+ new CPlacardPanel(*udWin, messageTextRects[1], msg, &Onyx10Font, nullptr, pal, 0, nullptr);
udWin->open();
@@ -1211,43 +1201,39 @@ int16 userDialog(const char *title, const char *msg, const char *bMsg1,
// get the graphics associated with the buttons
- checkAlloc(dialogPushImag = loadButtonRes(decRes, dialogPushResNum, numBtnImages));
+ dialogPushImag = loadButtonRes(decRes, dialogPushResNum, numBtnImages);
// create the window
- checkAlloc(win = new ModalWindow(messageWindowRect,
- 0,
- nullptr));
+ win = new ModalWindow(messageWindowRect, 0, nullptr);
gCompButton *t;
// button one
if (numBtns >= 1) {
- checkAlloc(t = new gCompButton(*win, messageButtonRects[0],
- dialogPushImag, numBtnImages, btnMsg1, pal, 10, cmdDialogQuit));
+ t = new gCompButton(*win, messageButtonRects[0],
+ dialogPushImag, numBtnImages, btnMsg1, pal, 10, cmdDialogQuit);
t->accelKey = k1;
}
// button two
if (numBtns >= 2) {
- checkAlloc(t = new gCompButton(*win, messageButtonRects[1],
- dialogPushImag, numBtnImages, btnMsg2, pal, 11, cmdDialogQuit));
+ t = new gCompButton(*win, messageButtonRects[1],
+ dialogPushImag, numBtnImages, btnMsg2, pal, 11, cmdDialogQuit);
t->accelKey = k2;
}
// button three
if (numBtns >= 3) {
- checkAlloc(t = new gCompButton(*win, messageButtonRects[2],
- dialogPushImag, numBtnImages, btnMsg3, pal, 12, cmdDialogQuit));
+ t = new gCompButton(*win, messageButtonRects[2],
+ dialogPushImag, numBtnImages, btnMsg3, pal, 12, cmdDialogQuit);
t->accelKey = k3;
}
// title for the box
- checkAlloc(new CPlaqText(*win, messageTextRects[0],
- title, &Plate18Font, 0, pal, 0, nullptr));
+ new CPlaqText(*win, messageTextRects[0], title, &Plate18Font, 0, pal, 0, nullptr);
// message for box
- checkAlloc(new CPlacardPanel(*win, messageTextRects[1],
- msg, &Onyx10Font, 0, pal, 0, nullptr));
+ new CPlacardPanel(*win, messageTextRects[1], msg, &Onyx10Font, 0, pal, 0, nullptr);
win->setDecorations(messageDecorations,
elementsof(messageDecorations),
@@ -1548,7 +1534,7 @@ void placardWindow(int8 type, char *text) {
pal.set(62, 64, 67, 11, 23, 17);
// create the window
- checkAlloc(win = new CPlacardWindow(plaqRectWood, 0, nullptr, text, pal, &Plate18Font));
+ win = new CPlacardWindow(plaqRectWood, 0, nullptr, text, pal, &Plate18Font);
// setup the background imagery
win->setDecorations(plaqDecWood,
@@ -1563,7 +1549,7 @@ void placardWindow(int8 type, char *text) {
pal.set(16, 12, 18, 11, 23, 0x78);
// create the window
- checkAlloc(win = new CPlacardWindow(plaqRectStone, 0, nullptr, text, pal, &Plate18Font));
+ win = new CPlacardWindow(plaqRectStone, 0, nullptr, text, pal, &Plate18Font);
// setup the background imagery
win->setDecorations(plaqDecStone,
@@ -1578,7 +1564,7 @@ void placardWindow(int8 type, char *text) {
pal.set(89, 93, 95, 11, 23, 0x76);
// create the window
- checkAlloc(win = new CPlacardWindow(plaqRectBrass, 0, nullptr, text, pal, &Plate18Font));
+ win = new CPlacardWindow(plaqRectBrass, 0, nullptr, text, pal, &Plate18Font);
// setup the background imagery
win->setDecorations(plaqDecBrass,
Commit: 4a71417f5c8fe1c18fb661c655415f76be1bbd65
https://github.com/scummvm/scummvm/commit/4a71417f5c8fe1c18fb661c655415f76be1bbd65
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:28+02:00
Commit Message:
SAGA2: Replace custom config code with ScummVM
Changed paths:
R engines/saga2/config.cpp
R engines/saga2/config.h
engines/saga2/calender.cpp
engines/saga2/main.cpp
engines/saga2/module.mk
engines/saga2/noise.cpp
engines/saga2/saga2.cpp
engines/saga2/saga2.h
engines/saga2/savefile.cpp
engines/saga2/speech.cpp
engines/saga2/tilemode.cpp
engines/saga2/tromode.cpp
engines/saga2/uidialog.cpp
diff --git a/engines/saga2/calender.cpp b/engines/saga2/calender.cpp
index 6bcd26c6e0..99b1304d4a 100644
--- a/engines/saga2/calender.cpp
+++ b/engines/saga2/calender.cpp
@@ -29,7 +29,6 @@
#include "saga2/std.h"
#include "saga2/calender.h"
#include "saga2/intrface.h"
-#include "saga2/config.h"
#include "saga2/localize.h"
#include "saga2/savefile.h"
@@ -43,8 +42,6 @@ static bool calenderPaused;
const int dayBias = CalenderTime::framesAtNoon / 6;
-extern configuration globalConfig;
-
/* ===================================================================== *
Constants
* ===================================================================== */
@@ -129,7 +126,7 @@ int CalenderTime::lightLevel(int maxLevel) {
// to framesAtNoon*2/3. Then we clip off the part of the
// curve below zero, and above 1/3, giving 1/3 night,
// 1/6 morning, 1/3 day, and 1/6 evening.
- solarLevel = clamp(globalConfig.showNight ? /* 0 */ (dayBias * 5 / 4) : (framesAtNoon / 3),
+ solarLevel = clamp(g_vm->_showNight ? /* 0 */ (dayBias * 5 / 4) : (framesAtNoon / 3),
solarAngle * 2 + season - framesAtNoon / 3 + dayBias * 2,
framesAtNoon / 3);
diff --git a/engines/saga2/config.cpp b/engines/saga2/config.cpp
deleted file mode 100644
index 121c9ce26f..0000000000
--- a/engines/saga2/config.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#include "saga2/std.h"
-#include "saga2/config.h"
-
-namespace Saga2 {
-
-char iniFile[] = "FTA2.INI";
-configuration globalConfig;
-
-static char originalDir[PATH_STR_SIZE];
-
-//-----------------------------------------------------------------------
-// This doesn't belong here, oh well...
-
-inline bool file_exists(const char f[]) {
- warning("STUB: file_exists()");
- return false;
- //return (!access(f, F_OK));
-}
-inline void deletefile(char n[]) {
- if (file_exists(n)) remove(n);
-}
-
-void KillLogs(void) {
- deletefile("AUDIOERR.LOG");
- deletefile("SYSERRS.LOG");
- deletefile("ERRORS.LOG");
- deletefile("MEMDUMP.LOG");
- deletefile("WINERROR.LOG");
- deletefile("MEMORY.LOG");
-}
-
-//-----------------------------------------------------------------------
-// Sets default values in config file
-
-static void defaultConfig(configuration &config) {
- config.musicVolume = 127;
- config.soundVolume = 127;
- config.voiceVolume = 127;
- config.autoAggression = true;
- config.autoWeapon = true;
- config.speechText = true;
- config.showNight = true;
-#ifdef _WIN32
- config.windowed = false;
-#endif
- strcpy(config.soundResfilePath, ".\\");
- strcpy(config.voiceResfilePath, ".\\");
- strcpy(config.imageResfilePath, ".\\");
- strcpy(config.videoFilePath, ".\\");
- strcpy(config.mainResfilePath, ".\\");
- strcpy(config.dataResfilePath, ".\\");
- strcpy(config.scriptResfilePath, ".\\");
- strcpy(config.savedGamePath, ".\\");
-}
-
-//-----------------------------------------------------------------------
-// saves settings to INI file
-
-void writeConfig(void) {
-#if 0
- WritePrivateProfileInt("Sound", "MusicVolume", globalConfig.musicVolume, iniFile);
- WritePrivateProfileInt("Sound", "SoundVolume", globalConfig.soundVolume, iniFile);
- WritePrivateProfileInt("Sound", "VoiceVolume", globalConfig.voiceVolume, iniFile);
- WritePrivateProfileInt("Options", "AutoAggression", globalConfig.autoAggression, iniFile);
- WritePrivateProfileInt("Options", "AutoWeapon", globalConfig.autoWeapon, iniFile);
- WritePrivateProfileInt("Options", "SpeechText", globalConfig.speechText, iniFile);
- WritePrivateProfileInt("Options", "Night", globalConfig.showNight, iniFile);
-#endif
- warning("STUB: writeConfig()");
-}
-
-/* ===================================================================== *
- Functions to save the original program directory, and to return to
- that directory whenever needed.
- * ===================================================================== */
-
-//-----------------------------------------------------------------------
-// Determine's the programs home directory
-
-
-void findProgramDir(char *argv) {
- char *sep;
- sprintf(originalDir, "%s", argv);
- if ((sep = strrchr(originalDir, '\\')) != NULL) * sep = '\0';
-}
-
-//-----------------------------------------------------------------------
-// Does a CD back to the program's directory
-
-void restoreProgramDir(void) {
- warning("STUB: restoreProgramDir()");
- //chdir(originalDir);
-}
-
-} // end of namespace Saga2
diff --git a/engines/saga2/config.h b/engines/saga2/config.h
deleted file mode 100644
index ce729e2d34..0000000000
--- a/engines/saga2/config.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#ifndef SAGA2_CONFIG_H
-#define SAGA2_CONFIG_H
-
-namespace Saga2 {
-
-// under WIN95 paths can get BIG
-#define PATH_STR_SIZE 260
-
-/* ===================================================================== *
- FTA2 INI file settings
- * ===================================================================== */
-
-struct configuration {
- uint8 musicVolume;
- uint8 soundVolume;
- uint8 voiceVolume;
- bool autoAggression;
- bool autoWeapon;
- bool speechText;
- bool showNight;
-#ifdef _WIN32
- bool windowed;
-#endif
- char soundResfilePath[PATH_STR_SIZE];
- char voiceResfilePath[PATH_STR_SIZE];
- char imageResfilePath[PATH_STR_SIZE];
- char videoFilePath[PATH_STR_SIZE];
- char mainResfilePath[PATH_STR_SIZE];
- char dataResfilePath[PATH_STR_SIZE];
- char scriptResfilePath[PATH_STR_SIZE];
- char savedGamePath[PATH_STR_SIZE];
-};
-
-/* ===================================================================== *
- FTA2 INI file code
- * ===================================================================== */
-
-void writeConfig(void);
-void findProgramDir(char *argv);
-void restoreProgramDir(void);
-
-extern configuration globalConfig;
-
-} // end of namespace Saga2
-
-#endif // CONFIG_H
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 8d0c72879a..2119a273db 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -46,7 +46,6 @@
#include "saga2/loadsave.h"
#include "saga2/gamerate.h"
#include "saga2/msgbox.h"
-#include "saga2/config.h"
#include "saga2/savefile.h"
namespace Saga2 {
@@ -60,7 +59,6 @@ namespace Saga2 {
extern WindowDecoration autoMapDecorations[];
extern gToolBase G_BASE;
-extern configuration globalConfig;
extern char *gameTimeStr;
extern bool underground;
extern char commandLineHelp[];
@@ -573,7 +571,6 @@ inline char drive(char *path) {
static bool openResource(
pHResource &hr, // resource to initialize
- const char *basePath, // path to data file
const char *defaultPath, // backup path
const char *fileName, // file name & extension
const char *description) {
@@ -601,26 +598,20 @@ static bool openResource(
bool openResources(void) {
if (
- openResource(resFile, globalConfig.imageResfilePath,
- "..\\resfile\\", IMAGE_RESFILE,
+ openResource(resFile, "..\\resfile\\", IMAGE_RESFILE,
"Imagery resource file") &&
- openResource(objResFile, globalConfig.mainResfilePath,
- "..\\resfile\\", OBJECT_RESFILE,
+ openResource(objResFile, "..\\resfile\\", OBJECT_RESFILE,
"Object resource file") &&
- openResource(auxResFile, globalConfig.dataResfilePath,
- "..\\resfile\\", AUX_RESFILE,
+ openResource(auxResFile, "..\\resfile\\", AUX_RESFILE,
"Data resource file") &&
- openResource(scriptResFile, globalConfig.scriptResfilePath,
- "..\\scripts\\", SCRIPT_RESFILE,
+ openResource(scriptResFile, "..\\scripts\\", SCRIPT_RESFILE,
"Script resource file") &&
- openResource(voiceResFile, globalConfig.voiceResfilePath,
- "..\\sound\\", VOICE_RESFILE,
+ openResource(voiceResFile, "..\\sound\\", VOICE_RESFILE,
"Voice resource file") &&
- openResource(soundResFile, globalConfig.soundResfilePath,
- "..\\sound\\", SOUND_RESFILE,
+ openResource(soundResFile, "..\\sound\\", SOUND_RESFILE,
"Sound resource file")) {
return true;
}
diff --git a/engines/saga2/module.mk b/engines/saga2/module.mk
index 6d7cfb397e..0965bab826 100644
--- a/engines/saga2/module.mk
+++ b/engines/saga2/module.mk
@@ -13,7 +13,6 @@ MODULE_OBJS := \
blitters.o \
button.o \
calender.o \
- config.o \
contain.o \
detection.o \
display.o \
diff --git a/engines/saga2/noise.cpp b/engines/saga2/noise.cpp
index d7f89ff99e..e67ecb27fc 100644
--- a/engines/saga2/noise.cpp
+++ b/engines/saga2/noise.cpp
@@ -24,6 +24,8 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
+#include "common/config-manager.h"
+
#include "saga2/std.h"
#include "saga2/fta.h"
#include "saga2/audio.h"
@@ -36,7 +38,6 @@
#include "saga2/audiosmp.h"
#include "saga2/audqueue.h"
#include "saga2/audiosys.h"
-#include "saga2/config.h"
#include "saga2/hresmgr.h"
namespace Saga2 {
@@ -63,8 +64,6 @@ const uint32 baseMusicID = MKTAG('M', 'I', 'L', 'O'),
extern audioInterface *audio;
extern hResource *soundResFile; // script resources
extern hResource *voiceResFile; // script resources
-extern configuration globalConfig;
-extern char iniFile[];
extern int32 maxClicks;
extern int32 clickSizes[];
@@ -234,18 +233,10 @@ void startAudio(void) {
(uint32) 400000 // sound buffer size
);
- bool disVoice = false, disMusic= false, disSound= false, disLoops= false;
- warning("STUB: startAudio, sync sound settings");
-#if 0
-
- disMusic = !GetPrivateProfileInt("Sound", "Music", 1, iniFile);
- disVoice = !GetPrivateProfileInt("Sound", "Voice", 1, iniFile);
- disLoops = !GetPrivateProfileInt("Sound", "Loops", 1, iniFile);
- disSound = !GetPrivateProfileInt("Sound", "Sound", 1, iniFile);
-#endif
-
return;
+ bool disVoice = true, disMusic = true, disSound = true, disLoops = true;
+
if (audio->active()) {
voiceDec = new decoderSet();
voiceDec->addDecoder(new soundDecoder(&readVoice, &seekVoice, &flushVoice));
@@ -268,6 +259,11 @@ void startAudio(void) {
uint32 musicID = haveKillerSoundCard() ? goodMusicID : baseMusicID;
+ disVoice = !ConfMan.getInt("speech_volume");
+ disMusic = !ConfMan.getInt("music_volume");
+ disSound = !ConfMan.getInt("sfx_volume");
+ disLoops = disSound;
+
if (!disMusic) {
musicRes = soundResFile->newContext(musicID, "music resource");
if (musicRes == NULL)
@@ -302,11 +298,6 @@ void startAudio(void) {
//audio->setMusicFadeStyle(15,15,5);
audio->setMusicFadeStyle(0, 0, 0);
oldAttenuator = audio->setAttenuator(&volumeFromDist);
-
- audio->setVolume(volMusic, volumeSetTo, globalConfig.musicVolume);
- audio->setVolume(volVoice, volumeSetTo, globalConfig.voiceVolume);
- audio->setVolume(volSandL, volumeSetTo, globalConfig.soundVolume);
-
}
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index aa9f85eefa..5629bf2de3 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -79,11 +79,7 @@ Common::Error Saga2Engine::run() {
// Initialize graphics using following:
initGraphics(640, 480);
- // Additional setup.
- debug("Saga2Engine::init");
-
- // Your main even loop should be (invoked from) here.
- debug("Saga2Engine::go: Hello, World!");
+ readConfig();
loadExeResources();
@@ -257,4 +253,32 @@ void Saga2Engine::freeExeResources() {
freeCursors();
}
+void Saga2Engine::readConfig() {
+ _autoWeapon = true;
+
+ if (ConfMan.hasKey("auto_weapon"))
+ _autoWeapon = ConfMan.getBool("auto_weapon");
+
+ _autoAggression = true;
+
+ if (ConfMan.hasKey("auto_aggression"))
+ _autoAggression = ConfMan.getBool("auto_aggression");
+
+ _showNight = true;
+
+ if (ConfMan.hasKey("show_night"))
+ _showNight = ConfMan.getBool("show_night");
+
+ _speechText = true;
+
+ if (ConfMan.hasKey("subtitles"))
+ _speechText = ConfMan.getBool("subtitles");
+
+ syncSoundSettings();
+}
+
+void Saga2Engine::saveConfig() {
+ ConfMan.flushToDisk();
+}
+
} // End of namespace Saga2
diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h
index f4f17a23aa..7fe897b7aa 100644
--- a/engines/saga2/saga2.h
+++ b/engines/saga2/saga2.h
@@ -76,6 +76,9 @@ public:
void endVideo(void);
void abortVideo(void);
+ void readConfig();
+ void saveConfig();
+
public:
// We need random numbers
Common::RandomSource *_rnd;
@@ -85,6 +88,11 @@ public:
Common::List<TimerList *> _timerLists;
Common::List<Timer *> _timers;
+ bool _autoAggression;
+ bool _autoWeapon;
+ bool _showNight;
+ bool _speechText;
+
private:
Video::SmackerDecoder *_smkDecoder;
int _videoX, _videoY;
diff --git a/engines/saga2/savefile.cpp b/engines/saga2/savefile.cpp
index bcdc62817c..8341fbbd42 100644
--- a/engines/saga2/savefile.cpp
+++ b/engines/saga2/savefile.cpp
@@ -28,7 +28,6 @@
#include "saga2/std.h"
#include "saga2/savefile.h"
-#include "saga2/config.h"
namespace Saga2 {
@@ -41,7 +40,7 @@ namespace Saga2 {
// number
void getSaveFileName(int16 saveNo, char *fileName) {
- sprintf(fileName, "%s%3.3d.SAV", globalConfig.savedGamePath, saveNo);
+ sprintf(fileName, "%3.3d.SAV", saveNo);
}
/* ===================================================================== *
diff --git a/engines/saga2/speech.cpp b/engines/saga2/speech.cpp
index 0747267887..353d1b2813 100644
--- a/engines/saga2/speech.cpp
+++ b/engines/saga2/speech.cpp
@@ -37,7 +37,6 @@
#include "saga2/annoy.h"
#include "saga2/savefile.h"
#include "saga2/cmisc.h"
-#include "saga2/config.h"
namespace Saga2 {
@@ -54,7 +53,6 @@ extern Point16 fineScroll;
extern Rect16 tileRect;
int kludgeHeight = 15;
extern TilePoint viewCenter; // coordinates of view on map
-extern configuration globalConfig;
//-----------------------------------------------------------------------
// constants
@@ -354,7 +352,7 @@ bool Speech::setupActive(void) {
speechButtonCount,
speechBuffer,
bounds.width,
- !globalConfig.speechText && (speechFlags & spHasVoice));
+ !g_vm->_speechText && (speechFlags & spHasVoice));
// Compute height of bitmap based on number of lines of text.
// Include 4 for outline width
@@ -462,7 +460,7 @@ void Speech::setWidth() {
speechButtonCount_,
speechBuffer,
defaultWidth,
- !globalConfig.speechText && (speechFlags & spHasVoice));
+ !g_vm->_speechText && (speechFlags & spHasVoice));
// If it's more than 3 lines, then use the max line width.
@@ -472,7 +470,7 @@ void Speech::setWidth() {
speechButtonCount_,
speechBuffer,
maxWidth,
- !globalConfig.speechText && (speechFlags & spHasVoice));
+ !g_vm->_speechText && (speechFlags & spHasVoice));
}
diff --git a/engines/saga2/tilemode.cpp b/engines/saga2/tilemode.cpp
index 3ee5f6c003..b88b93e567 100644
--- a/engines/saga2/tilemode.cpp
+++ b/engines/saga2/tilemode.cpp
@@ -42,7 +42,6 @@
#include "saga2/intrface.h"
#include "saga2/dispnode.h"
#include "saga2/uidialog.h"
-#include "saga2/config.h"
#include "saga2/contain.h"
#include "saga2/savefile.h"
@@ -98,7 +97,6 @@ extern hResContext *tileRes; // tile resource handle
extern CycleHandle cycleList; // list of tile cycling info
extern int16 cycleCount;
extern int32 lastUpdateTime; // time of last display update
-extern configuration globalConfig;
//Prototypes For Tile Mode GameMode Object Init
void TileModeHandleTask(void);
@@ -301,7 +299,9 @@ static void resumeCombat(void) {
// This function performs all combat initialization tasks
static void startCombat(void) {
- if (globalConfig.autoAggression) autoAdjustAggression();
+ if (g_vm->_autoAggression)
+ autoAdjustAggression();
+
setCombatBehavior(true);
combatPaused = false;
}
@@ -322,27 +322,27 @@ static void endCombat(void) {
//-----------------------------------------------------------------------
void toggleAutoAggression(void) {
- globalConfig.autoAggression = !globalConfig.autoAggression;
- updateAutoAggressionButton(globalConfig.autoAggression);
+ g_vm->_autoAggression = !g_vm->_autoAggression;
+ updateAutoAggressionButton(g_vm->_autoAggression);
}
//-----------------------------------------------------------------------
bool isAutoAggressionSet(void) {
- return globalConfig.autoAggression;
+ return g_vm->_autoAggression;
}
//-----------------------------------------------------------------------
void toggleAutoWeapon(void) {
- globalConfig.autoWeapon = !globalConfig.autoWeapon;
- updateAutoWeaponButton(globalConfig.autoWeapon);
+ g_vm->_autoWeapon = !g_vm->_autoWeapon;
+ updateAutoWeaponButton(g_vm->_autoWeapon);
}
//-----------------------------------------------------------------------
bool isAutoWeaponSet(void) {
- return globalConfig.autoWeapon;
+ return g_vm->_autoWeapon;
}
//-----------------------------------------------------------------------
diff --git a/engines/saga2/tromode.cpp b/engines/saga2/tromode.cpp
index 0427cf0b0a..abddaed5b1 100644
--- a/engines/saga2/tromode.cpp
+++ b/engines/saga2/tromode.cpp
@@ -30,7 +30,6 @@
#include "saga2/fta.h"
#include "saga2/player.h"
#include "saga2/display.h"
-#include "saga2/config.h"
#include "saga2/panel.h"
namespace Saga2 {
@@ -56,7 +55,6 @@ extern bool gameRunning;
extern gMouseState prevState;
extern gMousePointer pointer;
extern MouseExtState mouseQueue[];
-extern configuration globalConfig;
extern bool allPlayerActorsDead;
extern int16 queueIn,
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index 0f0d4b093d..d6ab0f3fcb 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -26,6 +26,9 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
+#include "common/config-manager.h"
+#include "audio/mixer.h"
+
#include "saga2/std.h"
#include "saga2/intrface.h"
#include "saga2/grequest.h"
@@ -47,7 +50,6 @@
#include "saga2/vpal.h"
#include "saga2/palette.h"
-#include "saga2/config.h"
#include "saga2/fontlib.h"
#include "saga2/savefile.h"
@@ -88,7 +90,6 @@ APPFUNCV(cmdSaveVolumeSettings);
* ===================================================================== */
extern BackWindow *mainWindow;
extern audioInterface *audio;
-extern configuration globalConfig;
extern bool fullInitialized;
/* ===================================================================== *
@@ -895,22 +896,22 @@ int16 OptionsDialog(bool disableSaveResume) {
speechTextBtn = new gOwnerSelCompButton(*win, optionsButtonRects[7],
checkImag, numBtnImages, 0, cmdSpeechText);
- speechTextBtn->select(globalConfig.speechText);
+ speechTextBtn->select(g_vm->_speechText);
nightBtn = new gOwnerSelCompButton(*win, optionsButtonRects[8],
checkImag, numBtnImages, 0, cmdNight);
- nightBtn->select(globalConfig.showNight);
+ nightBtn->select(g_vm->_showNight);
new gSlider(*win, optTopSliderRect, optTopFaceRect, 0,
- 127, slideFaceImag, numSlideFace, globalConfig.soundVolume,
+ Audio::Mixer::kMaxMixerVolume, slideFaceImag, numSlideFace, ConfMan.getInt("sfx_volume"),
0, cmdSetSoundVolume);
new gSlider(*win, optMidSliderRect, optMidFaceRect, 0,
- 127, slideFaceImag, numSlideFace, globalConfig.voiceVolume,
+ Audio::Mixer::kMaxMixerVolume, slideFaceImag, numSlideFace, ConfMan.getInt("speech_volume"),
0, cmdSetSpeechVolume);
new gSlider(*win, optBotSliderRect, optBotFaceRect, 0,
- 127, slideFaceImag, numSlideFace, globalConfig.musicVolume,
+ Audio::Mixer::kMaxMixerVolume, slideFaceImag, numSlideFace, ConfMan.getInt("music_volume"),
0, cmdSetMIDIVolume);
new CPlaqText(*win, optionsTextRects[0],
@@ -930,7 +931,7 @@ int16 OptionsDialog(bool disableSaveResume) {
EventLoop(rInfo.running, true);
- writeConfig();
+ g_vm->saveConfig();
// remove the window all attatched controls
if (win) delete win;
@@ -1610,12 +1611,6 @@ void updateAutoWeaponButton(bool setting) {
autoWeaponBtn->select(setting);
}
-//void updateShowNightButton( bool setting )
-//{
-// if ( nightBtn != nullptr )
-// nightBtn->select( setting );
-//}
-
// dialog appfuncs
APPFUNC(cmdDialogQuit) {
gWindow *win;
@@ -1775,6 +1770,9 @@ APPFUNC(cmdQuitGame) {
inline int16 quantizedVolume(uint16 trueVolume) {
int16 quantized = trueVolume & 0xFFF8;
quantized += (quantized / 16);
+
+ quantized += 2; // In ScummVM the range is 0..255
+
return quantized;
}
@@ -1801,15 +1799,15 @@ APPFUNC(cmdAutoWeapon) {
APPFUNC(cmdNight) {
if (isUserAction(ev)) {
- globalConfig.showNight = !globalConfig.showNight;
- nightBtn->select(globalConfig.showNight);
+ g_vm->_showNight = !g_vm->_showNight;
+ nightBtn->select(g_vm->_showNight);
}
}
APPFUNC(cmdSpeechText) {
if (isUserAction(ev)) {
- globalConfig.speechText = !globalConfig.speechText;
- speechTextBtn->select(globalConfig.speechText);
+ g_vm->_speechText = !g_vm->_speechText;
+ speechTextBtn->select(g_vm->_speechText);
}
}
@@ -1819,8 +1817,8 @@ void volumeChanged(void);
APPFUNC(cmdSetMIDIVolume) {
int16 v = quantizedVolume(ev.value);
- globalConfig.musicVolume = v;
- audio->setVolume(volMusic, volumeSetTo, globalConfig.musicVolume);
+ ConfMan.setInt("music_volume", v);
+ g_vm->syncSoundSettings();
volumeChanged();
}
@@ -1828,11 +1826,9 @@ APPFUNC(cmdSetMIDIVolume) {
APPFUNC(cmdSetDIGVolume) {
int16 v = quantizedVolume(ev.value);
- globalConfig.soundVolume = v;
- globalConfig.voiceVolume = v;
- //audio->setVolume(volVoice,volumeSetTo,globalConfig.voiceVolume);
- audio->setVolume(volSoundMaster, volumeSetTo, globalConfig.soundVolume);
- //setVideoVolume(globalConfig.soundVolume);
+ ConfMan.setInt("speech_volume", v);
+ ConfMan.setInt("sfx_volume", v);
+ g_vm->syncSoundSettings();
volumeChanged();
}
@@ -1840,8 +1836,8 @@ APPFUNC(cmdSetDIGVolume) {
APPFUNC(cmdSetSpeechVolume) {
int16 v = quantizedVolume(ev.value);
- globalConfig.voiceVolume = v;
- audio->setVolume(volVoice, volumeSetTo, globalConfig.voiceVolume);
+ ConfMan.setInt("speech_volume", v);
+ g_vm->syncSoundSettings();
volumeChanged();
}
@@ -1849,9 +1845,8 @@ APPFUNC(cmdSetSpeechVolume) {
APPFUNC(cmdSetSoundVolume) {
int16 v = quantizedVolume(ev.value);
- globalConfig.soundVolume = v;
- audio->setVolume(volSandL, volumeSetTo, globalConfig.soundVolume);
- //setVideoVolume(globalConfig.soundVolume);
+ ConfMan.setInt("sfx_volume", v);
+ g_vm->syncSoundSettings();
volumeChanged();
}
@@ -1859,7 +1854,7 @@ APPFUNC(cmdSetSoundVolume) {
// This should be called when exiting the dialog to save the changes
APPFUNCV(cmdSaveVolumeSettings) {
- writeConfig();
+ g_vm->saveConfig();
}
} // end of namespace Saga2
Commit: d7b74d5408fbf5f8550ca706d1120b2f0ddb8479
https://github.com/scummvm/scummvm/commit/d7b74d5408fbf5f8550ca706d1120b2f0ddb8479
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:28+02:00
Commit Message:
SAGA2: Fix endianness on scriptMakeActor
Changed paths:
engines/saga2/sagafunc.cpp
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index 3ec4cad37e..47d49f8be6 100644
--- a/engines/saga2/sagafunc.cpp
+++ b/engines/saga2/sagafunc.cpp
@@ -3009,7 +3009,7 @@ int16 scriptMakeActor(int16 *args) {
Actor *a;
assert(actorAppearanceName);
- memcpy(&actorAppearanceNum, actorAppearanceName, 4);
+ actorAppearanceNum = READ_BE_INT32(actorAppearanceName);
a = Actor::newActor(
args[0],
Commit: 732c87dd2c3f986da2ae5904c40f412d931ae1ba
https://github.com/scummvm/scummvm/commit/732c87dd2c3f986da2ae5904c40f412d931ae1ba
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:29+02:00
Commit Message:
SAGA2: Fix ResourceObjectPrototype copy constructor
Changed paths:
engines/saga2/objproto.h
diff --git a/engines/saga2/objproto.h b/engines/saga2/objproto.h
index 0bfeba237c..d1916ef300 100644
--- a/engines/saga2/objproto.h
+++ b/engines/saga2/objproto.h
@@ -247,7 +247,43 @@ struct ResourceObjectPrototype {
// Copy constructor
ResourceObjectPrototype(ResourceObjectPrototype &proto) {
- memcpy(this, &proto, sizeof(ResourceObjectPrototype));
+ classType = proto.classType;
+ script = proto.script;
+ nameIndex = proto.nameIndex;
+ iconSprite = proto.iconSprite;
+ groundSprite = proto.groundSprite;
+
+ for (int i = 0; i < 4; ++i)
+ colorMap[i] = proto.colorMap[i];
+
+ mass = proto.mass;
+ bulk = proto.bulk;
+ crossSection = proto.crossSection;
+ height = proto.height;
+ toughness = proto.toughness;
+ breakType = proto.breakType;
+ maxCapacity = proto.maxCapacity;
+ lockType = proto.lockType;
+ acceptableItems = proto.acceptableItems;
+ weaponDamage = proto.weaponDamage;
+ weaponFireRate = proto.weaponFireRate;
+ maximumRange = proto.maximumRange;
+ missileType = proto.missileType;
+ whereWearable = proto.whereWearable;
+ damageAbsorbtion = proto.damageAbsorbtion;
+ damageDivider = proto.damageDivider;
+ defenseBonus = proto.defenseBonus;
+ maxCharges = proto.maxCharges;
+ chargeType = proto.chargeType;
+ flags = proto.flags;
+ price = proto.price;
+ heldSpriteBase = proto.heldSpriteBase;
+ resistance = proto.resistance;
+ immunity = proto.immunity;
+ soundFXClass = proto.soundFXClass;
+
+ for (int i = 0; i < 7; ++i)
+ reserved[i] = proto.reserved[i];
}
};
Commit: 4748257123f78b006381e337a61c68991375cb2d
https://github.com/scummvm/scummvm/commit/4748257123f78b006381e337a61c68991375cb2d
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:29+02:00
Commit Message:
SAGA2: Fix some warnings
Changed paths:
engines/saga2/effects.h
diff --git a/engines/saga2/effects.h b/engines/saga2/effects.h
index 8bef3484e7..0d651d7636 100644
--- a/engines/saga2/effects.h
+++ b/engines/saga2/effects.h
@@ -274,7 +274,7 @@ inline uint16 makeEnchantmentID(uint16 type, uint16 damtyp, int16 damamt) {
assert(type < 8);
assert(damtyp < 32);
assert(damamt < 128 && damamt > -128);
- return (type << 13) | (damtyp << 8) + (damamt + 128);
+ return ((type << 13) | (damtyp << 8)) + (damamt + 128);
}
/* skill* are now in the spellid enum ;AS;
@@ -283,23 +283,23 @@ inline uint16 makeEnchantmentID(effectAttribTypes atttyp, int16 damamt)
*/
inline uint16 makeEnchantmentID(effectResistTypes restyp, bool damamt) {
- return (effectResist << 13) | (restyp << 8) + (damamt + 128);
+ return ((effectResist << 13) | (restyp << 8)) + (damamt + 128);
}
inline uint16 makeEnchantmentID(effectImmuneTypes immtyp, bool damamt) {
- return (effectImmune << 13) | (immtyp << 8) + (damamt + 128);
+ return ((effectImmune << 13) | (immtyp << 8)) + (damamt + 128);
}
inline uint16 makeEnchantmentID(effectOthersTypes othtyp, bool damamt) {
- return (effectOthers << 13) | (othtyp << 8) + (damamt + 128);
+ return ((effectOthers << 13) | (othtyp << 8)) + (damamt + 128);
}
inline uint16 makeEnchantmentID(objectFlags othtyp, bool damamt) {
- return (effectNonActor << 13) | (othtyp << 8) + (damamt + 128);
+ return ((effectNonActor << 13) | (othtyp << 8)) + (damamt + 128);
}
inline uint16 makeEnchantmentID(uint8 damamt) {
- return (effectPoison << 13) | (0 << 8) + damamt;
+ return ((effectPoison << 13) | (0 << 8)) + damamt;
}
inline effectTypes getEnchantmentType(uint16 eID) {
Commit: 09c4a42d32228400272112316a77221e647902d0
https://github.com/scummvm/scummvm/commit/09c4a42d32228400272112316a77221e647902d0
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:29+02:00
Commit Message:
SAGA2: Add warning for missing methods
Changed paths:
engines/saga2/objproto.cpp
diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp
index 1bcb634b4e..791f8114ca 100644
--- a/engines/saga2/objproto.cpp
+++ b/engines/saga2/objproto.cpp
@@ -490,6 +490,7 @@ bool ProtoObj::eat(ObjectID dObj, ObjectID enactor) {
int16 scriptResult;
// Handle object script in a standard fashion
+ warning("ProtoObj::eat: Method_GameObject_onEat undefined");
if ((scriptResult = stdActionScript(
Method_GameObject_onEat,
dObj, enactor, Nothing))
@@ -512,6 +513,7 @@ bool ProtoObj::insert(ObjectID dObj, ObjectID enactor, ObjectID item) {
int16 scriptResult;
// Handle object script in a standard fashion
+ warning("ProtoObj::insert: Method_GameObject_onInsert undefined");
if ((scriptResult = stdActionScript(
Method_GameObject_onInsert,
dObj, enactor, item))
@@ -533,6 +535,7 @@ bool ProtoObj::remove(ObjectID dObj, ObjectID enactor) {
int16 scriptResult;
// Handle object script in a standard fashion
+ warning("ProtoObj::remove: Method_GameObject_onRemove undefined");
if ((scriptResult = stdActionScript(
Method_GameObject_onRemove,
dObj, enactor, Nothing))
@@ -559,6 +562,7 @@ bool ProtoObj::acceptDrop(
int16 scriptResult;
// Handle object script in a standard fashion
+ warning("ProtoObj::acceptDrop: Method_GameObject_onAcceptDrop undefined");
if ((scriptResult = stdActionScript(
Method_GameObject_onAcceptDrop,
dObj, enactor, droppedObj, count))
@@ -658,6 +662,7 @@ bool ProtoObj::acceptStrike(
int16 scriptResult;
// Handle object script in a standard fashion
+ warning("ProtoObj::acceptStrike: Method_GameObject_onAcceptStrike undefined");
if ((scriptResult = stdActionScript(
Method_GameObject_onAcceptStrike,
dObj, enactor, strikingObj))
@@ -719,6 +724,7 @@ bool ProtoObj::acceptMix(ObjectID dObj, ObjectID enactor, ObjectID mixObj) {
int16 scriptResult;
// Handle object script in a standard fashion
+ warning("ProtoObj::acceptMix: Method_GameObject_onAcceptMix undefined");
if ((scriptResult = stdActionScript(
Method_GameObject_onAcceptMix,
dObj, enactor, mixObj))
Commit: fa11dcd1a41f67be641e6cfd4e8b7355497ea441
https://github.com/scummvm/scummvm/commit/fa11dcd1a41f67be641e6cfd4e8b7355497ea441
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:29+02:00
Commit Message:
SAGA2: Fix more warnings
Changed paths:
engines/saga2/floating.h
engines/saga2/sensor.cpp
engines/saga2/speech.cpp
engines/saga2/sprite.h
engines/saga2/task.cpp
engines/saga2/tile.cpp
diff --git a/engines/saga2/floating.h b/engines/saga2/floating.h
index 06c5e88262..ae7f8a2269 100644
--- a/engines/saga2/floating.h
+++ b/engines/saga2/floating.h
@@ -109,8 +109,8 @@ private:
class gButton : public gControl {
public:
- gButton(gPanelList &list, const Rect16 &box, char *title, uint16 ident, AppFunc *cmd = NULL) :
- gControl(list, box, title, ident, cmd) {}
+ gButton(gPanelList &list, const Rect16 &box, char *title_, uint16 ident, AppFunc *cmd = NULL) :
+ gControl(list, box, title_, ident, cmd) {}
gButton(gPanelList &list, const Rect16 &box, gPixelMap &img, uint16 ident, AppFunc *cmd = NULL) :
gControl(list, box, img, ident, cmd) {}
@@ -150,8 +150,8 @@ public:
selImage = &img1;
deselImage = &img2;
}
- gImageButton(gPanelList &list, const Rect16 &box, gPixelMap &img1, gPixelMap &img2, char *title, uint16 ident, AppFunc *cmd = NULL) :
- gButton(list, box, title, ident, cmd) {
+ gImageButton(gPanelList &list, const Rect16 &box, gPixelMap &img1, gPixelMap &img2, char *title_, uint16 ident, AppFunc *cmd = NULL) :
+ gButton(list, box, title_, ident, cmd) {
selImage = &img1;
deselImage = &img2;
}
diff --git a/engines/saga2/sensor.cpp b/engines/saga2/sensor.cpp
index e3e46249e3..4a91c56c09 100644
--- a/engines/saga2/sensor.cpp
+++ b/engines/saga2/sensor.cpp
@@ -482,7 +482,7 @@ bool ProtaganistSensor::check(SenseInfo &info, uint32 senseFlags) {
int16 i;
bool objIsActor = isActor(getObject());
- for (i = 0; i < elementsof(playerActorIDs); i++) {
+ for (i = 0; i < (long)elementsof(playerActorIDs); i++) {
Actor *protag =
getPlayerActorAddress(playerActorIDs[i])->getActor();
@@ -680,12 +680,12 @@ bool SpecificObjectSensor::check(SenseInfo &info, uint32 senseFlags) {
//----------------------------------------------------------------------
// Determine if an object meets the search criteria
-bool SpecificObjectSensor::isObjectSought(GameObject *obj) {
- assert(isObject(obj) || isActor(obj));
+bool SpecificObjectSensor::isObjectSought(GameObject *obj_) {
+ assert(isObject(obj_) || isActor(obj_));
assert(soughtObjID != Nothing);
assert(isObject(soughtObjID) || isActor(soughtObjID));
- return obj == GameObject::objectAddress(soughtObjID);
+ return obj_ == GameObject::objectAddress(soughtObjID);
}
/* ===================================================================== *
@@ -736,10 +736,10 @@ int16 ObjectPropertySensor::getType(void) {
//----------------------------------------------------------------------
// Determine if an object meets the search criteria
-bool ObjectPropertySensor::isObjectSought(GameObject *obj) {
- assert(isObject(obj) || isActor(obj));
+bool ObjectPropertySensor::isObjectSought(GameObject *obj_) {
+ assert(isObject(obj_) || isActor(obj_));
- return obj->hasProperty(*getObjProp(objectProperty));
+ return obj_->hasProperty(*getObjProp(objectProperty));
}
/* ===================================================================== *
@@ -749,11 +749,11 @@ bool ObjectPropertySensor::isObjectSought(GameObject *obj) {
//----------------------------------------------------------------------
// Determine if an object meets the search criteria
-bool ActorSensor::isObjectSought(GameObject *obj) {
- assert(isObject(obj) || isActor(obj));
+bool ActorSensor::isObjectSought(GameObject *obj_) {
+ assert(isObject(obj_) || isActor(obj_));
// Only actors need apply
- return isActor(obj) && isActorSought((Actor *)obj);
+ return isActor(obj_) && isActorSought((Actor *)obj_);
}
/* ===================================================================== *
diff --git a/engines/saga2/speech.cpp b/engines/saga2/speech.cpp
index 353d1b2813..ffb13633f0 100644
--- a/engines/saga2/speech.cpp
+++ b/engines/saga2/speech.cpp
@@ -269,7 +269,7 @@ bool Speech::append(char *text, int32 sampID) {
int16 len = strlen(text);
// Check to see if there's enough room in the character buffer
- if (charCount + len >= sizeof(speechBuffer)
+ if (charCount + len >= (long)sizeof(speechBuffer)
|| sampleCount >= MAX_SAMPLES) return false;
// Copy text to end of text in buffer, including '\0'
@@ -1015,7 +1015,7 @@ bool isVisible(GameObject *obj) {
SpeechTaskList::SpeechTaskList(void) {
lockFlag = false;
- for (int i = 0; i < elementsof(array); i++) {
+ for (int i = 0; i < (long)elementsof(array); i++) {
free.addTail(array[i]);
}
}
@@ -1032,7 +1032,7 @@ SpeechTaskList::SpeechTaskList(void **buf) {
lockFlag = false;
// Initialize the free list
- for (i = 0; i < elementsof(array); i++) {
+ for (i = 0; i < (long)elementsof(array); i++) {
free.addTail(array[i]);
}
diff --git a/engines/saga2/sprite.h b/engines/saga2/sprite.h
index 8845f31157..5b0e826be9 100644
--- a/engines/saga2/sprite.h
+++ b/engines/saga2/sprite.h
@@ -293,12 +293,11 @@ public:
loadSpriteBanks((int16)(1 << bank));
}
- // FIXME: Pointer Arithmetic
ActorAnimation *animation(int num) {
if (poseList == nullptr)
return nullptr;
- if (num >= poseList->numAnimations) {
+ if (num >= (int)poseList->numAnimations) {
warning("ActorPose:animation(), animation number is too high, %d >= %d", num, poseList->numAnimations);
return nullptr;
}
@@ -318,7 +317,7 @@ public:
num += anim->start[dir];
- if (num >= poseList->numPoses) {
+ if (num >= (int)poseList->numPoses) {
warning("ActorPose::pose(), pose number is too high, %d >= %d", num, poseList->numPoses);
return nullptr;
}
diff --git a/engines/saga2/task.cpp b/engines/saga2/task.cpp
index ac2210583b..249298d628 100644
--- a/engines/saga2/task.cpp
+++ b/engines/saga2/task.cpp
@@ -1973,7 +1973,7 @@ TaskResult GoAwayFromTask::evaluate(void) {
// Update this task
TaskResult GoAwayFromTask::update(void) {
- static const TilePoint dirTable[] = {
+ static const TilePoint dirTable_[] = {
TilePoint(64, 64, 0),
TilePoint(0, 64, 0),
TilePoint(-64, 64, 0),
@@ -1996,7 +1996,7 @@ TaskResult GoAwayFromTask::update(void) {
dest.v = actorLoc.v + ((int32)repulsionVector.v * 64 / repulsionDist);
dest.z = actorLoc.z;
} else
- dest = actorLoc + dirTable[a->currentFacing];
+ dest = actorLoc + dirTable_[a->currentFacing];
if (goTask != NULL) {
if (goTask->getTarget() != dest)
@@ -3950,7 +3950,7 @@ void BandTask::evaluateTarget(void) {
int16 j = repulsorCount;
if (repulsorDist < repulsorDistArray[j - 1]) {
- if (repulsorCount < elementsof(repulsorVectorArray)) {
+ if (repulsorCount < (long)elementsof(repulsorVectorArray)) {
repulsorDistArray[j] = repulsorDistArray[j - 1];
repulsorVectorArray[j] = repulsorVectorArray[j - 1];
repulsorStrengthArray[j] = repulsorStrengthArray[j - 1];
@@ -3965,8 +3965,8 @@ void BandTask::evaluateTarget(void) {
j--;
}
- if (j < elementsof(repulsorVectorArray)) {
- if (repulsorCount < elementsof(repulsorVectorArray))
+ if (j < (long)elementsof(repulsorVectorArray)) {
+ if (repulsorCount < (long)elementsof(repulsorVectorArray))
repulsorCount++;
repulsorDistArray[j] = repulsorDist;
repulsorVectorArray[j] = repulsorVector;
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 5faf49c181..4a74a8ada8 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -1312,8 +1312,6 @@ bool TileActivityTask::setWait(ActiveItem *tai, ThreadID script) {
// Calls the handling routine for each tile activity task
void moveActiveTerrain(int32 deltaTime) {
- deltaTime = 0;
-
TileActivityTask::updateActiveItems();
}
Commit: f9bc954de0084aace10e0353800f17bab723e830
https://github.com/scummvm/scummvm/commit/f9bc954de0084aace10e0353800f17bab723e830
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:29+02:00
Commit Message:
SAGA2: Added mapping to the SAGA classes
Changed paths:
engines/saga2/methods.r
engines/saga2/objproto.h
engines/saga2/pclass.r
diff --git a/engines/saga2/methods.r b/engines/saga2/methods.r
index 0c35904b6a..2d2acd2caf 100644
--- a/engines/saga2/methods.r
+++ b/engines/saga2/methods.r
@@ -67,7 +67,7 @@ enum {
Method_GameObject_onAcceptLockToggle,
Method_GameObject_onAcceptMix,
Method_GameObject_onAcceptDrop,
- Method_GameObject_onAcceptStrike,
+ Method_GameObject_onAcceptStrike = 37,
Method_GameObject_onAcceptInsertion = 40,
Method_GameObject_onTrigger = 41,
Method_GameObject_onTimerTick = 42,
diff --git a/engines/saga2/objproto.h b/engines/saga2/objproto.h
index d1916ef300..217c349e7b 100644
--- a/engines/saga2/objproto.h
+++ b/engines/saga2/objproto.h
@@ -224,7 +224,7 @@ struct ResourceObjectPrototype {
objPropHidden = (1 << 10), // "How not to be seen".
objPropGhosted = (1 << 11), // Object permanently ghosted
objPropHardSurface = (1 << 12), // Object makes hard sound when struck
- objPropNoSurface = (1 << 13), // Object makes no sound when struck (may grunt however)
+ objPropNoSurface = (1 << 13) // Object makes no sound when struck (may grunt however)
};
int16 price; // object's price
diff --git a/engines/saga2/pclass.r b/engines/saga2/pclass.r
index f20b588564..8bb6bdc0bf 100644
--- a/engines/saga2/pclass.r
+++ b/engines/saga2/pclass.r
@@ -29,37 +29,37 @@
namespace Saga2 {
-// TODO FIXME. All of these have to be extracted from the disassembly
-
enum {
- protoClassArrow,
- protoClassFood,
- protoClassKey,
- protoClassBottle,
- protoClassPhysContainer,
- protoClassBludgeoningWeapon,
- protoClassSlashingWeapon,
- protoClassBow,
- protoClassInventory,
- protoClassArmor,
- protoClassWeaponWand,
- protoClassShield,
- protoClassTool,
- protoClassBookDoc,
- protoClassPsych,
- protoClassMemory,
- protoClassIdea,
- protoClassScrollDoc,
- protoClassMap,
- protoClassSkill,
- protoClassIdeaContainer,
- protoClassMemoryContainer,
- protoClassPsychContainer,
- protoClassSkillContainer,
- protoClassEnchantment,
- protoClassMonsterGenerator,
- protoClassEncounterGenerator,
- protoClassMissionGenerator
+ protoClassArmor = 1,
+ protoClassArrow = 2,
+ protoClassBludgeoningWeapon = 4,
+ protoClassBookDoc = 5,
+ protoClassBottle = 6,
+ protoClassBow = 7,
+ protoClassEnchantment = 8,
+ protoClassEncounterGenerator = 9,
+ protoClassFood = 10,
+ protoClassIdea = 11,
+ protoClassInventory = 13,
+ protoClassKey = 14,
+ protoClassMap = 16,
+ protoClassMemory = 17,
+ protoClassMissionGenerator = 19,
+ protoClassMonsterGenerator = 20,
+ protoClassPhysContainer = 21,
+ protoClassPsych = 22,
+ protoClassScrollDoc = 24,
+ protoClassShield = 25,
+ protoClassSkill = 26,
+ protoClassSlashingWeapon = 28,
+ protoClassTool = 32,
+ protoClassWeaponWand = 33,
+
+ // FIXME: Doublecheck these
+ protoClassIdeaContainer = 12,
+ protoClassMemoryContainer = 18,
+ protoClassPsychContainer = 23,
+ protoClassSkillContainer = 27
};
} // end of namespace Saga2
Commit: 36ea80697b5dc1397ed83c10b3c75dc6b595ad50
https://github.com/scummvm/scummvm/commit/36ea80697b5dc1397ed83c10b3c75dc6b595ad50
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:29+02:00
Commit Message:
SAGA2: Remove rmem from button.cpp
Changed paths:
engines/saga2/button.cpp
diff --git a/engines/saga2/button.cpp b/engines/saga2/button.cpp
index a99aa67ddb..206b3fdf77 100644
--- a/engines/saga2/button.cpp
+++ b/engines/saga2/button.cpp
@@ -189,13 +189,13 @@ gCompImage::~gCompImage(void) {
// if we LoadRes'ed image internally RDispose those
if (internalAlloc) {
for (int16 i = 0; i < numPtrAlloc; i++) {
- RDisposePtr(compImages[i]);
+ free(compImages[i]);
}
}
// delete any pointer arrays new'ed
if (numPtrAlloc > 0) {
- delete compImages;
+ free(compImages);
}
}
@@ -334,7 +334,7 @@ void gSpriteImage::drawClipped(gPort &port,
//map.size = Point16( extent.height, extent.width );
map.size = sprPtr->size;
- map.data = (uint8 *)RNewPtr(map.bytes(), NULL, "gcomp image sprite decompression map");
+ map.data = (uint8 *)malloc(map.bytes() * sizeof(uint8));
if (map.data == NULL) return;
memset(map.data, 0, map.bytes());
@@ -347,7 +347,7 @@ void gSpriteImage::drawClipped(gPort &port,
extent.x - offset.x, extent.y - offset.y,
map.size.x, map.size.y);
- RDisposePtr(map.data);
+ free(map.data);
}
/* ===================================================================== *
@@ -482,17 +482,17 @@ gCompButton::gCompButton(gPanelList &list, const Rect16 &box, void *image, uint1
gCompButton::~gCompButton(void) {
if (internalAlloc) {
if (forImage) {
- RDisposePtr(forImage);
+ free(forImage);
forImage = NULL;
}
if (resImage) {
- RDisposePtr(resImage);
+ free(resImage);
resImage = NULL;
}
if (dimImage) {
- RDisposePtr(dimImage);
+ free(dimImage);
dimImage = NULL;
}
}
@@ -750,11 +750,11 @@ gMultCompButton::~gMultCompButton(void) {
if (images && internalAlloc) {
for (i = 0; i <= max; i++) {
if (images[i]) {
- RDisposePtr(images[i]);
+ free(images[i]);
}
}
- delete images;
+ free(images);
images = NULL;
}
}
Commit: 54d2e7ac11294ad9d9fcdde5b8fa0fd4b1842803
https://github.com/scummvm/scummvm/commit/54d2e7ac11294ad9d9fcdde5b8fa0fd4b1842803
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:29+02:00
Commit Message:
SAGA2: Kill rmem and rserver
Changed paths:
R engines/saga2/rmem.cpp
R engines/saga2/rmem.h
R engines/saga2/rmembase.h
R engines/saga2/rserver.cpp
engines/saga2/automap.cpp
engines/saga2/band.cpp
engines/saga2/contain.cpp
engines/saga2/document.cpp
engines/saga2/fta.h
engines/saga2/gtextbox.cpp
engines/saga2/hresmgr.cpp
engines/saga2/hresmgr.h
engines/saga2/imagcach.cpp
engines/saga2/interp.cpp
engines/saga2/main.cpp
engines/saga2/module.mk
engines/saga2/motion.cpp
engines/saga2/oncall.h
engines/saga2/speldata.cpp
engines/saga2/task.cpp
engines/saga2/tile.h
engines/saga2/tileload.cpp
engines/saga2/tilemode.cpp
engines/saga2/towerfta.cpp
engines/saga2/vpal.cpp
diff --git a/engines/saga2/automap.cpp b/engines/saga2/automap.cpp
index e4ef13e2b6..1e11dc8a20 100644
--- a/engines/saga2/automap.cpp
+++ b/engines/saga2/automap.cpp
@@ -218,7 +218,7 @@ void CAutoMap::locateRegion(void) {
}
}
- RDisposePtr(trRes);
+ free(trRes);
if (areaRes) auxResFile->disposeContext(areaRes);
baseCoords.u = centerCoords.u - summaryRadius;
@@ -568,7 +568,7 @@ int16 openAutoMap() {
unloadImageRes(closeBtnImage, numBtnImages);
unloadImageRes(scrollBtnImage, 2);
- RDisposePtr(summaryData);
+ free(summaryData);
resFile->disposeContext(decRes);
decRes = NULL;
diff --git a/engines/saga2/band.cpp b/engines/saga2/band.cpp
index 7d9d7c2da6..1ea0aacd8a 100644
--- a/engines/saga2/band.cpp
+++ b/engines/saga2/band.cpp
@@ -31,7 +31,6 @@
#include "saga2/band.h"
#include "saga2/savefile.h"
#include "saga2/dlist.h"
-#include "saga2/rmem.h"
namespace Saga2 {
@@ -328,7 +327,7 @@ void saveBands(SaveFileConstructor &saveGame) {
archiveBufSize = bandList.archiveSize();
- archiveBuffer = RNewPtr(archiveBufSize, NULL, "archive buffer");
+ archiveBuffer = malloc(archiveBufSize);
if (archiveBuffer == NULL)
error("Unable to allocate band archive buffer");
@@ -339,7 +338,7 @@ void saveBands(SaveFileConstructor &saveGame) {
archiveBuffer,
archiveBufSize);
- RDisposePtr(archiveBuffer);
+ free(archiveBuffer);
}
//----------------------------------------------------------------------
@@ -355,7 +354,7 @@ void loadBands(SaveFileReader &saveGame) {
void *archiveBuffer;
void *bufferPtr;
- archiveBuffer = RNewPtr(saveGame.getChunkSize(), NULL, "archive buffer");
+ archiveBuffer = malloc(saveGame.getChunkSize());
if (archiveBuffer == NULL)
error("Unable to allocate task archive buffer");
@@ -368,7 +367,7 @@ void loadBands(SaveFileReader &saveGame) {
new (&bandList) BandList;
bandList.restore(bufferPtr);
- RDisposePtr(archiveBuffer);
+ free(archiveBuffer);
}
//----------------------------------------------------------------------
diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index 710ae7801c..d5832f55e0 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -1822,7 +1822,7 @@ void saveContainerNodes(SaveFileConstructor &saveGame) {
archiveBufSize += numNodes * ContainerNode::archiveSize();
// Allocate the archive buffer
- archiveBuffer = RNewPtr(archiveBufSize, NULL, "archive buffer");
+ archiveBuffer = malloc(archiveBufSize);
if (archiveBuffer == NULL)
error("Unable to allocate ContainerNode archive buffer\n");
@@ -1847,7 +1847,7 @@ void saveContainerNodes(SaveFileConstructor &saveGame) {
archiveBufSize);
// Free the archive buffer
- RDisposePtr(archiveBuffer);
+ free(archiveBuffer);
}
void loadContainerNodes(SaveFileReader &saveGame) {
@@ -1874,7 +1874,7 @@ void loadContainerNodes(SaveFileReader &saveGame) {
// Allocate archive buffer
archiveBufSize = saveGame.bytesLeftInChunk();
- archiveBuffer = RNewPtr(archiveBufSize, NULL, "archive buffer");
+ archiveBuffer = malloc(archiveBufSize);
if (archiveBuffer == NULL)
error("Unable to allocate ContainerNode archive buffer\n");
@@ -1897,7 +1897,7 @@ void loadContainerNodes(SaveFileReader &saveGame) {
assert(tempList.empty());
// Free the archive buffer
- RDisposePtr(archiveBuffer);
+ free(archiveBuffer);
}
void cleanupContainerNodes(void) {
diff --git a/engines/saga2/document.cpp b/engines/saga2/document.cpp
index 4601954437..5326a92078 100644
--- a/engines/saga2/document.cpp
+++ b/engines/saga2/document.cpp
@@ -159,14 +159,12 @@ CDocument::CDocument(CDocumentAppearance &dApp,
textSize = clamp(0, strlen(buffer), maxSize);
// set the original text pointer
- //origText = ( char * )RNewPtr( textSize + 1, NULL, "book original text buffer" );
origText = new char[textSize + 1];
// and fill it
strcpy(origText, buffer);
// make a working buffer
- //text = ( char * )RNewPtr( textSize + 1, NULL, "book work text buffer" );
text = new char[textSize + 1];
// and fill it
@@ -205,25 +203,24 @@ CDocument::~CDocument(void) {
for (i = 0; i < maxPages; i++) {
if (images[i]) {
- RDisposePtr(images[i]);
+ free(images[i]);
}
}
// get rid of the working text buffer
if (text) {
- //RDisposePtr( text );
- delete text;
+ delete[] text;
text = NULL;
}
if (origText) {
- //RDisposePtr( origText );
- delete origText;
+ delete[] origText;
origText = NULL;
}
// get rid of the resource context
- if (illustrationCon) resFile->disposeContext(illustrationCon);
+ if (illustrationCon)
+ resFile->disposeContext(illustrationCon);
}
void CDocument::deactivate(void) {
diff --git a/engines/saga2/fta.h b/engines/saga2/fta.h
index fe247abe4c..55db92e8a0 100644
--- a/engines/saga2/fta.h
+++ b/engines/saga2/fta.h
@@ -28,7 +28,6 @@
#define SAGA2_FTA_H
#include "saga2/gpointer.h"
-#include "saga2/rmem.h"
namespace Saga2 {
@@ -160,30 +159,12 @@ void WriteStatusF(int16 lin, const char *msg, ...);
// File loading
void *LoadFile(char *filename); // load file into buffer
-RHANDLE LoadFileToHandle(char *filename); // load file into relocatable buf
// Resource loading
void *LoadResource(hResContext *con, uint32 id, const char desc[]);
-RHANDLE LoadResourceToHandle(hResContext *con, uint32 id, const char desc[]);
Common::SeekableReadStream *loadResourceToStream(hResContext *con, uint32 id, const char desc[]);
-// Asynchronous resource loading
-
-void RequestResource(
- RHANDLE handle,
- int32 offset,
- int32 length,
- // Function to notify when request is done.
- void *notify = NULL,
- void *userData = NULL);
-
-void syncResources(void);
-void *lockResource(RHANDLE h);
-void unlockResource(RHANDLE h);
-
-void loadAsyncResources(void);
-
// Directory control
void restoreProgramDir(void); // chdir() to program directory
@@ -191,7 +172,6 @@ void restoreProgramDir(void); // chdir() to program directory
// Memory allocation
void *mustAlloc(uint32 size, const char desc[]); // alloc 'size' bytes or fail
-RHANDLE mustAllocHandle(uint32 size, const char desc[]); // as above, but relocatable
// Returns Random Number
@@ -250,8 +230,6 @@ extern bool gameRunning; // true while game running
extern gDisplayPort mainPort; // main drawing port
extern gMousePointer pointer; // the mouse pointer
-extern RHeapPtr gameHeap; // memory heap for game
-
extern volatile int32 gameTime; // current timer
// Resource files
diff --git a/engines/saga2/gtextbox.cpp b/engines/saga2/gtextbox.cpp
index a1ac25d64f..7e060d6649 100644
--- a/engines/saga2/gtextbox.cpp
+++ b/engines/saga2/gtextbox.cpp
@@ -296,8 +296,6 @@ bool gTextBox::insertText(char *newText, int length) {
currentLen[index] += (length - selWidth);
fieldStrings[index][currentLen[index]] = '\0';
- RMemIntegrity();
-
return true;
}
@@ -334,8 +332,6 @@ void gTextBox::setText(char *newText) {
cursorPos = anchorPos = 0;
if (window.isOpen()) drawContents();
-
- RMemIntegrity();
}
//-----------------------------------------------------------------------
@@ -996,8 +992,6 @@ void gTextBox::drawContents(void) {
DisposeTempPort(tPort); // dispose of temporary pixelmap
}
-
- RMemIntegrity();
}
//-----------------------------------------------------------------------
@@ -1115,8 +1109,6 @@ void gTextBox::drawAll(gPort &port,
DisposeTempPort(tempPort); // dispose of temporary pixelmap
}
-
- RMemIntegrity();
}
} // end of namespace Saga2
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index 5740328174..3c6769018f 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -104,7 +104,7 @@ hResContext::~hResContext() {
releaseIndexData();
}
-hResEntry *hResContext::findEntry(hResID id, RHANDLE **capture) {
+hResEntry *hResContext::findEntry(hResID id) {
hResEntry *entry;
int16 i;
@@ -374,53 +374,6 @@ byte *hResContext::loadResource(hResID id, const char desc[], Common::String fil
return res;
}
-RHANDLE hResContext::load(hResID id, const char desc[], bool async, bool cacheable) {
- hResEntry *entry;
- RHANDLE *capture;
-
- if (!_valid)
- return nullptr;
- _bytecount = 0;
- _bytepos = 0;
-
- if ((entry = findEntry(id, &capture)) == nullptr)
- return nullptr;
-
- if (*capture != nullptr && **capture != nullptr) {
- entry->use();
- } else {
- if (*capture == nullptr)
- *capture = (RHANDLE)malloc(entry->size);
-
- if (*capture == nullptr) return nullptr;
-
- // If it's an external resource, then load synchronously
-
-#ifdef WINKLUDGE
- async = false;
-#endif
- if (entry->isExternal() || async == false) {
- if (seek(id) && read(**capture, entry->size)) {
- entry->use();
- } else {
- free(*capture);
- *capture = nullptr;
- }
-
- rest();
- } else {
-#ifndef WINKLUDGE
- RequestResource(*capture,
- entry->offset,
- entry->size);
-#endif
- entry->use();
- }
- }
-
- return (*capture);
-}
-
byte *hResContext::loadIndexResource(int16 index, const char desc[], Common::String filename) {
hResEntry *entry;
entry = &_base[index];
@@ -455,63 +408,6 @@ byte *hResContext::loadIndexResource(int16 index, const char desc[], Common::Str
return res;
}
-RHANDLE hResContext::loadIndex(int16 index, const char desc[], bool cacheable) {
- hResEntry *entry;
- RHANDLE *capture; //, _handle;
-
- if (!_valid)
- return nullptr;
- _bytecount = 0;
- _bytepos = 0;
-
- entry = &_base[index];
-
- if (*capture != nullptr && **capture != nullptr) {
- entry->use();
- } else {
- if (*capture == nullptr)
- *capture = (RHANDLE)malloc(entry->size);
-
- if (*capture == nullptr) return nullptr;
-
- _res->_handle->seek(entry->resOffset(), SEEK_SET);
-
- if (read(**capture, entry->size) == false) {
- free(*capture);
- *capture = nullptr;
- }
- entry->use();
- rest();
- }
- return (*capture);
-}
-
-void hResContext::release(RHANDLE p) {
- _bytecount = 0;
- _bytepos = 0;
-
- hResEntry *entry;
- RHANDLE *d;
-
- if (_valid && p != nullptr) {
- entry = _base;
-
- while (entry->id != BAD_ID) {
- if ((RHANDLE)p == *d) {
-
- entry->abandon();
- if (!entry->isUsed()) {
- RDisposeHandle(p);
- *d = nullptr;
- }
- return;
- }
- entry++;
- d++;
- }
- }
-}
-
void hResContext::releaseIndexData() {
debugC(4, kDebugResources, "releaseIndexData():");
for (DataMap::iterator i = _indexData.begin(); i != _indexData.end(); ++i) {
@@ -619,21 +515,4 @@ void hResource::disposeContext(hResContext *con) {
if (con) delete con;
}
-
-/* ===================================================================== *
- Assorted functions
- * ===================================================================== */
-
-//-----------------------------------------------------------------------
-// For handles which have been purged, but the handle structure is
-// still hanging around, we can free the handle structure and
-// set the actual handle pointer to nullptr.
-
-void washHandle(RHANDLE &handle) {
- if (handle != nullptr && *handle == nullptr) {
- RDisposeHandle(handle);
- handle = nullptr;
- }
-}
-
} // end of namespace Saga2
diff --git a/engines/saga2/hresmgr.h b/engines/saga2/hresmgr.h
index 6b4e74de9d..0541c6c841 100644
--- a/engines/saga2/hresmgr.h
+++ b/engines/saga2/hresmgr.h
@@ -29,8 +29,6 @@
#include "common/file.h"
-#include "saga2/rmem.h"
-
namespace Saga2 {
@@ -132,7 +130,7 @@ protected:
uint32 _bytecount;
uint32 _bytepos;
- hResEntry *findEntry(hResID id, RHANDLE **capture = NULL);
+ hResEntry *findEntry(hResID id);
Common::File *openExternal(Common::File *fh);
public:
@@ -169,11 +167,8 @@ public:
bool skip(uint32 amount);
bool get(hResID id, void *buffer, uint32 size);
uint32 getSize(hResID id, const char desc[]);
- RHANDLE load(hResID id, const char [], bool async = false, bool cacheable = true);
byte *loadResource(hResID id, const char desc[], Common::String filename = "");
byte *loadIndexResource(int16 index, const char desc[], Common::String filename = "");
- RHANDLE loadIndex(int16 index, const char[], bool cacheable = true);
- void release(RHANDLE p);
void releaseIndexData();
Common::File *resFileHandle(void) {
return _handle;
@@ -219,9 +214,6 @@ inline hResID RES_ID(uint8 a, uint8 b, uint8 c, uint8 d) {
#define HRES_ID MKTAG('H','R','E','S')
-// Handle-washing function.
-void washHandle(RHANDLE &handle);
-
#ifdef _WIN32 // Set structure alignment packing value to 1 byte
#pragma pack( pop )
#endif
diff --git a/engines/saga2/imagcach.cpp b/engines/saga2/imagcach.cpp
index f0918184ef..1ebdb97aa1 100644
--- a/engines/saga2/imagcach.cpp
+++ b/engines/saga2/imagcach.cpp
@@ -55,7 +55,7 @@ CImageNode::CImageNode(hResContext *con, uint32 resID) {
CImageNode::~CImageNode(void) {
if (image) {
- RDisposePtr(image);
+ free(image);
image = NULL;
}
}
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index eb572cbac8..1005e59315 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -1458,7 +1458,7 @@ Thread::Thread(uint16 segNum, uint16 segOff, scriptCallFrame &args) {
programCounter.segment = segNum;
programCounter.offset = segOff;
threadArgs = args;
- stackBase = (UBytePtr)malloc(stackSize);
+ stackBase = (byte *)malloc(stackSize);
stackPtr = stackBase + stackSize - initialStackFrameSize;
((uint16 *)stackPtr)[0] = 0; // 0 args
((uint16 *)stackPtr)[1] = 0; // dummy return address
@@ -1498,7 +1498,7 @@ Thread::Thread(void **buf) {
codeSeg = scriptRes->loadIndexResource(programCounter.segment, "saga code segment");
- stackBase = (UBytePtr)malloc(stackSize);
+ stackBase = (byte *)malloc(stackSize);
stackPtr = stackBase + stackSize - stackOffset;
memcpy(stackPtr, bufferPtr, stackOffset);
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 2119a273db..5e737c57c4 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -367,7 +367,6 @@ void displayUpdate(void) {
reDrawScreen();
// Call asynchronous resource loader
debugC(1, kDebugEventLoop, "EventLoop: resource update");
- loadAsyncResources();
//FIXME: Disabled for debug purposes. Enable and implement later.
//audioEventLoop();
@@ -538,28 +537,6 @@ Common::SeekableReadStream *loadResourceToStream(hResContext *con, uint32 id, co
return new Common::MemoryReadStream(buffer, size, DisposeAfterUse::YES);
}
-//-----------------------------------------------------------------------
-// Loads a resource into a relocatable buffer and returns a handle
-
-RHANDLE LoadResourceToHandle(hResContext *con, uint32 id, const char desc[]) {
- int32 size;
- RHANDLE buffer; // allocated buffer
-
- debugC(3, kDebugResources, "LoadResourceToHandle(): Loading resource %d (%s, %s)", id, tag2str(id), desc);
-
- size = con->size(id);
- if (size <= 0 || !con->seek(id)) {
- error("LoadResourceToHandle(): Error reading resource ID '%s'.", tag2str(id));
- }
-
- // Allocate the buffer
- buffer = mustAllocHandle(size, desc);
- con->read(*buffer, size);
- con->rest();
-
- return buffer;
-}
-
typedef hResource *pHResource;
inline char drive(char *path) {
@@ -958,17 +935,4 @@ void *mustAlloc(uint32 size, const char desc[]) {
return ptr;
}
-//-----------------------------------------------------------------------
-// Allocates relocatable memory, or throws exception if allocation fails.
-
-RHANDLE mustAllocHandle(uint32 size, const char desc[]) {
- void **ptr;
-
- ptr = (void **)malloc(size);
- // REM: Before we give up completely, try unloading some things...
- if (ptr == NULL)
- error("Local handle allocation size %d bytes failed.", size);
- return ptr;
-}
-
} // end of namespace Saga2
diff --git a/engines/saga2/module.mk b/engines/saga2/module.mk
index 0965bab826..c15a9685b4 100644
--- a/engines/saga2/module.mk
+++ b/engines/saga2/module.mk
@@ -58,8 +58,6 @@ MODULE_OBJS := \
property.o \
pt2angle.o \
rect.o \
- rmem.o \
- rserver.o \
saga2.o \
sagafunc.o \
savefile.o \
diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp
index 73a4625128..4bb1dff55c 100644
--- a/engines/saga2/motion.cpp
+++ b/engines/saga2/motion.cpp
@@ -4973,7 +4973,7 @@ void saveMotionTasks(SaveFileConstructor &saveGame) {
archiveBufSize = mTaskList.archiveSize();
- archiveBuffer = RNewPtr(archiveBufSize, NULL, "archive buffer");
+ archiveBuffer = malloc(archiveBufSize);
if (archiveBuffer == NULL)
error("Unable to allocate motion task archive buffer");
@@ -4984,7 +4984,7 @@ void saveMotionTasks(SaveFileConstructor &saveGame) {
archiveBuffer,
archiveBufSize);
- RDisposePtr(archiveBuffer);
+ free(archiveBuffer);
}
//-----------------------------------------------------------------------
@@ -5000,7 +5000,7 @@ void loadMotionTasks(SaveFileReader &saveGame) {
void *archiveBuffer;
void *bufferPtr;
- archiveBuffer = RNewPtr(saveGame.getChunkSize(), NULL, "archive buffer");
+ archiveBuffer = malloc(saveGame.getChunkSize());
if (archiveBuffer == NULL)
error("Unable to allocate motion task archive buffer");
@@ -5012,7 +5012,7 @@ void loadMotionTasks(SaveFileReader &saveGame) {
// Reconstruct mTaskList from archived data
new (&mTaskList) MotionTaskList(&bufferPtr);
- RDisposePtr(archiveBuffer);
+ free(archiveBuffer);
}
//-----------------------------------------------------------------------
diff --git a/engines/saga2/oncall.h b/engines/saga2/oncall.h
index 83c36c5a3f..4d79be27a2 100644
--- a/engines/saga2/oncall.h
+++ b/engines/saga2/oncall.h
@@ -63,122 +63,6 @@ public:
}
};
-template <class RESTYPE> class LoadOnCall {
- BitArray wanted;
- BitArray locked;
- BitArray recent;
- RESTYPE *handle;
- uint16 handles;
- uint32 tileID;
- RHANDLE(*loader)(hResID, bool);
-
- RESTYPE rLoad(uint16 ind, bool asynch);
- void rFree(uint16);
- void rInit(uint16);
-
-public:
-
- LoadOnCall(uint16 newSize, RHANDLE(*loadfunction)(hResID, bool), uint32 newID) {
- tileID = newID;
- wanted.resize(newSize);
- locked.resize(newSize);
- recent.resize(newSize);
- handle = (RESTYPE *)malloc(sizeof(RESTYPE) * newSize);
- handles = newSize;
- loader = loadfunction;
- for (uint16 i = 0; i < newSize; i++)
- rInit(i);
- }
-
- // destructor
- ~LoadOnCall() {
- //if (handles) delete[] handle;
- }
-
- RESTYPE operator[](uint32 ind) {
-// assert (ind<handles);
- if (!locked[ind]) handle[ind] = rLoad(ind, false);
- return handle[ind];
- }
-
- void flush(void) {
- //recent.clearAll();
- for (uint16 i = 0; i < handles; i++)
- if ((locked[i]) && (!recent[i]))
- rFree(i);
- //locked|=recent;
- recent.clearAll();
- }
-
- BitArray lockState(void) {
- return locked;
- }
-
- BitArray wantState(void) {
- return wanted;
- }
-
-};
-
-template <class RESTYPE> RESTYPE LoadOnCall<RESTYPE>::rLoad(uint16 ind, bool asynch) {
- RESTYPE t;
- if (isValidPtr(handle[ind]) && locked[ind]) {
- RLockHandle((RHANDLE) handle[ind]);
- locked.Bit(ind, true);
- wanted.Bit(ind, false);
- recent.Bit(ind, true);
- return handle[ind];
- }
- if (isValidPtr(handle[ind]) && wanted[ind]) {
- // wait for handle
- RLockHandle((RHANDLE) handle[ind]);
- locked.Bit(ind, true);
- wanted.Bit(ind, false);
- recent.Bit(ind, true);
- return NULL;
- }
-
- //t = (RESTYPE) tileRes->load( tileID + MKTAG( 0,0,0,bankNum ) );
- t = (RESTYPE) loader(tileID + MKTAG(0, 0, 0, ind), asynch);
-
- locked.Bit(ind, !asynch);
- wanted.Bit(ind, asynch);
- recent.Bit(ind, true);
-
- if (asynch) {
- handle[ind] = (RESTYPE) NULL;
- } else {
- if (t == NULL) {
- error("Resource %d could not load (Tile bank)", ind);
- }
- handle[ind] = t;
- }
- return t;
-}
-
-template <class RESTYPE> void LoadOnCall<RESTYPE>::rFree(uint16 ind) {
- if (isValidPtr(handle[ind])) {
- RUnlockHandle((RHANDLE) handle[ind]);
- locked.Bit(ind, false);
- //recent.Bit(ind,false);
-// washHandle(handle[ind]);
- }
-}
-
-template <class RESTYPE> void LoadOnCall<RESTYPE>::rInit(uint16 ind) {
- RESTYPE t;
- if (!isValidPtr(handle[ind])) {
- t = (RESTYPE) loader(tileID + MKTAG(0, 0, 0, ind), false);
- handle[ind] = t;
- locked.Bit(ind, true);
- RUnlockHandle((RHANDLE) handle[ind]);
- locked.Bit(ind, false);
- recent.Bit(ind, false);
- }
-}
-
-//typedef LoadOnCall<TileBankHandle> tileBankArray; //(64,tileResLoad);
-
} // end of namespace Saga2
#endif
diff --git a/engines/saga2/rmem.cpp b/engines/saga2/rmem.cpp
deleted file mode 100644
index 5db8a9a740..0000000000
--- a/engines/saga2/rmem.cpp
+++ /dev/null
@@ -1,1504 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * aint32 with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#include "saga2/std.h"
-
-#define NO_LOCAL_MEMORY_OVERRIDES 1
-#include "saga2/rmem.h"
-#include "saga2/rmembase.h"
-
-namespace Saga2 {
-
-#define VMM_lock(p,s) LocalLock(p)
-#define VMM_unlock(p,s) LocalUnlock(p)
-
-/* ===================================================================== */
-/* External Dependencies */
-/* System calls */
-/* assert(bool); */
-/* malloc(size_t); */
-/* free(void*); */
-/* DGI Library calls */
-/* STD.H */
-/* Others */
-/* VMM_Lock() or LocalLock() (DOS/WIN) */
-/* VMM_Unlock() or LocalUnlock() (DOS/WIN) */
-/* initRMemLogging() (in RMEMLOG.CPP) */
-/* */
-/* ===================================================================== */
-
-#define SysAlloc malloc
-#define SysFree( m,s ) free( m )
-
-/* ===================================================================== *
- Debugging variables which control the heap integrity checking
- NOTE: If you want to change these settings you should do so
- in RMEM.H, not here.
- * ===================================================================== */
-
-// most of the checks are only enabled in the DEBUG version
-#if DEBUG
-# define WARN_LEAKS RMEM_WARN_LEAKS
-
-# define WIPE_ALLOC RMEM_WIPE_ALLOC
-# define WIPE_FREE RMEM_WIPE_FREE
-
-# define wallSize RMEM_WALL_SIZE // memory wall size around allocs
-# define mungEnable RMEM_MUNG_ENABLE // enable munging of free blocks
-# define prefixOffset (sizeof( RMemPrefix ) + wallSize)
-
-void checkWalls(uint8 *begin, uint32 length);
-void setWalls(uint8 *begin, uint32 length);
-#else
-# define WARN_LEAKS 0
-
-# define WIPE_ALLOC false
-# define WIPE_FREE false
-
-# define wallSize 0 // compile wall size as zero
-# define mungEnable 0 // disable munging
-# define prefixOffset sizeof( RMemPrefix )
-// If debugging off, checkwalls is an inline function which does nothing.
-# define checkWalls( begin, length ) ((void)0)
-# define setWalls( begin, length ) ((void)0)
-#endif
-
-/* ===================================================================== *
- Debugging variables which control the "visible memory" display
- * ===================================================================== */
-
-#if RMEM_VISIBLE
-
-void RShowMem(void);
-#define SHOWMEM RShowMem();
-
-#else
-
-#define SHOWMEM ((void)0)
-
-#endif
-
-/* ===================================================================== *
- Global variables
- * ===================================================================== */
-
-static RHeapPtr heapList = NULL; // pointer to heap chain
-
-/* ===================================================================== *
- Debugging variables which control the heap integrity checking
- * ===================================================================== */
-
-#define QUANTIZE(x) ((x) + 7 & ~7) // quantize to multiple of 8
-
-// These should be provided by App to call malloc() or whatever
-
-/* ============================================================================ *
- Prototypes
- * ============================================================================ */
-
-static void FreeHandle(RHeap *heap, RHandle *handle);
-static void *NewPtr(int32 size, RHeapPtr heap, bool high, const char []);
-#if DEBUG
-static bool _RMemCleanHeap(RHeapPtr heap);
-#endif
-static RHeapPtr whichHeap(void *ptr);
-void RDumpMem(RHeapPtr, int);
-
-typedef void *MEMERRHANDLER(size_t s, const char d[]);
-typedef MEMERRHANDLER *pMEMERRHANDLER;
-
-static pMEMERRHANDLER onError = NULL;
-
-pMEMERRHANDLER RMemSetFailHandler(pMEMERRHANDLER nh) {
- pMEMERRHANDLER oh = onError;
- onError = nh;
- return oh;
-}
-
-/* ============================================================================ *
- General internal allocation & free routines
- * ============================================================================ */
-
-static void *rmemAlloc(size_t s, const char desc[]) {
- void *r = NULL;
- if (heapList != NULL)
- r = _RNewPtr(s, NULL, desc);
- else
- r = SysAlloc(s);
- if (r == NULL && onError != NULL)
- r = (*onError)(s, desc);
- return r;
-}
-
-
-//quick dealloc
-
-static bool complicatedFree = true;
-
-static void rmemFree(void *mem) {
- if (whichHeap(mem) != NULL) {
- if (complicatedFree)
- RDisposePtr(mem);
- } else
- SysFree(mem, RPtrSize(mem));
-}
-
-void RMemFastCleanup(void) {
-#if !DEBUG
- complicatedFree = false;
-#endif
-}
-
-/* ============================================================================ *
- These calls are used to override malloc and free
- * ============================================================================ */
-
-#if DEBUG
-
-void *localMalloc(size_t s, const int l, const char f[]) {
- char tBuf[256];
- sprintf(tBuf, "%d %s", l, f);
- return rmemAlloc(s, tBuf);
-}
-
-#else
-
-void *localMalloc(size_t s, const int, const char []) {
- return rmemAlloc(s, "malloc");
-}
-
-#endif
-
-void *namedMalloc(size_t s, const char d[]) {
- return rmemAlloc(s, d);
-}
-
-void localFree(void *mem) {
- rmemFree(mem);
-}
-
-/* ===================================================================== *
- VMM Locking code
- * ===================================================================== */
-
-void VMM_Lock_Mem(void *ptr, size_t size) {
- warning("STUB: VMM_Lock_Mem()");
-#if 0
- if (!VMM_lock(ptr, size))
- error("VMM Locking failed");
-#endif
-}
-
-void VMM_Unlock_Mem(void *ptr, size_t size) {
- warning("STUB: VMM_Unlock_mem");
-#if 0
- if (!VMM_unlock(ptr, size))
- error("VMM Locking failed");
-#endif
-}
-
-/* ============================================================================ *
- Heap management
- * ============================================================================ */
-
-// RNewHeap: create a new heap
-// Arguments:
-
-RHeapPtr _RNewHeap(uint8 *memory, int32 size) {
- RHeapPtr heap; // pointer to new heap
-#if DEBUG
- initRMemLogging();
-#endif
-
- heap = (RHeapPtr) SysAlloc(sizeof * heap);
- if (heap == NULL)
- error("Memory allocation (%ld bytes) failed", sizeof * heap);
-
- heap->next = heapList;
- heapList = heap;
-
- memset(heap, 0, sizeof * heap);
-
- // Create empty circular list of cached blocks
- heap->cacheHead = heap->cacheTail = (RHandle *)&heap->cacheHead;
-
- heap->size = size; // size of memory buffer
- heap->free = size; // free space in heap
- heap->memory = memory; // pointer to raw memory
- heap->firstFree = (RMemFreeBlock *)memory; // first free block in buffer
- heap->firstFree->next = NULL; // initialize free block to whole blk
- heap->firstFree->size = heap->size;
- SHOWMEM;
- return heap; // return heap we created
-}
-
-// RDisposeHeap: Gets rid of a heap.
-// Note the actual heap memory isn't freed since we didn't allocate it
-
-void _RDisposeHeap(RHeapPtr heap) {
- RHeap **prev; // indirect pointer to this heap
-
-#if WARN_LEAKS
- if (complicatedFree)
- _RMemCleanHeap(heap);
-#endif
-
- // search heap list, find pointer to the heap we want
- for (prev = &heapList; *prev; prev = &(*prev)->next) {
- if (*prev == heap) { // if we find it
- *prev = heap->next; // delink
- SysFree(heap, sizeof * heap); // and free
- heap = NULL;
- break;
- }
- }
-}
-
-// whichHeap: Determines which heap a particular pointer belongs to.
-
-static RHeapPtr whichHeap(void *ptr) {
- RHeapPtr h;
-
- // run through the list of heaps, and figure out which one the pointer is in
-
- for (h = heapList; h; h = h->next) { // for each heap
- // if ptr is within range of addresses
- if ((uint8 *)ptr >= (uint8 *)h->memory
- && (uint8 *)ptr < (uint8 *)h->memory + h->size) {
- return h;
- }
- }
- return NULL;
-}
-
-RHeapPtr getHeapList(void) {
- return heapList;
-}
-
-/* ============================================================================ *
- Low-level memory free routines
- * ============================================================================ */
-
-bool IsCacheable(RMemPrefix *pr) {
- return (pr->flags & rMemPurgeable);
-}
-
-bool IsVMMLocked(RMemPrefix *pr) {
- return (pr->flags & rMemVMMLocked);
-}
-
-bool IsMovable(RMemPrefix *pr) {
- return (bool)(pr->handle && pr->lockNestCount == 0);
-}
-
-// Low-level routine to merge adjacent free blocks
-
-static void MergeBlock(RHeapPtr heap, RMemFreeBlock *blk) {
- //assert(whichHeap(blk)==heap);
- if (blk != (RMemFreeBlock *)&heap->firstFree && blk->next != NULL) {
- // If the end of the block is equal to the beginning of
- // the next block, then merge the blocks into one.
-
- if ((uint8 *)blk + blk->size == (uint8 *)blk->next) {
- blk->size += blk->next->size; // expand 1st block
- blk->next = blk->next->next; // remove 2nd block from list
- }
- }
-}
-
-// Free a block of memory from a particular heap.
-// It returns the "merged" size of the free block, so that the
-// purging algorithm can determine if it has done enough work.
-
-static uint32 FreeBlockHeap(
- uint8 *mem,
- uint32 size,
- RHeapPtr heap) {
- RMemFreeBlock *blk,
- *nblk,
- *prev;
-
-// assert(whichHeap(mem)==heap);
-// assert(whichHeap(mem+size)==heap);
-
- size = QUANTIZE(size); // quantize the size
-
- // We always keep the list of free blocks in order by address;
- // So search through the list and find where to insert the new block
-
- prev = (RMemFreeBlock *)&heap->firstFree;
- for (blk = prev->next; blk; prev = blk, blk = blk->next) {
- if ((uint8 *)blk > mem) { // next free block is after mem
-#if 0
- // This is commented out because, once again, I feel like the code
- // is compacting just for the sake of moving stuff around, rather than
- // any real need for it at this time. My intent is to go with the
- // minimum possible compaction; I will only compact when I need to,
- // and even then only when it will work.
-
- // This does a simplistic compaction of movable blocks.
- // It attempts to put the newly freed memory as high
- // as possible by moving other blocks around.
-
- // No point in doing this, however, if the newly freed
- // block will end up merging with the previous block
-
- if ((uint8 *)prev + prev->size != mem) {
- // For each movable allocation which comes before
- // the next free block, move it down into the
- // newly freed area, and move the free area up in
- // exchange.
-
- while (mem + size < (uint8 *)blk) {
- RMemPrefix *pr = (RMemPrefix *)(mem + size)
-
- if (IsMovable(pr)) {
- RMemPrefix *new_pr = (RMemPrefix *)mem;
- // move block data down
- memcpy(new_pr, pr, pr->size);
- // fix up handle
- new_pr->handle->data = (uint8 *)new_pr + prefixOffset;
- // move free area up
- mem += QUANTIZE(new_pr->size);
- } else break;
- }
- }
-#endif
-
- nblk = (struct RMemFreeBlock *)mem; // make a new free block
- nblk->size = size; // initialize it
- nblk->next = blk;
- prev->next = nblk;
- heap->free += size;
-
- MergeBlock(heap, nblk); // try merge with previous block
- MergeBlock(heap, prev); // try merge with next block
-
- // return the size of this block after merging,
- // unless it got subsumed into the previous block
- // in which case return the size of the previous block.
-
- if (prev->next == nblk) return nblk->size;
- else return prev->size;
- }
- }
-
- nblk = (struct RMemFreeBlock *)mem; // make new free block at heaps end
- nblk->size = size; // initialize it
- nblk->next = NULL;
- prev->next = nblk;
- heap->free += size;
-
- MergeBlock(heap, prev); // try merge with previous block
-
- // return the size of this block after merging,
- // unless it got subsumed into the previous block
- // in which case return the size of the previous block.
-
- if (prev->next == nblk) return nblk->size;
- else return prev->size;
-}
-
-// RDisposePtrHeap: free memory pointer to by the pointer
-
-static void DisposePtrHeap(void *ptr, RHeapPtr heap) {
-#if DEBUG
-#if WIPE_FREE
- uint8 *cptr;
-#endif
- if (whichHeap(ptr) == NULL) {
- error("Cannot dispose pointers in global heap");
- }
- if (heap != whichHeap(ptr)) {
- error("bad heap specified on dispose");
- }
-#endif
- if (ptr) { // if pointer is non-null
- // get memory prefix address
- RMemPrefix *pr = PrefixBaseAddr(ptr);
- // debugging check
-#if DEBUG
- if (pr->size < sizeof * pr + wallSize * 2 ||
- pr->magic != RMEM_MAGIC_ID) {
- if (pr->magic == RMEM_FREED_ID)
- error("Double deletion detected");
- else if (pr->magic == RMEM_LEAK_ID) {
- char tDesc[20];
- strncpy(tDesc, pr->description, 16);
- tDesc[16] = '\0';
- warning("Block '%s' deleted after heap cleanup.", tDesc);
- } else
- error("Invalid Memory Prefix");
- } else {
- pr->magic = RMEM_FREED_ID;
- strncpy(pr->description, "freed", 16);
- }
-#if WIPE_FREE
- cptr = (uint8 *) ptr;
- memset(cptr, RMEM_FREE_WIPE_ID, pr->size - (sizeof * pr + wallSize * 2)); // clear prefix to zero
-#endif
-#endif
-
- //checkWalls( (uint8 *)(pr + 1), pr->size - sizeof *pr );
- FreeBlockHeap((uint8 *)pr, pr->size, heap);
- }
-}
-
-#if DEBUG
-void _RCheckPtr(void *ptr) {
- if (ptr) { // if pointer is non-null
- // get memory prefix address
- RMemPrefix *pr;
- if (whichHeap(ptr) == NULL) {
- error("Cannot check pointers in global heap");
- }
- pr = PrefixBaseAddr(ptr);
- // debugging check
- if (pr->size < sizeof * pr + wallSize * 2 ||
- pr->magic != RMEM_MAGIC_ID) {
- error("Invalid Memory Prefix");
- }
- //checkWalls( (uint8 *)(pr + 1), pr->size - sizeof *pr );
- }
-}
-#else
-void _RCheckPtr(void *) {}
-#endif
-
-/* ============================================================================ *
- Low-level memory allocation
- * ============================================================================ */
-
-// RAllocBlockHeap: Allocates a raw block of memory from the heap,
-// removing it from one of the free blocks.
-
-#ifdef __WATCOMC__
-#pragma off (unreferenced) ;
-#endif
-
-static void *RAllocBlockHeap(RHeapPtr heap, int32 size, bool high, const char desc[]) {
- RMemFreeBlock *blk, *nblk, *prev, *lastBlk = NULL;
- uint32 qSize;
- RMemPrefix *pr;
-#if WIPE_ALLOC
- uint8 *ptr;
-#endif
-
-// assert(heap);
-
- qSize = QUANTIZE(size);
-
- if (qSize > heap->free) return NULL;
-
- prev = (RMemFreeBlock *)&heap->firstFree;
-
- for (blk = prev->next; blk; prev = blk, blk = blk->next) {
- if (blk->size >= qSize) {
- lastBlk = prev;
- if (!high) break;
- }
- }
-
- if (lastBlk == NULL) return NULL;
-
- prev = lastBlk;
- blk = prev->next;
-
- if (blk->size == qSize) {
- prev->next = blk->next;
- pr = (RMemPrefix *)blk;
- } else {
- if (high) {
- blk->size -= qSize;
- pr = (RMemPrefix *)((uint8 *)blk + blk->size);
- } else {
- nblk = (struct RMemFreeBlock *)((char *)blk + qSize);
- nblk->size = blk->size - qSize;
- nblk->next = blk->next;
- prev->next = nblk;
-
- pr = (RMemPrefix *)blk;
- }
- }
-
- memset(pr, 0, sizeof * pr); // clear prefix to zero
-#if DEBUG
- pr->magic = RMEM_MAGIC_ID;
- if (high) {
- strncpy(pr->description, desc, 14);
- pr->description[14] = '\0';
- strcat(pr->description, "->");
- } else {
- strncpy(pr->description, desc, 16);
- }
-#if WIPE_ALLOC
- ptr = (uint8 *)pr + prefixOffset;
- memset(ptr, RMEM_ALLOC_WIPE_ID, size - (sizeof * pr + wallSize * 2)); // clear prefix to zero
-#endif
-#endif
- pr->size = size; // size of the block
- heap->free -= qSize; // subtract size of block
- // return pointer to real data
- return (uint8 *)pr + prefixOffset;
-}
-
-#ifdef __WATCOMC__
-#pragma on (unreferenced) ;
-#endif
-
-/* ============================================================================ *
- Heap Compaction & block Purging
- * ============================================================================ */
-
-// This returns the size of the largest free block
-
-static int32 LargestFree(RHeapPtr heap) {
- RMemFreeBlock *blk;
- int32 largest = 0;
-
- assert(heap);
-
- for (blk = heap->firstFree; blk; blk = blk->next) {
- largest = MAX<uint>(blk->size, largest);
- }
- return largest;
-}
-
-// This returns the size of the largest contiguous free block which
-// could be produced by simplistic compaction (The type of compaction
-// which does not change the ordering of allocated blocks in the heap)
-
-static int32 LargestMerged(RHeapPtr heap) {
- RMemFreeBlock *blk;
- int32 largest = 0;
- uint8 *nextAlloc, // address of next allocation
- *nextFree; // start of next free block
- uint32 freeSize = 0; // amount of coalesced free space
-
-// assert(heap);
-
- nextAlloc = heap->memory;
- nextFree = (uint8 *)(heap->firstFree);
- blk = heap->firstFree;
-
- // compact all blocks which come before the next immovable block.
-
- while (blk) {
- if (nextAlloc < nextFree) { // if alloc is before next free blk
- RMemPrefix *pr = (RMemPrefix *)nextAlloc;
-
- if (!IsMovable(pr)) {
- largest = MAX<uint>(freeSize, largest);
- freeSize = 0;
- }
- nextAlloc += QUANTIZE(pr->size);
- } else {
- freeSize += blk->size; // add to count of free bytes
- // compute addr of next allocation
- nextAlloc = nextFree + blk->size;
- blk = blk->next; // get address of next free block
- nextFree = blk ? (uint8 *)blk : heap->memory + heap->size;
- }
- }
- return largest;
-}
-
-// Attempts to defragment the heap by moving blocks around.
-// Problem with this routine: I feel like the code is moving
-// blocks around just for the sake of moving them around, and
-// not doing anything particularly useful.
-
-static void CompactHeap(RHeapPtr heap, uint32 needed) {
- RMemFreeBlock *prev, *blk, *nblk /* , *sblk */ ;
- uint8 *lastFixed = heap->memory;
-
- prev = (RMemFreeBlock *)&heap->firstFree;
-
- // compact all blocks which come before the next immovable block.
-
- while (prev->next) {
- uint32 freeSize = 0; // amount of coalesced free space
- uint8 *nextAlloc, // address of next allocation
- *putAlloc, // where to copy allocation to
- *nextFree; // start of next free block
-
- blk = prev->next;
- nextAlloc = putAlloc = lastFixed;
- nextFree = (uint8 *)blk;
-
- while (freeSize < needed) {
- if (nextAlloc < nextFree) { // if alloc is before next free blk
- RMemPrefix *pr = (RMemPrefix *)nextAlloc;
-
- if (!IsMovable(pr)) break;
-
- if (putAlloc < nextAlloc) { // if there are holes to fill
- RMemPrefix *new_pr = (RMemPrefix *)putAlloc;
- // move block data down
- memcpy(new_pr, pr, pr->size);
- // fix up handle
- new_pr->handle->data = (uint8 *)new_pr + prefixOffset;
- pr = new_pr;
- }
- // point to next alloc
- nextAlloc += QUANTIZE(pr->size);
- putAlloc += QUANTIZE(pr->size);
- } else {
- if (blk == NULL) break; // if at end of memory, break
-
- freeSize += blk->size; // add to count of free bytes
- // compute addr of next allocation
- nextAlloc = nextFree + blk->size;
- blk = blk->next; // get address of next free block
- prev->next = blk; // repair chain from deleted blocks
- nextFree = blk ? (uint8 *)blk : heap->memory + heap->size;
- }
- }
-
- // At this point, we ran into an immovable block.
- // Now, search for other, later blocks which might
- // fit in the remaining space.
-
- // The variable 'blk' at this point should be
- // pointing to the next free block after the immovable
- // block.
-
-#if 0
- if (blk && freeSize < needed) { // if we're not at the end
- laterAlloc = nextAlloc; // address of a later allocation
- sblk = blk; // address of a later free block
- nextFree = (uint8 *)sblk; // next free space
-
- while (laterAlloc < nextFree // search each block
- && freeSize > 0) { // for something to fill hole with
- int32 qSize;
-
- // We now have the address of a memory prefix.
- pr = (RMemPrefix *)laterAlloc;
- qSize = QUANTIZE(pr->size);
-
-#if DEBUG
- // Check to see if size field is too large or too small
- if (pr->size > next_free - alloc
- || alloc < sizeof * pr + wallSize * 2) {
- error("Invalid Memory prefix");
- }
-
- // Check memory wall integrity
- //checkWalls( alloc + sizeof *pr, pr->size - sizeof *pr );
-#endif
- if (isMovable(pr) && qSize <= freeSize) {
- memcpy(putAlloc, (uint8 *)pr, qSize);
- pr->handle->data = putAlloc + prefixOffset;
- freeSize -= qSize;
- putAlloc += qSize;
-
- // Delete the old block
- FreeBlockHeap(laterAlloc, qSize, heap);
- }
-
- // Go to the next block
- laterAlloc += qSize;
- }
- }
-#endif
-
- // Build a free block just before the immovable block.
-
- if (freeSize > 0) {
- nblk = (RMemFreeBlock *)putAlloc;
- nblk->next = blk;
- nblk->size = freeSize;
-
- prev->next = nblk;
- prev = nblk;
-
- if (freeSize >= needed) return;
- }
-
- if (blk) {
- RMemPrefix *pr = (RMemPrefix *)nextAlloc;
-
- lastFixed = nextAlloc + QUANTIZE(pr->size);
- }
- }
-}
-
-static bool PurgeBlocks(RHeapPtr heap, uint32 needed) {
- int32 freedUp = heap->free;
- RHandle *rh, *prevHandle;
-
- for (rh = heap->cacheTail;
- rh && rh != (RHandle *)&heap->cacheHead;
- rh = prevHandle
- ) {
- RMemPrefix *pr = PrefixBaseAddr(rh->data);
-
- prevHandle = rh->prev;
-
- freedUp += QUANTIZE(pr->size);
-
- RDisposePtr(rh->data); // Free the block
- rh->data = NULL; // NULL the handle.
- RDelinkHandle(rh); // delink from chain.
-
- if (freedUp > needed) return true;
- }
- return false;
-}
-
-// This function attempts to get free up enough space for a new
-// allocation.
-
-static void GetSpace(RHeapPtr heap, uint32 needed) {
- for (;;) {
- // First, try a simple compaction. If it works, then return;
-
- if (LargestMerged(heap) >= needed) {
- CompactHeap(heap, needed);
- return;
- }
- // We need more space!
-
- // REM: try more sophisticated compaction
-
- // check to see if it worked directly, otherwise try another
- // simple compaction.
-
- if (LargestMerged(heap) >= needed) {
- CompactHeap(heap, needed);
- return;
- }
-
- // See if there are any blocks in the cache. If not, return
- // (we failed).
-
- if (heap->cacheTail == (RHandle *)&heap->cacheHead)
- return;
-
- // Try deleting some blocks from the cache
-
- PurgeBlocks(heap, needed);
-
- // See if we got what we wanted without compaction.
-
- if (LargestFree(heap) >= needed) return;
-
- // Otherwise, go through the loop again and compact.
- }
-}
-
-/* ============================================================================ *
- Higher-level Allocate and Free routines
- * ============================================================================ */
-
-// RNewPtr: Allocates a new pointer. Also sets the "wall" magic cookie
-// around the allocation.
-
-// Rem: Instead of a heap pointer, how about a memory type, which
-// can include things like "zeroed"
-
-static void *NewPtr(int32 size, RHeapPtr heap, bool high, const char desc[]) {
- uint8 *mem;
- bool triedCompact = false;
- int tries;
-
- if (heap == NULL) heap = heapList;
-
- size += wallSize * 2 + sizeof(RMemPrefix);
-
- for (tries = 0; tries < 2; tries++) {
- if ((mem = (uint8 *) RAllocBlockHeap(heap, size, high, desc)) != NULL) {
- setWalls(mem - wallSize, size - sizeof(RMemPrefix));
- return mem;
- }
- if (triedCompact) return NULL;
-
- GetSpace(heap, size);
- triedCompact = true;
- }
- return NULL;
-}
-
-void *_RNewPtr(int32 size, RHeapPtr heap, const char desc[]) {
-#if RMEM_VISIBLE
- void *ptr = NewPtr(size, heap, true, desc);
- SHOWMEM;
- return ptr;
-#else
- return NewPtr(size, heap, true, desc);
-#endif
-}
-
-void *_RNewClearPtr(int32 size, RHeapPtr heap, const char desc[]) {
- uint8 *mem;
-
- if ((mem = (uint8 *) NewPtr(size, heap, true, desc)) != NULL)
- memset(mem, 0, size);
-
- SHOWMEM;
- return mem;
-}
-
-// RDisposePtr: free memory pointer to by the pointer
-void VMM_Lock_Mem(void *ptr, size_t size);
-void VMM_Unlock_Mem(void *ptr, size_t size);
-
-
-void _RVMMLockPtr(void *ptr) {
- if (ptr) {
- RMemPrefix *pr = PrefixBaseAddr(ptr);
- VMM_Lock_Mem(ptr, _RPtrSize(ptr));
- pr->flags |= rMemVMMLocked;
- }
-}
-
-void _RVMMUnlockPtr(void *ptr) {
- if (ptr) {
- RMemPrefix *pr = PrefixBaseAddr(ptr);
- VMM_Unlock_Mem(ptr, _RPtrSize(ptr));
- pr->flags &= ~rMemVMMLocked;
- }
-}
-
-bool _RPtrVMMLocked(void *ptr) {
- if (ptr) {
- RMemPrefix *pr = PrefixBaseAddr(ptr);
- return (pr->flags & rMemVMMLocked);
- }
- return 0;
-}
-
-void _RDisposePtr(void *ptr) {
- RHeapPtr heap;
-
- if (ptr // if pointer is non-null
- && (heap = whichHeap(ptr)) != NULL) { // and in a heap
- if (_RPtrVMMLocked(ptr)) {
- _RVMMUnlockPtr(ptr);
- }
- DisposePtrHeap(ptr, heap); // then free from heap
- }
- SHOWMEM;
-}
-
-/* ============================================================================ *
- Handle blocks
- * ============================================================================ */
-
-void _RLinkHandle(RHandle *r, RHandle *prev) {
- r->next = prev->next; // link handle into chain
- r->prev = prev;
- if (r->next) r->next->prev = r;
- prev->next = r;
-}
-
-void _RDelinkHandle(RHandle *r) {
- if (r->prev) r->prev->next = r->next; // unlink the handle from it's chain
- if (r->next) r->next->prev = r->prev;
-
- // link the handle to itself, so that multiple calls to RDelinkHandle
- // will not crash.
-
- r->next = r->prev = r;
-}
-
-// Create a new block of handles
-
-static RHandleBlock *NewHandleBlock(RHeapPtr heap, const char desc[]) {
- RHandleBlock *hBlock, *prevBlock;
- int i;
- // allocate space for handle block
- if ((hBlock = (RHandleBlock *) NewPtr(sizeof * hBlock, heap, true, desc)) != NULL) {
- SHOWMEM;
- memset(hBlock, 0, sizeof * hBlock);
-
- // Search through the list of handle blocks until we find
- // one that points to a block after the address of the
- // newly allocated block, or we find one that points to
- // the end of the list. This should result in the HandleBlocks
- // being placed on the list in address order;
-
- // The purpose of this is to bias the use of the handle blocks
- // so that only blocks near the beginning of memory will be
- // full most of the time, and blocks in other areas will
- // tend to be freed. We want handle blocks to concentrate
- // near the beginning of their memory blocks.
-
- for (prevBlock = (RHandleBlock *)&heap->handleBlocks;
- prevBlock->next && prevBlock->next < hBlock;
- prevBlock = prevBlock->next)
- ;
-
- // Link the handle block into the chain of blocks
-
- RLinkHandle((RHandle *)hBlock, (RHandle *)prevBlock);
-
- hBlock->freeHandleCount = HANDLES_PER_BLOCK;
-// hBlock->freeHandles = NULL;
-
- // Initialize each of the handles in the block.
-
- for (i = 0; i < HANDLES_PER_BLOCK; i++) { // link each handle into chain
- RHandle *rh = &hBlock->handles[i];
-
-// rh->data = NULL;
- RLinkHandle(rh, (RHandle *)&hBlock->freeHandles);
- }
- }
- return hBlock;
-}
-
-// Find an unused handle so that we can use it.
-
-static RHandle *FindFreeHandle(RHeapPtr heap) {
- RHandleBlock *hBlock;
- RHandle *handle;
-
- // Search for a handle in an existing block that's already free
-
- for (hBlock = heap->handleBlocks; hBlock; hBlock = hBlock->next) {
- if ((handle = hBlock->freeHandles) != NULL) {
- RDelinkHandle(handle);
- hBlock->freeHandleCount--;
- return handle;
- }
- }
-
- // instead we need to create a new block.
- // assume for now we'll create it on the same heap.
-
- if ((hBlock = NewHandleBlock(heap, "internal")) != NULL) {
- if ((handle = hBlock->freeHandles) != NULL) {
- RDelinkHandle(handle);
- hBlock->freeHandleCount--;
- return handle;
- }
- }
-
- return NULL;
-}
-
-static void FreeHandleBlock(RHeap *heap, RHandleBlock *hBlock) {
- if (hBlock && heap) { // if pointer is non-null
- // We want to encourage handle blocks to be allocated near
- // the beginning of the memory buffer. One way to do this is
- // to never free any handles near the beginning of the buffer.
-
- if ((uint8 *)hBlock >= (uint8 *)heap + (heap->size >> 3)) {
- // unlink from heap list
- RDelinkHandle((RHandle *)hBlock);
- DisposePtrHeap(hBlock, heap); // then free from heap
- }
- }
-}
-
-static void FreeHandle(RHeap *heap, RHandle *handle) {
- RHandleBlock *hBlock;
-
- // Search for a handle in an existing block that's already free
-
- for (hBlock = heap->handleBlocks; hBlock; hBlock = hBlock->next) {
- if (handle >= &hBlock->handles[0]
- && handle < &hBlock->handles[HANDLES_PER_BLOCK]) {
- RDelinkHandle(handle);
-
- handle->data = NULL;
- RLinkHandle(handle, (RHandle *)&hBlock->freeHandles);
-
- // If all the handles in this block are free, then consider
- // perhaps freeing the block
-
- if (++hBlock->freeHandleCount >= HANDLES_PER_BLOCK)
- FreeHandleBlock(heap, hBlock);
-
- return;
- }
- }
-}
-
-/* ============================================================================ *
- Higher-level handle allocate and deallocate.
- * ============================================================================ */
-
-// Allocate a block of memory and return a handle to it.
-
-RHANDLE _RNewHandle(int32 size, RHeapPtr heap, const char desc[]) {
- void *mem;
- RHandle *handle;
- RMemPrefix *pr;
-
- if (heap == NULL) heap = heapList;
-
- if ((handle = FindFreeHandle(heap)) != NULL) {
- if ((mem = NewPtr(size, heap, false, desc)) != NULL) {
- pr = PrefixBaseAddr(mem); // get memory prefix
- pr->handle = handle; // point prefix back to handle
- handle->data = mem; // point handle to prefix
-
- SHOWMEM;
- return &handle->data;
- }
- FreeHandle(heap, handle); // Free the handle
- }
- return NULL;
-}
-
-// Allocate a block of memory, clear it, and return a handle to it.
-
-RHANDLE _RNewClearHandle(int32 size, RHeapPtr heap, const char desc[]) {
- RHANDLE handle;
-
- if (heap == NULL) heap = heapList;
-
- if (handle = RNewHandle(size, heap, desc))
- memset(*handle, 0, size);
-
- SHOWMEM;
- return handle;
-}
-
-void _RDisposeHandle(RHANDLE handle) {
- RHandle *hb = HandleBaseAddr(handle);
- RMemPrefix *pr;
- RHeapPtr heap;
-
- if (handle && hb->data) {
- if ((heap = whichHeap(hb)) == NULL) {
- // REM: Error!
- return;
- }
-
- pr = PrefixBaseAddr(hb->data);
- RDisposePtr(hb->data); // Free the block
- FreeHandle(heap, hb); // Free the handle
- }
- SHOWMEM;
-}
-
-/* ============================================================================ *
- Functions to allocate data associated with handle without changing
- the handle.
- * ============================================================================ */
-
-void _RDisposeHandleData(RHANDLE handle) {
- RHandle *hb = HandleBaseAddr(handle);
- RHeapPtr heap;
- RMemPrefix *pr;
-
- if (handle && hb->data) {
- if ((heap = whichHeap(hb)) == NULL) {
- // REM: Error!
- return;
- }
-
- pr = PrefixBaseAddr(hb->data);
- RDisposePtr(hb->data); // Free the block
- hb->data = NULL;
- }
- SHOWMEM;
-}
-
-void *_RAllocHandleData(RHANDLE handle, int32 size, const char desc[]) {
- RHandle *hb = HandleBaseAddr(handle);
- void *mem;
- RMemPrefix *pr;
- RHeapPtr heap;
-
- if ((heap = whichHeap(hb)) == NULL) {
- // REM: Error!
- return NULL;
- }
-
- if (hb->data != NULL) RDisposeHandleData(handle);
-
- if ((mem = NewPtr(size, heap, false, desc)) != NULL) {
- pr = PrefixBaseAddr(mem); // get memory prefix
- pr->handle = hb; // point prefix back to handle
- hb->data = mem; // point handle to prefix
-
- SHOWMEM;
- return mem;
- }
- return NULL;
-}
-
-/* ============================================================================ *
- Functions to get handle attributes
- * ============================================================================ */
-
-uint32 _RPtrSize(void *ptr) {
- if (ptr) {
- RMemPrefix *pr = PrefixBaseAddr(ptr);
- return pr->size - sizeof * pr - wallSize * 2;
- }
- return 0;
-}
-
-uint16 _RGetHandleFlags(RHANDLE handle) {
- RHandle *hb = HandleBaseAddr(handle);
- RMemPrefix *pr;
-
- if (hb->data) {
- pr = PrefixBaseAddr(hb->data);
- return (uint16)pr->flags;
- }
- return (uint16)0;
-}
-
-/* ============================================================================ *
- Set block as cacheable
- * ============================================================================ */
-
-void _RCacheHandle(RHANDLE handle) {
- RHandle *hb = HandleBaseAddr(handle);
- RMemPrefix *pr;
- RHeapPtr heap;
-
- if (handle && hb->data) { // if handle exists
- pr = PrefixBaseAddr(hb->data); // get address of data
-
- if (!(pr->flags & rMemPurgeable)) { // if not already purgeable
- // determine which heap
- if ((heap = whichHeap(hb)) == NULL) return;
-
- pr->flags |= rMemPurgeable; // mark as purgeable
-
- if (pr->lockNestCount == 0) { // if unlocked, then...
- RDelinkHandle(hb);
- RLinkHandle(hb, (RHandle *)&heap->cacheHead);
- }
- }
- }
-}
-
-/* ============================================================================ *
- Functions to manipulate handle attributes
- * ============================================================================ */
-
-// RLockHandle: Prevents memory handle from being relocated.
-
-void *_RLockHandle(RHANDLE handle) {
- RHandle *hb = HandleBaseAddr(handle);
- RMemPrefix *pr;
-
- if (handle && hb->data) {
- pr = PrefixBaseAddr(hb->data);
-
- if (pr->lockNestCount == 0 // if not locked
- && (pr->flags & rMemPurgeable)) { // and purgeable
- RDelinkHandle(hb); // remove from cache list
- }
-
- pr->lockNestCount++;
- }
- return hb->data;
-}
-
-// RUnlockHandle: Enabled handle relocation (and caching if
-// the handle is cacheable.
-
-void _RUnlockHandle(RHANDLE handle) {
- RHandle *hb = HandleBaseAddr(handle);
- RMemPrefix *pr;
-
- if (handle && hb->data) {
- if (whichHeap(hb->data) == NULL)
- error("Handle has invalid data pointer");
- pr = PrefixBaseAddr(hb->data);
- pr->lockNestCount--;
-
- if (pr->lockNestCount == 0 // if not locked
- && (pr->flags & rMemPurgeable)) { // and purgeable
- RHeapPtr heap;
-
- if ((heap = whichHeap(hb)) != NULL) {
- RDelinkHandle(hb);
- RLinkHandle(hb, (RHandle *)&heap->cacheHead);
- }
- }
- //checkWalls( (uint8 *)(pr + 1), pr->size - sizeof *pr );
- }
-}
-
-/*
-void RSetHandleFlags( RHANDLE handle, uint16 newflags )
-{
- RHandle *hb = HandleBaseAddr( handle );
- RMemPrefix *pr;
-
- if (hb->data)
- {
- pr = PrefixBaseAddr(hb->data);
- pr->flags = (pr->flags & ~rMemUserFlags) | (newflags & rMemUserFlags);
- }
-}
-*/
-
-/* ============================================================================ *
- Deferred Loading functions
- * ============================================================================ */
-
-void _RHandleStartLoading(RHANDLE handle) {
- RMemPrefix *pr;
- RHandle *hb = HandleBaseAddr(handle);
-
- if (handle == NULL || hb->data == NULL) return;
- pr = PrefixBaseAddr(hb->data);
- pr->flags |= rMemLoading;
-}
-
-void _RHandleDoneLoading(RHANDLE handle) {
- RMemPrefix *pr;
- RHandle *hb = HandleBaseAddr(handle);
-
- if (handle == NULL || hb->data == NULL) return;
- pr = PrefixBaseAddr(hb->data);
- pr->flags &= ~rMemLoading;
-}
-
-bool _RHandleLoaded(RHANDLE handle) {
- RMemPrefix *pr;
- RHandle *hb = HandleBaseAddr(handle);
-
- if (handle == NULL || hb->data == NULL) return false;
- pr = PrefixBaseAddr(hb->data);
- return (pr->flags & rMemLoading) ? 0 : 1;
-}
-
-bool _RHandleLoading(RHANDLE handle) {
- RMemPrefix *pr;
- RHandle *hb = HandleBaseAddr(handle);
-
- if (handle == NULL || hb->data == NULL) return false;
- pr = PrefixBaseAddr(hb->data);
- return (pr->flags & rMemLoading) ? 1 : 0;
-}
-
-/* ============================================================================ *
- Debugging functions
- * ============================================================================ */
-
-#if DEBUG
-
-// Rem: We should also do a stack backtrace here...?
-
-// This function is called whenever a wall corruption is detected.
-// Probably should be set as a breakpoint in the debugger.
-void wallHit(void) {
- error("Wall Hit");
-}
-
-// Checks to see if the memory cookie is still in place around each allocation.
-void checkWalls(uint8 *begin, uint32 length) {
- uint8 *end = begin + length;
- int16 i;
-
- RHeapPtr heap = whichHeap(begin); // pointer to new heap
-
- if (heap == NULL) {
- error("invalid wall size");
- }
- if (length > heap->size) {
- error("invalid wall size");
- }
- if (whichHeap(end - 1) != heap) {
- error("invalid wall size");
- }
- for (i = 0; i < wallSize; i++) {
- --end;
- if (*begin != RMEM_WALL_ID || *end != RMEM_WALL_ID) {
- wallHit();
- *begin = *end = RMEM_WALL_ID;
- return;
- }
- begin++;
- }
-}
-
-// Sets the memory cookie surrounding each allocation.
-void setWalls(uint8 *begin, uint32 length) {
- RHeapPtr heap = whichHeap(begin); // pointer to new heap
- uint8 *end = begin + length;
- int i;
-
- if (heap == NULL || length > heap->size || whichHeap(end - 1) != heap) {
- error("invalid wallocation");
- }
- for (i = 0; i < wallSize; i++) {
- *begin++ = RMEM_WALL_ID;
- *--end = RMEM_WALL_ID;
- }
-}
-
-#endif
-
-void heapCheck(void) {
- if (heapList->firstFree
- && (uint8 *)heapList->firstFree < (uint8 *)heapList->memory) {
- error("HeapFailed: %d %d\n", heapList->size, heapList->free);
- }
-}
-
-// Check the integtrity of all memory
-
-bool _RMemIntegrity(void) {
- RHeapPtr heap;
- RMemPrefix *pr;
- RMemFreeBlock *blk;
- int16 heapNum;
-
- // run through the list of heaps, and figure out which one the pointer is in
-
- for (heap = heapList, heapNum = 0; heap; heap = heap->next, heapNum++) {
- uint8 *last_free,
- *next_free,
- *alloc;
-
- last_free = heap->memory;
-
- blk = heap->firstFree;
-
- heapCheck();
-
-
- for (;;) {
- next_free = blk ? (uint8 *)blk : heap->memory + heap->size;
-
- alloc = last_free;
- while (alloc < next_free) {
- uint32 bytesToNext = (next_free - alloc);
-
- // We now have the address of a memory prefix.
- pr = (RMemPrefix *)alloc;
-
- // Check to see if size field is too large or too small
- if (pr->size > bytesToNext
- || pr->size < sizeof * pr + wallSize * 2) {
-
- error("Bad prefix size %d : %s", pr->size,
-#if DEBUG
- pr->description
-#else
- ""
-#endif
- );
- return false;
- }
-
- // Check memory wall integrity
- checkWalls(alloc + sizeof * pr, pr->size - sizeof * pr);
-
- // Go to the next block
- alloc += QUANTIZE(pr->size);
- }
-
- if (blk == NULL) break;
- last_free = (uint8 *)blk + blk->size;
- blk = blk->next;
- }
- }
- return true;
-}
-
-
-// Check the integtrity of all memory
-
-#if DEBUG
-
-static uint32 leakWarnings = 0;
-const uint32 maxLeakWarnings = 32;
-
-static bool _RMemCleanHeap(RHeapPtr heap) {
- RMemPrefix *pr;
- RMemFreeBlock *blk;
- char *desc;
- uint8 *base = heap->memory,
- *last_free = base,
- *next_free,
- *alloc;
-
- next_free = heap->memory;
- alloc = last_free;
-
- for (blk = heap->firstFree;; blk = blk->next) {
- next_free = blk ? (uint8 *)blk : (uint8 *)heap->memory + heap->size;
-
- alloc = last_free;
- while (alloc < next_free) {
- // We now have the address of a memory prefix.
- pr = (RMemPrefix *)alloc;
-
- desc = pr->description;
- if (pr->magic == RMEM_MAGIC_ID) {
- char tDesc[20];
- strncpy(tDesc, pr->description, 16);
- tDesc[16] = '\0';
- memoryWarning("Warning: possible memory leak; block named '%s' was in the deleted heap.\n", tDesc);
- pr->magic = RMEM_LEAK_ID;
- } else {
- leakWarnings++;
- if (leakWarnings < maxLeakWarnings)
- memoryWarning("Warning: unknown memory arena ID %d in disposed heap.\n", pr->magic);
- else if (leakWarnings == maxLeakWarnings)
- memoryWarning("Warning: too many memory leak warnings. Remaining warnings ignored\n");
- else
- return true;
-
- }
- // Go to the next block
- alloc += QUANTIZE(pr->size);
- }
-
- if (blk == NULL) break;
-
- last_free = (uint8 *)blk + blk->size;
-
- }
- return true;
-}
-#endif
-
-
-void RShowMem(void) {
-#if DEBUG
- RDumpMem(heapList, wallSize);
-#endif
-}
-
-
-#define COMPACTER_RESOLUTION 1000000
-
-void RHeapsAMess(void) {
- RHeapPtr heap = heapList;
- if (heap) {
- int32 compactSize = heap->size / 2;
- for (int32 i = compactSize; i > 0; i -= COMPACTER_RESOLUTION)
- CompactHeap(heap, i);
- }
-}
-
-} // end of namespace Saga2
diff --git a/engines/saga2/rmem.h b/engines/saga2/rmem.h
deleted file mode 100644
index 359c0fb327..0000000000
--- a/engines/saga2/rmem.h
+++ /dev/null
@@ -1,322 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * aint32 with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#ifndef SAGA2_RMEM_H
-#define SAGA2_RMEM_H
-
-namespace Saga2 {
-
-// memory block magic ID's
-#define RMEM_MAGIC_ID ('E' + 'O'*256)
-#define RMEM_FREED_ID ('O' + 'E'*256)
-#define RMEM_LEAK_ID ('O' + 'O'*256)
-#define RMEM_WALL_ID 0xAE
-
-// Wiping allocated blocks
-#define RMEM_WIPE_ALLOC 1
-#define RMEM_ALLOC_WIPE_ID 0x90
-
-// Wiping freed blocks
-#define RMEM_WIPE_FREE 1
-#define RMEM_FREE_WIPE_ID 0xCD
-
-// Set this to 1 to display the memory blocks on the screen...
-#define RMEM_VISIBLE 0
-
-// Wall Size
-#define RMEM_WALL_SIZE 8 // memory wall size around allocs
-#define RMEM_MUNG_ENABLE 1 // enable munging of free blocks
-
-// enables the automatic setting to NULL of freed RPtrs
-#define RMEM_AUTO_NULL 1
-
-// allows the global new and delete to be redirected into the heap
-#define RMEM_TRAP_NEW_DELETE 1
-// enables malloc and free macros
-#define RMEM_TRAP_MALLOC_FREE 1
-
-// enable warnings about things that aren't cleaned up
-#define RMEM_WARN_LEAKS 1
-
-
-/* ===================================================================== *
- Common Memory Allocation Types
- Based on std.h types.
- * ====================================================================== */
-
-typedef int8 *BytePtr,
- * *ByteHandle;
-
-typedef uint8 *UBytePtr,
- * *UByteHandle;
-
-typedef int16 *WordPtr,
- * *WordHandle;
-
-typedef uint16 *UWordPtr,
- * *UWordHandle;
-
-typedef int32 *LongPtr,
- * *LongHandle;
-
-typedef uint32 *ULongPtr,
- * *ULongHandle;
-
-typedef bool *BoolPtr,
- * *BoolHandle;
-
-typedef void **RHANDLE;
-
-/* ===================================================================== *
- Some other types
- * ====================================================================== */
-
-typedef struct _RHeap RHeap,
- *RHeapPtr;
-
-typedef struct _RHandle RHandle;
-
-/* ===================================================================== *
- Basic functions
- * ===================================================================== */
-
-// Allocate and deallocate a heap
-RHeapPtr _RNewHeap(uint8 *memory, int32 size);
-void _RDisposeHeap(RHeapPtr heap);
-
-// Allocate and Deallocate a block of non-relocatable memory
-void *_RNewPtr(int32 size, RHeapPtr heap, const char []);
-void *_RNewClearPtr(int32 size, RHeapPtr heap, const char []);
-void _RVMMLockPtr(void *ptr);
-void _RVMMUnlockPtr(void *ptr);
-void _RDisposePtr(void *ptr);
-
-// Allcate and Deallocate a block of relocatable memory
-RHANDLE _RNewHandle(int32 size, RHeapPtr heap, const char []);
-RHANDLE _RNewClearHandle(int32 size, RHeapPtr heap, const char []);
-void _RDisposeHandle(RHANDLE handle);
-
-// Allocate and Deallocate a data associated with handle
-void *_RAllocHandleData(RHANDLE handle, int32 size, const char []);
-void _RDisposeHandleData(RHANDLE handle);
-
-// Lock a handle (prevent from moving)
-void *_RLockHandle(RHANDLE handle);
-void _RUnlockHandle(RHANDLE handle);
-
-// Get and Set the attributes of a handle
-//void RSetHandleFlags( void *handle, uint16 newflags );
-uint16 _RGetHandleFlags(RHANDLE handle);
-
-// Set this handle as cacheable
-void _RCacheHandle(RHANDLE handle);
-
-// Functions to mark a handle as "loading"
-void _RHandleStartLoading(RHANDLE handle);
-void _RHandleDoneLoading(RHANDLE handle);
-
-// Return true if loaded data is valid
-bool _RHandleLoaded(RHANDLE handle);
-
-// Return true if loaded data will be valid soon.
-bool _RHandleLoading(RHANDLE handle);
-
-void RShowMem(void);
-RHeapPtr whichHeapPublic(void *ptr);
-RHeapPtr getHeap(void);
-
-/* ===================================================================== *
- Advanced Functions (do not use in portable applications!)
- * ===================================================================== */
-
-// Link a handle into a chain of handles
-void _RLinkHandle(RHandle *r, RHandle *prev);
-void _RDelinkHandle(RHandle *r);
-
-// Get the size of the allocated block
-uint32 _RPtrSize(void *ptr);
-
-// Get the size of the allocated block
-bool _RPtrVMMLocked(void *ptr);
-
-// Test memory heap integrity
-bool _RMemIntegrity(void);
-
-void heapCheck(void);
-void _RCheckPtr(void *ptr);
-
-
-/* ===================================================================== *
- Include logging routines
- * ===================================================================== */
-
-//
-// Would the VMM be more effective if major memory
-// reorganizations were triggered by the application?
-// This would allow complete cleanups to be done
-// at times when the system was least stressed
-
-//
-// The logging of memory actions is done in a
-// rather brute force manner. The original routines
-// have been renamed. Macros have been defined
-// to redirect those calls. If logging is not in use
-// the original calls will be run. When logging is
-// enabled routines are called which do the dumping.
-//
-
-//
-// Using these routines:
-// To start logging memory manager calls use:
-// startLogging();
-// To pause/stop logging use:
-// stopLogging();
-// To resume a paused log use:
-// continueLogging();
-//
-
-//
-// Logging options
-//
-// Routines Logged
-// All the RMEM.C routines which are public can
-// be logged.
-//
-// Log Elements
-// Module dump : shows what call is being made and
-// where in the source code it was called from
-// In : The values of the parameters on entry to
-// the routine
-// Out : The values of the parameters when returning
-// from the routine
-// Return : shows the value returned by the routine
-//
-//
-
-#if DEBUG
-
-
-// Log file initialization / termination
-
-void initRMemLogging(void);
-void startLog(char *filename);
-void startLogging(void);
-void continueLogging(void);
-void stopLogging(void);
-
-//
-// These are the logging versions
-//
-
-RHeapPtr logRNewHeap(uint8 *m, int32 s, const int l, const char f[]);
-void logRDisposeHeap(RHeapPtr h, const int l, const char f[]);
-void *logRNewPtr(int32 s, RHeapPtr h, const char desc[], const int l, const char f[]);
-void *logRNewClearPtr(int32 s, RHeapPtr h, const char desc[], const int l, const char f[]);
-void *logRDisposePtr(void *p, const int l, const char f[]);
-RHANDLE logRNewHandle(int32 s, RHeapPtr h, const char desc[], const int l, const char f[]);
-RHANDLE logRNewClearHandle(int32 s, RHeapPtr h, const char desc[], const int l, const char f[]);
-void logRDisposeHandle(RHANDLE h, const int l, const char f[]);
-void *logRAllocHandleData(RHANDLE h, int32 s, const char desc[], const int l, const char f[]);
-void logRDisposeHandleData(RHANDLE h, const int l, const char f[]);
-void *logRLockHandle(RHANDLE h, const int l, const char f[]);
-void logRUnlockHandle(RHANDLE h, const int l, const char f[]);
-uint16 logRGetHandleFlags(RHANDLE h, const int l, const char f[]);
-void logRCacheHandle(RHANDLE h, const int l, const char f[]);
-void logRHandleStartLoading(RHANDLE h, const int l, const char f[]);
-void logRHandleDoneLoading(RHANDLE h, const int l, const char f[]);
-bool logRHandleLoaded(RHANDLE h, const int l, const char f[]);
-bool logRHandleLoading(RHANDLE h, const int l, const char f[]);
-void logRLinkHandle(RHandle *r, RHandle *p, const int l, const char f[]);
-void logRDelinkHandle(RHandle *r, const int l, const char f[]);
-uint32 logRPtrSize(void *p, const int l, const char f[]);
-bool logRMemIntegrity(const int l, const char f[]);
-
-//
-// These are the remapped memory management routines
-//
-
-#define RNewHeap(m,s) (logRNewHeap(m,s,__LINE__,__FILE__))
-#define RDisposeHeap(h) (logRDisposeHeap(h,__LINE__,__FILE__))
-#define RNewPtr(s,h,d) (logRNewPtr(s,h,d,__LINE__,__FILE__))
-#define RNewClearPtr(s,h,d) (logRNewClearPtr(s,h,d,__LINE__,__FILE__))
-#if RMEM_AUTO_NULL
-#define RDisposePtr(p) (logRDisposePtr(p,__LINE__,__FILE__),p=NULL)
-#else
-#define RDisposePtr(p) (logRDisposePtr(p,__LINE__,__FILE__))
-#endif
-#define RNewHandle(s,h,d) (logRNewHandle(s,h,d,__LINE__,__FILE__))
-#define RNewClearHandle(s,h,d) (logRNewClearHandle(s,h,d,__LINE__,__FILE__))
-#define RDisposeHandle(h) (logRDisposeHandle(h,__LINE__,__FILE__))
-#define RAllocHandleData(h,s,d) (logRAllocHandleData(h,s,d,__LINE__,__FILE__))
-#define RDisposeHandleData(h) (logRDisposeHandleData(h,__LINE__,__FILE__))
-#define RLockHandle(h) (logRLockHandle(h,__LINE__,__FILE__))
-#define RUnlockHandle(h) (logRUnlockHandle(h,__LINE__,__FILE__))
-#define RGetHandleFlags(h) (logRGetHandleFlags(h,__LINE__,__FILE__))
-#define RCacheHandle(h) (logRCacheHandle(h,__LINE__,__FILE__))
-#define RHandleStartLoading(h) (logRHandleStartLoading(h,__LINE__,__FILE__))
-#define RHandleDoneLoading(h) (logRHandleDoneLoading(h,__LINE__,__FILE__))
-#define RHandleLoaded(h) (logRHandleLoaded(h,__LINE__,__FILE__))
-#define RHandleLoading(h) (logRHandleLoading(h,__LINE__,__FILE__))
-#define RLinkHandle(r,p) (logRLinkHandle(r,p,__LINE__,__FILE__))
-#define RDelinkHandle(r) (logRDelinkHandle(r,__LINE__,__FILE__))
-#define RPtrSize(p) (logRPtrSize(p,__LINE__,__FILE__))
-#define RMemIntegrity() (logRMemIntegrity(__LINE__,__FILE__))
-
-#else // DEBUG
-
-#define RNewHeap(m,s) (_RNewHeap(m,s))
-#define RDisposeHeap(h) (_RDisposeHeap(h))
-#define RNewPtr(s,h,d) (_RNewPtr(s,h,d))
-#define RNewClearPtr(s,h,d) (_RNewClearPtr(s,h,d))
-#if RMEM_AUTO_NULL
-typedef void *pVOID;
-#define RDisposePtr(p) (_RDisposePtr(p),p=NULL)
-#else
-#define RDisposePtr(p) (_RDisposePtr(p))
-#endif
-#define RNewHandle(s,h,d) (_RNewHandle(s,h,d))
-#define RNewClearHandle(s,h,d) (_RNewClearHandle(s,h,d))
-#define RDisposeHandle(h) (_RDisposeHandle(h))
-#define RAllocHandleData(h,s,d) (_RAllocHandleData(h,s,d))
-#define RDisposeHandleData(h) (_RDisposeHandleData(h))
-#define RLockHandle(h) (_RLockHandle(h))
-#define RUnlockHandle(h) (_RUnlockHandle(h))
-#define RGetHandleFlags(h) (_RGetHandleFlags(h))
-#define RCacheHandle(h) (_RCacheHandle(h))
-#define RHandleStartLoading(h) (_RHandleStartLoading(h))
-#define RHandleDoneLoading(h) (_RHandleDoneLoading(h))
-#define RHandleLoaded(h) (_RHandleLoaded(h))
-#define RHandleLoading(h) (_RHandleLoading(h))
-#define RLinkHandle(r,p) (_RLinkHandle(r,p))
-#define RDelinkHandle(r) (_RDelinkHandle(r))
-#define RPtrSize(p) (_RPtrSize(p))
-#define RMemIntegrity (_RMemIntegrity)
-
-#endif // if/else DEBUG
-
-} // end of namespace Saga2
-
-#endif
diff --git a/engines/saga2/rmembase.h b/engines/saga2/rmembase.h
deleted file mode 100644
index 3440140f5d..0000000000
--- a/engines/saga2/rmembase.h
+++ /dev/null
@@ -1,183 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * aint32 with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#ifndef SAGA2_RMEMBASE_H
-#define SAGA2_RMEMBASE_H
-
-namespace Saga2 {
-
-/* ===================================================================== *
- Optional memory manager debugging settings
- Note that none of these has any effect if DEBUG is not 1
- * ====================================================================== */
-
-// memory block magic ID's
-#define RMEM_MAGIC_ID ('E' + 'O'*256)
-#define RMEM_FREED_ID ('O' + 'E'*256)
-
-// Wiping allocated blocks
-#define RMEM_WIPE_ALLOC 1
-#define RMEM_ALLOC_WIPE_ID 0x90
-
-// Wiping freed blocks
-#define RMEM_WIPE_FREE 1
-#define RMEM_FREE_WIPE_ID 0xCD
-
-// Set this to 1 to display the memory blocks on the screen...
-// (You will need to supply the display code)
-#define RMEM_VISIBLE 0
-
-#define RMEM_WALL_SIZE 8 // memory wall size around allocs
-#define RMEM_MUNG_ENABLE 1 // enable munging of free blocks
-
-
-/* ===================================================================== *
- types
- * ====================================================================== */
-
-#ifndef __cplusplus
-typedef struct RMemPrefix RMemPrefix;
-typedef struct RHandleBlock RHandleBlock;
-typedef struct RMemFreeBlock RMemFreeBlock;
-typedef struct RMemHeader RMemHeader;
-#endif
-
-// Flags which apply to a memory block prefix
-enum memPrefixFlags {
- rMemRelocatable = (1 << 0), // block is of relocatable type
- rMemPurgeable = (1 << 1), // block is purgeable
-
- // settable by appliprog
-// rMemUserFlags = (rMemPurgeable | rMemCacheable)
-
- // A flag which indicates that the block is not
- // yet ready for use (mark as "loading");
- rMemLoading = (1 << 2),
-
- // This flag indicates has been locked against VMM swapping
- // in addition to the internal memory locking
-
- rMemVMMLocked = (1 << 3),
-};
-
-
-// ISSUE: For integration with the database functions, it would be
-// useful to add in a database key or resource ID number, so that the
-// database routines could search for this data in the cache. Note
-// however, that the search would still be linear, which might not be
-// the best method. There might be a way to combine the LRU algorithm
-// with some kind of hash chain, so that only a few cache entries
-// need be searched.
-
-// RMemPrefix: This small structure precedes every allocated block
-
-struct RMemPrefix {
-#if DEBUG
- int16 magic;
-#endif
- uint32 size; // length of this block, incl. prefix
- RHandle *handle; // back pointer to handle
- uint8 flags, // flags: purgeable, etc.
- lockNestCount; // nest count of locks
-#if DEBUG
- char description[16];
-#endif
-// 10 bytes ( + 18 if DEBUG )
-};
-
-
-
-// A Memory Handle, which is an indirect reference to a block of memory.
-// This is used so that blocks of memory may be reorganized and compacted
-// while still keeping external references to the memory valid.
-// The handle has a DNode for two reasons: One, to keep a list of all
-// unused handles, and also to keep a least-recently-used list of all
-// purgeable handles.
-
-struct _RHandle {
- RHandle *next, // next handle in chain
- *prev; // previous handle in chain
- void *data; // pointer to real data for handle
- // NULL if no data allocated
-// 12 bytes
-};
-
-#define HandleBaseAddr(h) ((RHandle *)((uint8 *)(h) - offsetof( RHandle, data )))
-#define PrefixBaseAddr(d) ((RMemPrefix *)((uint8 *)(d) - prefixOffset))
-
-// RHandleBlock: A block of memory handles. It's based on the DNode so that
-// blocks can be linked and delinked independently of the others.
-// This block is itself allocated as a non-relocatable block.
-
-#define HANDLES_PER_BLOCK 64 // number of handles per block
-
-struct RHandleBlock {
- RHandleBlock *next,
- *prev;
-
- uint16 freeHandleCount; // number of handles in use
- RHandle *freeHandles; // the first free handle in block
- RHandle handles[HANDLES_PER_BLOCK]; // array of handles
-};
-
-// An "RMemFreeBlock" keeps track of which areas are unused.
-
-struct RMemFreeBlock {
- RMemFreeBlock *next; // pointer to next free block
- uint32 size; // size of this arena
-};
-
-
-// A "heap" consists of a linked lists of MemHeaders, such that
-// allocations within an Arena will be drawn from any of the
-// MemHeaders.
-
-struct _RHeap {
- struct _RHeap *next; // pointer to next heap
- uint32 size, // size of memory space for heap
- free; // number of bytes of free memory
- uint8 *memory; // ptr to actual memory
- RMemFreeBlock *firstFree; // ptr to first free block
- RHandleBlock *handleBlocks; // list of blocks of handles
- RHandle *cacheHead, // list of allocations in the cache
- *cacheTail; // end of cache list
-};
-
-/* Realm memory management functions:
-
- RMemAvail...
- RMemCompact...
-
-// database stuff...
- handle = RFindCacheItem( heap, keys?? );
- RSetCacheItem( handle, keys?? );
-
- RGetResource( keys... );
-*/
-
-} // end of namespace Saga2
-
-#endif
diff --git a/engines/saga2/rserver.cpp b/engines/saga2/rserver.cpp
deleted file mode 100644
index ea57a44711..0000000000
--- a/engines/saga2/rserver.cpp
+++ /dev/null
@@ -1,220 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * aint32 with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-
-#include "common/debug.h"
-
-#include "saga2/std.h"
-#include "saga2/dlist.h"
-#include "saga2/ioerrors.h"
-#include "saga2/hresmgr.h"
-
-namespace Saga2 {
-
-class ResourceRequest;
-
-class ResourceServer : public DList {
- HR_FILE *fHandle; // resource file handle
- int32 lastSeekPos; // where drive head is
- int32 actual; // bytes read so far
-
- ResourceRequest *currentRequest;
-
-public:
- ResourceServer(HR_FILE *); // constructor
- void service(void);
-};
-
-class ResourceRequest : public DNode {
-public:
- RHANDLE handle; // where to put the data
- uint32 offset, // offset in file of data
- length; // desired length of data
- bool done; // true if load is finished
- void *userData; // for app use
-
- // Function to notify when request is done.
- void (*notify)(ResourceRequest &);
-
- ResourceRequest(DList &dl); // constructor
-};
-
-/* ===================================================================== *
- Globals
- * ===================================================================== */
-
-ResourceServer *resourceServer; // resource server ptr
-DList resourceRequestPool; // pool of messages
-
-const int numResRequests = 32; // up to 32 messages allowed
-
-/* ===================================================================== *
- Member Functions
- * ===================================================================== */
-ResourceServer::ResourceServer(HR_FILE *fh) {
- currentRequest = NULL;
- fHandle = fh; // file handle
- lastSeekPos = 0; // drive position
-}
-
-const int loadQuanta = 0x4000; // 16K
-
-void ResourceServer::service(void) {
- if (currentRequest == NULL) {
- currentRequest = (ResourceRequest *)remHead();
-
- if (currentRequest == NULL) return;
-
- // seek to position in file
- HR_SEEK(fHandle, currentRequest->offset, SEEK_SET);
-
- // calculate final seek position
- lastSeekPos = currentRequest->offset + currentRequest->length;
- actual = 0; // bytes read so far
- }
-
- if (currentRequest->length > 0 // while there's data to read
- && *currentRequest->handle != NULL) { // and block not flushed
- int32 loadSize = MIN<uint>(currentRequest->length, loadQuanta);
- uint8 *buffer = (UBytePtr) * currentRequest->handle + actual;
-
- // Read 16K worth of data, or however much is left.
- if (HR_READ(buffer, loadSize, 1, fHandle) != 1)
- error("Error reading resource");
-
- buffer += loadSize;
- currentRequest->length -= loadSize;
- currentRequest->offset += loadSize;
- actual += loadSize;
-
-#if DEBUG
- WriteStatusF(1, "Loaded: %8.8d", actual);
-#endif
- } else {
- currentRequest->done = true;
- resourceRequestPool.addTail(*currentRequest);
- currentRequest = NULL;
-
- // Mark handle as ready for use.
- RHandleDoneLoading(currentRequest->handle); // mark handle as loaded
-
- // Notify callback that resource is done loading
- if (currentRequest->notify)
- currentRequest->notify(*currentRequest);
- currentRequest->notify = NULL;
- }
-}
-
-ResourceRequest::ResourceRequest(DList &dl) {
- notify = NULL;
- dl.addTail(*this);
-}
-
-void RequestResource(
- RHANDLE handle,
- int32 offset,
- int32 length,
- // Function to notify when request is done.
- void *notify,
- void *userData) {
- ResourceRequest *rr;
-
- // Try to get a resource request. If none are available,
- // then wait until one is avauilable.
-
- for (;;) {
- rr = (ResourceRequest *)
- resourceRequestPool.remHead();
-
- if (rr != NULL) break;
-
- // Service resources until request is free
- resourceServer->service();
- }
-
- RHandleStartLoading(handle);
-
- rr->done = false;
- rr->handle = handle;
- rr->offset = offset;
- rr->length = length;
- rr->notify = (void (*)(ResourceRequest &))notify;
- rr->userData = userData;
-
- resourceServer->addTail(*rr);
-}
-
-void initServers(void) {
- warning("STUB: initServers()");
-#if 0
- int16 i;
- resourceServer = NEW_PRES ResourceServer(resFile->resFileHandle());
- if (resourceServer == NULL) {
- error("Unable to start up resource server!\n");
- }
-
- for (i = 0; i < numResRequests; i++) {
- NEW_PRES ResourceRequest(resourceRequestPool);
- }
-#endif
-}
-
-void cleanupServers(void) {
- ResourceRequest *rr;
- if (resourceServer)
- delete resourceServer;
- resourceServer = NULL;
- while ((rr = (ResourceRequest *)resourceRequestPool.remHead()))
- delete rr;
-}
-
-void loadAsyncResources(void) {
- debug(6, "STUB: loadAsyncResources()");
-
-#if 0
- resourceServer->service();
-#endif
-}
-
-void syncResources(void) {
- while (resourceServer->count() > 0)
- resourceServer->service();
-}
-
-void *lockResource(RHANDLE h) {
- if (h && *h) {
- while (RHandleLoading(h)) resourceServer->service();
- return RLockHandle(h);
- }
- return NULL;
-}
-
-void unlockResource(RHANDLE handle) {
- RUnlockHandle(handle);
-}
-
-} // end if namespace Saga2
diff --git a/engines/saga2/speldata.cpp b/engines/saga2/speldata.cpp
index 4f9d299c53..b8141b9515 100644
--- a/engines/saga2/speldata.cpp
+++ b/engines/saga2/speldata.cpp
@@ -227,7 +227,7 @@ static void loadMagicData(void) {
spellBook[rsi->spell].setupFromResource(rsi);
SpellDisplayPrototypeList::sdpList.add(new SpellDisplayPrototype(rsi));
- RDisposePtr(rsi);
+ free(rsi);
i++;
}
assert(i > 1);
@@ -248,7 +248,7 @@ static void loadMagicData(void) {
if (rse->spell)
spellBook[rse->spell].addEffect(rse);
- RDisposePtr(rse);
+ free(rse);
i++;
}
assert(i > 1);
diff --git a/engines/saga2/task.cpp b/engines/saga2/task.cpp
index 249298d628..5d82588190 100644
--- a/engines/saga2/task.cpp
+++ b/engines/saga2/task.cpp
@@ -375,7 +375,7 @@ void saveTaskStacks(SaveFileConstructor &saveGame) {
archiveBufSize = stackList.archiveSize();
- archiveBuffer = RNewPtr(archiveBufSize, NULL, "archive buffer");
+ archiveBuffer = malloc(archiveBufSize);
if (archiveBuffer == NULL)
error("Unable to allocate task stack archive buffer");
@@ -386,7 +386,7 @@ void saveTaskStacks(SaveFileConstructor &saveGame) {
archiveBuffer,
archiveBufSize);
- RDisposePtr(archiveBuffer);
+ free(archiveBuffer);
}
//----------------------------------------------------------------------
@@ -404,7 +404,7 @@ void loadTaskStacks(SaveFileReader &saveGame) {
void *bufferPtr;
archiveBufSize = saveGame.getChunkSize();
- archiveBuffer = RNewPtr(archiveBufSize, NULL, "archive buffer");
+ archiveBuffer = malloc(archiveBufSize);
if (archiveBuffer == NULL)
error("Unable to allocate task stack archive buffer");
@@ -419,7 +419,7 @@ void loadTaskStacks(SaveFileReader &saveGame) {
assert(bufferPtr == &((char *)archiveBuffer)[archiveBufSize]);
- RDisposePtr(archiveBuffer);
+ free(archiveBuffer);
}
//----------------------------------------------------------------------
@@ -671,7 +671,7 @@ void saveTasks(SaveFileConstructor &saveGame) {
archiveBufSize = taskList.archiveSize();
- archiveBuffer = RNewPtr(archiveBufSize, NULL, "archive buffer");
+ archiveBuffer = malloc(archiveBufSize);
if (archiveBuffer == NULL)
error("Unable to allocate task archive buffer");
@@ -686,7 +686,7 @@ void saveTasks(SaveFileConstructor &saveGame) {
archiveBuffer,
archiveBufSize);
- RDisposePtr(archiveBuffer);
+ free(archiveBuffer);
}
//----------------------------------------------------------------------
@@ -704,7 +704,7 @@ void loadTasks(SaveFileReader &saveGame) {
void *bufferPtr;
archiveBufSize = saveGame.getChunkSize();
- archiveBuffer = RNewPtr(archiveBufSize, NULL, "archive buffer");
+ archiveBuffer = malloc(archiveBufSize);
if (archiveBuffer == NULL)
error("Unable to allocate task archive buffer");
@@ -719,7 +719,7 @@ void loadTasks(SaveFileReader &saveGame) {
assert(bufferPtr == &((char *)archiveBuffer)[archiveBufSize]);
- RDisposePtr(archiveBuffer);
+ free(archiveBuffer);
}
//----------------------------------------------------------------------
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index a51917b2d6..a738ffb02c 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -860,7 +860,7 @@ struct WorldMapData {
MetaTileList *metaList; // MetaTile list
TileRefPtr activeItemData; // ActiveItem tileRefs
ActiveItemList *activeItemList; // ActiveItem list
- UWordPtr assocList; // Associations
+ uint16 *assocList; // Associations
RipTableIDPtr ripTableIDList; // MetaTile object ripping
ActiveItem *instHash[513]; // ActiveItem hash table
diff --git a/engines/saga2/tileload.cpp b/engines/saga2/tileload.cpp
index 44e8ad9921..a3c5b94caf 100644
--- a/engines/saga2/tileload.cpp
+++ b/engines/saga2/tileload.cpp
@@ -63,8 +63,6 @@ void RHeapsAMess(void);
void freeAllTileBanks(void) {
tileImageBanks.flush();
- tileImageBanks.flush();
- RHeapsAMess();
}
void unlockAllTileBanks(void) {
diff --git a/engines/saga2/tilemode.cpp b/engines/saga2/tilemode.cpp
index b88b93e567..ddb3e07661 100644
--- a/engines/saga2/tilemode.cpp
+++ b/engines/saga2/tilemode.cpp
@@ -684,16 +684,6 @@ void TileModeSetup(void) {
lastUpdateTime = gameTime;
-#if DEBUG*0
- debugMap.size.x = 64;
- debugMap.size.y = 200;
-
- debugMap.data = (uint8 *)RNewPtr(debugMap.bytes(), NULL);
- if (debugMap.data == NULL) {
- fatal("Unable to allocate memory for debug map\n");
- }
-#endif
-
setCurrentWorld(WorldBaseID);
setCurrentMap(currentWorld->mapNum);
}
diff --git a/engines/saga2/towerfta.cpp b/engines/saga2/towerfta.cpp
index ff1c5a479e..b0baa7a0fd 100644
--- a/engines/saga2/towerfta.cpp
+++ b/engines/saga2/towerfta.cpp
@@ -174,12 +174,10 @@ TERMINATOR(termResourceFiles) {
// ------------------------------------------------------------------------
INITIALIZER(initResourceServers) {
- initServers();
return true;
}
TERMINATOR(termResourceServers) {
- cleanupServers(); // cleanup async servers
}
@@ -480,10 +478,6 @@ INITIALIZER(initTop) {
TERMINATOR(termTop) {
mainDisable();
- RMemFastCleanup();
-#ifdef _WIN32
- //pWindow->RestoreDisplay();
-#endif
}
} // end of namespace Saga2
diff --git a/engines/saga2/vpal.cpp b/engines/saga2/vpal.cpp
index 432cb874b5..35d2b35daa 100644
--- a/engines/saga2/vpal.cpp
+++ b/engines/saga2/vpal.cpp
@@ -165,7 +165,7 @@ void loadPalettes(void) {
void cleanupPalettes(void) {
if (noonPalette) {
- RDisposeHandle((RHANDLE) noonPalette);
+ free(noonPalette);
noonPalette = nullptr;
}
@@ -247,7 +247,7 @@ void createPalette(
int i;
uint32 fadeProgress = (elapsedTime << 8) / totalTime_;
- for (i = 0; i < elementsof(newP->entry); i++) {
+ for (i = 0; i < (long)elementsof(newP->entry); i++) {
gPaletteEntry *srcPal = &srcP->entry[i];
gPaletteEntry *dstPal = &dstP->entry[i];
gPaletteEntry *curPal = &newP->entry[i];
Commit: a640006ea606d46d78c396bc333de1e4550a388d
https://github.com/scummvm/scummvm/commit/a640006ea606d46d78c396bc333de1e4550a388d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:29+02:00
Commit Message:
SAGA2: Fix more warnings
Changed paths:
engines/saga2/contain.cpp
engines/saga2/display.cpp
engines/saga2/dispnode.cpp
engines/saga2/dispnode.h
engines/saga2/document.cpp
diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index d5832f55e0..718ceaf672 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -48,8 +48,6 @@ namespace Saga2 {
uint8 weight = 0;
uint8 encum = 0;
-const hResID containerGroupID = MKTAG('C', 'O', 'N', 'T');
-
const int maxOpenDistance = 32;
// selector image pointer
static void *selImage;
@@ -340,8 +338,6 @@ void ContainerView::totalObjects(void) {
// If the object is visible, then add to total mass and
// bulk.
if (isVisible(item)) {
- // get the container slot location and count
- TilePoint objLoc = item->getLocation();
uint16 numItems;
ProtoObj *proto = item->proto();
@@ -1686,7 +1682,7 @@ extern int16 openMindType;
// kind of container is appropriate, and also if a container of that
// type is already open.
ContainerNode *CreateContainerNode(ObjectID id, bool open, int16) {
- ContainerNode *cn;
+ ContainerNode *cn = NULL;
GameObject *obj = GameObject::objectAddress(id);
PlayerActorID owner;
diff --git a/engines/saga2/display.cpp b/engines/saga2/display.cpp
index 9bdaf5ec0c..595fd107e8 100644
--- a/engines/saga2/display.cpp
+++ b/engines/saga2/display.cpp
@@ -36,9 +36,6 @@ extern bool gameRunning;
extern bool delayReDraw;
extern gDisplayPort mainPort; // default rendering port
extern BackWindow *mainWindow; // main window...
-#ifdef _WIN32
-extern CFTWindow *pWindow;
-#endif
/* ===================================================================== *
Globals
@@ -53,10 +50,6 @@ bool paletteMayHaveChanged = false;
static uint32 displayStatus = GraphicsInit;
static bool paletteSuspendFlag = false;
-#ifndef _WIN32
-static bool VideoSaved = false;
-static uint8 VideoSaveMode;
-#endif
/* ===================================================================== *
@@ -73,10 +66,6 @@ void lightsOut(void);
void loadingScreen(void);
void resetInputDevices(void);
APPFUNC(cmdWindowFunc); // main window event handler
-#ifdef _WIN32
-void suspendProcessResources(void);
-void resumeProcessResources(void);
-#endif
static void switchOn(void);
static void switchOff(void);
@@ -103,9 +92,6 @@ void niceScreenStartup(void) {
disablePaletteChanges();
mainEnable();
closeLoadMode();
-#ifdef _WIN32
- localCursorOn();
-#endif
pointer.move(Point16(320, 240));
//pointer.hide();
enablePaletteChanges();
@@ -260,28 +246,10 @@ void reDrawScreen(void) {
* ===================================================================== */
void blackOut(void) {
- bool dispEnable = displayEnabled();
-#ifdef _WIN32
- if (!dispEnable)
- resumeDDGraphics();
-#endif
mainPort.drawMode = drawModeReplace;
mainPort.setColor(0); // fill screen with color
mainPort.fillRect(Rect16(0, 0, 640, 480));
-#ifdef _WIN32
- if (pWindow) {
- pWindow->SetEraseColor(0);
- pWindow->Erase();
- pWindow->FillBackBuffer();
- pWindow->Flip();
- pWindow->Erase();
- }
-#endif
lightsOut();
-#ifdef _WIN32
- if (!dispEnable)
- suspendDDGraphics();
-#endif
}
diff --git a/engines/saga2/dispnode.cpp b/engines/saga2/dispnode.cpp
index 879f8139bb..8cfde1290c 100644
--- a/engines/saga2/dispnode.cpp
+++ b/engines/saga2/dispnode.cpp
@@ -743,16 +743,13 @@ void DisplayNode::drawObject(void) {
// If we were carrying something in the right hand,
// then fill in the component structure for it.
if (rightIndex >= 0) {
- GameObject *ob;
- ProtoObj *proto;
-
- ob = GameObject::objectAddress(a->rightHandObject);
- proto = ob->proto();
+ GameObject *ob = GameObject::objectAddress(a->rightHandObject);
+ ProtoObj *prot = ob->proto();
ob->getColorTranslation(rightColors);
sc = &scList[rightIndex];
- sc->sp = proto->getOrientedSprite(
+ sc->sp = prot->getOrientedSprite(
ob,
a->poseInfo.rightObjectIndex);
assert(sc->sp != NULL);
@@ -969,8 +966,6 @@ void DisplayNode::drawEffect(void) {
}
void Effectron::drawEffect(void) {
- const int16 partCount = 1;
- const int16 bodyIndex = 0;
ColorTable eColors; // colors for object
bool obscured = false;
Point16 drawPos;
diff --git a/engines/saga2/dispnode.h b/engines/saga2/dispnode.h
index c06ca335dd..7d2b062c27 100644
--- a/engines/saga2/dispnode.h
+++ b/engines/saga2/dispnode.h
@@ -117,9 +117,6 @@ public:
void updateOStates(const int32 deltaTime);
void updateEStates(const int32 deltaTime);
bool dissipated(void);
-
-private:
- int16 sortDepth; // for sorting by depth
};
/* ============================================================================ *
diff --git a/engines/saga2/document.cpp b/engines/saga2/document.cpp
index 5326a92078..018efdda59 100644
--- a/engines/saga2/document.cpp
+++ b/engines/saga2/document.cpp
@@ -552,7 +552,7 @@ bool CDocument::checkForImage(char *string,
// image detected marker
if (strIndex[1] == dImage[0] &&
strIndex[2] == dImage[1]) {
- int16 numEat; // number of characters to eat
+ int16 numEat = 0; // number of characters to eat
char *argv = &strIndex[2 + 1]; // array to first element
// delete context
@@ -908,7 +908,6 @@ int16 openScroll(uint16 textScript) {
gCompButton *closeScroll;
void **closeBtnImage;
uint16 buttonResID = 0;
- uint16 numBtnImages = 2;
hResContext *decRes;
// init the resource context handle
Commit: d83fc2c8aae7c33b388b84d0058fc8d7a06f2211
https://github.com/scummvm/scummvm/commit/d83fc2c8aae7c33b388b84d0058fc8d7a06f2211
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:30+02:00
Commit Message:
SAGA2: Unstubbed GameMode::SetStack()
Changed paths:
engines/saga2/gamemode.cpp
diff --git a/engines/saga2/gamemode.cpp b/engines/saga2/gamemode.cpp
index dadd913b0b..c4ff5de812 100644
--- a/engines/saga2/gamemode.cpp
+++ b/engines/saga2/gamemode.cpp
@@ -99,21 +99,15 @@ void GameMode::SetStack(GameMode *modeFirst, ...) {
//Put List In New Array Of GameMode Object Pointers
- warning("STUB: GameMode::SetStack()");
-
-#if 0
- while (thisMode != End_List) {
+ while (thisMode != 0) {
newmodeStackPtr[newmodeStackCtr] = thisMode;
newmodeStackCtr++;
thisMode = va_arg(Modes, GameMode *);
}
-#endif
va_end(Modes); //Clean Up
newmodeFlag = true;
- return;
-
}
void GameMode::SetStack(GameMode **newStack, int newStackSize) {
Commit: b59c9d3334d3afca4ffa8ce13b63798a974debf2
https://github.com/scummvm/scummvm/commit/b59c9d3334d3afca4ffa8ce13b63798a974debf2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:30+02:00
Commit Message:
SAGA2: Remove unused unsafe method
Changed paths:
engines/saga2/objects.cpp
engines/saga2/objects.h
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 0cbfdd5473..b0900e267d 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -1678,24 +1678,6 @@ void GameObject::dropInventoryObject(GameObject *obj, int16 count) {
}
}
-void GameObject::protoAddressToOffset() {
- ProtoObj *objectBase = &objectProtos[0];
- ProtoObj *actorBase = &actorProtos[0];
- int32 newProto, size = sizeof(ResourceObjectPrototype) + 4;//Add 4 for jump Table
-
- if (prototype == nullptr) return;
-
- warning("STUB: GameObject::protoAddressToOffset(): unsafe pointer arithmetics");
-
- if (isActor(this))
- newProto = (prototype - actorBase) / size;
- else
- newProto = (prototype - objectBase) / size;
-
- prototype = (ProtoObj *)newProto;
-
-}
-
GameObject *GameObject::getIntangibleContainer(int containerType) {
ObjectID objID;
diff --git a/engines/saga2/objects.h b/engines/saga2/objects.h
index 1441d04f74..3cac92eda9 100644
--- a/engines/saga2/objects.h
+++ b/engines/saga2/objects.h
@@ -183,7 +183,6 @@ protected:
void remove(void); // removes from old list
void append(ObjectID newParent); // adds to new list (no remove)
void insert(ObjectID newPrev); // inserts after this item (no remove)
- void protoAddressToOffset(void); // converts proto address to offset in resource file
ProtoObj *prototype; // object that defines our behavior
public:
Commit: ebe78d8c9921fbc5cd9d025d267093c3a9122253
https://github.com/scummvm/scummvm/commit/ebe78d8c9921fbc5cd9d025d267093c3a9122253
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:30+02:00
Commit Message:
SAGA2: Cleanup gtext.cpp
Changed paths:
engines/saga2/gtext.cpp
diff --git a/engines/saga2/gtext.cpp b/engines/saga2/gtext.cpp
index 28f829f9dc..386348243d 100644
--- a/engines/saga2/gtext.cpp
+++ b/engines/saga2/gtext.cpp
@@ -65,7 +65,6 @@ namespace Saga2 {
and will not run on an 68000 or 68010 processor.
*/
-#if 1
void DrawChar(gFont *font, int drawchar, int xpos, uint8 *baseline, uint8 color,
uint16 destwidth) {
short w,
@@ -114,134 +113,6 @@ void DrawChar(gFont *font, int drawchar, int xpos, uint8 *baseline, uint8 color,
dst += 8;
}
}
-#else
-static void DrawChar(
- gFont *font, // address of the font
- int drawchar, // character index to draw
- int xpos, // x position to render to
- uint8 *baseline, // base address of line
- gPen color, // color to render
- uint16 destwidth) { // destination width
- uint16 h, // font height counter
- rowmod; // row modulus of font
-
- int16 charwidth; // width of character in pixels
-
- uint8 *chardata, // pointer to start of char data
- *destcol; // pointer to start of dest
-
- // point to the first byte of the first scanline of the
- // source char
-
- chardata = (uint8 *)(font + 1) + font->charXOffset[drawchar];
-
- // get the width of the character in pixels
-
- charwidth = font->charWidth[drawchar];
-
- // point to the first byte of where we want to place the character
-
- baseline += xpos;
-
- // this loop goes once for each 8 pixels wide that the
- // character is
-
- h = font->height;
- rowmod = font->rowMod;
-
- asm {
- push ds
-
- mov dx, charwidth // dx is the char width tracking register
- or dx, dx
- jmp endwhile
- }
-whiletop:
- asm {
- // get the pointer to the source and destination columns.
-
- lds si, chardata
- les di, baseline
- mov [word ptr destcol], di
- mov [word ptr destcol+2], es
-
- // this loop goes once for each scanline of the character
-
- mov cx, h
- inc cx
- jmp heightend
- }
-heighttop:
- asm {
- // get the font bit pattern for this scanline
-
- mov ah, ds:[si]
- xor al, al
-
- // point to the address of where to start rendering
-
- /* now, render the pixels. NOTE: Using Carry in assembly,
- you would probably want to do the shift first and be
- more efficient.
- */
-
- // prepare our loop render pixels one at a time...
- mov bl, color
- jmp innerbottom
- }
-innertop:
- asm {
- add ax, ax
- jnc nostore
-
- mov es:[di], bl
- }
-nostore:
- asm {
- inc di
- }
-innerbottom:
- asm {
- or ax, ax
- jnz innertop
-
- // increment source and dest pointers to next scanline
-
- add si, rowmod
- mov bx, [word ptr destcol]
- add bx, destwidth
- mov di, bx
- mov [word ptr destcol], bx
- }
-heightend:
- asm {
- loop heighttop
-
- // add one to chardata
- mov ax, [word ptr chardata]
- inc ax
- mov [word ptr chardata], ax
-
- // add 8 to baseline
- mov ax, [word ptr baseline]
- add ax, 8
- mov [word ptr baseline], ax
-
- // sub 8 from charwidth
- sub dx, 8
- }
-endwhile:
- asm {
- jle endall
- jmp whiletop
- }
-endall:
- asm {
- pop ds
- }
-}
-#endif
-
/* DrawChar3x3Outline:
This function renders a single bitmapped character into an offscreen
@@ -277,7 +148,6 @@ endall:
#define SQUARE_OUTLINES 1
-#if 1
void DrawChar3x3Outline(gFont *font, int drawchar, int xpos, uint8 *baseline,
uint8 color, uint16 destwidth) {
uint8 *d;
@@ -403,201 +273,6 @@ void DrawChar5x5Outline(gFont *font, int drawchar, int xpos, uint8 *baseline,
}
}
-#else
-static void DrawChar3x3Outline(
- gFont *font,
- int drawchar,
- int xpos,
- uint8 *baseline,
- gPen color,
- uint16 destwidth) {
- // These variables form a 3-stage pipeline, one per scanline
-
- uint16 txt1, // bit pattern for current scanline
- txt2, // bit pattern for previous scanline
- txt3, // bit pattern for one before that
- h,
- rowmod;
-
- int16 charwidth; // width of character in pixels
-
- uint8 *chardata, // pointer to start of char data
- *destcol; // pointer to start of dest
-
- // point to the first byte of the first scanline of the source char
-
- chardata = (uint8 *)(font + 1) + font->charXOffset[drawchar];
-
- // get the width of the character in pixels
-
- charwidth = font->charWidth[drawchar];
-
- // point to the first byte of where we want to place the character
-
- baseline += xpos - 1;
-
- // this loop goes once for each 8 pixels wide that the character is,
- // in other words it processes the data 8 pixels at a time.
-
- h = font->height;
- rowmod = font->rowMod;
-
- asm {
- push ds
-
- mov dx, charwidth // dx is the char width tracking register
- or dx, dx
- jmp endwhile
- }
-whiletop:
- asm {
- xor ax, ax
- mov txt1, ax
- mov txt2, ax
-
- // source and destination pointers
- lds si, chardata
- les di, baseline
- mov [word ptr destcol], di
- mov [word ptr destcol+2], es
-
- mov cx, h
- inc cx
- jmp heightend
- }
-heighttop:
- asm {
- mov ax, txt2
- mov txt3, ax
-
- mov ax, txt1
- mov txt2, ax
-
- mov ah, ds:[si] // Feed the fifopipe!
- xor al, al
-
- // some magic square outline or'ing of the last three lines
- mov bx, ax
- shr bx, 1
- or ax, bx
- shr bx, 1
- or ax, bx
-
- // save off txt1 and create txtmask in ax
- mov txt1, ax
-
- or ax, txt2
- or ax, txt3
-
- // prepare our loop render pixels one at a time...
- mov bl, color
- jmp innerbottom
- }
-innertop:
- asm {
- add ax, ax
- jnc nostore
-
- mov es:[di], bl
- }
-nostore:
- asm {
- inc di
- }
-innerbottom:
- asm {
- or ax, ax
- jnz innertop
-
- add si, rowmod
- mov bx, [word ptr destcol]
- add bx, destwidth
- mov di, bx
- mov [word ptr destcol], bx
- }
-heightend:
- asm {
- loop heighttop
-
- // FLUSH OUT THE FIFO
-
-// ********************************* FIRST FIFO
- mov ax, txt1
- or ax, txt2
-
-// mov di,bx
- mov bl, color
- jmp innerbottom1
- }
-innertop1:
- asm {
- add ax, ax
- jnc nostore1
-
- mov es:[di], bl
- }
-nostore1:
- asm {
- inc di
- }
-innerbottom1:
- asm {
- or ax, ax
- jnz innertop1
-
- mov bx, [word ptr destcol]
- add bx, destwidth
- mov [word ptr destcol], bx
-
-// ********************************* SECOND FIFO
-
- mov ax, txt1
-
- mov di, bx
- mov bl, color
- jmp innerbottom2
- }
-innertop2:
- asm {
- add ax, ax
- jnc nostore2
-
- mov es:[di], bl
- }
-nostore2:
- asm {
- inc di
- }
-innerbottom2:
- asm {
- or ax, ax
- jnz innertop2
-// ********************************* FINISH UP
-
- // add one to chardata
- mov ax, [word ptr chardata]
- inc ax
- mov [word ptr chardata], ax
-
- // add 8 to baseline
- mov ax, [word ptr baseline]
- add ax, 8
- mov [word ptr baseline], ax
-
- // sub 8 from charwidth
- sub dx, 8
- }
-endwhile:
- asm {
- jle endall
- jmp whiletop
- }
-endall:
- asm {
- pop ds
- }
-}
-#endif
/* A private routine to render a string of characters into a temp
buffer.
@@ -1280,134 +955,4 @@ int32 GTextWrap(gFont *font, char *mark, uint16 &count, uint16 width, int16 styl
return -1;
}
-#if 0
-int16 X_TextWrap(
- char *lines[],
- int16 line_chars[],
- int16 line_pixels[],
- char *text, // the text to render
- int16 width // width to constrain text
-) {
- int16 i, // loop counter
- line_start, // start of current line
- last_space, // last space encountered
- last_space_pixels, // pixel pos of last space
- pixel_len, // pixel length of line
- line_count = 0; // number of lines
-
- lines[line_count] = text;
- last_space = -1;
- line_start = 0;
- pixel_len = 0;
-
- // For each character in the string, check for word wrap
-
- for (i = 0; ; i++) {
- uint8 c = text[i];
-
- if (c == '\n' || c == '\r' || c == '\0') { // if deliberate end of line
- line_chars[line_count] = i - line_start; //
- line_pixels[line_count] = pixel_len;
- line_start = i + 1;
- if (c == '\0') {
- line_count++;
- break;
- }
- lines[++line_count] = &text[line_start];
- last_space = -1;
- pixel_len = 0;
- continue;
- } else if (c == ' ') {
- last_space = i;
- last_space_pixels = pixel_len;
- }
-
- pixel_len +=
- font->char_kern[c] + font->char_space[c];
-
- if (pixel_len > width - 2 && last_space > 0) {
- line_chars[line_count] = last_space - line_start;
- line_pixels[line_count] = last_space_pixels;
- line_start = last_space + 1;
- lines[++line_count] = &text[line_start];
-
- last_space = -1;
- pixel_len = 0;
-
- i = line_start - 1;
- }
- }
- return line_count;
-}
-
-void XS_DrawTextWrapped(
- xImage *dest, // where to draw to
- char *text, // the text to render
- xBox *box, // box to constrain text
- int16 text_color, // color of text
- int16 outline_color // color of outline
-) {
- int16 i, // loop counter
- line_count = 0; // number of lines
-
- char *lines[10]; // pointer to each line
-
- int16 line_chars[10], // # of chars in line
- line_pixels[10], // # of pixels in line
- ypos = box->Top, // top of box
- row_height;
- int16 save_flags = x_DrawFlags;
-
- line_count = X_TextWrap(lines, line_chars, line_pixels,
- text, box->Width);
-
- row_height = theFont->height + ((outline_color > 0) ? 2 : 0);
- if (outline_color > 0) ypos += 1;
-
- // Vertically center it in box
-
- if (box->Height >= line_count * row_height)
- ypos += (box->Height - line_count * row_height) / 2;
-
- X_Masking(true);
- X_Clipping(false);
-
- for (i = 0; i < line_count; i++) {
- DrawFixedString(dest,
- lines[i], line_chars[i],
- box->Left + (box->Width - line_pixels[i]) / 2 + 1,
- ypos,
- text_color, outline_color, 0);
-
- ypos += row_height;
- if (ypos >= box->Top + box->Height) break;
- }
- x_DrawFlags = save_flags;
-}
-
-// Figures the height of a wrapped text box.
-
-int16 X_WrappedTextHeight(
- char *text, // the text to render
- int16 width, // box to constrain text
- int16 outlined // color of outline
-) {
- int16 line_count = 0; // number of lines
-
- char *lines[10]; // pointer to each line
-
- int16 line_chars[10], // # of chars in line
- line_pixels[10], // # of pixels in line
- row_height;
-
- line_count = X_TextWrap(lines, line_chars, line_pixels,
- text, width);
-
- row_height = theFont->height + (outlined ? 2 : 0);
-
- if (outlined > 0) return (line_count * row_height) + 1;
- return (line_count * row_height);
-}
-#endif
-
} // end of namespace Saga2
Commit: 794fde8f9c39c325125f5c8d6ce8e8c1e67573b6
https://github.com/scummvm/scummvm/commit/794fde8f9c39c325125f5c8d6ce8e8c1e67573b6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:30+02:00
Commit Message:
SAGA2: Fix more warnings
Changed paths:
engines/saga2/contain.cpp
engines/saga2/dispnode.cpp
engines/saga2/gpointer.cpp
engines/saga2/grabinfo.cpp
diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index 718ceaf672..c5b918fcdd 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -1925,7 +1925,6 @@ void setMindContainer(int index, IntangibleContainerWindow &cw) {
GameObject *object = GameObject::objectAddress(ownerID);
ContainerIterator iter(object);
GameObject *item;
- GameObject *newContainer = NULL;
ObjectID id;
assert(index >= 0);
@@ -1996,7 +1995,7 @@ APPFUNC(cmdMindContainerFunc) {
break;
case -1:
- sprintf(textBuffer, "\0");
+ textBuffer[0] = 0;
break;
default:
diff --git a/engines/saga2/dispnode.cpp b/engines/saga2/dispnode.cpp
index 8cfde1290c..97ac7f3494 100644
--- a/engines/saga2/dispnode.cpp
+++ b/engines/saga2/dispnode.cpp
@@ -718,16 +718,13 @@ void DisplayNode::drawObject(void) {
// If we were carrying something in the left hand,
// then fill in the component structure for it.
if (leftIndex >= 0) {
- GameObject *ob;
- ProtoObj *proto;
-
- ob = GameObject::objectAddress(a->leftHandObject);
- proto = ob->proto();
+ GameObject *ob = GameObject::objectAddress(a->leftHandObject);
+ ProtoObj *prot = ob->proto();
ob->getColorTranslation(leftColors);
sc = &scList[leftIndex];
- sc->sp = proto->getOrientedSprite(
+ sc->sp = prot->getOrientedSprite(
ob,
a->poseInfo.leftObjectIndex);
assert(sc->sp != NULL);
diff --git a/engines/saga2/gpointer.cpp b/engines/saga2/gpointer.cpp
index ef03acc624..95ecb52801 100644
--- a/engines/saga2/gpointer.cpp
+++ b/engines/saga2/gpointer.cpp
@@ -69,13 +69,6 @@ void gMousePointer::draw(void) {
// Private routine to restore the mouse pointer image
void gMousePointer::restore(void) {
-#if defined( USEWINDOWS )
- if (useWinCursor)
- return;
-#endif
-
- enum draw_modes saveMode = videoPort->drawMode; // current drawing mode
-
if (shown) {
// blit from the saved map to the current position.
diff --git a/engines/saga2/grabinfo.cpp b/engines/saga2/grabinfo.cpp
index 8a337d77e9..cd9412eb61 100644
--- a/engines/saga2/grabinfo.cpp
+++ b/engines/saga2/grabinfo.cpp
@@ -254,6 +254,8 @@ void GrabInfo::setCursor(void) {
case Cast:
setMouseImage(kMouseAttakPtrImage, -11, -11);
break;
+ default:
+ break;
}
} else {
// indicate current intention is not doable
Commit: d8ca5e031a27ec576827f8f2cbd45b8a8ef5ab53
https://github.com/scummvm/scummvm/commit/d8ca5e031a27ec576827f8f2cbd45b8a8ef5ab53
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:30+02:00
Commit Message:
SAGA2: Load actor resources with stream
Changed paths:
engines/saga2/actor.cpp
engines/saga2/actor.h
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index e9e8a6caaf..6983879d26 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -3385,45 +3385,44 @@ void setCombatBehavior(bool enabled) {
//-------------------------------------------------------------------
// Initialize the actor list
-static void readResourceActor(hResContext *con, ResourceActor &resourceActor) {
- resourceActor.protoIndex = con->readS16LE();
- resourceActor.location.u = con->readS16LE();
- resourceActor.location.v = con->readS16LE();
- resourceActor.location.z = con->readS16LE();
- resourceActor.nameIndex = con->readU16LE();
- resourceActor.parentID = con->readU16LE();
- resourceActor.script = con->readU16LE();
- resourceActor.objectFlags = con->readU16LE();
- resourceActor.hitPoints = con->readByte();
- resourceActor.misc = con->readU16LE();
-
- resourceActor.faction = con->readByte();
- resourceActor.colorScheme = con->readByte();
- resourceActor.appearanceID = con->readS32BE();
- resourceActor.attitude = con->readSByte();
- resourceActor.mood = con->readSByte();
- resourceActor.disposition = con->readByte();
- resourceActor.currentFacing = con->readByte();
- resourceActor.tetherLocU = con->readS16LE();
- resourceActor.tetherLocV = con->readS16LE();
- resourceActor.tetherDist = con->readS16LE();
- resourceActor.leftHandObject = con->readU16LE();
- resourceActor.rightHandObject = con->readU16LE();
+ResourceActor::ResourceActor(Common::SeekableReadStream *stream) {
+ protoIndex = stream->readSint16LE();
+ location.u = stream->readSint16LE();
+ location.v = stream->readSint16LE();
+ location.z = stream->readSint16LE();
+ nameIndex = stream->readUint16LE();
+ parentID = stream->readUint16LE();
+ script = stream->readUint16LE();
+ objectFlags = stream->readUint16LE();
+ hitPoints = stream->readByte();
+ misc = stream->readUint16LE();
+
+ faction = stream->readByte();
+ colorScheme = stream->readByte();
+ appearanceID = stream->readSint32BE();
+ attitude = stream->readSByte();
+ mood = stream->readSByte();
+ disposition = stream->readByte();
+ currentFacing = stream->readByte();
+ tetherLocU = stream->readSint16LE();
+ tetherLocV = stream->readSint16LE();
+ tetherDist = stream->readSint16LE();
+ leftHandObject = stream->readUint16LE();
+ rightHandObject = stream->readUint16LE();
for (int i = 0; i < 16; ++i) {
- resourceActor.knowledge[i] = con->readU16LE();
+ knowledge[i] = stream->readUint16LE();
}
- resourceActor.schedule = con->readU16LE();
+ schedule = stream->readUint16LE();
for (int i = 0; i < 18; ++i) { // padding bytes = not neccessary?
- resourceActor.reserved[i] = con->readByte();
+ reserved[i] = stream->readByte();
}
}
void initActors(void) {
// Load actors
-
- int i,
- resourceActorCount;
- ResourceActor *resourceActorList;
+ int i, resourceActorCount;
+ Common::Array<ResourceActor> resourceActorList;
+ Common::SeekableReadStream *stream;
const int resourceActorSize = 91; // size of the packed struct
resourceActorCount = listRes->size(actorListID)
@@ -3442,15 +3441,14 @@ void initActors(void) {
if (!actorList)
error("Unable to load Actors");
- // Allocate memory for the resource actors
- resourceActorList = new ResourceActor[resourceActorCount]();
-
- if (!resourceActorList || listRes->seek(actorListID) == 0)
+ if ((stream = loadResourceToStream(listRes, actorListID, "res actor list")) == nullptr)
error("Unable to load Actors");
// Read the resource actors
- for (int k = 0; k < resourceActorCount; ++k)
- readResourceActor(listRes, resourceActorList[k]);
+ for (int k = 0; k < resourceActorCount; ++k) {
+ ResourceActor res(stream);
+ resourceActorList.push_back(res);
+ }
for (i = 0; i < resourceActorCount; i++) {
Actor *a = &actorList[i];
@@ -3469,12 +3467,6 @@ void initActors(void) {
actorList[0].disposition = dispositionPlayer + 0;
actorList[1].disposition = dispositionPlayer + 1;
actorList[2].disposition = dispositionPlayer + 2;
-
-
- // Wait for the object initialization to append the actors to their
- // parents' child lists
-
- delete[] resourceActorList;
}
//-------------------------------------------------------------------
diff --git a/engines/saga2/actor.h b/engines/saga2/actor.h
index 691ed8637a..c437f03e2a 100644
--- a/engines/saga2/actor.h
+++ b/engines/saga2/actor.h
@@ -517,6 +517,7 @@ struct ResourceActor : public ResourceGameObject {
// Pad bytes
uint8 reserved[18];
+ ResourceActor(Common::SeekableReadStream *stream);
};
class Actor : public GameObject {
Commit: c452adaf1bec78a04ef6a056cfd48b60adb9f720
https://github.com/scummvm/scummvm/commit/c452adaf1bec78a04ef6a056cfd48b60adb9f720
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:30+02:00
Commit Message:
SAGA2: Load ResourceGameObject with stream
Changed paths:
engines/saga2/actor.cpp
engines/saga2/objects.cpp
engines/saga2/objects.h
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 6983879d26..99f3061f81 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -3385,18 +3385,7 @@ void setCombatBehavior(bool enabled) {
//-------------------------------------------------------------------
// Initialize the actor list
-ResourceActor::ResourceActor(Common::SeekableReadStream *stream) {
- protoIndex = stream->readSint16LE();
- location.u = stream->readSint16LE();
- location.v = stream->readSint16LE();
- location.z = stream->readSint16LE();
- nameIndex = stream->readUint16LE();
- parentID = stream->readUint16LE();
- script = stream->readUint16LE();
- objectFlags = stream->readUint16LE();
- hitPoints = stream->readByte();
- misc = stream->readUint16LE();
-
+ResourceActor::ResourceActor(Common::SeekableReadStream *stream) : ResourceGameObject(stream) {
faction = stream->readByte();
colorScheme = stream->readByte();
appearanceID = stream->readSint32BE();
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index b0900e267d..6e9801b919 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -2918,23 +2918,23 @@ void cleanupWorlds(void) {
//-------------------------------------------------------------------
// Initialize the Objects list
-static void readGameObject(hResContext *con, ResourceGameObject &obj) {
- obj.protoIndex = con->readS16LE();
- obj.location.u = con->readS16LE();
- obj.location.v = con->readS16LE();
- obj.location.z = con->readS16LE();
- obj.nameIndex = con->readU16LE();
- obj.parentID = con->readU16LE();
- obj.script = con->readU16LE();
- obj.objectFlags = con->readU16LE();
- obj.hitPoints = con->readByte();
- obj.misc = con->readU16LE();
+ResourceGameObject::ResourceGameObject(Common::SeekableReadStream *stream) {
+ protoIndex = stream->readSint16LE();
+ location.u = stream->readSint16LE();
+ location.v = stream->readSint16LE();
+ location.z = stream->readSint16LE();
+ nameIndex = stream->readUint16LE();
+ parentID = stream->readUint16LE();
+ script = stream->readUint16LE();
+ objectFlags = stream->readUint16LE();
+ hitPoints = stream->readByte();
+ misc = stream->readUint16LE();
}
void initObjects(void) {
- int16 i,
- resourceObjectCount;
- ResourceGameObject *resourceObjectList;
+ int16 i, resourceObjectCount;
+ Common::Array<ResourceGameObject> resourceObjectList;
+ Common::SeekableReadStream *stream;
const int resourceGameObjSize = 19;
// Initialize the limbo counts
@@ -2959,15 +2959,14 @@ void initObjects(void) {
if (objectList == nullptr)
error("Unable to load Objects");
- // Allocate memory for the resource objects
- resourceObjectList = new ResourceGameObject[resourceObjectCount]();
-
- if (resourceObjectList == nullptr || listRes->seek(objListID) == 0)
+ if ((stream = loadResourceToStream(listRes, objListID, "res object list")) == nullptr)
error("Unable to load Objects");
// Read the resource Objects
- for (int k = 0; k < resourceObjectCount; ++k)
- readGameObject(listRes, resourceObjectList[k]);
+ for (int k = 0; k < resourceObjectCount; ++k) {
+ ResourceGameObject res(stream);
+ resourceObjectList.push_back(res);
+ }
for (i = 0; i < resourceObjectCount; i++) {
GameObject *obj = &objectList[i];
@@ -2988,8 +2987,6 @@ void initObjects(void) {
new (obj) GameObject;
}
- delete[] resourceObjectList;
-
// Go through the object list and initialize all objects.
//Add Object To World
diff --git a/engines/saga2/objects.h b/engines/saga2/objects.h
index 3cac92eda9..9ad070ebb9 100644
--- a/engines/saga2/objects.h
+++ b/engines/saga2/objects.h
@@ -84,6 +84,8 @@ struct ResourceGameObject {
};
uint8 missileFacing;
+
+ ResourceGameObject(Common::SeekableReadStream *stream);
};
// Base class of all objects
Commit: f367c884cbcd4956e12f519ad3677bf1c269c472
https://github.com/scummvm/scummvm/commit/f367c884cbcd4956e12f519ad3677bf1c269c472
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:30+02:00
Commit Message:
SAGA2: Fix memory leak
Changed paths:
engines/saga2/actor.cpp
engines/saga2/objects.cpp
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 99f3061f81..927ca73b69 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -3439,6 +3439,8 @@ void initActors(void) {
resourceActorList.push_back(res);
}
+ delete stream;
+
for (i = 0; i < resourceActorCount; i++) {
Actor *a = &actorList[i];
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 6e9801b919..eecb1deb6b 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -2509,6 +2509,8 @@ void initPrototypes(void) {
}
nameListCount = count;
+ delete stream;
+
// Load the Object prototype table
objectProtoCount = listRes->size(objProtoID)
@@ -2968,6 +2970,8 @@ void initObjects(void) {
resourceObjectList.push_back(res);
}
+ delete stream;
+
for (i = 0; i < resourceObjectCount; i++) {
GameObject *obj = &objectList[i];
Commit: ba5d06a20a27f6377a1493edcaeb4728994c03a4
https://github.com/scummvm/scummvm/commit/ba5d06a20a27f6377a1493edcaeb4728994c03a4
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:30+02:00
Commit Message:
SAGA2: Load prototypes with stream
Changed paths:
engines/saga2/actor.h
engines/saga2/objects.cpp
engines/saga2/objproto.h
diff --git a/engines/saga2/actor.h b/engines/saga2/actor.h
index c437f03e2a..2f8e2092cc 100644
--- a/engines/saga2/actor.h
+++ b/engines/saga2/actor.h
@@ -169,6 +169,30 @@ struct ActorAttributes {
uint8 getSkillLevel(int16 id) {
return skill(id) / skillFracPointsPerLevel + 1;
}
+
+ void load(Common::SeekableReadStream *stream) {
+ archery = stream->readByte();
+ swordcraft = stream->readByte();
+ shieldcraft = stream->readByte();
+ bludgeon = stream->readByte();
+ throwing = stream->readByte();
+ spellcraft = stream->readByte();
+ stealth = stream->readByte();
+ agility = stream->readByte();
+ brawn = stream->readByte();
+ lockpick = stream->readByte();
+ pilfer = stream->readByte();
+ firstAid = stream->readByte();
+ spotHidden = stream->readByte();
+ pad = stream->readSByte();
+ vitality = stream->readSint16LE();
+ redMana = stream->readSint16LE();
+ orangeMana = stream->readSint16LE();
+ yellowMana = stream->readSint16LE();
+ greenMana = stream->readSint16LE();
+ blueMana = stream->readSint16LE();
+ violetMana = stream->readSint16LE();
+ }
}; // 28 bytes
@@ -204,6 +228,13 @@ struct ResourceActorProtoExtension {
ResourceActorProtoExtension(ResourceActorProtoExtension &ext) {
memcpy(this, &ext, sizeof(ResourceActorProtoExtension));
}
+
+ void load(Common::SeekableReadStream *stream) {
+ baseStats.load(stream);
+ combatBehavior = stream->readByte();
+ gruntStyle = stream->readByte();
+ baseEffectFlags = stream->readUint32LE();
+ }
}; // 28 bytes
/* ===================================================================== *
@@ -214,6 +245,11 @@ struct ResourceActorProtoExtension {
struct ResourceActorPrototype {
ResourceObjectPrototype proto; // Standard prototype data
ResourceActorProtoExtension ext; // Extended actor data
+
+ void load(Common::SeekableReadStream *stream) {
+ proto.load(stream);
+ ext.load(stream);
+ }
};
/* ===================================================================== *
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index eecb1deb6b..e392d49889 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -2414,77 +2414,6 @@ extern int enchantmentProto;
//-------------------------------------------------------------------
// Load and construct object and actor prototype arrays
-static void readObjectPrototype(hResContext *con, ResourceObjectPrototype &obj) {
- obj.classType = con->readS16LE();
- obj.script = con->readU16LE();
- obj.nameIndex = con->readS16LE();
- obj.iconSprite = con->readU16LE();
- obj.groundSprite = con->readU16LE();
-
- for (int i = 0; i < 4; ++i)
- obj.colorMap[i] = con->readByte();
-
- obj.mass = con->readByte();
- obj.bulk = con->readByte();
- obj.crossSection = con->readByte();
- obj.height = con->readByte();
- obj.toughness = con->readByte();
- obj.breakType = con->readByte();
- obj.maxCapacity = con->readU16LE();
- obj.lockType = con->readByte();
- obj.acceptableItems = con->readByte();
- obj.weaponDamage = con->readByte();
- obj.weaponFireRate = con->readByte();
- obj.maximumRange = con->readByte();
- obj.missileType = con->readByte();
- obj.whereWearable = con->readByte();
- obj.damageAbsorbtion = con->readSByte();
- obj.damageDivider = con->readSByte();
- obj.defenseBonus = con->readSByte();
- obj.maxCharges = con->readByte();
- obj.chargeType = con->readByte();
- obj.flags = con->readS16LE();
- obj.price = con->readS16LE();
- obj.heldSpriteBase = con->readS16LE(); // union
- obj.resistance = con->readS16LE();
- obj.immunity = con->readS16LE();
- obj.soundFXClass = con->readByte();
-
- for (int i = 0; i < 7; ++i)
- obj.reserved[i] = con->readByte();
-}
-
-static void readActorPrototype(hResContext *con, ResourceActorPrototype &act) {
- readObjectPrototype(con, act.proto);
-
- ActorAttributes *att = &act.ext.baseStats;
- att->archery = con->readByte();
- att->swordcraft = con->readByte();
- att->shieldcraft = con->readByte();
- att->bludgeon = con->readByte();
- att->throwing = con->readByte();
- att->spellcraft = con->readByte();
- att->stealth = con->readByte();
- att->agility = con->readByte();
- att->brawn = con->readByte();
- att->lockpick = con->readByte();
- att->pilfer = con->readByte();
- att->firstAid = con->readByte();
- att->spotHidden = con->readByte();
- att->pad = con->readSByte();
- att->vitality = con->readS16LE();
- att->redMana = con->readS16LE();
- att->orangeMana = con->readS16LE();
- att->yellowMana = con->readS16LE();
- att->greenMana = con->readS16LE();
- att->blueMana = con->readS16LE();
- att->violetMana = con->readS16LE();
-
- act.ext.combatBehavior = con->readByte();
- act.ext.gruntStyle = con->readByte();
- act.ext.baseEffectFlags = con->readU32LE();
-}
-
void initPrototypes(void) {
const int resourceObjProtoSize = 52;
const int resourceActProtoSize = 86;
@@ -2521,7 +2450,7 @@ void initPrototypes(void) {
objectProtos = (ProtoObj *)malloc(objectProtoCount * sizeof (ProtoObj));
- if (listRes->seek(objProtoID) == 0)
+ if ((stream = loadResourceToStream(listRes, objProtoID, "object prototypes")) == nullptr)
error("Unable to load Object Prototypes");
// Load each individual prototype. Read in everything except
@@ -2531,7 +2460,7 @@ void initPrototypes(void) {
ResourceObjectPrototype ro;
ProtoObj *pr = &objectProtos[i];
- readObjectPrototype(listRes, ro);
+ ro.load(stream);
switch (ro.classType) {
case protoClassInventory:
@@ -2657,6 +2586,7 @@ void initPrototypes(void) {
}
listRes->rest();
+ delete stream;
// Load the Actor prototype table
@@ -2668,19 +2598,20 @@ void initPrototypes(void) {
actorProtos = (ActorProto *)malloc(actorProtoCount * sizeof(ActorProto));
- if (listRes->seek(actorProtoID) == 0)
+ if ((stream = loadResourceToStream(listRes, actorProtoID, "actor prototypes")) == nullptr)
error("Unable to load Actor Prototypes");
for (int i = 0; i < actorProtoCount; i++) {
ResourceActorPrototype ra;
ActorProto *pr = &actorProtos[i];
- readActorPrototype(listRes, ra);
+ ra.load(stream);
new (pr) ActorProto(ra);
}
listRes->rest();
+ delete stream;
}
//-------------------------------------------------------------------
diff --git a/engines/saga2/objproto.h b/engines/saga2/objproto.h
index 217c349e7b..de0cd01def 100644
--- a/engines/saga2/objproto.h
+++ b/engines/saga2/objproto.h
@@ -285,6 +285,46 @@ struct ResourceObjectPrototype {
for (int i = 0; i < 7; ++i)
reserved[i] = proto.reserved[i];
}
+
+ void load(Common::SeekableReadStream *stream) {
+ classType = stream->readSint16LE();
+ script = stream->readUint16LE();
+ nameIndex = stream->readSint16LE();
+ iconSprite = stream->readUint16LE();
+ groundSprite = stream->readUint16LE();
+
+ for (int i = 0; i < 4; ++i)
+ colorMap[i] = stream->readByte();
+
+ mass = stream->readByte();
+ bulk = stream->readByte();
+ crossSection = stream->readByte();
+ height = stream->readByte();
+ toughness = stream->readByte();
+ breakType = stream->readByte();
+ maxCapacity = stream->readUint16LE();
+ lockType = stream->readByte();
+ acceptableItems = stream->readByte();
+ weaponDamage = stream->readByte();
+ weaponFireRate = stream->readByte();
+ maximumRange = stream->readByte();
+ missileType = stream->readByte();
+ whereWearable = stream->readByte();
+ damageAbsorbtion = stream->readSByte();
+ damageDivider = stream->readSByte();
+ defenseBonus = stream->readSByte();
+ maxCharges = stream->readByte();
+ chargeType = stream->readByte();
+ flags = stream->readSint16LE();
+ price = stream->readSint16LE();
+ heldSpriteBase = stream->readSint16LE(); // union
+ resistance = stream->readSint16LE();
+ immunity = stream->readSint16LE();
+ soundFXClass = stream->readByte();
+
+ for (int i = 0; i < 7; ++i)
+ reserved[i] = stream->readByte();
+ }
};
class ProtoObj : public ResourceObjectPrototype {
Commit: e659aa14d3cb2bc0e2e6a7d8e72efc6d6ab5b9e2
https://github.com/scummvm/scummvm/commit/e659aa14d3cb2bc0e2e6a7d8e72efc6d6ab5b9e2
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:30+02:00
Commit Message:
SAGA2: Load more stuff with stream
Changed paths:
engines/saga2/objects.cpp
engines/saga2/tile.cpp
engines/saga2/tile.h
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index e392d49889..8e323a01ee 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -2312,10 +2312,12 @@ uint16 GameObject::totalContainedBulk(void) {
// Initial constructor
GameWorld::GameWorld(int16 map) {
- if (tileRes->seek(MKTAG('M', 'A', 'P', (char)map))) {
+ Common::SeekableReadStream *stream;
+ if (stream = loadResourceToStream(tileRes, MKTAG('M', 'A', 'P', (char)map),
+ "game map")) {
int16 mapSize; // Size of map in MetaTiles
- mapSize = tileRes->readU16LE();
+ mapSize = stream->readUint16LE();
size.u = (mapSize << kPlatShift) << kTileUVShift;
size.v = size.u;
@@ -2326,6 +2328,7 @@ GameWorld::GameWorld(int16 map) {
error("Unable to allocate world %d sector array", map);
mapNum = map;
+ delete stream;
} else {
size.u = size.v = 0;
sectorArraySize = 0;
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 4a74a8ada8..0e1a6fe94e 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -2298,24 +2298,11 @@ metaTileNoise MetaTile::HeavyMetaMusic(void) {
//-----------------------------------------------------------------------
// Return a pointer to the specified platform
-static void readPlatform(hResContext *con, Platform &plt) {
- plt.height = con->readU16LE();
- plt.highestPixel = con->readU16LE();
- plt.flags = con->readU16LE();
-
- for (int j = 0; j < kPlatformWidth; ++j) {
- for (int i = 0; i < kPlatformWidth; ++i) {
- plt.tiles[j][i].tile = con->readU16LE();
- plt.tiles[j][i].flags = con->readByte();
- plt.tiles[j][i].tileHeight = con->readByte();
- }
- }
-}
-
Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
const int cacheFlag = 0x8000;
uint16 plIndex = _stack[layer];
PlatformCacheEntry *pce;
+ Common::SeekableReadStream *stream;
assert(layer >= 0);
assert(_parent == mapList[mapNum].metaList);
@@ -2376,9 +2363,9 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
debugC(3, kDebugLoading, "- plIndex: %d", plIndex);
// Now, load the actual metatile data...
- if (tileRes->seek(platformID + mapNum)) {
- if (tileRes->skip(plIndex * sizeof(Platform))) {
- readPlatform(tileRes, pce->pl);
+ if (stream = loadResourceToStream(tileRes, platformID + mapNum, "platform")) {
+ if (stream->skip(plIndex * sizeof(Platform))) {
+ pce->pl.load(stream);
return &pce->pl;
}
}
@@ -4396,31 +4383,23 @@ struct TileCycleArchive {
//-----------------------------------------------------------------------
// Initialize the tile cycling state array
-static void readCycle(hResContext *con, TileCycleData &cyc) {
- cyc.counter = con->readS32LE();
- cyc.pad = con->readByte();
- cyc.numStates = con->readByte();
- cyc.currentState = con->readByte();
- cyc.cycleSpeed = con->readByte();
-
- for (int i = 0; i < 16; ++i)
- cyc.cycleList[i] = con->readU16LE();
-}
-
void initTileCyclingStates(void) {
+ Common::SeekableReadStream *stream;
const int tileCycleDataSize = 40;
cycleCount = tileRes->size(cycleID) / tileCycleDataSize;
cycleList = new TileCycleData[cycleCount];
- tileRes->seek(cycleID);
- for (int i = 0; i < cycleCount; ++i)
- readCycle(tileRes, cycleList[i]);
-
- debugC(2, kDebugLoading, "Loaded Cycles: cycleCount = %d", cycleCount);
if (cycleList == nullptr)
error("Unable to load tile cycling data");
+ if (stream = loadResourceToStream(tileRes, cycleID, "cycle list")) {
+ for (int i = 0; i < cycleCount; ++i)
+ cycleList[i].load(stream);
+
+ debugC(2, kDebugLoading, "Loaded Cycles: cycleCount = %d", cycleCount);
+ delete stream;
+ }
}
//-----------------------------------------------------------------------
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index a738ffb02c..9ad6ad5101 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -316,6 +316,17 @@ public:
cycleSpeed; // speed of cycling (0=none)
TileID cycleList[16]; // array of tiles
+
+ void load(Common::SeekableReadStream *stream) {
+ counter = stream->readSint32LE();
+ pad = stream->readByte();
+ numStates = stream->readByte();
+ currentState = stream->readByte();
+ cycleSpeed = stream->readByte();
+
+ for (int i = 0; i < 16; ++i)
+ cycleList[i] = stream->readUint16LE();
+ }
};
typedef TileCycleData
@@ -648,6 +659,20 @@ struct Platform {
uint16 flags; // platform flags
TileRef tiles[kPlatformWidth][kPlatformWidth];
+ void load(Common::SeekableReadStream *stream) {
+ height = stream->readUint16LE();
+ highestPixel = stream->readUint16LE();
+ flags = stream->readUint16LE();
+
+ for (int j = 0; j < kPlatformWidth; ++j) {
+ for (int i = 0; i < kPlatformWidth; ++i) {
+ tiles[j][i].tile = stream->readUint16LE();
+ tiles[j][i].flags = stream->readByte();
+ tiles[j][i].tileHeight = stream->readByte();
+ }
+ }
+ }
+
TileRef &getTileRef(const TilePoint p) {
return tiles[p.u][p.v];
}
Commit: e90a71d2fdc589e08c30842ba7aac0439bda7367
https://github.com/scummvm/scummvm/commit/e90a71d2fdc589e08c30842ba7aac0439bda7367
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:31+02:00
Commit Message:
SAGA2: Kill hResContext read* functions
Changed paths:
engines/saga2/hresmgr.cpp
engines/saga2/hresmgr.h
engines/saga2/tile.cpp
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index 3c6769018f..bfb753eaf1 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -214,76 +214,6 @@ void hResContext::rest(void) {
}
}
-uint8 hResContext::readByte() {
- if (!_handle)
- return 0;
-
- if (!_handle->isOpen())
- return 0;
-
- return _handle->readByte();
-}
-
-int8 hResContext::readSByte() {
- if (!_handle)
- return 0;
-
- if (!_handle->isOpen())
- return 0;
-
- return _handle->readSByte();
-}
-
-uint16 hResContext::readU16LE() {
- if (!_handle)
- return 0;
-
- if (!_handle->isOpen())
- return 0;
-
- return _handle->readUint16LE();
-}
-
-int16 hResContext::readS16LE() {
- if (!_handle)
- return 0;
-
- if (!_handle->isOpen())
- return 0;
-
- return _handle->readSint16LE();
-}
-
-uint32 hResContext::readU32LE() {
- if (!_handle)
- return 0;
-
- if (!_handle->isOpen())
- return 0;
-
- return _handle->readUint32LE();
-}
-
-int32 hResContext::readS32LE() {
- if (!_handle)
- return 0;
-
- if (!_handle->isOpen())
- return 0;
-
- return _handle->readSint32LE();
-}
-
-int32 hResContext::readS32BE() {
- if (!_handle)
- return 0;
-
- if (!_handle->isOpen())
- return 0;
-
- return _handle->readSint32BE();
-}
-
bool hResContext::read(void *buffer, uint32 size) {
assert(_handle);
if (!_valid) return false;
diff --git a/engines/saga2/hresmgr.h b/engines/saga2/hresmgr.h
index 0541c6c841..07ab2b443c 100644
--- a/engines/saga2/hresmgr.h
+++ b/engines/saga2/hresmgr.h
@@ -155,13 +155,6 @@ public:
inline size_t bytesleft(void) {
return _bytecount;
}
- uint8 readByte();
- int8 readSByte();
- uint16 readU16LE();
- int16 readS16LE();
- uint32 readU32LE();
- int32 readS32LE();
- int32 readS32BE();
bool read(void *buffer, uint32 size);
bool skip(uint32 amount);
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 0e1a6fe94e..e3c731db9e 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -1573,12 +1573,13 @@ void initMaps(void) {
if (mapData->activeItemData == nullptr)
error("Unable to load active item data");
- tileRes->seek(iTagRefID);
+ stream = loadResourceToStream(tileRes, iTagRefID, "active item data");
for (int k = 0; k < tileRefCount; ++k) {
- mapData->activeItemData[k].tile = tileRes->readU16LE();
- mapData->activeItemData[k].flags = tileRes->readByte();
- mapData->activeItemData[k].tileHeight = tileRes->readByte();
+ mapData->activeItemData[k].tile = stream->readUint16LE();
+ mapData->activeItemData[k].flags = stream->readByte();
+ mapData->activeItemData[k].tileHeight = stream->readByte();
}
+ delete stream;
} else
mapData->activeItemData = nullptr;
@@ -1589,9 +1590,9 @@ void initMaps(void) {
if (mapData->assocList == nullptr)
error("Unable to load association list");
- tileRes->seek(iAssocID);
+ stream = loadResourceToStream(tileRes, iAssocID, "association list");
for (int k = 0; k < assocCount; ++k)
- mapData->assocList[k] = tileRes->readU16LE();
+ mapData->assocList[k] = stream->readUint16LE();
} else
mapData->assocList = nullptr;
Commit: 44c4ad38e982e4329a3a51b84d161a19ccf298fa
https://github.com/scummvm/scummvm/commit/44c4ad38e982e4329a3a51b84d161a19ccf298fa
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:31+02:00
Commit Message:
SAGA2: Fix rest of the non-global-constructor warnings
Changed paths:
engines/saga2/gtext.cpp
engines/saga2/gtextbox.cpp
engines/saga2/gtextbox.h
engines/saga2/hresmgr.cpp
engines/saga2/interp.cpp
engines/saga2/intrface.cpp
engines/saga2/intrface.h
engines/saga2/keybored.cpp
engines/saga2/objects.cpp
engines/saga2/objproto.cpp
engines/saga2/playmode.cpp
engines/saga2/tile.cpp
diff --git a/engines/saga2/gtext.cpp b/engines/saga2/gtext.cpp
index 386348243d..d4a603ff03 100644
--- a/engines/saga2/gtext.cpp
+++ b/engines/saga2/gtext.cpp
@@ -284,12 +284,12 @@ void gPort::drawStringChars(
gPixelMap &dest,
int xpos, // x position to draw it
int ypos) { // y position to draw it
- uint8 *s, // pointer to string
- drawchar; // char to draw
+ const char *s; // pointer to string
+ uint8 drawchar; // char to draw
int16 x; // current x position
uint8 *buffer, // buffer to render to
*uBuffer; // underline buffer
- uint16 rowMod = dest.size.x; // row modulus of dest
+ uint16 drowMod = dest.size.x; // row modulus of dest
int16 i; // loop index
uint8 underbar = (textStyles & textStyleBar) != 0;
bool underscore;
@@ -299,35 +299,35 @@ void gPort::drawStringChars(
underPos = font->baseLine + 2;
if (underPos > font->height) underPos = font->height;
- buffer = dest.data + (ypos * rowMod);
- uBuffer = buffer + (underPos * rowMod);
+ buffer = dest.data + (ypos * drowMod);
+ uBuffer = buffer + (underPos * drowMod);
// draw drop-shadow, if any
if (textStyles & textStyleShadow) {
x = xpos - 1;
- s = (uint8 *)str;
+ s = str;
if (textStyles & textStyleOutline) { // if outlining
for (i = 0; i < len; i++) {
drawchar = *s++; // draw thick drop shadow
x += font->charKern[drawchar];
- DrawChar3x3Outline(font, drawchar, x, buffer, shPen, rowMod);
+ DrawChar3x3Outline(font, drawchar, x, buffer, shPen, drowMod);
x += font->charSpace[drawchar] + textSpacing;
}
} else if (textStyles & textStyleThickOutline) { // if outlining
for (i = 0; i < len; i++) {
drawchar = *s++; // draw thick drop shadow
x += font->charKern[drawchar];
- DrawChar5x5Outline(font, drawchar, x, buffer, shPen, rowMod);
+ DrawChar5x5Outline(font, drawchar, x, buffer, shPen, drowMod);
x += font->charSpace[drawchar] + textSpacing;
}
} else {
for (i = 0; i < len; i++) {
drawchar = *s++; // draw thick drop shadow
x += font->charKern[drawchar];
- DrawChar(font, drawchar, x, buffer + rowMod,
- shPen, rowMod);
+ DrawChar(font, drawchar, x, buffer + drowMod,
+ shPen, drowMod);
x += font->charSpace[drawchar] + textSpacing;
}
}
@@ -337,24 +337,24 @@ void gPort::drawStringChars(
if (textStyles & textStyleOutline) { // if outlining
x = xpos;
- s = (uint8 *)str;
+ s = str;
for (i = 0; i < len; i++) {
drawchar = *s++; // draw thick text
x += font->charKern[drawchar];
- DrawChar3x3Outline(font, drawchar, x, buffer - rowMod,
- olPen, rowMod);
+ DrawChar3x3Outline(font, drawchar, x, buffer - drowMod,
+ olPen, drowMod);
x += font->charSpace[drawchar] + textSpacing;
}
} else if (textStyles & textStyleThickOutline) { // if thick outlining
x = xpos;
- s = (uint8 *)str;
+ s = str;
for (i = 0; i < len; i++) {
drawchar = *s++; // draw extra thick text
x += font->charKern[drawchar];
- DrawChar5x5Outline(font, drawchar, x, buffer - rowMod * 2,
- olPen, rowMod);
+ DrawChar5x5Outline(font, drawchar, x, buffer - drowMod * 2,
+ olPen, drowMod);
x += font->charSpace[drawchar] + textSpacing;
}
}
@@ -362,7 +362,7 @@ void gPort::drawStringChars(
// draw inner part
x = xpos;
- s = (uint8 *)str;
+ s = str;
underscore = textStyles & textStyleUnderScore ? true : false;
for (i = 0; i < len; i++) {
@@ -377,7 +377,7 @@ void gPort::drawStringChars(
if (textStyles & textStyleHiLiteBar) color = bgPen;
}
x += font->charKern[drawchar];
- DrawChar(font, drawchar, x, buffer, color, rowMod);
+ DrawChar(font, drawchar, x, buffer, color, drowMod);
x += font->charSpace[drawchar] + textSpacing;
if (underscore) { // draw underscore
@@ -453,8 +453,8 @@ int16 gPort::drawClippedString(
// Handle special case of negative kern value of 1st character
- if (font->charKern[s[0]] < 0) {
- int16 kern = - font->charKern[s[0]];
+ if (font->charKern[(byte)s[0]] < 0) {
+ int16 kern = - font->charKern[(byte)s[0]];
clipWidth += kern; // increase size of map to render
xoff += kern; // offset text into map right
diff --git a/engines/saga2/gtextbox.cpp b/engines/saga2/gtextbox.cpp
index 7e060d6649..9a5d04f6f8 100644
--- a/engines/saga2/gtextbox.cpp
+++ b/engines/saga2/gtextbox.cpp
@@ -568,7 +568,6 @@ bool gTextBox::pointerHit(gPanelMessage &msg) {
if (Rect16(0, 0, extent.width, extent.height).ptInside(pos)) {
- Rect16 textBoxExtent = editRect;
int8 newIndex;
// get the position of the line
newIndex = clamp(0, pos.y / fontOffset, linesPerPage - 1);
@@ -646,7 +645,6 @@ bool gTextBox::keyStroke(gPanelMessage &msg) {
// Process the various keystrokes...
if (editing && cursorPos > anchorPos) {
- int16 t = cursorPos;
cursorPos = anchorPos;
anchorPos = cursorPos;
}
@@ -905,13 +903,13 @@ void gTextBox::drawContents(void) {
// Allocate a temporary pixel map and render into it.
if (NewTempPort(tPort, editRect.width, editRect.height)) {
int16 cursorX,
- anchorX,
+ anchorX = 0,
hiliteX,
hiliteWidth,
- textHeight;
+ textHeight_;
- textHeight = fontHeight;
+ textHeight_ = fontHeight;
if (hilit || editing) {
@@ -978,7 +976,7 @@ void gTextBox::drawContents(void) {
tPort.setFont(textFont);
tPort.setColor(fontColorHilite);
- tPort.moveTo(-scrollPixels, (editRect.height - textHeight + 1) / 2);
+ tPort.moveTo(-scrollPixels, (editRect.height - textHeight_ + 1) / 2);
tPort.drawText(fieldStrings[index], currentLen[index]);
// Blit the pixelmap to the main screen
diff --git a/engines/saga2/gtextbox.h b/engines/saga2/gtextbox.h
index 8198f1d049..2cf74b2955 100644
--- a/engines/saga2/gtextbox.h
+++ b/engines/saga2/gtextbox.h
@@ -26,6 +26,7 @@
#ifndef SAGA2_GTEXTBOX_H
#define SAGA2_GTEXTBOX_H
+
namespace Saga2 {
enum textBoxFlags {
@@ -65,7 +66,6 @@ class gTextBox : public gControl {
private:
char **fieldStrings;
- void *bufRef;
char *undoBuffer; // undo buffer for editing
bool internalBuffer;
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index bfb753eaf1..7e687be83f 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -95,7 +95,7 @@ hResContext::hResContext(hResContext *sire, hResID id, const char desc[]) {
_base = (hResEntry *)((uint8*)_res->_table + entry->offset - _res->_firstGroupOffset);
debugC(3, kDebugResources, "- _numEntries = %d, _base = %p, entry->offset = %d",
- _numEntries, _base, entry->offset);
+ _numEntries, (void *)_base, entry->offset);
_valid = true;
}
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 1005e59315..0ce5692e52 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -73,7 +73,7 @@ int16 lastExport;
extern hResource *scriptResFile; // script resources
hResContext *scriptRes; // script resource handle
-void script_error(char *msg) {
+void script_error(const char *msg) {
thisThread->flags |= Thread::aborted;
WriteStatusF(0, msg);
}
@@ -302,7 +302,7 @@ uint8 *byteAddress(Thread *th, uint8 **pcPtr) {
return segmentAddress(seg, index) + offset;
}
- error("byteAddress: Invalid addressing mode: %d.\n", *pcPtr);
+ error("byteAddress: Invalid addressing mode: %d.\n", **pcPtr);
}
// Returns the address of an object given an addressing mode
@@ -376,7 +376,7 @@ uint8 *objectAddress(
break;
default:
- error("objectAddress: Invalid addressing mode: %d.\n", *pcPtr);
+ error("objectAddress: Invalid addressing mode: %d.\n", **pcPtr);
}
offs = index;
@@ -443,7 +443,7 @@ uint8 *bitAddress(Thread *th, uint8 **pcPtr, int16 *mask) {
error("Addressing relative to 'this' not supported just yet.\n");
}
- error("bitAddress: Invalid addressing mode: %d.\n", *pcPtr);
+ error("bitAddress: Invalid addressing mode: %d.\n", **pcPtr);
}
// Returns the address of a string
@@ -577,7 +577,8 @@ bool Thread::interpret(void) {
switch (op = *pc++) {
case op_dup:
D_OP(op_dup);
- *--stack = stack[0]; // duplicate value on stack
+ --stack;
+ *stack = stack[1]; // duplicate value on stack
break;
case op_drop: // drop word on stack
@@ -1582,7 +1583,6 @@ void Thread::dispatch(void) {
numWaitSemi = 0,
numWaitOther = 0;
-#if DEBUG
for (th = threadList.first(); th; th = threadList.next(th)) {
if (th->flags & waiting) {
switch (th->waitType) {
@@ -1604,8 +1604,7 @@ void Thread::dispatch(void) {
numThreads++;
}
- WriteStatusF(17, "Threads:%d X:%d D:%d F:%d T:%d O:%d", numThreads, numExecute, numWaitDelay, numWaitFrames, numWaitSemi, numWaitOther);
-#endif
+ debugC(2, kDebugScripts, "Threads:%d X:%d D:%d F:%d T:%d O:%d", numThreads, numExecute, numWaitDelay, numWaitFrames, numWaitSemi, numWaitOther);
for (th = threadList.first(); th; th = nextThread) {
nextThread = threadList.next(th);
@@ -1638,6 +1637,8 @@ void Thread::dispatch(void) {
((ActiveItem *)th->waitParam)->setExclusive(true);
}
break;
+ default:
+ break;
}
}
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index f2ab3cd5b1..597a7b33a4 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -690,7 +690,7 @@ void CPortrait::getStateString(char buf[], int8 size, uint16 brotherID) {
// status line class
CStatusLine::CStatusLine(gPanelList &list,
const Rect16 &box,
- char *msg,
+ const char *msg,
gFont *font,
int16 textPos,
textPallete &pal,
@@ -896,8 +896,6 @@ void CMassWeightIndicator::recalculate(void) {
** weight/bulk control ( so it refreshes )
**/
void CMassWeightIndicator::update(void) {
- CMassWeightIndicator *indNode = nullptr;
-
if (bRedraw == true) {
for (Common::List<CMassWeightIndicator *>::iterator it = indList.begin(); it != indList.end(); ++it) {
(*it)->recalculate();
diff --git a/engines/saga2/intrface.h b/engines/saga2/intrface.h
index 1ff8ef7b57..059f559b71 100644
--- a/engines/saga2/intrface.h
+++ b/engines/saga2/intrface.h
@@ -238,7 +238,7 @@ private:
}
public:
- CStatusLine(gPanelList &, const Rect16 &, char *, gFont *,
+ CStatusLine(gPanelList &, const Rect16 &, const char *, gFont *,
int16, textPallete &, int32, int16, AppFunc *cmd = NULL);
~CStatusLine(void);
diff --git a/engines/saga2/keybored.cpp b/engines/saga2/keybored.cpp
index 4999a0808b..7e6d92d19e 100644
--- a/engines/saga2/keybored.cpp
+++ b/engines/saga2/keybored.cpp
@@ -36,13 +36,8 @@
#define TEST1 1 // enable test code
#define TEST2 1
-#define TEST3 1 // loading/saving
#define CHEATMOVE 1 // For moving with keypad in 8 directions
-#if TEST3
-#include "saga2/loadsave.h"
-#endif
-
#ifdef ALEXS
#include "saga2/automap.h"
#include "saga2/uidialog.h"
@@ -114,7 +109,6 @@ void TileModeHandleKey(int16 key, int16 /* qual */) {
Actor *a = getCenterActor();
Location l(a->getLocation(), a->IDParent());
- GameObject *object = (GameObject *)getCenterActor();
#ifdef FTA
static int Object = 2;
#endif
@@ -186,26 +180,6 @@ void TileModeHandleKey(int16 key, int16 /* qual */) {
#endif
-#if TEST3
- case '5':
- saveGameState(0, "game 1");
- break;
-
- case '6':
- saveGameState(1, "game 2");
- break;
-
- case '%':
- cleanupGameState();
- loadSavedGameState(0);
- break;
-
- case '^':
- cleanupGameState();
- loadSavedGameState(1);
- break;
-#endif
-
#ifdef FTA
case 'a':
if (++Object < 8) {
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 8e323a01ee..a3c74afaf0 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -2313,8 +2313,7 @@ uint16 GameObject::totalContainedBulk(void) {
GameWorld::GameWorld(int16 map) {
Common::SeekableReadStream *stream;
- if (stream = loadResourceToStream(tileRes, MKTAG('M', 'A', 'P', (char)map),
- "game map")) {
+ if ((stream = loadResourceToStream(tileRes, MKTAG('M', 'A', 'P', (char)map), "game map"))) {
int16 mapSize; // Size of map in MetaTiles
mapSize = stream->readUint16LE();
diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp
index 791f8114ca..2ebec42a41 100644
--- a/engines/saga2/objproto.cpp
+++ b/engines/saga2/objproto.cpp
@@ -418,15 +418,6 @@ bool ProtoObj::dropOn(
assert(target != NULL);
assert(isWorld(loc.context));
- int16 scriptResult;
- /*
- // Handle object script in a standard fashion
- if ( ( scriptResult = stdActionScript(
- Method_GameObject_onDropOnTAG,
- dObj, enactor, target ) )
- != actionResultNotDone )
- return scriptResult == actionResultSuccess;
- */
return dropOnAction(dObj, enactor, target, loc, num);
}
@@ -627,19 +618,12 @@ bool ProtoObj::acceptHealing(
int8 perDieMod) {
int8 pdm = perDieMod;
int16 damage = 0;
- int16 scriptResult;
assert(dObj != Nothing);
damage = absDamage;
if (dice)
for (int d = 0; d < abs(dice); d++)
damage += (g_vm->_rnd->getRandomNumber(sides - 1) + pdm + 1) * (dice > 0 ? 1 : -1);
-#if 0
- if ((scriptResult = stdActionScript(
- Method_GameObject_onAcceptDamage,
- dObj, enactor, Nothing))
- != actionResultNotDone)
- return scriptResult == actionResultSuccess;
-#endif
+
return acceptHealingAction(dObj, enactor, damage);
}
@@ -1091,7 +1075,6 @@ bool InventoryProto::dropAction(
ProtoObj *enactorProto = enactorPtr->proto();
TilePoint enactorLoc(enactorPtr->getLocation());
TilePoint vector = loc - enactorLoc;
- StandingTileInfo sti;
GameObject *extractedObj = NULL;
// Split the merged object if needed.
@@ -1468,13 +1451,9 @@ bool KeyProto::setUseCursor(ObjectID dObj) {
// Send acceptLockToggle message to container
bool KeyProto::useOnAction(ObjectID dObj, ObjectID enactor, ObjectID withObj) {
- GameObject *container = GameObject::objectAddress(withObj),
- *thisKey = GameObject::objectAddress(dObj);
-
- int16 keyID = thisKey->_data.massCount > 0 ? thisKey->_data.massCount : lockType;
+ GameObject *container = GameObject::objectAddress(withObj);
if (!container->acceptLockToggle(enactor, lockType)) {
-// WriteStatusF( 3, "%s doesn't work", thisKey->objName() );
return false;
}
@@ -1580,7 +1559,6 @@ bool MeleeWeaponProto::useAction(ObjectID dObj, ObjectID enactor) {
a->holdInRightHand(Nothing);
else {
GameObject *leftHandObjectPtr;
- ProtoObj *leftHandProto;
leftHandObjectPtr = a->leftHandObject != Nothing
? GameObject::objectAddress(a->leftHandObject)
@@ -2257,7 +2235,6 @@ bool ArmorProto::useSlotAvailable(GameObject *obj, Actor *a) {
bool ArmorProto::useAction(ObjectID dObj, ObjectID enactor) {
assert(isObject(dObj));
assert(isActor(enactor));
- PlayerActorID pID;
Actor *a = (Actor *)GameObject::objectAddress(enactor);
GameObject *obj = GameObject::objectAddress(dObj);
@@ -2663,9 +2640,6 @@ uint16 SkillProto::containmentSet(void) {
}
bool SkillProto::useAction(ObjectID dObj, ObjectID enactor) {
- //GameObject *spellPtr = GameObject::objectAddress( dObj );
- SpellStuff &sp = spellBook[getSpellID()];
-
if (nonUsable(this))
return false;
@@ -3024,18 +2998,15 @@ bool IntangibleContainerProto::canOpen(ObjectID dObj, ObjectID) {
// Open a intangible container
bool IntangibleContainerProto::openAction(ObjectID dObj, ObjectID enactor) {
ContainerNode *cn;
- GameObject *dObjPtr = GameObject::objectAddress(dObj);
// Perform appropriate opening tasks
cn = CreateContainerNode(enactor, false);
cn->markForShow();
-// dObjPtr->_data.objectFlags |= GameObject::objectOpen; // Set open bit;
return true;
}
bool IntangibleContainerProto::closeAction(ObjectID dObj, ObjectID) {
- GameObject *dObjPtr = GameObject::objectAddress(dObj);
ContainerNode *cn = globalContainerList.find(dObj, ContainerNode::mentalType);
assert(cn);
@@ -3043,9 +3014,6 @@ bool IntangibleContainerProto::closeAction(ObjectID dObj, ObjectID) {
// Mark container for lazy deletion
cn->markForDelete();
- // Clear open bit
-// dObjPtr->_data.objectFlags &= ~GameObject::objectOpen;
-
return true;
}
diff --git a/engines/saga2/playmode.cpp b/engines/saga2/playmode.cpp
index 953bad2ad1..2255082ef1 100644
--- a/engines/saga2/playmode.cpp
+++ b/engines/saga2/playmode.cpp
@@ -37,8 +37,7 @@
namespace Saga2 {
-const uint32 imageGroupID = MKTAG('I', 'M', 'A', 'G'),
- borderID = MKTAG('B', 'R', 'D', 0);
+const uint32 imageGroupID = MKTAG('I', 'M', 'A', 'G');
const int defaultStatusWait = 15;
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index e3c731db9e..6eadd5b434 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -2364,7 +2364,7 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
debugC(3, kDebugLoading, "- plIndex: %d", plIndex);
// Now, load the actual metatile data...
- if (stream = loadResourceToStream(tileRes, platformID + mapNum, "platform")) {
+ if ((stream = loadResourceToStream(tileRes, platformID + mapNum, "platform"))) {
if (stream->skip(plIndex * sizeof(Platform))) {
pce->pl.load(stream);
return &pce->pl;
@@ -4394,7 +4394,7 @@ void initTileCyclingStates(void) {
if (cycleList == nullptr)
error("Unable to load tile cycling data");
- if (stream = loadResourceToStream(tileRes, cycleID, "cycle list")) {
+ if ((stream = loadResourceToStream(tileRes, cycleID, "cycle list"))) {
for (int i = 0; i < cycleCount; ++i)
cycleList[i].load(stream);
Commit: 37bd0e9c380f161f7f926fda7b124338681a2d08
https://github.com/scummvm/scummvm/commit/37bd0e9c380f161f7f926fda7b124338681a2d08
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:31+02:00
Commit Message:
SAGA2: Replace elementsof with ARRAYSIZE
Changed paths:
engines/saga2/actor.cpp
engines/saga2/automap.cpp
engines/saga2/band.cpp
engines/saga2/band.h
engines/saga2/contain.cpp
engines/saga2/dispnode.cpp
engines/saga2/document.cpp
engines/saga2/intrface.cpp
engines/saga2/mission.cpp
engines/saga2/mission.h
engines/saga2/motion.cpp
engines/saga2/objects.cpp
engines/saga2/objproto.cpp
engines/saga2/path.cpp
engines/saga2/player.cpp
engines/saga2/sagafunc.cpp
engines/saga2/sensor.cpp
engines/saga2/speech.cpp
engines/saga2/sprite.cpp
engines/saga2/std.h
engines/saga2/task.cpp
engines/saga2/tile.cpp
engines/saga2/tilemode.cpp
engines/saga2/uidialog.cpp
engines/saga2/videobox.cpp
engines/saga2/vpal.cpp
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 927ca73b69..d02e1029d4 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -1330,7 +1330,7 @@ void *Actor::archive(void *buf) {
a->currentRecoveryPoints = currentRecoveryPoints;
a->leaderID = leader != NULL ? leader->thisID() : Nothing;
a->followersID = followers != NULL ? getBandID(followers) : NoBand;
- for (i = 0; i < elementsof(a->armorObjects); i++)
+ for (i = 0; i < ARRAYSIZE(a->armorObjects); i++)
a->armorObjects[i] = armorObjects[i];
a->currentTargetID = currentTarget != NULL ? currentTarget->thisID() : Nothing;
for (i = 0; i < actorScriptVars; i++)
@@ -3076,7 +3076,7 @@ bool Actor::pathFindState(void) {
// Add knowledge package to actor
bool Actor::addKnowledge(uint16 kID) {
- for (int i = 0; i < elementsof(knowledge); i++) {
+ for (int i = 0; i < ARRAYSIZE(knowledge); i++) {
if (knowledge[i] == 0) {
knowledge[i] = kID;
return true;
@@ -3089,7 +3089,7 @@ bool Actor::addKnowledge(uint16 kID) {
// Remove knowledge package from actor
bool Actor::removeKnowledge(uint16 kID) {
- for (int i = 0; i < elementsof(knowledge); i++) {
+ for (int i = 0; i < ARRAYSIZE(knowledge); i++) {
if (knowledge[i] == kID) {
knowledge[i] = 0;
return true;
@@ -3102,7 +3102,7 @@ bool Actor::removeKnowledge(uint16 kID) {
// Remove all knowledge package from actor
void Actor::clearKnowledge(void) {
- for (int i = 0; i < elementsof(knowledge); i++) {
+ for (int i = 0; i < ARRAYSIZE(knowledge); i++) {
knowledge[i] = 0;
}
}
@@ -3117,7 +3117,7 @@ void Actor::useKnowledge(scriptCallFrame &scf) {
// First, search for the class with the best response
- for (int i = 0; i < elementsof(knowledge); i++) {
+ for (int i = 0; i < ARRAYSIZE(knowledge); i++) {
if (knowledge[i]) {
scriptResult res;
diff --git a/engines/saga2/automap.cpp b/engines/saga2/automap.cpp
index 1e11dc8a20..c05678da03 100644
--- a/engines/saga2/automap.cpp
+++ b/engines/saga2/automap.cpp
@@ -551,7 +551,7 @@ int16 openAutoMap() {
scrollBtn = new gCompButton(*pAutoMap, scrollBtnRect, scrollBtnImage, numBtnImages, 0, cmdAutoMapScroll);
pAutoMap->setDecorations(autoMapDecorations,
- elementsof(autoMapDecorations),
+ ARRAYSIZE(autoMapDecorations),
decRes, 'M', 'A', 'P');
// attach the structure to the book
diff --git a/engines/saga2/band.cpp b/engines/saga2/band.cpp
index 1ea0aacd8a..a1c0ee1d8d 100644
--- a/engines/saga2/band.cpp
+++ b/engines/saga2/band.cpp
@@ -105,7 +105,7 @@ public:
BandList::BandList(void) {
int i;
- for (i = 0; i < elementsof(array); i++)
+ for (i = 0; i < ARRAYSIZE(array); i++)
free.addTail(array[i]);
}
@@ -222,7 +222,7 @@ void *BandList::newBand(void) {
// Place a specific Band into the active list and return its address
void *BandList::newBand(BandID id) {
- assert(id >= 0 && id < elementsof(array));
+ assert(id >= 0 && id < ARRAYSIZE(array));
BandPlaceHolder *bp;
@@ -395,7 +395,7 @@ Band::Band(void **buf) {
bufferPtr = (ObjectID *)bufferPtr + 1;
// Restore the member count
- assert(*((int16 *)bufferPtr) < elementsof(members));
+ assert(*((int16 *)bufferPtr) < ARRAYSIZE(members));
memberCount = *((int16 *)bufferPtr);
bufferPtr = (int16 *)bufferPtr + 1;
diff --git a/engines/saga2/band.h b/engines/saga2/band.h
index 14b7f40f1e..4137b386e8 100644
--- a/engines/saga2/band.h
+++ b/engines/saga2/band.h
@@ -98,7 +98,7 @@ public:
}
bool add(Actor *newMember) {
- if (memberCount < elementsof(members)) {
+ if (memberCount < ARRAYSIZE(members)) {
members[memberCount++] = newMember;
return true;
} else
diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index c5b918fcdd..30174c0a1a 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -1241,7 +1241,7 @@ TangibleContainerWindow::TangibleContainerWindow(
if (deathFlag) {
// set the decorations for this window
setDecorations(deathDecorations,
- elementsof(deathDecorations),
+ ARRAYSIZE(deathDecorations),
containerRes, 'F', 'R', 'M');
massWeightIndicator = NULL;
} else {
@@ -1258,7 +1258,7 @@ TangibleContainerWindow::TangibleContainerWindow(
// set the decorations for this window
setDecorations(winDecs[bgndType],
- elementsof(brassDecorations), // brass was arb, all should have same
+ ARRAYSIZE(brassDecorations), // brass was arb, all should have same
containerRes, 'F', 'R', 'M');
// set the userdata such that we can extract the container object later
@@ -1343,7 +1343,7 @@ IntangibleContainerWindow::IntangibleContainerWindow(
// set the decorations for this window
setDecorations(mentalDecorations,
- elementsof(mentalDecorations),
+ ARRAYSIZE(mentalDecorations),
containerRes, 'F', 'R', 'M');
setMindContainer(nd.mindType, *this);
@@ -1928,7 +1928,7 @@ void setMindContainer(int index, IntangibleContainerWindow &cw) {
ObjectID id;
assert(index >= 0);
- assert(index < elementsof(classTable));
+ assert(index < ARRAYSIZE(classTable));
int containerClass = classTable[index];
diff --git a/engines/saga2/dispnode.cpp b/engines/saga2/dispnode.cpp
index 97ac7f3494..bba75c729a 100644
--- a/engines/saga2/dispnode.cpp
+++ b/engines/saga2/dispnode.cpp
@@ -501,7 +501,7 @@ void DisplayNode::drawObject(void) {
buildColorTable(
mainColors,
bubbleColorTable,
- elementsof(bubbleColorTable));
+ ARRAYSIZE(bubbleColorTable));
if (a->kludgeCount < 0 || ++a->kludgeCount >= bubbleSpriteCount)
a->kludgeCount = 0;
diff --git a/engines/saga2/document.cpp b/engines/saga2/document.cpp
index 018efdda59..db011e695c 100644
--- a/engines/saga2/document.cpp
+++ b/engines/saga2/document.cpp
@@ -74,7 +74,7 @@ CDocumentAppearance scrollAppearance(
Rect16(0, 0, 0, 0), // (No page 2)
Rect16(184, 206, 44, 42), // Close button rect
scrollDecorations,
- elementsof(scrollDecorations),
+ ARRAYSIZE(scrollDecorations),
MKTAG('S', 'C', 'R', 'L'),
MKTAG('S', 'R', 'L', 0)
);
@@ -101,7 +101,7 @@ CDocumentAppearance bookAppearance(
Rect16(218, 26, 135, 205), // Page 2
Rect16(231, 217, 34, 27), // Close button rect
bookDecorations,
- elementsof(bookDecorations),
+ ARRAYSIZE(bookDecorations),
MKTAG('B', 'O', 'O', 'K'),
MKTAG('B', 'K', 'D', 0)
);
@@ -123,7 +123,7 @@ CDocumentAppearance parchAppearance(
Rect16(0, 0, 0, 0), // (No page 2)
Rect16(164, 229, 20, 20), // Close button rect
parchDecorations,
- elementsof(parchDecorations),
+ ARRAYSIZE(parchDecorations),
MKTAG('P', 'A', 'R', 'C'),
MKTAG('P', 'C', 'H', 0)
);
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index 597a7b33a4..c7bdcfd9e9 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -594,31 +594,31 @@ void CPortrait::getStateString(char buf[], int8 size, uint16 brotherID) {
length += appendToStr(
&buf[length],
asleepStr,
- elementsof(asleepStr) - 1,
+ ARRAYSIZE(asleepStr) - 1,
size - length - 1);
} else if (a->enchantmentFlags & (1 << actorParalyzed)) {
length += appendToStr(
&buf[length],
paralysedStr,
- elementsof(paralysedStr) - 1,
+ ARRAYSIZE(paralysedStr) - 1,
size - length - 1);
} else if (a->enchantmentFlags & (1 << actorBlind)) {
length += appendToStr(
&buf[length],
blindStr,
- elementsof(blindStr) - 1,
+ ARRAYSIZE(blindStr) - 1,
size - length - 1);
} else if (a->enchantmentFlags & (1 << actorFear)) {
length += appendToStr(
&buf[length],
afraidStr,
- elementsof(afraidStr) - 1,
+ ARRAYSIZE(afraidStr) - 1,
size - length - 1);
} else if (pa->isAggressive()) {
length += appendToStr(
&buf[length],
angryStr,
- elementsof(angryStr) - 1,
+ ARRAYSIZE(angryStr) - 1,
size - length - 1);
}
@@ -627,24 +627,24 @@ void CPortrait::getStateString(char buf[], int8 size, uint16 brotherID) {
length += appendToStr(
&buf[length],
commaStr,
- elementsof(commaStr) - 1,
+ ARRAYSIZE(commaStr) - 1,
size - length - 1);
length += appendToStr(
&buf[length],
badlyWoundedStr,
- elementsof(badlyWoundedStr) - 1,
+ ARRAYSIZE(badlyWoundedStr) - 1,
size - length - 1);
} else if (stats.vitality * 2 > a->effectiveStats.vitality * 3) {
if (length != 0)
length += appendToStr(
&buf[length],
commaStr,
- elementsof(commaStr) - 1,
+ ARRAYSIZE(commaStr) - 1,
size - length - 1);
length += appendToStr(
&buf[length],
hurtStr,
- elementsof(hurtStr) - 1,
+ ARRAYSIZE(hurtStr) - 1,
size - length - 1);
}
@@ -653,24 +653,24 @@ void CPortrait::getStateString(char buf[], int8 size, uint16 brotherID) {
length += appendToStr(
&buf[length],
commaStr,
- elementsof(commaStr) - 1,
+ ARRAYSIZE(commaStr) - 1,
size - length - 1);
length += appendToStr(
&buf[length],
poisonedStr,
- elementsof(poisonedStr) - 1,
+ ARRAYSIZE(poisonedStr) - 1,
size - length - 1);
} else if (a->enchantmentFlags & (1 << actorDiseased)) {
if (length != 0)
length += appendToStr(
&buf[length],
commaStr,
- elementsof(commaStr) - 1,
+ ARRAYSIZE(commaStr) - 1,
size - length - 1);
length += appendToStr(
&buf[length],
diseasedStr,
- elementsof(diseasedStr) - 1,
+ ARRAYSIZE(diseasedStr) - 1,
size - length - 1);
}
@@ -678,7 +678,7 @@ void CPortrait::getStateString(char buf[], int8 size, uint16 brotherID) {
length += appendToStr(
&buf[length],
normalStr,
- elementsof(normalStr) - 1,
+ ARRAYSIZE(normalStr) - 1,
size - length - 1);
}
}
@@ -705,7 +705,7 @@ CStatusLine::CStatusLine(gPanelList &list,
lineDisplayed = false;
queueHead = queueTail = 0;
- for (i = 0; i < elementsof(lineQueue); i++)
+ for (i = 0; i < ARRAYSIZE(lineQueue); i++)
lineQueue[i].text = nullptr;
}
diff --git a/engines/saga2/mission.cpp b/engines/saga2/mission.cpp
index 6332b27d1e..423d85cf80 100644
--- a/engines/saga2/mission.cpp
+++ b/engines/saga2/mission.cpp
@@ -42,7 +42,7 @@ ActiveMission *ActiveMission::newMission(ObjectID genID, uint16 script) {
int i;
ActiveMission *ms = NULL;
- for (i = 0; i < elementsof(activeMissions); i++) {
+ for (i = 0; i < ARRAYSIZE(activeMissions); i++) {
if (!(activeMissions[i]._data.missionFlags & inUse)) {
ms = &activeMissions[i];
break;
@@ -58,7 +58,7 @@ ActiveMission *ActiveMission::newMission(ObjectID genID, uint16 script) {
ms->_data.numKnowledgeIDs = ms->_data.numObjectIDs = 0;
- memset(ms->_data.missionVars, 0, elementsof(ms->_data.missionVars));
+ memset(ms->_data.missionVars, 0, ARRAYSIZE(ms->_data.missionVars));
return ms;
}
@@ -69,7 +69,7 @@ ActiveMission *ActiveMission::newMission(ObjectID genID, uint16 script) {
int ActiveMission::findMission(ObjectID genID) {
int i;
- for (i = 0; i < elementsof(activeMissions); i++) {
+ for (i = 0; i < ARRAYSIZE(activeMissions); i++) {
if (activeMissions[i]._data.missionFlags & inUse
&& activeMissions[i]._data.generatorID == genID) {
return i;
@@ -81,7 +81,7 @@ int ActiveMission::findMission(ObjectID genID) {
ActiveMission *ActiveMission::missionAddress(int index) {
assert(index >= 0);
- assert(index < elementsof(activeMissions));
+ assert(index < ARRAYSIZE(activeMissions));
return &activeMissions[index];
}
@@ -90,7 +90,7 @@ ActiveMission *ActiveMission::missionAddress(int index) {
// Add record of object creation to mission
bool ActiveMission::addObjectID(ObjectID objID) {
- if (_data.numObjectIDs < elementsof(_data.missionObjectList)) {
+ if (_data.numObjectIDs < ARRAYSIZE(_data.missionObjectList)) {
_data.missionObjectList[_data.numObjectIDs++] = objID;
return true;
}
@@ -124,7 +124,7 @@ bool ActiveMission::removeObjectID(ObjectID objID) {
bool ActiveMission::addKnowledgeID(ObjectID actor, uint16 knowledgeID) {
if (!isActor(actor)) return false;
- if (_data.numKnowledgeIDs < elementsof(_data.missionKnowledgeList)) {
+ if (_data.numKnowledgeIDs < ARRAYSIZE(_data.missionKnowledgeList)) {
Actor *a = (Actor *)GameObject::objectAddress(actor);
if (!a->addKnowledge(knowledgeID)) return false;
@@ -191,7 +191,7 @@ void ActiveMission::cleanup(void) {
void initMissions(void) {
int i;
- for (i = 0; i < elementsof(activeMissions); i++)
+ for (i = 0; i < ARRAYSIZE(activeMissions); i++)
activeMissions[i]._data.missionFlags &= ~inUse;
}
diff --git a/engines/saga2/mission.h b/engines/saga2/mission.h
index 51ea1fb58a..a9f2a47bb6 100644
--- a/engines/saga2/mission.h
+++ b/engines/saga2/mission.h
@@ -86,7 +86,7 @@ public:
void cleanup(void);
bool spaceForObject(void) {
- return _data.numObjectIDs < elementsof(_data.missionObjectList);
+ return _data.numObjectIDs < ARRAYSIZE(_data.missionObjectList);
}
// Add record of object creation to mission
diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp
index 4bb1dff55c..b188b20c29 100644
--- a/engines/saga2/motion.cpp
+++ b/engines/saga2/motion.cpp
@@ -361,7 +361,7 @@ static MotionTaskList &mTaskList = *((MotionTaskList *)mTaskListBuffer);
// Initialize the MotionTaskList
MotionTaskList::MotionTaskList(void) {
- for (int i = 0; i < elementsof(array); i++) {
+ for (int i = 0; i < ARRAYSIZE(array); i++) {
free.addTail(array[i]);
}
}
@@ -375,7 +375,7 @@ MotionTaskList::MotionTaskList(void **buf) {
int16 i,
motionTaskCount;
- for (i = 0; i < elementsof(array); i++) {
+ for (i = 0; i < ARRAYSIZE(array); i++) {
free.addTail(array[i]);
}
@@ -3283,7 +3283,7 @@ const uint8 twoHandedSwingArray[] = {
const CombatMotionSet twoHandedSwingSet =
CombatMotionSet(
twoHandedSwingArray,
- elementsof(twoHandedSwingArray));
+ ARRAYSIZE(twoHandedSwingArray));
// Construct a subset of all high two handed swing types
const uint8 twoHandedHighSwingArray[] = {
@@ -3295,7 +3295,7 @@ const uint8 twoHandedHighSwingArray[] = {
const CombatMotionSet twoHandedHighSwingSet =
CombatMotionSet(
twoHandedHighSwingArray,
- elementsof(twoHandedHighSwingArray));
+ ARRAYSIZE(twoHandedHighSwingArray));
// Construct a subset of all low two handed swing types
const uint8 twoHandedLowSwingArray[] = {
@@ -3307,7 +3307,7 @@ const uint8 twoHandedLowSwingArray[] = {
const CombatMotionSet twoHandedLowSwingSet =
CombatMotionSet(
twoHandedLowSwingArray,
- elementsof(twoHandedLowSwingArray));
+ ARRAYSIZE(twoHandedLowSwingArray));
//-----------------------------------------------------------------------
// Handle all two handed swing motions
@@ -3402,7 +3402,7 @@ const uint8 oneHandedSwingArray[] = {
const CombatMotionSet oneHandedSwingSet =
CombatMotionSet(
oneHandedSwingArray,
- elementsof(oneHandedSwingArray));
+ ARRAYSIZE(oneHandedSwingArray));
// Construct a subset of all high one handed swing types
const uint8 oneHandedHighSwingArray[] = {
@@ -3412,7 +3412,7 @@ const uint8 oneHandedHighSwingArray[] = {
const CombatMotionSet oneHandedHighSwingSet =
CombatMotionSet(
oneHandedHighSwingArray,
- elementsof(oneHandedHighSwingArray));
+ ARRAYSIZE(oneHandedHighSwingArray));
// Construct a subset of all low one handed swing types
const uint8 oneHandedLowSwingArray[] = {
@@ -3422,7 +3422,7 @@ const uint8 oneHandedLowSwingArray[] = {
const CombatMotionSet oneHandedLowSwingSet =
CombatMotionSet(
oneHandedLowSwingArray,
- elementsof(oneHandedLowSwingArray));
+ ARRAYSIZE(oneHandedLowSwingArray));
//-----------------------------------------------------------------------
// Handle all one handed swing motions
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index a3c74afaf0..d15b086866 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -1250,7 +1250,7 @@ void GameObject::deleteObject(void) {
if (a->leftHandObject == id) a->leftHandObject = Nothing;
if (a->rightHandObject == id) a->rightHandObject = Nothing;
- for (i = 0; i < elementsof(a->armorObjects); i++)
+ for (i = 0; i < ARRAYSIZE(a->armorObjects); i++)
if (a->armorObjects[i] == id)
a->wear(Nothing, i);
}
@@ -3246,7 +3246,7 @@ static ActiveRegion activeRegionList[playerActors];
void updateActiveRegions(void) {
int16 i;
- for (i = 0; i < elementsof(activeRegionList); i++)
+ for (i = 0; i < ARRAYSIZE(activeRegionList); i++)
activeRegionList[i].update();
}
@@ -3761,7 +3761,7 @@ bool ActiveRegionObjectIterator::nextActiveRegion(void) {
TilePoint currentRegionSize;
do {
- if (++activeRegionIndex >= elementsof(activeRegionList))
+ if (++activeRegionIndex >= ARRAYSIZE(activeRegionList))
return false;
int16 prevRegionIndex;
@@ -3941,7 +3941,7 @@ ObjectID ActiveRegionObjectIterator::first(GameObject **obj) {
ObjectID ActiveRegionObjectIterator::next(GameObject **obj) {
assert(activeRegionIndex >= 0);
- assert(activeRegionIndex < elementsof(activeRegionList));
+ assert(activeRegionIndex < ARRAYSIZE(activeRegionList));
ObjectID currentObjectID;
diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp
index 2ebec42a41..1674a81aae 100644
--- a/engines/saga2/objproto.cpp
+++ b/engines/saga2/objproto.cpp
@@ -786,7 +786,7 @@ bool ProtoObj::acceptInsertionAtAction(
// Creates a color translation table for this object
void ProtoObj::getColorTranslation(ColorTable map) {
- buildColorTable(map, colorMap, elementsof(colorMap));
+ buildColorTable(map, colorMap, ARRAYSIZE(colorMap));
}
uint16 ProtoObj::containmentSet(void) {
@@ -1106,7 +1106,7 @@ bool InventoryProto::dropAction(
static const int8 dirOffsetTable[] = { 0, 1, -1, 2, -2, 3, -3 };
- for (i = 0; i < elementsof(dirOffsetTable); i++) {
+ for (i = 0; i < ARRAYSIZE(dirOffsetTable); i++) {
TilePoint testPt;
Direction testDir;
@@ -2852,7 +2852,7 @@ ContainerWindow *EnchantmentProto::makeWindow( GameObject *Obj )
// set the decorations for this window
window->setDecorations( enchantDecorations,
- elementsof( enchantDecorations ),
+ ARRAYSIZE( enchantDecorations ),
decRes, 'E', 'F', 'R' );
diff --git a/engines/saga2/path.cpp b/engines/saga2/path.cpp
index cdf5775830..7f62f9c9ca 100644
--- a/engines/saga2/path.cpp
+++ b/engines/saga2/path.cpp
@@ -867,13 +867,13 @@ DirMaskGroup *MaskComputer::computeMask(uint8 crossSection) {
}
}
- if (arraySize < elementsof(array)) {
+ if (arraySize < ARRAYSIZE(array)) {
// Allocate a new place for this mask group
maskGroup = ptrArray[arraySize] = &array[arraySize];
arraySize++;
} else
// Discard last referenced mask group in array
- maskGroup = ptrArray[elementsof(array) - 1];
+ maskGroup = ptrArray[ARRAYSIZE(array) - 1];
// Compute the new group of masks
maskGroup->computeMask(crossSection);
@@ -1525,12 +1525,12 @@ void PathRequest::initialize(void) {
*tablePtrPtr = node;
if (nextAvailableLookupNode
- >= elementsof(volumeLookupNodePool))
+ >= ARRAYSIZE(volumeLookupNodePool))
goto big_break;
}
}
- if (++objectVolumes >= elementsof(objectVolumeArray)) break;
+ if (++objectVolumes >= ARRAYSIZE(objectVolumeArray)) break;
}
big_break:
@@ -1607,7 +1607,7 @@ void PathRequest::finish(void) {
assert(cell != nullptr);
if (cell->direction != dirInvalid) {
- res = &tempResult[elementsof(tempResult)];
+ res = &tempResult[ARRAYSIZE(tempResult)];
prevDir = dirInvalid;
@@ -1648,8 +1648,8 @@ void PathRequest::finish(void) {
}
if (resultSteps) {
- while (stepCount < elementsof(path)
- && res < &tempResult[elementsof(tempResult)]) {
+ while (stepCount < ARRAYSIZE(path)
+ && res < &tempResult[ARRAYSIZE(tempResult)]) {
*resultSteps++ = *res++;
stepCount++;
}
diff --git a/engines/saga2/player.cpp b/engines/saga2/player.cpp
index b895592898..19136940f5 100644
--- a/engines/saga2/player.cpp
+++ b/engines/saga2/player.cpp
@@ -510,7 +510,7 @@ void PlayerActor::handleAttacked(void) {
// Return a pointer to a PlayerActor given it's ID
PlayerActor *getPlayerActorAddress(PlayerActorID id) {
- assert(id >= 0 && id < elementsof(playerList));
+ assert(id >= 0 && id < ARRAYSIZE(playerList));
return &playerList[id];
}
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index 47d49f8be6..ae1121fc8a 100644
--- a/engines/saga2/sagafunc.cpp
+++ b/engines/saga2/sagafunc.cpp
@@ -2342,7 +2342,7 @@ C_Call *actorCFuncList[] = {
scriptActorImNotQuiteDead,
};
-CallTable actorCFuncs = { actorCFuncList, elementsof(actorCFuncList), 0 };
+CallTable actorCFuncs = { actorCFuncList, ARRAYSIZE(actorCFuncList), 0 };
//-----------------------------------------------------------------------
// Return the id of this TAI
@@ -2615,7 +2615,7 @@ C_Call *tagCFuncList[] = {
scriptTagReleaseLock,
};
-CallTable tagCFuncs = { tagCFuncList, elementsof(tagCFuncList), 0 };
+CallTable tagCFuncs = { tagCFuncList, ARRAYSIZE(tagCFuncList), 0 };
//-----------------------------------------------------------------------
// Find a mission by generator id
@@ -2696,7 +2696,7 @@ C_Call *missionCFuncList[] = {
scriptMissionMakeActor,
};
-CallTable missionCFuncs = { missionCFuncList, elementsof(missionCFuncList), 0 };
+CallTable missionCFuncs = { missionCFuncList, ARRAYSIZE(missionCFuncList), 0 };
//-----------------------------------------------------------------------
// Global functions
@@ -4014,6 +4014,6 @@ C_Call *globalCFuncList[] = {
scriptBigMul,
};
-CallTable globalCFuncs = { globalCFuncList, elementsof(globalCFuncList), 0 };
+CallTable globalCFuncs = { globalCFuncList, ARRAYSIZE(globalCFuncList), 0 };
} // end of namespace Saga2
diff --git a/engines/saga2/sensor.cpp b/engines/saga2/sensor.cpp
index 4a91c56c09..6189b23b84 100644
--- a/engines/saga2/sensor.cpp
+++ b/engines/saga2/sensor.cpp
@@ -482,7 +482,7 @@ bool ProtaganistSensor::check(SenseInfo &info, uint32 senseFlags) {
int16 i;
bool objIsActor = isActor(getObject());
- for (i = 0; i < (long)elementsof(playerActorIDs); i++) {
+ for (i = 0; i < (long)ARRAYSIZE(playerActorIDs); i++) {
Actor *protag =
getPlayerActorAddress(playerActorIDs[i])->getActor();
diff --git a/engines/saga2/speech.cpp b/engines/saga2/speech.cpp
index ffb13633f0..0e3a45b9ca 100644
--- a/engines/saga2/speech.cpp
+++ b/engines/saga2/speech.cpp
@@ -680,18 +680,18 @@ void abortAllSpeeches(void) {
void sentenceGenerator(char *sentence) {
int16 index;
- index = rand() % elementsof(names);
+ index = rand() % ARRAYSIZE(names);
strcat(sentence, names[index]);
- index = rand() % elementsof(verbs);
+ index = rand() % ARRAYSIZE(verbs);
strcat(sentence, verbs[index]);
- index = rand() % elementsof(adjectives);
+ index = rand() % ARRAYSIZE(adjectives);
strcat(sentence, adjectives[index]);
- index = rand() % elementsof(nouns);
+ index = rand() % ARRAYSIZE(nouns);
strcat(sentence, nouns[index]);
-// for(int i=0; i<elementsof(sentenceParts); i++)
+// for(int i=0; i<ARRAYSIZE(sentenceParts); i++)
// {
-// strcat(sentence,sentenceParts[i].index = rand() % elementsof(sentenceParts[i]);
+// strcat(sentence,sentenceParts[i].index = rand() % ARRAYSIZE(sentenceParts[i]);
// }
}
@@ -1015,7 +1015,7 @@ bool isVisible(GameObject *obj) {
SpeechTaskList::SpeechTaskList(void) {
lockFlag = false;
- for (int i = 0; i < (long)elementsof(array); i++) {
+ for (int i = 0; i < (long)ARRAYSIZE(array); i++) {
free.addTail(array[i]);
}
}
@@ -1032,7 +1032,7 @@ SpeechTaskList::SpeechTaskList(void **buf) {
lockFlag = false;
// Initialize the free list
- for (i = 0; i < (long)elementsof(array); i++) {
+ for (i = 0; i < (long)ARRAYSIZE(array); i++) {
free.addTail(array[i]);
}
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index 62bceeefb5..33f83806f3 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -572,7 +572,7 @@ void ActorAppearance::loadSpriteBanks(int16 banksNeeded) {
appearanceLRU.push_back(this);
// Load in additional sprite banks if requested...
- for (bank = 0; bank < (long)elementsof(spriteBanks); bank++) {
+ for (bank = 0; bank < (long)ARRAYSIZE(spriteBanks); bank++) {
// Load the sprite handle...
if (spriteBanks[bank] == nullptr && (banksNeeded & (1 << bank))) {
Common::SeekableReadStream *stream = loadResourceToStream(spriteRes, id + MKTAG(0, 0, 0, bank), "sprite bank");
@@ -666,7 +666,7 @@ ActorAppearance *LoadActorAppearance(uint32 id, int16 banksNeeded) {
}
// Dump the sprites being stored
- for (bank = 0; bank < (long)elementsof(aa->spriteBanks); bank++) {
+ for (bank = 0; bank < (long)ARRAYSIZE(aa->spriteBanks); bank++) {
if (aa->spriteBanks[bank])
delete aa->spriteBanks[bank];
aa->spriteBanks[bank] = nullptr;
@@ -845,7 +845,7 @@ void initSprites(void) {
initQuickMem(0x10000);
// Initialize actor appearance table
- for (i = 0; i < elementsof(appearanceTable); i++) {
+ for (i = 0; i < ARRAYSIZE(appearanceTable); i++) {
ActorAppearance *aa = &appearanceTable[i];
aa->useCount = 0;
diff --git a/engines/saga2/std.h b/engines/saga2/std.h
index 5b3d763cd3..510f67b6c6 100644
--- a/engines/saga2/std.h
+++ b/engines/saga2/std.h
@@ -38,13 +38,8 @@ typedef uint32 ChunkID;
#define FTA
-// #define LEAVE goto exitit // bail out of function
#define unless(x) if((x)==NULL) // an inverted if statement
-#ifndef elementsof
-#define elementsof(x) (sizeof(x)/sizeof(x[0]))
-#endif
-
#ifndef offsetof
#define offsetof(type,field) (uint32)&(((type *)0)->field)
#endif
diff --git a/engines/saga2/task.cpp b/engines/saga2/task.cpp
index 5d82588190..684085cc30 100644
--- a/engines/saga2/task.cpp
+++ b/engines/saga2/task.cpp
@@ -2170,11 +2170,11 @@ TilePoint GoAwayFromActorTask::getRepulsionVector(void) {
repulsionVector;
int16 i;
TilePoint locArray[6];
- int16 strengthArray[elementsof(locArray)] =
+ int16 strengthArray[ARRAYSIZE(locArray)] =
{ 1, 1, 1, 1, 1, 1 };
- int16 distArray[elementsof(locArray)];
+ int16 distArray[ARRAYSIZE(locArray)];
TargetLocationArray tla(
- elementsof(locArray),
+ ARRAYSIZE(locArray),
locArray,
distArray);
@@ -2728,9 +2728,9 @@ void HuntToBeNearObjectTask::evaluateTarget(void) {
Actor *a = stack->getActor();
int16 i;
GameObject *objArray[16];
- int16 distArray[elementsof(objArray)];
+ int16 distArray[ARRAYSIZE(objArray)];
TargetObjectArray toa(
- elementsof(objArray),
+ ARRAYSIZE(objArray),
objArray,
distArray);
SenseInfo info;
@@ -2867,9 +2867,9 @@ void HuntToPossessTask::evaluateTarget(void) {
Actor *a = stack->getActor();
int16 i;
GameObject *objArray[16];
- int16 distArray[elementsof(objArray)];
+ int16 distArray[ARRAYSIZE(objArray)];
TargetObjectArray toa(
- elementsof(objArray),
+ ARRAYSIZE(objArray),
objArray,
distArray);
SenseInfo info;
@@ -3166,9 +3166,9 @@ void HuntToBeNearActorTask::evaluateTarget(void) {
Actor *a = stack->getActor();
int16 i;
Actor *actorArray[16];
- int16 distArray[elementsof(actorArray)];
+ int16 distArray[ARRAYSIZE(actorArray)];
TargetActorArray taa(
- elementsof(actorArray),
+ ARRAYSIZE(actorArray),
actorArray,
distArray);
SenseInfo info;
@@ -3411,9 +3411,9 @@ void HuntToKillTask::evaluateTarget(void) {
ActorProto *proto = (ActorProto *)a->proto();
int16 i;
Actor *actorArray[16];
- int16 distArray[elementsof(actorArray)];
+ int16 distArray[ARRAYSIZE(actorArray)];
TargetActorArray taa(
- elementsof(actorArray),
+ ARRAYSIZE(actorArray),
actorArray,
distArray);
SenseInfo info;
@@ -3921,8 +3921,8 @@ void BandTask::evaluateTarget(void) {
TilePoint repulsorVector;
int16 repulsorStrength;
TilePoint repulsorVectorArray[6];
- int16 repulsorStrengthArray[elementsof(repulsorVectorArray)];
- int16 repulsorDistArray[elementsof(repulsorVectorArray)];
+ int16 repulsorStrengthArray[ARRAYSIZE(repulsorVectorArray)];
+ int16 repulsorDistArray[ARRAYSIZE(repulsorVectorArray)];
int16 repulsorCount;
bool repulsorFlag;
@@ -3950,7 +3950,7 @@ void BandTask::evaluateTarget(void) {
int16 j = repulsorCount;
if (repulsorDist < repulsorDistArray[j - 1]) {
- if (repulsorCount < (long)elementsof(repulsorVectorArray)) {
+ if (repulsorCount < (long)ARRAYSIZE(repulsorVectorArray)) {
repulsorDistArray[j] = repulsorDistArray[j - 1];
repulsorVectorArray[j] = repulsorVectorArray[j - 1];
repulsorStrengthArray[j] = repulsorStrengthArray[j - 1];
@@ -3965,8 +3965,8 @@ void BandTask::evaluateTarget(void) {
j--;
}
- if (j < (long)elementsof(repulsorVectorArray)) {
- if (repulsorCount < (long)elementsof(repulsorVectorArray))
+ if (j < (long)ARRAYSIZE(repulsorVectorArray)) {
+ if (repulsorCount < (long)ARRAYSIZE(repulsorVectorArray))
repulsorCount++;
repulsorDistArray[j] = repulsorDist;
repulsorVectorArray[j] = repulsorVector;
@@ -4099,8 +4099,8 @@ bool BandTask::BandAndAvoidEnemiesRepulsorIterator::firstEnemyRepulsor(
int16 &repulsorStrength) {
assert(iteratingThruEnemies);
- int16 actorDistArray[elementsof(actorArray)];
- TargetActorArray taa(elementsof(actorArray), actorArray, actorDistArray);
+ int16 actorDistArray[ARRAYSIZE(actorArray)];
+ TargetActorArray taa(ARRAYSIZE(actorArray), actorArray, actorDistArray);
ActorPropertyTarget target(actorPropIDEnemy);
numActors = target.actor(a->world(), a->getLocation(), taa);
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 6eadd5b434..d889a460d8 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -984,7 +984,7 @@ static TileActivityTaskList &aTaskList =
// Constructor
TileActivityTaskList::TileActivityTaskList(void) {
- for (uint i = 0; i < elementsof(array); i++) {
+ for (uint i = 0; i < ARRAYSIZE(array); i++) {
free.addTail(array[i]);
}
}
@@ -997,7 +997,7 @@ TileActivityTaskList::TileActivityTaskList(void **buf) {
int16 taskCount;
- for (uint i = 0; i < elementsof(array); i++) {
+ for (uint i = 0; i < ARRAYSIZE(array); i++) {
free.addTail(array[i]);
}
@@ -2481,7 +2481,7 @@ void WorldMapData::buildInstanceHash(void) {
if (ai->_data.itemType == activeTypeInstance) {
hashVal = (((ai->_data.instance.u + ai->_data.instance.h) << 4)
+ ai->_data.instance.v + (ai->_data.instance.groupID << 2))
- % elementsof(instHash);
+ % ARRAYSIZE(instHash);
itemHash.setVal(hashVal, ai);
}
@@ -2496,7 +2496,7 @@ ActiveItem *WorldMapData::findHashedInstance(
TilePoint &tp,
int16 group) {
int16 hashVal = (((tp.u + tp.z) << 4) + tp.v + (group << 2))
- % elementsof(instHash);
+ % ARRAYSIZE(instHash);
if (itemHash.contains(hashVal))
return itemHash.getVal(hashVal);
@@ -2865,7 +2865,7 @@ void buildRipTables(void) {
int16 tableIndex;
// bit array of available rip tables
- uint8 tableAvail[(elementsof(ripTableList) + 7) >> 3];
+ uint8 tableAvail[(ARRAYSIZE(ripTableList) + 7) >> 3];
memset(tableAvail, 0xFF, sizeof(tableAvail));
@@ -2899,7 +2899,7 @@ void buildRipTables(void) {
uint j;
// Find available table
- for (j = 0; j < elementsof(ripTableList); j++) {
+ for (j = 0; j < ARRAYSIZE(ripTableList); j++) {
if (tableAvail[j >> 3] & (1 << (j & 0x7)))
break;
}
diff --git a/engines/saga2/tilemode.cpp b/engines/saga2/tilemode.cpp
index ddb3e07661..b73a235c49 100644
--- a/engines/saga2/tilemode.cpp
+++ b/engines/saga2/tilemode.cpp
@@ -668,7 +668,7 @@ void loadTileModeState(SaveFileReader &saveGame) {
void TileModeSetup(void) {
// Load in decorative panels for the main window (for this mode)
- mainWindow->setDecorations(mainWindowDecorations, elementsof(mainWindowDecorations), imageRes);
+ mainWindow->setDecorations(mainWindowDecorations, ARRAYSIZE(mainWindowDecorations), imageRes);
// Test to draw borders.
// REM: We should actually have a routine to refresh the window...
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index d6ab0f3fcb..b57d8aab64 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -737,7 +737,7 @@ int16 FileDialog(int16 fileProcess) {
win->setDecorations(saveWindowDecorations,
- elementsof(saveWindowDecorations),
+ ARRAYSIZE(saveWindowDecorations),
decRes, 'S', 'L', 'D');
win->userData = &rInfo;
@@ -922,7 +922,7 @@ int16 OptionsDialog(bool disableSaveResume) {
}
win->setDecorations(optionsDecorations,
- elementsof(optionsDecorations),
+ ARRAYSIZE(optionsDecorations),
decRes, 'O', 'P', 'T');
@@ -1035,7 +1035,7 @@ bool initUserDialog(void) {
udWin = new ModalWindow(messageWindowRect, 0 nullptr);
udWin->setDecorations(messageDecorations,
- elementsof(messageDecorations),
+ ARRAYSIZE(messageDecorations),
udDecRes, 'M', 'E', 'S');
udWin->userData = &udrInfo;
@@ -1237,7 +1237,7 @@ int16 userDialog(const char *title, const char *msg, const char *bMsg1,
new CPlacardPanel(*win, messageTextRects[1], msg, &Onyx10Font, 0, pal, 0, nullptr);
win->setDecorations(messageDecorations,
- elementsof(messageDecorations),
+ ARRAYSIZE(messageDecorations),
decRes, 'M', 'E', 'S');
@@ -1539,7 +1539,7 @@ void placardWindow(int8 type, char *text) {
// setup the background imagery
win->setDecorations(plaqDecWood,
- elementsof(plaqDecWood),
+ ARRAYSIZE(plaqDecWood),
resContext, 'P', 'L', 'Q');
break;
@@ -1554,7 +1554,7 @@ void placardWindow(int8 type, char *text) {
// setup the background imagery
win->setDecorations(plaqDecStone,
- elementsof(plaqDecStone),
+ ARRAYSIZE(plaqDecStone),
resContext, 'P', 'L', 'Q');
break;
@@ -1569,7 +1569,7 @@ void placardWindow(int8 type, char *text) {
// setup the background imagery
win->setDecorations(plaqDecBrass,
- elementsof(plaqDecBrass),
+ ARRAYSIZE(plaqDecBrass),
resContext, 'P', 'L', 'Q');
break;
diff --git a/engines/saga2/videobox.cpp b/engines/saga2/videobox.cpp
index 168d4272b2..e82253dec1 100644
--- a/engines/saga2/videobox.cpp
+++ b/engines/saga2/videobox.cpp
@@ -137,7 +137,7 @@ void CVideoBox::init(void) {
// get the decorations for this window
setDecorations(vidDec,
- elementsof(vidDec),
+ ARRAYSIZE(vidDec),
decRes,
'V', 'B', 'D');
diff --git a/engines/saga2/vpal.cpp b/engines/saga2/vpal.cpp
index 35d2b35daa..e3c69886be 100644
--- a/engines/saga2/vpal.cpp
+++ b/engines/saga2/vpal.cpp
@@ -247,7 +247,7 @@ void createPalette(
int i;
uint32 fadeProgress = (elapsedTime << 8) / totalTime_;
- for (i = 0; i < (long)elementsof(newP->entry); i++) {
+ for (i = 0; i < (long)ARRAYSIZE(newP->entry); i++) {
gPaletteEntry *srcPal = &srcP->entry[i];
gPaletteEntry *dstPal = &dstP->entry[i];
gPaletteEntry *curPal = &newP->entry[i];
Commit: 2161d9e388b1e91e76ae8d7b6882eb4c0d7e938e
https://github.com/scummvm/scummvm/commit/2161d9e388b1e91e76ae8d7b6882eb4c0d7e938e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:31+02:00
Commit Message:
SAGA2: Removed std.h
Changed paths:
R engines/saga2/std.h
engines/saga2/actor.cpp
engines/saga2/arrowptr.cpp
engines/saga2/assign.cpp
engines/saga2/audio.cpp
engines/saga2/audiobuf.cpp
engines/saga2/audiores.cpp
engines/saga2/automap.cpp
engines/saga2/band.cpp
engines/saga2/beegee.cpp
engines/saga2/blitters.cpp
engines/saga2/button.cpp
engines/saga2/calender.cpp
engines/saga2/contain.cpp
engines/saga2/display.cpp
engines/saga2/dispnode.cpp
engines/saga2/dlist.cpp
engines/saga2/document.cpp
engines/saga2/effects.cpp
engines/saga2/enchant.cpp
engines/saga2/floating.cpp
engines/saga2/gamemode.cpp
engines/saga2/gdraw.cpp
engines/saga2/gpointer.cpp
engines/saga2/grabinfo.cpp
engines/saga2/grequest.cpp
engines/saga2/gtext.cpp
engines/saga2/gtextbox.cpp
engines/saga2/hresmgr.cpp
engines/saga2/idtypes.h
engines/saga2/imagcach.cpp
engines/saga2/interp.cpp
engines/saga2/intrface.cpp
engines/saga2/keybored.cpp
engines/saga2/loadmsg.cpp
engines/saga2/loadsave.cpp
engines/saga2/magic.cpp
engines/saga2/main.cpp
engines/saga2/mainmap.cpp
engines/saga2/mapfeatr.cpp
engines/saga2/messager.cpp
engines/saga2/mission.cpp
engines/saga2/modal.cpp
engines/saga2/motion.cpp
engines/saga2/mouseimg.cpp
engines/saga2/msgbox.cpp
engines/saga2/noise.cpp
engines/saga2/objects.cpp
engines/saga2/objproto.cpp
engines/saga2/panel.cpp
engines/saga2/path.cpp
engines/saga2/patrol.cpp
engines/saga2/player.cpp
engines/saga2/playmode.cpp
engines/saga2/property.cpp
engines/saga2/pt2angle.cpp
engines/saga2/rect.cpp
engines/saga2/saga2.cpp
engines/saga2/saga2.h
engines/saga2/sagafunc.cpp
engines/saga2/savefile.cpp
engines/saga2/sensor.cpp
engines/saga2/speech.cpp
engines/saga2/spelcast.cpp
engines/saga2/speldata.cpp
engines/saga2/speldraw.cpp
engines/saga2/spellini.cpp
engines/saga2/spellio.cpp
engines/saga2/spellloc.cpp
engines/saga2/spellsiz.cpp
engines/saga2/spellspr.cpp
engines/saga2/spellsta.cpp
engines/saga2/sprite.cpp
engines/saga2/target.cpp
engines/saga2/task.cpp
engines/saga2/terrain.cpp
engines/saga2/tile.cpp
engines/saga2/tileline.cpp
engines/saga2/tileload.cpp
engines/saga2/tilemode.cpp
engines/saga2/timers.cpp
engines/saga2/tower.cpp
engines/saga2/towerfta.cpp
engines/saga2/transit.cpp
engines/saga2/tromode.cpp
engines/saga2/uidialog.cpp
engines/saga2/vbacksav.cpp
engines/saga2/video.cpp
engines/saga2/videobox.cpp
engines/saga2/vpal.cpp
engines/saga2/vwdraw.cpp
engines/saga2/weapons.cpp
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index d02e1029d4..882b6a83f6 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -28,7 +28,7 @@
#include "common/debug.h"
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/dispnode.h"
#include "saga2/tile.h"
#include "saga2/motion.h"
diff --git a/engines/saga2/arrowptr.cpp b/engines/saga2/arrowptr.cpp
index 6d3cf64a03..87d5dddf2a 100644
--- a/engines/saga2/arrowptr.cpp
+++ b/engines/saga2/arrowptr.cpp
@@ -30,7 +30,7 @@
Converted by iff2c.
* ===================================================================== */
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/gdraw.h"
namespace Saga2 {
diff --git a/engines/saga2/assign.cpp b/engines/saga2/assign.cpp
index d67f8c849c..1fcce574f2 100644
--- a/engines/saga2/assign.cpp
+++ b/engines/saga2/assign.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/actor.h"
#include "saga2/assign.h"
#include "saga2/calender.h"
diff --git a/engines/saga2/audio.cpp b/engines/saga2/audio.cpp
index c8ea910f48..761510b06d 100644
--- a/engines/saga2/audio.cpp
+++ b/engines/saga2/audio.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/audio.h"
#include "saga2/rect.h"
diff --git a/engines/saga2/audiobuf.cpp b/engines/saga2/audiobuf.cpp
index 7a99e67079..c9b4757461 100644
--- a/engines/saga2/audiobuf.cpp
+++ b/engines/saga2/audiobuf.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/audio.h"
#include "saga2/rect.h"
diff --git a/engines/saga2/audiores.cpp b/engines/saga2/audiores.cpp
index ae511088d9..c5aed9c855 100644
--- a/engines/saga2/audiores.cpp
+++ b/engines/saga2/audiores.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/audio.h"
#include "saga2/hresmgr.h"
#include "saga2/audiodec.h"
diff --git a/engines/saga2/automap.cpp b/engines/saga2/automap.cpp
index c05678da03..cd519416ac 100644
--- a/engines/saga2/automap.cpp
+++ b/engines/saga2/automap.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/automap.h"
#include "saga2/blitters.h"
#include "saga2/tile.h"
diff --git a/engines/saga2/band.cpp b/engines/saga2/band.cpp
index a1c0ee1d8d..a5aee11bf2 100644
--- a/engines/saga2/band.cpp
+++ b/engines/saga2/band.cpp
@@ -26,7 +26,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/actor.h"
#include "saga2/band.h"
#include "saga2/savefile.h"
diff --git a/engines/saga2/beegee.cpp b/engines/saga2/beegee.cpp
index 5f954c26d5..4157672acc 100644
--- a/engines/saga2/beegee.cpp
+++ b/engines/saga2/beegee.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/idtypes.h"
#include "saga2/tile.h"
#include "saga2/music.h"
diff --git a/engines/saga2/blitters.cpp b/engines/saga2/blitters.cpp
index 40c111d743..a4331bbf9c 100644
--- a/engines/saga2/blitters.cpp
+++ b/engines/saga2/blitters.cpp
@@ -28,7 +28,7 @@
#include "common/memstream.h"
#include "graphics/surface.h"
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/gdraw.h"
namespace Saga2 {
diff --git a/engines/saga2/button.cpp b/engines/saga2/button.cpp
index 206b3fdf77..5c651e5871 100644
--- a/engines/saga2/button.cpp
+++ b/engines/saga2/button.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/fta.h"
#include "saga2/hresmgr.h"
#include "saga2/button.h"
diff --git a/engines/saga2/calender.cpp b/engines/saga2/calender.cpp
index 99b1304d4a..3111921dda 100644
--- a/engines/saga2/calender.cpp
+++ b/engines/saga2/calender.cpp
@@ -26,7 +26,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/calender.h"
#include "saga2/intrface.h"
#include "saga2/localize.h"
diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index 30174c0a1a..c4c0650db9 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -26,7 +26,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/objects.h"
#include "saga2/contain.h"
#include "saga2/grabinfo.h"
diff --git a/engines/saga2/display.cpp b/engines/saga2/display.cpp
index 595fd107e8..ea02d28218 100644
--- a/engines/saga2/display.cpp
+++ b/engines/saga2/display.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/display.h"
#include "saga2/intrface.h"
#include "saga2/loadmsg.h"
diff --git a/engines/saga2/dispnode.cpp b/engines/saga2/dispnode.cpp
index bba75c729a..863504632e 100644
--- a/engines/saga2/dispnode.cpp
+++ b/engines/saga2/dispnode.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/blitters.h"
#include "saga2/spelshow.h"
#include "saga2/player.h"
diff --git a/engines/saga2/dlist.cpp b/engines/saga2/dlist.cpp
index d93411a355..af1c6790e3 100644
--- a/engines/saga2/dlist.cpp
+++ b/engines/saga2/dlist.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/dlist.h"
namespace Saga2 {
diff --git a/engines/saga2/document.cpp b/engines/saga2/document.cpp
index db011e695c..eeb4be565e 100644
--- a/engines/saga2/document.cpp
+++ b/engines/saga2/document.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/document.h"
#include "saga2/script.h"
#include "saga2/intrface.h"
diff --git a/engines/saga2/effects.cpp b/engines/saga2/effects.cpp
index 889c3ed14f..b1ad52fdee 100644
--- a/engines/saga2/effects.cpp
+++ b/engines/saga2/effects.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/cmisc.h"
#include "saga2/spelshow.h"
#include "saga2/script.h"
diff --git a/engines/saga2/enchant.cpp b/engines/saga2/enchant.cpp
index b98a5b7b56..e3d953353a 100644
--- a/engines/saga2/enchant.cpp
+++ b/engines/saga2/enchant.cpp
@@ -26,7 +26,7 @@
//#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/cmisc.h"
#include "saga2/player.h"
#include "saga2/enchant.h"
diff --git a/engines/saga2/floating.cpp b/engines/saga2/floating.cpp
index cbc7143021..b68316bccd 100644
--- a/engines/saga2/floating.cpp
+++ b/engines/saga2/floating.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/floating.h"
#include "saga2/objects.h"
#include "saga2/imagcach.h"
diff --git a/engines/saga2/gamemode.cpp b/engines/saga2/gamemode.cpp
index c4ff5de812..3060bb4ced 100644
--- a/engines/saga2/gamemode.cpp
+++ b/engines/saga2/gamemode.cpp
@@ -26,7 +26,7 @@
//#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/floating.h"
namespace Saga2 {
diff --git a/engines/saga2/gdraw.cpp b/engines/saga2/gdraw.cpp
index c7fdb8cf3e..81ecb351ed 100644
--- a/engines/saga2/gdraw.cpp
+++ b/engines/saga2/gdraw.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/gdraw.h"
#include "saga2/gblitter.h"
diff --git a/engines/saga2/gpointer.cpp b/engines/saga2/gpointer.cpp
index 95ecb52801..5f21818ff5 100644
--- a/engines/saga2/gpointer.cpp
+++ b/engines/saga2/gpointer.cpp
@@ -26,7 +26,7 @@
#include "graphics/cursorman.h"
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/gpointer.h"
namespace Saga2 {
diff --git a/engines/saga2/grabinfo.cpp b/engines/saga2/grabinfo.cpp
index cd9412eb61..1c95845605 100644
--- a/engines/saga2/grabinfo.cpp
+++ b/engines/saga2/grabinfo.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/gdraw.h"
#include "saga2/objects.h"
#include "saga2/contain.h"
diff --git a/engines/saga2/grequest.cpp b/engines/saga2/grequest.cpp
index 05732f5260..7a99499039 100644
--- a/engines/saga2/grequest.cpp
+++ b/engines/saga2/grequest.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/grequest.h"
#include "saga2/modal.h"
#include "saga2/mouseimg.h"
diff --git a/engines/saga2/gtext.cpp b/engines/saga2/gtext.cpp
index d4a603ff03..798d6a8d19 100644
--- a/engines/saga2/gtext.cpp
+++ b/engines/saga2/gtext.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/gdraw.h"
namespace Saga2 {
diff --git a/engines/saga2/gtextbox.cpp b/engines/saga2/gtextbox.cpp
index 9a5d04f6f8..3d0e435828 100644
--- a/engines/saga2/gtextbox.cpp
+++ b/engines/saga2/gtextbox.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/cmisc.h"
#include "saga2/fta.h"
#include "saga2/panel.h"
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index 7e687be83f..4f7d5ccf5b 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -26,7 +26,7 @@
#include "common/debug.h"
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/hresmgr.h"
#include "saga2/fta.h"
diff --git a/engines/saga2/idtypes.h b/engines/saga2/idtypes.h
index 4d013b15ae..b121ca59d5 100644
--- a/engines/saga2/idtypes.h
+++ b/engines/saga2/idtypes.h
@@ -29,6 +29,11 @@
namespace Saga2 {
+#define FTA
+
+typedef uint32 ChunkID;
+#define MakeID(a,b,c,d) ((d<<24L)|(c<<16L)|(b<<8L)|a)
+
/* ===================================================================== *
ObjectID
* ===================================================================== */
@@ -227,6 +232,17 @@ typedef uint32 hResID;
typedef uint8 ColorTable[256];
+#ifndef offsetof
+#define offsetof(type,field) (uint32)&(((type *)0)->field)
+#endif
+
+#define maxuint8 0xff
+#define maxint16 0x7fff
+#define minint16 0x8000
+#define maxuint16 0xffff
+#define maxint32 0x7fffffff
+
+
// number of containers
const int kNumViews = 3;
diff --git a/engines/saga2/imagcach.cpp b/engines/saga2/imagcach.cpp
index 1ebdb97aa1..ec87e633bf 100644
--- a/engines/saga2/imagcach.cpp
+++ b/engines/saga2/imagcach.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/fta.h"
#include "saga2/dlist.h"
#include "saga2/imagcach.h"
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 0ce5692e52..fd49e49630 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -28,7 +28,7 @@
#include "common/debug.h"
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/fta.h"
#include "saga2/script.h"
#include "saga2/code.h"
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index c7bdcfd9e9..10b9e88f18 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -26,7 +26,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/blitters.h"
#include "saga2/objects.h"
#include "saga2/contain.h"
diff --git a/engines/saga2/keybored.cpp b/engines/saga2/keybored.cpp
index 7e6d92d19e..ed2fe9f8e5 100644
--- a/engines/saga2/keybored.cpp
+++ b/engines/saga2/keybored.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/tilemode.h"
#include "saga2/calender.h"
diff --git a/engines/saga2/loadmsg.cpp b/engines/saga2/loadmsg.cpp
index 4301c8cd35..5d576e7333 100644
--- a/engines/saga2/loadmsg.cpp
+++ b/engines/saga2/loadmsg.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "graphics/palette.h"
diff --git a/engines/saga2/loadsave.cpp b/engines/saga2/loadsave.cpp
index dbb6a823b1..82bc776a03 100644
--- a/engines/saga2/loadsave.cpp
+++ b/engines/saga2/loadsave.cpp
@@ -26,7 +26,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/loadsave.h"
#include "saga2/savefile.h"
#include "saga2/objects.h"
diff --git a/engines/saga2/magic.cpp b/engines/saga2/magic.cpp
index f968136841..a9a806728f 100644
--- a/engines/saga2/magic.cpp
+++ b/engines/saga2/magic.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/magic.h"
#include "saga2/idtypes.h"
#include "saga2/speldefs.h"
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 5e737c57c4..64780f9364 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -30,7 +30,7 @@
#include "common/events.h"
#include "common/memstream.h"
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/setup.h"
#include "saga2/transit.h"
#include "saga2/player.h"
diff --git a/engines/saga2/mainmap.cpp b/engines/saga2/mainmap.cpp
index 04979646d3..a97f14d4f2 100644
--- a/engines/saga2/mainmap.cpp
+++ b/engines/saga2/mainmap.cpp
@@ -25,7 +25,7 @@
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/fta.h"
#include "saga2/mainmap.h"
diff --git a/engines/saga2/mapfeatr.cpp b/engines/saga2/mapfeatr.cpp
index db0ffdf2da..17cb3c5ea7 100644
--- a/engines/saga2/mapfeatr.cpp
+++ b/engines/saga2/mapfeatr.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/mapfeatr.h"
#include "saga2/automap.h"
#include "saga2/tile.h"
diff --git a/engines/saga2/messager.cpp b/engines/saga2/messager.cpp
index 9358ce8a9f..7635a222f6 100644
--- a/engines/saga2/messager.cpp
+++ b/engines/saga2/messager.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/messager.h"
#include "saga2/vdraw.h"
diff --git a/engines/saga2/mission.cpp b/engines/saga2/mission.cpp
index 423d85cf80..5b34e0cc39 100644
--- a/engines/saga2/mission.cpp
+++ b/engines/saga2/mission.cpp
@@ -26,7 +26,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/mission.h"
#include "saga2/actor.h"
#include "saga2/savefile.h"
diff --git a/engines/saga2/modal.cpp b/engines/saga2/modal.cpp
index ddf00fd35d..38e5d1b7a6 100644
--- a/engines/saga2/modal.cpp
+++ b/engines/saga2/modal.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/modal.h"
#include "saga2/speech.h"
#include "saga2/grabinfo.h"
diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp
index b188b20c29..e92e40c0ea 100644
--- a/engines/saga2/motion.cpp
+++ b/engines/saga2/motion.cpp
@@ -26,7 +26,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/dispnode.h"
#include "saga2/tile.h"
#include "saga2/motion.h"
diff --git a/engines/saga2/mouseimg.cpp b/engines/saga2/mouseimg.cpp
index fe864e8158..7a6fddfd7b 100644
--- a/engines/saga2/mouseimg.cpp
+++ b/engines/saga2/mouseimg.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/blitters.h"
#include "saga2/fta.h"
#include "saga2/mouseimg.h"
diff --git a/engines/saga2/msgbox.cpp b/engines/saga2/msgbox.cpp
index 046f46b7cc..62ef0a5a10 100644
--- a/engines/saga2/msgbox.cpp
+++ b/engines/saga2/msgbox.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/fta.h"
#include "saga2/button.h"
#include "saga2/localize.h"
diff --git a/engines/saga2/noise.cpp b/engines/saga2/noise.cpp
index e67ecb27fc..6bb858d290 100644
--- a/engines/saga2/noise.cpp
+++ b/engines/saga2/noise.cpp
@@ -26,7 +26,7 @@
#include "common/config-manager.h"
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/fta.h"
#include "saga2/audio.h"
#include "saga2/audiores.h"
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index d15b086866..a4296e4144 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -26,7 +26,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/objects.h"
#include "saga2/tile.h"
#include "saga2/motion.h"
diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp
index 1674a81aae..e45292cfb3 100644
--- a/engines/saga2/objproto.cpp
+++ b/engines/saga2/objproto.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/gdraw.h"
#include "saga2/objects.h"
#include "saga2/grabinfo.h"
diff --git a/engines/saga2/panel.cpp b/engines/saga2/panel.cpp
index b2b668dc16..1f581ca342 100644
--- a/engines/saga2/panel.cpp
+++ b/engines/saga2/panel.cpp
@@ -26,7 +26,7 @@
#include "common/events.h"
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/panel.h"
#include "saga2/fontlib.h"
#include "saga2/floating.h"
diff --git a/engines/saga2/path.cpp b/engines/saga2/path.cpp
index 7f62f9c9ca..87505e3a36 100644
--- a/engines/saga2/path.cpp
+++ b/engines/saga2/path.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/dispnode.h"
#include "saga2/tile.h"
#include "saga2/motion.h"
diff --git a/engines/saga2/patrol.cpp b/engines/saga2/patrol.cpp
index fe01db4654..d4edb2ee8b 100644
--- a/engines/saga2/patrol.cpp
+++ b/engines/saga2/patrol.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/fta.h"
#include "saga2/patrol.h"
#include "saga2/cmisc.h"
diff --git a/engines/saga2/player.cpp b/engines/saga2/player.cpp
index 19136940f5..a6c83b9789 100644
--- a/engines/saga2/player.cpp
+++ b/engines/saga2/player.cpp
@@ -26,7 +26,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/intrface.h"
#include "saga2/contain.h"
#include "saga2/task.h"
diff --git a/engines/saga2/playmode.cpp b/engines/saga2/playmode.cpp
index 2255082ef1..d8e9da5670 100644
--- a/engines/saga2/playmode.cpp
+++ b/engines/saga2/playmode.cpp
@@ -26,7 +26,7 @@
#include "graphics/surface.h"
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/blitters.h"
#include "saga2/objects.h"
#include "saga2/tile.h"
diff --git a/engines/saga2/property.cpp b/engines/saga2/property.cpp
index 5f0f48e660..d2e68fb015 100644
--- a/engines/saga2/property.cpp
+++ b/engines/saga2/property.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/player.h"
#include "saga2/tile.h"
diff --git a/engines/saga2/pt2angle.cpp b/engines/saga2/pt2angle.cpp
index b038e44f2b..99db202a56 100644
--- a/engines/saga2/pt2angle.cpp
+++ b/engines/saga2/pt2angle.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
namespace Saga2 {
diff --git a/engines/saga2/rect.cpp b/engines/saga2/rect.cpp
index ca53eda78a..efb4b6f139 100644
--- a/engines/saga2/rect.cpp
+++ b/engines/saga2/rect.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/rect.h"
namespace Saga2 {
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index 5629bf2de3..87358a00f9 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -34,7 +34,6 @@
#include "saga2/saga2.h"
-#include "saga2/std.h"
#include "saga2/gdraw.h"
#include "saga2/mouseimg.h"
diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h
index 7fe897b7aa..b347d820df 100644
--- a/engines/saga2/saga2.h
+++ b/engines/saga2/saga2.h
@@ -23,9 +23,11 @@
#ifndef SAGA2_H
#define SAGA2_H
+#include "common/debug.h"
#include "common/random.h"
#include "common/serializer.h"
#include "common/system.h"
+
#include "engines/engine.h"
#include "saga2/idtypes.h"
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index ae1121fc8a..faecb72664 100644
--- a/engines/saga2/sagafunc.cpp
+++ b/engines/saga2/sagafunc.cpp
@@ -28,7 +28,7 @@
#include "common/debug.h"
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/fta.h"
#include "saga2/script.h"
#include "saga2/actor.h"
diff --git a/engines/saga2/savefile.cpp b/engines/saga2/savefile.cpp
index 8341fbbd42..b59fb89268 100644
--- a/engines/saga2/savefile.cpp
+++ b/engines/saga2/savefile.cpp
@@ -26,7 +26,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/savefile.h"
namespace Saga2 {
diff --git a/engines/saga2/sensor.cpp b/engines/saga2/sensor.cpp
index 6189b23b84..f18543b08a 100644
--- a/engines/saga2/sensor.cpp
+++ b/engines/saga2/sensor.cpp
@@ -26,7 +26,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/objects.h"
#include "saga2/sensor.h"
#include "saga2/player.h"
diff --git a/engines/saga2/speech.cpp b/engines/saga2/speech.cpp
index 0e3a45b9ca..85050c0353 100644
--- a/engines/saga2/speech.cpp
+++ b/engines/saga2/speech.cpp
@@ -26,7 +26,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/fta.h"
#include "saga2/fontlib.h"
#include "saga2/speech.h"
diff --git a/engines/saga2/spelcast.cpp b/engines/saga2/spelcast.cpp
index 89ae68fe89..aa9fe69af9 100644
--- a/engines/saga2/spelcast.cpp
+++ b/engines/saga2/spelcast.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/idtypes.h"
#include "saga2/speldefs.h"
#include "saga2/spellbuk.h"
diff --git a/engines/saga2/speldata.cpp b/engines/saga2/speldata.cpp
index b8141b9515..51bc647fce 100644
--- a/engines/saga2/speldata.cpp
+++ b/engines/saga2/speldata.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/objproto.h"
#include "saga2/spellbuk.h"
#include "saga2/spelshow.h"
diff --git a/engines/saga2/speldraw.cpp b/engines/saga2/speldraw.cpp
index d401deafd1..b8e66a0817 100644
--- a/engines/saga2/speldraw.cpp
+++ b/engines/saga2/speldraw.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/spelshow.h"
namespace Saga2 {
diff --git a/engines/saga2/spellini.cpp b/engines/saga2/spellini.cpp
index 0bfa5e57b2..9ed9cba2d4 100644
--- a/engines/saga2/spellini.cpp
+++ b/engines/saga2/spellini.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/spelshow.h"
#include "saga2/spelvals.h"
#include "saga2/tilevect.h"
diff --git a/engines/saga2/spellio.cpp b/engines/saga2/spellio.cpp
index 40662604ce..f1db67695e 100644
--- a/engines/saga2/spellio.cpp
+++ b/engines/saga2/spellio.cpp
@@ -26,7 +26,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/idtypes.h"
#include "saga2/magic.h"
#include "saga2/effects.h"
diff --git a/engines/saga2/spellloc.cpp b/engines/saga2/spellloc.cpp
index 373f9d0d0a..12e62992b6 100644
--- a/engines/saga2/spellloc.cpp
+++ b/engines/saga2/spellloc.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/spelshow.h"
#include "saga2/tilevect.h"
diff --git a/engines/saga2/spellsiz.cpp b/engines/saga2/spellsiz.cpp
index 6fc0b454fc..00031d9239 100644
--- a/engines/saga2/spellsiz.cpp
+++ b/engines/saga2/spellsiz.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/spelshow.h"
namespace Saga2 {
diff --git a/engines/saga2/spellspr.cpp b/engines/saga2/spellspr.cpp
index 348e10a58c..069af1a0cb 100644
--- a/engines/saga2/spellspr.cpp
+++ b/engines/saga2/spellspr.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/objproto.h"
#include "saga2/spellbuk.h"
#include "saga2/spelshow.h"
diff --git a/engines/saga2/spellsta.cpp b/engines/saga2/spellsta.cpp
index 55ae0fa600..ac4fa05d1c 100644
--- a/engines/saga2/spellsta.cpp
+++ b/engines/saga2/spellsta.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/spelshow.h"
namespace Saga2 {
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index 33f83806f3..9132ee7357 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/fta.h"
#include "saga2/blitters.h"
#include "saga2/sprite.h"
diff --git a/engines/saga2/std.h b/engines/saga2/std.h
deleted file mode 100644
index 510f67b6c6..0000000000
--- a/engines/saga2/std.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#ifndef SAGA2_STD_H
-#define SAGA2_STD_H
-
-#include "common/system.h"
-#include "common/debug.h"
-
-
-typedef uint32 ChunkID;
-#define MakeID(a,b,c,d) ((d<<24L)|(c<<16L)|(b<<8L)|a)
-
-#include "saga2/saga2.h"
-
-#define FTA
-
-#define unless(x) if((x)==NULL) // an inverted if statement
-
-#ifndef offsetof
-#define offsetof(type,field) (uint32)&(((type *)0)->field)
-#endif
-
-#define OK 0
-#define EMPTY -1
-
-#define maxuint8 0xff
-#define minuint8 0
-#define maxint16 0x7fff
-#define minint16 0x8000
-#define maxuint16 0xffff
-#define minuint16 0
-#define maxint32 0x7fffffff
-#define maxuint32 0xffffffffu
-#define minuint32 0u
-
-
-
-#endif //SAGA2_STD_H
diff --git a/engines/saga2/target.cpp b/engines/saga2/target.cpp
index a10f5255cd..76ccb3cc74 100644
--- a/engines/saga2/target.cpp
+++ b/engines/saga2/target.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/cmisc.h"
#include "saga2/objects.h"
#include "saga2/target.h"
diff --git a/engines/saga2/task.cpp b/engines/saga2/task.cpp
index 684085cc30..ee40d9f0b1 100644
--- a/engines/saga2/task.cpp
+++ b/engines/saga2/task.cpp
@@ -26,7 +26,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/fta.h"
#include "saga2/cmisc.h"
#include "saga2/actor.h"
diff --git a/engines/saga2/terrain.cpp b/engines/saga2/terrain.cpp
index 572e136255..392d2f5c07 100644
--- a/engines/saga2/terrain.cpp
+++ b/engines/saga2/terrain.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/idtypes.h"
#include "saga2/tile.h"
#include "saga2/actor.h"
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index d889a460d8..cd6e671ca1 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -29,7 +29,7 @@
#include "common/debug.h"
#include "graphics/surface.h"
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/blitters.h"
#include "saga2/hresmgr.h"
#include "saga2/objects.h"
diff --git a/engines/saga2/tileline.cpp b/engines/saga2/tileline.cpp
index c5da29e227..a6ea506dd2 100644
--- a/engines/saga2/tileline.cpp
+++ b/engines/saga2/tileline.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
namespace Saga2 {
diff --git a/engines/saga2/tileload.cpp b/engines/saga2/tileload.cpp
index a3c5b94caf..172aa5fd77 100644
--- a/engines/saga2/tileload.cpp
+++ b/engines/saga2/tileload.cpp
@@ -26,7 +26,7 @@
#include "common/debug.h"
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/idtypes.h"
#include "saga2/tile.h"
#include "saga2/hresmgr.h"
diff --git a/engines/saga2/tilemode.cpp b/engines/saga2/tilemode.cpp
index b73a235c49..e4d74877f9 100644
--- a/engines/saga2/tilemode.cpp
+++ b/engines/saga2/tilemode.cpp
@@ -26,7 +26,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/tilemode.h"
#include "saga2/tile.h"
#include "saga2/setup.h"
diff --git a/engines/saga2/timers.cpp b/engines/saga2/timers.cpp
index 373d41b375..1e4d51e171 100644
--- a/engines/saga2/timers.cpp
+++ b/engines/saga2/timers.cpp
@@ -28,7 +28,7 @@
#include "common/timer.h"
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/fta.h"
#include "saga2/timers.h"
#include "saga2/objects.h"
diff --git a/engines/saga2/tower.cpp b/engines/saga2/tower.cpp
index 5929f76d98..5cb5f48d3a 100644
--- a/engines/saga2/tower.cpp
+++ b/engines/saga2/tower.cpp
@@ -26,7 +26,7 @@
#include "common/debug.h"
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/tower.h"
namespace Saga2 {
diff --git a/engines/saga2/towerfta.cpp b/engines/saga2/towerfta.cpp
index b0baa7a0fd..213ad0c1d2 100644
--- a/engines/saga2/towerfta.cpp
+++ b/engines/saga2/towerfta.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/towerwin.h"
#include "saga2/towerfta.h"
#include "saga2/fta.h"
diff --git a/engines/saga2/transit.cpp b/engines/saga2/transit.cpp
index a0969df922..a3295a4c6d 100644
--- a/engines/saga2/transit.cpp
+++ b/engines/saga2/transit.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/idtypes.h"
#include "saga2/tile.h"
#include "saga2/vpal.h"
diff --git a/engines/saga2/tromode.cpp b/engines/saga2/tromode.cpp
index abddaed5b1..f11ee259f3 100644
--- a/engines/saga2/tromode.cpp
+++ b/engines/saga2/tromode.cpp
@@ -26,7 +26,7 @@
#include "common/config-manager.h"
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/fta.h"
#include "saga2/player.h"
#include "saga2/display.h"
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index b57d8aab64..e75884411a 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -29,7 +29,7 @@
#include "common/config-manager.h"
#include "audio/mixer.h"
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/intrface.h"
#include "saga2/grequest.h"
#include "saga2/gtextbox.h"
diff --git a/engines/saga2/vbacksav.cpp b/engines/saga2/vbacksav.cpp
index dd78cf4053..68e2df0219 100644
--- a/engines/saga2/vbacksav.cpp
+++ b/engines/saga2/vbacksav.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/vbacksav.h"
namespace Saga2 {
diff --git a/engines/saga2/video.cpp b/engines/saga2/video.cpp
index aa9d0e7958..15582be68a 100644
--- a/engines/saga2/video.cpp
+++ b/engines/saga2/video.cpp
@@ -27,7 +27,7 @@
#include "graphics/palette.h"
#include "video/smk_decoder.h"
-#include "saga2/std.h"
+#include "saga2/saga2.h"
namespace Saga2 {
diff --git a/engines/saga2/videobox.cpp b/engines/saga2/videobox.cpp
index e82253dec1..10fa48c9cd 100644
--- a/engines/saga2/videobox.cpp
+++ b/engines/saga2/videobox.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/videobox.h"
namespace Saga2 {
diff --git a/engines/saga2/vpal.cpp b/engines/saga2/vpal.cpp
index e3c69886be..9152fa393b 100644
--- a/engines/saga2/vpal.cpp
+++ b/engines/saga2/vpal.cpp
@@ -29,7 +29,7 @@
#include "common/debug.h"
#include "graphics/palette.h"
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/fta.h"
#include "saga2/vpal.h"
#include "saga2/palette.h"
diff --git a/engines/saga2/vwdraw.cpp b/engines/saga2/vwdraw.cpp
index 1f332cae59..609eca7082 100644
--- a/engines/saga2/vwdraw.cpp
+++ b/engines/saga2/vwdraw.cpp
@@ -26,7 +26,7 @@
#include "graphics/surface.h"
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/vdraw.h"
#include "saga2/blitters.h"
diff --git a/engines/saga2/weapons.cpp b/engines/saga2/weapons.cpp
index 91d00f8133..a5ee27e1a2 100644
--- a/engines/saga2/weapons.cpp
+++ b/engines/saga2/weapons.cpp
@@ -24,7 +24,7 @@
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
-#include "saga2/std.h"
+#include "saga2/saga2.h"
#include "saga2/weapons.h"
#include "saga2/spelshow.h"
#include "saga2/spellbuk.h"
Commit: ef389b13ff8f8ef79fc6f202ed3c11022c565cf5
https://github.com/scummvm/scummvm/commit/ef389b13ff8f8ef79fc6f202ed3c11022c565cf5
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:31+02:00
Commit Message:
SAGA2: Remove DList from path.cpp
Changed paths:
engines/saga2/path.cpp
diff --git a/engines/saga2/path.cpp b/engines/saga2/path.cpp
index 87505e3a36..f0bf3fb91c 100644
--- a/engines/saga2/path.cpp
+++ b/engines/saga2/path.cpp
@@ -1061,7 +1061,7 @@ enum PathResult {
};
// This if the base class for all PathRequests
-class PathRequest : public DNode {
+class PathRequest {
friend void addPathRequestToQueue(PathRequest *pr);
protected:
@@ -1259,7 +1259,7 @@ public:
Common::List<WanderPathRequest *> pathRequestPool;
-DList pathQueue;
+Common::List<PathRequest *> pathQueue;
PathRequest *currentRequest = nullptr;
static PathTilePosArray *pathTileArray;
@@ -2264,12 +2264,10 @@ int16 WanderPathRequest::evaluateMove(const TilePoint &testPt, uint8) {
}
void runPathFinder(void) {
- if (currentRequest == nullptr) {
- currentRequest = (PathRequest *)pathQueue.first();
- if (currentRequest != nullptr) {
- currentRequest->remove();
- currentRequest->initialize();
- }
+ if (currentRequest == nullptr && !pathQueue.empty()) {
+ currentRequest = pathQueue.front();
+ pathQueue.pop_front();
+ currentRequest->initialize();
}
if (currentRequest != nullptr) {
@@ -2296,26 +2294,24 @@ void addPathRequestToQueue(PathRequest *pr) {
Actor *centerActor = getCenterActor();
if (a == centerActor)
- pathQueue.addHead(*pr);
+ pathQueue.push_front(pr);
else {
if (isPlayerActor(a)) {
- PathRequest *prInQueue;
+ Common::List<PathRequest *>::iterator it;
- for (prInQueue = (PathRequest *)pathQueue.first();
- prInQueue != nullptr;
- prInQueue = (PathRequest *)prInQueue->next()) {
- Actor *prActor = prInQueue->actor;
+ for (it = pathQueue.begin(); it != pathQueue.end(); it++) {
+ Actor *prActor = (*it)->actor;
if (prActor != centerActor || !isPlayerActor(prActor))
break;
}
- if (prInQueue != nullptr)
- pathQueue.insert(*pr, *prInQueue);
+ if (it != pathQueue.end())
+ pathQueue.insert(it, pr);
else
- pathQueue.addTail(*pr);
+ pathQueue.push_back(pr);
} else
- pathQueue.addTail(*pr);
+ pathQueue.push_back(pr);
}
}
@@ -2341,10 +2337,8 @@ void abortPathFind(MotionTask *mTask) {
if (pr == currentRequest)
pr->requestAbort();
- else {
- pr->remove();
- delete pr;
- }
+ else
+ pathQueue.remove(pr);
mTask->pathFindTask = nullptr;
}
Commit: 8bf479ba43e5cf7a650c6ecc70332f660c0591d2
https://github.com/scummvm/scummvm/commit/8bf479ba43e5cf7a650c6ecc70332f660c0591d2
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:31+02:00
Commit Message:
SAGA2: Raise level of noisy warning
Changed paths:
engines/saga2/objproto.cpp
diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp
index e45292cfb3..61bd2c8b90 100644
--- a/engines/saga2/objproto.cpp
+++ b/engines/saga2/objproto.cpp
@@ -964,7 +964,7 @@ void ProtoObj::doBackgroundUpdate(GameObject *obj) {
// XXX: Temporary crash prevention
// We should properly solve the problem
- debug(3, "XXX: doBackgroundUpdate");
+ debug(5, "XXX: doBackgroundUpdate");
if (w == nullptr) {
obj->deactivate();
Commit: 8940f362a2a08a3318a9ccd80d5f97eb9984406c
https://github.com/scummvm/scummvm/commit/8940f362a2a08a3318a9ccd80d5f97eb9984406c
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:31+02:00
Commit Message:
SAGA2: Add debug output to path.cpp
Changed paths:
engines/saga2/detection.cpp
engines/saga2/path.cpp
engines/saga2/saga2.h
diff --git a/engines/saga2/detection.cpp b/engines/saga2/detection.cpp
index 9cfa174cc5..cc02059aef 100644
--- a/engines/saga2/detection.cpp
+++ b/engines/saga2/detection.cpp
@@ -36,6 +36,7 @@ static const DebugChannelDef debugFlagList[] = {
{Saga2::kDebugPalettes, "palettes", "Debug the palettes"},
{Saga2::kDebugLoading, "loading", "Debug the loading"},
{Saga2::kDebugTimers, "timers", "Debug the timers"},
+ {Saga2::kDebugPath, "path", "Debug the pathfinding"},
DEBUG_CHANNEL_END
};
diff --git a/engines/saga2/path.cpp b/engines/saga2/path.cpp
index f0bf3fb91c..ddaa26de53 100644
--- a/engines/saga2/path.cpp
+++ b/engines/saga2/path.cpp
@@ -1602,6 +1602,8 @@ void PathRequest::finish(void) {
static TilePoint tempResult[32];
+ debugC(2, kDebugPath, "Finishing Path Request: %p", (void *)this);
+
if (bestLoc != Nowhere) {
cell = cellArray->getCell(bestPlatform, bestLoc.u, bestLoc.v);
assert(cell != nullptr);
@@ -1672,6 +1674,8 @@ void PathRequest::finish(void) {
}
void PathRequest::abortReq(void) {
+ debugC(4, kDebugPath, "Aborting Path Request: %p", (void *)this);
+
if (mTask->pathFindTask == this)
mTask->pathFindTask = nullptr;
}
@@ -1680,12 +1684,14 @@ void PathRequest::abortReq(void) {
PathResult PathRequest::findPath(void) {
assert(cellArray != nullptr);
- static const uint8 costTable[] = { 4, 10, 12, 16, 12, 10, 4, 0, 4, 10, 12, 16, 12, 10, 4, 0 };
+ static const uint8 costTable[] = {4, 10, 12, 16, 12, 10, 4, 0, 4, 10, 12, 16, 12, 10, 4, 0};
ProtoObj *proto = actor->proto();
QueueItem qi;
uint8 pCross = proto->crossSection;
+ debugC(4, kDebugPath, "Finding Path for %p: pCross = %d", (void *)this, pCross);
+
if (flags & aborted) return pathAborted;
int32 lastTick_ = gameTime;
@@ -2062,6 +2068,8 @@ DestinationPathRequest::DestinationPathRequest(Actor *a, int16 howSmart) :
// Initialize the static data members
void DestinationPathRequest::initialize(void) {
+ debugC(2, kDebugPath, "Initializing Path Request: %p", (void *)this);
+
PathRequest::initialize();
// Initialize bestDist to the highest possible value.
diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h
index b347d820df..0449ab401d 100644
--- a/engines/saga2/saga2.h
+++ b/engines/saga2/saga2.h
@@ -51,7 +51,8 @@ enum {
kDebugTiles = 1 << 5,
kDebugPalettes = 1 << 6,
kDebugLoading = 1 << 7,
- kDebugTimers = 1 << 8
+ kDebugTimers = 1 << 8,
+ kDebugPath = 1 << 9
};
#define TICKSPERSECOND (728L/10L)
Commit: 9b02c77bee15b3a091aec0f9cb5610d8c6813f2a
https://github.com/scummvm/scummvm/commit/9b02c77bee15b3a091aec0f9cb5610d8c6813f2a
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:31+02:00
Commit Message:
SAGA2: Fix ThreadList::next
Changed paths:
engines/saga2/interp.cpp
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index fd49e49630..9e3764762a 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -1324,9 +1324,9 @@ Thread *ThreadList::next(Thread *thread) {
if (i == kNumThreads)
return nullptr;
- for (; i < kNumThreads; i++)
- if (_list[i])
- return _list[i];
+ for (int j = i + 1; j < kNumThreads; j++)
+ if (_list[j])
+ return _list[j];
return nullptr;
}
Commit: 9a39a34a5d8d6b2bb213e20c922c4287a1046226
https://github.com/scummvm/scummvm/commit/9a39a34a5d8d6b2bb213e20c922c4287a1046226
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:32+02:00
Commit Message:
SAGA2: Remove unnecessary warning
Changed paths:
engines/saga2/objproto.cpp
diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp
index 61bd2c8b90..f1488512fc 100644
--- a/engines/saga2/objproto.cpp
+++ b/engines/saga2/objproto.cpp
@@ -962,10 +962,6 @@ void ProtoObj::doBackgroundUpdate(GameObject *obj) {
int u = location.u >> kSectorShift;
int v = location.v >> kSectorShift;
- // XXX: Temporary crash prevention
- // We should properly solve the problem
- debug(5, "XXX: doBackgroundUpdate");
-
if (w == nullptr) {
obj->deactivate();
return;
Commit: d03865729423edfc14dec9bd6744962085b8df0b
https://github.com/scummvm/scummvm/commit/d03865729423edfc14dec9bd6744962085b8df0b
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:32+02:00
Commit Message:
SAGA2: Change code for readability
Changed paths:
engines/saga2/interp.cpp
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 9e3764762a..45cf86a9a7 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -1321,12 +1321,13 @@ Thread *ThreadList::next(Thread *thread) {
if (_list[i] == thread)
break;
- if (i == kNumThreads)
+ i++;
+ if (i >= kNumThreads)
return nullptr;
- for (int j = i + 1; j < kNumThreads; j++)
- if (_list[j])
- return _list[j];
+ for (; i < kNumThreads; i++)
+ if (_list[i])
+ return _list[i];
return nullptr;
}
Commit: 5580bcc1121afe4e4de6637adcaae82deb595730
https://github.com/scummvm/scummvm/commit/5580bcc1121afe4e4de6637adcaae82deb595730
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:32+02:00
Commit Message:
SAGA2: Revert getMillis back to gameTime
Changed paths:
engines/saga2/beegee.cpp
engines/saga2/vpal.cpp
diff --git a/engines/saga2/beegee.cpp b/engines/saga2/beegee.cpp
index 4157672acc..28b30e1f60 100644
--- a/engines/saga2/beegee.cpp
+++ b/engines/saga2/beegee.cpp
@@ -280,8 +280,8 @@ void audioEnvironmentUseSet(int16 audioSet, int32 auxID, Point32 relPos) {
void audioEnvironmentCheck(void) {
- uint32 delta = g_system->getMillis() - lastGameTime;
- lastGameTime = g_system->getMillis();
+ uint32 delta = gameTime - lastGameTime;
+ lastGameTime = gameTime;
if (currentTheme) {
elapsedGameTime += delta;
if (elapsedGameTime > checkGameTime) {
diff --git a/engines/saga2/vpal.cpp b/engines/saga2/vpal.cpp
index 9152fa393b..ca23a3db3c 100644
--- a/engines/saga2/vpal.cpp
+++ b/engines/saga2/vpal.cpp
@@ -184,7 +184,7 @@ void cleanupPalettes(void) {
// Begin fade up/down
void beginFade(gPalettePtr newPalette, int32 fadeDuration) {
- startTime = g_system->getMillis();
+ startTime = gameTime;
totalTime = fadeDuration;
// Save the current palette for interpolation
@@ -200,7 +200,7 @@ void beginFade(gPalettePtr newPalette, int32 fadeDuration) {
bool updatePalette() {
int32 elapsedTime;
- elapsedTime = g_system->getMillis() - startTime;
+ elapsedTime = gameTime - startTime;
if (totalTime == 0)
return false;
Commit: 5bb5fe9396979ecb6a11c8032e15034628d14988
https://github.com/scummvm/scummvm/commit/5bb5fe9396979ecb6a11c8032e15034628d14988
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:32+02:00
Commit Message:
SAGA2: Change some classes into packed structs
Changed paths:
engines/saga2/contain.h
engines/saga2/dispnode.h
engines/saga2/idtypes.h
engines/saga2/patrol.h
engines/saga2/sprite.h
engines/saga2/tcoords.h
engines/saga2/terrain.h
diff --git a/engines/saga2/contain.h b/engines/saga2/contain.h
index 9c9bc20f11..2687d705fe 100644
--- a/engines/saga2/contain.h
+++ b/engines/saga2/contain.h
@@ -55,7 +55,7 @@ class ProtoObj;
class gCompButton;
class gCompImage;
class gMultCompButton;
-class TilePoint;
+struct TilePoint;
/* ===================================================================== *
Class definitions
diff --git a/engines/saga2/dispnode.h b/engines/saga2/dispnode.h
index 7d2b062c27..40aadc66e5 100644
--- a/engines/saga2/dispnode.h
+++ b/engines/saga2/dispnode.h
@@ -33,7 +33,7 @@
namespace Saga2 {
class GameObject;
-class TilePoint;
+struct TilePoint;
class Effectron;
diff --git a/engines/saga2/idtypes.h b/engines/saga2/idtypes.h
index b121ca59d5..28b68083f6 100644
--- a/engines/saga2/idtypes.h
+++ b/engines/saga2/idtypes.h
@@ -108,13 +108,11 @@ const int activeItemMapShift = 13;
const int16 activeItemIndexNullID = 0x1FFF;
-class ActiveItemID {
-private:
+struct ActiveItemID {
int16 val; // ID value --
// first 3 bits world number
// next 13 bits index
-public:
// Default constructor
ActiveItemID(void) {}
diff --git a/engines/saga2/patrol.h b/engines/saga2/patrol.h
index a3e5aeedca..cea107eca2 100644
--- a/engines/saga2/patrol.h
+++ b/engines/saga2/patrol.h
@@ -29,7 +29,7 @@
namespace Saga2 {
-class TilePoint;
+struct TilePoint;
class PatrolRouteList;
extern PatrolRouteList **patrolRouteList; // Global patrol route array
diff --git a/engines/saga2/sprite.h b/engines/saga2/sprite.h
index 5b0e826be9..7d84262138 100644
--- a/engines/saga2/sprite.h
+++ b/engines/saga2/sprite.h
@@ -333,7 +333,7 @@ public:
void initSprites(void);
void cleanupSprites(void);
-class TilePoint;
+struct TilePoint;
// Draw a plain sprite into a gPort, no masking or clipping
void DrawSprite(gPort &port, const Point16 &dest, Sprite *sp);
diff --git a/engines/saga2/tcoords.h b/engines/saga2/tcoords.h
index be5a13d169..8add87b1e4 100644
--- a/engines/saga2/tcoords.h
+++ b/engines/saga2/tcoords.h
@@ -43,12 +43,9 @@ enum facingDirections {
};
typedef uint8 Direction;
-/* ============================================================================ *
- A class which defines a position on a tile map (including height)
- * ============================================================================ */
-class TilePoint {
-public:
+#include "common/pack-start.h"
+struct TilePoint {
// When an object is within a World, the u & v represent
// the U and V coordinates on the tilemap, and the Z
// represents the height.
@@ -108,6 +105,8 @@ public:
int16 magnitude(void);
};
+#include "common/pack-end.h"
+
/* ============================================================================ *
Constants
diff --git a/engines/saga2/terrain.h b/engines/saga2/terrain.h
index f5994507f0..5669ee0c5b 100644
--- a/engines/saga2/terrain.h
+++ b/engines/saga2/terrain.h
@@ -29,7 +29,7 @@
namespace Saga2 {
-class TilePoint;
+struct TilePoint;
struct TileRegion;
// these control the rate of drowning damage
Commit: 3ad054d85cb9ff84911eb8c8c84397a2f9b0c30f
https://github.com/scummvm/scummvm/commit/3ad054d85cb9ff84911eb8c8c84397a2f9b0c30f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:32+02:00
Commit Message:
SAGA2: Properly mark structs as packed
Changed paths:
engines/saga2/idtypes.h
engines/saga2/mission.h
engines/saga2/tcoords.h
engines/saga2/tile.h
diff --git a/engines/saga2/idtypes.h b/engines/saga2/idtypes.h
index 28b68083f6..8832652985 100644
--- a/engines/saga2/idtypes.h
+++ b/engines/saga2/idtypes.h
@@ -108,6 +108,7 @@ const int activeItemMapShift = 13;
const int16 activeItemIndexNullID = 0x1FFF;
+#include "common/pack-start.h"
struct ActiveItemID {
int16 val; // ID value --
// first 3 bits world number
@@ -179,7 +180,8 @@ struct ActiveItemID {
int16 getIndexNum(void) {
return val & activeItemIndexMask;
}
-};
+} PACKED_STRUCT;
+#include "common/pack-end.h"
// ID of NULL active item
extern const ActiveItemID NoActiveItem;
diff --git a/engines/saga2/mission.h b/engines/saga2/mission.h
index a9f2a47bb6..67bbb55e8c 100644
--- a/engines/saga2/mission.h
+++ b/engines/saga2/mission.h
@@ -63,7 +63,7 @@ struct ActiveMissionData {
KnowledgeID missionKnowledgeList[32];
uint16 numObjectIDs,
numKnowledgeIDs;
-};
+} PACKED_STRUCT;
#include "common/pack-end.h"
diff --git a/engines/saga2/tcoords.h b/engines/saga2/tcoords.h
index 8add87b1e4..4264e1a60d 100644
--- a/engines/saga2/tcoords.h
+++ b/engines/saga2/tcoords.h
@@ -104,7 +104,7 @@ struct TilePoint {
int16 quickDir(void);
int16 magnitude(void);
-};
+} PACKED_STRUCT;
#include "common/pack-end.h"
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index 9ad6ad5101..1df569bd21 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -383,7 +383,7 @@ struct ActiveItemData {
worldNum; // Add 0xf000 to get world Object ID
} instance;
};
-};
+} PACKED_STRUCT;
#include "common/pack-end.h"
Commit: 14811e32024de0d4b62c0308d87b2603ffced010
https://github.com/scummvm/scummvm/commit/14811e32024de0d4b62c0308d87b2603ffced010
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:32+02:00
Commit Message:
SAGA2: Fix some gcc warnings
Changed paths:
engines/saga2/beegee.cpp
engines/saga2/blitters.cpp
engines/saga2/button.cpp
engines/saga2/panel.h
diff --git a/engines/saga2/beegee.cpp b/engines/saga2/beegee.cpp
index 28b30e1f60..b346879114 100644
--- a/engines/saga2/beegee.cpp
+++ b/engines/saga2/beegee.cpp
@@ -256,7 +256,7 @@ void audioEnvironmentUseSet(int16 audioSet, int32 auxID, Point32 relPos) {
res = metaNoiseID(audioSet);
else
res = 0;
- if (currentTheme != audioSet || auxTheme != auxID) {
+ if (currentTheme != (uint16)audioSet || auxTheme != (uint32)auxID) {
currentTheme = audioSet;
auxTheme = auxID;
themeAt = relPos;
diff --git a/engines/saga2/blitters.cpp b/engines/saga2/blitters.cpp
index a4331bbf9c..9df23116d8 100644
--- a/engines/saga2/blitters.cpp
+++ b/engines/saga2/blitters.cpp
@@ -176,8 +176,8 @@ void unpackSprite(gPixelMap *map, uint8 *sprData, uint32 dataSize) {
fail = true;
}
-#if DEBUGPACK
if (fail) {
+#if DEBUGPACK
Graphics::Surface surf;
surf.w = map->size.x;
surf.h = map->size.y;
@@ -187,8 +187,8 @@ void unpackSprite(gPixelMap *map, uint8 *sprData, uint32 dataSize) {
surf.setPixels(map->data);
surf.debugPrint();
- }
#endif
+ }
}
void drawTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData, bool mask) {
diff --git a/engines/saga2/button.cpp b/engines/saga2/button.cpp
index 5c651e5871..43e4306e33 100644
--- a/engines/saga2/button.cpp
+++ b/engines/saga2/button.cpp
@@ -297,7 +297,7 @@ void gCompImage::drawClipped(gPort &port,
textRect.x -= offset.x;
textRect.y -= offset.y;
- writePlaqText(port, textRect, textFont, NULL, textPal, selected, title);
+ writePlaqText(port, textRect, textFont, 0, textPal, selected, title);
}
}
}
diff --git a/engines/saga2/panel.h b/engines/saga2/panel.h
index ef7b6126ce..b8112bb1d0 100644
--- a/engines/saga2/panel.h
+++ b/engines/saga2/panel.h
@@ -133,11 +133,11 @@ protected:
gWindow &window; // window this belongs to
Rect16 extent; // rectangular bounds of the control
const char *title; // title of the panel
- int enabled : 1, // allows disabling the panel
- selected : 1, // some panels have a selected state
- imageLabel : 1, // button label is image, not text
- ghosted : 1, // button is dimmed
- wantMousePoll : 1; // send mousemoves even if mouse not moving!
+ int enabled, // allows disabling the panel
+ selected, // some panels have a selected state
+ imageLabel, // button label is image, not text
+ ghosted, // button is dimmed
+ wantMousePoll; // send mousemoves even if mouse not moving!
// window constructor
gPanel(gWindow &, const Rect16 &, AppFunc *cmd);
Commit: a8600afb26c7959fc70de2490aca9b791840f574
https://github.com/scummvm/scummvm/commit/a8600afb26c7959fc70de2490aca9b791840f574
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:32+02:00
Commit Message:
SAGA2: Amend unsafe and strange pointer arithmetics in lineTerrain()
Changed paths:
engines/saga2/terrain.cpp
diff --git a/engines/saga2/terrain.cpp b/engines/saga2/terrain.cpp
index 392d2f5c07..c7bd6bd983 100644
--- a/engines/saga2/terrain.cpp
+++ b/engines/saga2/terrain.cpp
@@ -376,8 +376,8 @@ uint32 lineTerrain(
uint16 subTileMask_ = 0;
int16 tileStartZ,
- *minZ,
- *maxZ;
+ minZ,
+ maxZ;
int32 curZ,
zStep;
@@ -423,11 +423,11 @@ uint32 lineTerrain(
curZ = (int32)curSubTile.z << 16;
zStep = ((int32)(destSubTile.z - curSubTile.z) << 16);
if (zStep > 0) {
- minZ = &tileStartZ;
- maxZ = &curSubTile.z;
+ minZ = tileStartZ;
+ maxZ = curSubTile.z;
} else {
- minZ = &curSubTile.z;
- maxZ = &tileStartZ;
+ minZ = curSubTile.z;
+ maxZ = tileStartZ;
}
if (uDiff > vDiff) {
@@ -447,8 +447,8 @@ uint32 lineTerrain(
mapNum,
tilePt,
subTileMask_,
- *minZ,
- *maxZ + 1);
+ minZ,
+ maxZ + 1);
if (terrain & opaqueTerrain) return terrain;
tilePt.u = curSubTile.u >> kTileSubShift;
@@ -478,8 +478,8 @@ uint32 lineTerrain(
mapNum,
tilePt,
subTileMask_,
- *minZ,
- *maxZ + 1);
+ minZ,
+ maxZ + 1);
if (terrain & opaqueTerrain) return terrain;
tilePt.v = curSubTile.v >> kTileSubShift;
@@ -516,8 +516,8 @@ uint32 lineTerrain(
mapNum,
tilePt,
subTileMask_,
- *minZ,
- *maxZ + 1);
+ minZ,
+ maxZ + 1);
if (terrain & opaqueTerrain) return terrain;
tilePt.v = curSubTile.v >> kTileSubShift;
@@ -548,8 +548,8 @@ uint32 lineTerrain(
mapNum,
tilePt,
subTileMask_,
- *minZ,
- *maxZ + 1);
+ minZ,
+ maxZ + 1);
if (terrain & opaqueTerrain) return terrain;
tilePt.u = curSubTile.u >> kTileSubShift;
@@ -577,8 +577,8 @@ uint32 lineTerrain(
mapNum,
tilePt,
subTileMask_,
- *minZ,
- *maxZ);
+ minZ,
+ maxZ);
return terrain;
}
Commit: 9f9808e7594b0e49987fd0a6450c86a3dec24314
https://github.com/scummvm/scummvm/commit/9f9808e7594b0e49987fd0a6450c86a3dec24314
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:32+02:00
Commit Message:
SAGA2: Remove unneeded header
Changed paths:
R engines/saga2/testmap.h
diff --git a/engines/saga2/testmap.h b/engines/saga2/testmap.h
deleted file mode 100644
index 7fda1e297d..0000000000
--- a/engines/saga2/testmap.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * aint32 with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-/* ===================================================================== *
- Tile Activity Group Symbol File
- Created from Tile Scene File: testmap.scn
- * ===================================================================== */
-
-#ifndef SAGA2_TESTMAP_H
-#define SAGA2_TESTMAP_H
-
-namespace Saga2 {
-
-#define Group1 0
-#define Untitled_00001 1
-#define Untitled_00002 2
-#define Untitled_00003 3
-#define Untitled_00004 4
-#define Untitled_00005 5
-#define Untitled_00006 6
-
-} // end of namespace Saga2
-
-#endif
Commit: 27dd030e9437ff24f0ef201ad8fb070cda42d35e
https://github.com/scummvm/scummvm/commit/27dd030e9437ff24f0ef201ad8fb070cda42d35e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:32+02:00
Commit Message:
SAGA2: Fix more gcc warnings
Changed paths:
engines/saga2/actor.cpp
engines/saga2/audiobuf.cpp
engines/saga2/audiores.cpp
engines/saga2/automap.cpp
engines/saga2/contain.cpp
engines/saga2/dlist.cpp
engines/saga2/document.cpp
engines/saga2/effects.cpp
engines/saga2/floating.cpp
engines/saga2/gamerate.h
engines/saga2/gtextbox.cpp
engines/saga2/interp.cpp
engines/saga2/intrface.cpp
engines/saga2/main.cpp
engines/saga2/motion.cpp
engines/saga2/msgbox.cpp
engines/saga2/noise.cpp
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 882b6a83f6..03f004bfbe 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -614,10 +614,9 @@ bool ActorProto::acceptStrikeAction(
enactorPtr->handleSuccessfulStrike(weapon);
if (!a->isDead()) {
- int16 mass = a->proto()->mass;
+ int16 pmass = a->proto()->mass;
- if (mass <= 100
- || (rand() % 156) >= mass - 100) {
+ if (pmass <= 100 || (rand() % 156) >= pmass - 100) {
if ((rand() & 0x7) == 0)
MotionTask::fallDown(*a, *enactorPtr);
else
@@ -883,15 +882,13 @@ bool ActorProto::canFitMasswise(GameObject *container, GameObject *obj) {
#endif
{
Actor *a = (Actor *)container;
- uint16 maxCapacity,
- totalMass;
// get the maxium amount of weight this character should be able to carry
- maxCapacity = container->massCapacity();
+ uint16 cmaxCapacity = container->massCapacity();
- totalMass = a->totalContainedMass();
+ uint16 totalMass = a->totalContainedMass();
- return totalMass + obj->totalMass() <= maxCapacity;
+ return totalMass + obj->totalMass() <= cmaxCapacity;
}
#if DEBUG
@@ -1025,7 +1022,15 @@ void Actor::init(
flags = 0;
if (!(initFlags & actorPermanent))
flags |= temporary;
- memset(&poseInfo, 0, sizeof(poseInfo));
+
+ poseInfo.flags = 0;
+ poseInfo.actorFrameIndex = 0;
+ poseInfo.actorFrameBank = 0;
+ poseInfo.leftObjectIndex = 0;
+ poseInfo.rightObjectIndex = 0;
+ poseInfo.leftObjectOffset.x = poseInfo.leftObjectOffset.y = 0;
+ poseInfo.rightObjectOffset.x = poseInfo.rightObjectOffset.y = 0;
+
appearance = NULL;
cycleCount = 0;
kludgeCount = 0;
@@ -1088,7 +1093,15 @@ Actor::Actor(void) {
currentPose = 0;
animationFlags = 0;
flags = 0;
- memset(&poseInfo, 0, sizeof(poseInfo));
+
+ poseInfo.flags = 0;
+ poseInfo.actorFrameIndex = 0;
+ poseInfo.actorFrameBank = 0;
+ poseInfo.leftObjectIndex = 0;
+ poseInfo.rightObjectIndex = 0;
+ poseInfo.leftObjectOffset.x = poseInfo.leftObjectOffset.y = 0;
+ poseInfo.rightObjectOffset.x = poseInfo.rightObjectOffset.y = 0;
+
appearance = nullptr;
cycleCount = 0;
kludgeCount = 0;
@@ -1146,7 +1159,15 @@ Actor::Actor(const ResourceActor &res) : GameObject(res) {
currentPose = 0;
animationFlags = 0;
flags = 0;
- memset(&poseInfo, 0, sizeof(poseInfo));
+
+ poseInfo.flags = 0;
+ poseInfo.actorFrameIndex = 0;
+ poseInfo.actorFrameBank = 0;
+ poseInfo.leftObjectIndex = 0;
+ poseInfo.rightObjectIndex = 0;
+ poseInfo.leftObjectOffset.x = poseInfo.leftObjectOffset.y = 0;
+ poseInfo.rightObjectOffset.x = poseInfo.rightObjectOffset.y = 0;
+
appearance = NULL;
cycleCount = 0;
kludgeCount = 0;
diff --git a/engines/saga2/audiobuf.cpp b/engines/saga2/audiobuf.cpp
index c9b4757461..9b425ac45b 100644
--- a/engines/saga2/audiobuf.cpp
+++ b/engines/saga2/audiobuf.cpp
@@ -432,9 +432,7 @@ void workBuffer::activate(int16 bufNo) {
}
void musicBuffer::activate(int16 bufNo) {
- int32 n;
assert(ailSampleHandle);
- n = bufNo;
audioSet = 0;
if (washed() > -1) {
targetSated = false;
diff --git a/engines/saga2/audiores.cpp b/engines/saga2/audiores.cpp
index c5aed9c855..a921fa7157 100644
--- a/engines/saga2/audiores.cpp
+++ b/engines/saga2/audiores.cpp
@@ -47,7 +47,7 @@ namespace Saga2 {
extern audioInterface *audio;
extern bool debugStatuses;
extern bool debugResource;
-extern int32 maxClicks;
+extern uint32 maxClicks;
extern int32 clickSizes[];
extern uint8 *clickData[];
diff --git a/engines/saga2/automap.cpp b/engines/saga2/automap.cpp
index cd519416ac..bc4be4fc5e 100644
--- a/engines/saga2/automap.cpp
+++ b/engines/saga2/automap.cpp
@@ -521,8 +521,6 @@ int16 openAutoMap() {
rInfo.running = true;
hResContext *decRes;
- gCompButton *closeAutoMap;
- gCompButton *scrollBtn;
void *summaryData;
void **closeBtnImage;
void **scrollBtnImage;
@@ -546,9 +544,9 @@ int16 openAutoMap() {
pAutoMap = new CAutoMap(autoMapRect, (uint8 *)summaryData, 0, NULL);
- closeAutoMap = new gCompButton(*pAutoMap, closeAutoMapBtnRect, closeBtnImage, numBtnImages, 0, cmdAutoMapQuit);
+ new gCompButton(*pAutoMap, closeAutoMapBtnRect, closeBtnImage, numBtnImages, 0, cmdAutoMapQuit);
- scrollBtn = new gCompButton(*pAutoMap, scrollBtnRect, scrollBtnImage, numBtnImages, 0, cmdAutoMapScroll);
+ new gCompButton(*pAutoMap, scrollBtnRect, scrollBtnImage, numBtnImages, 0, cmdAutoMapScroll);
pAutoMap->setDecorations(autoMapDecorations,
ARRAYSIZE(autoMapDecorations),
diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index c4c0650db9..5569dfc117 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -469,9 +469,7 @@ void ContainerView::drawClipped(
// draws the mereged object multi-item selector
void ContainerView::drawSelector(gPort &port, Point16 &pos) {
- const int bufSize = 20;
-
- char buf[bufSize];
+ char buf[20];
uint8 num;
SAVE_GPORT_STATE(port);
@@ -481,7 +479,6 @@ void ContainerView::drawSelector(gPort &port, Point16 &pos) {
// draw the number of items selected thus far
num = sprintf(buf, " %d ", numPicked);
-// num = strlen( buf );
port.moveTo(Point16(pos.x - ((3 * (num - 3)) + 1), pos.y + 7));
port.setFont(&Helv11Font);
@@ -613,7 +610,7 @@ void ContainerView::pointerMove(gPanelMessage &msg) {
lastPickedObjectID = Nothing;
lastPickedObjectQuantity = -1;
mouseInfo.setText(NULL);
- mouseText[0] = NULL;
+ mouseText[0] = 0;
// static bool that tells if the mouse cursor
// is in a panel
@@ -760,7 +757,7 @@ void ContainerView::clickOn(
// activate multi-object get interface if a mergeable object
getMerged(cObj);
mouseInfo.setText(NULL);
- mouseText[0] = NULL;
+ mouseText[0] = 0;
}
} else {
// just get the object into the cursor
@@ -895,7 +892,7 @@ void ContainerView::updateMouseText(Point16 &pickPos) {
if (slotID == Nothing) {
// clear out the mouse text
mouseInfo.setText(NULL);
- mouseText[0] = NULL;
+ mouseText[0] = 0;
// reset the last picked thingy
lastPickedObjectID = Nothing;
@@ -919,7 +916,7 @@ void ContainerView::updateMouseText(Point16 &pickPos) {
// clear out the mouse text
mouseInfo.setText(NULL);
- mouseText[0] = NULL;
+ mouseText[0] = 0;
// reset the alarm flag
objTextAlarm = false;
@@ -950,7 +947,7 @@ void ContainerView::setCursorText(GameObject *obj) {
void ContainerView::setDelayedCursorText(GameObject *obj) {
// clear out the mouse text
mouseInfo.setText(NULL);
- mouseText[0] = NULL;
+ mouseText[0] = 0;
// reset the alarm flag
objTextAlarm = false;
diff --git a/engines/saga2/dlist.cpp b/engines/saga2/dlist.cpp
index af1c6790e3..5f739d23c3 100644
--- a/engines/saga2/dlist.cpp
+++ b/engines/saga2/dlist.cpp
@@ -30,10 +30,8 @@
namespace Saga2 {
DNode *DNode::remove(void) {
- if (this) {
- succ->pred = pred;
- pred->succ = succ;
- }
+ succ->pred = pred;
+ pred->succ = succ;
return this;
}
diff --git a/engines/saga2/document.cpp b/engines/saga2/document.cpp
index eeb4be565e..934e114909 100644
--- a/engines/saga2/document.cpp
+++ b/engines/saga2/document.cpp
@@ -518,7 +518,7 @@ bool CDocument::checkForPageBreak(char *string, uint16 index, int32 &offset) {
strIndex[2] == dPageBreak[1]) {
// eat the page breaks chars
// tie off the end
- strIndex[0] = NULL;
+ strIndex[0] = 0;
// string them together
strcat(&strIndex[0], &strIndex[2 + 1]);
@@ -566,7 +566,7 @@ bool CDocument::checkForImage(char *string,
// if the last entry is defined as a number
if (argv[7] == ':') {
// convert the text into a number
- char numSt[2] = { argv[8], NULL };
+ char numSt[2] = { argv[8], 0 };
uint8 num = atoi(numSt);
@@ -592,7 +592,7 @@ bool CDocument::checkForImage(char *string,
((ImageHeader *)images[offPageIndex])->size;
// tie off the end
- strIndex[0] = NULL;
+ strIndex[0] = 0;
// and string them together
strcat(&strIndex[0], &strIndex[2 + 1 + numEat]);
@@ -858,7 +858,7 @@ char bookText[textSize] = { "" };
void appendBookText(char *string) {
if (string) {
strncat(bookText, string, textSize - 1);
- bookText[textSize - 1] = NULL;
+ bookText[textSize - 1] = 0;
}
}
diff --git a/engines/saga2/effects.cpp b/engines/saga2/effects.cpp
index b1ad52fdee..f3ecba5516 100644
--- a/engines/saga2/effects.cpp
+++ b/engines/saga2/effects.cpp
@@ -205,7 +205,7 @@ void ProtoDrainage::implement(GameObject *cst, SpellTarget *trg, int8) {
// enchant something based on an enchantment proto-effect
bool ProtoEnchantment::realSavingThrow(Actor *a) {
- int32 power = (a->getBaseStats())->vitality;
+ uint32 power = (a->getBaseStats())->vitality;
power *= power;
int32 saveSpace = absoluteMaximumVitality;
saveSpace *= saveSpace;
diff --git a/engines/saga2/floating.cpp b/engines/saga2/floating.cpp
index b68316bccd..608f7c3301 100644
--- a/engines/saga2/floating.cpp
+++ b/engines/saga2/floating.cpp
@@ -139,7 +139,7 @@ void DecoratedWindow::setDecorations(
WindowDecoration *dec,
int16 count,
hResContext *con,
- hResID id) {
+ hResID id_) {
int16 i;
decorations = dec;
@@ -149,8 +149,7 @@ void DecoratedWindow::setDecorations(
for (i = 0; i < numDecorations; i++, dec++) {
// request an image pointer from the image Cache
- dec->image = ImageCache.requestImage(con,
- id | MKTAG(0, 0, 0, dec->imageNumber));
+ dec->image = ImageCache.requestImage(con, id_ | MKTAG(0, 0, 0, dec->imageNumber));
}
}
diff --git a/engines/saga2/gamerate.h b/engines/saga2/gamerate.h
index 4f844e3698..77cad5237d 100644
--- a/engines/saga2/gamerate.h
+++ b/engines/saga2/gamerate.h
@@ -105,18 +105,16 @@ class frameSmoother: public frameCounter {
}
void calculateAverages(void) {
- int i;
-
// clear averages
memset(avg1Sec, 0, 20);
avg5Sec = 0;
// get totals
- for (i = 0; i < historySize; i++)
+ for (uint i = 0; i < historySize; i++)
avg1Sec[i / int(desiredFPS)] += ksHistory(i);
// get averages
- for (i = 0; i < 5; i++) {
+ for (uint i = 0; i < 5; i++) {
avg5Sec += avg1Sec[i];
avg1Sec[i] /= desiredFPS;
}
@@ -127,20 +125,18 @@ class frameSmoother: public frameCounter {
}
void calculateVariance(void) {
- int i;
-
// clear variances
memset(dif1Sec, 0, 20);
dif5Sec = 0;
// get variance totals
- for (i = 0; i < historySize; i++) {
+ for (uint i = 0; i < historySize; i++) {
dif1Sec[i / int(desiredFPS)] += abs(ksHistory(i) - avg1Sec[i / int(desiredFPS)]);
dif5Sec += abs(ksHistory(i) - avg5Sec);
}
// get average variances
- for (i = 0; i < 5; i++) {
+ for (uint i = 0; i < 5; i++) {
secDif += avg1Sec[i] - secAvg;
dif1Sec[i] /= desiredFPS;
}
diff --git a/engines/saga2/gtextbox.cpp b/engines/saga2/gtextbox.cpp
index 3d0e435828..3fbcbf741c 100644
--- a/engines/saga2/gtextbox.cpp
+++ b/engines/saga2/gtextbox.cpp
@@ -159,7 +159,7 @@ gTextBox::gTextBox(
int8 HLColor,
int8 BGHLColor,
int8 CRColor,
- const char *title,
+ const char *title_,
const char *buffer,
char **stringBufs,
uint16 length,
@@ -169,7 +169,7 @@ gTextBox::gTextBox(
AppFunc *cmd,
AppFunc *cmdEnter,
AppFunc *cmdEscape)
- : gControl(list, box, title, ident, cmd) {
+ : gControl(list, box, title_, ident, cmd) {
int16 i;
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 45cf86a9a7..ebdc26e7fb 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -677,6 +677,8 @@ bool Thread::interpret(void) {
case op_return: // return with value
D_OP(op_return);
returnVal = *stack++;
+ // fall through
+
case op_return_v: // return with void
D_OP(op_return_v);
stack = (int16 *)(stackBase + framePtr); // pop autos
@@ -1126,6 +1128,7 @@ bool Thread::interpret(void) {
case op_reply:
case op_animate:
script_error("Feature not implemented.\n");
+ break;
default:
script_error("fatal error: undefined opcode");
@@ -1804,10 +1807,6 @@ scriptResult runScript(uint16 exportEntryNum, scriptCallFrame &args) {
scriptResult result;
Thread *saveThread = thisThread;
- // Lookup function entry point in export table
- if (exportEntryNum < 0)
- error("SAGA failure: Attempt to run script with invalid export ID %d.", exportEntryNum);
-
assert(exportEntryNum > 0);
lookupExport(exportEntryNum, segNum, segOff);
@@ -1857,10 +1856,6 @@ scriptResult runMethod(
if (bType == builtinAbstract)
index = scriptClassID;
- // Lookup class function table in export table
- if (scriptClassID < 0)
- error("SAGA failure: Attempt to run object script with invalid export ID %d.\n", scriptClassID);
-
lookupExport(scriptClassID, segNum, segOff);
// Get address of class function table
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index 10b9e88f18..6d236eded7 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -417,7 +417,7 @@ CManaIndicator *ManaIndicator = nullptr;
const int clickSounds = 3;
-int32 maxClicks = clickSounds;
+uint32 maxClicks = clickSounds;
int32 clickSizes[clickSounds];
uint8 *clickData[clickSounds];
@@ -1449,8 +1449,8 @@ void writePlaqText(gPort &port,
const char *msg, ...) {
char lineBuf[128];
va_list argptr;
- int16 cnt;
Rect16 workRect;
+ int16 cnt;
gFont *oldFont = port.font;
va_start(argptr, msg);
@@ -1501,12 +1501,11 @@ void writePlaqTextPos(gPort &port,
const char *msg, ...) {
char lineBuf[128];
va_list argptr;
- int16 cnt;
Point16 drawPos;
gFont *oldFont = port.font;
va_start(argptr, msg);
- cnt = vsprintf(lineBuf, msg, argptr);
+ vsprintf(lineBuf, msg, argptr);
va_end(argptr);
SAVE_GPORT_STATE(port);
@@ -2812,7 +2811,6 @@ void gEnchantmentDisplay::setValue(PlayerActorID pID) {
ContainerIterator cIter(a);
GameObject *obj;
- ObjectID id;
memset(newIconFlags, 0, sizeof newIconFlags);
@@ -2825,7 +2823,7 @@ void gEnchantmentDisplay::setValue(PlayerActorID pID) {
iconSpellBarrier,
*/
- for (id = iter.first(&obj); id != Nothing; id = iter.next(&obj)) {
+ for (ObjectID id1 = iter.first(&obj); id1 != Nothing; id1 = iter.next(&obj)) {
uint16 enchantmentID = obj->getExtra();
uint16 eType = getEnchantmentType(enchantmentID);
uint16 eSubType = getEnchantmentSubType(enchantmentID);
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 64780f9364..55b40e17bd 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -797,15 +797,14 @@ void cleanupGUIMessagers(void) {
#ifdef WriteStatus
void WriteStatusF(int16 line, const char *msg, ...) {
va_list argptr;
- int cnt;
if (displayEnabled()) {
va_start(argptr, msg);
if (line > 9) {
if (Status2[line - 10])
- cnt = Status2[line - 10]->va(msg, argptr);
+ Status2[line - 10]->va(msg, argptr);
} else {
if (Status[line])
- cnt = Status[line]->va(msg, argptr);
+ Status[line]->va(msg, argptr);
}
va_end(argptr);
}
@@ -813,11 +812,10 @@ void WriteStatusF(int16 line, const char *msg, ...) {
void WriteStatusF2(int16 line, const char *msg, ...) {
va_list argptr;
- int cnt;
if (displayEnabled()) {
va_start(argptr, msg);
if (Status2[line])
- cnt = Status2[line]->va(msg, argptr);
+ Status2[line]->va(msg, argptr);
va_end(argptr);
}
}
diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp
index e92e40c0ea..f286819160 100644
--- a/engines/saga2/motion.cpp
+++ b/engines/saga2/motion.cpp
@@ -2524,7 +2524,6 @@ void MotionTask::walkAction(void) {
Actor *a;
ActorAppearance *aa;
StandingTileInfo sti;
- ProtoObj *proto;
bool moveTaskWaiting = false,
moveTaskDone = false;
@@ -2539,8 +2538,6 @@ void MotionTask::walkAction(void) {
return;
}
- proto = a->proto();
-
// Make sure that the actor is interruptable
a->setInterruptablity(true);
@@ -4826,7 +4823,6 @@ falling:
// Calls the handling routine for each active motion task
void moveActors(int32 deltaTime) {
- deltaTime = 0;
MotionTask::updatePositions();
}
diff --git a/engines/saga2/msgbox.cpp b/engines/saga2/msgbox.cpp
index 62ef0a5a10..b5541c487d 100644
--- a/engines/saga2/msgbox.cpp
+++ b/engines/saga2/msgbox.cpp
@@ -249,7 +249,6 @@ void SimpleWindow::drawClipped(
int16 textPos = textPosHigh;
//textPallete pal( 33+9, 36+9, 41+9, 34+9, 40+9, 43+9 );
textPallete pal(33 + 9, 33 + 9, 41 + 9, 33 + 9, 33 + 9, 41 + 9);
- bool selected = false;
box.x += 10;
box.y += 10;
@@ -260,7 +259,7 @@ void SimpleWindow::drawClipped(
pointer.hide(port, extent); // hide mouse pointer
DrawOutlineFrame(port, extent, windowColor);
- writeWrappedPlaqText(port, box, mbButtonFont, textPos, pal, selected, title);
+ writeWrappedPlaqText(port, box, mbButtonFont, textPos, pal, false, title);
gWindow::drawClipped(port, p, r);
@@ -347,9 +346,8 @@ void SimpleWindow::DrawOutlineFrame(gPort &port, const Rect16 &r, int16 fillColo
SimpleButton
* ===================================================================== */
-SimpleButton::SimpleButton(gWindow &win, const Rect16 &box, const char *title, uint16 ident,
- AppFunc *cmd)
- : gControl(win, box, title, ident, cmd) {
+SimpleButton::SimpleButton(gWindow &win, const Rect16 &box, const char *title_, uint16 ident, AppFunc *cmd_)
+ : gControl(win, box, title_, ident, cmd_) {
window = &win;
}
diff --git a/engines/saga2/noise.cpp b/engines/saga2/noise.cpp
index 6bb858d290..60c4208805 100644
--- a/engines/saga2/noise.cpp
+++ b/engines/saga2/noise.cpp
@@ -65,7 +65,6 @@ extern audioInterface *audio;
extern hResource *soundResFile; // script resources
extern hResource *voiceResFile; // script resources
-extern int32 maxClicks;
extern int32 clickSizes[];
extern uint8 *clickData[];
@@ -208,7 +207,7 @@ BUFFERLOD(flushMemSound) {
static ATTENUATOR(volumeFromDist) {
TilePoint tp(loc.x, loc.y, 0);
- int32 dist = tp.quickHDistance();
+ uint32 dist = tp.quickHDistance();
if (dist < fullVolumeDist) {
return abs(maxVol);
} else if (dist < offVolumeDist) {
Commit: 14da1dcc518f904759e59196c7d3d780b28ee925
https://github.com/scummvm/scummvm/commit/14da1dcc518f904759e59196c7d3d780b28ee925
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:33+02:00
Commit Message:
SAGA2: More gcc warning fixes
Changed paths:
engines/saga2/objects.cpp
engines/saga2/objects.h
engines/saga2/objproto.cpp
engines/saga2/panel.cpp
engines/saga2/panel.h
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index a4296e4144..40b4bb28d8 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -529,7 +529,7 @@ void GameObject::objCursorText(char nameBuf[], const int8 size, int16 count) {
// put the object name into the buffer as a default value
Common::strlcpy(nameBuf, objName(), size);
- assert(strlen(objName()) < size - addTextSize);
+ assert(strlen(objName()) < (uint)(size - addTextSize));
// check to see if this item is a physical object
// if so, then give the count of the item ( if stacked )
@@ -604,10 +604,8 @@ void GameObject::objCursorText(char nameBuf[], const int8 size, int16 count) {
assert(player);
int16 manaAmount;
- int16 baseManaAmount;
manaAmount = player->getEffStats()->mana(manaColor);
- baseManaAmount = player->getBaseStats().mana(manaColor);
sprintf(nameBuf, "%s [x%d]", objName(), manaAmount / manaCost);
}
@@ -1471,7 +1469,7 @@ void GameObject::updateState(void) {
* ======================================================================= */
const char *GameObject::nameText(uint16 index) {
- if (index < 0 || index >= nameListCount)
+ if (index >= nameListCount)
return "Bad Name Index";
return nameList[index];
@@ -2341,6 +2339,8 @@ GameWorld::GameWorld(int16 map) {
// Constructor -- reconstruct from archive buffer
GameWorld::GameWorld(void **buf) {
+ warning("STUB:GameWorld::GameWorld()");
+#if 0
int16 *bufferPtr = (int16 *)*buf;
size.u = size.v = *bufferPtr++;
@@ -2366,6 +2366,7 @@ GameWorld::GameWorld(void **buf) {
}
*buf = bufferPtr;
+#endif
}
//-------------------------------------------------------------------
@@ -3317,7 +3318,7 @@ SectorRegionObjectIterator::SectorRegionObjectIterator(GameWorld *world) :
ObjectID SectorRegionObjectIterator::first(GameObject **obj) {
Sector *currentSector;
- currentObject = nullptr;
+ _currentObject = nullptr;
sectorCoords = minSector;
currentSector = searchWorld->getSector(sectorCoords.u, sectorCoords.v);
@@ -3335,9 +3336,9 @@ ObjectID SectorRegionObjectIterator::first(GameObject **obj) {
sectorCoords.v);
}
- currentObject = GameObject::objectAddress(currentSector->childID);
+ _currentObject = GameObject::objectAddress(currentSector->childID);
- if (obj != nullptr) *obj = currentObject;
+ if (obj != nullptr) *obj = _currentObject;
return currentSector->childID;
}
@@ -3352,7 +3353,7 @@ ObjectID SectorRegionObjectIterator::next(GameObject **obj) {
ObjectID currentObjectID;
- currentObjectID = currentObject->IDNext();
+ currentObjectID = _currentObject->IDNext();
while (currentObjectID == Nothing) {
Sector *currentSector;
@@ -3375,9 +3376,9 @@ ObjectID SectorRegionObjectIterator::next(GameObject **obj) {
currentObjectID = currentSector->childID;
}
- currentObject = GameObject::objectAddress(currentObjectID);
+ _currentObject = GameObject::objectAddress(currentObjectID);
- if (obj != nullptr) *obj = currentObject;
+ if (obj != nullptr) *obj = _currentObject;
return currentObjectID;
}
@@ -3900,7 +3901,7 @@ bool ActiveRegionObjectIterator::nextSector(void) {
ObjectID ActiveRegionObjectIterator::first(GameObject **obj) {
ObjectID currentObjectID = Nothing;
- currentObject = nullptr;
+ _currentObject = nullptr;
if (firstSector()) {
Sector *currentSector;
@@ -3912,7 +3913,7 @@ ObjectID ActiveRegionObjectIterator::first(GameObject **obj) {
assert(currentSector != nullptr);
currentObjectID = currentSector->childID;
- currentObject = currentObjectID != Nothing
+ _currentObject = currentObjectID != Nothing
? GameObject::objectAddress(currentObjectID)
: nullptr;
@@ -3926,13 +3927,13 @@ ObjectID ActiveRegionObjectIterator::first(GameObject **obj) {
assert(currentSector != nullptr);
currentObjectID = currentSector->childID;
- currentObject = currentObjectID != Nothing
+ _currentObject = currentObjectID != Nothing
? GameObject::objectAddress(currentObjectID)
: nullptr;
}
}
- if (obj != nullptr) *obj = currentObject;
+ if (obj != nullptr) *obj = _currentObject;
return currentObjectID;
}
@@ -3945,8 +3946,8 @@ ObjectID ActiveRegionObjectIterator::next(GameObject **obj) {
ObjectID currentObjectID;
- currentObjectID = currentObject->IDNext();
- currentObject = currentObjectID != Nothing
+ currentObjectID = _currentObject->IDNext();
+ _currentObject = currentObjectID != Nothing
? GameObject::objectAddress(currentObjectID)
: nullptr;
@@ -3962,12 +3963,12 @@ ObjectID ActiveRegionObjectIterator::next(GameObject **obj) {
assert(currentSector != nullptr);
currentObjectID = currentSector->childID;
- currentObject = currentObjectID != Nothing
+ _currentObject = currentObjectID != Nothing
? GameObject::objectAddress(currentObjectID)
: nullptr;
}
- if (obj != nullptr) *obj = currentObject;
+ if (obj != nullptr) *obj = _currentObject;
return currentObjectID;
}
diff --git a/engines/saga2/objects.h b/engines/saga2/objects.h
index 9ad070ebb9..e4ac025905 100644
--- a/engines/saga2/objects.h
+++ b/engines/saga2/objects.h
@@ -920,7 +920,7 @@ class SectorRegionObjectIterator : public ObjectIterator {
maxSector,
sectorCoords;
GameWorld *searchWorld;
- GameObject *currentObject;
+ GameObject *_currentObject;
public:
// Constructor
@@ -1210,7 +1210,7 @@ class ActiveRegionObjectIterator : public ObjectIterator {
sectorCoords;
uint8 sectorBitMask;
GameWorld *currentWorld;
- GameObject *currentObject;
+ GameObject *_currentObject;
bool firstActiveRegion(void);
bool nextActiveRegion(void);
diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp
index f1488512fc..75fcf3a260 100644
--- a/engines/saga2/objproto.cpp
+++ b/engines/saga2/objproto.cpp
@@ -1709,7 +1709,7 @@ uint8 MeleeWeaponProto::defenseDirMask(void) {
// Rate this weapon's goodness for a specified attack situation
uint8 MeleeWeaponProto::weaponRating(
- ObjectID weaponID,
+ ObjectID weaponID_,
ObjectID wielderID,
ObjectID targetID) {
assert(isActor(wielderID));
@@ -1932,13 +1932,13 @@ bool BowProto::useSlotAvailable(GameObject *obj, Actor *a) {
// Rate this weapon's goodness for a specified attack situation
uint8 BowProto::weaponRating(
- ObjectID weaponID,
+ ObjectID weaponID_,
ObjectID wielderID,
ObjectID targetID) {
assert(isActor(wielderID));
assert(isObject(targetID) || isActor(targetID));
- if (getProjectile(weaponID, wielderID) == NULL) return 0;
+ if (getProjectile(weaponID_, wielderID) == NULL) return 0;
Actor *wielder = (Actor *)GameObject::objectAddress(wielderID);
@@ -2022,10 +2022,10 @@ bool WeaponWandProto::useSlotAvailable(GameObject *obj, Actor *a) {
// Rate this weapon's goodness for a specified attack situation
uint8 WeaponWandProto::weaponRating(
- ObjectID weaponID,
+ ObjectID weaponID_,
ObjectID wielderID,
ObjectID targetID) {
- assert(isObject(weaponID) || isActor(weaponID));
+ assert(isObject(weaponID_) || isActor(weaponID_));
assert(isActor(wielderID));
assert(isObject(targetID) || isActor(targetID));
@@ -2037,7 +2037,7 @@ uint8 WeaponWandProto::weaponRating(
&& !wielder->isActionAvailable(fightStanceAction(wielderID)))
return 0;
- GameObject *weapon = GameObject::objectAddress(weaponID),
+ GameObject *weapon = GameObject::objectAddress(weaponID_),
*target = GameObject::objectAddress(targetID);
int16 dist = (target->getLocation() - wielder->getLocation()).quickHDistance();
uint8 rating = 0;
@@ -2088,7 +2088,7 @@ bool ProjectileProto::isObjectBeingUsed(GameObject *) {
// Rate this weapon's goodness for a specified attack situation
uint8 ProjectileProto::weaponRating(
- ObjectID weaponID,
+ ObjectID weaponID_,
ObjectID wielderID,
ObjectID targetID) {
// Projectiles are worthless as far as wieldable weapons
@@ -2763,13 +2763,13 @@ void EnchantmentProto::doBackgroundUpdate(GameObject *obj) {
// then hurt the victim
if (parentObj && isActor(parentObj)) {
// get the enchantment type
- uint16 flags = obj->getExtra();
- uint16 type = getEnchantmentType(flags),
- subType = getEnchantmentSubType(flags);
+ uint16 flgs = obj->getExtra();
+ uint16 type = getEnchantmentType(flgs),
+ subType = getEnchantmentSubType(flgs);
if (type == effectOthers && subType == actorPoisoned) {
// get the damage amount for this poison
- int16 damage = getEnchantmentAmount(flags);
+ int16 damage = getEnchantmentAmount(flgs);
// apply the damage
parentObj->acceptDamage(obj->thisID(), damage, kDamagePoison);
@@ -2793,73 +2793,6 @@ void EnchantmentProto::doBackgroundUpdate(GameObject *obj) {
}
}
-/*
-ContainerWindow *EnchantmentProto::makeWindow( GameObject *Obj )
-{
- ContainerWindow *window;
-
- uint32 contContextID = RES_ID( 'C', 'O', 'N', 'T' );
-
- ButtonInfoStruct CloseInfo( entCloseBtnRect,
- contContextID,
- 'E', 'C', 'L',
- 0, 1 ),
-
- ScrollInfo( entScrollBtnRect,
- contContextID,
- 'E', 'S', 'L',
- 0, 1 );
-
- window = new EnchContainerWindow(
-
- // the obj
- Obj,
-
- // rect of the window
- physWindowRect,
-
- // start position of container hot spot section
- entHotSpotXY,
-
- // object drawing information
- entObjectDisplayRect,
-
- // gauge image information
- gaugesImageInfo,
- weightPieImageInfo,
- encumPieImageInfo,
-
- // button information
- CloseInfo,
- ScrollInfo,
-
- // icon positioning
- Point16( physIconOriginX, physIconOriginY ),
- Point16( physIconSpaceX, physIconSpaceY ),
- 2, //Rows
- 2, //Cols
- 4 );//Total Rows
-
-
- // init the resource context handle
- hResContext *decRes = resFile->newContext( contContextID,
- "enchant container window resource" );
-
-
- // set the decorations for this window
- window->setDecorations( enchantDecorations,
- ARRAYSIZE( enchantDecorations ),
- decRes, 'E', 'F', 'R' );
-
-
- resFile->disposeContext( decRes );
- decRes = NULL;
-
- return window;
-}
-*/
-
-
/* ======================================================================== *
GeneratorProto
* ======================================================================== */
@@ -2930,7 +2863,7 @@ void EncounterGeneratorProto::doBackgroundUpdate(GameObject *obj) {
// Now, roll to see if we got an encounter!
- if ((g_vm->_rnd->getRandomNumber(65534) & 0x0000ffff) < prob) {
+ if ((g_vm->_rnd->getRandomNumber(65534) & 0x0000ffff) < (uint)prob) {
scriptCallFrame scf;
#if DEBUG
diff --git a/engines/saga2/panel.cpp b/engines/saga2/panel.cpp
index 1f581ca342..1caf439d2d 100644
--- a/engines/saga2/panel.cpp
+++ b/engines/saga2/panel.cpp
@@ -589,8 +589,8 @@ void gWindow::setPointer( gPixelMap &map, int x, int y )
gControl class: The basis for buttons and other controls.
* ===================================================================== */
-gControl::gControl(gPanelList &list, const Rect16 &box, const char *title, uint16 ident,
- AppFunc *cmd) : gPanel(list, box, title, ident, cmd) {
+gControl::gControl(gPanelList &list, const Rect16 &box, const char *title_, uint16 ident,
+ AppFunc *cmd) : gPanel(list, box, title_, ident, cmd) {
accelKey = 0;
// Add control to the window's control list.
diff --git a/engines/saga2/panel.h b/engines/saga2/panel.h
index b8112bb1d0..b4e84c8eb7 100644
--- a/engines/saga2/panel.h
+++ b/engines/saga2/panel.h
@@ -133,7 +133,7 @@ protected:
gWindow &window; // window this belongs to
Rect16 extent; // rectangular bounds of the control
const char *title; // title of the panel
- int enabled, // allows disabling the panel
+ byte enabled, // allows disabling the panel
selected, // some panels have a selected state
imageLabel, // button label is image, not text
ghosted, // button is dimmed
@@ -226,12 +226,12 @@ class gPanelMessage {
public:
Point16 pickPos, // mouse position relative to panel
pickAbsPos; // mouse position relative to display
- int leftButton : 1, // left button state
- rightButton : 1, // right button state
- inPanel : 1, // whether mouse is currently in panel
- pointerEnter : 1, // set when pointer enters panel
- pointerLeave : 1, // set when pointer leaves panel
- doubleClick : 1; // set when double click detected
+ byte leftButton, // left button state
+ rightButton, // right button state
+ inPanel, // whether mouse is currently in panel
+ pointerEnter, // set when pointer enters panel
+ pointerLeave, // set when pointer leaves panel
+ doubleClick; // set when double click detected
// For keyboard input
Commit: 45075d5e0c3912445612688d03ad660b6d712c33
https://github.com/scummvm/scummvm/commit/45075d5e0c3912445612688d03ad660b6d712c33
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:33+02:00
Commit Message:
SAGA2: Fix remaining trivial gcc warnings
Changed paths:
engines/saga2/gtextbox.cpp
engines/saga2/gtextbox.h
engines/saga2/path.cpp
engines/saga2/patrol.cpp
engines/saga2/sprite.cpp
engines/saga2/terrain.cpp
engines/saga2/tileload.cpp
engines/saga2/uidialog.cpp
diff --git a/engines/saga2/gtextbox.cpp b/engines/saga2/gtextbox.cpp
index 3fbcbf741c..39bb62fe00 100644
--- a/engines/saga2/gtextbox.cpp
+++ b/engines/saga2/gtextbox.cpp
@@ -157,8 +157,8 @@ gTextBox::gTextBox(
int8 FGColor,
int8 BGColor,
int8 HLColor,
- int8 BGHLColor,
- int8 CRColor,
+ byte BGHLColor,
+ byte CRColor,
const char *title_,
const char *buffer,
char **stringBufs,
diff --git a/engines/saga2/gtextbox.h b/engines/saga2/gtextbox.h
index 2cf74b2955..9d4a3a0ba4 100644
--- a/engines/saga2/gtextbox.h
+++ b/engines/saga2/gtextbox.h
@@ -93,8 +93,8 @@ private:
int8 fontColorFore;
int8 fontColorBack;
int8 fontColorHilite;
- int8 fontColorBackHilite;
- int8 cursorColor;
+ byte fontColorBackHilite;
+ byte cursorColor;
int32 blinkStart;
int16 blinkX;
int8 blinkState;
@@ -166,8 +166,8 @@ public:
int8 FGColor, // foreground color of font
int8 BGColor, // background color of font
int8 HLColor, // hilite color of font
- int8 BGHLColor, // back ground hilite color
- int8 CRColor, // cusor color
+ byte BGHLColor, // back ground hilite color
+ byte CRColor, // cusor color
const char *title, // title bar
const char *buffer, // buffer to edit
char **stringBufs,
diff --git a/engines/saga2/path.cpp b/engines/saga2/path.cpp
index ddaa26de53..1d1100d09e 100644
--- a/engines/saga2/path.cpp
+++ b/engines/saga2/path.cpp
@@ -1747,7 +1747,8 @@ PathResult PathRequest::findPath(void) {
0)
+ baseTileCoords,
TilePoint(1, fetchRadius << 1, 0));
- case 1: // FALL THROUGH
+ // fall through
+ case 1:
tileArray.fetchTileSection(
TilePoint(
qi.u - fetchRadius,
@@ -1764,7 +1765,8 @@ PathResult PathRequest::findPath(void) {
0)
+ baseTileCoords,
TilePoint(fetchRadius << 1, 1, 0));
- case 3: // FALL THROUGH
+ // fall through
+ case 3:
tileArray.fetchTileSection(
TilePoint(
qi.u - fetchRadius,
@@ -1781,7 +1783,8 @@ PathResult PathRequest::findPath(void) {
0)
+ baseTileCoords,
TilePoint(1, fetchRadius << 1, 0));
- case 5: // FALL THROUGH
+ // fall through
+ case 5:
tileArray.fetchTileSection(
TilePoint(
qi.u - fetchRadius,
@@ -1798,7 +1801,8 @@ PathResult PathRequest::findPath(void) {
0)
+ baseTileCoords,
TilePoint(fetchRadius << 1, 1, 0));
- case 7: // FALL THROUGH
+ // fall through
+ case 7:
tileArray.fetchTileSection(
TilePoint(
qi.u + fetchRadius,
@@ -2042,7 +2046,7 @@ bool PathRequest::timeLimitExceeded(void) {
#ifdef OLD_PATHFINDER_TIME_MGMT
return (gameTime - firstTick >= timeLimit);
#else
- uint32 cutoff = smartness / (queue.getCount() ? 5 : 8);
+ int32 cutoff = smartness / (queue.getCount() ? 5 : 8);
return (gameTime - firstTick >= cutoff);
#endif
}
@@ -2084,7 +2088,7 @@ void DestinationPathRequest::initialize(void) {
// Set and evaluate a new center location.
bool DestinationPathRequest::setCenter(
- const TilePoint &baseTileCoords,
+ const TilePoint &baseTileCoords_,
const QueueItem &qi) {
int16 dist,
zDist,
@@ -2092,7 +2096,7 @@ bool DestinationPathRequest::setCenter(
TilePoint targetDelta;
// Calculate the center coordinates.
- calcCenterPt(baseTileCoords, qi);
+ calcCenterPt(baseTileCoords_, qi);
// Determine the target vector in order to calculate distance.
targetDelta = (targetCoords - centerPt);
@@ -2207,14 +2211,14 @@ void WanderPathRequest::initialize(void) {
// Set and evaluate a new center location.
bool WanderPathRequest::setCenter(
- const TilePoint &baseTileCoords,
+ const TilePoint &baseTileCoords_,
const QueueItem &qi) {
int16 dist,
zDist;
TilePoint movementDelta;
// Calculate the center coordinates.
- calcCenterPt(baseTileCoords, qi);
+ calcCenterPt(baseTileCoords_, qi);
// Determine the movement vector in order to calculate distance.
movementDelta = (startingCoords - centerPt);
diff --git a/engines/saga2/patrol.cpp b/engines/saga2/patrol.cpp
index d4edb2ee8b..3268ad7570 100644
--- a/engines/saga2/patrol.cpp
+++ b/engines/saga2/patrol.cpp
@@ -182,7 +182,7 @@ const TilePoint &PatrolRouteIterator::operator*(void) const {
const PatrolRouteIterator &PatrolRouteIterator::operator++(void) {
const PatrolRoute &route = patrolRouteList[_mapNum]->getRoute(_routeNo);
- if (_vertexNo >= 0 & _vertexNo < route.vertices()) {
+ if (_vertexNo >= 0 && _vertexNo < route.vertices()) {
if (!(_flags & patrolRouteRandom)) {
if (!(_flags & patrolRouteInAlternate)) {
if (!(_flags & patrolRouteReverse))
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index 9132ee7357..ff2d559aec 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -786,7 +786,7 @@ SpriteSet::SpriteSet(Common::SeekableReadStream *stream) {
}
SpriteSet::~SpriteSet() {
- for (int i = 0; i < count; ++i) {
+ for (uint i = 0; i < count; ++i) {
if (_sprites[i])
delete _sprites[i];
}
diff --git a/engines/saga2/terrain.cpp b/engines/saga2/terrain.cpp
index c7bd6bd983..50e1b01ade 100644
--- a/engines/saga2/terrain.cpp
+++ b/engines/saga2/terrain.cpp
@@ -276,7 +276,7 @@ uint32 volumeTerrain(int16 mapNum, const TileRegion &vol) {
}
}
return terrain;
-};
+}
uint32 volumeTerrain(
int16 mapNum,
@@ -297,7 +297,7 @@ uint32 volumeTerrain(
terrain = volumeTerrain(mapNum, volume);
return terrain;
-};
+}
uint32 volumeTerrain(
int16 mapNum,
@@ -345,7 +345,7 @@ uint32 volumeTerrain(
terrain = volumeTerrain(mapNum, volume);
return terrain;
-};
+}
/* ===================================================================== *
Function to get the terrain info for linear area
diff --git a/engines/saga2/tileload.cpp b/engines/saga2/tileload.cpp
index 172aa5fd77..f74dd49093 100644
--- a/engines/saga2/tileload.cpp
+++ b/engines/saga2/tileload.cpp
@@ -55,8 +55,6 @@ static byte *tileResLoad(hResID i, bool asynch = false) {
HandleArray tileImageBanks(64, tileResLoad, tileImageID);
void initTileBank(int16 bankNum) {
- byte *th;
- th = tileImageBanks[bankNum];
}
void RHeapsAMess(void);
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index e75884411a..946a2eed01 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -706,26 +706,21 @@ int16 FileDialog(int16 fileProcess) {
// create the window
win = new ModalWindow(saveLoadWindowRect, 0, nullptr);
- gCompButton *t;
// make the quit button
- t = new gCompButton(*win, saveLoadButtonRects[0], pushBtnIm, numBtnImages, btnStrings[stringIndex][0], pal, 0, cmdDialogQuit);
+ new gCompButton(*win, saveLoadButtonRects[0], pushBtnIm, numBtnImages, btnStrings[stringIndex][0], pal, 0, cmdDialogQuit);
//t->accelKey=0x1B;
// make the Save/Load button
- t = new gCompButton(*win, saveLoadButtonRects[1],
- pushBtnIm, numBtnImages, btnStrings[stringIndex][1], pal, fileProcess, fileCommands[fileProcess]);
+ new gCompButton(*win, saveLoadButtonRects[1], pushBtnIm, numBtnImages, btnStrings[stringIndex][1], pal, fileProcess, fileCommands[fileProcess]);
//t->accelKey=0x0D;
// make the up arrow
- t = new gCompButton(*win, saveLoadButtonRects[2],
- arrowUpIm, numBtnImages, 0, cmdSaveDialogUp);
+ new gCompButton(*win, saveLoadButtonRects[2], arrowUpIm, numBtnImages, 0, cmdSaveDialogUp);
//t->accelKey=33+0x80;
// make the down arrow
- t = new gCompButton(*win, saveLoadButtonRects[3],
- arrowDnIm, numBtnImages, 0, cmdSaveDialogDown);
+ new gCompButton(*win, saveLoadButtonRects[3], arrowDnIm, numBtnImages, 0, cmdSaveDialogDown);
//t->accelKey=34+0x80;
// attach the title
- new CPlaqText(*win, saveLoadTextRects[0],
- textStrings[stringIndex][0], &Plate18Font, 0, pal, 0, nullptr);
+ new CPlaqText(*win, saveLoadTextRects[0], textStrings[stringIndex][0], &Plate18Font, 0, pal, 0, nullptr);
Commit: 45a0023da886c82a2ff65f36cfe9bd27e609e753
https://github.com/scummvm/scummvm/commit/45a0023da886c82a2ff65f36cfe9bd27e609e753
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:33+02:00
Commit Message:
SAGA2: Fix bug in the original with poisoning effect
Changed paths:
engines/saga2/weapons.cpp
diff --git a/engines/saga2/weapons.cpp b/engines/saga2/weapons.cpp
index a5ee27e1a2..96da0ee379 100644
--- a/engines/saga2/weapons.cpp
+++ b/engines/saga2/weapons.cpp
@@ -95,6 +95,7 @@ ProtoEffect *createNewProtoEffect(Common::SeekableReadStream *stream) {
case effectPoison:
pe = new ProtoEnchantment(makeEnchantmentID(baseDamage), // poison
reserved0, reserved1);
+ break;
case effectTAG:
pe = new ProtoTAGEffect((effectTAGTypes)effectType, skillDamage, baseDamage);
Commit: 236130d6afc828c48f3f9168a8e5842af873f0c2
https://github.com/scummvm/scummvm/commit/236130d6afc828c48f3f9168a8e5842af873f0c2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:33+02:00
Commit Message:
SAGA2: Fix bug in the original, when bouncing was leading to death
Changed paths:
engines/saga2/spelcast.cpp
diff --git a/engines/saga2/spelcast.cpp b/engines/saga2/spelcast.cpp
index aa9fe69af9..99ff1c11ec 100644
--- a/engines/saga2/spelcast.cpp
+++ b/engines/saga2/spelcast.cpp
@@ -823,6 +823,7 @@ void Effectron::bump(void) {
switch (parent->dProto->elasticity) {
case ecFlagBounce :
velocity = -velocity;
+ break;
case ecFlagDie :
kill();
break;
Commit: 4b0b742baa37cd04e8c21640b99f0636010598f0
https://github.com/scummvm/scummvm/commit/4b0b742baa37cd04e8c21640b99f0636010598f0
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:33+02:00
Commit Message:
SAGA2: Revert stub in objObscured
Changed paths:
engines/saga2/objects.cpp
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 40b4bb28d8..39a778908e 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -4261,15 +4261,11 @@ bool objObscured(GameObject *testObj) {
bool obscured = false;
if (isObject(testObj)) {
- debug(3, "STUB: objObscured");
Point16 drawPos,
org;
ObjectSpriteInfo objSprInfo;
ColorTable objColors;
ProtoObj *proto = testObj->proto();
- ObjectID parent = testObj->_data.parentID;
- if (isWorld(parent) == false)
- return false;
// Calculate X, Y coordinates of the sprite
TileToScreenCoords(testObj->getLocation(), drawPos);
Commit: f39036ff8eb921e0954fdaacbd918a7376171db2
https://github.com/scummvm/scummvm/commit/f39036ff8eb921e0954fdaacbd918a7376171db2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:33+02:00
Commit Message:
SAGA2: Move motion.cpp from DList
Changed paths:
engines/saga2/motion.cpp
engines/saga2/motion.h
diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp
index f286819160..b363df12cf 100644
--- a/engines/saga2/motion.cpp
+++ b/engines/saga2/motion.cpp
@@ -48,9 +48,6 @@ namespace Saga2 {
bool interruptableMotionsPaused;
-// Used to track the next motion task to process
-static MotionTask *nextMT;
-
/* ===================================================================== *
Test Functions
* ===================================================================== */
@@ -353,23 +350,21 @@ uint8 computeTurnFrames(Direction fromDir, Direction toDir) {
//-----------------------------------------------------------------------
// The list of active motion tasks for all actors
-static uint8 mTaskListBuffer[sizeof(MotionTaskList)];
-
-static MotionTaskList &mTaskList = *((MotionTaskList *)mTaskListBuffer);
+static MotionTaskList mTaskList;
+static Common::List<MotionTask *>::iterator nextMT;
//-----------------------------------------------------------------------
// Initialize the MotionTaskList
MotionTaskList::MotionTaskList(void) {
- for (int i = 0; i < ARRAYSIZE(array); i++) {
- free.addTail(array[i]);
- }
}
//-----------------------------------------------------------------------
// Reconstruct motion task list from archive buffer
MotionTaskList::MotionTaskList(void **buf) {
+ warning("STUB: MotionTaskList::MotionTaskList(**buf)");
+#if 0
void *bufferPtr = *buf;
int16 i,
@@ -399,6 +394,7 @@ MotionTaskList::MotionTaskList(void **buf) {
}
*buf = bufferPtr;
+#endif
}
//-----------------------------------------------------------------------
@@ -409,13 +405,8 @@ int32 MotionTaskList::archiveSize(void) {
// Initilialize with sizeof motion task count
int32 size = sizeof(int16);
- MotionTask *mt;
-
- // Accumulate the archive size of each motion task
- for (mt = (MotionTask *)list.first();
- mt;
- mt = (MotionTask *)mt->next())
- size += mt->archiveSize();
+ for (Common::List<MotionTask *>::iterator it = _list.begin(); it != _list.end(); ++it)
+ size += (*it)->archiveSize();
return size;
}
@@ -424,24 +415,15 @@ int32 MotionTaskList::archiveSize(void) {
// Create an archive of the motion tasks in the specified buffer
void *MotionTaskList::archive(void *buf) {
- int16 motionTaskCount;
- MotionTask *mt;
-
- // Count the active motion tasks
- for (mt = (MotionTask *)list.first(), motionTaskCount = 0;
- mt;
- mt = (MotionTask *)mt->next())
- motionTaskCount++;
+ int16 motionTaskCount = _list.size();
// Store the motion task count
*((int16 *)buf) = motionTaskCount;
buf = (int16 *)buf + 1;
// Archive the active motion tasks
- for (mt = (MotionTask *)list.first();
- mt;
- mt = (MotionTask *)mt->next())
- buf = mt->archive(buf);
+ for (Common::List<MotionTask *>::iterator it = _list.begin(); it != _list.end(); ++it)
+ buf = (*it)->archive(buf);
return buf;
}
@@ -450,28 +432,22 @@ void *MotionTaskList::archive(void *buf) {
// Cleanup the motion tasks
void MotionTaskList::cleanup(void) {
- MotionTask *mt;
- MotionTask *nextMT_;
-
- // Remove all of the active motion tasks
- for (mt = (MotionTask *)list.first();
- mt;
- mt = nextMT_) {
- nextMT_ = (MotionTask *)mt->next();
- mt->remove();
- }
+ for (Common::List<MotionTask *>::iterator it = _list.begin(); it != _list.end(); ++it)
+ delete *it;
+
+ _list.clear();
}
//-----------------------------------------------------------------------
// Get a new motion task, if there is one available, and initialize it.
MotionTask *MotionTaskList::newTask(GameObject *obj) {
- MotionTask *mt;
+ MotionTask *mt;
// Check see if there's already motion associated with this object.
- for (mt = (MotionTask *)list.first();
- mt;
- mt = (MotionTask *)mt->next()) {
+ for (Common::List<MotionTask *>::iterator it = _list.begin(); it != _list.end(); ++it) {
+ mt = *it;
+
if (mt->object == obj) {
wakeUpThread(mt->thread, motionInterrupted);
mt->thread = NoThread;
@@ -481,24 +457,25 @@ MotionTask *MotionTaskList::newTask(GameObject *obj) {
}
if (mt == NULL) {
- mt = (MotionTask *)free.remHead();
+ mt = new MotionTask;
- if (mt) {
- mt->object = obj;
- mt->motionType = mt->prevMotionType = MotionTask::motionTypeNone;
- mt->pathFindTask = NULL;
- mt->pathCount = -1;
- mt->flags = 0;
- mt->velocity = TilePoint(0, 0, 0);
- mt->immediateLocation = mt->finalTarget = obj->getLocation();
- mt->thread = NoThread;
+ mt->object = obj;
+ mt->motionType = mt->prevMotionType = MotionTask::motionTypeNone;
+ mt->pathFindTask = NULL;
+ mt->pathCount = -1;
+ mt->flags = 0;
+ mt->velocity = TilePoint(0, 0, 0);
+ mt->immediateLocation = mt->finalTarget = obj->getLocation();
+ mt->thread = NoThread;
- list.addTail(*mt);
+ _list.push_back(mt);
- if (isActor(obj))((Actor *)obj)->moveTask = mt;
- }
+ if (isActor(obj))
+ ((Actor *)obj)->moveTask = mt;
}
+
obj->_data.objectFlags |= objectMoving;
+
return mt;
}
@@ -1198,8 +1175,8 @@ void *MotionTask::archive(void *buf) {
// When a motion task is finished, call this function to delete it.
void MotionTask::remove(int16 returnVal) {
- if (nextMT == this)
- nextMT = (MotionTask *)next();
+ if (nextMT != mTaskList._list.end() && *nextMT == this)
+ ++nextMT;
object->_data.objectFlags &= ~objectMoving;
if (objObscured(object))
@@ -1219,8 +1196,7 @@ void MotionTask::remove(int16 returnVal) {
a->setInterruptablity(true);
}
- DNode::remove();
- mTaskList.free.addTail(*this);
+ mTaskList._list.remove(this);
abortPathFind(this);
pathFindTask = NULL;
@@ -4169,21 +4145,21 @@ void MotionTask::defensiveMeleeAction(void) {
// Routine to update positions of all moving objects using MotionTasks
void MotionTask::updatePositions(void) {
- MotionTask *mt;
TilePoint targetVector;
TilePoint fallVelocity, terminalVelocity(15, 15, 0);
TilePoint curLoc;
int16 targetDist;
StandingTileInfo sti;
- nextMT = NULL;
- for (mt = (MotionTask *)mTaskList.list.first(); mt; mt = nextMT) {
+ for (Common::List<MotionTask *>::iterator it = mTaskList._list.begin(); it != mTaskList._list.end(); it = nextMT) {
+ MotionTask *mt = *it;
GameObject *obj = mt->object;
ProtoObj *proto = obj->proto();
Actor *a = (Actor *)obj;
bool moveTaskDone = false;
- nextMT = (MotionTask *)mt->next();
+ nextMT = it;
+ nextMT++;
if (!isWorld(obj->IDParent())) {
mt->remove();
@@ -4260,7 +4236,7 @@ void MotionTask::updatePositions(void) {
mt->finalTarget,
(mt->flags & requestRun) != 0);
}
- nextMT = mt;
+ nextMT = it;
}
} else {
a->setAction(newAction, 0);
@@ -4279,7 +4255,7 @@ void MotionTask::updatePositions(void) {
mt->finalTarget,
(mt->flags & requestRun) != 0);
}
- nextMT = mt;
+ nextMT = it;
} else if (mt->freeFall(obj->_data.location, sti) == false)
moveTaskDone = true;
} else {
@@ -4300,7 +4276,7 @@ void MotionTask::updatePositions(void) {
mt->finalTarget,
(mt->flags & requestRun) != 0);
}
- nextMT = mt;
+ nextMT = it;
}
}
break;
@@ -4341,7 +4317,7 @@ void MotionTask::updatePositions(void) {
if (targetDist > kTileUVSize) {
mt->motionType = mt->prevMotionType;
mt->flags |= reset;
- nextMT = mt;
+ nextMT = it;
} else
moveTaskDone = true;
}
@@ -4389,7 +4365,7 @@ void MotionTask::updatePositions(void) {
if (mt && mt->motionType == motionTypeUseObjectOnObject)
moveTaskDone = true;
else
- nextMT = mt;
+ nextMT = it;
}
}
} else {
@@ -4401,7 +4377,7 @@ void MotionTask::updatePositions(void) {
if (mt && mt->motionType == motionTypeUseObjectOnObject)
moveTaskDone = true;
else
- nextMT = mt;
+ nextMT = it;
}
break;
@@ -4442,7 +4418,7 @@ void MotionTask::updatePositions(void) {
if (mt && mt->motionType == motionTypeUseObjectOnTAI)
moveTaskDone = true;
else
- nextMT = mt;
+ nextMT = it;
}
break;
@@ -4462,7 +4438,7 @@ void MotionTask::updatePositions(void) {
if (mt && mt->motionType == motionTypeUseObjectOnLocation)
moveTaskDone = true;
else
- nextMT = mt;
+ nextMT = it;
}
break;
@@ -4522,7 +4498,7 @@ void MotionTask::updatePositions(void) {
if (mt && mt->motionType == motionTypeDropObject)
moveTaskDone = true;
else
- nextMT = mt;
+ nextMT = it;
}
} else {
// The actor will now be uniterruptable
@@ -4533,7 +4509,7 @@ void MotionTask::updatePositions(void) {
if (mt && mt->motionType == motionTypeDropObject)
moveTaskDone = true;
else
- nextMT = mt;
+ nextMT = it;
}
CMassWeightIndicator::bRedraw = true; // tell the mass/weight indicators to refresh
@@ -4557,7 +4533,7 @@ void MotionTask::updatePositions(void) {
if (mt && mt->motionType == motionTypeDropObjectOnObject)
moveTaskDone = true;
else
- nextMT = mt;
+ nextMT = it;
}
} else {
// The actor will now be uniterruptable
@@ -4569,7 +4545,7 @@ void MotionTask::updatePositions(void) {
if (mt && mt->motionType == motionTypeDropObjectOnObject)
moveTaskDone = true;
else
- nextMT = mt;
+ nextMT = it;
}
CMassWeightIndicator::bRedraw = true; // tell the mass/weight indicators to refresh
@@ -4595,7 +4571,7 @@ void MotionTask::updatePositions(void) {
if (mt && mt->motionType == motionTypeDropObjectOnTAI)
moveTaskDone = true;
else
- nextMT = mt;
+ nextMT = it;
}
break;
@@ -4987,6 +4963,8 @@ void saveMotionTasks(SaveFileConstructor &saveGame) {
// Load the motion task list from a save file
void loadMotionTasks(SaveFileReader &saveGame) {
+ warning("STUB: loadMotionTasks()");
+#if 0
// If there is no saved data, simply call the default constructor
if (saveGame.getChunkSize() == 0) {
new (&mTaskList) MotionTaskList;
@@ -5009,6 +4987,7 @@ void loadMotionTasks(SaveFileReader &saveGame) {
new (&mTaskList) MotionTaskList(&bufferPtr);
free(archiveBuffer);
+#endif
}
//-----------------------------------------------------------------------
diff --git a/engines/saga2/motion.h b/engines/saga2/motion.h
index 65ab1dd70e..6ff7a065f6 100644
--- a/engines/saga2/motion.h
+++ b/engines/saga2/motion.h
@@ -28,7 +28,6 @@
#define SAGA2_MOTION_H
#include "saga2/actor.h"
-#include "saga2/dlist.h"
namespace Saga2 {
@@ -90,7 +89,7 @@ void setObjectSurface(GameObject *obj, StandingTileInfo &sti);
// can set off trap
// can explode
-class MotionTask : private DNode {
+class MotionTask {
friend class MotionTaskList;
friend class PathRequest;
friend class DestinationPathRequest;
@@ -539,9 +538,7 @@ public:
class MotionTaskList {
friend class MotionTask;
- DList list,
- free;
- MotionTask array[48];
+ Common::List<MotionTask *> _list;
public:
// Default constructor
Commit: d39fa6e86ef9bc707459a691b52fdff36a863c22
https://github.com/scummvm/scummvm/commit/d39fa6e86ef9bc707459a691b52fdff36a863c22
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:33+02:00
Commit Message:
SAGA2: Fallback for invalid sector deactivation
Changed paths:
engines/saga2/objects.cpp
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 39a778908e..3c437f792f 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -3199,8 +3199,13 @@ void ActiveRegion::update(void) {
for (v = region.min.v; v < region.max.v; v++) {
if (uOutOfRange
|| v < newRegion.min.v
- || v >= newRegion.max.v)
- world->getSector(u, v)->deactivate();
+ || v >= newRegion.max.v) {
+
+ if(Sector *sect = world->getSector(u, v))
+ sect->deactivate();
+ else
+ warning("ActiveRegion::update: Invalid Sector (%d, %d)", u, v);
+ }
}
}
Commit: f60d4a18fc18112703e38c8a23427241420ba5ae
https://github.com/scummvm/scummvm/commit/f60d4a18fc18112703e38c8a23427241420ba5ae
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:33+02:00
Commit Message:
SAGA2: Fix MotionTaskList::newTask
Changed paths:
engines/saga2/motion.cpp
diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp
index b363df12cf..ad80317c97 100644
--- a/engines/saga2/motion.cpp
+++ b/engines/saga2/motion.cpp
@@ -442,13 +442,13 @@ void MotionTaskList::cleanup(void) {
// Get a new motion task, if there is one available, and initialize it.
MotionTask *MotionTaskList::newTask(GameObject *obj) {
- MotionTask *mt;
+ MotionTask *mt = nullptr;
// Check see if there's already motion associated with this object.
for (Common::List<MotionTask *>::iterator it = _list.begin(); it != _list.end(); ++it) {
- mt = *it;
- if (mt->object == obj) {
+ if ((*it)->object == obj) {
+ mt = *it;
wakeUpThread(mt->thread, motionInterrupted);
mt->thread = NoThread;
@@ -456,12 +456,12 @@ MotionTask *MotionTaskList::newTask(GameObject *obj) {
}
}
- if (mt == NULL) {
+ if (mt == nullptr) {
mt = new MotionTask;
mt->object = obj;
mt->motionType = mt->prevMotionType = MotionTask::motionTypeNone;
- mt->pathFindTask = NULL;
+ mt->pathFindTask = nullptr;
mt->pathCount = -1;
mt->flags = 0;
mt->velocity = TilePoint(0, 0, 0);
Commit: 51a6baab82e66e717474ba34fc87d5ecb6a92c3e
https://github.com/scummvm/scummvm/commit/51a6baab82e66e717474ba34fc87d5ecb6a92c3e
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:33+02:00
Commit Message:
SAGA2: Fix assignment flag setting
Changed paths:
engines/saga2/assign.cpp
engines/saga2/assign.h
diff --git a/engines/saga2/assign.cpp b/engines/saga2/assign.cpp
index 1fcce574f2..bc3d6fc963 100644
--- a/engines/saga2/assign.cpp
+++ b/engines/saga2/assign.cpp
@@ -35,6 +35,8 @@ namespace Saga2 {
const uint16 indefinitely = CalenderTime::framesPerDay;
+extern Common::Array<char *> nameList;
+
/* ===================================================================== *
ActorAssignment member functions
* ===================================================================== */
@@ -44,7 +46,10 @@ ActorAssignment::ActorAssignment(Actor *a, uint16 until) :
startFrame(calender.frameInDay()),
endFrame(until) {
_actor = a;
+ debugC(2, kDebugActors, "New assignment for %p (%s) from %d until %d: %p",
+ (void *)a, nameList[a->proto()->nameIndex], startFrame, endFrame, (void *)this);
a->_assignment = this;
+ a->flags |= hasAssignment;
}
//----------------------------------------------------------------------
@@ -60,6 +65,7 @@ ActorAssignment::ActorAssignment(Actor *ac, void **buf) {
_actor = ac;
ac->_assignment = this;
+ a->flags |= hasAssignment;
}
//----------------------------------------------------------------------
@@ -67,6 +73,8 @@ ActorAssignment::ActorAssignment(Actor *ac, void **buf) {
ActorAssignment::~ActorAssignment(void) {
Actor *a = getActor();
+ debugC(2, kDebugActors, "Ending assignment for %p (%s): %p",
+ (void *)a, nameList[a->proto()->nameIndex], (void *)this);
// Determine if the actor has a task initiated by this assignment
if (a->currentGoal == actorGoalFollowAssignment
@@ -76,6 +84,8 @@ ActorAssignment::~ActorAssignment(void) {
delete a->curTask;
a->curTask = NULL;
}
+
+ a->flags &= ~hasAssignment;
}
//----------------------------------------------------------------------
diff --git a/engines/saga2/assign.h b/engines/saga2/assign.h
index 9e052f3723..9db8e665a9 100644
--- a/engines/saga2/assign.h
+++ b/engines/saga2/assign.h
@@ -50,6 +50,11 @@ enum AssignmentTypes {
* ===================================================================== */
class ActorAssignment {
+
+ enum {
+ hasAssignment = (1 << 3)
+ };
+
uint16 startFrame, // Time in day when this was constructed
endFrame; // End time of the assignment
Commit: 3b9c1f530fc22f9baea2b4a922a2ae0d177932c0
https://github.com/scummvm/scummvm/commit/3b9c1f530fc22f9baea2b4a922a2ae0d177932c0
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:34+02:00
Commit Message:
SAGA2: Fix copy-paste error in actor.cpp
Changed paths:
engines/saga2/assign.cpp
diff --git a/engines/saga2/assign.cpp b/engines/saga2/assign.cpp
index bc3d6fc963..575110d752 100644
--- a/engines/saga2/assign.cpp
+++ b/engines/saga2/assign.cpp
@@ -65,7 +65,7 @@ ActorAssignment::ActorAssignment(Actor *ac, void **buf) {
_actor = ac;
ac->_assignment = this;
- a->flags |= hasAssignment;
+ ac->flags |= hasAssignment;
}
//----------------------------------------------------------------------
Commit: 7a8a5e6e6e176425bc57113e6e0bae8de528cf79
https://github.com/scummvm/scummvm/commit/7a8a5e6e6e176425bc57113e6e0bae8de528cf79
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:34+02:00
Commit Message:
SAGA2: Added more debug output
Changed paths:
engines/saga2/actor.cpp
engines/saga2/detection.cpp
engines/saga2/objects.cpp
engines/saga2/saga2.h
engines/saga2/task.cpp
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 03f004bfbe..2b1aedaf42 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -985,6 +985,8 @@ void Actor::init(
uint8 initFlags) {
int i;
+ debugC(1, kDebugActors, "Actor init flags: %d, permanent: %d", initFlags, initFlags & actorPermanent);
+
// Fixup the prototype pointer to point to an actor prototype
prototype = (ProtoObj *)&actorProtos[protoIndex];
@@ -1066,7 +1068,6 @@ void Actor::init(
//-----------------------------------------------------------------------
// Actor constructor -- copies the resource fields and simply NULL's most
// of the rest of the data members
-
Actor::Actor(void) {
prototype = nullptr;
faction = 0;
@@ -1379,6 +1380,9 @@ Actor *Actor::newActor(
GameObject *limbo = objectAddress(ActorLimbo);
Actor *a;
+ debugC(2, kDebugActors, "Actor::newActor(protoNum = %d, nameIndex = %d, scriptIndex = %d, appearanceNum = %d, colorSchemeIndex = %d, factionNum = %d, initFlags = %d)",
+ protoNum, nameIndex, scriptIndex, appearanceNum, colorSchemeIndex, factionNum, initFlags);
+
if (limbo->IDChild() == Nothing) {
int16 i;
diff --git a/engines/saga2/detection.cpp b/engines/saga2/detection.cpp
index cc02059aef..6776e8fae6 100644
--- a/engines/saga2/detection.cpp
+++ b/engines/saga2/detection.cpp
@@ -37,6 +37,7 @@ static const DebugChannelDef debugFlagList[] = {
{Saga2::kDebugLoading, "loading", "Debug the loading"},
{Saga2::kDebugTimers, "timers", "Debug the timers"},
{Saga2::kDebugPath, "path", "Debug the pathfinding"},
+ {Saga2::kDebugTasks, "tasks", "Debug the tasks"},
DEBUG_CHANNEL_END
};
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 3c437f792f..67c0b17354 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -1335,7 +1335,9 @@ void GameObject::deleteObjectRecursive(void) {
// Activate this object
void GameObject::activate(void) {
- if (_data.objectFlags & objectActivated) return;
+ warning("GameObject::activate %d", thisID());
+ if (_data.objectFlags & objectActivated)
+ return;
ObjectID dObj = thisID();
scriptCallFrame scf;
@@ -1350,7 +1352,11 @@ void GameObject::activate(void) {
runObjectMethod(dObj, Method_GameObject_onActivate, scf);
- if (isActor(this))((Actor *)this)->activateActor();
+
+
+ if (isActor(this)) {
+ ((Actor *)this)->activateActor();
+ }
}
//-----------------------------------------------------------------------
diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h
index 0449ab401d..1957831d2e 100644
--- a/engines/saga2/saga2.h
+++ b/engines/saga2/saga2.h
@@ -52,7 +52,8 @@ enum {
kDebugPalettes = 1 << 6,
kDebugLoading = 1 << 7,
kDebugTimers = 1 << 8,
- kDebugPath = 1 << 9
+ kDebugPath = 1 << 9,
+ kDebugTasks = 1 << 10
};
#define TICKSPERSECOND (728L/10L)
diff --git a/engines/saga2/task.cpp b/engines/saga2/task.cpp
index ee40d9f0b1..d9312a195a 100644
--- a/engines/saga2/task.cpp
+++ b/engines/saga2/task.cpp
@@ -586,7 +586,7 @@ void *TaskList::archive(void *buf) {
}
void TaskList::newTask(Task *t) {
- warning("List: %p Adding task %p", (void *)this, (void *)t);
+ debugC(1, kDebugTasks, "List: %p Adding task %p", (void *)this, (void *)t);
for (int i = 0; i < numTasks; i++)
if (!_list[i]) {
_list[i] = t;
@@ -605,11 +605,10 @@ void TaskList::newTask(Task *t, TaskID id) {
// into the inactive list
void TaskList::deleteTask(Task *p) {
- warning("List: %p Deleting task %p", (void *)this, (void *)p);
+ debugC(1, kDebugTasks, "List: %p Deleting task %p", (void *)this, (void *)p);
for (int i = 0; i < numTasks; i++)
if (_list[i] == p) {
_list[i] = nullptr;
- warning("Deleted");
}
}
Commit: 13831e17c19995039bf2d44f8c05619086370436
https://github.com/scummvm/scummvm/commit/13831e17c19995039bf2d44f8c05619086370436
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:34+02:00
Commit Message:
SAGA2: Add more debug output
Changed paths:
engines/saga2/actor.cpp
engines/saga2/objects.cpp
engines/saga2/objects.h
engines/saga2/task.cpp
engines/saga2/task.h
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 2b1aedaf42..22b96c3905 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -1585,7 +1585,7 @@ void Actor::vitalityUpdate(void) {
void Actor::activateActor(void) {
if (thisID() > 32768)
- debugC(1, kDebugActors, "Actors: Activated %d ", thisID() - 32768);
+ debugC(1, kDebugActors, "Actors: Activated %d (%s) ", thisID() - 32768, objName());
evaluateNeeds();
}
@@ -1594,7 +1594,7 @@ void Actor::activateActor(void) {
void Actor::deactivateActor(void) {
if (thisID() > 32768)
- debugC(1, kDebugActors, "Actors: De-activated %d ", thisID() - 32768);
+ debugC(1, kDebugActors, "Actors: De-activated %d (%s)", thisID() - 32768, objName());
// Kill task
if (curTask != NULL) {
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 67c0b17354..d2b352baef 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -2320,7 +2320,7 @@ GameWorld::GameWorld(int16 map) {
if ((stream = loadResourceToStream(tileRes, MKTAG('M', 'A', 'P', (char)map), "game map"))) {
int16 mapSize; // Size of map in MetaTiles
- mapSize = stream->readUint16LE();
+ mapSize = stream->readSint16LE();
size.u = (mapSize << kPlatShift) << kTileUVShift;
size.v = size.u;
diff --git a/engines/saga2/objects.h b/engines/saga2/objects.h
index e4ac025905..7f3db7b893 100644
--- a/engines/saga2/objects.h
+++ b/engines/saga2/objects.h
@@ -794,9 +794,12 @@ public:
void cleanup(void);
Sector *getSector(int16 u, int16 v) {
+ if (u == -1 && v == -1)
+ return nullptr;
+
if (v * sectorArraySize + u >= sectorArraySize * sectorArraySize ||
v * sectorArraySize + u < 0) {
- warning("Sector::getSector: Invalid sector: (%d, %d)", u, v);
+ warning("Sector::getSector: Invalid sector: (%d, %d) (sectorArraySize = %d)", u, v, sectorArraySize);
return nullptr;
}
diff --git a/engines/saga2/task.cpp b/engines/saga2/task.cpp
index d9312a195a..10802c2fbe 100644
--- a/engines/saga2/task.cpp
+++ b/engines/saga2/task.cpp
@@ -440,6 +440,7 @@ const int numTasks = 64;
// global instantiation of this class
class TaskList {
+ int _size;
Task *_list[numTasks];
public:
@@ -488,6 +489,7 @@ public:
// the inactive list
TaskList::TaskList(void) {
+ _size = 0;
for (int i = 0; i < numTasks; i++)
_list[i] = nullptr;
}
@@ -586,17 +588,22 @@ void *TaskList::archive(void *buf) {
}
void TaskList::newTask(Task *t) {
- debugC(1, kDebugTasks, "List: %p Adding task %p", (void *)this, (void *)t);
+ debugC(1, kDebugTasks, "List: %p Adding task %p (total %d)", (void *)this, (void *)t, ++_size);
for (int i = 0; i < numTasks; i++)
if (!_list[i]) {
_list[i] = t;
return;
}
- warning("Too many tasks in the list, > %d", numTasks);
+
+ for (int i = 0; i < numTasks; i++)
+ debug("%d: %p (%s)", i, (void *)_list[i], _list[i]->_type.c_str());
+ error("Too many tasks in the list, > %d", numTasks);
}
void TaskList::newTask(Task *t, TaskID id) {
+ if (_list[id])
+ error("Task already exists");
_list[id] = t;
}
@@ -605,7 +612,7 @@ void TaskList::newTask(Task *t, TaskID id) {
// into the inactive list
void TaskList::deleteTask(Task *p) {
- debugC(1, kDebugTasks, "List: %p Deleting task %p", (void *)this, (void *)p);
+ debugC(1, kDebugTasks, "List: %p Deleting task %p (total %d)", (void *)this, (void *)p, --_size);
for (int i = 0; i < numTasks; i++)
if (_list[i] == p) {
_list[i] = nullptr;
@@ -2100,6 +2107,7 @@ GoAwayFromActorTask::GoAwayFromActorTask(
Actor *a,
bool runFlag) :
GoAwayFromTask(ts, runFlag) {
+ debugC(2, kDebugTasks, " - GoAwayFromActorTask1");
SpecificActorTarget(a).clone(targetMem);
}
@@ -2109,6 +2117,7 @@ GoAwayFromActorTask::GoAwayFromActorTask(
bool runFlag) :
GoAwayFromTask(ts, runFlag) {
assert(at.size() <= sizeof(targetMem));
+ debugC(2, kDebugTasks, " - GoAwayFromActorTask2");
// Copy the target to the target buffer
at.clone(targetMem);
}
@@ -2380,6 +2389,7 @@ HuntLocationTask::HuntLocationTask(TaskStack *ts, const Target &t) :
HuntTask(ts),
currentTarget(Nowhere) {
assert(t.size() <= sizeof(targetMem));
+ debugC(2, kDebugTasks, " - HuntLocationTask");
// Copy the target to the target buffer
t.clone(targetMem);
}
@@ -2569,6 +2579,7 @@ HuntObjectTask::HuntObjectTask(TaskStack *ts, const ObjectTarget &ot) :
HuntTask(ts),
currentTarget(NULL) {
assert(ot.size() <= sizeof(targetMem));
+ debugC(2, kDebugTasks, " - HuntObjectTask");
// Copy the target to the target buffer
ot.clone(targetMem);
}
@@ -2947,6 +2958,7 @@ HuntActorTask::HuntActorTask(
flags(trackFlag ? track : 0),
currentTarget(NULL) {
assert(at.size() <= sizeof(targetMem));
+ debugC(2, kDebugTasks, " - HuntActorTask");
// Copy the target to the target buffer
at.clone(targetMem);
}
@@ -3295,6 +3307,7 @@ HuntToKillTask::HuntToKillTask(
targetEvaluateCtr(0),
specialAttackCtr(10),
flags(evalWeapon) {
+ debugC(2, kDebugTasks, " - HuntToKillTask");
Actor *a = stack->getActor();
if (isActor(a->currentTarget))
diff --git a/engines/saga2/task.h b/engines/saga2/task.h
index cd17c40987..d74c46356e 100644
--- a/engines/saga2/task.h
+++ b/engines/saga2/task.h
@@ -137,6 +137,8 @@ protected:
TaskStack *stack;
public:
+ Common::String _type;
+
// Constructor -- initial construction
Task(TaskStack *ts) : stack(ts) {
newTask(this);
@@ -191,6 +193,8 @@ protected:
public:
// Constructor
WanderTask(TaskStack *ts) : Task(ts) {
+ debugC(2, kDebugTasks, " - WanderTask");
+ _type = "WanderTask";
wander();
}
@@ -262,6 +266,8 @@ public:
maxU(uMax),
maxV(vMax),
gotoTether(NULL) {
+ debugC(2, kDebugTasks, " - TetheredWanderTask");
+ _type = "TetheredWanderTask";
}
// Constructor -- reconstruct from archive buffer
@@ -309,6 +315,8 @@ public:
Task(ts),
wander(NULL),
prevRunState(false) {
+ debugC(2, kDebugTasks, " - GotoTask");
+ _type = "GotoTask";
}
// Constructor -- reconstruct from archive buffer
@@ -358,6 +366,8 @@ public:
GotoTask(ts),
targetLoc(tp),
runThreshold(runDist) {
+ debugC(2, kDebugTasks, " - GotoLocationTask");
+ _type = "GotoLocationTask";
}
// Constructor -- reconstruct from archive buffer
@@ -414,6 +424,8 @@ public:
regionMinV(minV),
regionMaxU(maxU),
regionMaxV(maxV) {
+ debugC(2, kDebugTasks, " - GotoRegionTask");
+ _type = "GotoRegionTask";
}
// Constructor -- reconstruct from archive buffer
@@ -471,6 +483,8 @@ public:
sightCtr(0),
flags(trackFlag ? track : 0),
lastKnownLoc(Nowhere) {
+ debugC(2, kDebugTasks, " - GotoObjectTargetTask");
+ _type = "GotoObjectTargetTask";
}
// Constructor -- reconstruct from archive buffer
@@ -516,6 +530,8 @@ public:
bool trackFlag = false) :
GotoObjectTargetTask(ts, trackFlag),
targetObj(obj) {
+ debugC(2, kDebugTasks, " - GotoObjectTask");
+ _type = "GotoObjectTask";
}
// Constructor -- reconstruct from archive buffer
@@ -555,6 +571,8 @@ public:
GotoActorTask(TaskStack *ts, Actor *a, bool trackFlag = false) :
GotoObjectTargetTask(ts, trackFlag),
targetActor(a) {
+ debugC(2, kDebugTasks, " - GotoActorTask");
+ _type = "GotoActorTask";
}
// Constructor -- reconstruct from archive buffer
GotoActorTask(void **buf, TaskID id);
@@ -600,12 +618,16 @@ public:
Task(ts),
goTask(NULL),
flags(0) {
+ debugC(2, kDebugTasks, " - GoAwayFromTask1");
+ _type = "GoAwayFromTask";
}
GoAwayFromTask(TaskStack *ts, bool runFlag) :
Task(ts),
goTask(NULL),
flags(runFlag ? run : 0) {
+ debugC(2, kDebugTasks, " - GoAwayFromTask2");
+ _type = "GoAwayFromTask";
}
// Constructor -- reconstruct from archive buffer
@@ -647,6 +669,8 @@ public:
GoAwayFromObjectTask(TaskStack *ts, GameObject *object) :
GoAwayFromTask(ts),
obj(object) {
+ debugC(2, kDebugTasks, " - GoAwayFromObjectTask");
+ _type = "GoAwayFromObjectTask";
}
// Constructor -- reconstruct from archive buffer
@@ -730,6 +754,8 @@ public:
HuntTask(TaskStack *ts) :
Task(ts),
huntFlags(0) {
+ debugC(2, kDebugTasks, " - HuntTask");
+ _type = "HuntTask";
}
// Constructor -- reconstruct from archive buffer
@@ -827,6 +853,8 @@ public:
HuntLocationTask(ts, t),
range(r),
targetEvaluateCtr(0) {
+ debugC(2, kDebugTasks, " - HuntToBeNearLocationTask");
+ _type = "HuntToBeNearLocationTask";
}
// Constructor -- reconstruct from archive buffer
@@ -918,6 +946,8 @@ public:
HuntObjectTask(ts, ot),
range(r),
targetEvaluateCtr(0) {
+ debugC(2, kDebugTasks, " - HuntToBeNearObjectTask");
+ _type = "HuntToBeNearObjectTask";
}
// Constructor -- reconstruct from archive buffer
@@ -972,6 +1002,8 @@ public:
HuntObjectTask(ts, ot),
targetEvaluateCtr(0),
grabFlag(false) {
+ debugC(2, kDebugTasks, " - HuntToPossessTask");
+ _type = "HuntToPossessTask";
}
// Constructor -- reconstruct from archive buffer
@@ -1078,6 +1110,8 @@ public:
goAway(NULL),
range(MAX<uint16>(r, 16)),
targetEvaluateCtr(0) {
+ debugC(2, kDebugTasks, " - HuntToBeNearActorTask");
+ _type = "HuntToBeNearActorTask";
}
// Constructor -- reconstruct from archive buffer
@@ -1205,6 +1239,8 @@ public:
bool trackFlag = false) :
HuntActorTask(ts, at, trackFlag),
objToGive(obj) {
+ debugC(2, kDebugTasks, " - HuntToGiveTask");
+ _type = "HuntToGiveTask";
}
// Constructor -- reconstruct from archive buffer
@@ -1326,6 +1362,8 @@ public:
attend(NULL),
currentTarget(Nowhere),
targetEvaluateCtr(0) {
+ debugC(2, kDebugTasks, " - BandTask");
+ _type = "BandTask";
}
// Constructor -- reconstruct from archive buffer
@@ -1452,6 +1490,8 @@ public:
gotoWayPoint(NULL),
patrolIter(iter),
lastWayPointNum(stopAt) {
+ debugC(2, kDebugTasks, " - FollowPatrolRouteTask");
+ _type = "FollowPatrolRouteTask";
followPatrolRoute();
}
@@ -1508,7 +1548,10 @@ class AttendTask : public Task {
public:
// Constructor -- initial construction
- AttendTask(TaskStack *ts, GameObject *o) : Task(ts), obj(o) {}
+ AttendTask(TaskStack *ts, GameObject *o) : Task(ts), obj(o) {
+ debugC(2, kDebugTasks, " - AttendTask");
+ _type = "AttendTask";
+ }
// Constructor -- reconstruct from archive buffer
AttendTask(void **buf, TaskID id);
Commit: 708a5b374b5e0c1493a628681f13a2b887152fa1
https://github.com/scummvm/scummvm/commit/708a5b374b5e0c1493a628681f13a2b887152fa1
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:34+02:00
Commit Message:
SAGA2: Add more debug output
Changed paths:
engines/saga2/assign.cpp
engines/saga2/objects.cpp
diff --git a/engines/saga2/assign.cpp b/engines/saga2/assign.cpp
index 575110d752..aa8579cb20 100644
--- a/engines/saga2/assign.cpp
+++ b/engines/saga2/assign.cpp
@@ -35,8 +35,6 @@ namespace Saga2 {
const uint16 indefinitely = CalenderTime::framesPerDay;
-extern Common::Array<char *> nameList;
-
/* ===================================================================== *
ActorAssignment member functions
* ===================================================================== */
@@ -47,7 +45,7 @@ ActorAssignment::ActorAssignment(Actor *a, uint16 until) :
endFrame(until) {
_actor = a;
debugC(2, kDebugActors, "New assignment for %p (%s) from %d until %d: %p",
- (void *)a, nameList[a->proto()->nameIndex], startFrame, endFrame, (void *)this);
+ (void *)a, a->objName(), startFrame, endFrame, (void *)this);
a->_assignment = this;
a->flags |= hasAssignment;
}
@@ -74,7 +72,7 @@ ActorAssignment::ActorAssignment(Actor *ac, void **buf) {
ActorAssignment::~ActorAssignment(void) {
Actor *a = getActor();
debugC(2, kDebugActors, "Ending assignment for %p (%s): %p",
- (void *)a, nameList[a->proto()->nameIndex], (void *)this);
+ (void *)a, a->objName(), (void *)this);
// Determine if the actor has a task initiated by this assignment
if (a->currentGoal == actorGoalFollowAssignment
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index d2b352baef..7cdb27f54d 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -1335,7 +1335,7 @@ void GameObject::deleteObjectRecursive(void) {
// Activate this object
void GameObject::activate(void) {
- warning("GameObject::activate %d", thisID());
+ warning("GameObject::activate %d (%s)", thisID(), objName());
if (_data.objectFlags & objectActivated)
return;
@@ -1364,6 +1364,7 @@ void GameObject::activate(void) {
void GameObject::deactivate(void) {
if (!(_data.objectFlags & objectActivated)) return;
+ warning("GameObject::deactivate %d (%s)", thisID(), objName());
ObjectID dObj = thisID();
scriptCallFrame scf;
Commit: 29ab7ab00178cbb8e6dbc84eb331ad16dd219ca8
https://github.com/scummvm/scummvm/commit/29ab7ab00178cbb8e6dbc84eb331ad16dd219ca8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:34+02:00
Commit Message:
SAGA2: Added more debug output
Changed paths:
engines/saga2/actor.cpp
engines/saga2/main.cpp
engines/saga2/objects.cpp
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 22b96c3905..9e77a6b737 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -1584,8 +1584,8 @@ void Actor::vitalityUpdate(void) {
// Perform actor specific activation tasks
void Actor::activateActor(void) {
- if (thisID() > 32768)
- debugC(1, kDebugActors, "Actors: Activated %d (%s) ", thisID() - 32768, objName());
+ debugC(1, kDebugActors, "Actors: Activated %d (%s)", thisID() - 32768, objName());
+
evaluateNeeds();
}
@@ -1593,8 +1593,7 @@ void Actor::activateActor(void) {
// Perfrom actor specific deactivation tasks
void Actor::deactivateActor(void) {
- if (thisID() > 32768)
- debugC(1, kDebugActors, "Actors: De-activated %d (%s)", thisID() - 32768, objName());
+ debugC(1, kDebugActors, "Actors: De-activated %d (%s)", thisID() - 32768, objName());
// Kill task
if (curTask != NULL) {
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 55b40e17bd..195d86dd6c 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -354,8 +354,8 @@ void displayUpdate(void) {
GameMode::modeStackPtr[GameMode::modeStackCtr - 1]->handleTask();
lrate.updateFrameCount();
loops++;
- elapsed += (g_system->getMillis() - lastGameTime);
- lastGameTime = g_system->getMillis();
+ elapsed += (gameTime - lastGameTime);
+ lastGameTime = gameTime;
debugC(1, kDebugEventLoop, "EventLoop: Interface indicator updates");
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 7cdb27f54d..fedf8aa4b4 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -1335,10 +1335,11 @@ void GameObject::deleteObjectRecursive(void) {
// Activate this object
void GameObject::activate(void) {
- warning("GameObject::activate %d (%s)", thisID(), objName());
if (_data.objectFlags & objectActivated)
return;
+ debugC(1, kDebugActors, "GameObject::activate %d (%s)", thisID(), objName());
+
ObjectID dObj = thisID();
scriptCallFrame scf;
@@ -1363,8 +1364,10 @@ void GameObject::activate(void) {
// Deactivate this object
void GameObject::deactivate(void) {
- if (!(_data.objectFlags & objectActivated)) return;
- warning("GameObject::deactivate %d (%s)", thisID(), objName());
+ if (!(_data.objectFlags & objectActivated))
+ return;
+
+ debugC(1, kDebugActors, "GameObject::deactivate %d (%s)", thisID(), objName());
ObjectID dObj = thisID();
scriptCallFrame scf;
@@ -1384,7 +1387,8 @@ void GameObject::deactivate(void) {
removeAllTimers();
removeAllSensors();
- if (isActor(this))((Actor *)this)->deactivateActor();
+ if (isActor(this))
+ ((Actor *)this)->deactivateActor();
}
// Determine if an object is contained in this object
Commit: 8a9827985d3e2ada879a5fab71adaed2206878cf
https://github.com/scummvm/scummvm/commit/8a9827985d3e2ada879a5fab71adaed2206878cf
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:34+02:00
Commit Message:
SAGA2: Print out object names
Changed paths:
engines/saga2/actor.cpp
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 9e77a6b737..8dd9fd486e 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -1417,7 +1417,7 @@ Actor *Actor::newActor(
if (a->flags & temporary) {
incTempActorCount(protoNum);
- debugC(1, kDebugActors, "Actors: Created temp actor %d new count:%d", a->thisID() - 32768, getTempActorCount(protoNum));
+ debugC(1, kDebugActors, "Actors: Created temp actor %d (%s) new count:%d", a->thisID() - 32768, a->objName(), getTempActorCount(protoNum));
}
return a;
@@ -1431,7 +1431,7 @@ void Actor::deleteActor(void) {
uint16 protoNum = (ActorProto *)prototype - actorProtos;
decTempActorCount(protoNum);
- debugC(1, kDebugActors, "Actors: Deleting temp actor %d new count:%d", thisID() - 32768, getTempActorCount(protoNum));
+ debugC(1, kDebugActors, "Actors: Deleting temp actor %d (%s) new count:%d", thisID() - 32768, objName(), getTempActorCount(protoNum));
}
// Kill task
Commit: 74a5424dce0a95f809559f46ca759e666b71bcc6
https://github.com/scummvm/scummvm/commit/74a5424dce0a95f809559f46ca759e666b71bcc6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:34+02:00
Commit Message:
SAGA2: Get rid of DList is tile.cpp
Changed paths:
engines/saga2/tile.cpp
engines/saga2/tile.h
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index cd6e671ca1..35fd73a59e 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -975,24 +975,20 @@ void cleanupActiveItemStates(void) {
//-----------------------------------------------------------------------
// The list of active tile activity tasks
-static uint8 aTaskListBuffer[sizeof(TileActivityTaskList)];
-
-static TileActivityTaskList &aTaskList =
- *((TileActivityTaskList *)aTaskListBuffer);
+static TileActivityTaskList aTaskList;
//-----------------------------------------------------------------------
// Constructor
TileActivityTaskList::TileActivityTaskList(void) {
- for (uint i = 0; i < ARRAYSIZE(array); i++) {
- free.addTail(array[i]);
- }
}
//-----------------------------------------------------------------------
// Reconstruct the TileActivityTaskList from an archive buffer
TileActivityTaskList::TileActivityTaskList(void **buf) {
+ warning("STUB: TileActivityTaskList::TileActivityTaskList(void **buf)");
+#if 0
void *bufferPtr = *buf;
int16 taskCount;
@@ -1025,6 +1021,7 @@ TileActivityTaskList::TileActivityTaskList(void **buf) {
}
*buf = bufferPtr;
+#endif
}
//-----------------------------------------------------------------------
@@ -1032,12 +1029,9 @@ TileActivityTaskList::TileActivityTaskList(void **buf) {
// TileActivityTaskList
int32 TileActivityTaskList::archiveSize(void) {
- int32 size = sizeof(int16);
- TileActivityTask *tat;
+ int32 size = sizeof(int16);
- for (tat = (TileActivityTask *)list.first();
- tat != nullptr;
- tat = (TileActivityTask *)tat->next())
+ for (Common::List<TileActivityTask *>::iterator it = _list.begin(); it != _list.end(); ++it)
size += sizeof(ActiveItemID) + sizeof(uint8);
return size;
@@ -1048,27 +1042,19 @@ int32 TileActivityTaskList::archiveSize(void) {
// archive buffer
Common::MemorySeekableReadWriteStream *TileActivityTaskList::archive(Common::MemorySeekableReadWriteStream *stream) {
- int16 taskCount;
- TileActivityTask *tat;
-
- for (tat = (TileActivityTask *)list.first(), taskCount = 0;
- tat != nullptr;
- tat = (TileActivityTask *)tat->next())
- taskCount++;
+ int16 taskCount = _list.size();
// Store the task count
stream->writeSint16LE(taskCount);
- for (tat = (TileActivityTask *)list.first();
- tat != nullptr;
- tat = (TileActivityTask *)tat->next()) {
- ActiveItem *ai = tat->tai;
+ for (Common::List<TileActivityTask *>::iterator it = _list.begin(); it != _list.end(); ++it) {
+ ActiveItem *ai = (*it)->tai;
// Store the activeItemID
stream->writeSint16LE(ai->thisID());
// Store the task type
- stream->writeByte(tat->activityType);
+ stream->writeByte((*it)->activityType);
}
return stream;
@@ -1078,15 +1064,10 @@ Common::MemorySeekableReadWriteStream *TileActivityTaskList::archive(Common::Mem
// Cleanup
void TileActivityTaskList::cleanup(void) {
- TileActivityTask *tat;
- TileActivityTask *nextTat;
-
- for (tat = (TileActivityTask *)list.first();
- tat != nullptr;
- tat = nextTat) {
- nextTat = (TileActivityTask *)tat->next();
- tat->remove();
- }
+ for (Common::List<TileActivityTask *>::iterator it = _list.begin(); it != _list.end(); ++it)
+ delete *it;
+
+ _list.clear();
}
//-----------------------------------------------------------------------
@@ -1094,41 +1075,36 @@ void TileActivityTaskList::cleanup(void) {
// and initialize it.
TileActivityTask *TileActivityTaskList::newTask(ActiveItem *activeInstance) {
- TileActivityTask *tat;
+ TileActivityTask *tat = nullptr;
// Check see if there's already tile activity task associated with
// this instance.
- for (tat = (TileActivityTask *)list.first();
- tat;
- tat = (TileActivityTask *)tat->next()) {
- if (tat->tai == activeInstance) break;
- }
+ for (Common::List<TileActivityTask *>::iterator it = _list.begin(); it != _list.end(); ++it)
+ if ((*it)->tai == activeInstance) {
+ tat = *it;
+ break;
+ }
-#if TATLOG
- if (tat) writeLog("Found old TAT\n");
-#endif
+ if (tat)
+ debugC(3, kDebugTasks, "Found old TAT");
if (tat == nullptr) {
- tat = (TileActivityTask *)free.remHead();
+ debugC(3, kDebugTasks, "Making new TAT");
-#if TATLOG
- writeLog("Making new TAT\n");
-#endif
- if (tat) {
- tat->tai = activeInstance;
- tat->activityType = TileActivityTask::activityTypeNone;
- tat->script = NoThread;
- tat->targetState = 0;
+ tat = new TileActivityTask;
- list.addTail(*tat);
- }
+ tat->tai = activeInstance;
+ tat->activityType = TileActivityTask::activityTypeNone;
+ tat->script = NoThread;
+ tat->targetState = 0;
+
+ _list.push_back(tat);
}
// If we re-used an old task struct, then make sure script gets woken up.
if (tat->script != NoThread) {
-#if TATLOG
- writeLog("Waking up thread TAT\n");
-#endif
+ debugC(3, kDebugTasks, "Waking up thread TAT");
+
wakeUpThread(tat->script);
tat->script = NoThread;
}
@@ -1144,22 +1120,18 @@ TileActivityTask *TileActivityTaskList::newTask(ActiveItem *activeInstance) {
// When a tile activity task is finished, call this function to delete it.
void TileActivityTask::remove(void) {
-#if TATLOG
- writeLog("Removing TAT\n");
-#endif
- DNode::remove();
- aTaskList.free.addTail(*this);
+ debugC(3, kDebugTasks, "Removing TAT");
+
+ aTaskList._list.remove(this);
}
//-----------------------------------------------------------------------
// This initiates a tile activity task for opening a door
void TileActivityTask::openDoor(ActiveItem &activeInstance) {
- TileActivityTask *tat;
+ debugC(3, kDebugTasks, "TAT Open Door");
-#if TATLOG
- writeLog("TAT Open Door\n");
-#endif
+ TileActivityTask *tat;
if ((tat = aTaskList.newTask(&activeInstance)) != nullptr)
tat->activityType = activityTypeOpen;
}
@@ -1168,11 +1140,9 @@ void TileActivityTask::openDoor(ActiveItem &activeInstance) {
// This initiates a tile activity task for closing a door
void TileActivityTask::closeDoor(ActiveItem &activeInstance) {
- TileActivityTask *tat;
+ debugC(3, kDebugTasks, "TAT Close Door");
-#if TATLOG
- writeLog("TAT Close Door\n");
-#endif
+ TileActivityTask *tat;
if ((tat = aTaskList.newTask(&activeInstance)) != nullptr)
tat->activityType = activityTypeClose;
}
@@ -1181,22 +1151,19 @@ void TileActivityTask::closeDoor(ActiveItem &activeInstance) {
// This initiates a tile activity task for script-based activity
void TileActivityTask::doScript(ActiveItem &activeInstance, uint8 finalState, ThreadID scr) {
- TileActivityTask *tat;
+ debugC(3, kDebugTasks, "TAT Do Script");
-#if TATLOG
- writeLog("TAT Do Script\n");
-#endif
+ TileActivityTask *tat;
if ((tat = aTaskList.newTask(&activeInstance)) != nullptr) {
-#if TATLOG
- if (scr) writeLog("TAT Assign Script!\n");
-#endif
+ if (scr)
+ debugC(3, kDebugTasks, "TAT Assign Script!");
+
tat->activityType = activityTypeScript;
tat->targetState = finalState;
tat->script = scr;
} else {
-#if TATLOG
- writeLog("Waking up thread 'cause newTask Failed\n");
-#endif
+ debugC(3, kDebugTasks, "Waking up thread 'cause newTask Failed");
+
wakeUpThread(scr); // If there were no threads available
}
}
@@ -1205,26 +1172,21 @@ void TileActivityTask::doScript(ActiveItem &activeInstance, uint8 finalState, Th
// Routine to update positions of all active terrain using TileActivityTasks
void TileActivityTask::updateActiveItems(void) {
- TileActivityTask *tat,
- *nextTat;
-#if DEBUG
- int count = 0,
- scriptCount = 0;
-#endif
+ int count = 0, scriptCount = 0;
- for (tat = (TileActivityTask *)aTaskList.list.first(); tat; tat = nextTat) {
- ActiveItem *activityInstance = tat->tai;
- bool activityTaskDone = false;
+ for (Common::List<TileActivityTask *>::iterator it = aTaskList._list.begin(); it != aTaskList._list.end();) {
+ TileActivityTask *tat = *it;
+ ActiveItem *activityInstance = tat->tai;
+ bool activityTaskDone = false;
int16 mapNum = activityInstance->getMapNum();
uint16 state = activityInstance->getInstanceState(mapNum);
- nextTat = (TileActivityTask *)tat->next();
-
-#if TATLOG
+ // collecting stats
count++;
- if (tat->script != NoThread) scriptCount++;
-#endif
+ if (tat->script != NoThread)
+ scriptCount++;
+
switch (tat->activityType) {
case activityTypeOpen:
@@ -1255,29 +1217,29 @@ void TileActivityTask::updateActiveItems(void) {
break;
}
+ ++it; // Go to next task before potentially removing it
+
if (activityTaskDone) {
// Wake up the script...
-#if TATLOG
- if (tat->script != NoThread) writeLog("TAT Wake Up Thread\n");
-#endif
- if (tat->script != NoThread) wakeUpThread(tat->script);
+ if (tat->script != NoThread) {
+ debugC(3, kDebugTasks, "TAT Wake Up Thread");
+
+ wakeUpThread(tat->script);
+ }
tat->remove();
}
}
-#if DEBUG
- WriteStatusF(16, "TileTasks: %d SW:%d", count, scriptCount);
-#endif
+ debugC(3, kDebugTasks, "TileTasks: %d SW:%d", count, scriptCount);
}
//-----------------------------------------------------------------------
// Search for tile activity task matching an item
TileActivityTask *TileActivityTask::find(ActiveItem *tai) {
- TileActivityTask *tat;
-
- for (tat = (TileActivityTask *)aTaskList.list.first(); tat; tat = (TileActivityTask *)tat->next()) {
- if (tai == tat->tai) return tat;
+ for (Common::List<TileActivityTask *>::iterator it = aTaskList._list.begin(); it != aTaskList._list.end(); ++it) {
+ if (tai == (*it)->tai)
+ return *it;
}
return nullptr;
@@ -1287,24 +1249,23 @@ TileActivityTask *TileActivityTask::find(ActiveItem *tai) {
// Add script to tile activity task...
bool TileActivityTask::setWait(ActiveItem *tai, ThreadID script) {
- TileActivityTask *tat;
+ TileActivityTask *tat = find(tai);
- tat = find(tai);
+ debugC(3, kDebugTasks, "Set Wait TAT\n");
-#if TATLOG
- writeLog("Set Wait TAT\n");
-#endif
if (tat) {
-#if TATLOG
- if (tat->script != NoThread) writeLog("TAT Waking Up Thread\n");
-#endif
- if (tat->script != NoThread) wakeUpThread(tat->script);
+ if (tat->script != NoThread) {
+ debugC(3, kDebugTasks, "TAT Waking Up Thread\n");
+
+ wakeUpThread(tat->script);
+ }
tat->script = script;
+
return true;
}
-#if TATLOG
- writeLog("SetWait failed\n");
-#endif
+
+ debugC(3, kDebugTasks, "SetWait failed\n");
+
return false;
}
@@ -1319,8 +1280,6 @@ void moveActiveTerrain(int32 deltaTime) {
// Initialize the tile activity task list
void initTileTasks(void) {
- // Simply call the default constructor
- new (&aTaskList) TileActivityTaskList;
}
//-----------------------------------------------------------------------
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index 1df569bd21..9d4aafd081 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -32,7 +32,6 @@
#include "saga2/tileload.h"
#include "saga2/annoy.h"
#include "saga2/terrain.h"
-#include "saga2/dlist.h"
#include "saga2/property.h"
#include "saga2/tcoords.h"
@@ -566,7 +565,7 @@ public:
// Since most things in the game aren't moving at a given point, the
// variables for simulating motion don't need to always be present.
-class TileActivityTask : private DNode {
+class TileActivityTask {
friend class TileActivityTaskList;
friend class ActiveItem;
@@ -608,11 +607,9 @@ public:
class TileActivityTaskList {
friend class TileActivityTask;
- DList list,
- free;
- TileActivityTask array[32];
-
public:
+ Common::List<TileActivityTask *> _list;
+
// Constructor -- initial construction
TileActivityTaskList(void);
Commit: 81505c6feb428ea4db902ea5eef8a6729c50dc66
https://github.com/scummvm/scummvm/commit/81505c6feb428ea4db902ea5eef8a6729c50dc66
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:34+02:00
Commit Message:
SAGA2: Fix object activation mistake in updateImage
Changed paths:
engines/saga2/objects.cpp
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index fedf8aa4b4..5eccd60b1e 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -974,7 +974,7 @@ void GameObject::updateImage(ObjectID oldParentID) {
sect = w->getSector(u, v);
if (sect) {
if (sect->isActivated())
- sect->activate();
+ activate();
}
else
warning("GameObject::updateImage: Invalid Sector (%d, %d))", u, v);
Commit: 4c0d6d0e63e41a0e53bea53b0a14d7b1a93e78cf
https://github.com/scummvm/scummvm/commit/4c0d6d0e63e41a0e53bea53b0a14d7b1a93e78cf
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:35+02:00
Commit Message:
SAGA2: Print Task type on deletion
Changed paths:
engines/saga2/task.cpp
diff --git a/engines/saga2/task.cpp b/engines/saga2/task.cpp
index 10802c2fbe..1ef58bf52a 100644
--- a/engines/saga2/task.cpp
+++ b/engines/saga2/task.cpp
@@ -612,7 +612,7 @@ void TaskList::newTask(Task *t, TaskID id) {
// into the inactive list
void TaskList::deleteTask(Task *p) {
- debugC(1, kDebugTasks, "List: %p Deleting task %p (total %d)", (void *)this, (void *)p, --_size);
+ debugC(1, kDebugTasks, "List: %p Deleting task %p (%s) (total %d)", (void *)this, (void *)p, p->_type.c_str(), --_size);
for (int i = 0; i < numTasks; i++)
if (_list[i] == p) {
_list[i] = nullptr;
Commit: 6f9d0728d3685d74503867e5e19ac9809d797550
https://github.com/scummvm/scummvm/commit/6f9d0728d3685d74503867e5e19ac9809d797550
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:35+02:00
Commit Message:
SAGA2: Fix unremoved GotoTask
Changed paths:
engines/saga2/task.cpp
diff --git a/engines/saga2/task.cpp b/engines/saga2/task.cpp
index 1ef58bf52a..6947b132e3 100644
--- a/engines/saga2/task.cpp
+++ b/engines/saga2/task.cpp
@@ -2375,6 +2375,7 @@ void HuntTask::removeWanderTask(void) {
void HuntTask::removeGotoTask(void) {
subTask->abortTask();
+ delete subTask;
huntFlags &= ~huntGoto;
}
Commit: 279f41d02c4f82b19e9f611344b9973e11cc0706
https://github.com/scummvm/scummvm/commit/279f41d02c4f82b19e9f611344b9973e11cc0706
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:35+02:00
Commit Message:
SAGA2: Added debug print method
Changed paths:
engines/saga2/tcoords.h
diff --git a/engines/saga2/tcoords.h b/engines/saga2/tcoords.h
index 4264e1a60d..7a251ff55a 100644
--- a/engines/saga2/tcoords.h
+++ b/engines/saga2/tcoords.h
@@ -104,6 +104,10 @@ struct TilePoint {
int16 quickDir(void);
int16 magnitude(void);
+
+ void debugPrint(int level = 0, const char *msg = "TilePoint:") {
+ debug(level, "%s %d, %d, %d", msg, u, v, z);
+ }
} PACKED_STRUCT;
#include "common/pack-end.h"
Commit: 88f01580773d1e667211583771987b173f326bf7
https://github.com/scummvm/scummvm/commit/88f01580773d1e667211583771987b173f326bf7
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:35+02:00
Commit Message:
SAGA2: Fix delete on TaskStack::abortTask
Changed paths:
engines/saga2/task.cpp
diff --git a/engines/saga2/task.cpp b/engines/saga2/task.cpp
index 6947b132e3..3129df2937 100644
--- a/engines/saga2/task.cpp
+++ b/engines/saga2/task.cpp
@@ -4626,6 +4626,7 @@ void TaskStack::abortTask(void) {
Task *stackBottom = getTaskAddress(stackBottomID);
stackBottom->abortTask();
+ delete stackBottom;
}
}
Commit: 99c8e3f59aea8c09e577bc3c96689b37a1e2b8ee
https://github.com/scummvm/scummvm/commit/99c8e3f59aea8c09e577bc3c96689b37a1e2b8ee
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:35+02:00
Commit Message:
SAGA2: Fix double free in removeAllTimers
Changed paths:
engines/saga2/objects.cpp
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 5eccd60b1e..34677bc180 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -1845,8 +1845,7 @@ void GameObject::removeAllTimers(void) {
// Get this object's timer list
if ((timerList = fetchTimerList(this)) != nullptr) {
for (Common::List<Timer *>::iterator it = timerList->_timers.begin(); it != timerList->_timers.end(); ++it) {
- timerList->_timers.remove(*it);
- delete *it;
+ timerList->_timers.erase(it);
}
delete timerList;
Commit: 540d58a135efbefdefc25f110f0f1d4f197f3ac3
https://github.com/scummvm/scummvm/commit/540d58a135efbefdefc25f110f0f1d4f197f3ac3
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:35+02:00
Commit Message:
SAGA2: Add more debug output
Changed paths:
engines/saga2/timers.cpp
engines/saga2/timers.h
diff --git a/engines/saga2/timers.cpp b/engines/saga2/timers.cpp
index 1e4d51e171..e33da65bf5 100644
--- a/engines/saga2/timers.cpp
+++ b/engines/saga2/timers.cpp
@@ -269,8 +269,8 @@ void cleanupTimers(void) {
* ===================================================================== */
TimerList::TimerList(GameObject *o) : _obj(o) {
- debugC(1, kDebugTimers, "Creating timer list %p (obj %p)",
- (void *)this, (void *)o);
+ debugC(1, kDebugTimers, "Creating timer list %p for %p (%s)",
+ (void *)this, (void *)o, o->objName());
g_vm->_timerLists.push_back(this);
}
@@ -290,8 +290,8 @@ TimerList::TimerList(void **buf) {
}
TimerList::~TimerList() {
- debugC(1, kDebugTimers, "Deleting timer list %p (obj %p)",
- (void *)this, (void *)_obj);
+ debugC(1, kDebugTimers, "Deleting timer list %p for %p (%s))",
+ (void *)this, (void *)_obj, _obj->objName());
g_vm->_timerLists.remove(this);
}
diff --git a/engines/saga2/timers.h b/engines/saga2/timers.h
index 15da6c8fe5..4bc8803199 100644
--- a/engines/saga2/timers.h
+++ b/engines/saga2/timers.h
@@ -30,10 +30,10 @@
#include "saga2/idtypes.h"
#include "saga2/dlist.h"
#include "saga2/calender.h"
+#include "saga2/objects.h"
namespace Saga2 {
-class GameObject;
class TimerList;
// Fetch a specified actor's TimerList
@@ -97,8 +97,8 @@ public:
// Constructor -- initial construction
Timer(GameObject *o, TimerID timerID, int16 frameInterval) : _obj(o), _id(timerID), _interval(frameInterval) {
_alarm.set(_interval);
- debugC(1, kDebugTimers, "Creating timer %p (obj %p)",
- (void *)this, (void *)o);
+ debugC(1, kDebugTimers, "Creating timer %p for %p (%s)",
+ (void *)this, (void *)o, o->objName());
g_vm->_timers.push_back(this);
}
Commit: 080ad92b236700d2d82b857e141ab2b587d081f2
https://github.com/scummvm/scummvm/commit/080ad92b236700d2d82b857e141ab2b587d081f2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:35+02:00
Commit Message:
SAGA2: Hid a noisy log message deeper
Changed paths:
engines/saga2/interp.cpp
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index ebdc26e7fb..1920be6693 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -1608,7 +1608,7 @@ void Thread::dispatch(void) {
numThreads++;
}
- debugC(2, kDebugScripts, "Threads:%d X:%d D:%d F:%d T:%d O:%d", numThreads, numExecute, numWaitDelay, numWaitFrames, numWaitSemi, numWaitOther);
+ debugC(9, kDebugScripts, "Threads:%d X:%d D:%d F:%d T:%d O:%d", numThreads, numExecute, numWaitDelay, numWaitFrames, numWaitSemi, numWaitOther);
for (th = threadList.first(); th; th = nextThread) {
nextThread = threadList.next(th);
Commit: b0cf10eb67c25eb3528a611081de3aab264d9048
https://github.com/scummvm/scummvm/commit/b0cf10eb67c25eb3528a611081de3aab264d9048
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:35+02:00
Commit Message:
SAGA2: Add speech debug output
Changed paths:
engines/saga2/speech.cpp
diff --git a/engines/saga2/speech.cpp b/engines/saga2/speech.cpp
index 85050c0353..d21074350b 100644
--- a/engines/saga2/speech.cpp
+++ b/engines/saga2/speech.cpp
@@ -559,6 +559,10 @@ void Speech::dispose(void) {
}
} else wakeUpThread(thread, 0);
+ GameObject *obj = GameObject::objectAddress(objID);
+
+ debugC(1, kDebugTasks, "Speech: Disposing %p for %p (%s)", (void *)this, (void *)obj, obj->objName());
+
remove();
}
@@ -1171,6 +1175,8 @@ Speech *SpeechTaskList::newTask(ObjectID id, uint16 flags) {
#endif
if (sp == NULL) return NULL;
+ debugC(1, kDebugTasks, "Speech: New Task: %p for %p (%s) (flags = %d)", (void *)sp, (void *)obj, obj->objName(), flags);
+
sp->sampleCount = sp->charCount = 0;
sp->objID = id;
sp->speechFlags = flags & (Speech::spNoAnimate | Speech::spLock);
Commit: abad186530e1b8a04c97ea6efcd11652c9bf376c
https://github.com/scummvm/scummvm/commit/abad186530e1b8a04c97ea6efcd11652c9bf376c
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:35+02:00
Commit Message:
SAGA2: Fix timer delete on removeAllTimers
Changed paths:
engines/saga2/objects.cpp
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 34677bc180..4e14227873 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -1844,9 +1844,10 @@ void GameObject::removeAllTimers(void) {
// Get this object's timer list
if ((timerList = fetchTimerList(this)) != nullptr) {
- for (Common::List<Timer *>::iterator it = timerList->_timers.begin(); it != timerList->_timers.end(); ++it) {
- timerList->_timers.erase(it);
- }
+ for (Common::List<Timer *>::iterator it = timerList->_timers.begin(); it != timerList->_timers.end(); ++it)
+ delete *it;
+
+ timerList->_timers.clear();
delete timerList;
}
Commit: 5761c830043a77611f055b697cae06553202cf0c
https://github.com/scummvm/scummvm/commit/5761c830043a77611f055b697cae06553202cf0c
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:36+02:00
Commit Message:
SAGA2: Remove DList from speech.cpp
Changed paths:
engines/saga2/speech.cpp
engines/saga2/speech.h
diff --git a/engines/saga2/speech.cpp b/engines/saga2/speech.cpp
index d21074350b..c4206c4105 100644
--- a/engines/saga2/speech.cpp
+++ b/engines/saga2/speech.cpp
@@ -194,8 +194,8 @@ void *Speech::restore(void *buf) {
// Requeue the speech if needed
if (speechFlags & spQueued) {
// Add to the active list
- DNode::remove();
- speechList.activeList.addTail(*this);
+ speechList.remove(this);
+ speechList._list.push_back(this);
}
return buf;
@@ -291,10 +291,10 @@ bool Speech::append(char *text, int32 sampID) {
bool Speech::activate(void) {
// Remove from existing list
- DNode::remove();
+ speechList.remove(this);
// Add to the active list
- speechList.activeList.addTail(*this);
+ speechList._list.push_back(this);
speechFlags |= spQueued;
@@ -561,7 +561,7 @@ void Speech::dispose(void) {
GameObject *obj = GameObject::objectAddress(objID);
- debugC(1, kDebugTasks, "Speech: Disposing %p for %p (%s)", (void *)this, (void *)obj, obj->objName());
+ debugC(1, kDebugTasks, "Speech: Disposing %p for %p (%s) (total = %d)'", (void *)this, (void *)obj, obj->objName(), speechList.speechCount());
remove();
}
@@ -646,7 +646,7 @@ void queueActorSpeech(
Speech *sp;
// Check see if there's already speech associated with this object.
- for (sp = (Speech *)speechList.nonActiveList.first();
+ for (sp = (Speech *)speechList._inactiveList.first();
sp;
sp = (Speech *)sp->next()) {
if (sp->obj == obj) {
@@ -1013,15 +1013,29 @@ bool isVisible(GameObject *obj) {
SpeechTaskList member functions
* ===================================================================== */
+void SpeechTaskList::remove(Speech *p) {
+ for (Common::List<Speech *>::iterator it = _list.begin();
+ it != _list.end(); ++it) {
+ if (p == *it) {
+ _list.remove(p);
+ break;
+ }
+ }
+
+ for (Common::List<Speech *>::iterator it = _inactiveList.begin();
+ it != _inactiveList.end(); ++it) {
+ if (p == *it) {
+ _inactiveList.remove(p);
+ break;
+ }
+ }
+}
+
//-----------------------------------------------------------------------
// Initialize the SpeechTaskList
SpeechTaskList::SpeechTaskList(void) {
lockFlag = false;
-
- for (int i = 0; i < (long)ARRAYSIZE(array); i++) {
- free.addTail(array[i]);
- }
}
//-----------------------------------------------------------------------
@@ -1035,21 +1049,16 @@ SpeechTaskList::SpeechTaskList(void **buf) {
lockFlag = false;
- // Initialize the free list
- for (i = 0; i < (long)ARRAYSIZE(array); i++) {
- free.addTail(array[i]);
- }
-
// Get the speech count
count = *((int16 *)bufferPtr);
bufferPtr = (int16 *)bufferPtr + 1;
// Restore the speeches
for (i = 0; i < count; i++) {
- Speech *sp = (Speech *)free.remHead();
+ Speech *sp = new Speech;
assert(sp != NULL);
- nonActiveList.addTail(*sp);
+ _inactiveList.push_back(sp);
bufferPtr = sp->restore(bufferPtr);
}
@@ -1065,17 +1074,15 @@ int32 SpeechTaskList::archiveSize(void) {
size += sizeof(int16); // Speech count
- // Tally active speeches
- for (sp = (Speech *)activeList.first();
- sp != NULL;
- sp = (Speech *)sp->next())
- size += sp->archiveSize();
+ for (Common::List<Speech *>::iterator it = _list.begin();
+ it != _list.end(); ++it) {
+ size += (*it)->archiveSize();
+ }
- // Tally inactive speeches
- for (sp = (Speech *)nonActiveList.first();
- sp != NULL;
- sp = (Speech *)sp->next())
- size += sp->archiveSize();
+ for (Common::List<Speech *>::iterator it = _inactiveList.begin();
+ it != _inactiveList.end(); ++it) {
+ size += (*it)->archiveSize();
+ }
return size;
}
@@ -1087,33 +1094,23 @@ void *SpeechTaskList::archive(void *buf) {
int16 count = 0;
Speech *sp;
- // Tally active speeches
- for (sp = (Speech *)activeList.first();
- sp != NULL;
- sp = (Speech *)sp->next())
- count++;
-
- // Tally inactive speeches
- for (sp = (Speech *)nonActiveList.first();
- sp != NULL;
- sp = (Speech *)sp->next())
- count++;
+ count += _list.size() + _inactiveList.size();
// Store speech count
*((int16 *)buf) = count;
buf = (int16 *)buf + 1;
// Store active speeches
- for (sp = (Speech *)activeList.first();
- sp != NULL;
- sp = (Speech *)sp->next())
- buf = sp->archive(buf);
+ for (Common::List<Speech *>::iterator it = _list.begin();
+ it != _list.end(); ++it) {
+ buf = (*it)->archive(buf);
+ }
// Store inactive speeches
- for (sp = (Speech *)nonActiveList.first();
- sp != NULL;
- sp = (Speech *)sp->next())
- buf = sp->archive(buf);
+ for (Common::List<Speech *>::iterator it = _inactiveList.begin();
+ it != _inactiveList.end(); ++it) {
+ buf = (*it)->archive(buf);
+ }
return buf;
}
@@ -1122,41 +1119,31 @@ void *SpeechTaskList::archive(void *buf) {
// Cleanup the speech tasks
void SpeechTaskList::cleanup(void) {
- Speech *sp;
- Speech *nextSP;
-
- // Remove active speeches
- for (sp = (Speech *)activeList.first();
- sp != NULL;
- sp = nextSP) {
- nextSP = (Speech *)sp->next();
-
- sp->remove();
+ for (Common::List<Speech *>::iterator it = speechList._list.begin();
+ it != speechList._list.end(); ++it) {
+ delete *it;
}
- // Remove inactive speeches
- for (sp = (Speech *)nonActiveList.first();
- sp != NULL;
- sp = nextSP) {
- nextSP = (Speech *)sp->next();
-
- sp->remove();
+ for (Common::List<Speech *>::iterator it = speechList._inactiveList.begin();
+ it != speechList._inactiveList.end(); ++it) {
+ delete *it;
}
+
+ _list.clear();
+ _inactiveList.clear();
}
//-----------------------------------------------------------------------
// Search for a speech task associated with a particular GameObject.
Speech *SpeechTaskList::findSpeech(ObjectID id) {
- Speech *sp;
-
- for (sp = (Speech *)speechList.nonActiveList.first();
- sp;
- sp = (Speech *)sp->next()) {
- if (sp->objID == id) return sp;
+ for (Common::List<Speech *>::iterator it = speechList._inactiveList.begin();
+ it != speechList._inactiveList.end(); ++it) {
+ if ((*it)->objID == id)
+ return *it;
}
- return NULL;
+ return nullptr;
}
//-----------------------------------------------------------------------
@@ -1169,13 +1156,18 @@ Speech *SpeechTaskList::newTask(ObjectID id, uint16 flags) {
// Actors cannot speak if not in the world
if (obj->world() != currentWorld) return NULL;
- sp = (Speech *)free.remHead();
+ if (speechCount() >= MAX_SPEECH_PTRS) {
+ warning("Too many speech tasks: > %d", MAX_SPEECH_PTRS);
+ return nullptr;
+ }
+
+ sp = new Speech;
#if DEBUG
if (sp == NULL) fatal("Ran out of Speech Tasks, Object = %s\n", obj->objName());
#endif
if (sp == NULL) return NULL;
- debugC(1, kDebugTasks, "Speech: New Task: %p for %p (%s) (flags = %d)", (void *)sp, (void *)obj, obj->objName(), flags);
+ debugC(1, kDebugTasks, "Speech: New Task: %p for %p (%s) (flags = %d) (total = %d)", (void *)sp, (void *)obj, obj->objName(), flags, speechCount());
sp->sampleCount = sp->charCount = 0;
sp->objID = id;
@@ -1201,7 +1193,7 @@ Speech *SpeechTaskList::newTask(ObjectID id, uint16 flags) {
sp->penColor = 4 + 9;
}
- nonActiveList.addTail(*sp);
+ _inactiveList.push_back(sp);
return sp;
}
@@ -1222,8 +1214,7 @@ void SpeechTaskList::SetLock(int newState) {
// When a speech task is finished, call this function to delete it.
void Speech::remove(void) {
- DNode::remove();
- speechList.free.addTail(*this);
+ speechList.remove(this);
}
//-----------------------------------------------------------------------
diff --git a/engines/saga2/speech.h b/engines/saga2/speech.h
index bca3b5f38f..be5c0a1b70 100644
--- a/engines/saga2/speech.h
+++ b/engines/saga2/speech.h
@@ -79,7 +79,7 @@ enum {
speakLock = (1 << 3), // lock UI while speech in progress
};
-class Speech : private DNode {
+class Speech {
private:
friend class SpeechTaskList;
friend void setNextActive();
@@ -171,10 +171,8 @@ class SpeechTaskList {
int flags
);
- DList activeList,
- nonActiveList,
- free;
- Speech array[MAX_SPEECH_PTRS];
+ Common::List<Speech *> _list,
+ _inactiveList;
int8 lockFlag;
@@ -204,12 +202,20 @@ public:
Speech *findSpeech(ObjectID id);
Speech *currentActive(void) {
- return (Speech *)activeList.first();
+ if (_list.size() > 0)
+ return _list.front();
+ return nullptr;
}
int32 activeCount(void) {
- return activeList.count();
+ return _list.size();
}
+
+ int speechCount(void) {
+ return _list.size() + _inactiveList.size();
+ }
+
+ void remove(Speech *p);
};
extern SpeechTaskList &speechList;
Commit: 8e7ef16608b5482d292f3308e9cc09b51567ceaa
https://github.com/scummvm/scummvm/commit/8e7ef16608b5482d292f3308e9cc09b51567ceaa
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:36+02:00
Commit Message:
SAGA2: Remove Dlist usage from band.cpp
Changed paths:
engines/saga2/band.cpp
engines/saga2/band.h
diff --git a/engines/saga2/band.cpp b/engines/saga2/band.cpp
index a5aee11bf2..5aa043977e 100644
--- a/engines/saga2/band.cpp
+++ b/engines/saga2/band.cpp
@@ -30,7 +30,6 @@
#include "saga2/actor.h"
#include "saga2/band.h"
#include "saga2/savefile.h"
-#include "saga2/dlist.h"
namespace Saga2 {
@@ -43,21 +42,9 @@ const int numBands = 32;
// Manages the memory used for the Band's. There will only be one
// global instantiation of this class
class BandList {
-
- struct BandPlaceHolder : public DNode {
- uint8 buf[sizeof(Band)];
-
- Band *getBand(void) {
- return (Band *)&buf;
- }
- };
-
- DList list, // allocated Bands
- free; // unallocated Bands
-
- BandPlaceHolder array[numBands];
-
public:
+ Band *_list[numBands];
+
// Constructor -- initial construction
BandList(void);
@@ -76,25 +63,27 @@ public:
// Place a Band from the inactive list into the active
// list.
- void *newBand(void);
- void *newBand(BandID id);
+ Band *newBand(void);
+ Band *newBand(BandID id);
+
+ void addBand(Band *band);
// Place a Band back into the inactive list.
- void deleteBand(void *p);
+ void deleteBand(Band *p);
// Return the specified Band's ID
BandID getBandID(Band *b) {
- BandPlaceHolder *bp;
+ for (int i = 0; i < numBands; i++)
+ if (_list[i] == b)
+ return i;
- warning("FIXME: BandPlaceHolder::getBandID(): unsafe pointer arithmetics");
- bp = ((BandPlaceHolder *)((uint8 *)b - offsetof(BandPlaceHolder, buf)));
- return bp - array;
+ error("BandList::getBandID(): Unknown band");
}
// Return a pointer to a Band given a BandID
Band *getBandAddress(BandID id) {
assert(id >= 0 && id < numBands);
- return array[id].getBand();
+ return _list[id];
}
};
@@ -103,27 +92,16 @@ public:
// the inactive list
BandList::BandList(void) {
- int i;
-
- for (i = 0; i < ARRAYSIZE(array); i++)
- free.addTail(array[i]);
+ for (int i = 0; i < numBands; i++)
+ _list[i] = nullptr;
}
//----------------------------------------------------------------------
// BandList destructor
BandList::~BandList(void) {
- BandPlaceHolder *bp;
- BandPlaceHolder *nextBP;
-
- for (bp = (BandPlaceHolder *)list.first();
- bp != NULL;
- bp = nextBP) {
- // Save the address of the next in the list
- nextBP = (BandPlaceHolder *)bp->next();
-
- delete bp->getBand();
- }
+ for (int i = 0; i < numBands; i++)
+ delete _list[i];
}
//----------------------------------------------------------------------
@@ -145,7 +123,7 @@ void *BandList::restore(void *buf) {
id = *((BandID *)buf);
buf = (BandID *)buf + 1;
- new (id)Band(&buf);
+ _list[id] = new Band(&buf);
}
return buf;
@@ -156,12 +134,10 @@ void *BandList::restore(void *buf) {
int32 BandList::archiveSize(void) {
int32 size = sizeof(int16);
- BandPlaceHolder *bp;
- for (bp = (BandPlaceHolder *)list.first();
- bp != NULL;
- bp = (BandPlaceHolder *)bp->next())
- size += sizeof(BandID) + bp->getBand()->archiveSize();
+ for (int i = 0; i < numBands; i++)
+ if (_list[i])
+ size += sizeof(BandID) + _list[i]->archiveSize();
return size;
}
@@ -170,30 +146,26 @@ int32 BandList::archiveSize(void) {
// Make an archive of the BandList in an archive buffer
void *BandList::archive(void *buf) {
- int16 bandCount = 0;
- BandPlaceHolder *bp;
+ int16 bandCount = 0;
// Count the active bands
- for (bp = (BandPlaceHolder *)list.first();
- bp != NULL;
- bp = (BandPlaceHolder *)bp->next())
- bandCount++;
+ for (int i = 0; i < numBands; i++)
+ if (_list[i])
+ bandCount++;
// Store the band count in the archive buffer
*((int16 *)buf) = bandCount;
buf = (int16 *)buf + 1;
// Iterate through the bands, archiving each
- for (bp = (BandPlaceHolder *)list.first();
- bp != NULL;
- bp = (BandPlaceHolder *)bp->next()) {
- Band *b = bp->getBand();
-
- // Store the Band's id number
- *((BandID *)buf) = bp - array;
- buf = (BandID *)buf + 1;
+ for (int i = 0; i < numBands; i++) {
+ if (_list[i]) {
+ // Store the Band's id number
+ *((BandID *)buf) = i;
+ buf = (BandID *)buf + 1;
- buf = b->archive(buf);
+ buf = _list[i]->archive(buf);
+ }
}
return buf;
@@ -202,17 +174,13 @@ void *BandList::archive(void *buf) {
//----------------------------------------------------------------------
// Place a Band into the active list and return its address
-void *BandList::newBand(void) {
- BandPlaceHolder *bp;
-
- // Grab a band holder from the inactive list
- bp = (BandPlaceHolder *)free.remHead();
-
- if (bp != NULL) {
- // Place the place holder into the active list
- list.addTail(*bp);
+Band *BandList::newBand(void) {
+ for (int i = 0; i < numBands; i++) {
+ if (!_list[i]) {
+ _list[i] = new Band();
- return bp->buf;
+ return _list[i];
+ }
}
return NULL;
@@ -221,56 +189,44 @@ void *BandList::newBand(void) {
//----------------------------------------------------------------------
// Place a specific Band into the active list and return its address
-void *BandList::newBand(BandID id) {
- assert(id >= 0 && id < ARRAYSIZE(array));
+Band *BandList::newBand(BandID id) {
+ assert(id >= 0 && id < numBands);
+
+ if (_list[id])
+ delete _list[id];
- BandPlaceHolder *bp;
+ _list[id] = new Band();
+
+ return _list[id];
+}
- // Grab the band place holder from the inactive list
- bp = (BandPlaceHolder *)&array[id];
- bp->remove();
+ void BandList::addBand(Band *b) {
+ for (int i = 0; i < numBands; i++) {
+ if (!_list[i]) {
+ _list[i] = b;
- // Place the place holder into the active list
- list.addTail(*bp);
+ return;
+ }
+ }
- return bp->buf;
+ error("BandList::addBand(): Too many bands, > %d", numBands);
}
//----------------------------------------------------------------------
// Remove the specified Band from the active list and place it back
// into the inactive list
-void BandList::deleteBand(void *p) {
- BandPlaceHolder *bp;
-
- warning("FIXME: BandList::deleteBand(): unsafe pointer arithmetics");
-
- // Convert the pointer to the Band to a pointer to the
- // BandPlaceHolder
- bp = (BandPlaceHolder *)((uint8 *)p - offsetof(BandPlaceHolder, buf));
+void BandList::deleteBand(Band *p) {
+ int id = getBandID(p);
- // Remove the band place holder from the active list
- bp->remove();
-
- // Place it into the inactive list
- free.addTail(*bp);
+ _list[id] = nullptr;
}
/* ===================================================================== *
Global BandList instantiation
* ===================================================================== */
-// This is a statically allocated buffer large enough to hold a BandList.
-// The bandList is a BandList reference to this area of memory. The
-// reason that I did this in this manner is to prevent the BandList
-// constructor from being called until it is expicitly called using an
-// overloaded new call. The overloaded new call will simply return a
-// pointer to the bandListBuffer in order to construct the BandList in
-// place.
-
-static uint8 bandListBuffer[sizeof(BandList)];
-
-static BandList &bandList = *((BandList *)bandListBuffer);
+static BandList bandList;
/* ===================================================================== *
Misc. band management functions
@@ -280,11 +236,11 @@ static BandList &bandList = *((BandList *)bandListBuffer);
// Call the bandList member function newBand() to get a pointer to a
// new Band
-void *newBand(void) {
+Band *newBand(void) {
return bandList.newBand();
}
-void *newBand(BandID id) {
+Band *newBand(BandID id) {
return bandList.newBand(id);
}
@@ -292,7 +248,7 @@ void *newBand(BandID id) {
// Call the bandList member function deleteBand() to dispose of a
// previously allocated Band
-void deleteBand(void *p) {
+void deleteBand(Band *p) {
bandList.deleteBand(p);
}
@@ -314,8 +270,6 @@ Band *getBandAddress(BandID id) {
// Initialize the bandList
void initBands(void) {
- // Simply call the default constructor for the band list
- new (&bandList) BandList;
}
//----------------------------------------------------------------------
@@ -382,8 +336,12 @@ void cleanupBands(void) {
Band member functions
* ===================================================================== */
-//----------------------------------------------------------------------
-// Constructor -- reconstruct from archive buffer
+Band::Band() : leader(nullptr), memberCount(0) {
+ bandList.addBand(this);
+}
+Band::Band(Actor *l) : leader(l), memberCount(0) {
+ bandList.addBand(this);
+}
Band::Band(void **buf) {
void *bufferPtr = *buf;
@@ -408,6 +366,8 @@ Band::Band(void **buf) {
}
*buf = bufferPtr;
+
+ bandList.addBand(this);
}
//----------------------------------------------------------------------
diff --git a/engines/saga2/band.h b/engines/saga2/band.h
index 4137b386e8..8f8e15233c 100644
--- a/engines/saga2/band.h
+++ b/engines/saga2/band.h
@@ -38,11 +38,11 @@ const int maxBandMembers = 32;
* ===================================================================== */
// Allocate a new band
-void *newBand(void);
-void *newBand(BandID id);
+Band *newBand(void);
+Band *newBand(BandID id);
// Delete a previously allocated band
-void deleteBand(void *p);
+void deleteBand(Band *p);
// Get a band's ID given its address
BandID getBandID(Band *b);
@@ -69,12 +69,15 @@ class Band {
Actor *members[maxBandMembers];
public:
- // Constructor -- initial construction
- Band(Actor *l) : leader(l), memberCount(0) {}
+
+ Band();
+ Band(Actor *l);
// Constructor -- reconstruct from archive buffer
Band(void **buf);
+ ~Band() { deleteBand(this); }
+
// Return the number of bytes needed to archive this object in a
// buffer
int32 archiveSize(void);
@@ -82,17 +85,6 @@ public:
// Archive this object in a buffer
void *archive(void *buf);
- // Overloaded memory management functions
- void *operator new (size_t) {
- return newBand();
- }
- void *operator new (size_t, BandID id) {
- return newBand(id);
- }
- void operator delete (void *p) {
- deleteBand(p);
- }
-
Actor *getLeader(void) {
return leader;
}
Commit: cf8b7945b869d866e62abe565cb5a58918b3c85f
https://github.com/scummvm/scummvm/commit/cf8b7945b869d866e62abe565cb5a58918b3c85f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:36+02:00
Commit Message:
SAGA2: Move bandList from global to SagaEngine
Changed paths:
engines/saga2/band.cpp
engines/saga2/saga2.cpp
engines/saga2/saga2.h
diff --git a/engines/saga2/band.cpp b/engines/saga2/band.cpp
index 5aa043977e..7fd0def6ec 100644
--- a/engines/saga2/band.cpp
+++ b/engines/saga2/band.cpp
@@ -37,13 +37,13 @@ namespace Saga2 {
BandList class
* ===================================================================== */
-const int numBands = 32;
+const int kNumBands = 32;
// Manages the memory used for the Band's. There will only be one
// global instantiation of this class
class BandList {
public:
- Band *_list[numBands];
+ Band *_list[kNumBands];
// Constructor -- initial construction
BandList(void);
@@ -73,7 +73,7 @@ public:
// Return the specified Band's ID
BandID getBandID(Band *b) {
- for (int i = 0; i < numBands; i++)
+ for (int i = 0; i < kNumBands; i++)
if (_list[i] == b)
return i;
@@ -82,7 +82,7 @@ public:
// Return a pointer to a Band given a BandID
Band *getBandAddress(BandID id) {
- assert(id >= 0 && id < numBands);
+ assert(id >= 0 && id < kNumBands);
return _list[id];
}
};
@@ -92,7 +92,7 @@ public:
// the inactive list
BandList::BandList(void) {
- for (int i = 0; i < numBands; i++)
+ for (int i = 0; i < kNumBands; i++)
_list[i] = nullptr;
}
@@ -100,7 +100,7 @@ BandList::BandList(void) {
// BandList destructor
BandList::~BandList(void) {
- for (int i = 0; i < numBands; i++)
+ for (int i = 0; i < kNumBands; i++)
delete _list[i];
}
@@ -135,7 +135,7 @@ void *BandList::restore(void *buf) {
int32 BandList::archiveSize(void) {
int32 size = sizeof(int16);
- for (int i = 0; i < numBands; i++)
+ for (int i = 0; i < kNumBands; i++)
if (_list[i])
size += sizeof(BandID) + _list[i]->archiveSize();
@@ -149,7 +149,7 @@ void *BandList::archive(void *buf) {
int16 bandCount = 0;
// Count the active bands
- for (int i = 0; i < numBands; i++)
+ for (int i = 0; i < kNumBands; i++)
if (_list[i])
bandCount++;
@@ -158,7 +158,7 @@ void *BandList::archive(void *buf) {
buf = (int16 *)buf + 1;
// Iterate through the bands, archiving each
- for (int i = 0; i < numBands; i++) {
+ for (int i = 0; i < kNumBands; i++) {
if (_list[i]) {
// Store the Band's id number
*((BandID *)buf) = i;
@@ -175,7 +175,7 @@ void *BandList::archive(void *buf) {
// Place a Band into the active list and return its address
Band *BandList::newBand(void) {
- for (int i = 0; i < numBands; i++) {
+ for (int i = 0; i < kNumBands; i++) {
if (!_list[i]) {
_list[i] = new Band();
@@ -190,7 +190,7 @@ Band *BandList::newBand(void) {
// Place a specific Band into the active list and return its address
Band *BandList::newBand(BandID id) {
- assert(id >= 0 && id < numBands);
+ assert(id >= 0 && id < kNumBands);
if (_list[id])
delete _list[id];
@@ -201,7 +201,7 @@ Band *BandList::newBand(BandID id) {
}
void BandList::addBand(Band *b) {
- for (int i = 0; i < numBands; i++) {
+ for (int i = 0; i < kNumBands; i++) {
if (!_list[i]) {
_list[i] = b;
@@ -209,7 +209,7 @@ Band *BandList::newBand(BandID id) {
}
}
- error("BandList::addBand(): Too many bands, > %d", numBands);
+ error("BandList::addBand(): Too many bands, > %d", kNumBands);
}
//----------------------------------------------------------------------
@@ -222,12 +222,6 @@ void BandList::deleteBand(Band *p) {
_list[id] = nullptr;
}
-/* ===================================================================== *
- Global BandList instantiation
- * ===================================================================== */
-
-static BandList bandList;
-
/* ===================================================================== *
Misc. band management functions
* ===================================================================== */
@@ -237,11 +231,11 @@ static BandList bandList;
// new Band
Band *newBand(void) {
- return bandList.newBand();
+ return g_vm->_bandList->newBand();
}
Band *newBand(BandID id) {
- return bandList.newBand(id);
+ return g_vm->_bandList->newBand(id);
}
//----------------------------------------------------------------------
@@ -249,27 +243,28 @@ Band *newBand(BandID id) {
// previously allocated Band
void deleteBand(Band *p) {
- bandList.deleteBand(p);
+ g_vm->_bandList->deleteBand(p);
}
//----------------------------------------------------------------------
// Return the specified Band's ID
BandID getBandID(Band *b) {
- return bandList.getBandID(b);
+ return g_vm->_bandList->getBandID(b);
}
//----------------------------------------------------------------------
// Return a pointer to a Band given a BandID
Band *getBandAddress(BandID id) {
- return bandList.getBandAddress(id);
+ return g_vm->_bandList->getBandAddress(id);
}
//----------------------------------------------------------------------
// Initialize the bandList
void initBands(void) {
+ g_vm->_bandList = new BandList();
}
//----------------------------------------------------------------------
@@ -279,13 +274,13 @@ void saveBands(SaveFileConstructor &saveGame) {
int32 archiveBufSize;
void *archiveBuffer;
- archiveBufSize = bandList.archiveSize();
+ archiveBufSize = g_vm->_bandList->archiveSize();
archiveBuffer = malloc(archiveBufSize);
if (archiveBuffer == NULL)
error("Unable to allocate band archive buffer");
- bandList.archive(archiveBuffer);
+ g_vm->_bandList->archive(archiveBuffer);
saveGame.writeChunk(
MKTAG('B', 'A', 'N', 'D'),
@@ -301,12 +296,12 @@ void saveBands(SaveFileConstructor &saveGame) {
void loadBands(SaveFileReader &saveGame) {
// If there is no saved data, simply call the default constructor
if (saveGame.getChunkSize() == 0) {
- new (&bandList) BandList;
+ g_vm->_bandList = new BandList;
return;
}
- void *archiveBuffer;
- void *bufferPtr;
+ void *archiveBuffer;
+ void *bufferPtr;
archiveBuffer = malloc(saveGame.getChunkSize());
if (archiveBuffer == NULL)
@@ -318,8 +313,8 @@ void loadBands(SaveFileReader &saveGame) {
bufferPtr = archiveBuffer;
// Reconstruct taskList from archived data
- new (&bandList) BandList;
- bandList.restore(bufferPtr);
+ g_vm->_bandList = new BandList;
+ g_vm->_bandList->restore(bufferPtr);
free(archiveBuffer);
}
@@ -328,8 +323,8 @@ void loadBands(SaveFileReader &saveGame) {
// Cleanup the bandList
void cleanupBands(void) {
- // Simply call the bandList's destructor
- bandList.~BandList();
+ delete g_vm->_bandList;
+ g_vm->_bandList = nullptr;
}
/* ===================================================================== *
@@ -337,10 +332,10 @@ void cleanupBands(void) {
* ===================================================================== */
Band::Band() : leader(nullptr), memberCount(0) {
- bandList.addBand(this);
+ g_vm->_bandList->addBand(this);
}
Band::Band(Actor *l) : leader(l), memberCount(0) {
- bandList.addBand(this);
+ g_vm->_bandList->addBand(this);
}
Band::Band(void **buf) {
@@ -367,7 +362,7 @@ Band::Band(void **buf) {
*buf = bufferPtr;
- bandList.addBand(this);
+ g_vm->_bandList->addBand(this);
}
//----------------------------------------------------------------------
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index 87358a00f9..cc28d714b1 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -57,6 +57,7 @@ Saga2Engine::Saga2Engine(OSystem *syst)
g_vm = this;
+ _bandList = nullptr;
_smkDecoder = nullptr;
_videoX = _videoY = 0;
diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h
index 1957831d2e..0cd7d031bd 100644
--- a/engines/saga2/saga2.h
+++ b/engines/saga2/saga2.h
@@ -41,6 +41,7 @@ namespace Saga2 {
class Timer;
class TimerList;
+class BandList;
enum {
kDebugResources = 1 << 0,
@@ -91,6 +92,7 @@ public:
weaponID _loadedWeapons = 0;
Common::List<TimerList *> _timerLists;
Common::List<Timer *> _timers;
+ BandList *_bandList;
bool _autoAggression;
bool _autoWeapon;
Commit: a85940e77d8175b7c5f5c32be6bd2a8a27c6eaac
https://github.com/scummvm/scummvm/commit/a85940e77d8175b7c5f5c32be6bd2a8a27c6eaac
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:36+02:00
Commit Message:
SAGA2: Unstub mouse-related interface functions
Changed paths:
engines/saga2/intrface.cpp
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index 6d236eded7..ea985d6ae1 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -2302,10 +2302,9 @@ APPFUNC(cmdAggressive) {
} else if (ev.eventType == gEventMouseMove) {
if (ev.value == gCompImage::enter) {
// set the text in the cursor
- warning("STUB: APPFUNC(cmdAggressive)");
- //mouseInfo.setText(isAggressive(transBroID)
- // ? ON_AGRESS
- // : OFF_AGRESS);
+ mouseInfo.setText(isAggressive(transBroID)
+ ? ON_AGRESS
+ : OFF_AGRESS);
} else if (ev.value == gCompImage::leave) {
mouseInfo.setText(nullptr);
}
@@ -2368,10 +2367,9 @@ APPFUNC(cmdCenter) {
if (ev.eventType == gEventMouseMove) {
if (ev.value == gCompImage::enter) {
// set the text in the cursor
- warning("STUB: APPFUNC(cmdCenter)");
- //mouseInfo.setText(getCenterActorPlayerID() == transBroID
- // ? ON_CENTER
- // : OFF_CENTER);
+ mouseInfo.setText(getCenterActorPlayerID() == transBroID
+ ? ON_CENTER
+ : OFF_CENTER);
} else if (ev.value == gCompImage::leave) {
mouseInfo.setText(nullptr);
}
@@ -2403,10 +2401,9 @@ APPFUNC(cmdBand) {
} else if (ev.eventType == gEventMouseMove) {
if (ev.value == gCompImage::enter) {
// set the text in the cursor
- warning("STUB: APPFUNC(cmdBand)");
- //mouseInfo.setText(isBanded(transBroID)
- // ? ON_BANDED
- // : OFF_BANDED);
+ mouseInfo.setText(isBanded(transBroID)
+ ? ON_BANDED
+ : OFF_BANDED);
} else if (ev.value == gCompImage::leave) {
mouseInfo.setText(nullptr);
}
Commit: 8f9c326747c0e38ec217f7799f8d9088d6c47762
https://github.com/scummvm/scummvm/commit/8f9c326747c0e38ec217f7799f8d9088d6c47762
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:36+02:00
Commit Message:
SAGA2: Raise level of script stack debug messages
Changed paths:
engines/saga2/interp.cpp
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 1920be6693..bd544e194f 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -546,13 +546,13 @@ static void print_stack(int16 *stackBase, int16 *stack) {
if (size > STACK_PRINT_DEPTH)
end = stack + STACK_PRINT_DEPTH;
- debugCN(2, kDebugScripts, "stack size: %d: [", size);
+ debugCN(3, kDebugScripts, "stack size: %d: [", size);
for (int16 *i = stack; i < end; i++)
- debugCN(2, kDebugScripts, "%d ", *i);
+ debugCN(3, kDebugScripts, "%d ", *i);
if (size > STACK_PRINT_DEPTH)
- debugCN(2, kDebugScripts, "... ");
+ debugCN(3, kDebugScripts, "... ");
- debugC(2, kDebugScripts, "]");
+ debugC(3, kDebugScripts, "]");
}
#define D_OP(x) debugC(1, kDebugScripts, "[%04ld 0x%04lx]: %s", (pc - codeSeg - 1), (pc - codeSeg - 1), #x)
Commit: 8748806a5c01ac0556c20d896053ad6d7210e5bd
https://github.com/scummvm/scummvm/commit/8748806a5c01ac0556c20d896053ad6d7210e5bd
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:36+02:00
Commit Message:
SAGA2: Add more debug messages
Changed paths:
engines/saga2/sagafunc.cpp
engines/saga2/timers.cpp
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index faecb72664..f419d94d99 100644
--- a/engines/saga2/sagafunc.cpp
+++ b/engines/saga2/sagafunc.cpp
@@ -255,7 +255,7 @@ int16 scriptActorTransfer(int16 *args) {
globalContainerList.setUpdate(targetID);
}
} else {
- obj->move(Location(args[1], args[2], args[3], args[0 ]));
+ obj->move(Location(args[1], args[2], args[3], args[0]));
}
// If optional 5th parameter is present, then set actor facing
@@ -524,6 +524,7 @@ int16 scriptActorSay(int16 *args) {
uint16 sampleNum = args[i];
char *speechText = STRING(args[i + 1]);
+ debugC(2, kDebugScripts, "Speech Text: - %s", speechText);
sp->append(speechText, sampleNum);
}
@@ -1259,6 +1260,7 @@ int16 scriptActorGetVitality(int16 *) {
if (isActor((GameObject *)thisThread->thisObject)) {
Actor *a = (Actor *)thisThread->thisObject;
+ debugC(2, kDebugScripts, " - value = %d", a->getStats()->vitality);
return a->getStats()->vitality;
}
@@ -1276,6 +1278,7 @@ int16 scriptActorSetVitality(int16 *args) {
int16 &vitalityRef = a->getStats()->vitality;
int16 oldVal = vitalityRef;
PlayerActorID pID;
+ debugC(2, kDebugScripts, " - value = %d", args[0]);
vitalityRef = args[0];
if (actorToPlayerID(a, pID)) updateBrotherControls(pID);
diff --git a/engines/saga2/timers.cpp b/engines/saga2/timers.cpp
index e33da65bf5..3cb25d1846 100644
--- a/engines/saga2/timers.cpp
+++ b/engines/saga2/timers.cpp
@@ -113,6 +113,7 @@ TimerList *fetchTimerList(GameObject *obj) {
void checkTimers(void) {
for (Common::List<Timer *>::iterator it = g_vm->_timers.begin(); it != g_vm->_timers.end(); ++it) {
if ((*it)->check()) {
+ debugC(2, kDebugTimers, "Timer tick for %p (%s): %p (duration %d)", (void *)(*it)->getObject(), (*it)->getObject()->objName(), (void *)(*it), (*it)->getInterval());
(*it)->reset();
(*it)->getObject()->timerTick((*it)->thisID());
}
Commit: 932b20ace6357621eb723de8d5c6f6eb26fe3bbb
https://github.com/scummvm/scummvm/commit/932b20ace6357621eb723de8d5c6f6eb26fe3bbb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:36+02:00
Commit Message:
SAGA2: Fix warnings
Changed paths:
engines/saga2/speech.cpp
diff --git a/engines/saga2/speech.cpp b/engines/saga2/speech.cpp
index c4206c4105..bc477699af 100644
--- a/engines/saga2/speech.cpp
+++ b/engines/saga2/speech.cpp
@@ -1070,7 +1070,6 @@ SpeechTaskList::SpeechTaskList(void **buf) {
int32 SpeechTaskList::archiveSize(void) {
int32 size = 0;
- Speech *sp;
size += sizeof(int16); // Speech count
@@ -1092,7 +1091,6 @@ int32 SpeechTaskList::archiveSize(void) {
void *SpeechTaskList::archive(void *buf) {
int16 count = 0;
- Speech *sp;
count += _list.size() + _inactiveList.size();
Commit: 8da92d2af52b678642b4faa0afcd2fba56dc1cd4
https://github.com/scummvm/scummvm/commit/8da92d2af52b678642b4faa0afcd2fba56dc1cd4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:37+02:00
Commit Message:
SAGA2: Cleanup speech.cpp
Changed paths:
engines/saga2/speech.cpp
diff --git a/engines/saga2/speech.cpp b/engines/saga2/speech.cpp
index bc477699af..b8d69f314a 100644
--- a/engines/saga2/speech.cpp
+++ b/engines/saga2/speech.cpp
@@ -99,21 +99,6 @@ int16 speechLineCount, // count of speech lines
static Point16 initialSpeechPosition; // inital coords of speech
// Image data for the little "bullet"
-
-#if 0
-static uint8 BulletData[] = {
- 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, // Row 0
- 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, // Row 1
- 0x00, 0x0F, 0x0F, 0x43, 0x41, 0x41, 0x0F, 0x0F, 0x00, // Row 2
- 0x0F, 0x0F, 0x45, 0x43, 0x41, 0x01, 0x41, 0x0F, 0x0F, // Row 3
- 0x0F, 0x0F, 0x47, 0x45, 0x43, 0x41, 0x41, 0x0F, 0x0F, // Row 4
- 0x0F, 0x0F, 0x45, 0x47, 0x47, 0x45, 0x45, 0x0F, 0x0F, // Row 5
- 0x00, 0x0F, 0x0F, 0x45, 0x47, 0x47, 0x0F, 0x0F, 0x00, // Row 6
- 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, // Row 7
- 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, // Row 8
-};
-#else
-// Remapped by hand into new palette
static uint8 BulletData[] = {
0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, // Row 0
0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, // Row 1
@@ -125,7 +110,6 @@ static uint8 BulletData[] = {
0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, // Row 7
0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, // Row 8
};
-#endif
static gStaticImage BulletImage(9, 9, BulletData);
@@ -618,89 +602,6 @@ void abortSpeech(void) {
if (speechList.currentActive()) speechList.currentActive()->abortSpeech();
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#if 0
-
-//Non Member Speech Functions / User Interface Calls
-
-void queueActorSpeech(
- GameObject *obj,
- char *text,
- int count,
- int32 sampleID,
- int flags
-) {
- Speech *sp;
-
- // Check see if there's already speech associated with this object.
- for (sp = (Speech *)speechList._inactiveList.first();
- sp;
- sp = (Speech *)sp->next()) {
- if (sp->obj == obj) {
- if (!sp->addSpeech(text, sampleID, flags))
- throw gError("Cant Append Speech");
- return;
- }
- }
-
- sp = speechList.newTask(obj, text, count, sampleID, flags);
-
-}
-
-// Causes all speeches to be skipped over
-
-void abortAllSpeeches(void) {
-// int16 i;
-
-// activeSpeech.speechFinished.set( 0 );
-// SetAlarm( &activeSpeech.speechFinished, 0 );
-// if (activeSpeech.sampleID != -1)
-// {
-// StopVoices();
-// activeSpeech.sampleID = -1;
-// }
-// if (abortEnabled)
-// {
-// skipSpeeches = true;
-// wakeUpThreads( TWAIT_SPEECH );
-// }
-
-// for (i=0; i<10; i++) dispatchThreads();
-}
-
-void sentenceGenerator(char *sentence) {
- int16 index;
-
- index = rand() % ARRAYSIZE(names);
- strcat(sentence, names[index]);
- index = rand() % ARRAYSIZE(verbs);
- strcat(sentence, verbs[index]);
- index = rand() % ARRAYSIZE(adjectives);
- strcat(sentence, adjectives[index]);
- index = rand() % ARRAYSIZE(nouns);
- strcat(sentence, nouns[index]);
-
-// for(int i=0; i<ARRAYSIZE(sentenceParts); i++)
-// {
-// strcat(sentence,sentenceParts[i].index = rand() % ARRAYSIZE(sentenceParts[i]);
-// }
-
-}
-#endif
-
//-----------------------------------------------------------------------
// Delete all speeches relating to a particular actor
@@ -716,9 +617,7 @@ int16 TextWrap(
int16 line_pixels[], // pixel count of each line
char *text, // the text to render
int16 width // width to constrain text
-)
-
-{
+) {
int16 i, // loop counter
line_start, // start of current line
last_space, // last space encountered
@@ -1244,10 +1143,6 @@ APPFUNC(cmdClickSpeech) {
if ((sp = speechList.currentActive()) != NULL) {
sp->selectedButton = pickSpeechButton(ev.mouse);
-#if 0
- if (sp->selectedButton != 0)
- sp->dispose();
-#endif
}
break;
Commit: b210e1691fca609ee4b5f5ae0f20e7d5c31dfc30
https://github.com/scummvm/scummvm/commit/b210e1691fca609ee4b5f5ae0f20e7d5c31dfc30
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:37+02:00
Commit Message:
SAGA2: Get rid of some global constructors in uidialog.cpp
Changed paths:
engines/saga2/button.cpp
engines/saga2/button.h
engines/saga2/panel.cpp
engines/saga2/panel.h
engines/saga2/rect.h
engines/saga2/uidialog.cpp
diff --git a/engines/saga2/button.cpp b/engines/saga2/button.cpp
index 43e4306e33..9c3bb378e0 100644
--- a/engines/saga2/button.cpp
+++ b/engines/saga2/button.cpp
@@ -179,6 +179,25 @@ gCompImage::gCompImage(gPanelList &list, const Rect16 &box, void **images,
#endif
}
+gCompImage::gCompImage(gPanelList &list, const StaticRect &box, void **images,
+ int16 numRes, int16 initial, const char *text, textPallete &pal,
+ uint16 ident, AppFunc *cmd) : gControl(list, box, text, ident, cmd) {
+ init();
+
+ if (images) {
+ compImages = images;
+
+ // set up limits
+ max = numRes - 1;
+ currentImage = clamp(min, initial, max);
+ }
+
+ title = text;
+ textFont = &Onyx10Font; // >>> this should be dynamic
+ textPal = pal;
+}
+
+
gCompImage::~gCompImage(void) {
// delete any allocated image pointers
// for JEFFL: I took out the winklude #ifdefs becuase I belive
@@ -478,6 +497,21 @@ gCompButton::gCompButton(gPanelList &list, const Rect16 &box, void *image, uint1
extent = box;
}
+gCompButton::gCompButton(gPanelList &list, const StaticRect &box, void **images, int16 numRes, const char *text, textPallete &pal, uint16 ident, AppFunc *cmd) : gCompImage(list, box, NULL, 0, 0, text, pal, ident, cmd) {
+ if (images[0] && images[1] && numRes == 2) {
+ forImage = images[0];
+ resImage = images[1];
+ dimImage = nullptr;
+ } else {
+ forImage = nullptr;
+ resImage = nullptr;
+ dimImage = nullptr;
+ }
+
+ internalAlloc = false;
+ dimmed = false;
+ extent = box;
+}
gCompButton::~gCompButton(void) {
if (internalAlloc) {
diff --git a/engines/saga2/button.h b/engines/saga2/button.h
index b3bbb2154e..cfc8b6a98f 100644
--- a/engines/saga2/button.h
+++ b/engines/saga2/button.h
@@ -125,6 +125,9 @@ public:
uint16 ident,
AppFunc *cmd);
+ gCompImage(gPanelList &, const StaticRect &, void **, int16, int16,
+ const char *, textPallete &, uint16, AppFunc *cmd = NULL);
+
~gCompImage(void);
void pointerMove(gPanelMessage &msg);
@@ -222,6 +225,10 @@ public:
gCompButton(gPanelList &, const Rect16 &, void *,
uint16, AppFunc *cmd = NULL);
+ gCompButton(gPanelList &, const StaticRect &, void **, int16,
+ const char *, textPallete &, uint16, AppFunc *cmd = NULL);
+
+
~gCompButton(void);
diff --git a/engines/saga2/panel.cpp b/engines/saga2/panel.cpp
index 1caf439d2d..420db50071 100644
--- a/engines/saga2/panel.cpp
+++ b/engines/saga2/panel.cpp
@@ -92,6 +92,19 @@ gPanel::gPanel(gPanelList &list, const Rect16 &box,
id = ident;
}
+gPanel::gPanel(gPanelList &list, const StaticRect &box,
+ const char *newTitle, uint16 ident, AppFunc *cmd)
+ : window(list.window) {
+ title = newTitle;
+ extent = Rect16(box);
+ enabled = 1;
+ ghosted = 0;
+ selected = 0;
+ imageLabel = 0;
+ command = cmd;
+ id = ident;
+}
+
// Dummy virtual functions
gPanel::~gPanel() {
@@ -611,6 +624,15 @@ gControl::~gControl() {
remove();
}
+gControl::gControl(gPanelList &list, const StaticRect &box, const char *title_, uint16 ident,
+ AppFunc *cmd) : gPanel(list, box, title_, ident, cmd) {
+ accelKey = 0;
+
+ // Add control to the window's control list.
+
+ list.contents.addTail(*this);
+}
+
void gControl::enable(bool abled) {
if (!abled != !getEnabled()) { // Use '!' to insure boolean-ness
gPanel::enable(abled);
diff --git a/engines/saga2/panel.h b/engines/saga2/panel.h
index b4e84c8eb7..b08157e057 100644
--- a/engines/saga2/panel.h
+++ b/engines/saga2/panel.h
@@ -149,6 +149,8 @@ public:
// constructor
gPanel(gPanelList &, const Rect16 &, const char *, uint16, AppFunc *cmd = NULL);
gPanel(gPanelList &, const Rect16 &, gPixelMap &, uint16, AppFunc *cmd = NULL);
+
+ gPanel(gPanelList &, const StaticRect &, const char *, uint16, AppFunc *cmd = NULL);
virtual ~gPanel(); // destructor
virtual gPanel *hitTest(const Point16 &p);
@@ -402,6 +404,8 @@ public:
gControl(gPanelList &, const Rect16 &, const char *, uint16, AppFunc *cmd = NULL);
gControl(gPanelList &, const Rect16 &, gPixelMap &, uint16, AppFunc *cmd = NULL);
+
+ gControl(gPanelList &, const StaticRect &, const char *, uint16, AppFunc *cmd = NULL);
~gControl(); // destructor
gPanel *keyTest(int16 key);
diff --git a/engines/saga2/rect.h b/engines/saga2/rect.h
index 4222aebcd7..cc3b30da5a 100644
--- a/engines/saga2/rect.h
+++ b/engines/saga2/rect.h
@@ -243,6 +243,10 @@ typedef Point32 Vector32; // vectors are treated as points
typedef Point32 Extent32; // contains width and height
+struct StaticRect {
+ int16 x, y, width, height;
+};
+
/* ===================================================================== *
Rect16: 16-bit 2-D rectangle
* ===================================================================== */
@@ -304,6 +308,14 @@ public:
return r;
}
#endif
+
+ Rect16(StaticRect r) {
+ x = r.x;
+ y = r.y;
+ width = r.width;
+ height = r.height;
+ }
+
// Rect16 operators
friend int operator==(Rect16 a, Rect16 b) {
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index 946a2eed01..5ee7aa9914 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -289,51 +289,70 @@ const int imageHeight = 17;
const int textPixelLen = 175;
const int smallTextOffset = 80;
+static const StaticRect optResumeRect = {
+ optBoxXSzNS - (pushButtonWidth + 14),
+ buttonYOffset + buttonSpace,
+ pushButtonWidth,
+ pushButtonHeight
+};
-Rect16 optResumeRect(optBoxXSzNS - (pushButtonWidth + 14),
- buttonYOffset + buttonSpace,
- pushButtonWidth,
- pushButtonHeight);
+static const StaticRect optSaveRect = {
+ optBoxXSzNS - (pushButtonWidth + 14),
+ buttonYOffset + ((pushButtonHeight * 1) + buttonSpace * 2),
+ pushButtonWidth,
+ pushButtonHeight
+};
-Rect16 optSaveRect(optBoxXSzNS - (pushButtonWidth + 14),
- buttonYOffset + ((pushButtonHeight * 1) + buttonSpace * 2),
- pushButtonWidth,
- pushButtonHeight);
-Rect16 optRestoreRect(optBoxXSzNS - (pushButtonWidth + 14),
- buttonYOffset + ((pushButtonHeight * 2) + buttonSpace * 3),
- pushButtonWidth,
- pushButtonHeight);
-Rect16 optQuitRect(optBoxXSzNS - (pushButtonWidth + 14),
- buttonYOffset + ((pushButtonHeight * 3) + buttonSpace * 4),
- pushButtonWidth,
- pushButtonHeight);
+static const StaticRect optRestoreRect = {
+ optBoxXSzNS - (pushButtonWidth + 14),
+ buttonYOffset + ((pushButtonHeight * 2) + buttonSpace * 3),
+ pushButtonWidth,
+ pushButtonHeight
+};
-Rect16 optCreditsRect(optBoxXSzNS - (pushButtonWidth + 14),
- buttonYOffset + ((pushButtonHeight * 4) + buttonSpace * 5),
- pushButtonWidth,
- pushButtonHeight);
+static const StaticRect optQuitRect = {
+ optBoxXSzNS - (pushButtonWidth + 14),
+ buttonYOffset + ((pushButtonHeight * 3) + buttonSpace * 4),
+ pushButtonWidth,
+ pushButtonHeight
+};
-Rect16 optAggressRect(14,
- 98 + optTPHeight,
- 18,
- 17);
+static const StaticRect optCreditsRect = {
+ optBoxXSzNS - (pushButtonWidth + 14),
+ buttonYOffset + ((pushButtonHeight * 4) + buttonSpace * 5),
+ pushButtonWidth,
+ pushButtonHeight
+};
-Rect16 optWeaponRect(14,
- 121 + optTPHeight,
- 18,
- 17);
+static const StaticRect optAggressRect = {
+ 14,
+ 98 + optTPHeight,
+ 18,
+ 17
+};
-Rect16 optSpeechRect(14,
- 121 + 23 + optTPHeight,
- 18,
- 17);
+static const StaticRect optWeaponRect = {
+ 14,
+ 121 + optTPHeight,
+ 18,
+ 17
+};
-Rect16 optNightRect(14 + 200,
- 98 + optTPHeight,
- 18,
- 17);
+static const StaticRect optSpeechRect = {
+ 14,
+ 121 + 23 + optTPHeight,
+ 18,
+ 17
+};
+
+static const StaticRect optNightRect = {
+ 14 + 200,
+ 98 + optTPHeight,
+ 18,
+ 17
+};
Rect16 optTopSliderRect(15,
15 + optTPHeight - 2,
@@ -423,7 +442,8 @@ Rect16 optionsPanelRects[numOptionsPanels] = { { optTopPanel },
{ optBotPanel }
};
-Rect16 optionsButtonRects[] = { { optResumeRect },
+StaticRect optionsButtonRects[] = {
+ { optResumeRect },
{ optSaveRect },
{ optRestoreRect },
{ optQuitRect },
Commit: 23953b6d9c1ad0c6ac60e528db24e58d630c985d
https://github.com/scummvm/scummvm/commit/23953b6d9c1ad0c6ac60e528db24e58d630c985d
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:37+02:00
Commit Message:
SAGA2: Rename some constants in uidialog.cpp
Changed paths:
engines/saga2/uidialog.cpp
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index 5ee7aa9914..d6cb9f5510 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -136,22 +136,22 @@ enum messageImageResIDs {
// Save/Load dialog metrics
-const int numSaveLoadPanels = 3;
-const int numSaveLoadBtns = 4;
-const int numSaveLoadTexts = 1;
+const int kNumSaveLoadPanels = 3;
+const int kNumSaveLoadBtns = 4;
+const int kNumSaveLoadTexts = 1;
-const int16 SLDBoxXSize = 374,
- SLDBoxXSzNS = 366,
- SLDBoxYSize = 223,
- SLDBoxX = (640 - SLDBoxXSize) / 2,
- SLDBoxY = (480 - SLDBoxYSize) / 3;
+const int16 SLDBoxXSize = 374,
+ SLDBoxXSzNS = 366,
+ SLDBoxYSize = 223,
+ SLDBoxX = (640 - SLDBoxXSize) / 2,
+ SLDBoxY = (480 - SLDBoxYSize) / 3;
-const int16 SLTPHeight = 38;
-const int16 SLMDHeight = 122;
-const int16 SLBTHeight = 63;
-const int16 SLTPWidth = 374;
-const int16 SLMDWidth = 374;
-const int16 SLBTWidth = 374;
+const int16 SLTPHeight = 38;
+const int16 SLMDHeight = 122;
+const int16 SLBTHeight = 63;
+const int16 SLTPWidth = 374;
+const int16 SLMDWidth = 374;
+const int16 SLBTWidth = 374;
@@ -211,24 +211,24 @@ Rect16 saveLoadWindowRect = Rect16(SLDBoxX,
// indirections
-Rect16 saveLoadPanelRects[numSaveLoadPanels] = { { SLTopPanel },
+Rect16 saveLoadPanelRects[kNumSaveLoadPanels] = { { SLTopPanel },
{ SLMidPanel },
{ SLBotPanel }
};
-Rect16 saveLoadButtonRects[numSaveLoadBtns] = { { SLQuitBtnRect },
+Rect16 saveLoadButtonRects[kNumSaveLoadBtns] = { { SLQuitBtnRect },
{ SLBtnRect },
{ SLUpArrowBtnRect },
{ SLDnArrowBtnRect }
};
-Rect16 saveLoadTextRects[numSaveLoadTexts] = { { SLTitleRect } };
+Rect16 saveLoadTextRects[kNumSaveLoadTexts] = { { SLTitleRect } };
// save/load dialog window decorations
-WindowDecoration saveWindowDecorations[numSaveLoadPanels] =
+WindowDecoration saveWindowDecorations[kNumSaveLoadPanels] =
{ { WindowDecoration(saveLoadPanelRects[0], SLTopPanelResID) },
{ WindowDecoration(saveLoadPanelRects[1], SLMidPanelResID) },
@@ -238,9 +238,9 @@ WindowDecoration saveWindowDecorations[numSaveLoadPanels] =
// Options dialog metrics
-const int numOptionsPanels = 3;
-const int numOptionsBtns = 9;
-const int numOptionsTexts = 8;
+const int kNumOptionsPanels = 3;
+const int kNumOptionsBtns = 9;
+const int kNumOptionsTexts = 8;
const int16 optBoxXSize = 487,
@@ -277,53 +277,53 @@ Rect16 optBotPanel(optBoxX,
// buttons
-const int buttonSpace = 3;
-const int buttonYOffset = optTPHeight + 7;
-const int pushButtonWidth = 121;
-const int pushButtonHeight = 30;
+const int kButtonSpace = 3;
+const int kButtonYOffset = optTPHeight + 7;
+const int kPushButtonWidth = 121;
+const int kPushButtonHeight = 30;
-const int sliderWidth = 168;
+const int kSliderWidth = 168;
//const int sliderHeight = 15;
-const int imageHeight = 17;
+const int kImageHeight = 17;
-const int textPixelLen = 175;
-const int smallTextOffset = 80;
+const int kTextPixelLen = 175;
+const int kSmallTextOffset = 80;
static const StaticRect optResumeRect = {
- optBoxXSzNS - (pushButtonWidth + 14),
- buttonYOffset + buttonSpace,
- pushButtonWidth,
- pushButtonHeight
+ optBoxXSzNS - (kPushButtonWidth + 14),
+ kButtonYOffset + kButtonSpace,
+ kPushButtonWidth,
+ kPushButtonHeight
};
static const StaticRect optSaveRect = {
- optBoxXSzNS - (pushButtonWidth + 14),
- buttonYOffset + ((pushButtonHeight * 1) + buttonSpace * 2),
- pushButtonWidth,
- pushButtonHeight
+ optBoxXSzNS - (kPushButtonWidth + 14),
+ kButtonYOffset + ((kPushButtonHeight * 1) + kButtonSpace * 2),
+ kPushButtonWidth,
+ kPushButtonHeight
};
static const StaticRect optRestoreRect = {
- optBoxXSzNS - (pushButtonWidth + 14),
- buttonYOffset + ((pushButtonHeight * 2) + buttonSpace * 3),
- pushButtonWidth,
- pushButtonHeight
+ optBoxXSzNS - (kPushButtonWidth + 14),
+ kButtonYOffset + ((kPushButtonHeight * 2) + kButtonSpace * 3),
+ kPushButtonWidth,
+ kPushButtonHeight
};
static const StaticRect optQuitRect = {
- optBoxXSzNS - (pushButtonWidth + 14),
- buttonYOffset + ((pushButtonHeight * 3) + buttonSpace * 4),
- pushButtonWidth,
- pushButtonHeight
+ optBoxXSzNS - (kPushButtonWidth + 14),
+ kButtonYOffset + ((kPushButtonHeight * 3) + kButtonSpace * 4),
+ kPushButtonWidth,
+ kPushButtonHeight
};
static const StaticRect optCreditsRect = {
- optBoxXSzNS - (pushButtonWidth + 14),
- buttonYOffset + ((pushButtonHeight * 4) + buttonSpace * 5),
- pushButtonWidth,
- pushButtonHeight
+ optBoxXSzNS - (kPushButtonWidth + 14),
+ kButtonYOffset + ((kPushButtonHeight * 4) + kButtonSpace * 5),
+ kPushButtonWidth,
+ kPushButtonHeight
};
static const StaticRect optAggressRect = {
@@ -356,33 +356,33 @@ static const StaticRect optNightRect = {
Rect16 optTopSliderRect(15,
15 + optTPHeight - 2,
- sliderWidth,
- imageHeight);
+ kSliderWidth,
+ kImageHeight);
Rect16 optMidSliderRect(15,
optTopSliderRect.y + 32 - 2,
- sliderWidth,
- imageHeight);
+ kSliderWidth,
+ kImageHeight);
Rect16 optBotSliderRect(15,
optMidSliderRect.y + 32 - 2,
- sliderWidth,
- imageHeight);
+ kSliderWidth,
+ kImageHeight);
Rect16 optTopFaceRect(optTopSliderRect.x,
optTopSliderRect.y,
28,
- imageHeight);
+ kImageHeight);
Rect16 optMidFaceRect(optMidSliderRect.x,
optMidSliderRect.y,
28,
- imageHeight);
+ kImageHeight);
Rect16 optBotFaceRect(optBotSliderRect.x,
optBotSliderRect.y,
28,
- imageHeight);
+ kImageHeight);
// texts
@@ -392,39 +392,39 @@ Rect16 optTitleText(0,
optBoxXSzNS,
optTPHeight);
-Rect16 optTopSlideText(16 + sliderWidth,
+Rect16 optTopSlideText(16 + kSliderWidth,
optTopSliderRect.y + 1,
- textPixelLen,
+ kTextPixelLen,
20);
-Rect16 optMidSlideText(16 + sliderWidth,
+Rect16 optMidSlideText(16 + kSliderWidth,
optMidSliderRect.y + 1,
- textPixelLen,
+ kTextPixelLen,
17);
-Rect16 optBotSlideText(16 + sliderWidth,
+Rect16 optBotSlideText(16 + kSliderWidth,
optBotSliderRect.y + 1,
- textPixelLen,
+ kTextPixelLen,
17);
Rect16 optTopCheckText(optAggressRect.x + optAggressRect.width + 3,
optAggressRect.y,
- textPixelLen - smallTextOffset,
+ kTextPixelLen - kSmallTextOffset,
17);
Rect16 optMidCheckText(optWeaponRect.x + optWeaponRect.width + 3,
optWeaponRect.y,
- textPixelLen - smallTextOffset,
+ kTextPixelLen - kSmallTextOffset,
17);
Rect16 optBotCheckText(optSpeechRect.x + optSpeechRect.width + 3,
optSpeechRect.y,
- textPixelLen - smallTextOffset,
+ kTextPixelLen - kSmallTextOffset,
17);
Rect16 optTop2CheckText(optNightRect.x + optNightRect.width + 3,
optNightRect.y,
- textPixelLen - smallTextOffset,
+ kTextPixelLen - kSmallTextOffset,
17);
// options window rect
@@ -437,7 +437,7 @@ Rect16 optionsWindowRect = Rect16(optBoxX,
// indirections
-Rect16 optionsPanelRects[numOptionsPanels] = { { optTopPanel },
+Rect16 optionsPanelRects[kNumOptionsPanels] = { { optTopPanel },
{ optMidPanel },
{ optBotPanel }
};
@@ -467,7 +467,7 @@ Rect16 optionsTextRects[] = { { optTitleText },
// options dialog window decorations
-WindowDecoration optionsDecorations[numOptionsPanels] =
+WindowDecoration optionsDecorations[kNumOptionsPanels] =
{ { WindowDecoration(optionsPanelRects[0], optTopPanelResID) },
{ WindowDecoration(optionsPanelRects[1], optMidPanelResID) },
@@ -477,9 +477,9 @@ WindowDecoration optionsDecorations[numOptionsPanels] =
// Message Dialog Metrics
-const int numMessagePanels = 1;
-const int numMessageBtns = 3;
-const int numMessageTexts = 2;
+const int kNumMessagePanels = 1;
+const int kNumMessageBtns = 3;
+const int kNumMessageTexts = 2;
const int mesBtnOffset = 14;
const int16 mesBoxXSize = 374,
@@ -498,21 +498,21 @@ Rect16 messagePanel(mesBoxX,
// buttons
-Rect16 mesCancelBtnRect(mesBoxXSzNS - (pushButtonWidth + mesBtnOffset),
+Rect16 mesCancelBtnRect(mesBoxXSzNS - (kPushButtonWidth + mesBtnOffset),
mesBoxY - mesBtnOffset,
- pushButtonWidth,
- pushButtonHeight);
+ kPushButtonWidth,
+ kPushButtonHeight);
Rect16 mesOkBtnRect(mesBtnOffset,
mesBoxY - mesBtnOffset,
- pushButtonWidth,
- pushButtonHeight);
+ kPushButtonWidth,
+ kPushButtonHeight);
-Rect16 mesBtn3Rect(mesBoxXSzNS / 2 - pushButtonWidth / 2,
+Rect16 mesBtn3Rect(mesBoxXSzNS / 2 - kPushButtonWidth / 2,
mesBoxY - mesBtnOffset,
- pushButtonWidth,
- pushButtonHeight);
+ kPushButtonWidth,
+ kPushButtonHeight);
@@ -530,12 +530,12 @@ Rect16 messageRect(0,
-Rect16 messageTextRects[numMessageTexts] = { { mesTitleRect },
+Rect16 messageTextRects[kNumMessageTexts] = { { mesTitleRect },
{ messageRect }
};
-Rect16 messageButtonRects[numMessageBtns] = { { mesOkBtnRect },
+Rect16 messageButtonRects[kNumMessageBtns] = { { mesOkBtnRect },
{ mesCancelBtnRect },
{ mesBtn3Rect }
};
@@ -552,7 +552,7 @@ Rect16 messageWindowRect = Rect16(mesBoxX,
// message dialog window decorations
-WindowDecoration messageDecorations[numMessagePanels] =
+WindowDecoration messageDecorations[kNumMessagePanels] =
{ { WindowDecoration(messagePanel, mesPanelResID) } };
@@ -660,11 +660,11 @@ int16 FileDialog(int16 fileProcess) {
AppFunc *fileCommands[2] = { cmdFileSave, cmdFileLoad };
// text for dialog
- const char *saveTextStrings[numSaveLoadTexts] = { SAVE_DIALOG_NAME };
- const char *saveBtnStrings[numSaveLoadBtns] = { SAVE_DIALOG_BUTTON1, SAVE_DIALOG_BUTTON2 };
+ const char *saveTextStrings[kNumSaveLoadTexts] = { SAVE_DIALOG_NAME };
+ const char *saveBtnStrings[kNumSaveLoadBtns] = { SAVE_DIALOG_BUTTON1, SAVE_DIALOG_BUTTON2 };
- const char *loadTextStrings[numSaveLoadTexts] = { LOAD_DIALOG_NAME };
- const char *loadBtnStrings[numSaveLoadBtns] = { LOAD_DIALOG_BUTTON1, LOAD_DIALOG_BUTTON2 };
+ const char *loadTextStrings[kNumSaveLoadTexts] = { LOAD_DIALOG_NAME };
+ const char *loadBtnStrings[kNumSaveLoadBtns] = { LOAD_DIALOG_BUTTON1, LOAD_DIALOG_BUTTON2 };
const char **textStrings[] = { saveTextStrings, loadTextStrings };
const char **btnStrings[] = { saveBtnStrings, loadBtnStrings };
@@ -810,7 +810,7 @@ void updateAllUserControls(void);
int16 OptionsDialog(bool disableSaveResume) {
// text for dialog
- const char *btnStrings[numOptionsBtns] = {
+ const char *btnStrings[kNumOptionsBtns] = {
OPTN_DIALOG_BUTTON1,
OPTN_DIALOG_BUTTON2,
OPTN_DIALOG_BUTTON3,
@@ -819,7 +819,7 @@ int16 OptionsDialog(bool disableSaveResume) {
};
- const char *textStrings[numOptionsTexts] = {
+ const char *textStrings[kNumOptionsTexts] = {
OPTN_DIALOG_NAME,
OPTN_DIALOG_SLIDE1,
OPTN_DIALOG_SLIDE2,
@@ -932,7 +932,7 @@ int16 OptionsDialog(bool disableSaveResume) {
new CPlaqText(*win, optionsTextRects[0],
textStrings[0], &Plate18Font, 0, pal, 0, nullptr);
- for (int i = 1; i < numOptionsTexts; i++) {
+ for (int i = 1; i < kNumOptionsTexts; i++) {
new CPlaqText(*win, optionsTextRects[i], textStrings[i], &SmallFont, textPosLeft, pal, 0, nullptr);
}
Commit: 3cd0cc90d2336a32c13634c0560846b6f7899321
https://github.com/scummvm/scummvm/commit/3cd0cc90d2336a32c13634c0560846b6f7899321
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:37+02:00
Commit Message:
SAGA2: Cleanup noise.cpp
Changed paths:
engines/saga2/noise.cpp
diff --git a/engines/saga2/noise.cpp b/engines/saga2/noise.cpp
index 60c4208805..c355826e94 100644
--- a/engines/saga2/noise.cpp
+++ b/engines/saga2/noise.cpp
@@ -96,18 +96,6 @@ hResContext *voiceRes,
*longRes;
-//-----------------------------------------------------------------------
-// debugging studff
-
-#if DEBUG
-char hellBuffer[256];
-int audioVerbosity = 1;
-bool debugStatuses;
-bool debugResource;
-bool debugAudioThemes;
-bool randomAudioTesting;
-#endif
-
/* ===================================================================== *
Locals
* ===================================================================== */
@@ -310,13 +298,6 @@ void startAudio(void) {
clickData[2] = (uint8 *) LoadResource(soundRes, MKTAG('C', 'L', 'K', 2), "Click 2");
}
-#if DEBUG
- if (debugStatuses) {
- WriteStatusF(5, audio->statusMessage());
- audio->setVerbosity(3);
- }
-#endif
-
if (disMusic)
audio->disable(volMusic);
if (disVoice)
@@ -335,13 +316,6 @@ void audioEventLoop(void) {
if (audio->playFlag())
audio->playMe();
-#if DEBUG
- if (randomAudioTesting)
- audioStressTest();
- if (debugStatuses)
- WriteStatusF(5, audio->statusMessage());
-#endif
-
audioEnvironmentCheck();
}
@@ -358,15 +332,6 @@ void makeGruntSound(uint8 cs, Location l) {
}
-//-----------------------------------------------------------------------
-// debugging crap
-
-char dummy[256];
-#if DEBUG
-void DebMsg(const char *fmt, ...);
-char msg[80];
-#endif
-
//-----------------------------------------------------------------------
// check for higher quality MIDI card
@@ -440,12 +405,15 @@ void resumeAudio(void) {
// UI volume change hook
void volumeChanged(void) {
-#if ZERO_VOLUME_DISABLES
- if (audio->getVolume(volLoops)) resumeLoops();
- else suspendLoops();
- if (audio->getVolume(volMusic)) resumeMusic();
- else suspendMusic();
-#endif
+ if (audio->getVolume(volLoops))
+ resumeLoops();
+ else
+ suspendLoops();
+
+ if (audio->getVolume(volMusic))
+ resumeMusic();
+ else
+ suspendMusic();
}
/* ===================================================================== *
@@ -467,64 +435,50 @@ Point32 translateLocation(Location playAt) {
// MIDI playback
void playMusic(uint32 s) {
-#ifndef AUDIO_DISABLED
currentMidi = s;
if (hResCheckResID(musicRes, s)) {
-#ifdef _WIN32
- audio->stopMusic();
-#endif
audio->queueMusic(s, musicDec, 0);
} else
audio->stopMusic();
-
-#endif
}
//-----------------------------------------------------------------------
// in memory sfx
void playMemSound(uint32 s) {
-#ifndef AUDIO_DISABLED
if (bufCheckResID(NULL, s))
audio->queueSound(s, memDec, 1, Here);
-#endif
}
//-----------------------------------------------------------------------
// on disk sfx
void playSound(uint32 s) {
-#ifndef AUDIO_DISABLED
if (hResCheckResID(soundRes, s))
audio->queueSound(s, soundDec, 1, Here);
-#endif
}
//-----------------------------------------------------------------------
// on disk sfx (x2 buffered)
void playLongSound(uint32 s) {
-#ifndef AUDIO_DISABLED
if (hResCheckResID(longRes, s))
audio->queueVoice(s, longSoundDec);
else
audio->stopVoice();
-#endif
}
//-----------------------------------------------------------------------
// on disk voice (x2 buffered)
void playVoice(uint32 s) {
-#ifndef AUDIO_DISABLED
if (hResCheckResID(voiceRes, s)) {
if (s)
audio->queueVoice(s, voiceDec, Here);
else
audio->stopVoice();
}
-#endif
}
//-----------------------------------------------------------------------
@@ -532,13 +486,13 @@ void playVoice(uint32 s) {
bool sayVoice(uint32 s[]) {
bool worked = false;
-#ifndef AUDIO_DISABLED
+
if (hResCheckResID(voiceRes, s)) {
audio->queueVoice(s, voiceDec, Here);
if (audio->talking())
worked = true;
}
-#endif
+
return worked;
}
@@ -546,9 +500,8 @@ bool sayVoice(uint32 s[]) {
// main loop playback
void _playLoop(uint32 s) {
- warning("STUB: _playLoop(%d)", s);
- return;
-#ifndef AUDIO_DISABLED
+ warning("STUB: playLoop(%d)", s);
+
currentLoop = s;
if (currentLoop == audio->currentLoop())
return;
@@ -556,34 +509,27 @@ void _playLoop(uint32 s) {
audio->stopLoop();
if (hResCheckResID(loopRes, s))
audio->queueLoop(s, loopDec, 0, Here);
-#endif
}
//-----------------------------------------------------------------------
// loop playback that disables background loops
void playLoop(uint32 s) {
-#ifndef AUDIO_DISABLED
if (s) {
//disableBGLoop(s);
} else {
_playLoop(s);
//enableBGLoop();
}
-#endif
}
-
-
//-----------------------------------------------------------------------
// attenuated sound players
void playSoundAt(uint32 s, Point32 p) {
-#ifndef AUDIO_DISABLED
if (hResCheckResID(soundRes, s))
audio->queueSound(s, soundDec, 1, p);
-#endif
}
void playSoundAt(uint32 s, Location playAt) {
@@ -597,13 +543,13 @@ void playSoundAt(uint32 s, Location playAt) {
bool sayVoiceAt(uint32 s[], Point32 p) {
bool worked = false;
-#ifndef AUDIO_DISABLED
+
if (hResCheckResID(voiceRes, s)) {
audio->queueVoice(s, voiceDec, p);
if (audio->talking())
worked = true;
}
-#endif
+
return worked;
}
@@ -618,12 +564,10 @@ bool sayVoiceAt(uint32 s[], Location playAt) {
// loop playback w/ attenuation
void playLoopAt(uint32 s, Point32 loc) {
-#ifndef AUDIO_DISABLED
if (hResCheckResID(loopRes, s))
audio->queueLoop(s, loopDec, 0, loc);
else
audio->stopLoop();
-#endif
}
void addAuxTheme(Location loc, soundSegment lid);
@@ -631,13 +575,11 @@ void killAuxTheme(soundSegment lid);
void killAllAuxThemes(void);
void playLoopAt(uint32 s, Location playAt) {
-#ifndef AUDIO_DISABLED
if (s) {
addAuxTheme(playAt, s);
} else {
killAllAuxThemes();
}
-#endif
}
//-----------------------------------------------------------------------
@@ -726,6 +668,7 @@ void PlayLoopAt(char IDstr[], Location l) {
}
void PlayMusic(char IDstr[]) {
+ warning("STUB: PlayMusic()");
if (IDstr == NULL)
playMusic(0);
else
Commit: 389990009e7d561975d9d4f18871c179100475fc
https://github.com/scummvm/scummvm/commit/389990009e7d561975d9d4f18871c179100475fc
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:37+02:00
Commit Message:
SAGA2: Initial work on sound subsystem
Changed paths:
engines/saga2/audio.cpp
engines/saga2/loadsave.cpp
engines/saga2/rect.h
diff --git a/engines/saga2/audio.cpp b/engines/saga2/audio.cpp
index 761510b06d..673578d4cd 100644
--- a/engines/saga2/audio.cpp
+++ b/engines/saga2/audio.cpp
@@ -39,12 +39,16 @@
namespace Saga2 {
+audioInterface *audio;
+
void initAudio() {
warning("STUB: initAudio()");
+ audio = new audioInterface();
}
void cleanupAudio() {
warning("STUB: cleanupAudio()");
+ delete audio;
}
void *audioAlloc(size_t s, const char desc[]) {
@@ -52,14 +56,11 @@ void *audioAlloc(size_t s, const char desc[]) {
return malloc(s);
}
-void audioFree(void *mem)
-{
+void audioFree(void *mem) {
warning("STUB: audioFree()");
//delete mem;
}
-audioInterface *audio;
-
audioInterface::audioInterface(const char *driver_path, const char *undriver_path) {
warning("STUB: audioInteraface::audioInterface()");
}
@@ -102,7 +103,7 @@ bool audioInterface::goodMIDICard(void) {
}
void audioInterface::queueSound(soundSegment s, decoderSet *, int16 loopFactor, sampleLocation where) {
- warning("STUB: audioInterface::queueSound()");
+ warning("STUB: audioInterface::queueSound(%d, @%d,%d)", s, where.x, where.y);
}
void audioInterface::queueLoop(soundSegment s, decoderSet *sDec, int16 loopFactor, sampleLocation where) {
warning("STUB: audioInterface::queueLoop()");
@@ -111,7 +112,7 @@ void audioInterface::stopLoop(void) {
warning("STUB: audioInterface::stopLoop()");
}
void audioInterface::setLoopPosition(sampleLocation newLoc) {
- warning("STUB: audioInterface::setLoopPosition()");
+ warning("STUB: audioInterface::setLoopPosition(%d,%d)", newLoc.x, newLoc.y);
}
void audioInterface::queueVoice(soundSegment s, decoderSet *, sampleLocation where) {
diff --git a/engines/saga2/loadsave.cpp b/engines/saga2/loadsave.cpp
index 82bc776a03..3b37c6d46f 100644
--- a/engines/saga2/loadsave.cpp
+++ b/engines/saga2/loadsave.cpp
@@ -93,6 +93,7 @@ void initGameState(void) {
initGlobals();
initTimer();
+ initAudio();
initCalender();
initWorlds();
initActors();
@@ -482,6 +483,7 @@ void cleanupGameState(void) {
cleanupObjects();
cleanupActors();
cleanupWorlds();
+ cleanupAudio();
cleanupTimer();
cleanupGlobals();
}
diff --git a/engines/saga2/rect.h b/engines/saga2/rect.h
index cc3b30da5a..7784d70493 100644
--- a/engines/saga2/rect.h
+++ b/engines/saga2/rect.h
@@ -122,6 +122,9 @@ public:
y <<= (int16)a;
}
+ void debugPrint(int level = 0, const char *msg = "Point32:") {
+ debug(level, "%s %d,%d", msg, x, y);
+ }
// Point16 functions
};
@@ -235,6 +238,10 @@ public:
x <<= (int32)a;
y <<= (int32)a;
}
+
+ void debugPrint(int level = 0, const char *msg = "Point32:") {
+ debug(level, "%s %d,%d", msg, x, y);
+ }
};
typedef Point32 Vector32; // vectors are treated as points
Commit: b72d66a393865468c529fbcbf9afe248289b8f1b
https://github.com/scummvm/scummvm/commit/b72d66a393865468c529fbcbf9afe248289b8f1b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:37+02:00
Commit Message:
SAGA2: Initial code for voice playback
Changed paths:
A engines/saga2/shorten.cpp
A engines/saga2/shorten.h
engines/saga2/audio.cpp
engines/saga2/hresmgr.cpp
engines/saga2/module.mk
engines/saga2/noise.cpp
diff --git a/engines/saga2/audio.cpp b/engines/saga2/audio.cpp
index 673578d4cd..4224e95b68 100644
--- a/engines/saga2/audio.cpp
+++ b/engines/saga2/audio.cpp
@@ -135,7 +135,7 @@ bool audioInterface::saying(soundSegment s) {
bool audioInterface::active(void) {
warning("STUB: audioInterface::active()");
- return false;
+ return true;
}
void audioInterface::enable(volumeTarget i, bool onOff) {
warning("STUB: audioInterface::enable()");
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index 4f7d5ccf5b..f8ec74fb63 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -85,7 +85,7 @@ hResContext::hResContext(hResContext *sire, hResID id, const char desc[]) {
_parent = sire;
- debugC(3, kDebugResources, "Creating context %x (%s)", id, tag2str(id));
+ debugC(3, kDebugResources, "Creating context %x (%s), %s", id, tag2str(id), desc);
if ((entry = _parent->findEntry(id)) == nullptr) {
debugC(3, kDebugResources, "Could not create context");
return;
@@ -197,6 +197,7 @@ bool hResContext::seek(hResID id) {
// resource _data is actually a path name
_handle = openExternal(_res->_handle);
+
return (_handle != nullptr);
}
diff --git a/engines/saga2/module.mk b/engines/saga2/module.mk
index c15a9685b4..cd89c17b97 100644
--- a/engines/saga2/module.mk
+++ b/engines/saga2/module.mk
@@ -62,6 +62,7 @@ MODULE_OBJS := \
sagafunc.o \
savefile.o \
sensor.o \
+ shorten.o \
speech.o \
spelcast.o \
speldata.o \
diff --git a/engines/saga2/noise.cpp b/engines/saga2/noise.cpp
index c355826e94..62779a7460 100644
--- a/engines/saga2/noise.cpp
+++ b/engines/saga2/noise.cpp
@@ -25,6 +25,7 @@
*/
#include "common/config-manager.h"
+#include "audio/mixer.h"
#include "saga2/saga2.h"
#include "saga2/fta.h"
@@ -39,6 +40,7 @@
#include "saga2/audqueue.h"
#include "saga2/audiosys.h"
#include "saga2/hresmgr.h"
+#include "saga2/shorten.h"
namespace Saga2 {
@@ -220,8 +222,6 @@ void startAudio(void) {
(uint32) 400000 // sound buffer size
);
- return;
-
bool disVoice = true, disMusic = true, disSound = true, disLoops = true;
if (audio->active()) {
@@ -463,6 +463,7 @@ void playSound(uint32 s) {
// on disk sfx (x2 buffered)
void playLongSound(uint32 s) {
+ warning("playLongSound(%d)", s);
if (hResCheckResID(longRes, s))
audio->queueVoice(s, longSoundDec);
else
@@ -473,6 +474,8 @@ void playLongSound(uint32 s) {
// on disk voice (x2 buffered)
void playVoice(uint32 s) {
+ warning("playVoice(%d)", s);
+
if (hResCheckResID(voiceRes, s)) {
if (s)
audio->queueVoice(s, voiceDec, Here);
@@ -485,6 +488,8 @@ void playVoice(uint32 s) {
// supplemental interface for speech
bool sayVoice(uint32 s[]) {
+ warning("sayVoice(%d)", s[0]);
+
bool worked = false;
if (hResCheckResID(voiceRes, s)) {
@@ -500,15 +505,21 @@ bool sayVoice(uint32 s[]) {
// main loop playback
void _playLoop(uint32 s) {
- warning("STUB: playLoop(%d)", s);
+ warning("STUB: _playLoop(%d)", s);
currentLoop = s;
- if (currentLoop == audio->currentLoop())
+ if (currentLoop == audio->currentLoop() && 0)
return;
audio->stopLoop();
- if (hResCheckResID(loopRes, s))
- audio->queueLoop(s, loopDec, 0, Here);
+
+ byte *data = loopRes->loadResource(s, "loop sound");
+ uint32 size = loopRes->getSize(s, "loop sound");
+
+ warning("Size: %d", size);
+
+ Common::hexdump(data, MIN(size, 256U));
+ audio->queueLoop(s, loopDec, 0, Here);
}
//-----------------------------------------------------------------------
@@ -541,16 +552,18 @@ void playSoundAt(uint32 s, Location playAt) {
//-----------------------------------------------------------------------
// voice playback w/ attenuation
+Audio::SoundHandle _speechSoundHandle;
+
bool sayVoiceAt(uint32 s[], Point32 p) {
- bool worked = false;
+ warning("sayVoiceAt(%s, %d,%d)", tag2str(s[0]), p.x, p.y);
- if (hResCheckResID(voiceRes, s)) {
- audio->queueVoice(s, voiceDec, p);
- if (audio->talking())
- worked = true;
- }
+ Common::SeekableReadStream *stream = loadResourceToStream(voiceRes, s[0], "voice data");
- return worked;
+ Audio::AudioStream *aud = makeShortenStream(*stream);
+
+ g_system->getMixer()->playStream(Audio::Mixer::kSpeechSoundType, &_speechSoundHandle, aud);
+
+ return true;
}
bool sayVoiceAt(uint32 s[], Location playAt) {
diff --git a/engines/saga2/shorten.cpp b/engines/saga2/shorten.cpp
new file mode 100644
index 0000000000..a6be9f7f75
--- /dev/null
+++ b/engines/saga2/shorten.cpp
@@ -0,0 +1,564 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+#include "common/stream.h"
+#include "common/textconsole.h"
+#include "audio/audiostream.h"
+
+#include "saga/shorten.h"
+
+// Based on etree's Shorten tool, version 3.6.1
+// http://etree.org/shnutils/shorten/
+// and
+// https://github.com/soiaf/Java-Shorten-decoder
+
+// FIXME: This doesn't work yet correctly
+
+#include "common/util.h"
+
+#include "audio/decoders/raw.h"
+
+namespace Saga2 {
+
+#define MASKTABSIZE 33
+#define MAX_SUPPORTED_VERSION 3
+#define DEFAULT_BLOCK_SIZE 256
+
+enum kShortenTypes {
+ kTypeAU1 = 0, // lossless ulaw
+ kTypeS8 = 1, // signed 8 bit
+ kTypeU8 = 2, // unsigned 8 bit
+ kTypeS16HL = 3, // signed 16 bit shorts: high-low
+ kTypeU16HL = 4, // unsigned 16 bit shorts: high-low
+ kTypeS16LH = 5, // signed 16 bit shorts: low-high
+ kTypeU16LH = 6, // unsigned 16 bit shorts: low-high
+ kTypeULaw = 7, // lossy ulaw
+ kTypeAU2 = 8, // new ulaw with zero mapping
+ kTypeAU3 = 9, // lossless alaw
+ kTypeALaw = 10, // lossy alaw
+ kTypeWAV = 11, // WAV
+ kTypeAIFF = 12, // AIFF
+ kTypeEOF = 13,
+ kTypeGenericULaw = 128,
+ kTypeGenericALaw = 129
+};
+
+enum kShortenCommands {
+ kCmdDiff0 = 0,
+ kCmdDiff1 = 1,
+ kCmdDiff2 = 2,
+ kCmdDiff3 = 3,
+ kCmdQuit = 4,
+ kCmdBlockSize = 5,
+ kCmdBitShift = 6,
+ kCmdQLPC = 7,
+ kCmdZero = 8,
+ kCmdVerbatim = 9
+};
+
+#ifndef M_LN2
+#define M_LN2 0.69314718055994530942
+#endif
+
+// ---------------------------------------------------------------------------
+
+class ShortenGolombReader {
+public:
+ ShortenGolombReader(Common::ReadStream *stream, int version);
+ ~ShortenGolombReader() {}
+ uint32 getUint32(uint32 numBits); // UINT_GET
+ int32 getURice(uint32 numBits); // uvar_get
+ int32 getSRice(uint32 numBits); // var_get
+private:
+ int _version;
+ uint32 _nbitget;
+ uint32 _buf;
+ uint32 _masktab[MASKTABSIZE];
+ Common::ReadStream *_stream;
+};
+
+ShortenGolombReader::ShortenGolombReader(Common::ReadStream *stream, int version) {
+ _stream = stream;
+ _version = version;
+ uint32 val = 0;
+ _masktab[0] = 0;
+ _nbitget = 0;
+ _buf = 0;
+
+ for (int i = 1; i < MASKTABSIZE; i++) {
+ val <<= 1;
+ val |= 1;
+ _masktab[i] = val;
+ }
+}
+
+int32 ShortenGolombReader::getURice(uint32 numBits) {
+ int32 result = 0;
+
+ if (!_nbitget) {
+ _buf = _stream->readUint32BE();
+ _nbitget = 32;
+ }
+
+ for (result = 0; !(_buf & (1L << --_nbitget)); result++) {
+ if (!_nbitget) {
+ _buf = _stream->readUint32BE();
+ _nbitget = 32;
+ }
+ }
+
+ while (numBits != 0) {
+ if (_nbitget >= numBits) {
+ result = (result << numBits) | ((_buf >> (_nbitget - numBits)) & _masktab[numBits]);
+ _nbitget -= numBits;
+ numBits = 0;
+ } else {
+ result = (result << _nbitget) | (_buf & _masktab[_nbitget]);
+ _buf = _stream->readUint32BE();
+ numBits -= _nbitget;
+ _nbitget = 32;
+ }
+ }
+
+ return result;
+}
+
+int32 ShortenGolombReader::getSRice(uint32 numBits) {
+ uint32 uvar = (uint32) getURice(numBits + 1);
+ return (uvar & 1) ? (int32) ~(uvar >> 1) : (int32) (uvar >> 1);
+}
+
+uint32 ShortenGolombReader::getUint32(uint32 numBits) {
+ return (_version == 0) ? (uint32)getURice(numBits) : (uint32)getURice(getURice(2));
+}
+
+// ---------------------------------------------------------------------------
+
+byte *loadShortenFromStream(Common::ReadStream &stream, int &size, int &rate, byte &flags) {
+ int32 *buffer[2], *offset[2]; // up to 2 channels
+ int32 *oldValues[2];
+ byte *unpackedBuffer = 0;
+ byte *pBuf = unpackedBuffer;
+ int prevSize = 0;
+ int32 *lpc = 0;
+
+ ShortenGolombReader *gReader;
+ uint32 i, j, version, mean, type, channels, blockSize;
+ uint32 maxLPC = 0, lpcqOffset = 0;
+ int32 bitShift = 0, wrap = 0;
+ flags = 0;
+ size = 0;
+
+ // Read header
+ byte magic[4];
+ stream.read(magic, 4);
+ if (memcmp(magic, "ajkg", 4) != 0) {
+ warning("loadShortenFromStream: No 'ajkg' header");
+ return NULL;
+ }
+
+ version = stream.readByte();
+
+ if (version > MAX_SUPPORTED_VERSION) {
+ warning("loadShortenFromStream: Can't decode version %d, maximum supported version is %d", version, MAX_SUPPORTED_VERSION);
+ return NULL;
+ }
+
+ mean = (version < 2) ? 0 : 4;
+
+ gReader = new ShortenGolombReader(&stream, version);
+
+ // Get file type
+ type = gReader->getUint32(4);
+
+ switch (type) {
+ case kTypeS8:
+ mean = 0;
+ break;
+ case kTypeU8:
+ flags |= Audio::FLAG_UNSIGNED;
+ mean = 0x80;
+ break;
+ case kTypeS16LH:
+ flags |= Audio::FLAG_LITTLE_ENDIAN;
+ // fallthrough
+ case kTypeS16HL:
+ flags |= Audio::FLAG_16BITS;
+ mean = 0;
+ break;
+ case kTypeU16LH:
+ flags |= Audio::FLAG_LITTLE_ENDIAN;
+ // fallthrough
+ case kTypeU16HL:
+ flags |= Audio::FLAG_16BITS;
+ flags |= Audio::FLAG_UNSIGNED;
+ mean = 0x8000;
+ break;
+ case kTypeWAV:
+ // TODO: Perhaps implement this if we find WAV Shorten encoded files
+ warning("loadShortenFromStream: Type WAV is not supported");
+ delete gReader;
+ return NULL;
+ case kTypeAIFF:
+ // TODO: Perhaps implement this if we find AIFF Shorten encoded files
+ warning("loadShortenFromStream: Type AIFF is not supported");
+ delete gReader;
+ return NULL;
+ case kTypeAU1:
+ case kTypeAU2:
+ case kTypeAU3:
+ case kTypeULaw:
+ case kTypeALaw:
+ case kTypeEOF:
+ case kTypeGenericULaw:
+ case kTypeGenericALaw:
+ default:
+ warning("loadShortenFromStream: Type %d is not supported", type);
+ delete gReader;
+ return NULL;
+ }
+
+ // Get channels
+ channels = gReader->getUint32(0);
+ if (channels != 1 && channels != 2) {
+ warning("loadShortenFromStream: Only 1 or 2 channels are supported, stream contains %d channels", channels);
+ delete gReader;
+ return NULL;
+ }
+
+ // Get block size
+ if (version > 0) {
+ blockSize = gReader->getUint32((int)(log((double) DEFAULT_BLOCK_SIZE) / M_LN2));
+ maxLPC = gReader->getUint32(2);
+ mean = gReader->getUint32(0);
+ uint32 skipBytes = gReader->getUint32(1);
+ if (skipBytes > 0) {
+ prevSize = size;
+ size += skipBytes;
+ unpackedBuffer = (byte *) realloc(unpackedBuffer, size);
+ pBuf = unpackedBuffer + prevSize;
+ for (i = 0; i < skipBytes; i++) {
+ *pBuf++ = gReader->getUint32(7) & 0xFF;
+ }
+ }
+ } else {
+ blockSize = DEFAULT_BLOCK_SIZE;
+ }
+
+ wrap = MAX<uint32>(3, maxLPC);
+
+ // Initialize buffers
+ for (i = 0; i < channels; i++) {
+ buffer[i] = (int32 *)malloc((blockSize + wrap) * 4);
+ offset[i] = (int32 *)malloc((MAX<uint32>(1, mean)) * 4);
+ oldValues[i] = (int32 *)malloc(64 * 4);
+ memset(buffer[i], 0, (blockSize + wrap) * 4);
+ memset(offset[i], 0, (MAX<uint32>(1, mean)) * 4);
+ memset(oldValues[i], 0, 64 * 4);
+ }
+
+ if (maxLPC > 0)
+ lpc = (int32 *) malloc(maxLPC * 4);
+
+ if (version > 1)
+ lpcqOffset = 1 << 5;
+
+ // Init offset
+ int32 offsetMean = 0;
+ uint32 blocks = MAX<int>(1, mean);
+
+ if (type == kTypeU8)
+ offsetMean = 0x80;
+ else if (type == kTypeU16HL || type == kTypeU16LH)
+ offsetMean = 0x8000;
+
+ for (uint32 channel = 0; channel < channels; channel++)
+ for (uint32 block = 0; block < blocks; block++)
+ offset[channel][block] = offsetMean;
+
+
+ uint32 curChannel = 0, cmd = 0;
+
+ // Parse Shorten commands
+ while (true) {
+ cmd = gReader->getURice(2);
+
+ if (cmd == kCmdQuit)
+ break;
+
+ switch (cmd) {
+ case kCmdZero:
+ case kCmdDiff0:
+ case kCmdDiff1:
+ case kCmdDiff2:
+ case kCmdDiff3:
+ case kCmdQLPC:
+ {
+ int32 channelOffset = 0, energy = 0;
+ uint32 lpcNum = 0;
+
+ if (cmd != kCmdZero) {
+ energy = gReader->getURice(3);
+ // hack for version 0
+ if (version == 0)
+ energy--;
+ }
+
+ // Find mean offset (code duplicated below)
+ if (mean == 0) {
+ channelOffset = offset[curChannel][0];
+ } else {
+ int32 sum = (version < 2) ? 0 : mean / 2;
+ for (i = 0; i < mean; i++)
+ sum += offset[curChannel][i];
+
+ channelOffset = sum / mean;
+
+ if (version >= 2 && bitShift > 0)
+ channelOffset = (channelOffset >> (bitShift - 1)) >> 1;
+ }
+
+ switch (cmd) {
+ case kCmdZero:
+ for (i = 0; i < blockSize; i++)
+ buffer[curChannel][i] = 0;
+ break;
+ case kCmdDiff0:
+ for (i = 0; i < blockSize; i++)
+ buffer[curChannel][i] = gReader->getSRice(energy) + channelOffset;
+ break;
+ case kCmdDiff1:
+ for (i = 0; i < blockSize; i++) {
+ if (i == 0)
+ buffer[curChannel][i] = gReader->getSRice(energy) + oldValues[curChannel][0];
+ else
+ buffer[curChannel][i] = gReader->getSRice(energy) + buffer[curChannel][i - 1];
+ }
+ break;
+ case kCmdDiff2:
+ for (i = 0; i < blockSize; i++) {
+ if (i == 0)
+ buffer[curChannel][i] = gReader->getSRice(energy) + 2 * oldValues[curChannel][0] - oldValues[curChannel][1];
+ else if (i == 1)
+ buffer[curChannel][i] = gReader->getSRice(energy) + 2 * buffer[curChannel][0] - oldValues[curChannel][0];
+ else
+ buffer[curChannel][i] = gReader->getSRice(energy) + 2 * buffer[curChannel][i - 1] - buffer[curChannel][i - 2];
+ }
+ break;
+ case kCmdDiff3:
+ for (i = 0; i < blockSize; i++) {
+ if (i == 0)
+ buffer[curChannel][i] = gReader->getSRice(energy) + 3 * (oldValues[curChannel][0] - oldValues[curChannel][1]) + oldValues[curChannel][2];
+ else if (i == 1)
+ buffer[curChannel][i] = gReader->getSRice(energy) + 3 * (buffer[curChannel][0] - oldValues[curChannel][0]) + oldValues[curChannel][1];
+ else if (i == 2)
+ buffer[curChannel][i] = gReader->getSRice(energy) + 3 * (buffer[curChannel][1] - buffer[curChannel][0]) + oldValues[curChannel][0];
+ else
+ buffer[curChannel][i] = gReader->getSRice(energy) + 3 * (buffer[curChannel][i - 1] - buffer[curChannel][i - 2]) + buffer[curChannel][i - 3];
+ }
+ break;
+ case kCmdQLPC:
+ lpcNum = gReader->getURice(2);
+
+ // Safeguard: if maxLPC < lpcNum, realloc the lpc buffer
+ if (maxLPC < lpcNum) {
+ warning("Safeguard: maxLPC < lpcNum (should never happen)");
+ maxLPC = lpcNum;
+ int32 *tmp = (int32 *) realloc(lpc, maxLPC * 4);
+ if ((tmp != NULL) || (maxLPC == 0)) {
+ lpc = tmp;
+ } else {
+ error("loadShortenFromStream(): Error while reallocating memory");
+ }
+ }
+
+ for (i = 0; i < lpcNum; i++)
+ lpc[i] = gReader->getSRice(5);
+
+ for (i = 0; i < lpcNum; i++)
+ buffer[curChannel][i - lpcNum] -= channelOffset;
+
+ for (i = 0; i < blockSize; i++) {
+ int32 sum = lpcqOffset;
+ for (j = 0; j < lpcNum; j++) {
+ // FIXME: The original code did an invalid memory access here
+ // (if i and j are 0, the array index requested is -1)
+ // I've removed those invalid writes, since they happen all the time (even when curChannel is 0)
+ if (i <= j) // ignore invalid table/memory access
+ continue;
+ sum += lpc[j] * buffer[curChannel][i - j - 1];
+ }
+ buffer[curChannel][i] = gReader->getSRice(energy) + (sum >> 5);
+ }
+
+ if (channelOffset > 0)
+ for (i = 0; i < blockSize; i++)
+ buffer[curChannel][i] += channelOffset;
+
+ break;
+ default:
+ break;
+ }
+
+ // Store mean value, if appropriate (duplicated code from above)
+ if (mean > 0) {
+ int32 sum = (version < 2) ? 0 : blockSize / 2;
+ for (i = 0; i < blockSize; i++)
+ sum += buffer[curChannel][i];
+
+ for (i = 1; i < mean; i++)
+ offset[curChannel][i - 1] = offset[curChannel][i];
+
+ offset[curChannel][mean - 1] = sum / blockSize;
+
+ if (version >= 2 && bitShift > 0)
+ offset[curChannel][mean - 1] = offset[curChannel][mean - 1] << bitShift;
+ }
+
+
+ // Do the wrap
+ for (i = 0; i < 64; ++i)
+ oldValues[curChannel][i] = 0;
+
+ uint arrayTerminator = MIN<int>(64, blockSize);
+ for (i = 0; i < arrayTerminator; ++i)
+ oldValues[curChannel][i] = buffer[curChannel][blockSize - (i + 1)];
+
+ // Fix bitshift
+ if (bitShift > 0) {
+ for (i = 0; i < blockSize; i++)
+ buffer[curChannel][i] <<= bitShift;
+ }
+
+ if (curChannel == channels - 1) {
+ int dataSize = (flags & Audio::FLAG_16BITS) ? 2 : 1;
+ int limit = (flags & Audio::FLAG_16BITS) ? 32767 : 127;
+ limit = (flags & Audio::FLAG_UNSIGNED) ? limit * 2 + 1 : limit;
+
+ prevSize = size;
+ size += (blockSize * dataSize);
+ byte *tmp = (byte *) realloc(unpackedBuffer, size);
+ if ((tmp != NULL) || (size == 0)) {
+ unpackedBuffer = tmp;
+ } else {
+ error("loadShortenFromStream(): Error while reallocating memory");
+ }
+ pBuf = unpackedBuffer + prevSize;
+
+ if (flags & Audio::FLAG_16BITS) {
+ for (i = 0; i < blockSize; i++) {
+ for (j = 0; j < channels; j++) {
+ int16 val = (int16)(MIN<int32>(buffer[j][i], limit) & 0xFFFF);
+ // values are written in LE
+ *pBuf++ = (byte) (val & 0xFF);
+ *pBuf++ = (byte) ((val >> 8) & 0xFF);
+ }
+ }
+ } else {
+ for (i = 0; i < blockSize; i++)
+ for (j = 0; j < channels; j++)
+ *pBuf++ = (byte)(MIN<int32>(buffer[j][i], limit) & 0xFF);
+ }
+ }
+ curChannel = (curChannel + 1) % channels;
+
+ }
+ break;
+ case kCmdBlockSize:
+ blockSize = gReader->getUint32((uint32)log((double) blockSize / M_LN2));
+ break;
+ case kCmdBitShift:
+ bitShift = gReader->getURice(2);
+ break;
+ case kCmdVerbatim:
+ {
+
+ uint32 vLen = (uint32)gReader->getURice(5);
+ prevSize = size;
+ size += vLen;
+ byte *tmp = (byte *) realloc(unpackedBuffer, size);
+ if ((tmp != NULL) || (size == 0)) {
+ unpackedBuffer = tmp;
+ } else {
+ error("loadShortenFromStream(): Error while reallocating memory");
+ }
+ pBuf = unpackedBuffer + prevSize;
+
+ while (vLen--) {
+ *pBuf++ = (byte)(gReader->getURice(8) & 0xFF);
+ }
+
+ }
+ break;
+ default:
+ warning("loadShortenFromStream: Unknown command: %d", cmd);
+
+ // Cleanup
+ for (i = 0; i < channels; i++) {
+ free(buffer[i]);
+ free(offset[i]);
+ free(oldValues[i]);
+ }
+
+ if (maxLPC > 0)
+ free(lpc);
+
+ if (size > 0)
+ free(unpackedBuffer);
+
+ delete gReader;
+ return NULL;
+ break;
+ }
+ }
+
+ // Rate is always 44100Hz
+ rate = 44100;
+
+ // Cleanup
+ for (i = 0; i < channels; i++) {
+ free(buffer[i]);
+ free(offset[i]);
+ free(oldValues[i]);
+ }
+
+ if (maxLPC > 0)
+ free(lpc);
+
+ delete gReader;
+ return unpackedBuffer;
+}
+
+Audio::AudioStream *makeShortenStream(Common::SeekableReadStream &stream) {
+ int size, rate;
+ byte *data, flags;
+ data = loadShortenFromStream(stream, size, rate, flags);
+
+ if (!data)
+ return 0;
+
+ // Since we allocated our own buffer for the data, we must specify DisposeAfterUse::YES.
+ return Audio::makeRawStream(data, size, rate, flags);
+}
+
+} // End of namespace Saga2
diff --git a/engines/saga2/shorten.h b/engines/saga2/shorten.h
new file mode 100644
index 0000000000..f305964bf3
--- /dev/null
+++ b/engines/saga2/shorten.h
@@ -0,0 +1,56 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef SOUND_SHORTEN_H
+#define SOUND_SHORTEN_H
+
+#include "common/scummsys.h"
+
+namespace Audio {
+class AudioStream;
+}
+
+namespace Common {
+class ReadStream;
+}
+
+namespace Saga2 {
+
+/**
+ * Try to load a Shorten file from the given stream. Returns true if
+ * successful. In that case, the stream's seek position will be set to the
+ * start of the audio data, and size, rate and flags contain information
+ * necessary for playback.
+ */
+byte *loadShortenFromStream(Common::ReadStream &stream, int &size, int &rate, byte &flags);
+
+/**
+ * Try to load a Shorten file from the given stream and create an AudioStream
+ * from that data.
+ *
+ * This function uses loadShortenFromStream() internally.
+ */
+Audio::AudioStream *makeShortenStream(Common::SeekableReadStream &stream);
+
+} // End of namespace Saga2
+
+#endif
Commit: 1df171e36b56c61745939748dfa84810367b39a3
https://github.com/scummvm/scummvm/commit/1df171e36b56c61745939748dfa84810367b39a3
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:37+02:00
Commit Message:
SAGA2: Delete timers on list removal
Changed paths:
engines/saga2/objects.cpp
engines/saga2/timers.cpp
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 4e14227873..5bc7fb4789 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -1803,6 +1803,7 @@ bool GameObject::addTimer(TimerID id, int16 frameInterval) {
assert((*it)->getObject() == this);
if (newTimer->thisID() == (*it)->thisID()) {
+ delete *it;
timerList->_timers.erase(it);
break;
@@ -1825,6 +1826,7 @@ void GameObject::removeTimer(TimerID id) {
if ((timerList = fetchTimerList(this)) != nullptr) {
for (Common::List<Timer *>::iterator it = timerList->_timers.begin(); it != timerList->_timers.end(); ++it) {
if ((*it)->thisID() == id) {
+ delete *it;
timerList->_timers.erase(it);
if (timerList->_timers.empty())
diff --git a/engines/saga2/timers.cpp b/engines/saga2/timers.cpp
index 3cb25d1846..7ef797b83e 100644
--- a/engines/saga2/timers.cpp
+++ b/engines/saga2/timers.cpp
@@ -111,7 +111,11 @@ TimerList *fetchTimerList(GameObject *obj) {
//----------------------------------------------------------------------
// Check all active Timers
void checkTimers(void) {
- for (Common::List<Timer *>::iterator it = g_vm->_timers.begin(); it != g_vm->_timers.end(); ++it) {
+ Common::List<Timer *>::iterator nextIt;
+
+ for (Common::List<Timer *>::iterator it = g_vm->_timers.begin(); it != g_vm->_timers.end(); it = nextIt) {
+ nextIt = it;
+ nextIt++;
if ((*it)->check()) {
debugC(2, kDebugTimers, "Timer tick for %p (%s): %p (duration %d)", (void *)(*it)->getObject(), (*it)->getObject()->objName(), (void *)(*it), (*it)->getInterval());
(*it)->reset();
Commit: cf7e412b5955f7b936616d8f1eabfea2e68a2e91
https://github.com/scummvm/scummvm/commit/cf7e412b5955f7b936616d8f1eabfea2e68a2e91
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:37+02:00
Commit Message:
SAGA2: Get rid of some global constructors
Changed paths:
engines/saga2/floating.cpp
engines/saga2/floating.h
engines/saga2/uidialog.cpp
diff --git a/engines/saga2/floating.cpp b/engines/saga2/floating.cpp
index 608f7c3301..bd38e1d7af 100644
--- a/engines/saga2/floating.cpp
+++ b/engines/saga2/floating.cpp
@@ -202,6 +202,15 @@ void DecoratedWindow::update(const Rect16 &updateRect) {
updateWindowSection(r);
}
+void DecoratedWindow::update(const StaticRect &updateRect) {
+ Rect16 r = updateRect;
+
+ r.x += extent.x;
+ r.y += extent.y;
+
+ updateWindowSection(r);
+}
+
/* ===================================================================== *
BackWindow member functions
* ===================================================================== */
@@ -217,6 +226,11 @@ void BackWindow::invalidate(Rect16 *area) {
window.update(*area);
}
+void BackWindow::invalidate(const StaticRect *area) {
+ if (displayEnabled())
+ window.update(*area);
+}
+
// Return true if window floats above animated are
bool BackWindow::isBackdrop(void) {
diff --git a/engines/saga2/floating.h b/engines/saga2/floating.h
index ae7f8a2269..f10cdf60fb 100644
--- a/engines/saga2/floating.h
+++ b/engines/saga2/floating.h
@@ -233,6 +233,7 @@ public:
// Update a region of a window, and all floaters which
// might be above that window.
void update(const Rect16 &updateRect);
+ void update(const StaticRect &updateRect);
};
/* ===================================================================== *
@@ -247,6 +248,7 @@ class BackWindow : public DecoratedWindow {
public:
BackWindow(const Rect16 &, uint16, AppFunc *cmd = NULL);
void invalidate(Rect16 *area);
+ void invalidate(const StaticRect *area);
virtual bool isBackdrop(void);
};
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index d6cb9f5510..08a2561bdf 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -354,90 +354,121 @@ static const StaticRect optNightRect = {
17
};
-Rect16 optTopSliderRect(15,
- 15 + optTPHeight - 2,
- kSliderWidth,
- kImageHeight);
+static const StaticRect optTopSliderRect = {
+ 15,
+ 15 + optTPHeight - 2,
+ kSliderWidth,
+ kImageHeight
+};
-Rect16 optMidSliderRect(15,
- optTopSliderRect.y + 32 - 2,
- kSliderWidth,
- kImageHeight);
+static const StaticRect optMidSliderRect = {
+ 15,
+ (int16)(optTopSliderRect.y + 32 - 2),
+ kSliderWidth,
+ kImageHeight
+};
-Rect16 optBotSliderRect(15,
- optMidSliderRect.y + 32 - 2,
- kSliderWidth,
- kImageHeight);
+static const StaticRect optBotSliderRect = {
+ 15,
+ (int16)(optMidSliderRect.y + 32 - 2),
+ kSliderWidth,
+ kImageHeight
+};
-Rect16 optTopFaceRect(optTopSliderRect.x,
- optTopSliderRect.y,
- 28,
- kImageHeight);
+static const StaticRect optTopFaceRect = {
+ optTopSliderRect.x,
+ optTopSliderRect.y,
+ 28,
+ kImageHeight
+};
-Rect16 optMidFaceRect(optMidSliderRect.x,
- optMidSliderRect.y,
- 28,
- kImageHeight);
+static const StaticRect optMidFaceRect = {
+ optMidSliderRect.x,
+ optMidSliderRect.y,
+ 28,
+ kImageHeight
+};
-Rect16 optBotFaceRect(optBotSliderRect.x,
- optBotSliderRect.y,
- 28,
- kImageHeight);
+static const StaticRect optBotFaceRect = {
+ optBotSliderRect.x,
+ optBotSliderRect.y,
+ 28,
+ kImageHeight
+};
// texts
-Rect16 optTitleText(0,
- 0,
- optBoxXSzNS,
- optTPHeight);
-
-Rect16 optTopSlideText(16 + kSliderWidth,
- optTopSliderRect.y + 1,
- kTextPixelLen,
- 20);
-
-Rect16 optMidSlideText(16 + kSliderWidth,
- optMidSliderRect.y + 1,
- kTextPixelLen,
- 17);
-
-Rect16 optBotSlideText(16 + kSliderWidth,
- optBotSliderRect.y + 1,
- kTextPixelLen,
- 17);
-
-Rect16 optTopCheckText(optAggressRect.x + optAggressRect.width + 3,
- optAggressRect.y,
- kTextPixelLen - kSmallTextOffset,
- 17);
-
-Rect16 optMidCheckText(optWeaponRect.x + optWeaponRect.width + 3,
- optWeaponRect.y,
- kTextPixelLen - kSmallTextOffset,
- 17);
-
-Rect16 optBotCheckText(optSpeechRect.x + optSpeechRect.width + 3,
- optSpeechRect.y,
- kTextPixelLen - kSmallTextOffset,
- 17);
-
-Rect16 optTop2CheckText(optNightRect.x + optNightRect.width + 3,
- optNightRect.y,
- kTextPixelLen - kSmallTextOffset,
- 17);
+static const StaticRect optTitleText = {
+ 0,
+ 0,
+ optBoxXSzNS,
+ optTPHeight
+};
+
+static const StaticRect optTopSlideText = {
+ 16 + kSliderWidth,
+ (int16)(optTopSliderRect.y + 1),
+ kTextPixelLen,
+ 20
+};
+
+static const StaticRect optMidSlideText = {
+ 16 + kSliderWidth,
+ (int16)(optMidSliderRect.y + 1),
+ kTextPixelLen,
+ 17
+};
+
+static const StaticRect optBotSlideText = {
+ 16 + kSliderWidth,
+ (int16)(optBotSliderRect.y + 1),
+ kTextPixelLen,
+ 17
+};
+
+static const StaticRect optTopCheckText = {
+ (int16)(optAggressRect.x + optAggressRect.width + 3),
+ optAggressRect.y,
+ kTextPixelLen - kSmallTextOffset,
+ 17
+};
+
+static const StaticRect optMidCheckText = {
+ (int16)(optWeaponRect.x + optWeaponRect.width + 3),
+ optWeaponRect.y,
+ kTextPixelLen - kSmallTextOffset,
+ 17
+};
+
+static const StaticRect optBotCheckText = {
+ (int16)(optSpeechRect.x + optSpeechRect.width + 3),
+ optSpeechRect.y,
+ kTextPixelLen - kSmallTextOffset,
+ 17
+};
+
+static const StaticRect optTop2CheckText = {
+ (int16)(optNightRect.x + optNightRect.width + 3),
+ optNightRect.y,
+ kTextPixelLen - kSmallTextOffset,
+ 17
+};
// options window rect
-Rect16 optionsWindowRect = Rect16(optBoxX,
- optBoxY,
- optBoxXSize,
- optBoxYSize);
+static const StaticRect optionsWindowRect = {
+ optBoxX,
+ optBoxY,
+ optBoxXSize,
+ optBoxYSize
+};
// indirections
-Rect16 optionsPanelRects[kNumOptionsPanels] = { { optTopPanel },
+Rect16 optionsPanelRects[kNumOptionsPanels] = {
+ { optTopPanel },
{ optMidPanel },
{ optBotPanel }
};
@@ -454,7 +485,8 @@ StaticRect optionsButtonRects[] = {
{ optNightRect }
};
-Rect16 optionsTextRects[] = { { optTitleText },
+StaticRect optionsTextRects[] = {
+ { optTitleText },
{ optTopSlideText },
{ optMidSlideText },
{ optBotSlideText },
@@ -467,9 +499,8 @@ Rect16 optionsTextRects[] = { { optTitleText },
// options dialog window decorations
-WindowDecoration optionsDecorations[kNumOptionsPanels] =
-
-{ { WindowDecoration(optionsPanelRects[0], optTopPanelResID) },
+WindowDecoration optionsDecorations[kNumOptionsPanels] = {
+ { WindowDecoration(optionsPanelRects[0], optTopPanelResID) },
{ WindowDecoration(optionsPanelRects[1], optMidPanelResID) },
{ WindowDecoration(optionsPanelRects[2], optBotPanelResID) }
};
Commit: 1aad98b3bfe706949d269ec3f70d12977adc86f0
https://github.com/scummvm/scummvm/commit/1aad98b3bfe706949d269ec3f70d12977adc86f0
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:37+02:00
Commit Message:
SAGA2: Remove more global constructors
Changed paths:
engines/saga2/uidialog.cpp
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index 08a2561bdf..f2536d55d9 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -521,71 +521,87 @@ const int16 mesBoxXSize = 374,
// panels
-Rect16 messagePanel(mesBoxX,
- mesBoxY,
- mesBoxXSize,
- mesBoxYSize);
+static const StaticRect messagePanel = {
+ mesBoxX,
+ mesBoxY,
+ mesBoxXSize,
+ mesBoxYSize
+};
// buttons
-Rect16 mesCancelBtnRect(mesBoxXSzNS - (kPushButtonWidth + mesBtnOffset),
- mesBoxY - mesBtnOffset,
- kPushButtonWidth,
- kPushButtonHeight);
+static const StaticRect mesCancelBtnRect = {
+ mesBoxXSzNS - (kPushButtonWidth + mesBtnOffset),
+ mesBoxY - mesBtnOffset,
+ kPushButtonWidth,
+ kPushButtonHeight
+};
-Rect16 mesOkBtnRect(mesBtnOffset,
- mesBoxY - mesBtnOffset,
- kPushButtonWidth,
- kPushButtonHeight);
+static const StaticRect mesOkBtnRect = {
+ mesBtnOffset,
+ mesBoxY - mesBtnOffset,
+ kPushButtonWidth,
+ kPushButtonHeight
+};
-Rect16 mesBtn3Rect(mesBoxXSzNS / 2 - kPushButtonWidth / 2,
- mesBoxY - mesBtnOffset,
- kPushButtonWidth,
- kPushButtonHeight);
+static const StaticRect mesBtn3Rect = {
+ mesBoxXSzNS / 2 - kPushButtonWidth / 2,
+ mesBoxY - mesBtnOffset,
+ kPushButtonWidth,
+ kPushButtonHeight
+};
// texts
-Rect16 mesTitleRect(0,
- 0,
- mesBoxXSzNS,
- 47);
+static const StaticRect mesTitleRect = {
+ 0,
+ 0,
+ mesBoxXSzNS,
+ 47
+};
-Rect16 messageRect(0,
- 0,
- mesBoxXSzNS,
- mesBoxYSize);
+static const StaticRect messageRect = {
+ 0,
+ 0,
+ mesBoxXSzNS,
+ mesBoxYSize
+};
-Rect16 messageTextRects[kNumMessageTexts] = { { mesTitleRect },
+StaticRect messageTextRects[kNumMessageTexts] = {
+ { mesTitleRect },
{ messageRect }
};
-Rect16 messageButtonRects[kNumMessageBtns] = { { mesOkBtnRect },
+StaticRect messageButtonRects[kNumMessageBtns] = {
+ { mesOkBtnRect },
{ mesCancelBtnRect },
- { mesBtn3Rect }
+ { mesBtn3Rect }
};
// options window rect
-Rect16 messageWindowRect = Rect16(mesBoxX,
- mesBoxY,
- mesBoxXSize,
- mesBoxYSize);
+static const StaticRect messageWindowRect = {
+ mesBoxX,
+ mesBoxY,
+ mesBoxXSize,
+ mesBoxYSize
+};
// message dialog window decorations
-WindowDecoration messageDecorations[kNumMessagePanels] =
-
-{ { WindowDecoration(messagePanel, mesPanelResID) } };
+WindowDecoration messageDecorations[kNumMessagePanels] = {
+ { WindowDecoration(messagePanel, mesPanelResID) }
+};
// pointer to the auto aggression button
Commit: c290115f741f5fd164b830f089d3abb453eaa402
https://github.com/scummvm/scummvm/commit/c290115f741f5fd164b830f089d3abb453eaa402
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:38+02:00
Commit Message:
SAGA2: Move some uidialog.cpp constants to idtypes.h
Changed paths:
engines/saga2/idtypes.h
engines/saga2/uidialog.cpp
diff --git a/engines/saga2/idtypes.h b/engines/saga2/idtypes.h
index 8832652985..ac895a1711 100644
--- a/engines/saga2/idtypes.h
+++ b/engines/saga2/idtypes.h
@@ -358,6 +358,76 @@ enum {
kMaxJumpStep = 64 // highest jump character likes
};
+
+// Save/Load dialog metrics
+
+enum {
+ kNumSaveLoadPanels = 3,
+ kNumSaveLoadBtns = 4,
+ kNumSaveLoadTexts = 1,
+
+ kSLDBoxXSize = 374,
+ kSLDBoxXSzNS = 366,
+ kSLDBoxYSize = 223,
+ kSLDBoxX = (640 - kSLDBoxXSize) / 2,
+ kSLDBoxY = (480 - kSLDBoxYSize) / 3,
+
+ kSLTPHeight = 38,
+ kSLMDHeight = 122,
+ kSLBTHeight = 63,
+ kSLTPWidth = 374,
+ kSLMDWidth = 374,
+ kSLBTWidth = 374
+};
+
+// Options dialog metrics
+enum {
+ kNumOptionsPanels = 3,
+ kNumOptionsBtns = 9,
+ kNumOptionsTexts = 8,
+
+ kOptBoxXSize = 487,
+ kOptBoxXSzNS = 479,
+ kOptBoxYSize = 230,
+ kOptBoxX = (640 - kOptBoxXSize) / 2,
+ kOptBoxY = (480 - kOptBoxYSize) / 3,
+
+ kOptTPHeight = 39,
+ kOptMDHeight = 90,
+ kOptBTHeight = 101,
+ kOptTPWidth = 487,
+ kOptMDWidth = 487,
+ kOptBTWidth = 487
+};
+
+// buttons
+enum {
+ kButtonSpace = 3,
+ kButtonYOffset = kOptTPHeight + 7,
+ kPushButtonWidth = 121,
+ kPushButtonHeight = 30,
+
+ kSliderWidth = 168,
+ kImageHeight = 17,
+
+ kTextPixelLen = 175,
+ kSmallTextOffset = 80
+};
+
+// Message Dialog Metrics
+enum {
+ kNumMessagePanels = 1,
+ kNumMessageBtns = 3,
+ kNumMessageTexts = 2,
+ kMesBtnOffset = 14,
+
+ kMesBoxXSize = 374,
+ kMesBoxXSzNS = 368,
+ kMesBoxYSize = 146,
+ kMesBoxX = (640 - kMesBoxXSize) / 2,
+ kMesBoxY = (480 - kMesBoxYSize) / 3
+};
+
} // end of namespace Saga2
#endif
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index f2536d55d9..3a134fe8c6 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -134,52 +134,32 @@ enum messageImageResIDs {
mesPanelResID = 0
};
-// Save/Load dialog metrics
-
-const int kNumSaveLoadPanels = 3;
-const int kNumSaveLoadBtns = 4;
-const int kNumSaveLoadTexts = 1;
-
-const int16 SLDBoxXSize = 374,
- SLDBoxXSzNS = 366,
- SLDBoxYSize = 223,
- SLDBoxX = (640 - SLDBoxXSize) / 2,
- SLDBoxY = (480 - SLDBoxYSize) / 3;
-
-const int16 SLTPHeight = 38;
-const int16 SLMDHeight = 122;
-const int16 SLBTHeight = 63;
-const int16 SLTPWidth = 374;
-const int16 SLMDWidth = 374;
-const int16 SLBTWidth = 374;
-
-
// panels
-Rect16 SLTopPanel(SLDBoxX,
- SLDBoxY,
- SLTPWidth,
- SLTPHeight);
+Rect16 SLTopPanel(kSLDBoxX,
+ kSLDBoxY,
+ kSLTPWidth,
+ kSLTPHeight);
-Rect16 SLMidPanel(SLDBoxX,
- SLDBoxY + SLTPHeight,
- SLMDWidth,
- SLMDHeight);
+Rect16 SLMidPanel(kSLDBoxX,
+ kSLDBoxY + kSLTPHeight,
+ kSLMDWidth,
+ kSLMDHeight);
-Rect16 SLBotPanel(SLDBoxX,
- SLDBoxY + SLTPHeight + SLMDHeight,
- SLBTWidth,
- SLBTHeight);
+Rect16 SLBotPanel(kSLDBoxX,
+ kSLDBoxY + kSLTPHeight + kSLMDHeight,
+ kSLBTWidth,
+ kSLBTHeight);
// buttons
Rect16 SLQuitBtnRect(211,
- SLTPHeight + SLMDHeight + 11,
+ kSLTPHeight + kSLMDHeight + 11,
122,
30);
Rect16 SLBtnRect(31,
- SLTPHeight + SLMDHeight + 11,
+ kSLTPHeight + kSLMDHeight + 11,
122,
30);
@@ -197,16 +177,16 @@ Rect16 SLDnArrowBtnRect(327,
Rect16 SLTitleRect(0,
0,
- SLDBoxXSzNS,
+ kSLDBoxXSzNS,
47);
// save load window rect
-Rect16 saveLoadWindowRect = Rect16(SLDBoxX,
- SLDBoxY,
- SLDBoxXSize,
- SLDBoxYSize);
+Rect16 saveLoadWindowRect = Rect16(kSLDBoxX,
+ kSLDBoxY,
+ kSLDBoxXSize,
+ kSLDBoxYSize);
// indirections
@@ -236,68 +216,34 @@ WindowDecoration saveWindowDecorations[kNumSaveLoadPanels] =
};
-// Options dialog metrics
-
-const int kNumOptionsPanels = 3;
-const int kNumOptionsBtns = 9;
-const int kNumOptionsTexts = 8;
-
-
-const int16 optBoxXSize = 487,
- optBoxXSzNS = 479,
- optBoxYSize = 230,
- optBoxX = (640 - optBoxXSize) / 2,
- optBoxY = (480 - optBoxYSize) / 3;
-
-const int16 optTPHeight = 39;
-const int16 optMDHeight = 90;
-const int16 optBTHeight = 101;
-const int16 optTPWidth = 487;
-const int16 optMDWidth = 487;
-const int16 optBTWidth = 487;
-
-
// panels
-Rect16 optTopPanel(optBoxX,
- optBoxY,
- optTPWidth,
- optTPHeight);
-
-Rect16 optMidPanel(optBoxX,
- optBoxY + optTPHeight,
- optMDWidth,
- optMDHeight);
-
-Rect16 optBotPanel(optBoxX,
- optBoxY + optTPHeight + optMDHeight,
- optBTWidth,
- optBTHeight);
+Rect16 optTopPanel(kOptBoxX,
+ kOptBoxY,
+ kOptTPWidth,
+ kOptTPHeight);
+Rect16 optMidPanel(kOptBoxX,
+ kOptBoxY + kOptTPHeight,
+ kOptMDWidth,
+ kOptMDHeight);
-// buttons
-const int kButtonSpace = 3;
-const int kButtonYOffset = optTPHeight + 7;
-const int kPushButtonWidth = 121;
-const int kPushButtonHeight = 30;
-
-const int kSliderWidth = 168;
-//const int sliderHeight = 15;
-const int kImageHeight = 17;
+Rect16 optBotPanel(kOptBoxX,
+ kOptBoxY + kOptTPHeight + kOptMDHeight,
+ kOptBTWidth,
+ kOptBTHeight);
-const int kTextPixelLen = 175;
-const int kSmallTextOffset = 80;
static const StaticRect optResumeRect = {
- optBoxXSzNS - (kPushButtonWidth + 14),
+ kOptBoxXSzNS - (kPushButtonWidth + 14),
kButtonYOffset + kButtonSpace,
kPushButtonWidth,
kPushButtonHeight
};
static const StaticRect optSaveRect = {
- optBoxXSzNS - (kPushButtonWidth + 14),
+ kOptBoxXSzNS - (kPushButtonWidth + 14),
kButtonYOffset + ((kPushButtonHeight * 1) + kButtonSpace * 2),
kPushButtonWidth,
kPushButtonHeight
@@ -306,21 +252,21 @@ static const StaticRect optSaveRect = {
static const StaticRect optRestoreRect = {
- optBoxXSzNS - (kPushButtonWidth + 14),
+ kOptBoxXSzNS - (kPushButtonWidth + 14),
kButtonYOffset + ((kPushButtonHeight * 2) + kButtonSpace * 3),
kPushButtonWidth,
kPushButtonHeight
};
static const StaticRect optQuitRect = {
- optBoxXSzNS - (kPushButtonWidth + 14),
+ kOptBoxXSzNS - (kPushButtonWidth + 14),
kButtonYOffset + ((kPushButtonHeight * 3) + kButtonSpace * 4),
kPushButtonWidth,
kPushButtonHeight
};
static const StaticRect optCreditsRect = {
- optBoxXSzNS - (kPushButtonWidth + 14),
+ kOptBoxXSzNS - (kPushButtonWidth + 14),
kButtonYOffset + ((kPushButtonHeight * 4) + kButtonSpace * 5),
kPushButtonWidth,
kPushButtonHeight
@@ -328,35 +274,35 @@ static const StaticRect optCreditsRect = {
static const StaticRect optAggressRect = {
14,
- 98 + optTPHeight,
+ 98 + kOptTPHeight,
18,
17
};
static const StaticRect optWeaponRect = {
14,
- 121 + optTPHeight,
+ 121 + kOptTPHeight,
18,
17
};
static const StaticRect optSpeechRect = {
14,
- 121 + 23 + optTPHeight,
+ 121 + 23 + kOptTPHeight,
18,
17
};
static const StaticRect optNightRect = {
14 + 200,
- 98 + optTPHeight,
+ 98 + kOptTPHeight,
18,
17
};
static const StaticRect optTopSliderRect = {
15,
- 15 + optTPHeight - 2,
+ 15 + kOptTPHeight - 2,
kSliderWidth,
kImageHeight
};
@@ -402,8 +348,8 @@ static const StaticRect optBotFaceRect = {
static const StaticRect optTitleText = {
0,
0,
- optBoxXSzNS,
- optTPHeight
+ kOptBoxXSzNS,
+ kOptTPHeight
};
static const StaticRect optTopSlideText = {
@@ -458,10 +404,10 @@ static const StaticRect optTop2CheckText = {
// options window rect
static const StaticRect optionsWindowRect = {
- optBoxX,
- optBoxY,
- optBoxXSize,
- optBoxYSize
+ kOptBoxX,
+ kOptBoxY,
+ kOptBoxXSize,
+ kOptBoxYSize
};
@@ -506,49 +452,34 @@ WindowDecoration optionsDecorations[kNumOptionsPanels] = {
};
-// Message Dialog Metrics
-
-const int kNumMessagePanels = 1;
-const int kNumMessageBtns = 3;
-const int kNumMessageTexts = 2;
-const int mesBtnOffset = 14;
-
-const int16 mesBoxXSize = 374,
- mesBoxXSzNS = 368,
- mesBoxYSize = 146,
- mesBoxX = (640 - mesBoxXSize) / 2,
- mesBoxY = (480 - mesBoxYSize) / 3;
-
-
// panels
static const StaticRect messagePanel = {
- mesBoxX,
- mesBoxY,
- mesBoxXSize,
- mesBoxYSize
+ kMesBoxX,
+ kMesBoxY,
+ kMesBoxXSize,
+ kMesBoxYSize
};
-
// buttons
static const StaticRect mesCancelBtnRect = {
- mesBoxXSzNS - (kPushButtonWidth + mesBtnOffset),
- mesBoxY - mesBtnOffset,
+ kMesBoxXSzNS - (kPushButtonWidth + kMesBtnOffset),
+ kMesBoxY - kMesBtnOffset,
kPushButtonWidth,
kPushButtonHeight
};
static const StaticRect mesOkBtnRect = {
- mesBtnOffset,
- mesBoxY - mesBtnOffset,
+ kMesBtnOffset,
+ kMesBoxY - kMesBtnOffset,
kPushButtonWidth,
kPushButtonHeight
};
static const StaticRect mesBtn3Rect = {
- mesBoxXSzNS / 2 - kPushButtonWidth / 2,
- mesBoxY - mesBtnOffset,
+ kMesBoxXSzNS / 2 - kPushButtonWidth / 2,
+ kMesBoxY - kMesBtnOffset,
kPushButtonWidth,
kPushButtonHeight
};
@@ -560,15 +491,15 @@ static const StaticRect mesBtn3Rect = {
static const StaticRect mesTitleRect = {
0,
0,
- mesBoxXSzNS,
+ kMesBoxXSzNS,
47
};
static const StaticRect messageRect = {
0,
0,
- mesBoxXSzNS,
- mesBoxYSize
+ kMesBoxXSzNS,
+ kMesBoxYSize
};
@@ -589,10 +520,10 @@ StaticRect messageButtonRects[kNumMessageBtns] = {
// options window rect
static const StaticRect messageWindowRect = {
- mesBoxX,
- mesBoxY,
- mesBoxXSize,
- mesBoxYSize
+ kMesBoxX,
+ kMesBoxY,
+ kMesBoxXSize,
+ kMesBoxYSize
};
Commit: 349028e26216babb5b5594e3e1a7188b92e6b46c
https://github.com/scummvm/scummvm/commit/349028e26216babb5b5594e3e1a7188b92e6b46c
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:38+02:00
Commit Message:
SAGA2: Remove more global constructors
Changed paths:
engines/saga2/uidialog.cpp
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index 3a134fe8c6..a4961f1165 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -136,81 +136,102 @@ enum messageImageResIDs {
// panels
-Rect16 SLTopPanel(kSLDBoxX,
- kSLDBoxY,
- kSLTPWidth,
- kSLTPHeight);
+static const StaticRect SLTopPanel = {
+ kSLDBoxX,
+ kSLDBoxY,
+ kSLTPWidth,
+ kSLTPHeight
+};
-Rect16 SLMidPanel(kSLDBoxX,
- kSLDBoxY + kSLTPHeight,
- kSLMDWidth,
- kSLMDHeight);
+static const StaticRect SLMidPanel = {
+ kSLDBoxX,
+ kSLDBoxY + kSLTPHeight,
+ kSLMDWidth,
+ kSLMDHeight
+};
-Rect16 SLBotPanel(kSLDBoxX,
- kSLDBoxY + kSLTPHeight + kSLMDHeight,
- kSLBTWidth,
- kSLBTHeight);
+static const StaticRect SLBotPanel = {
+ kSLDBoxX,
+ kSLDBoxY + kSLTPHeight + kSLMDHeight,
+ kSLBTWidth,
+ kSLBTHeight
+};
// buttons
-Rect16 SLQuitBtnRect(211,
- kSLTPHeight + kSLMDHeight + 11,
- 122,
- 30);
-
-Rect16 SLBtnRect(31,
- kSLTPHeight + kSLMDHeight + 11,
- 122,
- 30);
-
-Rect16 SLUpArrowBtnRect(327,
- 46,
- 32,
- 36);
-
-Rect16 SLDnArrowBtnRect(327,
- 121,
- 32,
- 36);
+static const StaticRect SLQuitBtnRect = {
+ 211,
+ kSLTPHeight + kSLMDHeight + 11,
+ 122,
+ 30
+};
+
+static const StaticRect SLBtnRect = {
+ 31,
+ kSLTPHeight + kSLMDHeight + 11,
+ 122,
+ 30
+};
+
+static const StaticRect SLUpArrowBtnRect = {
+ 327,
+ 46,
+ 32,
+ 36
+};
+
+static const StaticRect SLDnArrowBtnRect = {
+ 327,
+ 121,
+ 32,
+ 36
+};
// texts
-Rect16 SLTitleRect(0,
- 0,
- kSLDBoxXSzNS,
- 47);
+static const StaticRect SLTitleRect = {
+ 0,
+ 0,
+ kSLDBoxXSzNS,
+ 47
+};
// save load window rect
-Rect16 saveLoadWindowRect = Rect16(kSLDBoxX,
- kSLDBoxY,
- kSLDBoxXSize,
- kSLDBoxYSize);
+static const StaticRect saveLoadWindowRect = {
+ kSLDBoxX,
+ kSLDBoxY,
+ kSLDBoxXSize,
+ kSLDBoxYSize
+};
// indirections
-Rect16 saveLoadPanelRects[kNumSaveLoadPanels] = { { SLTopPanel },
+static const StaticRect saveLoadPanelRects[kNumSaveLoadPanels] = {
+ { SLTopPanel },
{ SLMidPanel },
{ SLBotPanel }
};
-Rect16 saveLoadButtonRects[kNumSaveLoadBtns] = { { SLQuitBtnRect },
- { SLBtnRect },
+static const StaticRect saveLoadButtonRects[kNumSaveLoadBtns] = {
+ { SLQuitBtnRect },
+ { SLBtnRect },
{ SLUpArrowBtnRect },
{ SLDnArrowBtnRect }
};
-Rect16 saveLoadTextRects[kNumSaveLoadTexts] = { { SLTitleRect } };
+static const StaticRect saveLoadTextRects[kNumSaveLoadTexts] = {
+ { SLTitleRect }
+};
// save/load dialog window decorations
-WindowDecoration saveWindowDecorations[kNumSaveLoadPanels] =
-
-{ { WindowDecoration(saveLoadPanelRects[0], SLTopPanelResID) },
+WindowDecoration saveWindowDecorations[kNumSaveLoadPanels] = {
+ { WindowDecoration(saveLoadPanelRects[0], SLTopPanelResID) },
{ WindowDecoration(saveLoadPanelRects[1], SLMidPanelResID) },
{ WindowDecoration(saveLoadPanelRects[2], SLBotPanelResID) }
};
@@ -219,20 +240,26 @@ WindowDecoration saveWindowDecorations[kNumSaveLoadPanels] =
// panels
-Rect16 optTopPanel(kOptBoxX,
- kOptBoxY,
- kOptTPWidth,
- kOptTPHeight);
+static const StaticRect optTopPanel = {
+ kOptBoxX,
+ kOptBoxY,
+ kOptTPWidth,
+ kOptTPHeight
+};
-Rect16 optMidPanel(kOptBoxX,
- kOptBoxY + kOptTPHeight,
- kOptMDWidth,
- kOptMDHeight);
+static const StaticRect optMidPanel = {
+ kOptBoxX,
+ kOptBoxY + kOptTPHeight,
+ kOptMDWidth,
+ kOptMDHeight
+};
-Rect16 optBotPanel(kOptBoxX,
- kOptBoxY + kOptTPHeight + kOptMDHeight,
- kOptBTWidth,
- kOptBTHeight);
+static const StaticRect optBotPanel = {
+ kOptBoxX,
+ kOptBoxY + kOptTPHeight + kOptMDHeight,
+ kOptBTWidth,
+ kOptBTHeight
+};
static const StaticRect optResumeRect = {
@@ -413,13 +440,13 @@ static const StaticRect optionsWindowRect = {
// indirections
-Rect16 optionsPanelRects[kNumOptionsPanels] = {
+static StaticRect optionsPanelRects[kNumOptionsPanels] = {
{ optTopPanel },
{ optMidPanel },
{ optBotPanel }
};
-StaticRect optionsButtonRects[] = {
+static StaticRect optionsButtonRects[] = {
{ optResumeRect },
{ optSaveRect },
{ optRestoreRect },
@@ -431,7 +458,7 @@ StaticRect optionsButtonRects[] = {
{ optNightRect }
};
-StaticRect optionsTextRects[] = {
+static StaticRect optionsTextRects[] = {
{ optTitleText },
{ optTopSlideText },
{ optMidSlideText },
@@ -445,7 +472,7 @@ StaticRect optionsTextRects[] = {
// options dialog window decorations
-WindowDecoration optionsDecorations[kNumOptionsPanels] = {
+static WindowDecoration optionsDecorations[kNumOptionsPanels] = {
{ WindowDecoration(optionsPanelRects[0], optTopPanelResID) },
{ WindowDecoration(optionsPanelRects[1], optMidPanelResID) },
{ WindowDecoration(optionsPanelRects[2], optBotPanelResID) }
@@ -504,13 +531,13 @@ static const StaticRect messageRect = {
-StaticRect messageTextRects[kNumMessageTexts] = {
+static StaticRect messageTextRects[kNumMessageTexts] = {
{ mesTitleRect },
{ messageRect }
};
-StaticRect messageButtonRects[kNumMessageBtns] = {
+static StaticRect messageButtonRects[kNumMessageBtns] = {
{ mesOkBtnRect },
{ mesCancelBtnRect },
{ mesBtn3Rect }
@@ -530,7 +557,7 @@ static const StaticRect messageWindowRect = {
// message dialog window decorations
-WindowDecoration messageDecorations[kNumMessagePanels] = {
+static WindowDecoration messageDecorations[kNumMessagePanels] = {
{ WindowDecoration(messagePanel, mesPanelResID) }
};
Commit: 17af3b9c2c64bfe49e0410520d91c49392037cd3
https://github.com/scummvm/scummvm/commit/17af3b9c2c64bfe49e0410520d91c49392037cd3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:38+02:00
Commit Message:
SAGA2: Fix rate for the shorten audio
Changed paths:
engines/saga2/shorten.cpp
diff --git a/engines/saga2/shorten.cpp b/engines/saga2/shorten.cpp
index a6be9f7f75..743109de78 100644
--- a/engines/saga2/shorten.cpp
+++ b/engines/saga2/shorten.cpp
@@ -532,8 +532,7 @@ byte *loadShortenFromStream(Common::ReadStream &stream, int &size, int &rate, by
}
}
- // Rate is always 44100Hz
- rate = 44100;
+ rate = 22050;
// Cleanup
for (i = 0; i < channels; i++) {
Commit: 03409d77cd83ac7ae6e71c921f0898a797af2b57
https://github.com/scummvm/scummvm/commit/03409d77cd83ac7ae6e71c921f0898a797af2b57
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:38+02:00
Commit Message:
SAGA2: Added more debug output to sound
Changed paths:
engines/saga2/detection.cpp
engines/saga2/noise.cpp
engines/saga2/saga2.h
diff --git a/engines/saga2/detection.cpp b/engines/saga2/detection.cpp
index 6776e8fae6..783202873f 100644
--- a/engines/saga2/detection.cpp
+++ b/engines/saga2/detection.cpp
@@ -38,6 +38,7 @@ static const DebugChannelDef debugFlagList[] = {
{Saga2::kDebugTimers, "timers", "Debug the timers"},
{Saga2::kDebugPath, "path", "Debug the pathfinding"},
{Saga2::kDebugTasks, "tasks", "Debug the tasks"},
+ {Saga2::kDebugSound, "sound", "Debug the sound"},
DEBUG_CHANNEL_END
};
diff --git a/engines/saga2/noise.cpp b/engines/saga2/noise.cpp
index 62779a7460..a8204e0f7d 100644
--- a/engines/saga2/noise.cpp
+++ b/engines/saga2/noise.cpp
@@ -435,6 +435,8 @@ Point32 translateLocation(Location playAt) {
// MIDI playback
void playMusic(uint32 s) {
+ debugC(1, kDebugSound, "playMusic(%s)", tag2str(s));
+
currentMidi = s;
if (hResCheckResID(musicRes, s)) {
@@ -447,6 +449,8 @@ void playMusic(uint32 s) {
// in memory sfx
void playMemSound(uint32 s) {
+ debugC(1, kDebugSound, "playMemSound(%s)", tag2str(s));
+
if (bufCheckResID(NULL, s))
audio->queueSound(s, memDec, 1, Here);
}
@@ -455,6 +459,8 @@ void playMemSound(uint32 s) {
// on disk sfx
void playSound(uint32 s) {
+ debugC(1, kDebugSound, "playSound(%s)", tag2str(s));
+
if (hResCheckResID(soundRes, s))
audio->queueSound(s, soundDec, 1, Here);
}
@@ -463,7 +469,8 @@ void playSound(uint32 s) {
// on disk sfx (x2 buffered)
void playLongSound(uint32 s) {
- warning("playLongSound(%d)", s);
+ debugC(1, kDebugSound, "playLongSound(%s)", tag2str(s));
+
if (hResCheckResID(longRes, s))
audio->queueVoice(s, longSoundDec);
else
@@ -474,7 +481,7 @@ void playLongSound(uint32 s) {
// on disk voice (x2 buffered)
void playVoice(uint32 s) {
- warning("playVoice(%d)", s);
+ debugC(1, kDebugSound, "playVoice(%s)", tag2str(s));
if (hResCheckResID(voiceRes, s)) {
if (s)
@@ -488,7 +495,12 @@ void playVoice(uint32 s) {
// supplemental interface for speech
bool sayVoice(uint32 s[]) {
- warning("sayVoice(%d)", s[0]);
+ debugCN(1, kDebugSound, "sayVoice([%s", tag2str(s[0]));
+
+ for (uint32 i = 1; s[i]; i++)
+ debugCN(1, kDebugSound, ", %s", tag2str(s[i]));
+
+ debugC(1, kDebugSound, "])");
bool worked = false;
@@ -505,7 +517,7 @@ bool sayVoice(uint32 s[]) {
// main loop playback
void _playLoop(uint32 s) {
- warning("STUB: _playLoop(%d)", s);
+ warning("STUB: _playLoop(%s)", tag2str(s));
currentLoop = s;
if (currentLoop == audio->currentLoop() && 0)
@@ -539,6 +551,8 @@ void playLoop(uint32 s) {
// attenuated sound players
void playSoundAt(uint32 s, Point32 p) {
+ debugC(1, kDebugSound, "playSoundAt(%s, %d,%d)", tag2str(s), p.x, p.y);
+
if (hResCheckResID(soundRes, s))
audio->queueSound(s, soundDec, 1, p);
}
@@ -555,7 +569,12 @@ void playSoundAt(uint32 s, Location playAt) {
Audio::SoundHandle _speechSoundHandle;
bool sayVoiceAt(uint32 s[], Point32 p) {
- warning("sayVoiceAt(%s, %d,%d)", tag2str(s[0]), p.x, p.y);
+ debugCN(1, kDebugSound, "sayVoiceAt([%s", tag2str(s[0]));
+
+ for (uint32 i = 1; s[i]; i++)
+ debugCN(1, kDebugSound, ", %s", tag2str(s[i]));
+
+ debugC(1, kDebugSound, "], %d,%d", p.x, p.y);
Common::SeekableReadStream *stream = loadResourceToStream(voiceRes, s[0], "voice data");
@@ -577,6 +596,8 @@ bool sayVoiceAt(uint32 s[], Location playAt) {
// loop playback w/ attenuation
void playLoopAt(uint32 s, Point32 loc) {
+ debugC(1, kDebugSound, "playLoopAt(%s, %d,%d)", tag2str(s), loc.x, loc.y);
+
if (hResCheckResID(loopRes, s))
audio->queueLoop(s, loopDec, 0, loc);
else
@@ -588,6 +609,8 @@ void killAuxTheme(soundSegment lid);
void killAllAuxThemes(void);
void playLoopAt(uint32 s, Location playAt) {
+ debugC(1, kDebugSound, "playLoopAt(%s, %d,%d,%d)", tag2str(s), playAt.u, playAt.v, playAt.z);
+
if (s) {
addAuxTheme(playAt, s);
} else {
diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h
index 0cd7d031bd..d8f072a1d1 100644
--- a/engines/saga2/saga2.h
+++ b/engines/saga2/saga2.h
@@ -54,7 +54,8 @@ enum {
kDebugLoading = 1 << 7,
kDebugTimers = 1 << 8,
kDebugPath = 1 << 9,
- kDebugTasks = 1 << 10
+ kDebugTasks = 1 << 10,
+ kDebugSound = 1 << 11
};
#define TICKSPERSECOND (728L/10L)
Commit: 0e6d008ef92d8738cd7090a3069350880094ee15
https://github.com/scummvm/scummvm/commit/0e6d008ef92d8738cd7090a3069350880094ee15
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:38+02:00
Commit Message:
SAGA2: Improved debug output
Changed paths:
engines/saga2/noise.cpp
diff --git a/engines/saga2/noise.cpp b/engines/saga2/noise.cpp
index a8204e0f7d..aebeb94c3e 100644
--- a/engines/saga2/noise.cpp
+++ b/engines/saga2/noise.cpp
@@ -574,7 +574,7 @@ bool sayVoiceAt(uint32 s[], Point32 p) {
for (uint32 i = 1; s[i]; i++)
debugCN(1, kDebugSound, ", %s", tag2str(s[i]));
- debugC(1, kDebugSound, "], %d,%d", p.x, p.y);
+ debugC(1, kDebugSound, "], %d,%d)", p.x, p.y);
Common::SeekableReadStream *stream = loadResourceToStream(voiceRes, s[0], "voice data");
Commit: 7fc299c4e4e256dc2304b2cd3fe42ded7ca0c15b
https://github.com/scummvm/scummvm/commit/7fc299c4e4e256dc2304b2cd3fe42ded7ca0c15b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:38+02:00
Commit Message:
SAGA2: Added stub for stillDoingVoice()
Changed paths:
engines/saga2/noise.cpp
diff --git a/engines/saga2/noise.cpp b/engines/saga2/noise.cpp
index aebeb94c3e..1307a2842f 100644
--- a/engines/saga2/noise.cpp
+++ b/engines/saga2/noise.cpp
@@ -636,7 +636,10 @@ void moveLoop(Location loc) {
// supplemental interface check for speech
bool stillDoingVoice(uint32 sampno) {
- return (audio->saying(sampno));
+ warning("STUB: stillDoingVoice(%s)", tag2str(sampno));
+ return g_system->getMixer()->isSoundHandleActive(_speechSoundHandle);
+
+// return (audio->saying(sampno));
}
Commit: 596706948d7a4965f59fba9e67f8c25eca33e407
https://github.com/scummvm/scummvm/commit/596706948d7a4965f59fba9e67f8c25eca33e407
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:38+02:00
Commit Message:
SAGA2: Re-enable audio
Changed paths:
engines/saga2/main.cpp
engines/saga2/towerfta.cpp
engines/saga2/towerfta.h
engines/saga2/towerwin.h
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 195d86dd6c..4e4c4b192b 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -299,8 +299,7 @@ void processEventLoop(bool updateScreen) {
}
debugC(1, kDebugEventLoop, "EventLoop: audio event loop");
- //FIXME: Disabled for debug purposes. Enable and implement later.
- //audioEventLoop();
+ audioEventLoop();
debugC(1, kDebugEventLoop, "EventLoop: game mode update");
if (GameMode::newmodeFlag)
@@ -368,8 +367,7 @@ void displayUpdate(void) {
// Call asynchronous resource loader
debugC(1, kDebugEventLoop, "EventLoop: resource update");
- //FIXME: Disabled for debug purposes. Enable and implement later.
- //audioEventLoop();
+ audioEventLoop();
// Call the asynchronous path finder
debugC(1, kDebugEventLoop, "EventLoop: pathfinder update");
diff --git a/engines/saga2/towerfta.cpp b/engines/saga2/towerfta.cpp
index 213ad0c1d2..afbc5c1f50 100644
--- a/engines/saga2/towerfta.cpp
+++ b/engines/saga2/towerfta.cpp
@@ -58,6 +58,7 @@ TowerLayer tower[fullyInitialized] = {
{ memoryInitialized, &initMemPool, &termMemPool },
{ introInitialized, &initPlayIntro, &termPlayOutro },
{ timerInitialized, &initSystemTimer, &termSystemTimer },
+ { audioInitialized, &initAudio, &termAudio},
{ resourcesInitialized, &initResourceFiles, &termResourceFiles },
{ serversInitialized, &initResourceServers, &termResourceServers },
{ pathFinderInitialized, &initPathFinders, &termPathFinders },
@@ -159,6 +160,14 @@ TERMINATOR(termSystemTimer) {
cleanupSystemTimer();
}
+// ------------------------------------------------------------------------
+
+extern INITIALIZER(initAudio);
+
+TERMINATOR (termAudio)
+{
+ cleanupAudio();
+}
// ------------------------------------------------------------------------
diff --git a/engines/saga2/towerfta.h b/engines/saga2/towerfta.h
index a17e026d36..aeb9c0eecb 100644
--- a/engines/saga2/towerfta.h
+++ b/engines/saga2/towerfta.h
@@ -43,6 +43,9 @@ TERMINATOR(termPlayOutro);
INITIALIZER(initSystemTimer);
TERMINATOR(termSystemTimer);
+INITIALIZER(initAudio);
+TERMINATOR (termAudio);
+
INITIALIZER(initResourceFiles);
TERMINATOR(termResourceFiles);
diff --git a/engines/saga2/towerwin.h b/engines/saga2/towerwin.h
index 37ba6337fc..d8b717f7a8 100644
--- a/engines/saga2/towerwin.h
+++ b/engines/saga2/towerwin.h
@@ -40,6 +40,7 @@ enum initializationStates {
graphicsSystemInitialized,
procResEnabled,
memoryInitialized,
+ audioInitialized,
videoInitialized,
resourcesInitialized,
serversInitialized,
Commit: 56b351d645ad7800ec1018b21c190ff98b2bd627
https://github.com/scummvm/scummvm/commit/56b351d645ad7800ec1018b21c190ff98b2bd627
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:38+02:00
Commit Message:
SAGA2: Add SoundQueue
Changed paths:
engines/saga2/audio.cpp
engines/saga2/audiosys.h
engines/saga2/audqueue.h
engines/saga2/noise.cpp
diff --git a/engines/saga2/audio.cpp b/engines/saga2/audio.cpp
index 4224e95b68..f81d40a470 100644
--- a/engines/saga2/audio.cpp
+++ b/engines/saga2/audio.cpp
@@ -41,9 +41,10 @@ namespace Saga2 {
audioInterface *audio;
-void initAudio() {
+bool initAudio() {
warning("STUB: initAudio()");
audio = new audioInterface();
+ return true;
}
void cleanupAudio() {
@@ -86,10 +87,11 @@ void audioInterface::resumeGameClock(void) {
bool audioInterface::playFlag(void) {
warning("STUB: audioInterface::playFlag()");
- return false;
+ return (!audio->queue.isPlaying() && audio->queue.getSize() > 0);
}
void audioInterface::playMe(void) {
warning("STUB: audioInterface::PlayMe()");
+ audio->queue.playNext();
}
void audioInterface::queueMusic(soundSegment s, decoderSet *, int16 loopFactor, sampleLocation where) {
warning("STUB: audioInterface::queueMusic()");
@@ -117,6 +119,7 @@ void audioInterface::setLoopPosition(sampleLocation newLoc) {
void audioInterface::queueVoice(soundSegment s, decoderSet *, sampleLocation where) {
warning("STUB: audioInterface::queueVoice(soundSegment, decoderSet *, sampleLocation)");
+ audio->queue.pushVoice(s);
}
void audioInterface::queueVoice(soundSegment s[], decoderSet *, sampleLocation where) {
warning("STUB: audioInterface::queueVoice(soundSegment [], decoderSet *, sampleLocation)");
diff --git a/engines/saga2/audiosys.h b/engines/saga2/audiosys.h
index c576d14bbd..c3bae45be2 100644
--- a/engines/saga2/audiosys.h
+++ b/engines/saga2/audiosys.h
@@ -177,7 +177,6 @@ private:
HTIMER gameTimer;
- soundQueue *queue; // the queue
queueFlags queueRes;
BufferRequest numBuffers;
@@ -217,6 +216,7 @@ private:
int32 suspendCalls;
public:
+ SoundQueue queue; // the queue
HDIGDRIVER dig; // AIL sample driver
HMDIDRIVER mid; // AIL MIDI driver
audioAttenuationFunction attenuator;
@@ -302,7 +302,7 @@ public:
verbosity = n;
}
int16 getQueueSize(void) {
- return queue->getSize();
+ return queue.getSize();
}
// moving sample calls
diff --git a/engines/saga2/audqueue.h b/engines/saga2/audqueue.h
index 5c46de4e58..33fec23713 100644
--- a/engines/saga2/audqueue.h
+++ b/engines/saga2/audqueue.h
@@ -27,33 +27,57 @@
#ifndef SAGA2_AUDQUEUE_H
#define SAGA2_AUDQUEUE_H
+#include "audio/mixer.h"
+#include "saga2/saga2.h"
+#include "saga2/shorten.h"
+#include "saga2/hresmgr.h"
+
namespace Saga2 {
-class soundQueue {
-public:
- positionedSample *tip;
- soundSegment curSeg;
- soundSegment headSeg;
+Common::SeekableReadStream *loadResourceToStream(hResContext *con, uint32 id, const char desc[]);
+
+extern hResContext *voiceRes;
+
+class SoundQueue {
private:
- PublicPtrQueue<positionedSample> sampleList;
+ Common::Queue<soundSegment> _voiceQueue;
+ Common::Queue<soundSegment> _sfxQueue;
+ Common::Queue<soundSegment> _bgmQueue;
+ Audio::SoundHandle _speechSoundHandle;
public:
- soundQueue(void) {
- tip = NULL;
+ void pushVoice(soundSegment s) {
+ _voiceQueue.push(s);
+ }
+
+ void pushVoice(soundSegment s[]) {
+ soundSegment *p = s;
+ while (*p) {
+ _voiceQueue.push(*p);
+ p++;
+ }
}
- ~soundQueue(void);
- positionedSample *firstSample(void);
- positionedSample *nextSample(void);
+ void playNext() {
+ if (_voiceQueue.size()) {
+ soundSegment s = _voiceQueue.pop();
+ Common::SeekableReadStream *stream = loadResourceToStream(voiceRes, s, "voice data");
- soundSegment firstSegment(void);
- soundSegment nextSegment(void);
+ Audio::AudioStream *aud = makeShortenStream(*stream);
- void pushSample(positionedSample *sam, decoderSet *);
- bool findSample(soundSegment s);
+ g_system->getMixer()->playStream(Audio::Mixer::kSpeechSoundType, &_speechSoundHandle, aud);
- int16 getSize(void);
- int16 getSampleSize(void);
+ delete stream;
+ }
+ }
+
+ bool isPlaying() {
+ return g_system->getMixer()->isSoundHandleActive(_speechSoundHandle);
+ }
+
+ int getSize() {
+ return _voiceQueue.size();
+ }
};
} // end of namespace Saga2
diff --git a/engines/saga2/noise.cpp b/engines/saga2/noise.cpp
index 1307a2842f..4ebd746ab3 100644
--- a/engines/saga2/noise.cpp
+++ b/engines/saga2/noise.cpp
@@ -576,11 +576,7 @@ bool sayVoiceAt(uint32 s[], Point32 p) {
debugC(1, kDebugSound, "], %d,%d)", p.x, p.y);
- Common::SeekableReadStream *stream = loadResourceToStream(voiceRes, s[0], "voice data");
-
- Audio::AudioStream *aud = makeShortenStream(*stream);
-
- g_system->getMixer()->playStream(Audio::Mixer::kSpeechSoundType, &_speechSoundHandle, aud);
+ audio->queue.pushVoice(s);
return true;
}
@@ -637,7 +633,7 @@ void moveLoop(Location loc) {
bool stillDoingVoice(uint32 sampno) {
warning("STUB: stillDoingVoice(%s)", tag2str(sampno));
- return g_system->getMixer()->isSoundHandleActive(_speechSoundHandle);
+ return audio->queue.isPlaying();
// return (audio->saying(sampno));
}
Commit: 06d708fd9aa5d315c05f3a6f9c4c61d56f7bdbda
https://github.com/scummvm/scummvm/commit/06d708fd9aa5d315c05f3a6f9c4c61d56f7bdbda
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:39+02:00
Commit Message:
SAGA2: Increase level of noisy stub warning
Changed paths:
engines/saga2/audio.cpp
diff --git a/engines/saga2/audio.cpp b/engines/saga2/audio.cpp
index f81d40a470..e2aa87555b 100644
--- a/engines/saga2/audio.cpp
+++ b/engines/saga2/audio.cpp
@@ -81,24 +81,29 @@ void audioInterface::cleanupAudioInterface(void) {
void audioInterface::suspendGameClock(void) {
warning("STUB: audioInterace::suspendGameClock()");
}
+
void audioInterface::resumeGameClock(void) {
warning("STUB: audioInterface::resumeGameClock()");
}
bool audioInterface::playFlag(void) {
- warning("STUB: audioInterface::playFlag()");
+ debugC(2, kDebugSound, "STUB: audioInterface::playFlag()");
return (!audio->queue.isPlaying() && audio->queue.getSize() > 0);
}
+
void audioInterface::playMe(void) {
warning("STUB: audioInterface::PlayMe()");
audio->queue.playNext();
}
+
void audioInterface::queueMusic(soundSegment s, decoderSet *, int16 loopFactor, sampleLocation where) {
warning("STUB: audioInterface::queueMusic()");
}
+
void audioInterface::stopMusic(void) {
warning("STUB: audioInterface::stopMusic()");
}
+
bool audioInterface::goodMIDICard(void) {
warning("STUB: audioInterface::goodMIDICard()");
return false;
@@ -107,12 +112,15 @@ bool audioInterface::goodMIDICard(void) {
void audioInterface::queueSound(soundSegment s, decoderSet *, int16 loopFactor, sampleLocation where) {
warning("STUB: audioInterface::queueSound(%d, @%d,%d)", s, where.x, where.y);
}
+
void audioInterface::queueLoop(soundSegment s, decoderSet *sDec, int16 loopFactor, sampleLocation where) {
warning("STUB: audioInterface::queueLoop()");
}
+
void audioInterface::stopLoop(void) {
warning("STUB: audioInterface::stopLoop()");
}
+
void audioInterface::setLoopPosition(sampleLocation newLoc) {
warning("STUB: audioInterface::setLoopPosition(%d,%d)", newLoc.x, newLoc.y);
}
@@ -121,16 +129,20 @@ void audioInterface::queueVoice(soundSegment s, decoderSet *, sampleLocation whe
warning("STUB: audioInterface::queueVoice(soundSegment, decoderSet *, sampleLocation)");
audio->queue.pushVoice(s);
}
+
void audioInterface::queueVoice(soundSegment s[], decoderSet *, sampleLocation where) {
warning("STUB: audioInterface::queueVoice(soundSegment [], decoderSet *, sampleLocation)");
}
+
void audioInterface::stopVoice(void) {
warning("STUB: audioInterface::stopVoice()");
}
+
bool audioInterface::talking(void) {
warning("STUB: audioInterface::talking()");
return false;
}
+
bool audioInterface::saying(soundSegment s) {
warning("STUB: audioInterface::saying()");
return false;
@@ -140,22 +152,28 @@ bool audioInterface::active(void) {
warning("STUB: audioInterface::active()");
return true;
}
+
void audioInterface::enable(volumeTarget i, bool onOff) {
warning("STUB: audioInterface::enable()");
}
+
void audioInterface::setVolume(volumeTarget targ, volumeMode op, Volume val) {
warning("STUB: audioInterface::setVolume()");
}
+
Volume audioInterface::getVolume(volumeTarget src) {
warning("STUB: audioInterface::getVolume()");
return 0;
}
+
void audioInterface::setMusicFadeStyle(int16 tOut, int16 tIn, int16 tOver) {
warning("STUB: audioInterface::setMusicFadeStyle()");
}
+
void audioInterface::suspend(void) {
warning("STUB: audioInterface::suspend()");
}
+
void audioInterface::resume(void) {
warning("STUB: audioInterface::resume()");
}
Commit: f37fceb82bdb680f6430e99f1a51a12b69f9a5c3
https://github.com/scummvm/scummvm/commit/f37fceb82bdb680f6430e99f1a51a12b69f9a5c3
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:39+02:00
Commit Message:
SAGA2: Add sound/music handles for SoundQueue
Changed paths:
engines/saga2/audio.cpp
engines/saga2/audqueue.h
engines/saga2/noise.cpp
diff --git a/engines/saga2/audio.cpp b/engines/saga2/audio.cpp
index e2aa87555b..1a5d2dc0d2 100644
--- a/engines/saga2/audio.cpp
+++ b/engines/saga2/audio.cpp
@@ -111,6 +111,7 @@ bool audioInterface::goodMIDICard(void) {
void audioInterface::queueSound(soundSegment s, decoderSet *, int16 loopFactor, sampleLocation where) {
warning("STUB: audioInterface::queueSound(%d, @%d,%d)", s, where.x, where.y);
+ audio->queue.pushSound(s);
}
void audioInterface::queueLoop(soundSegment s, decoderSet *sDec, int16 loopFactor, sampleLocation where) {
@@ -132,6 +133,7 @@ void audioInterface::queueVoice(soundSegment s, decoderSet *, sampleLocation whe
void audioInterface::queueVoice(soundSegment s[], decoderSet *, sampleLocation where) {
warning("STUB: audioInterface::queueVoice(soundSegment [], decoderSet *, sampleLocation)");
+ audio->queue.pushVoice(s);
}
void audioInterface::stopVoice(void) {
diff --git a/engines/saga2/audqueue.h b/engines/saga2/audqueue.h
index 33fec23713..55d6fc1a55 100644
--- a/engines/saga2/audqueue.h
+++ b/engines/saga2/audqueue.h
@@ -29,54 +29,114 @@
#include "audio/mixer.h"
#include "saga2/saga2.h"
+#include "saga2/fta.h"
#include "saga2/shorten.h"
#include "saga2/hresmgr.h"
namespace Saga2 {
-Common::SeekableReadStream *loadResourceToStream(hResContext *con, uint32 id, const char desc[]);
-
extern hResContext *voiceRes;
+extern hResContext *soundRes;
+extern hResContext *musicRes;
class SoundQueue {
private:
- Common::Queue<soundSegment> _voiceQueue;
+ Common::Queue<soundSegment> _speechQueue;
Common::Queue<soundSegment> _sfxQueue;
Common::Queue<soundSegment> _bgmQueue;
Audio::SoundHandle _speechSoundHandle;
+ Audio::SoundHandle _sfxSoundHandle;
+ Audio::SoundHandle _bgmSoundHandle;
public:
void pushVoice(soundSegment s) {
- _voiceQueue.push(s);
+ _speechQueue.push(s);
}
void pushVoice(soundSegment s[]) {
soundSegment *p = s;
while (*p) {
- _voiceQueue.push(*p);
+ _speechQueue.push(*p);
p++;
}
}
- void playNext() {
- if (_voiceQueue.size()) {
- soundSegment s = _voiceQueue.pop();
- Common::SeekableReadStream *stream = loadResourceToStream(voiceRes, s, "voice data");
+ void pushSound(soundSegment s) {
+ _sfxQueue.push(s);
+ }
- Audio::AudioStream *aud = makeShortenStream(*stream);
+ void pushMusic(soundSegment s) {
+ _bgmQueue.push(s);
+ }
- g_system->getMixer()->playStream(Audio::Mixer::kSpeechSoundType, &_speechSoundHandle, aud);
+ void playNext() {
+ if (_speechQueue.size()) {
+ soundSegment s = _speechQueue.pop();
+ playSpeech(s);
+ }
- delete stream;
+ if (_sfxQueue.size()) {
+ soundSegment s = _sfxQueue.pop();
+ playSound(s);
}
}
- bool isPlaying() {
+ void playSpeech(soundSegment s) {
+ Common::SeekableReadStream *stream = loadResourceToStream(voiceRes, s, "voice data");
+
+ Audio::AudioStream *aud = makeShortenStream(*stream);
+
+ g_system->getMixer()->playStream(Audio::Mixer::kSpeechSoundType, &_speechSoundHandle, aud);
+
+ delete stream;
+ }
+
+ void playSound(soundSegment s) {
+ warning("STUB: SoundQueue::playSound");
+
+#if 0
+ Common::SeekableReadStream *stream = loadResourceToStream(soundRes, s, "voice data");
+
+ Audio::AudioStream *aud = makeShortenStream(*stream);
+
+ g_system->getMixer()->playStream(Audio::Mixer::kSpeechSoundType, &_sfxSoundHandle, aud);
+
+ delete stream;
+#endif
+ }
+
+ void playMusic(soundSegment s) {
+ warning("STUB: SoundQueue::playMusic");
+
+#if 0
+ Common::SeekableReadStream *stream = loadResourceToStream(musicRes, s, "voice data");
+
+ Audio::AudioStream *aud = makeShortenStream(*stream);
+
+ g_system->getMixer()->playStream(Audio::Mixer::kSpeechSoundType, &_bgmSoundHandle, aud);
+
+ delete stream;
+#endif
+ }
+
+ bool isSpeechPlaying() {
return g_system->getMixer()->isSoundHandleActive(_speechSoundHandle);
}
+ bool isSoundPlaying() {
+ return g_system->getMixer()->isSoundHandleActive(_sfxSoundHandle);
+ }
+
+ bool isMusicPlaying() {
+ return g_system->getMixer()->isSoundHandleActive(_bgmSoundHandle);
+ }
+
+ bool isPlaying() {
+ return isSpeechPlaying() || isSoundPlaying() || isMusicPlaying();
+ }
+
int getSize() {
- return _voiceQueue.size();
+ return _speechQueue.size() + _sfxQueue.size() + _bgmQueue.size();
}
};
diff --git a/engines/saga2/noise.cpp b/engines/saga2/noise.cpp
index 4ebd746ab3..b5ee259227 100644
--- a/engines/saga2/noise.cpp
+++ b/engines/saga2/noise.cpp
@@ -576,7 +576,7 @@ bool sayVoiceAt(uint32 s[], Point32 p) {
debugC(1, kDebugSound, "], %d,%d)", p.x, p.y);
- audio->queue.pushVoice(s);
+ audio->queueVoice(s, voiceDec, p);
return true;
}
@@ -633,9 +633,8 @@ void moveLoop(Location loc) {
bool stillDoingVoice(uint32 sampno) {
warning("STUB: stillDoingVoice(%s)", tag2str(sampno));
- return audio->queue.isPlaying();
-// return (audio->saying(sampno));
+ return audio->queue.isSpeechPlaying();
}
Commit: a19250b36b05a062af2b04423121c3247fbc1468
https://github.com/scummvm/scummvm/commit/a19250b36b05a062af2b04423121c3247fbc1468
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:39+02:00
Commit Message:
SAGA2: Add isSpeechPlaying(soundSegment) stub
Changed paths:
engines/saga2/audio.cpp
engines/saga2/audqueue.h
engines/saga2/noise.cpp
diff --git a/engines/saga2/audio.cpp b/engines/saga2/audio.cpp
index 1a5d2dc0d2..338e0417a9 100644
--- a/engines/saga2/audio.cpp
+++ b/engines/saga2/audio.cpp
@@ -87,7 +87,7 @@ void audioInterface::resumeGameClock(void) {
}
bool audioInterface::playFlag(void) {
- debugC(2, kDebugSound, "STUB: audioInterface::playFlag()");
+ debugC(5, kDebugSound, "STUB: audioInterface::playFlag()");
return (!audio->queue.isPlaying() && audio->queue.getSize() > 0);
}
diff --git a/engines/saga2/audqueue.h b/engines/saga2/audqueue.h
index 55d6fc1a55..03d70dab8d 100644
--- a/engines/saga2/audqueue.h
+++ b/engines/saga2/audqueue.h
@@ -48,6 +48,8 @@ private:
Audio::SoundHandle _sfxSoundHandle;
Audio::SoundHandle _bgmSoundHandle;
+ soundSegment _currentSpeech = 0;
+
public:
void pushVoice(soundSegment s) {
_speechQueue.push(s);
@@ -72,6 +74,7 @@ public:
void playNext() {
if (_speechQueue.size()) {
soundSegment s = _speechQueue.pop();
+ _currentSpeech = s;
playSpeech(s);
}
@@ -123,6 +126,11 @@ public:
return g_system->getMixer()->isSoundHandleActive(_speechSoundHandle);
}
+ bool isSpeechPlaying(soundSegment s) {
+ debugC(2, kDebugSound, "STUB: Sound: isSpeechPlaying(%d) vs %d", s, _currentSpeech);
+ return isSpeechPlaying() && _currentSpeech <= s;
+ }
+
bool isSoundPlaying() {
return g_system->getMixer()->isSoundHandleActive(_sfxSoundHandle);
}
diff --git a/engines/saga2/noise.cpp b/engines/saga2/noise.cpp
index b5ee259227..5db5f09d6d 100644
--- a/engines/saga2/noise.cpp
+++ b/engines/saga2/noise.cpp
@@ -634,7 +634,7 @@ void moveLoop(Location loc) {
bool stillDoingVoice(uint32 sampno) {
warning("STUB: stillDoingVoice(%s)", tag2str(sampno));
- return audio->queue.isSpeechPlaying();
+ return audio->queue.isSpeechPlaying(sampno);
}
Commit: e4ca5a7864c0534aaa44c3d9e9068e3416d8d368
https://github.com/scummvm/scummvm/commit/e4ca5a7864c0534aaa44c3d9e9068e3416d8d368
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:39+02:00
Commit Message:
SAGA2: Get rid of some global constructors
Changed paths:
engines/saga2/automap.cpp
engines/saga2/beegee.cpp
engines/saga2/objproto.h
engines/saga2/rect.h
engines/saga2/tcoords.h
diff --git a/engines/saga2/automap.cpp b/engines/saga2/automap.cpp
index bc4be4fc5e..1cc3432fd2 100644
--- a/engines/saga2/automap.cpp
+++ b/engines/saga2/automap.cpp
@@ -92,28 +92,37 @@ const int16 autoMapMDWidth = 544;
const int16 autoMapBTWidth = 544;
-Rect16 autoMapRect(autoMapBoxX,
- autoMapBoxY,
- autoMapBoxXSize,
- autoMapBoxYSize);
+static const StaticRect autoMapRect = {
+ autoMapBoxX,
+ autoMapBoxY,
+ autoMapBoxXSize,
+ autoMapBoxYSize
+};
-Rect16 autoMapTopPanelRect(autoMapBoxX,
- autoMapBoxY,
- autoMapTPWidth,
- autoMapTPHeight);
+static const StaticRect autoMapTopPanelRect = {
+ autoMapBoxX,
+ autoMapBoxY,
+ autoMapTPWidth,
+ autoMapTPHeight
+};
-Rect16 autoMapMidPanelRect(autoMapBoxX,
- autoMapBoxY + autoMapTPHeight,
- autoMapMDWidth,
- autoMapMDHeight);
+static const StaticRect autoMapMidPanelRect = {
+ autoMapBoxX,
+ autoMapBoxY + autoMapTPHeight,
+ autoMapMDWidth,
+ autoMapMDHeight
+};
-Rect16 autoMapBotPanelRect(autoMapBoxX,
- autoMapBoxY + autoMapTPHeight + autoMapMDHeight,
- autoMapBTWidth,
- autoMapBTHeight);
+static const StaticRect autoMapBotPanelRect = {
+ autoMapBoxX,
+ autoMapBoxY + autoMapTPHeight + autoMapMDHeight,
+ autoMapBTWidth,
+ autoMapBTHeight
+};
-Rect16 autoMapPanelRects[numAutoMapPanels] = { { autoMapTopPanelRect },
+static const StaticRect autoMapPanelRects[numAutoMapPanels] = {
+ { autoMapTopPanelRect },
{ autoMapMidPanelRect },
{ autoMapBotPanelRect }
};
@@ -123,8 +132,19 @@ const int16 scrollBtnWidth = 42;
const int16 scrollBtnHeight = 42;
-Rect16 closeAutoMapBtnRect(-1, 276, 42, 41);
-Rect16 scrollBtnRect(493, 275, scrollBtnWidth, scrollBtnHeight);
+static const StaticRect closeAutoMapBtnRect = {
+ -1,
+ 276,
+ 42,
+ 41
+};
+
+static const StaticRect scrollBtnRect = {
+ 493,
+ 275,
+ scrollBtnWidth,
+ scrollBtnHeight
+};
WindowDecoration autoMapDecorations[numAutoMapPanels] = {
diff --git a/engines/saga2/beegee.cpp b/engines/saga2/beegee.cpp
index b346879114..68867a85bc 100644
--- a/engines/saga2/beegee.cpp
+++ b/engines/saga2/beegee.cpp
@@ -44,15 +44,12 @@ struct auxAudioTheme {
bool active;
Location l;
soundSegment loopID;
-
- auxAudioTheme() {
- active = false;
- loopID = 0;
- l = Nowhere;
- }
};
-auxAudioTheme aats[AUXTHEMES];
+static auxAudioTheme aats[AUXTHEMES] = {
+ { false, Nowhere, 0 },
+ { false, Nowhere, 0 }
+};
void addAuxTheme(Location loc, soundSegment lid);
void killAuxTheme(soundSegment lid);
@@ -62,7 +59,8 @@ void killAllAuxThemes(void);
Constants
* ===================================================================== */
-const TilePoint AudibilityVector = TilePoint(1, 1, 0);
+const static StaticTilePoint AudibilityVector = { 1, 1, 0 };
+
const int32 checkGameTime = 1000;
/* ===================================================================== *
@@ -88,7 +86,7 @@ static Deejay grandMasterFTA;
static uint32 currentTheme = 0;
static uint32 auxTheme = 0;
-static Point32 themeAt;
+static StaticPoint32 themeAt = {0, 0};
static int32 lastGameTime = 0;
static int32 elapsedGameTime = 0;
@@ -98,7 +96,24 @@ static bool playingExternalLoop = false;
int activeFactions[maxFactions];
-TilePoint themeVectors[MaxThemes];
+static StaticTilePoint themeVectors[MaxThemes] = {
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0}
+};
@@ -189,19 +204,20 @@ void setAreaSound(const TilePoint &) {
Point32 themePos;
for (int r = 1; r < 5 && loopID == 0 ; r++) {
TileRegion regn;
- regn.max = baseCoords + ((AudibilityVector * r) << kPlatShift) ; ///kTileUVSize;
- regn.min = baseCoords - ((AudibilityVector * r) << kPlatShift); ///kTileUVSize;
+ TilePoint AudVec = TilePoint(AudibilityVector);
+ regn.max = baseCoords + ((AudVec * r) << kPlatShift) ; ///kTileUVSize;
+ regn.min = baseCoords - ((AudVec * r) << kPlatShift); ///kTileUVSize;
MetaTileIterator mIter(currentMapNum, regn);
int i = 0;
int j = 0;
- TilePoint dist = AudibilityVector * r << (kPlatShift + 1);
+ TilePoint dist = AudVec * r << (kPlatShift + 1);
dist = dist << 4;
themePos.x = dist.u;
themePos.y = dist.v;
MetaTilePtr mt = mIter.first(&mtPos);
for (i = 0; i < 16; i++) {
- themeVectors[i] = TilePoint(0, 0, 0);
+ themeVectors[i].set(0, 0, 0);
}
while (mt) {
i++;
@@ -259,7 +275,8 @@ void audioEnvironmentUseSet(int16 audioSet, int32 auxID, Point32 relPos) {
if (currentTheme != (uint16)audioSet || auxTheme != (uint32)auxID) {
currentTheme = audioSet;
auxTheme = auxID;
- themeAt = relPos;
+ themeAt.x = relPos.x;
+ themeAt.y = relPos.y;
_playLoop(0);
if (currentTheme)
playLoopAt(res, themeAt);
@@ -270,7 +287,8 @@ void audioEnvironmentUseSet(int16 audioSet, int32 auxID, Point32 relPos) {
WriteStatusF(9, "Thm: %2.2d (%d,%d) was (%d,%d) ", audioSet, relPos.x, relPos.y, themeAt.x, themeAt.y);
}
#endif
- themeAt = relPos;
+ themeAt.x = relPos.x;
+ themeAt.y = relPos.y;
moveLoop(themeAt);
}
}
diff --git a/engines/saga2/objproto.h b/engines/saga2/objproto.h
index de0cd01def..eaeeef9bc8 100644
--- a/engines/saga2/objproto.h
+++ b/engines/saga2/objproto.h
@@ -127,7 +127,7 @@ public:
context = con;
}
- Location(TilePoint p, ObjectID con) {
+ Location(TilePoint p, ObjectID con = 0) {
u = p.u;
v = p.v;
z = p.z;
diff --git a/engines/saga2/rect.h b/engines/saga2/rect.h
index 7784d70493..41ebe36bc7 100644
--- a/engines/saga2/rect.h
+++ b/engines/saga2/rect.h
@@ -139,6 +139,10 @@ typedef Point16 Extent16; // contains width and height
Point32: 32-bit 2-D point
* ===================================================================== */
+struct StaticPoint32 {
+ int32 x, y;
+};
+
class Point32 {
public:
int32 x, y;
@@ -177,6 +181,12 @@ public:
y = HIWORD(lparam);
}
#endif
+
+ Point32(StaticPoint32 p) {
+ x = p.x;
+ y = p.y;
+ }
+
// Point32 operators
friend Point32 operator+ (Point32 a, Point32 b) {
return Point32(a.x + b.x, a.y + b.y);
diff --git a/engines/saga2/tcoords.h b/engines/saga2/tcoords.h
index 7a251ff55a..f4fee90557 100644
--- a/engines/saga2/tcoords.h
+++ b/engines/saga2/tcoords.h
@@ -43,6 +43,15 @@ enum facingDirections {
};
typedef uint8 Direction;
+struct StaticTilePoint {
+ int16 u, v, z;
+
+ void set(int nu, int nv, int nz) {
+ u = nu;
+ v = nv;
+ z = nz;
+ }
+};
#include "common/pack-start.h"
struct TilePoint {
@@ -59,6 +68,11 @@ struct TilePoint {
TilePoint() { u = v = z = 0; }
TilePoint(int16 nu, int16 nv, int16 nz) { u = nu; v = nv; z = nz; }
TilePoint(Common::SeekableReadStream *stream);
+ TilePoint(StaticTilePoint p) {
+ u = p.u;
+ v = p.v;
+ z = p.z;
+ }
// TilePoint operators
friend TilePoint operator+ (TilePoint a, TilePoint b)
Commit: deb8ee29a4adac78026c080da517e7f3817f2625
https://github.com/scummvm/scummvm/commit/deb8ee29a4adac78026c080da517e7f3817f2625
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:39+02:00
Commit Message:
SAGA2: Remove global constructors in floating.cpp
Changed paths:
engines/saga2/floating.cpp
engines/saga2/floating.h
engines/saga2/rect.h
diff --git a/engines/saga2/floating.cpp b/engines/saga2/floating.cpp
index bd38e1d7af..c5483a83db 100644
--- a/engines/saga2/floating.cpp
+++ b/engines/saga2/floating.cpp
@@ -245,8 +245,8 @@ void BackWindow::toFront(void) {}
DragBar class member functions
* ===================================================================== */
-Point16 DragBar::dragOffset,
-DragBar::dragPos;
+StaticPoint16 DragBar::dragOffset = {0, 0};
+StaticPoint16 DragBar::dragPos = {0, 0};
bool DragBar::update;
FloatingWindow *DragBar::dragWindow;
@@ -267,7 +267,7 @@ bool DragBar::pointerHit(gPanelMessage &msg) {
dragPos.x = wExtent.x;
dragPos.y = wExtent.y;
- dragOffset = msg.pickAbsPos;
+ dragOffset.set(msg.pickAbsPos.x, msg.pickAbsPos.y);
return true;
}
@@ -287,7 +287,7 @@ void DragBar::pointerDrag(gPanelMessage &msg) {
// If window position has changed, then signal the drawing loop
if (pos != dragPos) {
- dragPos = pos;
+ dragPos.set(pos.x, pos.y);
update = true;
dragWindow = (FloatingWindow *)&window;
}
diff --git a/engines/saga2/floating.h b/engines/saga2/floating.h
index f10cdf60fb..19cf023aa4 100644
--- a/engines/saga2/floating.h
+++ b/engines/saga2/floating.h
@@ -87,8 +87,8 @@ class FloatingWindow;
class DragBar : public gControl {
public:
- static Point16 dragOffset, // mouse offset
- dragPos; // new position of window
+ static StaticPoint16 dragOffset, // mouse offset
+ dragPos; // new position of window
static bool update; // true = update window pos
static FloatingWindow *dragWindow; // which window to update
diff --git a/engines/saga2/rect.h b/engines/saga2/rect.h
index 41ebe36bc7..bafade9606 100644
--- a/engines/saga2/rect.h
+++ b/engines/saga2/rect.h
@@ -29,6 +29,15 @@
namespace Saga2 {
+struct StaticPoint16 {
+ int16 x, y;
+
+ void set(int16 nx, int16 ny) {
+ x = nx;
+ y = ny;
+ }
+};
+
class Point16 {
public:
int16 x, y;
@@ -58,6 +67,11 @@ public:
}
#endif
+ Point16(StaticPoint16 p) {
+ x = p.x;
+ y = p.y;
+ }
+
void load(Common::SeekableReadStream *stream);
// Point16 operators
Commit: e1b48b6215048cf662030d641f897048841e03ba
https://github.com/scummvm/scummvm/commit/e1b48b6215048cf662030d641f897048841e03ba
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:39+02:00
Commit Message:
SAGA2: Remove some global constructors in intrface.cpp
Changed paths:
engines/saga2/intrface.cpp
engines/saga2/uimetrcs.h
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index ea985d6ae1..f9bd5b4d12 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -256,37 +256,37 @@ bool userControlsSetup = false;
* ===================================================================== */
// position arrays for all buttons on the individual panels
-Rect16 topBox[numButtons] = {
- /* portrait */ Rect16(489, 22 + (yContOffset * 0), 65, 72),
- /* agress */ Rect16(559, 86 + (yContOffset * 0), 28, 27),
- /* jump */ Rect16(592, 86 + (yContOffset * 0), 28, 27),
- /* center */ Rect16(559, 56 + (yContOffset * 0), 28, 27),
- /* banding */ Rect16(592, 56 + (yContOffset * 0), 28, 27),
- /* namePlates */ Rect16(488, 94 + (yFaceOffset * 0), 65, 15),
- /* namePlateFrames */ Rect16(487, 20 + (yFaceOffset * 0), 69, 92)
+static const StaticRect topBox[numButtons] = {
+ /* portrait */ { 489, 22 + (yContOffset * 0), 65, 72 },
+ /* agress */ { 559, 86 + (yContOffset * 0), 28, 27 },
+ /* jump */ { 592, 86 + (yContOffset * 0), 28, 27 },
+ /* center */ { 559, 56 + (yContOffset * 0), 28, 27 },
+ /* banding */ { 592, 56 + (yContOffset * 0), 28, 27 },
+ /* namePlates */ { 488, 94 + (yFaceOffset * 0), 65, 15 },
+ /* namePlateFrames */ { 487, 20 + (yFaceOffset * 0), 69, 92 }
};
-Rect16 midBox[numButtons] = {
- Rect16(489, 22 + (yContOffset * 1), 65, 72),
- Rect16(559, 86 + (yContOffset * 1), 28, 27),
- Rect16(592, 86 + (yContOffset * 1), 28, 27),
- Rect16(559, 56 + (yContOffset * 1), 28, 27),
- Rect16(592, 56 + (yContOffset * 1), 28, 27),
- Rect16(488, 94 + (yFaceOffset * 1), 65, 15),
- Rect16(487, 20 + (yFaceOffset * 1), 69, 92)
+static const StaticRect midBox[numButtons] = {
+ { 489, 22 + (yContOffset * 1), 65, 72 },
+ { 559, 86 + (yContOffset * 1), 28, 27 },
+ { 592, 86 + (yContOffset * 1), 28, 27 },
+ { 559, 56 + (yContOffset * 1), 28, 27 },
+ { 592, 56 + (yContOffset * 1), 28, 27 },
+ { 488, 94 + (yFaceOffset * 1), 65, 15 },
+ { 487, 20 + (yFaceOffset * 1), 69, 92 }
};
-Rect16 botBox[numButtons] = {
- Rect16(489, 22 + (yContOffset * 2), 65, 72),
- Rect16(559, 86 + (yContOffset * 2), 28, 27),
- Rect16(592, 86 + (yContOffset * 2), 28, 27),
- Rect16(559, 56 + (yContOffset * 2), 28, 27),
- Rect16(592, 56 + (yContOffset * 2), 28, 27),
- Rect16(488, 94 + (yFaceOffset * 2), 65, 15),
- Rect16(487, 20 + (yFaceOffset * 2), 69, 92)
+static const StaticRect botBox[numButtons] = {
+ { 489, 22 + (yContOffset * 2), 65, 72 },
+ { 559, 86 + (yContOffset * 2), 28, 27 },
+ { 592, 86 + (yContOffset * 2), 28, 27 },
+ { 559, 56 + (yContOffset * 2), 28, 27 },
+ { 592, 56 + (yContOffset * 2), 28, 27 },
+ { 488, 94 + (yFaceOffset * 2), 65, 15 },
+ { 487, 20 + (yFaceOffset * 2), 69, 92 }
};
@@ -363,22 +363,22 @@ const uint32 containerGroupID = MKTAG('C', 'O', 'N', 'T');
// button position views
// topBox, midBox, and botBox are defined in uimetrcs.h
-Rect16 *views[] = { topBox, midBox, botBox };
+static const StaticRect *views[] = { topBox, midBox, botBox };
// individual indicators/buttons
-Rect16 menConBtnRect = Rect16(485, 265, 44, 43);
+static const StaticRect menConBtnRect = { 485, 265, 44, 43 };
// options button
-Rect16 optBtnRect = Rect16(20, 445, 26, 15);
+static const StaticRect optBtnRect = { 20, 445, 26, 15 };
// enchantment display
-Rect16 enchDispRect = Rect16(0, 0, 630, 18);
+static const StaticRect enchDispRect = { 0, 0, 630, 18 };
// brother buttons and frame
-Rect16 broBtnRect = Rect16(481, 450, 144, 11);
-Rect16 julBtnRect = Rect16(482, 451, 44, 9);
-Rect16 phiBtnRect = Rect16(531, 451, 44, 9);
-Rect16 kevBtnRect = Rect16(580, 451, 44, 9);
+static const StaticRect broBtnRect = { 481, 450, 144, 11 };
+static const StaticRect julBtnRect = { 482, 451, 44, 9 };
+static const StaticRect phiBtnRect = { 531, 451, 44, 9 };
+static const StaticRect kevBtnRect = { 580, 451, 44, 9 };
textPallete genericTextPal(9 + 15, 20, 14, 11, 23, 17);
diff --git a/engines/saga2/uimetrcs.h b/engines/saga2/uimetrcs.h
index 61497d94cc..ca53cf8030 100644
--- a/engines/saga2/uimetrcs.h
+++ b/engines/saga2/uimetrcs.h
@@ -47,10 +47,6 @@ const int backWidth = 42,
const int16 numButtons = 7;
const int16 yContOffset = 150;
-
-// position arrays for all buttons on the individual panels
-extern Rect16 topBox[], midBox[], botBox[];
-
// facial button position defines
const int16 yFaceOffset = 150;
Commit: c2af56f01275791c1c60b2afbc9ab581e9a7e2d2
https://github.com/scummvm/scummvm/commit/c2af56f01275791c1c60b2afbc9ab581e9a7e2d2
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:39+02:00
Commit Message:
SAGA2: Move appearanceLRU to Saga2Engine
Changed paths:
engines/saga2/saga2.h
engines/saga2/sprite.cpp
diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h
index d8f072a1d1..a563e12466 100644
--- a/engines/saga2/saga2.h
+++ b/engines/saga2/saga2.h
@@ -42,6 +42,7 @@ namespace Saga2 {
class Timer;
class TimerList;
class BandList;
+class ActorAppearance;
enum {
kDebugResources = 1 << 0,
@@ -93,6 +94,7 @@ public:
weaponID _loadedWeapons = 0;
Common::List<TimerList *> _timerLists;
Common::List<Timer *> _timers;
+ Common::List<ActorAppearance *> _appearanceLRU;
BandList *_bandList;
bool _autoAggression;
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index ff2d559aec..fd29f752d1 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -91,9 +91,6 @@ hResContext *spriteRes, // sprite resource handle
// An array of 32 actor appearances
static ActorAppearance appearanceTable[32];
-// A least-recently-used list of actor appearances
-static Common::List<ActorAppearance *> appearanceLRU;
-
/* ===================================================================== *
Quick memory routines
* ===================================================================== */
@@ -569,7 +566,7 @@ void ActorAppearance::loadSpriteBanks(int16 banksNeeded) {
WriteStatusF(2, "Loading Banks: %x", banksNeeded);
// Make this one the most recently used entry
- appearanceLRU.push_back(this);
+ g_vm->_appearanceLRU.push_back(this);
// Load in additional sprite banks if requested...
for (bank = 0; bank < (long)ARRAYSIZE(spriteBanks); bank++) {
@@ -639,7 +636,7 @@ ActorAppearance *LoadActorAppearance(uint32 id, int16 banksNeeded) {
// Search the table for either a matching appearance,
// or for an empty one.
- for (Common::List<ActorAppearance *>::iterator it = appearanceLRU.begin(); it != appearanceLRU.end(); ++it) {
+ for (Common::List<ActorAppearance *>::iterator it = g_vm->_appearanceLRU.begin(); it != g_vm->_appearanceLRU.end(); ++it) {
if ((*it)->id == id // If has same ID
&& (*it)->poseList != nullptr) { // and frames not dumped
// then use this one!
@@ -653,7 +650,7 @@ ActorAppearance *LoadActorAppearance(uint32 id, int16 banksNeeded) {
// empty one.
ActorAppearance *aa = nullptr;
// Search from LRU end of list.
- for (Common::List<ActorAppearance *>::iterator it = appearanceLRU.begin(); it != appearanceLRU.end(); ++it) {
+ for (Common::List<ActorAppearance *>::iterator it = g_vm->_appearanceLRU.begin(); it != g_vm->_appearanceLRU.end(); ++it) {
if ((*it)->useCount == 0) { // If not in use
aa = *it; // then use this one!
break;
@@ -849,7 +846,7 @@ void initSprites(void) {
ActorAppearance *aa = &appearanceTable[i];
aa->useCount = 0;
- appearanceLRU.push_front(aa);
+ g_vm->_appearanceLRU.push_front(aa);
}
}
Commit: d63e2c1ca5625db293812f4886d7574726946d02
https://github.com/scummvm/scummvm/commit/d63e2c1ca5625db293812f4886d7574726946d02
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:39+02:00
Commit Message:
SAGA2: Remove some global constructors in path.cpp
Changed paths:
engines/saga2/path.cpp
engines/saga2/saga2.h
engines/saga2/tcoords.h
diff --git a/engines/saga2/path.cpp b/engines/saga2/path.cpp
index 1d1100d09e..785e010f2c 100644
--- a/engines/saga2/path.cpp
+++ b/engines/saga2/path.cpp
@@ -82,37 +82,37 @@ const int subMetaSize = 4,
-static TilePoint tDirTable[8] = {
- TilePoint(4, 4, 0),
- TilePoint(0, 4, 0),
- TilePoint(-4, 4, 0),
- TilePoint(-4, 0, 0),
- TilePoint(-4, -4, 0),
- TilePoint(0, -4, 0),
- TilePoint(4, -4, 0),
- TilePoint(4, 0, 0)
+static StaticTilePoint tDirTable[8] = {
+ { 4, 4, 0},
+ { 0, 4, 0},
+ {-4, 4, 0},
+ {-4, 0, 0},
+ {-4, -4, 0},
+ { 0, -4, 0},
+ { 4, -4, 0},
+ { 4, 0, 0}
};
-static TilePoint tDirTable2[8] = {
- TilePoint(1, 1, 0),
- TilePoint(0, 1, 0),
- TilePoint(-1, 1, 0),
- TilePoint(-1, 0, 0),
- TilePoint(-1, -1, 0),
- TilePoint(0, -1, 0),
- TilePoint(1, -1, 0),
- TilePoint(1, 0, 0)
+static StaticTilePoint tDirTable2[8] = {
+ { 1, 1, 0},
+ { 0, 1, 0},
+ {-1, 1, 0},
+ {-1, 0, 0},
+ {-1, -1, 0},
+ { 0, -1, 0},
+ { 1, -1, 0},
+ { 1, 0, 0}
};
-static TilePoint tDirTable3[8] = {
- TilePoint(16, 16, 0),
- TilePoint(0, 16, 0),
- TilePoint(-16, 16, 0),
- TilePoint(-16, 0, 0),
- TilePoint(-16, -16, 0),
- TilePoint(0, -16, 0),
- TilePoint(16, -16, 0),
- TilePoint(16, 0, 0)
+static StaticTilePoint tDirTable3[8] = {
+ { 16, 16, 0},
+ { 0, 16, 0},
+ {-16, 16, 0},
+ {-16, 0, 0},
+ {-16, -16, 0},
+ { 0, -16, 0},
+ { 16, -16, 0},
+ { 16, 0, 0}
};
@@ -1078,10 +1078,10 @@ protected:
// These static members are initialized when the path request
// becomes the current active request being serviced.
- static TilePoint path[16];
+ static StaticTilePoint path[16];
static int16 pathLength;
- static TilePoint baseCoords,
+ static StaticTilePoint baseCoords,
baseTileCoords,
centerPt, // The current center coordinates
bestLoc; // The best cell coordinates,
@@ -1167,7 +1167,7 @@ protected:
// These static members are initialized when the path request
// becomes the current active request being serviced.
- static TilePoint targetCoords; // The current destination coordinates
+ static StaticTilePoint targetCoords; // The current destination coordinates
// quantized to the nearest tile
// center.
static uint8 targetPlatform;
@@ -1217,7 +1217,7 @@ protected:
// These static members are initialized when the path request
// becomes the current active request being serviced.
- static TilePoint startingCoords; // The actor's location at the
+ static StaticTilePoint startingCoords; // The actor's location at the
// beginning of the service.
static int16 bestDist, // The distance from the target of
// the best cell visited so far.
@@ -1257,9 +1257,6 @@ public:
Globals
* ===================================================================== */
-Common::List<WanderPathRequest *> pathRequestPool;
-
-Common::List<PathRequest *> pathQueue;
PathRequest *currentRequest = nullptr;
static PathTilePosArray *pathTileArray;
@@ -1280,13 +1277,13 @@ struct VolumeLookupNode {
static VolumeLookupNode volumeLookupNodePool[256];
static VolumeLookupNode *volumeLookupTable[searchDiameter][searchDiameter];
-TilePoint PathRequest::path[16];
+StaticTilePoint PathRequest::path[16] = {0, 0, 0};
int16 PathRequest::pathLength;
-TilePoint PathRequest::baseCoords,
- PathRequest::baseTileCoords,
- PathRequest::centerPt, // The current center coordinates
- PathRequest::bestLoc; // The best cell coordinates,
+StaticTilePoint PathRequest::baseCoords = {0, 0, 0},
+ PathRequest::baseTileCoords = {0, 0, 0},
+ PathRequest::centerPt = {0, 0, 0}, // The current center coordinates
+ PathRequest::bestLoc = {0, 0, 0}; // The best cell coordinates,
// currently visited
uint8 PathRequest::centerPlatform,
PathRequest::bestPlatform;
@@ -1300,12 +1297,12 @@ DirMaskGroup *PathRequest::dirMasks;
PathTileRegion PathRequest::tileArray;
-TilePoint DestinationPathRequest::targetCoords;
+StaticTilePoint DestinationPathRequest::targetCoords = {0, 0, 0};
uint8 DestinationPathRequest::targetPlatform;
int16 DestinationPathRequest::bestDist,
DestinationPathRequest::centerCost;
-TilePoint WanderPathRequest::startingCoords;
+StaticTilePoint WanderPathRequest::startingCoords = {0, 0, 0};
int16 WanderPathRequest::bestDist,
WanderPathRequest::centerCost;
@@ -1422,7 +1419,7 @@ void PathRequest::initialize(void) {
dirMasks = maskComp->computeMask(pCross);
// Set the best location to the starting location
- bestLoc = Nowhere;
+ bestLoc.set(Nowhere.u, Nowhere.v, Nowhere.z);
// Calculate where search cells will be projected onto map
baseTileCoords.u = (startingCoords.u >> kTileUVShift) - searchCenter;
@@ -1594,13 +1591,13 @@ big_break:
void PathRequest::finish(void) {
Direction prevDir;
int16 prevHeight;
- TilePoint *resultSteps = path,
+ StaticTilePoint *resultSteps = path,
coords;
int16 stepCount = 0;
- TilePoint *res;
+ StaticTilePoint *res;
PathCell *cell;
- static TilePoint tempResult[32];
+ static StaticTilePoint tempResult[32];
debugC(2, kDebugPath, "Finishing Path Request: %p", (void *)this);
@@ -1702,7 +1699,7 @@ PathResult PathRequest::findPath(void) {
assert(qi.v >= 1 && qi.v < searchDiameter - 1);
TilePoint centerTileCoords;
- TilePoint *tDir;
+ StaticTilePoint *tDir;
int32 i,
dir,
endDir;
@@ -2205,7 +2202,9 @@ void WanderPathRequest::initialize(void) {
// Initialize bestDist to zero.
bestDist = 0;
- startingCoords = actor->getLocation();
+ startingCoords.set(actor->getLocation().u,
+ actor->getLocation().v,
+ actor->getLocation().z);
}
@@ -2276,9 +2275,9 @@ int16 WanderPathRequest::evaluateMove(const TilePoint &testPt, uint8) {
}
void runPathFinder(void) {
- if (currentRequest == nullptr && !pathQueue.empty()) {
- currentRequest = pathQueue.front();
- pathQueue.pop_front();
+ if (currentRequest == nullptr && !g_vm->_pathQueue.empty()) {
+ currentRequest = g_vm->_pathQueue.front();
+ g_vm->_pathQueue.pop_front();
currentRequest->initialize();
}
@@ -2306,24 +2305,24 @@ void addPathRequestToQueue(PathRequest *pr) {
Actor *centerActor = getCenterActor();
if (a == centerActor)
- pathQueue.push_front(pr);
+ g_vm->_pathQueue.push_front(pr);
else {
if (isPlayerActor(a)) {
Common::List<PathRequest *>::iterator it;
- for (it = pathQueue.begin(); it != pathQueue.end(); it++) {
+ for (it = g_vm->_pathQueue.begin(); it != g_vm->_pathQueue.end(); it++) {
Actor *prActor = (*it)->actor;
if (prActor != centerActor || !isPlayerActor(prActor))
break;
}
- if (it != pathQueue.end())
- pathQueue.insert(it, pr);
+ if (it != g_vm->_pathQueue.end())
+ g_vm->_pathQueue.insert(it, pr);
else
- pathQueue.push_back(pr);
+ g_vm->_pathQueue.push_back(pr);
} else
- pathQueue.push_back(pr);
+ g_vm->_pathQueue.push_back(pr);
}
}
@@ -2350,7 +2349,7 @@ void abortPathFind(MotionTask *mTask) {
if (pr == currentRequest)
pr->requestAbort();
else
- pathQueue.remove(pr);
+ g_vm->_pathQueue.remove(pr);
mTask->pathFindTask = nullptr;
}
@@ -2524,7 +2523,7 @@ TilePoint selectNearbySite(
while (squeue.remove(qi)) {
TilePoint centerTileCoords,
distVector;
- TilePoint *tDir;
+ StaticTilePoint *tDir;
int16 dir;
int32 distFromCenter,
rating;
@@ -2799,7 +2798,7 @@ bool checkPath(
while (squeue.remove(qi)) {
TilePoint centerTileCoords;
- TilePoint *tDir;
+ StaticTilePoint *tDir;
int16 centerDistFromDest;
int dir;
diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h
index a563e12466..89afd7ee46 100644
--- a/engines/saga2/saga2.h
+++ b/engines/saga2/saga2.h
@@ -43,6 +43,7 @@ class Timer;
class TimerList;
class BandList;
class ActorAppearance;
+class PathRequest;
enum {
kDebugResources = 1 << 0,
@@ -95,8 +96,10 @@ public:
Common::List<TimerList *> _timerLists;
Common::List<Timer *> _timers;
Common::List<ActorAppearance *> _appearanceLRU;
+ Common::List<PathRequest *> _pathQueue;
BandList *_bandList;
+
bool _autoAggression;
bool _autoWeapon;
bool _showNight;
diff --git a/engines/saga2/tcoords.h b/engines/saga2/tcoords.h
index f4fee90557..113fbe7a2a 100644
--- a/engines/saga2/tcoords.h
+++ b/engines/saga2/tcoords.h
@@ -51,6 +51,39 @@ struct StaticTilePoint {
v = nv;
z = nz;
}
+
+ friend StaticTilePoint operator+(StaticTilePoint a, StaticTilePoint b) {
+ int16 nu = a.u + b.u;
+ int16 nv = a.v + b.v;
+ int16 nz = a.z + b.z;
+ StaticTilePoint p = {nu, nv, nz};
+
+ return p;
+ }
+
+ friend StaticTilePoint operator-(StaticTilePoint a, StaticTilePoint b) {
+ int16 nu = a.u - b.u;
+ int16 nv = a.v - b.v;
+ int16 nz = a.z - b.z;
+ StaticTilePoint p = {nu, nv, nz};
+
+ return p;
+ }
+
+ friend StaticTilePoint operator*(StaticTilePoint a, int b) {
+ int16 nu = a.u * b;
+ int16 nv = a.v * b;
+ int16 nz = a.z * b;
+ StaticTilePoint p = {nu, nv, nz};
+
+ return p;
+ }
+
+ void operator+=(StaticTilePoint a) {
+ u += a.u;
+ v += a.v;
+ z += a.z;
+ }
};
#include "common/pack-start.h"
Commit: 9d55dced8486ac7ad5ff1084bb1236aec255981d
https://github.com/scummvm/scummvm/commit/9d55dced8486ac7ad5ff1084bb1236aec255981d
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:39+02:00
Commit Message:
SAGA2: Fix code formatting for consistency
Changed paths:
engines/saga2/automap.cpp
engines/saga2/intrface.cpp
diff --git a/engines/saga2/automap.cpp b/engines/saga2/automap.cpp
index 1cc3432fd2..ba2dcb3326 100644
--- a/engines/saga2/automap.cpp
+++ b/engines/saga2/automap.cpp
@@ -132,12 +132,7 @@ const int16 scrollBtnWidth = 42;
const int16 scrollBtnHeight = 42;
-static const StaticRect closeAutoMapBtnRect = {
- -1,
- 276,
- 42,
- 41
-};
+static const StaticRect closeAutoMapBtnRect = {-1, 276, 42, 41};
static const StaticRect scrollBtnRect = {
493,
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index f9bd5b4d12..38fc78f85a 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -353,7 +353,8 @@ int16 namePlateResNum[] = { 8, 9, 10 };
int16 numNamePlateRes[] = { 1, 1, 1 };
// brother resource names
-ResName broNames[] = { { 'J', 'U', 'L', 0 },
+ResName broNames[] = {
+ { 'J', 'U', 'L', 0 },
{ 'P', 'H', 'I', 0 },
{ 'K', 'E', 'V', 0 }
};
@@ -363,22 +364,26 @@ const uint32 containerGroupID = MKTAG('C', 'O', 'N', 'T');
// button position views
// topBox, midBox, and botBox are defined in uimetrcs.h
-static const StaticRect *views[] = { topBox, midBox, botBox };
+static const StaticRect *views[] = {
+ { topBox },
+ { midBox },
+ { botBox }
+};
// individual indicators/buttons
-static const StaticRect menConBtnRect = { 485, 265, 44, 43 };
+static const StaticRect menConBtnRect = {485, 265, 44, 43};
// options button
-static const StaticRect optBtnRect = { 20, 445, 26, 15 };
+static const StaticRect optBtnRect = {20, 445, 26, 15};
// enchantment display
-static const StaticRect enchDispRect = { 0, 0, 630, 18 };
+static const StaticRect enchDispRect = {0, 0, 630, 18};
// brother buttons and frame
-static const StaticRect broBtnRect = { 481, 450, 144, 11 };
-static const StaticRect julBtnRect = { 482, 451, 44, 9 };
-static const StaticRect phiBtnRect = { 531, 451, 44, 9 };
-static const StaticRect kevBtnRect = { 580, 451, 44, 9 };
+static const StaticRect broBtnRect = {481, 450, 144, 11};
+static const StaticRect julBtnRect = {482, 451, 44, 9};
+static const StaticRect phiBtnRect = {531, 451, 44, 9};
+static const StaticRect kevBtnRect = {580, 451, 44, 9};
textPallete genericTextPal(9 + 15, 20, 14, 11, 23, 17);
Commit: cea3e83f72498e8e435c29d50ded5ea8990f2b73
https://github.com/scummvm/scummvm/commit/cea3e83f72498e8e435c29d50ded5ea8990f2b73
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:40+02:00
Commit Message:
SAGA2: Remove global constructors from msgbox.cpp
Changed paths:
engines/saga2/msgbox.cpp
diff --git a/engines/saga2/msgbox.cpp b/engines/saga2/msgbox.cpp
index b5541c487d..058be0741b 100644
--- a/engines/saga2/msgbox.cpp
+++ b/engines/saga2/msgbox.cpp
@@ -39,12 +39,13 @@ const int8 windowColor = 33 + 9;
const int8 buttonColor = 36 + 9;
const int numMessageBtns = 2;
-Rect16 mbWindowRect(70, 170, 500, 140);
+static const StaticRect mbWindowRect = {70, 170, 500, 140};
-const Rect16 mbOkBtnRect(100, 100, 100, 25);
-const Rect16 mbCancelBtnRect(300, 100, 100, 25);
-const Rect16 mbOneBtnRect(200, 100, 100, 25);
-const Rect16 mbButtonRects[numMessageBtns] = { { mbOkBtnRect },
+static const StaticRect mbOkBtnRect = {100, 100, 100, 25};
+static const StaticRect mbCancelBtnRect = {300, 100, 100, 25};
+static const StaticRect mbOneBtnRect = {200, 100, 100, 25};
+static const StaticRect mbButtonRects[numMessageBtns] = {
+ { mbOkBtnRect },
{ mbCancelBtnRect }
};
static gFont *mbButtonFont = &ThinFix8Font;
Commit: 2e4246faa34883bd225d4e05722aae83243c5d7d
https://github.com/scummvm/scummvm/commit/2e4246faa34883bd225d4e05722aae83243c5d7d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:40+02:00
Commit Message:
SAGA2: Print non-printables in debug messages
Changed paths:
engines/saga2/noise.cpp
engines/saga2/tile.cpp
diff --git a/engines/saga2/noise.cpp b/engines/saga2/noise.cpp
index 5db5f09d6d..5e70c65bfc 100644
--- a/engines/saga2/noise.cpp
+++ b/engines/saga2/noise.cpp
@@ -435,7 +435,7 @@ Point32 translateLocation(Location playAt) {
// MIDI playback
void playMusic(uint32 s) {
- debugC(1, kDebugSound, "playMusic(%s)", tag2str(s));
+ debugC(1, kDebugSound, "playMusic(%s)", tag2strP(s));
currentMidi = s;
@@ -449,7 +449,7 @@ void playMusic(uint32 s) {
// in memory sfx
void playMemSound(uint32 s) {
- debugC(1, kDebugSound, "playMemSound(%s)", tag2str(s));
+ debugC(1, kDebugSound, "playMemSound(%s)", tag2strP(s));
if (bufCheckResID(NULL, s))
audio->queueSound(s, memDec, 1, Here);
@@ -459,7 +459,7 @@ void playMemSound(uint32 s) {
// on disk sfx
void playSound(uint32 s) {
- debugC(1, kDebugSound, "playSound(%s)", tag2str(s));
+ debugC(1, kDebugSound, "playSound(%s)", tag2strP(s));
if (hResCheckResID(soundRes, s))
audio->queueSound(s, soundDec, 1, Here);
@@ -469,7 +469,7 @@ void playSound(uint32 s) {
// on disk sfx (x2 buffered)
void playLongSound(uint32 s) {
- debugC(1, kDebugSound, "playLongSound(%s)", tag2str(s));
+ debugC(1, kDebugSound, "playLongSound(%s)", tag2strP(s));
if (hResCheckResID(longRes, s))
audio->queueVoice(s, longSoundDec);
@@ -481,7 +481,7 @@ void playLongSound(uint32 s) {
// on disk voice (x2 buffered)
void playVoice(uint32 s) {
- debugC(1, kDebugSound, "playVoice(%s)", tag2str(s));
+ debugC(1, kDebugSound, "playVoice(%s)", tag2strP(s));
if (hResCheckResID(voiceRes, s)) {
if (s)
@@ -495,10 +495,10 @@ void playVoice(uint32 s) {
// supplemental interface for speech
bool sayVoice(uint32 s[]) {
- debugCN(1, kDebugSound, "sayVoice([%s", tag2str(s[0]));
+ debugCN(1, kDebugSound, "sayVoice([%s", tag2strP(s[0]));
for (uint32 i = 1; s[i]; i++)
- debugCN(1, kDebugSound, ", %s", tag2str(s[i]));
+ debugCN(1, kDebugSound, ", %s", tag2strP(s[i]));
debugC(1, kDebugSound, "])");
@@ -517,7 +517,7 @@ bool sayVoice(uint32 s[]) {
// main loop playback
void _playLoop(uint32 s) {
- warning("STUB: _playLoop(%s)", tag2str(s));
+ warning("STUB: _playLoop(%s)", tag2strP(s));
currentLoop = s;
if (currentLoop == audio->currentLoop() && 0)
@@ -551,7 +551,7 @@ void playLoop(uint32 s) {
// attenuated sound players
void playSoundAt(uint32 s, Point32 p) {
- debugC(1, kDebugSound, "playSoundAt(%s, %d,%d)", tag2str(s), p.x, p.y);
+ debugC(1, kDebugSound, "playSoundAt(%s, %d,%d)", tag2strP(s), p.x, p.y);
if (hResCheckResID(soundRes, s))
audio->queueSound(s, soundDec, 1, p);
@@ -569,10 +569,10 @@ void playSoundAt(uint32 s, Location playAt) {
Audio::SoundHandle _speechSoundHandle;
bool sayVoiceAt(uint32 s[], Point32 p) {
- debugCN(1, kDebugSound, "sayVoiceAt([%s", tag2str(s[0]));
+ debugCN(1, kDebugSound, "sayVoiceAt([%s", tag2strP(s[0]));
for (uint32 i = 1; s[i]; i++)
- debugCN(1, kDebugSound, ", %s", tag2str(s[i]));
+ debugCN(1, kDebugSound, ", %s", tag2strP(s[i]));
debugC(1, kDebugSound, "], %d,%d)", p.x, p.y);
@@ -592,7 +592,7 @@ bool sayVoiceAt(uint32 s[], Location playAt) {
// loop playback w/ attenuation
void playLoopAt(uint32 s, Point32 loc) {
- debugC(1, kDebugSound, "playLoopAt(%s, %d,%d)", tag2str(s), loc.x, loc.y);
+ debugC(1, kDebugSound, "playLoopAt(%s, %d,%d)", tag2strP(s), loc.x, loc.y);
if (hResCheckResID(loopRes, s))
audio->queueLoop(s, loopDec, 0, loc);
@@ -605,7 +605,7 @@ void killAuxTheme(soundSegment lid);
void killAllAuxThemes(void);
void playLoopAt(uint32 s, Location playAt) {
- debugC(1, kDebugSound, "playLoopAt(%s, %d,%d,%d)", tag2str(s), playAt.u, playAt.v, playAt.z);
+ debugC(1, kDebugSound, "playLoopAt(%s, %d,%d,%d)", tag2strP(s), playAt.u, playAt.v, playAt.z);
if (s) {
addAuxTheme(playAt, s);
@@ -632,7 +632,7 @@ void moveLoop(Location loc) {
// supplemental interface check for speech
bool stillDoingVoice(uint32 sampno) {
- warning("STUB: stillDoingVoice(%s)", tag2str(sampno));
+ warning("STUB: stillDoingVoice(%s)", tag2strP(sampno));
return audio->queue.isSpeechPlaying(sampno);
}
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 35fd73a59e..48b53202b5 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -1488,7 +1488,7 @@ void initMaps(void) {
for (worldCount = 0;
tileRes->seek(mapID + worldCount);
worldCount++) {
- warning("MapID: %s %08x res: %s %08x", tag2str(mapID), mapID, tag2str(mapID + worldCount), mapID + worldCount);
+ warning("MapID: %s %08x res: %s %08x", tag2strP(mapID), mapID, tag2strP(mapID + worldCount), mapID + worldCount);
}
// Allocate the map data array
Commit: 6aa642a54a27c1c9cc0d3908c9fa90fa145ad3bd
https://github.com/scummvm/scummvm/commit/6aa642a54a27c1c9cc0d3908c9fa90fa145ad3bd
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:40+02:00
Commit Message:
SAGA2: Remove commas at ends of enumerations
Changed paths:
engines/saga2/assign.h
engines/saga2/sensor.h
engines/saga2/setup.h
engines/saga2/stimtype.h
engines/saga2/task.h
diff --git a/engines/saga2/assign.h b/engines/saga2/assign.h
index 9db8e665a9..0f3d65e46c 100644
--- a/engines/saga2/assign.h
+++ b/engines/saga2/assign.h
@@ -42,7 +42,7 @@ enum AssignmentTypes {
huntToBeNearActorAssignment,
huntToKillAssignment,
tetheredWanderAssignment,
- attendAssignment,
+ attendAssignment
};
/* ===================================================================== *
@@ -118,7 +118,7 @@ class PatrolRouteAssignment : public ActorAssignment {
// assignment
enum {
- routeCompleted = (1 << 0),
+ routeCompleted = (1 << 0)
};
public:
@@ -235,7 +235,7 @@ class HuntToBeNearActorAssignment : public ActorAssignment {
uint8 flags;
enum {
- track = (1 << 0), // This hunt is a track.
+ track = (1 << 0) // This hunt is a track.
};
// An initialization function which provides a common ground for
@@ -317,7 +317,7 @@ class HuntToKillAssignment : public ActorAssignment {
enum {
track = (1 << 0), // This hunt is a track.
- specificActor = (1 << 1), // The actor target is a specific actor
+ specificActor = (1 << 1) // The actor target is a specific actor
};
// An initialization function which provides a common ground for
diff --git a/engines/saga2/sensor.h b/engines/saga2/sensor.h
index 829274dff2..f1ff981979 100644
--- a/engines/saga2/sensor.h
+++ b/engines/saga2/sensor.h
@@ -45,7 +45,7 @@ enum SensorType {
objectPropertySensor,
specificActorSensor,
actorPropertySensor,
- eventSensor,
+ eventSensor
};
// Sensors will be checked every 5 frames
diff --git a/engines/saga2/setup.h b/engines/saga2/setup.h
index abacbcccdb..5185f870f1 100644
--- a/engines/saga2/setup.h
+++ b/engines/saga2/setup.h
@@ -97,7 +97,7 @@ enum borderIDs {
MWLeftBorder,
MWRightBorder1,
MWRightBorder2,
- MWRightBorder3,
+ MWRightBorder3
};
extern WindowDecoration mainWindowDecorations[];
diff --git a/engines/saga2/stimtype.h b/engines/saga2/stimtype.h
index acc9514314..c954e53f26 100644
--- a/engines/saga2/stimtype.h
+++ b/engines/saga2/stimtype.h
@@ -88,7 +88,7 @@ enum stimuliTypes {
senseDidGive, // we gave something to protag
// Number of sensory types
- senseCount,
+ senseCount
};
diff --git a/engines/saga2/task.h b/engines/saga2/task.h
index d74c46356e..b2172a3914 100644
--- a/engines/saga2/task.h
+++ b/engines/saga2/task.h
@@ -55,11 +55,7 @@ enum TaskType {
bandTask,
bandAndAvoidEnemiesTask,
followPatrolRouteTask,
- attendTask,
-#if 0
- defendTask,
- parryTask,
-#endif
+ attendTask
};
/* ===================================================================== *
@@ -463,12 +459,12 @@ class GotoObjectTargetTask : public GotoTask {
enum {
track = (1 << 0),
- inSight = (1 << 1),
+ inSight = (1 << 1)
};
// static const doesn't work in Visual C++
enum {
- sightRate = 16,
+ sightRate = 16
};
// static const int16 sightRate = 16;
@@ -609,7 +605,7 @@ class GoAwayFromTask : public Task {
uint8 flags;
enum {
- run = (1 << 0),
+ run = (1 << 0)
};
public:
@@ -746,7 +742,7 @@ class HuntTask : public Task {
enum HuntFlags {
huntWander = (1 << 0), // Indicates that subtask is a wander task
- huntGoto = (1 << 1), // Indicates that subtask is a goto task
+ huntGoto = (1 << 1) // Indicates that subtask is a goto task
};
public:
@@ -843,7 +839,7 @@ class HuntToBeNearLocationTask : public HuntLocationTask {
// static const doesn't work in Visual C++
enum {
- targetEvaluateRate = 64,
+ targetEvaluateRate = 64
};
// static const uint8 targetEvaluateRate;
@@ -933,7 +929,7 @@ class HuntToBeNearObjectTask : public HuntObjectTask {
uint8 targetEvaluateCtr;
enum {
- targetEvaluateRate = 64,
+ targetEvaluateRate = 64
};
// static const uint8 targetEvaluateRate;
@@ -990,7 +986,7 @@ class HuntToPossessTask : public HuntObjectTask {
uint8 targetEvaluateCtr;
enum {
- targetEvaluateRate = 64,
+ targetEvaluateRate = 64
};
// static const uint8 targetEvaluateRate;
@@ -1042,7 +1038,7 @@ class HuntActorTask : public HuntTask {
uint8 flags;
enum {
- track = (1 << 0),
+ track = (1 << 0)
};
protected:
@@ -1090,14 +1086,14 @@ class HuntToBeNearActorTask : public HuntActorTask {
uint8 targetEvaluateCtr;
enum {
- targetEvaluateRate = 16,
+ targetEvaluateRate = 16
};
// static const uint8 targetEvaluateRate;
public:
enum {
- tooClose = 12,
+ tooClose = 12
};
// Constructor -- initial construction
@@ -1164,17 +1160,17 @@ class HuntToKillTask : public HuntActorTask {
uint8 specialAttackCtr;
enum {
- targetEvaluateRate = 16,
+ targetEvaluateRate = 16
};
enum {
- currentWeaponBonus = 1,
+ currentWeaponBonus = 1
};
uint8 flags;
enum {
- evalWeapon = (1 << 0),
+ evalWeapon = (1 << 0)
};
// static const uint8 targetEvaluateRate;
@@ -1281,7 +1277,7 @@ class BandTask : public HuntTask {
uint8 targetEvaluateCtr;
enum {
- targetEvaluateRate = 2,
+ targetEvaluateRate = 2
};
public:
@@ -1631,7 +1627,7 @@ class ParryTask : public Task {
enum {
motionStarted = (1 << 0),
- blockStarted = (1 << 1),
+ blockStarted = (1 << 1)
};
public:
Commit: 725f11ca60fe2c47105b50b186f8448c85c59acf
https://github.com/scummvm/scummvm/commit/725f11ca60fe2c47105b50b186f8448c85c59acf
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:40+02:00
Commit Message:
SAGA2: Fix more warnings with enumarations
Changed paths:
engines/saga2/actor.cpp
engines/saga2/actor.h
engines/saga2/button.h
engines/saga2/calender.h
engines/saga2/combat.h
engines/saga2/contain.h
engines/saga2/dispnode.h
engines/saga2/effects.h
engines/saga2/idtypes.h
engines/saga2/input.h
engines/saga2/intrface.h
engines/saga2/motion.h
engines/saga2/objects.h
engines/saga2/objproto.h
engines/saga2/player.h
engines/saga2/property.h
engines/saga2/saga2.cpp
engines/saga2/saga2.h
engines/saga2/script.h
engines/saga2/spells.h
engines/saga2/sprite.h
engines/saga2/target.h
engines/saga2/tile.h
engines/saga2/tileload.h
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 8dd9fd486e..1da601d558 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -654,7 +654,7 @@ bool ActorProto::acceptInsertionAtAction(
notInUse,
heldInLeftHand,
heldInRightHand,
- worn,
+ worn
} inUseType;
int wornWhere;
diff --git a/engines/saga2/actor.h b/engines/saga2/actor.h
index 2f8e2092cc..463b90327d 100644
--- a/engines/saga2/actor.h
+++ b/engines/saga2/actor.h
@@ -59,7 +59,7 @@ enum ActorSkillID {
skillIDPilfer, // gone
skillIDFirstAid, // gone
skillIDSpotHidden, // gone
- numSkills,
+ numSkills
};
enum ArmorObjectTypes {
@@ -98,11 +98,11 @@ struct ActorAttributes {
skillBasePercent = 100,
skillFracPointsPerLevel = 5, // this being twenty and levels at 5
skillLevels = 20, // will make the advancement calc quick & easy
- skillMaxLevel = skillFracPointsPerLevel * skillLevels,
+ skillMaxLevel = skillFracPointsPerLevel * skillLevels
};
enum vitalityInfo {
- vitalityLimit = 256,
+ vitalityLimit = 256
};
// Automatic skills
@@ -207,7 +207,7 @@ enum combatBehaviorTypes {
behaviorHungry,
behaviorCowardly,
behaviorBerserk,
- behaviorSmart,
+ behaviorSmart
};
// This defines the additional data fields needed for actor prototypes
@@ -263,7 +263,7 @@ private:
ViewableRows = 3,
ViewableCols = 3,
maxRows = 3,
- maxCols = 3,
+ maxCols = 3
};
public:
@@ -416,7 +416,7 @@ enum actionSequenceOptions {
// This flag gets set if the sprite could not be displayed
// because it's bank hasn't been loaded yet.
- animateNotLoaded = (1 << 7),
+ animateNotLoaded = (1 << 7)
};
// Various types of action sequences
@@ -497,7 +497,7 @@ enum ActorAnimationTypes {
actionSpecial5, // special Action
actionSpecial6, // special Action
actionSpecial7, // special Action
- actionSpecial8, // special Action
+ actionSpecial8 // special Action
};
enum ActorGoalTypes {
@@ -505,7 +505,7 @@ enum ActorGoalTypes {
actorGoalPreserveSelf,
actorGoalAttackEnemy,
actorGoalFollowLeader,
- actorGoalAvoidEnemies,
+ actorGoalAvoidEnemies
};
// The actor structure will be divided into two parts. The
@@ -616,7 +616,7 @@ public:
afraid = (1 << 2),
hasAssignment = (1 << 3),
specialAttack = (1 << 4),
- fightStance = (1 << 5),
+ fightStance = (1 << 5)
};
uint8 flags;
@@ -663,7 +663,7 @@ public:
int16 currentRecoveryPoints; // fraction left from last recovery
enum vitalityRecovery {
- recPointsPerVitality = 10,
+ recPointsPerVitality = 10
};
diff --git a/engines/saga2/button.h b/engines/saga2/button.h
index cfc8b6a98f..75c1a43db0 100644
--- a/engines/saga2/button.h
+++ b/engines/saga2/button.h
@@ -78,7 +78,7 @@ class gCompImage : public gControl {
private:
enum {
- textSize = 128,
+ textSize = 128
};
// number of image pointer allocated
diff --git a/engines/saga2/calender.h b/engines/saga2/calender.h
index d947fe5942..4e9d0b7356 100644
--- a/engines/saga2/calender.h
+++ b/engines/saga2/calender.h
@@ -50,8 +50,7 @@ public:
// Derived variables
framesPerHour = (framesPerDay / hoursPerDay),
- framesAtNoon = (framesPerDay / 2),
-
+ framesAtNoon = (framesPerDay / 2)
};
uint16 years,
diff --git a/engines/saga2/combat.h b/engines/saga2/combat.h
index cec659c735..fc34b58662 100644
--- a/engines/saga2/combat.h
+++ b/engines/saga2/combat.h
@@ -34,7 +34,7 @@ class Location;
enum weaponHitType {
hitMiss = 0,
hitShield,
- hitTarget,
+ hitTarget
};
//-----------------------------------------------------------------------
@@ -52,7 +52,7 @@ enum combatSound {
swordMetal,
whoosh1,
whoosh2,
- whoosh3,
+ whoosh3
};
diff --git a/engines/saga2/contain.h b/engines/saga2/contain.h
index 2687d705fe..39f4d02c13 100644
--- a/engines/saga2/contain.h
+++ b/engines/saga2/contain.h
@@ -73,7 +73,7 @@ protected:
enum imageData {
selectorX = 10,
- selectorY = 25,
+ selectorY = 25
};
public:
@@ -109,7 +109,7 @@ public:
// ID of the last object the mouse was on
enum {
bufSize = 60,
- accelSpeed = 8, // this tells the multi-item getting gadget how many items to grab per time unit
+ accelSpeed = 8 // this tells the multi-item getting gadget how many items to grab per time unit
};
static ObjectID lastPickedObjectID;
@@ -443,7 +443,7 @@ public:
actionUpdate = (1 << 0), // Refresh this window
actionDelete = (1 << 1), // Delete this window
actionHide = (1 << 2), // Refresh this window
- actionShow = (1 << 3), // Refresh this window
+ actionShow = (1 << 3) // Refresh this window
};
private:
diff --git a/engines/saga2/dispnode.h b/engines/saga2/dispnode.h
index 40aadc66e5..5fd8c4df94 100644
--- a/engines/saga2/dispnode.h
+++ b/engines/saga2/dispnode.h
@@ -39,7 +39,7 @@ class Effectron;
enum nodeType {
nodeTypeObject = 0,
- nodeTypeEffect,
+ nodeTypeEffect
};
@@ -58,7 +58,7 @@ private:
uint8 flags; // various flags
enum {
- displayIndicator = (1 << 0),
+ displayIndicator = (1 << 0)
};
public:
diff --git a/engines/saga2/effects.h b/engines/saga2/effects.h
index 0d651d7636..366df4ce6f 100644
--- a/engines/saga2/effects.h
+++ b/engines/saga2/effects.h
@@ -102,7 +102,7 @@ enum effectResistTypes {
// Physiological Damage
resistStarve = kDamageStarve,
// other
- resistEnergy = kDamageEnergy,
+ resistEnergy = kDamageEnergy
};
//
@@ -130,7 +130,7 @@ enum effectImmuneTypes {
// PhysiologiDamage
immuneStarve = resistStarve,
// other
- immuneEnergy = resistEnergy,
+ immuneEnergy = resistEnergy
};
//
@@ -175,15 +175,7 @@ enum effectOthersTypes {
actorNotDefenseless = 26, // forgo defenselessness check
actorDisappearOnDeath = 27, // gets deleted on death and spews inventory
// dead or moved flags
-// actorMapping =15, //
-// actorLandWalk =0 , // someone else had this I have no idea what it is
-// actorFloat =2 , // the creature can travel through malts shakes & sundaes
- actorWaterWalk, // can walk on water (same as float ?)
-// actorPanic =13, // creature takes off randomly
-// actorSpotHidden =17, // can see hidden
-// actorDetTraps =22, // traps glow green
-// actorFlameAura =23, // has a flaming aura
-// actorDead =25, // death spell
+ actorWaterWalk // can walk on water (same as float ?)
};
//
@@ -201,7 +193,7 @@ enum effectDrainsTypes {
drainsManaViolet,
drainsLifeLevel,
drainsVitality,
- drainsMoney,
+ drainsMoney
};
@@ -211,7 +203,7 @@ enum effectDrainsTypes {
enum effectTAGTypes {
settagLocked = 1,
- settagOpen = 2,
+ settagOpen = 2
};
@@ -220,7 +212,7 @@ enum effectTAGTypes {
//
enum effectLocationTypes {
- locateDummy = 1,
+ locateDummy = 1
};
enum objectFlags {
@@ -238,7 +230,7 @@ enum objectFlags {
objectAlias = (1 << 11), // object is not real, just a copy of another object
objectTriggeringTAG = (1 << 12), // object has triggerred TAG upon which it rests
objectOnScreen = (1 << 13), // object is on display list
- objectSightedByCenter = (1 << 14), // there is a line of sight to center actor
+ objectSightedByCenter = (1 << 14) // there is a line of sight to center actor
};
@@ -258,7 +250,7 @@ enum effectSpecialTypes {
specialCreateFWisp, // calls a saga function
specialCreateWraith, // calls a saga function
specialCreateFood, // calls a saga function
- specialRejoin,
+ specialRejoin
};
// ------------------------------------------------------------------
diff --git a/engines/saga2/idtypes.h b/engines/saga2/idtypes.h
index ac895a1711..d63eb286e3 100644
--- a/engines/saga2/idtypes.h
+++ b/engines/saga2/idtypes.h
@@ -194,7 +194,7 @@ extern const ActiveItemID NoActiveItem;
enum TaskResult {
taskFailed = -1, // Task has ended in failure
taskNotDone = 0, // Task has not ended yet
- taskSucceeded = 1, // Task has ended in success
+ taskSucceeded = 1 // Task has ended in success
};
typedef int16 TaskID;
diff --git a/engines/saga2/input.h b/engines/saga2/input.h
index 61ee551bf8..2b43cb5b7a 100644
--- a/engines/saga2/input.h
+++ b/engines/saga2/input.h
@@ -37,7 +37,7 @@ enum keyQualifiers {
qualifierAlt = (1 << 2),
// special qualifiers used internally
- spQualifierFunc = (1 << 7), // indicates function key
+ spQualifierFunc = (1 << 7) // indicates function key
};
const int homeKey = (0x47 << 8),
diff --git a/engines/saga2/intrface.h b/engines/saga2/intrface.h
index 059f559b71..3ac2cf91e7 100644
--- a/engines/saga2/intrface.h
+++ b/engines/saga2/intrface.h
@@ -311,8 +311,7 @@ private:
bulkPieXOffset = 53,
bulkPieYOffset = 9,
pieXSize = 28,
- pieYSize = 26,
-
+ pieYSize = 26
};
// xy positions of this indicator
@@ -383,7 +382,7 @@ public:
star6XSize = 36,
star6YSize = 35,
star7XSize = 46,
- star7YSize = 45,
+ star7YSize = 45
};
// sizes of the rings
@@ -401,7 +400,7 @@ public:
ring6XSize = 32,
ring6YSize = 31,
ring7XSize = 40,
- ring7YSize = 39,
+ ring7YSize = 39
};
// area of control
@@ -409,7 +408,7 @@ public:
x = 475,
y = 315,
xSize = 152,
- ySize = 135,
+ ySize = 135
};
// coordinates
@@ -419,7 +418,7 @@ public:
wellXSize = 108,
wellYSize = 123,
wellX = (xSize / 2 - wellXSize / 2) + 1,
- wellY = ySize / 2 - wellYSize / 2,
+ wellY = ySize / 2 - wellYSize / 2
};
// manas end points
@@ -439,7 +438,7 @@ public:
lowerMidX = 70 + xOffset,
lowerMidY = 135 + yOffset,
lowerRightX = 122 + xOffset,
- lowerRightY = 106 + yOffset,
+ lowerRightY = 106 + yOffset
};
enum manaEndCoords {
@@ -456,18 +455,18 @@ public:
violetEndX = lowerRightX, //d
violetEndY = lowerRightY, //e
numXYCoords = 12,
- numManaTypes = numXYCoords / 2,
+ numManaTypes = numXYCoords / 2
};
// mana star display offset from well center
enum startOffset {
- startOffset = 12,
+ startOffset = 12
};
// mana information
enum manainfo {
maxLevel = 200,
- numManaRegions = numManaTypes,
+ numManaRegions = numManaTypes
};
// resource data
@@ -476,7 +475,7 @@ public:
numRings = 7,
starResNum = 0,
ringResNum = 0,
- numManaColors = 13,
+ numManaColors = 13
};
// this describes a star
@@ -567,7 +566,7 @@ private:
starNum = 23,
starInitial = 0,
starLevels = 24,
- numControls = kNumViews,
+ numControls = kNumViews
};
enum {
@@ -579,7 +578,7 @@ private:
frameXPos = 571,
frameYPos = 20,
frameXSize = 32,
- frameYSize = 32,
+ frameYSize = 32
};
// resource handle
diff --git a/engines/saga2/motion.h b/engines/saga2/motion.h
index 6ff7a065f6..f7124eb259 100644
--- a/engines/saga2/motion.h
+++ b/engines/saga2/motion.h
@@ -53,12 +53,12 @@ enum MotionThreadReturnValues {
motionStarted, // The actor started moving.
motionCompleted, // The actor motion completed
// successfully.
- motionWalkBlocked, // The walk motion failed.
+ motionWalkBlocked // The walk motion failed.
};
enum {
moveWait = (1 << 0),
- moveRun = (1 << 1),
+ moveRun = (1 << 1)
};
/* ===================================================================== *
diff --git a/engines/saga2/objects.h b/engines/saga2/objects.h
index 7f3db7b893..f61d27b4c8 100644
--- a/engines/saga2/objects.h
+++ b/engines/saga2/objects.h
@@ -54,7 +54,7 @@ enum ActorManaID {
manaIDBlue,
manaIDViolet,
- numManas,
+ numManas
};
// Used to indicate if objects can be stacked or merged
@@ -168,7 +168,7 @@ private:
// container info
enum {
maxRow = 20,
- maxCol = 4,
+ maxCol = 4
};
public:
@@ -1326,7 +1326,7 @@ enum MissileFacings {
missileUpRtRt,
missileUpRt,
missileUpUpRt,
- missileNoFacing,
+ missileNoFacing
};
enum blockageType {
diff --git a/engines/saga2/objproto.h b/engines/saga2/objproto.h
index eaeeef9bc8..c841109590 100644
--- a/engines/saga2/objproto.h
+++ b/engines/saga2/objproto.h
@@ -340,7 +340,7 @@ private:
ViewableRows = 6,
ViewableCols = 4,
maxRows = 8,
- maxCols = 4,
+ maxCols = 4
};
public:
@@ -360,7 +360,7 @@ public:
isSpell = (1 << 11),
isSkill = (1 << 12),
isEnchantment = (1 << 13),
- isTargetable = (1 << 14),
+ isTargetable = (1 << 14)
};
// kludge: define earlier, incorrectly spelled names to correct spelling
@@ -371,7 +371,7 @@ public:
enum spriteTypes {
objOnGround = 0,
objInContainerView,
- objAsMousePtr,
+ objAsMousePtr
};
// Memeber functions
@@ -760,7 +760,7 @@ private:
ViewableRows = 4,
ViewableCols = 4,
maxRows = 8,
- maxCols = 4,
+ maxCols = 4
};
public:
@@ -915,7 +915,7 @@ class WeaponProto : public InventoryProto {
protected:
enum {
- inRangeRatingBonus = 4,
+ inRangeRatingBonus = 4
};
public:
diff --git a/engines/saga2/player.h b/engines/saga2/player.h
index 162198b3c2..280afeb30a 100644
--- a/engines/saga2/player.h
+++ b/engines/saga2/player.h
@@ -66,18 +66,18 @@ public:
enum PlayerActorFlags {
playerAggressive = (1 << 0), // Player is in aggressive mode
playerBanded = (1 << 1), // Player is banded
- playerHasCartography = (1 << 2), // Player has ability to map
+ playerHasCartography = (1 << 2) // Player has ability to map
};
// recovery information
enum Recovery {
baseManaRec = 1,
attribPointsPerUpdate = 1,
- attribPointsPerValue = 10,
+ attribPointsPerValue = 10
};
enum {
- vitalityLevelBump = 50,
+ vitalityLevelBump = 50
};
// Container node for ready containers
diff --git a/engines/saga2/property.h b/engines/saga2/property.h
index b36ba580f9..dcc33a6bbf 100644
--- a/engines/saga2/property.h
+++ b/engines/saga2/property.h
@@ -221,7 +221,7 @@ enum {
objPropIDPlayerActor,
objPropIDEnemy,
- objPropIDCount,
+ objPropIDCount
};
extern const ObjectProperty *objPropArray[objPropIDCount];
@@ -251,7 +251,7 @@ enum {
actorPropIDPlayerActor,
actorPropIDEnemy,
- actorPropIDCount,
+ actorPropIDCount
};
extern const ActorProperty *actorPropArray[actorPropIDCount];
@@ -276,7 +276,7 @@ typedef int16 TilePropertyID;
enum {
tilePropIDHasWater,
- tilePropIDCount,
+ tilePropIDCount
};
extern const TileProperty *tilePropArray[tilePropIDCount];
@@ -391,7 +391,7 @@ typedef int16 MetaTilePropertyID;
enum {
metaTilePropIDHasWater,
- metaTilePropIDCount,
+ metaTilePropIDCount
};
extern const MetaTileProperty *metaTilePropArray[metaTilePropIDCount];
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index cc28d714b1..c62ed3403d 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -60,6 +60,7 @@ Saga2Engine::Saga2Engine(OSystem *syst)
_bandList = nullptr;
_smkDecoder = nullptr;
_videoX = _videoY = 0;
+ _loadedWeapons = 0;
SearchMan.addSubDirectoryMatching(gameDataDir, "res");
diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h
index 89afd7ee46..858e39328c 100644
--- a/engines/saga2/saga2.h
+++ b/engines/saga2/saga2.h
@@ -92,7 +92,7 @@ public:
Common::RandomSource *_rnd;
WeaponStuff _weaponRack[kMaxWeapons];
- weaponID _loadedWeapons = 0;
+ weaponID _loadedWeapons;
Common::List<TimerList *> _timerLists;
Common::List<Timer *> _timers;
Common::List<ActorAppearance *> _appearanceLRU;
diff --git a/engines/saga2/script.h b/engines/saga2/script.h
index 764fa8c657..7732559f84 100644
--- a/engines/saga2/script.h
+++ b/engines/saga2/script.h
@@ -52,7 +52,7 @@ enum scriptResult {
scriptResultFinished,
// Script spun off as async thread; no answer available.
- scriptResultAsync,
+ scriptResultAsync
};
// Variables specific to a thread
@@ -101,7 +101,7 @@ enum {
// Code returned by script when requested action should complete
// the action
- actionResultNotDone,
+ actionResultNotDone
};
// Method used to refer to a SAGA object
@@ -118,7 +118,7 @@ enum builtinTypes {
builtinTypeObject = -1,
builtinTypeTAG = -2,
builtinAbstract = -3,
- builtinTypeMission = -4,
+ builtinTypeMission = -4
};
/* ===================================================================== *
@@ -207,7 +207,7 @@ public:
// run until it is finished or this bit
// is cleared
- asleep = (waiting | finished | aborted),
+ asleep = (waiting | finished | aborted)
};
int16 stackSize, // allocated size of stack
@@ -223,7 +223,7 @@ public:
waitDelay, // waiting for a timer
waitFrameDelay, // waiting for frame count
waitOther, // waiting for to be awoken
- waitTagSemaphore, // waiting for a tag semaphore
+ waitTagSemaphore // waiting for a tag semaphore
// waitSpeech, // waiting for speech to finish
// waitDialogEnd, // waiting for my dialog to finish
diff --git a/engines/saga2/spells.h b/engines/saga2/spells.h
index 40335b6ecd..bfeee7112f 100644
--- a/engines/saga2/spells.h
+++ b/engines/saga2/spells.h
@@ -143,7 +143,7 @@ enum SpellID {
spellMaelstrom,
spellDeath_Cloud,
spellVenom_Blast,
- totalSpellBookPages,
+ totalSpellBookPages
};
#define nullSpell ((SpellID)0xFF)
diff --git a/engines/saga2/sprite.h b/engines/saga2/sprite.h
index 7d84262138..ca8e7be838 100644
--- a/engines/saga2/sprite.h
+++ b/engines/saga2/sprite.h
@@ -120,7 +120,7 @@ struct ActorPose {
leftObjectInFront = (1 << 3), // left object in front of actor
rightObjectInFront = (1 << 4), // right object in front of actor
- leftOverRight = (1 << 5), // left in front of right
+ leftOverRight = (1 << 5) // left in front of right
};
uint16 flags; // sequence element flags
@@ -203,7 +203,7 @@ struct SpriteComponent {
enum spriteEffectFlags {
sprFXGhosted = (1 << 0), // semi-translucent dither
sprFXTerrainMask = (1 << 1), // mask sprite to terrain
- sprFXGhostIfObscured = (1 << 2), // apply ghosted effect if
+ sprFXGhostIfObscured = (1 << 2) // apply ghosted effect if
// obscured by terrain
};
@@ -242,7 +242,7 @@ enum spriteBankNums {
sprDnStairsBankNum,
sprSitBankNum,
- sprBankCount,
+ sprBankCount
};
enum spriteBankBits {
@@ -259,7 +259,7 @@ enum spriteBankBits {
sprPassiveBank = (1 << sprPassiveBankNum),
sprUpStairsBank = (1 << sprUpStairsBankNum),
sprDnStairsBank = (1 << sprDnStairsBankNum),
- sprSitBank = (1 << sprSitBankNum),
+ sprSitBank = (1 << sprSitBankNum)
};
// This structure is used to contain all of the items needed
diff --git a/engines/saga2/target.h b/engines/saga2/target.h
index 32959abaad..216099eb5d 100644
--- a/engines/saga2/target.h
+++ b/engines/saga2/target.h
@@ -44,7 +44,7 @@ enum TargetType {
specificObjectTarget,
objectPropertyTarget,
specificActorTarget,
- actorPropertyTarget,
+ actorPropertyTarget
};
/* ===================================================================== *
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index 9d4aafd081..9da34bfe90 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -129,7 +129,7 @@ enum tile_flags {
tileWalkSense = (1 << 2),
// Indicates that tile has been recently modified
- tileModified = (1 << 3),
+ tileModified = (1 << 3)
};
/* ===================================================================== *
@@ -156,7 +156,7 @@ enum terrainTypes {
terrNumIce,
terrNumCold,
terrNumHot,
- terrNumFurniture,
+ terrNumFurniture
};
enum terrainBits {
@@ -179,7 +179,7 @@ enum terrainBits {
terrainIce = (1 << terrNumIce),
terrainCold = (1 << terrNumCold),
terrainHot = (1 << terrNumHot),
- terrainFurniture = (1 << terrNumFurniture),
+ terrainFurniture = (1 << terrNumFurniture)
};
// A combination mask of all the terrain types which can have
@@ -341,7 +341,7 @@ const int maxCycleRanges = 128; // 128 should do for now...
enum ActiveItemTypes {
activeTypeGroup = 0,
- activeTypeInstance,
+ activeTypeInstance
};
// A pointer to the array of active item state arrays
@@ -396,7 +396,7 @@ public:
enum {
activeItemLocked = (1 << 8), // The door is locked
activeItemOpen = (1 << 9), // The door is open (not used)
- activeItemExclusive = (1 << 10), // Script semaphore
+ activeItemExclusive = (1 << 10) // Script semaphore
};
ActiveItem(ActiveItemList *parent, int ind, Common::SeekableReadStream *stream);
@@ -423,7 +423,7 @@ public:
builtInNone = 0, // TAG handled by SAGA
builtInLamp, // TAG has lamp behavior
builtInDoor, // TAG has door behavior
- builtInTransporter, // TAG has transporter behavior
+ builtInTransporter // TAG has transporter behavior
};
// Return the state number of this active item instance
@@ -580,7 +580,7 @@ class TileActivityTask {
activityTypeOpen, // open door
activityTypeClose, // close door
- activityTypeScript, // scriptable activity
+ activityTypeScript // scriptable activity
};
void remove(void); // tile activity task is finished.
@@ -726,9 +726,7 @@ enum platformFlags {
plCutUPos = (1 << 13),
plCutUNeg = (1 << 13),
plCutVPos = (1 << 13),
- plCutVNeg = (1 << 13),
-
-
+ plCutVNeg = (1 << 13)
};
#if OLDPLATFLAAGS
@@ -744,7 +742,7 @@ enum platformFlags {
plCutVNeg = (1 << 4),
plVisible = (1 << 5), // platform is visible
- plEnabled = (1 << 6), // enforce platform terrain.
+ plEnabled = (1 << 6) // enforce platform terrain.
};
#endif
@@ -863,7 +861,7 @@ enum mapEdgeTypes {
edgeTypeFill0,
edgeTypeFill1,
edgeTypeRepeat,
- edgeTypeWrap,
+ edgeTypeWrap
};
typedef MapHeader *MapPtr,
diff --git a/engines/saga2/tileload.h b/engines/saga2/tileload.h
index e4ebca9667..4953644482 100644
--- a/engines/saga2/tileload.h
+++ b/engines/saga2/tileload.h
@@ -137,7 +137,7 @@ public:
template<int size> class FixedBitArray {
private:
enum {
- lWords = ((size + 31) / 32),
+ lWords = ((size + 31) / 32)
};
int16 WORDNUM(int n) {
Commit: dab42f94f2c90c24c01361cf40ea693ea072e0e4
https://github.com/scummvm/scummvm/commit/dab42f94f2c90c24c01361cf40ea693ea072e0e4
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:40+02:00
Commit Message:
SAGA2: Remove test-purposes code
Changed paths:
engines/saga2/main.cpp
engines/saga2/saga2.cpp
engines/saga2/tile.cpp
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 4e4c4b192b..1d18377bd9 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -57,7 +57,6 @@ namespace Saga2 {
// enable the following to display event loop processing
#define DEBUG_LOOP 0
-extern WindowDecoration autoMapDecorations[];
extern gToolBase G_BASE;
extern char *gameTimeStr;
extern bool underground;
@@ -183,8 +182,6 @@ int16 OptionsDialog(bool disableSaveResume = false);
static void mainLoop(bool &cleanExit, int argc, char *argv[]);
void displayUpdate(void);
-void testTiles();
-
bool initResourceHandles();
bool initDisplayPort();
bool initPanelSystem();
@@ -594,42 +591,6 @@ bool openResources(void) {
}
-void testOpenImage() {
- hResContext *decRes;
-
- decRes = resFile->newContext(MKTAG('A', 'M', 'A', 'P'), "Automap Resources");
- //checkAlloc(summaryData = LoadResource(decRes,
- // MKTAG('S', 'U', 'M', currentMapNum),
- // "summary data"));
-
- WindowDecoration *dec = &autoMapDecorations[0];
- dec->image = LoadResource(decRes, MKTAG('M', 'A', 'P', 0), "MAP0");
- //dec->image = ImageCache.requestImage(decRes, MKTAG('M', 'A', 'P', 0) | MKTAG('B', 'R', 'D', dec->imageNumber));
- Point16 pos(0, 0);
- drawCompressedImage(mainPort, pos, dec->image);
-}
-
-void testScripts() {
- scriptCallFrame scf;
- //for (int i = 1; i < 100; ++i)
- // runScript(i, scf);
- runScript(1, scf);
-}
-
-void testTileRendering() {
- tileRes = resFile->newContext(MKTAG('T', 'I', 'L', 'E'), "tile resources");
- listRes = objResFile->newContext(MKTAG('L', 'I', 'S', 'T'), "list resources");
- resImports = (ResImportTable *)LoadResource(listRes, MKTAG('I', 'M', 'P', 'O'), "res imports");
-
- initResourceHandles();
- mainPort.setDisplayPage(&protoPage);
- initPanelSystem();
- initDisplayPort();
- initDisplay();
- initGameMaps();
- testTiles();
-}
-
//-----------------------------------------------------------------------
// Routine to cleanup all the resource files
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index c62ed3403d..c1ae34e31c 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -39,11 +39,6 @@
namespace Saga2 {
-void testTileRendering();
-void testScripts();
-void initScripts();
-void testOpenImage();
-bool openResources();
void main_saga2();
Saga2Engine *g_vm;
@@ -86,24 +81,6 @@ Common::Error Saga2Engine::run() {
main_saga2();
-#if 0
- if (openResources()) {
- testOpenImage();
- initScripts();
- testScripts();
- testTileRendering();
- }
-
- // Simple main event loop
- Common::Event evt;
- while (!shouldQuit()) {
- g_system->getEventManager()->pollEvent(evt);
-
- g_system->updateScreen();
- g_system->delayMillis(10);
- }
-#endif
-
return Common::kNoError;
}
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 48b53202b5..f40f4e7c19 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -4683,51 +4683,6 @@ void updateMainDisplay(void) {
cycleTiles(deltaTime);
}
-void testTiles() {
- //initBackPanel();
- //initMaps();
- initTileCyclingStates();
-
- setCurrentMap(0);
- PlayModeSetup();
-
- //buildRoofTable();
- //buildDisplayList();
-
- // draws tiles to tileDrawMap.data
- drawMetaTiles();
-
- //uint8 *img = (uint8*)mapList[0].map->mapData;
- //int16 size = mapList[0].map->size;
- uint8 *img = tileDrawMap.data;
- Point16 size = tileDrawMap.size;
- debugC(3, kDebugTiles, "img = %p, size = %d,%d", (void *)img, size.x, size.y);
- //Common::hexdump(img, size*size);
-
- Graphics::Surface sur;
- sur.create(size.x, size.y, Graphics::PixelFormat::createFormatCLUT8());
- sur.setPixels(img);
- sur.debugPrint();
- g_system->copyRectToScreen(sur.getPixels(), sur.pitch, 0, 0, sur.w, sur.h);
-
- // Draw sprites onto back buffer
- //drawDisplayList();
-
- // Render the image of the mouse pointer on everything else
- //drawTileMousePointer();
-
- // Blit it all onto the screen
- //drawPage->writePixels(
- // tileRect,
- // tileDrawMap.data
- // + fineScroll.x
- // + fineScroll.y * tileDrawMap.size.x,
- // tileDrawMap.size.x);
-
- cleanupTileCyclingStates();
- cleanupMaps();
-}
-
void drawMainDisplay(void) {
Commit: 408bd41daf2b2224fb40a8cd540d2942e3ab73df
https://github.com/scummvm/scummvm/commit/408bd41daf2b2224fb40a8cd540d2942e3ab73df
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:40+02:00
Commit Message:
SAGA2: Fix more enum warnings
Changed paths:
engines/saga2/actor.h
engines/saga2/audiobuf.h
engines/saga2/audiodec.h
engines/saga2/audiosmp.h
engines/saga2/audiosys.h
engines/saga2/audqueue.h
engines/saga2/grabinfo.h
diff --git a/engines/saga2/actor.h b/engines/saga2/actor.h
index 463b90327d..bca566b370 100644
--- a/engines/saga2/actor.h
+++ b/engines/saga2/actor.h
@@ -387,7 +387,7 @@ public:
* ============================================================================ */
enum actorCreationFlags {
- actorPermanent = (1 << 0),
+ actorPermanent = (1 << 0)
};
enum DispositionType {
diff --git a/engines/saga2/audiobuf.h b/engines/saga2/audiobuf.h
index 6ff21bffa5..188ee9c5a0 100644
--- a/engines/saga2/audiobuf.h
+++ b/engines/saga2/audiobuf.h
@@ -57,7 +57,7 @@ enum soundBufferStatus {
bufferFull, // buffer is full & ready to go
bufferPlay, // buffer is playing
bufferWork, // indicates a permanent work buffer
- bufferUsed,
+ bufferUsed
};
diff --git a/engines/saga2/audiodec.h b/engines/saga2/audiodec.h
index 79e3ddcfce..4e1ae8f16e 100644
--- a/engines/saga2/audiodec.h
+++ b/engines/saga2/audiodec.h
@@ -61,7 +61,7 @@ class soundQueue;
enum soundDecoderType {
decodeInPlace,
decodeBuffer,
- decodeSource,
+ decodeSource
};
/* ===================================================================== *
@@ -124,7 +124,7 @@ enum decoderStatuses {
msgSamplePause = 1 << 3, // partial load - continue next time
msgSampleDone = 1 << 4, // sample complete
msgWaitForBuffer = 1 << 5, // waiting for free buffer
- msgIOError = 1 << 6, // an I/O error occurred reading the file
+ msgIOError = 1 << 6 // an I/O error occurred reading the file
};
class soundDecoder {
diff --git a/engines/saga2/audiosmp.h b/engines/saga2/audiosmp.h
index 5e4c882d85..a775948595 100644
--- a/engines/saga2/audiosmp.h
+++ b/engines/saga2/audiosmp.h
@@ -57,7 +57,7 @@ typedef Point32 sampleLocation;
enum soundSampleRate {
soundRate11K = 11025,
soundRate22K = 22050,
- soundRate44K = 44100,
+ soundRate44K = 44100
};
@@ -70,19 +70,19 @@ public:
sampleStop,
samplePart,
sampleDone,
- sampleKill,
+ sampleKill
};
enum soundSampleChannels {
channelMono,
channelStereo,
channelLeftOnly,
- channelRightOnly,
+ channelRightOnly
};
enum soundSampleGranularity {
granularity8Bit,
- granularity16Bit,
+ granularity16Bit
};
@@ -90,7 +90,7 @@ public:
enum soundSampleFlags {
sampleLooped = 0x0001,
sampleSigned = 0x0002,
- sampleRvrsed = 0x0004,
+ sampleRvrsed = 0x0004
};
private:
bool initialized;
diff --git a/engines/saga2/audiosys.h b/engines/saga2/audiosys.h
index c3bae45be2..5d8401ca87 100644
--- a/engines/saga2/audiosys.h
+++ b/engines/saga2/audiosys.h
@@ -82,12 +82,12 @@ enum volumeTarget {
volVLandM, // voice loops and music
volAll, // all four
volSoundMaster = 1L << 4, // master sound volume level
- volMusicMaster = 1L << 5, // master music volume level
+ volMusicMaster = 1L << 5 // master music volume level
};
enum volumeMode {
volumeSetTo = 0L, // absolute mode
- volumeUpDown, // relative mode
+ volumeUpDown // relative mode
};
/*******************************************************************/
@@ -143,21 +143,21 @@ public:
requestSound2 = 6L,
maxBuffers = 7L,
requestMusic = 8L,
- requestSound = 9L,
+ requestSound = 9L
};
private:
enum sampleFlags {
sampleClear = 0L,
sampleMoving = 1L << 0,
- sampleQueued = 1L << 1,
+ sampleQueued = 1L << 1
};
enum sampleStopLevel {
sStopCleanup = 0L,
sStopSegment = 1L,
sStopSample = 2L,
- sStopQueue = 3L,
+ sStopQueue = 3L
};
enum queueFlags {
@@ -169,7 +169,7 @@ private:
qrPlayDone = 5L,
qrFinishing = 6L,
qrFinished = 7L,
- qrCleanup = 8L,
+ qrCleanup = 8L
};
int16 instance;
diff --git a/engines/saga2/audqueue.h b/engines/saga2/audqueue.h
index 03d70dab8d..8466f3796f 100644
--- a/engines/saga2/audqueue.h
+++ b/engines/saga2/audqueue.h
@@ -48,9 +48,13 @@ private:
Audio::SoundHandle _sfxSoundHandle;
Audio::SoundHandle _bgmSoundHandle;
- soundSegment _currentSpeech = 0;
+ soundSegment _currentSpeech;
public:
+ SoundQueue() {
+ _currentSpeech = 0;
+ }
+
void pushVoice(soundSegment s) {
_speechQueue.push(s);
}
diff --git a/engines/saga2/grabinfo.h b/engines/saga2/grabinfo.h
index e46494cc09..dc015404fd 100644
--- a/engines/saga2/grabinfo.h
+++ b/engines/saga2/grabinfo.h
@@ -53,7 +53,7 @@ public:
private:
enum {
- bufSize = 60,
+ bufSize = 60
};
protected:
Commit: 50a0807d2f7051d369d1d30a7bf9422a89d6ae03
https://github.com/scummvm/scummvm/commit/50a0807d2f7051d369d1d30a7bf9422a89d6ae03
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:40+02:00
Commit Message:
SAGA2: Fix automap panel initalization
Changed paths:
engines/saga2/automap.cpp
diff --git a/engines/saga2/automap.cpp b/engines/saga2/automap.cpp
index ba2dcb3326..531dd7c551 100644
--- a/engines/saga2/automap.cpp
+++ b/engines/saga2/automap.cpp
@@ -121,10 +121,10 @@ static const StaticRect autoMapBotPanelRect = {
};
-static const StaticRect autoMapPanelRects[numAutoMapPanels] = {
- { autoMapTopPanelRect },
- { autoMapMidPanelRect },
- { autoMapBotPanelRect }
+static const StaticRect *autoMapPanelRects[numAutoMapPanels] = {
+ &autoMapTopPanelRect,
+ &autoMapMidPanelRect,
+ &autoMapBotPanelRect
};
@@ -143,9 +143,9 @@ static const StaticRect scrollBtnRect = {
WindowDecoration autoMapDecorations[numAutoMapPanels] = {
- { WindowDecoration(autoMapPanelRects[0], autoMapTopPanelResID) },
- { WindowDecoration(autoMapPanelRects[1], autoMapMidPanelResID) },
- { WindowDecoration(autoMapPanelRects[2], autoMapBotPanelResID) }
+ { WindowDecoration(*autoMapPanelRects[0], autoMapTopPanelResID) },
+ { WindowDecoration(*autoMapPanelRects[1], autoMapMidPanelResID) },
+ { WindowDecoration(*autoMapPanelRects[2], autoMapBotPanelResID) }
};
Commit: 6179f9fac5bbc0dcf6eaac47189e5da40957b7ea
https://github.com/scummvm/scummvm/commit/6179f9fac5bbc0dcf6eaac47189e5da40957b7ea
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:40+02:00
Commit Message:
SAGA2: Fix global constructor warnings on noise.cpp
Changed paths:
engines/saga2/noise.cpp
diff --git a/engines/saga2/noise.cpp b/engines/saga2/noise.cpp
index 5e70c65bfc..d3a97c72f6 100644
--- a/engines/saga2/noise.cpp
+++ b/engines/saga2/noise.cpp
@@ -48,7 +48,7 @@ namespace Saga2 {
#define AUDIO_REFRESH_RATE 5
-Point32 VeryFarAway = Point32(32767, 32766);
+static const StaticPoint32 VeryFarAway = {32767, 32766};
const uint32 fullVolumeDist = 75;
const uint32 offVolumeDist = 200;
@@ -566,8 +566,6 @@ void playSoundAt(uint32 s, Location playAt) {
//-----------------------------------------------------------------------
// voice playback w/ attenuation
-Audio::SoundHandle _speechSoundHandle;
-
bool sayVoiceAt(uint32 s[], Point32 p) {
debugCN(1, kDebugSound, "sayVoiceAt([%s", tag2strP(s[0]));
Commit: a79b1379e4b3db98a85a03d4b3be5abb1f6910e6
https://github.com/scummvm/scummvm/commit/a79b1379e4b3db98a85a03d4b3be5abb1f6910e6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:40+02:00
Commit Message:
SAGA2: Fix more warnings
Changed paths:
engines/saga2/actor.cpp
engines/saga2/audtweak.h
engines/saga2/code.h
engines/saga2/display.h
engines/saga2/dispnode.cpp
engines/saga2/document.cpp
engines/saga2/enchant.h
engines/saga2/speldefs.h
engines/saga2/spellbuk.h
engines/saga2/spelshow.h
engines/saga2/uidialog.h
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 1da601d558..e9a1b5134b 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -2813,7 +2813,7 @@ void Actor::handleSuccessfulKill(Actor *target) {
bool Actor::canBlockWith(GameObject *defenseObj, Direction relativeDir) {
assert(defenseObj->proto()->canBlock());
- assert(relativeDir >= 0 && relativeDir < 8);
+ assert(relativeDir < 8);
// Assuming that the actor may increment or decrement their facing
// to block, these masks represent the possible relative facings
diff --git a/engines/saga2/audtweak.h b/engines/saga2/audtweak.h
index bbcc0e16b2..cf8cdf07cc 100644
--- a/engines/saga2/audtweak.h
+++ b/engines/saga2/audtweak.h
@@ -40,7 +40,7 @@ enum audioTerrains {
audioTerrainRiver,
audioTerrainFire,
- audioTerrainLIMIT,
+ audioTerrainLIMIT
};
struct IntermittentAudioRecord {
diff --git a/engines/saga2/code.h b/engines/saga2/code.h
index 7219202184..d60375c22f 100644
--- a/engines/saga2/code.h
+++ b/engines/saga2/code.h
@@ -194,10 +194,6 @@ enum op_types {
op_jmp_seedrandom, // seeded random jump
op_symref_x, // get the export number of the symbol
-#if 0
- op_type,
-#endif
-
op_last /* about 90 so far */
};
@@ -254,14 +250,7 @@ enum addr_types {
// specified that the address is relative to whatever
// object the 1st argument is referrring to.
- addr_this, // relative to arg 1
-
-// addr_common=0, // offset from global variables
-// addr_static, // offset from global variables
-
-// addr_id, // offset from const id object
-// addr_id_indirect, // offset from stack id object
-// addr_index, // index from id
+ addr_this // relative to arg 1
};
#define IS_CONST(x) ((x) >= op_constint && (x) <= op_conststr)
@@ -274,41 +263,6 @@ enum addr_types {
// #define IS_UNOP2(x) ((x) == op_getarray || (x) == op_putarray)
// #define CONST(op) ((op) >= op_constflag && (op) <= op_conststr)
-#if 0
-op_conststr, // constant string
-/* we would need an array ref for each type of thing we get,
- as well as a way to get the array base...
- (I.e. pointer math)
-*/
-op_getarray, /* arrays not supported currently */
-op_putarray,
-
-operands we need to add:
-op_select implements selection statement
-op_bin2str binary to string
-op_fork might have to be done in - language so debugger works ?
-op_foreach implements "foreach"
-
-op_t, fast true and false
-op_f,
-
-- - also need to change statement producer to "drop" top of stack
-if necessary.
-
-op_min, /* comparison opcodes */
-op_max,
-op_clamp,
-op_abs,
-
-op_dropn, /* drop n stack locations */
-op_swap, /* swap s[0] and s[1] */
-op_swap2, /* transpose s[0] and s[2] */
-op_dupn, /* duplicate s[0]-s[n-1] */
-
-op_acalc, /* array calculation */
-op_field, /* field reference */
-#endif
-
// Flags for special statements
#define SPEAKF_NOANIMATE (1<<0) // speaker should animate
diff --git a/engines/saga2/display.h b/engines/saga2/display.h
index 17e3f605ee..715acd6030 100644
--- a/engines/saga2/display.h
+++ b/engines/saga2/display.h
@@ -38,13 +38,7 @@ enum DisplayDisabledBecause {
PlayingVideo = 1 << 1,
GraphicsInit = 1 << 2,
GameSuspended = 1 << 3,
- GameEnded = 1 << 4,
-#ifdef _WIN32
- WindowInactive = 1 << 8,
- WindowResizing = 1 << 9,
- TimerSuspended = 1 << 10,
- WindowReresing = 1 << 11,
-#endif
+ GameEnded = 1 << 4
};
/* ===================================================================== *
diff --git a/engines/saga2/dispnode.cpp b/engines/saga2/dispnode.cpp
index 863504632e..cc31d73293 100644
--- a/engines/saga2/dispnode.cpp
+++ b/engines/saga2/dispnode.cpp
@@ -582,11 +582,8 @@ void DisplayNode::drawObject(void) {
if (anim == nullptr)
return;
- assert(anim->start[0] >= 0);
assert(anim->start[0] < 10000);
- assert(anim->start[1] >= 0);
assert(anim->start[1] < 10000);
- assert(anim->start[2] >= 0);
assert(anim->start[2] < 10000);
assert(pose->rightObjectOffset.x < 1000);
diff --git a/engines/saga2/document.cpp b/engines/saga2/document.cpp
index 934e114909..271d0836b6 100644
--- a/engines/saga2/document.cpp
+++ b/engines/saga2/document.cpp
@@ -789,7 +789,7 @@ void CDocument::renderText(void) {
}
for (; lineIndex < numLines[pageIndex]; lineIndex++) {
- assert(pageIndex <= maxPages && pageIndex >= 0);
+ assert(pageIndex <= maxPages);
tPort.moveTo(pageRect->x, pageRect->y + (textHeight * lineIndex) + 1);
tPort.setColor(app.textColors[lineIndex]);
diff --git a/engines/saga2/enchant.h b/engines/saga2/enchant.h
index 141b880365..9c7eb4157f 100644
--- a/engines/saga2/enchant.h
+++ b/engines/saga2/enchant.h
@@ -84,7 +84,7 @@ enum actorEnchantments {
enchDetectPoison,
// Changes NPC behavior
- enchHasNoSmell,
+ enchHasNoSmell
};
//-----------------------------------------------------------------------
@@ -112,7 +112,7 @@ enum worldEnchantments {
weTimeStop = 0,
- weCount,
+ weCount
};
} // end of namespace Saga2
diff --git a/engines/saga2/speldefs.h b/engines/saga2/speldefs.h
index 1e0f0e8398..9e27a4c5a3 100644
--- a/engines/saga2/speldefs.h
+++ b/engines/saga2/speldefs.h
@@ -146,7 +146,7 @@ public :
spellTargetPoint, // targeted on a particular point
spellTargetObjectPoint, // targeted on an object's location
spellTargetObject, // targeted on an object (tracking)
- spellTargetTAG, // targeted on an object (tracking)
+ spellTargetTAG // targeted on an object (tracking)
};
private:
@@ -254,7 +254,7 @@ enum EffectronFlagMasks {
effectronOK = 0,
effectronHidden = (1 << 0),
effectronDead = (1 << 1),
- effectronBumped = (1 << 2),
+ effectronBumped = (1 << 2)
};
typedef uint32 EffectronFlags;
diff --git a/engines/saga2/spellbuk.h b/engines/saga2/spellbuk.h
index d7f473cedc..0636273c8d 100644
--- a/engines/saga2/spellbuk.h
+++ b/engines/saga2/spellbuk.h
@@ -44,7 +44,7 @@ enum SpellManaID {
sManaIDGreen = 3,
sManaIDBlue = 4,
sManaIDViolet = 5,
- sManaIDSkill = 6, // skills are here for convenience
+ sManaIDSkill = 6 // skills are here for convenience
};
//-------------------------------------------------------------------
@@ -63,7 +63,7 @@ enum SpellTargetingTypes {
spellTargTAG = 1 << 2, // cast at tileactivity inst.
spellTargObject = 1 << 3, // cast at objects
spellTargActor = 1 << 4,
- spellTargCaster = 1 << 5,
+ spellTargCaster = 1 << 5
};
//-------------------------------------------------------------------
@@ -75,7 +75,7 @@ enum SpellApplicationTypes {
spellApplyTAG = spellTargTAG,
spellApplyObject = spellTargObject,
spellApplyActor = spellTargObject,
- spellApplyTracking = 1 << 6, // track object targets
+ spellApplyTracking = 1 << 6 // track object targets
};
@@ -97,7 +97,7 @@ enum effectAreas {
eAreaMissle,
eAreaGlow,
eAreaBeam,
- eAreaWall,
+ eAreaWall
};
diff --git a/engines/saga2/spelshow.h b/engines/saga2/spelshow.h
index ddbd7a8b91..17c785f755 100644
--- a/engines/saga2/spelshow.h
+++ b/engines/saga2/spelshow.h
@@ -218,7 +218,7 @@ enum effectCollisionCont {
ecFlagNone = 0,
ecFlagBounce,
ecFlagDie,
- ecFlagStop,
+ ecFlagStop
};
enum effectDirectionInit {
@@ -227,7 +227,7 @@ enum effectDirectionInit {
diFlagInc2 = 2,
diFlagInc3 = 3,
diFlagInc4 = 4,
- diFlagRand = 5,
+ diFlagRand = 5
};
diff --git a/engines/saga2/uidialog.h b/engines/saga2/uidialog.h
index ea29a03d50..c764dda375 100644
--- a/engines/saga2/uidialog.h
+++ b/engines/saga2/uidialog.h
@@ -79,7 +79,7 @@ private:
enum {
maxLines = 16,
- maxText = 512,
+ maxText = 512
};
int16 titleCount;
@@ -120,7 +120,7 @@ public:
class CPlacardPanel : public CPlaqText {
enum {
maxLines = 16,
- maxText = 512,
+ maxText = 512
};
int16 titleCount;
Commit: c683a1df4768ac6cca899814aad104f7acd2d440
https://github.com/scummvm/scummvm/commit/c683a1df4768ac6cca899814aad104f7acd2d440
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:41+02:00
Commit Message:
SAGA2: Fix intrface initialization
Changed paths:
engines/saga2/intrface.cpp
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index 38fc78f85a..fc3b56908a 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -365,9 +365,9 @@ const uint32 containerGroupID = MKTAG('C', 'O', 'N', 'T');
// button position views
// topBox, midBox, and botBox are defined in uimetrcs.h
static const StaticRect *views[] = {
- { topBox },
- { midBox },
- { botBox }
+ topBox,
+ midBox,
+ botBox
};
// individual indicators/buttons
Commit: 21077e5d13a7a6b2aec360ea90e3bd9fdbccef27
https://github.com/scummvm/scummvm/commit/21077e5d13a7a6b2aec360ea90e3bd9fdbccef27
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:41+02:00
Commit Message:
SAGA2: More enum warnings fixed
Changed paths:
engines/saga2/gamerate.h
engines/saga2/gbevel.h
engines/saga2/loadsave.cpp
engines/saga2/motion.cpp
engines/saga2/msgbox.cpp
engines/saga2/speech.h
diff --git a/engines/saga2/gamerate.h b/engines/saga2/gamerate.h
index 77cad5237d..aed8390302 100644
--- a/engines/saga2/gamerate.h
+++ b/engines/saga2/gamerate.h
@@ -30,7 +30,7 @@
namespace Saga2 {
enum {
- grFramesPerSecond = 0,
+ grFramesPerSecond = 0
};
class frameCounter {
@@ -84,7 +84,7 @@ enum {
grFPKS1SecVarOld = 12,
grFPKS1SecVarOldest = 13,
grFPKS5SecVar = 14,
- grFPKSVar1SecAvg = 15,
+ grFPKSVar1SecAvg = 15
};
class frameSmoother: public frameCounter {
diff --git a/engines/saga2/gbevel.h b/engines/saga2/gbevel.h
index 465e6a4d00..d76599e403 100644
--- a/engines/saga2/gbevel.h
+++ b/engines/saga2/gbevel.h
@@ -118,7 +118,7 @@ extern gPen mainPens[]; // the array of pens
enum bevelOptions {
bevelRecessed = (1 << 0), // bevel is pushed in
bevelFilled = (1 << 1), // bevel filled with approp. color
- bevelInverted = (1 << 2), // pushed in w/slightly diff. look
+ bevelInverted = (1 << 2) // pushed in w/slightly diff. look
};
void DrawBevelFrame(gPort &port, const Rect16 &r, uint16 flags);
diff --git a/engines/saga2/loadsave.cpp b/engines/saga2/loadsave.cpp
index 3b37c6d46f..e08a7bc730 100644
--- a/engines/saga2/loadsave.cpp
+++ b/engines/saga2/loadsave.cpp
@@ -202,7 +202,7 @@ void loadSavedGameState(int16 saveNo) {
loadAutoMapFlag = (1 << 26),
loadUIStateFlag = (1 << 27),
loadPaletteStateFlag = (1 << 28),
- loadContainerNodesFlag = (1 << 29),
+ loadContainerNodesFlag = (1 << 29)
};
uint32 loadFlags = 0;
diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp
index ad80317c97..ca61971203 100644
--- a/engines/saga2/motion.cpp
+++ b/engines/saga2/motion.cpp
@@ -1260,7 +1260,7 @@ void MotionTask::calcVelocity(const TilePoint &vector, int16 turns) {
// This initiates a motion task for turning an actor
void MotionTask::turn(Actor &obj, Direction dir) {
- assert(dir >= 0 && dir < 8);
+ assert(dir < 8);
MotionTask *mt;
@@ -2485,7 +2485,7 @@ void MotionTask::walkAction(void) {
walkNormal = 0,
walkSlow,
walkRun,
- walkStairs,
+ walkStairs
};
TilePoint immediateTarget = getImmediateTarget(),
diff --git a/engines/saga2/msgbox.cpp b/engines/saga2/msgbox.cpp
index 058be0741b..10b60ac159 100644
--- a/engines/saga2/msgbox.cpp
+++ b/engines/saga2/msgbox.cpp
@@ -44,9 +44,9 @@ static const StaticRect mbWindowRect = {70, 170, 500, 140};
static const StaticRect mbOkBtnRect = {100, 100, 100, 25};
static const StaticRect mbCancelBtnRect = {300, 100, 100, 25};
static const StaticRect mbOneBtnRect = {200, 100, 100, 25};
-static const StaticRect mbButtonRects[numMessageBtns] = {
- { mbOkBtnRect },
- { mbCancelBtnRect }
+static const StaticRect *mbButtonRects[numMessageBtns] = {
+ &mbOkBtnRect,
+ &mbCancelBtnRect
};
static gFont *mbButtonFont = &ThinFix8Font;
@@ -72,7 +72,7 @@ void writePlaqText(gPort &port,
const char *msg, ...);
inline Rect16 butBox(int n, int i) {
- return (n > 1 ? mbButtonRects[i] : mbOneBtnRect);
+ return (n > 1 ? *mbButtonRects[i] : mbOneBtnRect);
}
/* ===================================================================== *
diff --git a/engines/saga2/speech.h b/engines/saga2/speech.h
index be5c0a1b70..c78c266a33 100644
--- a/engines/saga2/speech.h
+++ b/engines/saga2/speech.h
@@ -76,7 +76,7 @@ enum {
speakContinued = (1 << 0), // Append next speech
speakNoAnimate = (1 << 1), // Don't animate speaking
speakWait = (1 << 2), // wait until speech finished
- speakLock = (1 << 3), // lock UI while speech in progress
+ speakLock = (1 << 3) // lock UI while speech in progress
};
class Speech {
@@ -134,7 +134,7 @@ public:
spHasVoice = (1 << 1), // The audio interface is playing this voice
spQueued = (1 << 2), // In active queue
spActive = (1 << 3), // Is current active speech
- spLock = (1 << 4), // Lock UI while speaking
+ spLock = (1 << 4) // Lock UI while speaking
};
// remove speech, dealloc resources
Commit: bede93482c695b5083957c529d4cba8272bed236
https://github.com/scummvm/scummvm/commit/bede93482c695b5083957c529d4cba8272bed236
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:41+02:00
Commit Message:
SAGA2: Fix uidialog.cpp static initializers
Changed paths:
engines/saga2/uidialog.cpp
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index a4961f1165..1ad51e06f7 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -209,21 +209,21 @@ static const StaticRect saveLoadWindowRect = {
// indirections
-static const StaticRect saveLoadPanelRects[kNumSaveLoadPanels] = {
- { SLTopPanel },
- { SLMidPanel },
- { SLBotPanel }
+static const StaticRect *saveLoadPanelRects[kNumSaveLoadPanels] = {
+ &SLTopPanel,
+ &SLMidPanel,
+ &SLBotPanel
};
-static const StaticRect saveLoadButtonRects[kNumSaveLoadBtns] = {
- { SLQuitBtnRect },
- { SLBtnRect },
- { SLUpArrowBtnRect },
- { SLDnArrowBtnRect }
+static const StaticRect *saveLoadButtonRects[kNumSaveLoadBtns] = {
+ &SLQuitBtnRect,
+ &SLBtnRect,
+ &SLUpArrowBtnRect,
+ &SLDnArrowBtnRect
};
-static const StaticRect saveLoadTextRects[kNumSaveLoadTexts] = {
- { SLTitleRect }
+static const StaticRect *saveLoadTextRects[kNumSaveLoadTexts] = {
+ &SLTitleRect
};
@@ -231,9 +231,9 @@ static const StaticRect saveLoadTextRects[kNumSaveLoadTexts] = {
// save/load dialog window decorations
WindowDecoration saveWindowDecorations[kNumSaveLoadPanels] = {
- { WindowDecoration(saveLoadPanelRects[0], SLTopPanelResID) },
- { WindowDecoration(saveLoadPanelRects[1], SLMidPanelResID) },
- { WindowDecoration(saveLoadPanelRects[2], SLBotPanelResID) }
+ { WindowDecoration(*saveLoadPanelRects[0], SLTopPanelResID) },
+ { WindowDecoration(*saveLoadPanelRects[1], SLMidPanelResID) },
+ { WindowDecoration(*saveLoadPanelRects[2], SLBotPanelResID) }
};
@@ -440,42 +440,42 @@ static const StaticRect optionsWindowRect = {
// indirections
-static StaticRect optionsPanelRects[kNumOptionsPanels] = {
- { optTopPanel },
- { optMidPanel },
- { optBotPanel }
+static const StaticRect *optionsPanelRects[kNumOptionsPanels] = {
+ &optTopPanel,
+ &optMidPanel,
+ &optBotPanel
};
-static StaticRect optionsButtonRects[] = {
- { optResumeRect },
- { optSaveRect },
- { optRestoreRect },
- { optQuitRect },
- { optCreditsRect },
- { optAggressRect },
- { optWeaponRect },
- { optSpeechRect },
- { optNightRect }
+static const StaticRect *optionsButtonRects[] = {
+ &optResumeRect,
+ &optSaveRect,
+ &optRestoreRect,
+ &optQuitRect,
+ &optCreditsRect,
+ &optAggressRect,
+ &optWeaponRect,
+ &optSpeechRect,
+ &optNightRect
};
-static StaticRect optionsTextRects[] = {
- { optTitleText },
- { optTopSlideText },
- { optMidSlideText },
- { optBotSlideText },
- { optTopCheckText },
- { optMidCheckText },
- { optBotCheckText },
- { optTop2CheckText }
+static const StaticRect *optionsTextRects[] = {
+ &optTitleText,
+ &optTopSlideText,
+ &optMidSlideText,
+ &optBotSlideText,
+ &optTopCheckText,
+ &optMidCheckText,
+ &optBotCheckText,
+ &optTop2CheckText
};
// options dialog window decorations
static WindowDecoration optionsDecorations[kNumOptionsPanels] = {
- { WindowDecoration(optionsPanelRects[0], optTopPanelResID) },
- { WindowDecoration(optionsPanelRects[1], optMidPanelResID) },
- { WindowDecoration(optionsPanelRects[2], optBotPanelResID) }
+ { WindowDecoration(*optionsPanelRects[0], optTopPanelResID) },
+ { WindowDecoration(*optionsPanelRects[1], optMidPanelResID) },
+ { WindowDecoration(*optionsPanelRects[2], optBotPanelResID) }
};
@@ -531,16 +531,16 @@ static const StaticRect messageRect = {
-static StaticRect messageTextRects[kNumMessageTexts] = {
- { mesTitleRect },
- { messageRect }
+static const StaticRect *messageTextRects[kNumMessageTexts] = {
+ &mesTitleRect,
+ &messageRect
};
-static StaticRect messageButtonRects[kNumMessageBtns] = {
- { mesOkBtnRect },
- { mesCancelBtnRect },
- { mesBtn3Rect }
+static const StaticRect *messageButtonRects[kNumMessageBtns] = {
+ &mesOkBtnRect,
+ &mesCancelBtnRect,
+ &mesBtn3Rect
};
@@ -732,20 +732,20 @@ int16 FileDialog(int16 fileProcess) {
win = new ModalWindow(saveLoadWindowRect, 0, nullptr);
// make the quit button
- new gCompButton(*win, saveLoadButtonRects[0], pushBtnIm, numBtnImages, btnStrings[stringIndex][0], pal, 0, cmdDialogQuit);
+ new gCompButton(*win, *saveLoadButtonRects[0], pushBtnIm, numBtnImages, btnStrings[stringIndex][0], pal, 0, cmdDialogQuit);
//t->accelKey=0x1B;
// make the Save/Load button
- new gCompButton(*win, saveLoadButtonRects[1], pushBtnIm, numBtnImages, btnStrings[stringIndex][1], pal, fileProcess, fileCommands[fileProcess]);
+ new gCompButton(*win, *saveLoadButtonRects[1], pushBtnIm, numBtnImages, btnStrings[stringIndex][1], pal, fileProcess, fileCommands[fileProcess]);
//t->accelKey=0x0D;
// make the up arrow
- new gCompButton(*win, saveLoadButtonRects[2], arrowUpIm, numBtnImages, 0, cmdSaveDialogUp);
+ new gCompButton(*win, *saveLoadButtonRects[2], arrowUpIm, numBtnImages, 0, cmdSaveDialogUp);
//t->accelKey=33+0x80;
// make the down arrow
- new gCompButton(*win, saveLoadButtonRects[3], arrowDnIm, numBtnImages, 0, cmdSaveDialogDown);
+ new gCompButton(*win, *saveLoadButtonRects[3], arrowDnIm, numBtnImages, 0, cmdSaveDialogDown);
//t->accelKey=34+0x80;
// attach the title
- new CPlaqText(*win, saveLoadTextRects[0], textStrings[stringIndex][0], &Plate18Font, 0, pal, 0, nullptr);
+ new CPlaqText(*win, *saveLoadTextRects[0], textStrings[stringIndex][0], &Plate18Font, 0, pal, 0, nullptr);
@@ -881,44 +881,44 @@ int16 OptionsDialog(bool disableSaveResume) {
// buttons
if (!disableSaveResume) {
- t = new gCompButton(*win, optionsButtonRects[0],
+ t = new gCompButton(*win, *optionsButtonRects[0],
dialogPushImag, numBtnImages, btnStrings[0], pal, 0, cmdDialogQuit);
t->accelKey = 0x1B;
- t = new gCompButton(*win, optionsButtonRects[1],
+ t = new gCompButton(*win, *optionsButtonRects[1],
dialogPushImag, numBtnImages, btnStrings[1], pal, 0, cmdOptionsSaveGame); // make the quit button
t->accelKey = 'S';
} else {
- t = new gCompButton(*win, optionsButtonRects[1],
+ t = new gCompButton(*win, *optionsButtonRects[1],
dialogPushImag, numBtnImages, OPTN_DIALOG_BUTTON6, pal, 0, cmdOptionsNewGame);
t->accelKey = 'N';
}
- t = new gCompButton(*win, optionsButtonRects[2],
+ t = new gCompButton(*win, *optionsButtonRects[2],
dialogPushImag, numBtnImages, btnStrings[2], pal, 0, cmdOptionsLoadGame); // make the quit button
t->accelKey = 'L';
- t = new gCompButton(*win, optionsButtonRects[3],
+ t = new gCompButton(*win, *optionsButtonRects[3],
dialogPushImag, numBtnImages, btnStrings[3], pal, 0, cmdQuitGame);
t->accelKey = 'Q';
- t = new gCompButton(*win, optionsButtonRects[4],
+ t = new gCompButton(*win, *optionsButtonRects[4],
dialogPushImag, numBtnImages, btnStrings[4], pal, 0, cmdCredits);
t->accelKey = 'C';
- autoAggressBtn = new gOwnerSelCompButton(*win, optionsButtonRects[5],
+ autoAggressBtn = new gOwnerSelCompButton(*win, *optionsButtonRects[5],
checkImag, numBtnImages, 0, cmdAutoAggression);
autoAggressBtn->select(isAutoAggressionSet());
- autoWeaponBtn = new gOwnerSelCompButton(*win, optionsButtonRects[6],
+ autoWeaponBtn = new gOwnerSelCompButton(*win, *optionsButtonRects[6],
checkImag, numBtnImages, 0, cmdAutoWeapon);
autoWeaponBtn->select(isAutoWeaponSet());
- speechTextBtn = new gOwnerSelCompButton(*win, optionsButtonRects[7],
+ speechTextBtn = new gOwnerSelCompButton(*win, *optionsButtonRects[7],
checkImag, numBtnImages, 0, cmdSpeechText);
speechTextBtn->select(g_vm->_speechText);
- nightBtn = new gOwnerSelCompButton(*win, optionsButtonRects[8],
+ nightBtn = new gOwnerSelCompButton(*win, *optionsButtonRects[8],
checkImag, numBtnImages, 0, cmdNight);
nightBtn->select(g_vm->_showNight);
@@ -934,11 +934,11 @@ int16 OptionsDialog(bool disableSaveResume) {
Audio::Mixer::kMaxMixerVolume, slideFaceImag, numSlideFace, ConfMan.getInt("music_volume"),
0, cmdSetMIDIVolume);
- new CPlaqText(*win, optionsTextRects[0],
+ new CPlaqText(*win, *optionsTextRects[0],
textStrings[0], &Plate18Font, 0, pal, 0, nullptr);
for (int i = 1; i < kNumOptionsTexts; i++) {
- new CPlaqText(*win, optionsTextRects[i], textStrings[i], &SmallFont, textPosLeft, pal, 0, nullptr);
+ new CPlaqText(*win, *optionsTextRects[i], textStrings[i], &SmallFont, textPosLeft, pal, 0, nullptr);
}
win->setDecorations(optionsDecorations,
@@ -1231,30 +1231,30 @@ int16 userDialog(const char *title, const char *msg, const char *bMsg1,
// button one
if (numBtns >= 1) {
- t = new gCompButton(*win, messageButtonRects[0],
+ t = new gCompButton(*win, *messageButtonRects[0],
dialogPushImag, numBtnImages, btnMsg1, pal, 10, cmdDialogQuit);
t->accelKey = k1;
}
// button two
if (numBtns >= 2) {
- t = new gCompButton(*win, messageButtonRects[1],
+ t = new gCompButton(*win, *messageButtonRects[1],
dialogPushImag, numBtnImages, btnMsg2, pal, 11, cmdDialogQuit);
t->accelKey = k2;
}
// button three
if (numBtns >= 3) {
- t = new gCompButton(*win, messageButtonRects[2],
+ t = new gCompButton(*win, *messageButtonRects[2],
dialogPushImag, numBtnImages, btnMsg3, pal, 12, cmdDialogQuit);
t->accelKey = k3;
}
// title for the box
- new CPlaqText(*win, messageTextRects[0], title, &Plate18Font, 0, pal, 0, nullptr);
+ new CPlaqText(*win, *messageTextRects[0], title, &Plate18Font, 0, pal, 0, nullptr);
// message for box
- new CPlacardPanel(*win, messageTextRects[1], msg, &Onyx10Font, 0, pal, 0, nullptr);
+ new CPlacardPanel(*win, *messageTextRects[1], msg, &Onyx10Font, 0, pal, 0, nullptr);
win->setDecorations(messageDecorations,
ARRAYSIZE(messageDecorations),
Commit: eeb969fa3572531b4bc30fa90812e1cf9147c1f6
https://github.com/scummvm/scummvm/commit/eeb969fa3572531b4bc30fa90812e1cf9147c1f6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:41+02:00
Commit Message:
SAGA2: Fix more enum warnings
Changed paths:
engines/saga2/objects.cpp
engines/saga2/path.cpp
engines/saga2/speldraw.cpp
engines/saga2/tile.cpp
engines/saga2/towerwin.h
engines/saga2/videobox.h
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 5bc7fb4789..5f4f93ab05 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -401,7 +401,7 @@ void GameObject::remove(void) { // removes from old list
// If object has not parent, then it's not on a list
if (_data.parentID == Nothing) return;
- if (id >= Nothing && id <= ImportantLimbo) return;
+ if (id <= ImportantLimbo) return;
// Get the head of the object chain. Worlds have more than
// one, so we need to get the right one.
@@ -669,7 +669,7 @@ int32 GameObject::getSprOffset(int16 num) {
enum spriteDelimiters {
spriteNumFew = 2,
spriteNumSome = 10,
- spriteNumMany = 25,
+ spriteNumMany = 25
};
// default return offset is zero ( no change )
@@ -1019,9 +1019,6 @@ ObjectID GameObject::extractMerged(const Location &loc, int16 num) {
if (_data.massCount == 0) {
this->deleteObject();
}
-
- // _data.massCount should never go negitive
- assert(_data.massCount >= 0);
} else
return Nothing;
} else {
@@ -1052,9 +1049,6 @@ GameObject *GameObject::extractMerged(int16 num) {
if (_data.massCount == 0) {
this->deleteObject();
}
-
- // _data.massCount should never go negitive
- assert(_data.massCount >= 0);
} else
return nullptr;
} else {
@@ -4432,20 +4426,14 @@ void cleanupReadyContainers(void) {
unloadImageRes(backImages, numReadyContRes);
}
- if (TrioCviews) {
- int16 i;
-
- //delete TrioCviews;
+ for (int16 i = 0; i < kNumViews && i < playerActors ; i++) {
+ delete TrioCviews[i];
+ TrioCviews[i] = nullptr;
- for (i = 0; i < kNumViews && i < playerActors ; i++) {
- delete TrioCviews[i];
- TrioCviews[i] = nullptr;
-
- delete playerList[i].readyNode;
- playerList[i].readyNode = nullptr;
- }
- delete indivReadyNode;
+ delete playerList[i].readyNode;
+ playerList[i].readyNode = nullptr;
}
+ delete indivReadyNode;
if (indivCviewTop) {
delete indivCviewTop;
diff --git a/engines/saga2/path.cpp b/engines/saga2/path.cpp
index 785e010f2c..92241ae61f 100644
--- a/engines/saga2/path.cpp
+++ b/engines/saga2/path.cpp
@@ -462,8 +462,7 @@ public:
enum {
chunkTileDiameter = 4,
- regionChunkDiameter =
- (searchDiameter + chunkTileDiameter - 1) / chunkTileDiameter,
+ regionChunkDiameter = (searchDiameter + chunkTileDiameter - 1) / chunkTileDiameter
};
private:
@@ -1057,7 +1056,7 @@ int16 tileSlopeHeight(
enum PathResult {
pathNotDone,
pathDone,
- pathAborted,
+ pathAborted
};
// This if the base class for all PathRequests
@@ -1073,7 +1072,7 @@ protected:
enum pathFlags {
aborted = (1 << 0), // path request has been aborted
completed = (1 << 1), // pathfinder has found best path
- run = (1 << 2),
+ run = (1 << 2)
};
// These static members are initialized when the path request
@@ -1641,7 +1640,7 @@ void PathRequest::finish(void) {
assert(bestLoc.u >= 0 && bestLoc.u < searchDiameter);
assert(bestLoc.v >= 0 && bestLoc.v < searchDiameter);
bestPlatform -= cell->platformDelta;
- assert(bestPlatform >= 0 && bestPlatform < maxPlatforms);
+ assert(bestPlatform < maxPlatforms);
} else
break;
}
@@ -2376,7 +2375,7 @@ void abortPathFind(MotionTask *mTask) {
enum cellStates {
cellUnvisited = 0,
cellOccupied = (1 << 0),
- cellVisited = (1 << 1),
+ cellVisited = (1 << 1)
};
typedef uint8 SimpleCellArray[searchDiameter][searchDiameter];
diff --git a/engines/saga2/speldraw.cpp b/engines/saga2/speldraw.cpp
index b8e66a0817..dbdb4274be 100644
--- a/engines/saga2/speldraw.cpp
+++ b/engines/saga2/speldraw.cpp
@@ -114,7 +114,7 @@ void EffectDisplayPrototypeList::append(EffectDisplayPrototype *nedp, int32 acou
}
EffectDisplayPrototype *EffectDisplayPrototypeList::operator[](EffectID e) {
- assert(e >= 0 && e < maxCount);
+ assert(e < maxCount);
return effects[e];
}
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index f40f4e7c19..5bce04cde0 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -87,7 +87,7 @@ const ActiveItemID NoActiveItem(0, activeItemIndexNullID);
enum SurfaceType {
surfaceHoriz, // Level surface
surfaceVertV, // Vertical surface, parallel to V axis
- surfaceVertU, // Vertical surface, parallel to U axis
+ surfaceVertU // Vertical surface, parallel to U axis
};
@@ -2277,7 +2277,6 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
// Get the address of the pce from the cache
pce = &platformCache[plIndex];
- assert(pce->platformNum >= 0);
assert(pce->metaID != NoMetaTile);
assert(pce->metaID == thisID(mapNum));
@@ -2318,7 +2317,6 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
pce->metaID = thisID(mapNum);
_stack[layer] = (cacheIndex | cacheFlag);
- assert(plIndex >= 0);
assert(plIndex * sizeof(Platform) < tileRes->size(platformID + mapNum));
debugC(3, kDebugLoading, "- plIndex: %d", plIndex);
@@ -3044,7 +3042,7 @@ enum maskRules {
maskRuleConvexNear,
maskRuleConcaveFar,
maskRuleConvexFar,
- maskRuleConcaveNear,
+ maskRuleConcaveNear
// More mask types to come!
};
diff --git a/engines/saga2/towerwin.h b/engines/saga2/towerwin.h
index d8b717f7a8..fe3cd9fac6 100644
--- a/engines/saga2/towerwin.h
+++ b/engines/saga2/towerwin.h
@@ -69,7 +69,7 @@ enum initializationStates {
gameModeInitialized,
gameDisplayEnabled,
activeErrInitialized,
- fullyInitialized,
+ fullyInitialized
};
} // end of namespace Saga2
diff --git a/engines/saga2/videobox.h b/engines/saga2/videobox.h
index 207875d74e..f10bfefade 100644
--- a/engines/saga2/videobox.h
+++ b/engines/saga2/videobox.h
@@ -39,23 +39,23 @@ public:
xSize = 340,
ySize = 220,
x = (640 - xSize) / 2,
- y = (480 - ySize) / 3,
+ y = (480 - ySize) / 3
};
private:
enum brush {
xBrushSize = 340, // size of each brush 'chunk'.
yBrushSize = 110,
- numBrushes = 2, // number of chunks
+ numBrushes = 2 // number of chunks
};
enum borderWidth {
- borderWidth = 6,
+ borderWidth = 6
};
enum {
vidPan1ResID = 0,
- vidPan2ResID,
+ vidPan2ResID
};
public:
Commit: c3083875896556ca618e09847a033f9f61cdb4fb
https://github.com/scummvm/scummvm/commit/c3083875896556ca618e09847a033f9f61cdb4fb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:41+02:00
Commit Message:
SAGA2: Fix another warning
Changed paths:
engines/saga2/sagafunc.cpp
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index f419d94d99..d4fa54d789 100644
--- a/engines/saga2/sagafunc.cpp
+++ b/engines/saga2/sagafunc.cpp
@@ -2506,7 +2506,7 @@ int16 scriptTagUse(int16 *args) {
// void "c" setAnimation( int flags, int targetState );
enum {
- tileAnimateWait = (1 << 0), // wait until animation finished
+ tileAnimateWait = (1 << 0) // wait until animation finished
};
int16 scriptTagSetAnimation(int16 *args) {
Commit: 7fe3baf1847c5ace5ae9c74fa65875d206dc7d1d
https://github.com/scummvm/scummvm/commit/7fe3baf1847c5ace5ae9c74fa65875d206dc7d1d
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:41+02:00
Commit Message:
SAGA2: Clear some WindowDecoration global constructor warnings
Changed paths:
engines/saga2/automap.cpp
engines/saga2/floating.cpp
engines/saga2/floating.h
engines/saga2/uidialog.cpp
diff --git a/engines/saga2/automap.cpp b/engines/saga2/automap.cpp
index 531dd7c551..5582b17634 100644
--- a/engines/saga2/automap.cpp
+++ b/engines/saga2/automap.cpp
@@ -142,10 +142,10 @@ static const StaticRect scrollBtnRect = {
};
-WindowDecoration autoMapDecorations[numAutoMapPanels] = {
- { WindowDecoration(*autoMapPanelRects[0], autoMapTopPanelResID) },
- { WindowDecoration(*autoMapPanelRects[1], autoMapMidPanelResID) },
- { WindowDecoration(*autoMapPanelRects[2], autoMapBotPanelResID) }
+StaticWindow autoMapDecorations[numAutoMapPanels] = {
+ {*autoMapPanelRects[0], nullptr, autoMapTopPanelResID},
+ {*autoMapPanelRects[1], nullptr, autoMapMidPanelResID},
+ {*autoMapPanelRects[2], nullptr, autoMapBotPanelResID}
};
diff --git a/engines/saga2/floating.cpp b/engines/saga2/floating.cpp
index c5483a83db..afe9f3adc7 100644
--- a/engines/saga2/floating.cpp
+++ b/engines/saga2/floating.cpp
@@ -122,16 +122,22 @@ void DecoratedWindow::setDecorations(
hResContext *con) {
int16 i;
- decorations = dec;
numDecorations = count;
- // For each "decorative panel" within the frame of the window
- for (i = 0; i < numDecorations; i++, dec++) {
+ if (decorations)
+ delete[] decorations;
- // request an image pointer from the imageCache
+ decorations = new WindowDecoration[numDecorations];
+ // For each "decorative panel" within the frame of the window
+
+ for (i = 0; i < numDecorations; i++, dec++) {
+ // request an image pointer from the image Cache
dec->image = ImageCache.requestImage(con,
MKTAG('B', 'R', 'D', dec->imageNumber));
+ decorations[i].extent = dec->extent;
+ decorations[i].image = dec->image;
+ decorations[i].imageNumber = dec->imageNumber;
}
}
@@ -142,14 +148,21 @@ void DecoratedWindow::setDecorations(
hResID id_) {
int16 i;
- decorations = dec;
numDecorations = count;
+ if (decorations)
+ delete[] decorations;
+
+ decorations = new WindowDecoration[numDecorations];
+
// For each "decorative panel" within the frame of the window
for (i = 0; i < numDecorations; i++, dec++) {
// request an image pointer from the image Cache
dec->image = ImageCache.requestImage(con, id_ | MKTAG(0, 0, 0, dec->imageNumber));
+ decorations[i].extent = dec->extent;
+ decorations[i].image = dec->image;
+ decorations[i].imageNumber = dec->imageNumber;
}
}
@@ -161,6 +174,40 @@ void DecoratedWindow::setDecorations(
setDecorations(dec, count, con, MKTAG(a, b, c, 0));
}
+
+void DecoratedWindow::setDecorations(
+ StaticWindow *dec,
+ int16 count,
+ hResContext *con,
+ hResID id_) {
+ int16 i;
+
+ numDecorations = count;
+
+ if (decorations)
+ delete[] decorations;
+
+ decorations = new WindowDecoration[numDecorations];
+
+ // For each "decorative panel" within the frame of the window
+
+ for (i = 0; i < numDecorations; i++, dec++) {
+ // request an image pointer from the image Cache
+ dec->image = ImageCache.requestImage(con, id_ | MKTAG(0, 0, 0, dec->imageNumber));
+ decorations[i].extent = dec->extent;
+ decorations[i].image = dec->image;
+ decorations[i].imageNumber = dec->imageNumber;
+ }
+}
+
+void DecoratedWindow::setDecorations(
+ StaticWindow *dec,
+ int16 count,
+ hResContext *con,
+ char a, char b, char c) {
+ setDecorations(dec, count, con, MKTAG(a, b, c, 0));
+}
+
// Free the decorations from the memory pool
void DecoratedWindow::removeDecorations(void) {
@@ -172,7 +219,8 @@ void DecoratedWindow::removeDecorations(void) {
ImageCache.releaseImage(dec->image);
}
- decorations = NULL;
+ if (decorations)
+ delete[] decorations;
numDecorations = 0;
}
diff --git a/engines/saga2/floating.h b/engines/saga2/floating.h
index 19cf023aa4..702b611ea1 100644
--- a/engines/saga2/floating.h
+++ b/engines/saga2/floating.h
@@ -53,6 +53,12 @@ class GameObject;
// artwork, this class provides a linked list of all the "artwork
// panels" which cover the borders of the image.
+struct StaticWindow {
+ StaticRect extent;
+ void *image;
+ int16 imageNumber;
+};
+
struct WindowDecoration {
Rect16 extent; // area that image covers
void *image; // pointer to image data
@@ -70,6 +76,12 @@ struct WindowDecoration {
imageNumber = num;
}
+ WindowDecoration(StaticWindow s) {
+ extent = s.extent;
+ image = s.image;
+ imageNumber = s.imageNumber;
+ }
+
// this sets the decorations ( for use with the default constructor
void set(const Rect16 &r, int16 num) {
extent = r, image = NULL, imageNumber = num;
@@ -224,6 +236,9 @@ public:
void setDecorations(WindowDecoration *, int16, hResContext *, hResID);
void setDecorations(WindowDecoration *, int16, hResContext *, char, char, char);
+ void setDecorations(StaticWindow *, int16, hResContext *, hResID);
+ void setDecorations(StaticWindow *, int16, hResContext *, char, char, char);
+
// Free up memory used by decorative panels
void removeDecorations(void);
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index 1ad51e06f7..bd0da93bd7 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -230,10 +230,10 @@ static const StaticRect *saveLoadTextRects[kNumSaveLoadTexts] = {
// save/load dialog window decorations
-WindowDecoration saveWindowDecorations[kNumSaveLoadPanels] = {
- { WindowDecoration(*saveLoadPanelRects[0], SLTopPanelResID) },
- { WindowDecoration(*saveLoadPanelRects[1], SLMidPanelResID) },
- { WindowDecoration(*saveLoadPanelRects[2], SLBotPanelResID) }
+StaticWindow saveWindowDecorations[kNumSaveLoadPanels] = {
+ {*saveLoadPanelRects[0], nullptr, SLTopPanelResID},
+ {*saveLoadPanelRects[1], nullptr, SLMidPanelResID},
+ {*saveLoadPanelRects[2], nullptr, SLBotPanelResID}
};
Commit: c586d3c590ebc856015a341154a799554e8a608b
https://github.com/scummvm/scummvm/commit/c586d3c590ebc856015a341154a799554e8a608b
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:41+02:00
Commit Message:
SAGA2: Clear global constructor warnings in uidialog.cpp
Changed paths:
engines/saga2/uidialog.cpp
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index bd0da93bd7..a5f1806ed4 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -230,7 +230,7 @@ static const StaticRect *saveLoadTextRects[kNumSaveLoadTexts] = {
// save/load dialog window decorations
-StaticWindow saveWindowDecorations[kNumSaveLoadPanels] = {
+static StaticWindow saveWindowDecorations[kNumSaveLoadPanels] = {
{*saveLoadPanelRects[0], nullptr, SLTopPanelResID},
{*saveLoadPanelRects[1], nullptr, SLMidPanelResID},
{*saveLoadPanelRects[2], nullptr, SLBotPanelResID}
@@ -472,10 +472,10 @@ static const StaticRect *optionsTextRects[] = {
// options dialog window decorations
-static WindowDecoration optionsDecorations[kNumOptionsPanels] = {
- { WindowDecoration(*optionsPanelRects[0], optTopPanelResID) },
- { WindowDecoration(*optionsPanelRects[1], optMidPanelResID) },
- { WindowDecoration(*optionsPanelRects[2], optBotPanelResID) }
+static StaticWindow optionsDecorations[kNumOptionsPanels] = {
+ {*optionsPanelRects[0], nullptr, optTopPanelResID},
+ {*optionsPanelRects[1], nullptr, optMidPanelResID},
+ {*optionsPanelRects[2], nullptr, optBotPanelResID}
};
@@ -557,8 +557,8 @@ static const StaticRect messageWindowRect = {
// message dialog window decorations
-static WindowDecoration messageDecorations[kNumMessagePanels] = {
- { WindowDecoration(messagePanel, mesPanelResID) }
+static StaticWindow messageDecorations[kNumMessagePanels] = {
+ {messagePanel, nullptr, mesPanelResID}
};
Commit: e6f0beb24399bca0af07b579f8454d0b92924d38
https://github.com/scummvm/scummvm/commit/e6f0beb24399bca0af07b579f8454d0b92924d38
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:41+02:00
Commit Message:
SAGA2: Clear more global constructors
Changed paths:
engines/saga2/floating.cpp
engines/saga2/floating.h
engines/saga2/setup.h
engines/saga2/tilemode.cpp
diff --git a/engines/saga2/floating.cpp b/engines/saga2/floating.cpp
index afe9f3adc7..74a3ece637 100644
--- a/engines/saga2/floating.cpp
+++ b/engines/saga2/floating.cpp
@@ -174,6 +174,30 @@ void DecoratedWindow::setDecorations(
setDecorations(dec, count, con, MKTAG(a, b, c, 0));
}
+void DecoratedWindow::setDecorations(
+ StaticWindow *dec,
+ int16 count,
+ hResContext *con) {
+ int16 i;
+
+ numDecorations = count;
+
+ if (decorations)
+ delete[] decorations;
+
+ decorations = new WindowDecoration[numDecorations];
+
+ // For each "decorative panel" within the frame of the window
+
+ for (i = 0; i < numDecorations; i++, dec++) {
+ // request an image pointer from the image Cache
+ dec->image = ImageCache.requestImage(con,
+ MKTAG('B', 'R', 'D', dec->imageNumber));
+ decorations[i].extent = dec->extent;
+ decorations[i].image = dec->image;
+ decorations[i].imageNumber = dec->imageNumber;
+ }
+}
void DecoratedWindow::setDecorations(
StaticWindow *dec,
diff --git a/engines/saga2/floating.h b/engines/saga2/floating.h
index 702b611ea1..3b511be6f6 100644
--- a/engines/saga2/floating.h
+++ b/engines/saga2/floating.h
@@ -236,6 +236,7 @@ public:
void setDecorations(WindowDecoration *, int16, hResContext *, hResID);
void setDecorations(WindowDecoration *, int16, hResContext *, char, char, char);
+ void setDecorations(StaticWindow *, int16, hResContext *);
void setDecorations(StaticWindow *, int16, hResContext *, hResID);
void setDecorations(StaticWindow *, int16, hResContext *, char, char, char);
diff --git a/engines/saga2/setup.h b/engines/saga2/setup.h
index 5185f870f1..65ee326e90 100644
--- a/engines/saga2/setup.h
+++ b/engines/saga2/setup.h
@@ -100,8 +100,6 @@ enum borderIDs {
MWRightBorder3
};
-extern WindowDecoration mainWindowDecorations[];
-
const int extraObjects = 512,
extraActors = 64;
diff --git a/engines/saga2/tilemode.cpp b/engines/saga2/tilemode.cpp
index e4d74877f9..c447e1965f 100644
--- a/engines/saga2/tilemode.cpp
+++ b/engines/saga2/tilemode.cpp
@@ -234,13 +234,13 @@ static bool inCombat,
// precompiled header services if data is assigned during declaration
// inside a header. GT 09/11/95
-WindowDecoration mainWindowDecorations[] = {
- WindowDecoration(Rect16(0, 0, 640, 20), MWTopBorder), // top border
- WindowDecoration(Rect16(0, 440, 640, 40), MWBottomBorder), // bottom border
- WindowDecoration(Rect16(0, 20, 20, 420), MWLeftBorder), // left border
- WindowDecoration(Rect16(460, 20, 180, 142), MWRightBorder1), // right border #1
- WindowDecoration(Rect16(460, 162, 180, 151), MWRightBorder2),// right border #2
- WindowDecoration(Rect16(460, 313, 180, 127), MWRightBorder3),// right border #3
+static StaticWindow mainWindowDecorations[] = {
+ {{0, 0, 640, 20}, nullptr, MWTopBorder}, // top border
+ {{0, 440, 640, 40}, nullptr, MWBottomBorder}, // bottom border
+ {{0, 20, 20, 420}, nullptr, MWLeftBorder}, // left border
+ {{460, 20, 180, 142}, nullptr, MWRightBorder1}, // right border #1
+ {{460, 162, 180, 151}, nullptr, MWRightBorder2}, // right border #2
+ {{460, 313, 180, 127}, nullptr, MWRightBorder3}, // right border #3
};
/* ===================================================================== *
Commit: 4c1376844f72000e650d2dc5c976fd96c997ca76
https://github.com/scummvm/scummvm/commit/4c1376844f72000e650d2dc5c976fd96c997ca76
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:41+02:00
Commit Message:
SAGA2: Fix more WindowDecoration global constructors
Changed paths:
engines/saga2/contain.cpp
diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index 5569dfc117..6991349a72 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -131,28 +131,28 @@ ContainerAppearanceDef physicalContainerAppearance(
0 // Total rows
);
-static WindowDecoration brassDecorations[] = {
- { WindowDecoration(Rect16(0, 0, 268, 86), 3) },
- { WindowDecoration(Rect16(13, 86, 242, 109), 4) },
- { WindowDecoration(Rect16(13, 195, 242, 121), 5) }
+static StaticWindow brassDecorations[] = {
+ {{0, 0, 268, 86}, nullptr, 3},
+ {{13, 86, 242, 109}, nullptr, 4},
+ {{13, 195, 242, 121}, nullptr, 5}
};
-static WindowDecoration clothDecorations[] = {
- { WindowDecoration(Rect16(0, 0, 268, 86), 6) },
- { WindowDecoration(Rect16(13, 86, 242, 109), 7) },
- { WindowDecoration(Rect16(13, 195, 242, 121), 8) }
+static StaticWindow clothDecorations[] = {
+ {{0, 0, 268, 86}, nullptr, 6},
+ {{13, 86, 242, 109}, nullptr, 7},
+ {{13, 195, 242, 121}, nullptr, 8}
};
-static WindowDecoration steelDecorations[] = {
- { WindowDecoration(Rect16(0, 0, 268, 86), 9) },
- { WindowDecoration(Rect16(13, 86, 242, 109), 10) },
- { WindowDecoration(Rect16(13, 195, 242, 121), 11) }
+static StaticWindow steelDecorations[] = {
+ {{0, 0, 268, 86}, nullptr, 9},
+ {{13, 86, 242, 109}, nullptr, 10},
+ {{13, 195, 242, 121}, nullptr, 11}
};
-static WindowDecoration woodDecorations[] = {
- { WindowDecoration(Rect16(0, 0, 268, 86), 12) },
- { WindowDecoration(Rect16(13, 86, 242, 109), 13) },
- { WindowDecoration(Rect16(13, 195, 242, 121), 14) }
+static StaticWindow woodDecorations[] = {
+ {{0, 0, 268, 86}, nullptr, 12},
+ {{13, 86, 242, 109}, nullptr, 13},
+ {{13, 195, 242, 121}, nullptr, 14}
};
//-----------------------------------------------------------------------
@@ -176,8 +176,8 @@ ContainerAppearanceDef deathContainerAppearance(
);
// physal dialog window decorations
-static WindowDecoration deathDecorations[] =
-{ { WindowDecoration(Rect16(0, 0, 206, 250), 15) } };
+static StaticWindow deathDecorations[] =
+{ {{0, 0, 206, 250}, nullptr, 15} };
//-----------------------------------------------------------------------
// ReadyContainer appearance
@@ -219,8 +219,8 @@ ContainerAppearanceDef mentalContainerAppearance(
20 // Total rows
);
-static WindowDecoration mentalDecorations[] =
-{ { WindowDecoration(Rect16(0, 0, 158, 215), 0) } }; // Bottom decoration panel
+static StaticWindow mentalDecorations[] =
+{ {{0, 0, 158, 215}, nullptr, 0} }; // Bottom decoration panel
//-----------------------------------------------------------------------
// Enchantment container appearance
@@ -1242,11 +1242,12 @@ TangibleContainerWindow::TangibleContainerWindow(
containerRes, 'F', 'R', 'M');
massWeightIndicator = NULL;
} else {
- static WindowDecoration *winDecs[] = { brassDecorations,
- clothDecorations,
- steelDecorations,
- woodDecorations
- };
+ static StaticWindow *winDecs[] = {
+ brassDecorations,
+ clothDecorations,
+ steelDecorations,
+ woodDecorations
+ };
uint16 bgndType = view->containerObject->proto()->appearanceType;
assert(bgndType < 4);
Commit: 46e38b5a5b48d1a229f8136c895e1175a3073a92
https://github.com/scummvm/scummvm/commit/46e38b5a5b48d1a229f8136c895e1175a3073a92
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:42+02:00
Commit Message:
SAGA2: Cleanup Win32-specific code
Changed paths:
R engines/saga2/ioerrors.h
engines/saga2/audiodec.h
engines/saga2/audiosys.h
engines/saga2/button.cpp
engines/saga2/display.h
engines/saga2/floating.cpp
engines/saga2/hresmgr.cpp
engines/saga2/hresmgr.h
engines/saga2/interp.cpp
engines/saga2/loadsave.cpp
engines/saga2/mainmap.h
engines/saga2/noise.cpp
engines/saga2/objects.h
engines/saga2/path.cpp
engines/saga2/rect.h
engines/saga2/sagafunc.cpp
engines/saga2/script.h
engines/saga2/sprite.h
engines/saga2/tile.cpp
engines/saga2/tile.h
engines/saga2/tileline.cpp
engines/saga2/tileload.h
engines/saga2/towerfta.cpp
engines/saga2/tromode.cpp
diff --git a/engines/saga2/audiodec.h b/engines/saga2/audiodec.h
index 4e1ae8f16e..db967c1dec 100644
--- a/engines/saga2/audiodec.h
+++ b/engines/saga2/audiodec.h
@@ -64,19 +64,9 @@ enum soundDecoderType {
decodeSource
};
-/* ===================================================================== *
- Visual C sucks
- * ===================================================================== */
-
-#ifdef _WIN32
-typedef int16 __cdecl INPLACEDECODER(Buffer &, soundDecoder *, soundSample &);
-typedef int16 __cdecl BUFFERDECODER(Buffer &, soundDecoder *, soundSample &, workBuffer *);
-typedef int16 __cdecl BUFFERLOADER(Buffer &, soundSample &);
-#else
typedef int16 INPLACEDECODER(Buffer &, soundDecoder *, soundSample &);
typedef int16 BUFFERDECODER(Buffer &, soundDecoder *, soundSample &, workBuffer *);
typedef int16 BUFFERLOADER(Buffer &, soundSample &);
-#endif
union soundServer {
INPLACEDECODER *pDec;
@@ -141,15 +131,9 @@ public:
private:
soundDecoder();
public:
-#ifdef _WIN32
- soundDecoder(INPLACEDECODER *, INPLACEDECODER *, INPLACEDECODER *);
- soundDecoder(BUFFERDECODER *, BUFFERDECODER *, BUFFERDECODER *, int16, audioInterface *, int16);
- soundDecoder(BUFFERLOADER *, BUFFERLOADER *, BUFFERLOADER *);
-#else
soundDecoder(INPLACEDECODER, INPLACEDECODER, INPLACEDECODER);
soundDecoder(BUFFERDECODER, BUFFERDECODER, BUFFERDECODER, int16, audioInterface *, int16);
soundDecoder(BUFFERLOADER, BUFFERLOADER, BUFFERLOADER);
-#endif
~soundDecoder(void);
soundDecoder &operator=(const soundDecoder &src);
soundDecoder(const soundDecoder &src);
diff --git a/engines/saga2/audiosys.h b/engines/saga2/audiosys.h
index 5d8401ca87..58ae0e0a64 100644
--- a/engines/saga2/audiosys.h
+++ b/engines/saga2/audiosys.h
@@ -225,9 +225,6 @@ public:
private:
char status[256]; // audio status messages
int16 verbosity;
-#if defined(_WIN32) && defined(USE_REAL_WAIL)
- LPDIRECTSOUND lpDS;
-#endif
public:
// ctor, dtor, initialization
diff --git a/engines/saga2/button.cpp b/engines/saga2/button.cpp
index 9c3bb378e0..de65b48871 100644
--- a/engines/saga2/button.cpp
+++ b/engines/saga2/button.cpp
@@ -554,9 +554,6 @@ bool gCompButton::activate(gEventType why) {
window.update(extent);
if (why == gEventKeyDown) { // momentarily depress
-#ifndef _WIN32
- g_system->delayMillis(200);
-#endif
deactivate();
notify(gEventNewValue, 1); // notify App of successful hit
}
diff --git a/engines/saga2/display.h b/engines/saga2/display.h
index 715acd6030..808c5565fa 100644
--- a/engines/saga2/display.h
+++ b/engines/saga2/display.h
@@ -94,11 +94,6 @@ void resumeAudio(void);
// ------------------------------------------------------------------------
// The display may be disabled for several reasons these track them
-
-#ifdef _WIN32
-void localCursorOn(void);
-void localCursorOff(void);
-#endif
void blackOut(void);
void assertCurrentPalette(void);
diff --git a/engines/saga2/floating.cpp b/engines/saga2/floating.cpp
index 74a3ece637..8e3505dca9 100644
--- a/engines/saga2/floating.cpp
+++ b/engines/saga2/floating.cpp
@@ -387,9 +387,6 @@ bool gButton::activate(gEventType why) {
draw();
if (why == gEventKeyDown) { // momentarily depress
-#ifndef _WIN32
- g_system->delayMillis(200);
-#endif
deactivate();
notify(gEventNewValue, 1); // notify App of successful hit
}
diff --git a/engines/saga2/hresmgr.cpp b/engines/saga2/hresmgr.cpp
index f8ec74fb63..a12ad435d4 100644
--- a/engines/saga2/hresmgr.cpp
+++ b/engines/saga2/hresmgr.cpp
@@ -32,31 +32,6 @@
namespace Saga2 {
-/* ===================================================================== *
- Calls which do disk access
- bool hResContext::seek(hResID id)
- fseek
- void hResContext::rest(void)
- fclose
- bool hResContext::read(void *buffer, int32 size)
- fread
- uint32 hResContext::readbytes(void *buffer, uint32 size)
- fseek
- fread
- bool hResContext::skip(int32 amount)
- fseek
- RHANDLE hResContext::loadIndex( int16 index, const char desc[], bool cacheable )
- fseek
- hResource::hResource(char *resname, char *extname, const char desc[])
- fopen
- fseek
- fread
- hResource::~hResource()
- fclose
-
- Calls which deal with external files
- HR_FILE *hResContext::openExternal(HR_FILE *fh)
- * ===================================================================== */
/* ===================================================================== *
Resource context
* ===================================================================== */
diff --git a/engines/saga2/hresmgr.h b/engines/saga2/hresmgr.h
index 07ab2b443c..d03a68871d 100644
--- a/engines/saga2/hresmgr.h
+++ b/engines/saga2/hresmgr.h
@@ -34,25 +34,6 @@ namespace Saga2 {
#define USE_MEMORY_MAPPED_FILES 0
-#if defined(_WIN32) && USE_MEMORY_MAPPED_FILES
-#define HR_FILE MMFILE
-#define HR_OPEN mmfopen
-#define HR_CLOSE mmfclose
-#define HR_SEEK mmfseek
-#define HR_READ mmfread
-#else
-#define HR_FILE FILE
-#define HR_OPEN ftaopen
-#define HR_CLOSE ftaclose
-#define HR_SEEK ftaseek
-#define HR_READ ftaread
-#endif
-
-
-#ifdef _WIN32 // Set structure alignment packing value to 1 byte
-#pragma pack( push, 1 )
-#endif
-
/* ===================================================================== *
Constants and common types
* ===================================================================== */
@@ -190,27 +171,9 @@ public:
void readResource(hResEntry &element);
};
-/* ===================================================================== *
- Resource Type Macros
- * ===================================================================== */
-
-#if 0
-#define RES_ID(a,b,c,d) ((uint32)(a) | (uint32)(b) << 8 | \
- (uint32)(c) << 16 | (uint32)(d) << 24)
-
-#else
-inline hResID RES_ID(uint8 a, uint8 b, uint8 c, uint8 d) {
- return ((uint32)(a) | (uint32)(b) << 8 | (uint32)(c) << 16 | (uint32)(d) << 24);
-}
-#endif
-
#define HRES_ID MKTAG('H','R','E','S')
-#ifdef _WIN32 // Set structure alignment packing value to 1 byte
-#pragma pack( pop )
-#endif
-
} // end of namespace Saga2
#endif
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index bd544e194f..6e1f29565e 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -123,9 +123,6 @@ uint8 *builtinObjectAddress(int16 segment, uint16 index) {
default:
error("Invalid builtin object segment number: %d\n", segment);
}
-#if _WIN32
- return NULL;
-#endif
}
//-----------------------------------------------------------------------
diff --git a/engines/saga2/ioerrors.h b/engines/saga2/ioerrors.h
deleted file mode 100644
index f1893a2146..0000000000
--- a/engines/saga2/ioerrors.h
+++ /dev/null
@@ -1,163 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * aint32 with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#ifndef SAGA2_IOERRORS_H
-#define SAGA2_IOERRORS_H
-
-namespace Saga2 {
-
-#ifdef _WIN32
-#define F_OK 0
-#define W_OK 2
-#define R_OK 4
-#endif
-
-/* ===================================================================== *
- Inlines
- * ===================================================================== */
-
-//-----------------------------------------------------------------------
-// error checking fopen
-
-inline FILE *ftaopen(const char *filename, const char *access) {
-#if 0
- FILE *fp = fopen(filename, access);
- if (fp == NULL)
- systemConfigError(cpResFileMissing, "opening file '%s'", filename);
- return fp;
-#endif
- warning("STUB: ftaopen()");
- return nullptr;
-}
-
-//-----------------------------------------------------------------------
-// error checking fclose
-
-inline int ftaclose(void *fp) {
-#if 0
- int r = fclose(fp);
- if (r)
- systemConfigError(cpResFileClose, "closing a program file");
- return r;
-#endif
- warning("STUB: ftaclose()");
- return 0;
-}
-
-//-----------------------------------------------------------------------
-// error checking fseek
-
-inline int ftaseek(void *fp, size_t offset, int relativeTo) {
-#if 0
- int r = fseek(fp, offset, relativeTo);
- if (r)
- systemConfigError(cpResFileSeek, "seeking in a program file");
- return r;
-#endif
- warning("STUB: ftaseek()");
- return 0;
-}
-
-//-----------------------------------------------------------------------
-// error checking fread
-
-inline size_t ftaread(void *targ, size_t size, size_t count, void *fp) {
-#if 0
- size_t r = fread(targ, size, count, fp);
- if (r < count)
- systemConfigError(cpResFileRead, "reading a program file");
- return r;
-#endif
- warning("STUB: ftaread()");
- return 0;
-}
-
-//-----------------------------------------------------------------------
-// error checking fwrite
-
-inline size_t ftawrite(void *targ, size_t size, size_t count, void *fp) {
-#if 0
- size_t r = fwrite(targ, size, count, fp);
- if (r < count)
- systemConfigError(cpResFileWrite, "writing a program file");
- return r;
-#endif
- warning("STUB: ftawrite()");
- return 0;
-}
-
-//-----------------------------------------------------------------------
-// check file existence
-
-inline bool fileExists(const char f[]) {
-#if 0
-#ifndef _WIN32
- struct stat st; // Added because without it
- stat(f, &st); // Watcom doesnt always notice CD changes
-#endif
- return (!access(f, F_OK));
-#endif
- warning("STUB: fileExists()");
- return false;
-}
-
-//-----------------------------------------------------------------------
-// check file readability
-
-inline bool fileReadable(const char f[]) {
-#if 0
-#ifndef _WIN32
- struct stat st; // Added because without it
- stat(f, &st); // Watcom doesnt always notice CD changes
-#endif
- return (!access(f, R_OK));
-#endif
- warning("STUB: fileReadable()");
- return false;
-}
-
-//-----------------------------------------------------------------------
-// get the file date
-
-inline int32 getFileDate(const char f[]) {
-#if 0
-#ifdef _WIN32
- struct stat st;
- stat(f, &st);
- return st.st_mtime;
-#else
- struct stat st;
- stat(f, &st);
- return st.st_mtime;
-#endif
-#endif
- warning("STUB: getFileDate()");
- return 0;
-}
-
-} // end of namespace Saga2
-
-#endif
diff --git a/engines/saga2/loadsave.cpp b/engines/saga2/loadsave.cpp
index e08a7bc730..bad6e31dde 100644
--- a/engines/saga2/loadsave.cpp
+++ b/engines/saga2/loadsave.cpp
@@ -45,7 +45,6 @@
#include "saga2/vpal.h"
#include "saga2/palette.h"
#include "saga2/contain.h"
-#include "saga2/ioerrors.h"
namespace Saga2 {
diff --git a/engines/saga2/mainmap.h b/engines/saga2/mainmap.h
index b116d11266..e45aba034d 100644
--- a/engines/saga2/mainmap.h
+++ b/engines/saga2/mainmap.h
@@ -31,39 +31,6 @@ namespace Saga2 {
void main_saga2();
-/* ===================================================================== *
- Multitasking control
- * ===================================================================== */
-
-// Forbid() disables all multitasking within this application,
-// and Permit() re-enables it. Use these when you need to access
-// critical data and don't want other tasks mucking with it.
-// (DOS tasking is cooperative, so these funcs are NULL).
-//
-// REM: Use these with extreme caution! You can cause the
-// program to lock up if used improperly. Make sure every
-// Forbid() has a matching Permit(), even under error conditions.
-
-#ifdef _WIN32
-void Forbid(void);
-void Permit(void);
-#else
-inline void Forbid(void) {}
-inline void Permit(void) {}
-#endif
-
-#ifdef _WIN32
-#define returnAfterThrow(n) return n
-#else
-#define returnAfterThrow(n)
-#endif
-
-#ifdef _WIN32
-#define controlPause(n) ((void)0)
-#else
-#define controlPause(n) delay(n)
-#endif
-
// command line parsing
//extern char *commandLineHelp;
void parseCommandLine(int argc, char *argv[]);
diff --git a/engines/saga2/noise.cpp b/engines/saga2/noise.cpp
index d3a97c72f6..220c2e6894 100644
--- a/engines/saga2/noise.cpp
+++ b/engines/saga2/noise.cpp
@@ -749,11 +749,8 @@ int annoyingTestVoice(int32 sampID) {
//-----------------------------------------------------------------------
int annoyingTestMusic(int32 sampID) {
-#if defined(_WIN32) && !defined(USE_REAL_WAIL)
- playMusic(MKTAG('M', 'I', 'D', sampID));
-#else
+ //playMusic(MKTAG('M', 'I', 'D', sampID));
playMusic(MKTAG('X', 'M', 'I', sampID));
-#endif
return 0;
}
diff --git a/engines/saga2/objects.h b/engines/saga2/objects.h
index f61d27b4c8..89b1595fab 100644
--- a/engines/saga2/objects.h
+++ b/engines/saga2/objects.h
@@ -32,10 +32,6 @@
namespace Saga2 {
-#ifdef _WIN32 // Set structure alignment packing value to 1 byte
-#pragma pack( push, 1 )
-#endif
-
/* ======================================================================= *
GameObject: Describes an instance of an object
* ======================================================================= */
@@ -1453,10 +1449,6 @@ void resumeObjectStates(void);
void readyContainerSetup(void);
void cleanupReadyContainers(void);
-#ifdef _WIN32 // Reset old structure alignment
-#pragma pack( pop )
-#endif
-
} // end of namespace Saga2
#endif
diff --git a/engines/saga2/path.cpp b/engines/saga2/path.cpp
index 92241ae61f..80da6a10cf 100644
--- a/engines/saga2/path.cpp
+++ b/engines/saga2/path.cpp
@@ -563,13 +563,6 @@ PathCell *PathArray::makeCell(int plat, int uCoord, int vCoord, bool *newCell) {
} else {
// Failed to allocate cell so throw exception
error("Cell Allocation failure");
-
-#ifdef _WIN32
- // Visual C++ 4.0 requires this return because it appearently
- // does not recognize the 'throw' statement as a return
- // structure
- return nullptr;
-#endif
}
}
diff --git a/engines/saga2/rect.h b/engines/saga2/rect.h
index bafade9606..694018d913 100644
--- a/engines/saga2/rect.h
+++ b/engines/saga2/rect.h
@@ -48,24 +48,6 @@ public:
x = nx;
y = ny;
}
-#if _MACINTOSH
- Point16(Point p) {
- x = p.h;
- y = p.v;
- }
- operator Point() {
- Point p;
- p.h = x;
- p.v = y;
- return p;
- }
-#endif
-#if defined( USEWINDOWS ) || defined( _WIN32 )
- Point16(LPARAM lparam) {
- x = LOWORD(lparam);
- y = HIWORD(lparam);
- }
-#endif
Point16(StaticPoint16 p) {
x = p.x;
@@ -177,25 +159,6 @@ public:
return Point16((int16)x, (int16)y);
}
-#if _MACINTOSH
- Point32(Point p) {
- x = p.h;
- y = p.v;
- }
- operator Point() {
- Point p;
- p.h = x;
- p.v = y;
- return p;
- }
-#endif
-#if defined( USEWINDOWS ) || defined( _WIN32 )
- Point32(LPARAM lparam) {
- x = LOWORD(lparam);
- y = HIWORD(lparam);
- }
-#endif
-
Point32(StaticPoint32 p) {
x = p.x;
y = p.y;
@@ -307,38 +270,6 @@ public:
width = (int16)(b.x - a.x);
height = (int16)(b.y - a.y);
}
-#if _MACINTOSH
- Rect16(Rect r) {
- x = r.left;
- y = r.top;
- width = r.right - r.left;
- height = r.bottom - r.top;
- }
- operator Rect() {
- Rect r;
- r.left = x;
- r.top = y;
- r.right = x + width;
- r.bottom = y + height;
- return r;
- }
-#endif
-#if defined( USEWINDOWS ) || defined( _WIN32 )
- Rect16(RECT r) {
- x = (int16)r.left;
- y = (int16)r.top;
- width = (int16)(r.right - r.left);
- height = (int16)(r.bottom - r.top);
- }
- operator RECT() {
- RECT r;
- r.left = x;
- r.top = y;
- r.right = x + width;
- r.bottom = y + height;
- return r;
- }
-#endif
Rect16(StaticRect r) {
x = r.x;
@@ -459,38 +390,6 @@ public:
return Rect16((int16)x, (int16)y, (int16)width, (int16)height);
}
-#if _MACINTOSH
- Rect32(Rect r) {
- x = r.left;
- y = r.top;
- width = r.right - r.left;
- height = r.bottom - r.top;
- }
- operator Rect() {
- Rect r;
- r.left = x;
- r.top = y;
- r.right = x + width;
- r.bottom = y + height;
- return r;
- }
-#endif
-#if defined( USEWINDOWS ) || defined( _WIN32 )
- Rect32(RECT r) {
- x = r.left;
- y = r.top;
- width = r.right - r.left;
- height = r.bottom - r.top;
- }
- operator RECT() {
- RECT r;
- r.left = x;
- r.top = y;
- r.right = x + width;
- r.bottom = y + height;
- return r;
- }
-#endif
// Rect32 operators
friend int operator==(Rect32 a, Rect32 b) {
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index d4fa54d789..bc0f26acdb 100644
--- a/engines/saga2/sagafunc.cpp
+++ b/engines/saga2/sagafunc.cpp
@@ -52,11 +52,6 @@
void drawMainDisplay(void);
-
-#ifndef _WIN32
-#pragma off (unreferenced);
-#endif
-
#define MONOLOG(s) {debugC(2, kDebugScripts, "cfunc: " #s );}
#define OBJLOG(s) {debugC(2, kDebugScripts, "cfunc: [%s]." #s , ((GameObject *)thisThread->thisObject)->objName() );}
@@ -3056,9 +3051,9 @@ int16 scriptGetCenterActor(int16 *) {
int16 scriptPlaySound(int16 *args) {
MONOLOG(PlaySound);
char *sID = STRING(args[0]);
-//#ifndef _WIN32
+
PlaySound(sID);
-//#endif
+
return 0;
}
@@ -3167,9 +3162,9 @@ int16 scriptIsContaining(int16 *args) {
int16 scriptPlayLongSound(int16 *args) {
MONOLOG(PlayLongSound);
char *sID = STRING(args[0]);
-#ifndef _WIN32
+
PlayLongSound(sID);
-#endif
+
return 0;
}
@@ -3780,9 +3775,9 @@ int16 scriptOpenAutoMap(int16 *args) {
int16 scriptPlayVideo(int16 *args) {
MONOLOG(PlaySound);
char *sID = STRING(args[0]);
-//#ifndef _WIN32
+
openVidBox(sID);
-//#endif
+
return 0;
}
diff --git a/engines/saga2/script.h b/engines/saga2/script.h
index 7732559f84..dc294a1071 100644
--- a/engines/saga2/script.h
+++ b/engines/saga2/script.h
@@ -32,10 +32,6 @@
namespace Saga2 {
-#ifdef _WIN32 // Set structure alignment packing value to 1 byte
-#pragma pack( push, 1 )
-#endif
-
typedef int16 ThreadID;
// Various result codes returned from runScript
@@ -350,10 +346,6 @@ struct ResImportTable {
extern ResImportTable *resImports;
-#ifdef _WIN32 // Reset old structure alignment
-#pragma pack( pop )
-#endif
-
} // end of namespace Saga2
#endif
diff --git a/engines/saga2/sprite.h b/engines/saga2/sprite.h
index ca8e7be838..f782d1be50 100644
--- a/engines/saga2/sprite.h
+++ b/engines/saga2/sprite.h
@@ -34,10 +34,6 @@ namespace Saga2 {
class gPort;
class gPixelMap;
-#ifdef _WIN32 // Set structure alignment packing value to 1 byte
-#pragma pack( push, 1 )
-#endif
-
/* ===================================================================== *
Basic sprite structures
* ===================================================================== */
@@ -386,10 +382,6 @@ void buildColorTable(
ActorAppearance *LoadActorAppearance(uint32 id, int16 banksNeeded);
void ReleaseActorAppearance(ActorAppearance *aa);
-#ifdef _WIN32 // Set structure alignment packing value to 1 byte
-#pragma pack( pop )
-#endif
-
} // end of namespace Saga2
#endif
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 5bce04cde0..604915a6a1 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -4552,18 +4552,6 @@ bool underSameRoof(GameObject *obj1, GameObject *obj2) {
extern void testSprites(void);
-
-#ifdef _WIN32
-void *LockTileDrawMapSurface(LPRECT rc = nullptr);
-bool UnlockTileDrawMapSurface(void *);
-void drawTileMapToScreen(Rect16 tileRect, void *);
-#include "ftawin.h"
-extern CFTWindow *pWindow;
-extern uint32 tileSurfaceWidth;
-extern uint32 tileSurfaceHeight;
-
-#endif
-
void updateMainDisplay(void) {
static TilePoint lastViewLoc = TilePoint(0, 0, 0);
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index 9da34bfe90..2f4b167cca 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -35,10 +35,6 @@
#include "saga2/property.h"
#include "saga2/tcoords.h"
-#ifdef _WIN32 // Set structure alignment packing value to 1 byte
-#pragma pack( push, 1 )
-#endif
-
namespace Saga2 {
/* ===================================================================== *
@@ -1072,11 +1068,6 @@ TilePoint selectNearbySite(
int32 maxDist,
bool offScreenOnly = false); // true if we want it off-screen
-
-#ifdef _WIN32 // Set structure alignment packing value to 1 byte
-#pragma pack( pop )
-#endif
-
} // end of namespace Saga2
#endif
diff --git a/engines/saga2/tileline.cpp b/engines/saga2/tileline.cpp
index a6ea506dd2..f036eca572 100644
--- a/engines/saga2/tileline.cpp
+++ b/engines/saga2/tileline.cpp
@@ -54,11 +54,6 @@ void TPCircle(const TilePoint &tp, const int radius, int16 color) {
TPLine(tp + TilePoint(radius / 1, radius / -2, 0), tp + TilePoint(radius / 1, radius / 2, 0), color);
}
-#ifdef _WIN32
-#include <windows.h>
-#include "saga2/ftawin.h"
-extern CFTWindow *pWindow;
-#endif
extern Rect16 tileRect;
// Draw a line in TP space
@@ -75,21 +70,9 @@ void TPLine(const TilePoint &start, const TilePoint &stop) {
startPt.y += tileRect.y;
stopPt.y += tileRect.y;
-#ifdef _WIN32
- HDC hdc;
- HPEN hPen;
-
- hdc = GetDC(pWindow->m_hWnd);
- hPen = SelectObject(hdc, GetStockObject(WHITE_PEN));
- MoveToEx(hdc, startPt.x, startPt.y, NULL);
- LineTo(hdc, stopPt.x, stopPt.y);
- SelectObject(hdc, hPen);
- ReleaseDC(pWindow->m_hWnd, hdc);
-#else
mainPort.setColor(1);
mainPort.moveTo(startPt);
mainPort.drawTo(stopPt);
-#endif
}
void TPLine(const TilePoint &start, const TilePoint &stop, int16 color);
@@ -106,21 +89,9 @@ void TPLine(const TilePoint &start, const TilePoint &stop, int16 color) {
startPt.y += tileRect.y;
stopPt.y += tileRect.y;
-#ifdef _WIN32
- HDC hdc;
- HPEN hPen;
-
- hdc = GetDC(pWindow->m_hWnd);
- hPen = SelectObject(hdc, GetStockObject(WHITE_PEN));
- MoveToEx(hdc, startPt.x, startPt.y, NULL);
- LineTo(hdc, stopPt.x, stopPt.y);
- SelectObject(hdc, hPen);
- ReleaseDC(pWindow->m_hWnd, hdc);
-#else
mainPort.setColor(color);
mainPort.moveTo(startPt);
mainPort.drawTo(stopPt);
-#endif
}
#endif
diff --git a/engines/saga2/tileload.h b/engines/saga2/tileload.h
index 4953644482..2e84af67e1 100644
--- a/engines/saga2/tileload.h
+++ b/engines/saga2/tileload.h
@@ -29,10 +29,6 @@
namespace Saga2 {
-#ifdef _WIN32 // Set structure alignment packing value to 1 byte
-#pragma pack( push, 1 )
-#endif
-
const int maxBanks = 64; // 64 banks maximum
/* ============================================================================ *
diff --git a/engines/saga2/towerfta.cpp b/engines/saga2/towerfta.cpp
index afbc5c1f50..b1c3635ad9 100644
--- a/engines/saga2/towerfta.cpp
+++ b/engines/saga2/towerfta.cpp
@@ -99,17 +99,10 @@ bool openResources(void);
void closeResources(void);
void initServers(void);
void cleanupServers(void);
-//void initBackPanel(void);
void initMagic(void);
void cleanupMagic(void);
void cleanupMousePointer(void);
-//void mainEnable( void );
-//void mainDisable( void );
-//void lightsOut( void );
void resetInputDevices(void);
-#ifdef _WIN32
-// void localCursorOn( void );
-#endif
extern hResContext *tileRes; // tile resource handle
extern hResContext *listRes;
diff --git a/engines/saga2/tromode.cpp b/engines/saga2/tromode.cpp
index f11ee259f3..fb76e88fe0 100644
--- a/engines/saga2/tromode.cpp
+++ b/engines/saga2/tromode.cpp
@@ -68,10 +68,6 @@ void blackOut(void);
void quickSavePalette(void);
void quickRestorePalette(void);
void cursorFullHide(bool onOff);
-#ifdef _WIN32
-void suspendWinTimer(void);
-void resumeWinTimer(void);
-#endif
static void doIntro(void);
static void doWintro(int16 whichOne);
@@ -169,9 +165,6 @@ void TroModeExternEvent(void) {
static void TroModeSetup(void) {
suspendAudio();
pointer.hide();
-#ifdef _WIN32
- cursorFullHide(true);
-#endif
quickSavePalette();
blackOut();
displayDisable(PlayingVideo);
@@ -190,9 +183,6 @@ static void TroModeCleanup(void) {
blackOut();
quickRestorePalette();
resumeAudio();
-#ifdef _WIN32
- cursorFullHide(false);
-#endif
pointer.show();
// pointer.manditoryShow(); // hide mouse pointer
resetInputDevices();
Commit: 5dc97185ee924f7df3aa65431d4f32adbce7fef0
https://github.com/scummvm/scummvm/commit/5dc97185ee924f7df3aa65431d4f32adbce7fef0
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:42+02:00
Commit Message:
SAGA2: Fix remaining WindowDecoration constructor warnings
Changed paths:
engines/saga2/contain.cpp
engines/saga2/document.cpp
engines/saga2/document.h
diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index 6991349a72..491eac9b3f 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -176,8 +176,9 @@ ContainerAppearanceDef deathContainerAppearance(
);
// physal dialog window decorations
-static StaticWindow deathDecorations[] =
-{ {{0, 0, 206, 250}, nullptr, 15} };
+static StaticWindow deathDecorations[] = {
+ {{0, 0, 206, 250}, nullptr, 15}
+};
//-----------------------------------------------------------------------
// ReadyContainer appearance
@@ -219,9 +220,9 @@ ContainerAppearanceDef mentalContainerAppearance(
20 // Total rows
);
-static StaticWindow mentalDecorations[] =
-{ {{0, 0, 158, 215}, nullptr, 0} }; // Bottom decoration panel
-
+static StaticWindow mentalDecorations[] = {
+ {{0, 0, 158, 215}, nullptr, 0} // Bottom decoration panel
+};
//-----------------------------------------------------------------------
// Enchantment container appearance
diff --git a/engines/saga2/document.cpp b/engines/saga2/document.cpp
index 271d0836b6..e29b27abd9 100644
--- a/engines/saga2/document.cpp
+++ b/engines/saga2/document.cpp
@@ -57,10 +57,10 @@ APPFUNC(cmdDocumentQuit);
//Rect16 closeScrollBtnRect( 184, 206, 44, 42 );
// options dialog window decorations
-WindowDecoration scrollDecorations[] = {
- { WindowDecoration(Rect16(202, 54, 232, 100), 0) },
- { WindowDecoration(Rect16(212, 154, 212, 100), 1) },
- { WindowDecoration(Rect16(202, 254, 236, 117), 2) }
+static StaticWindow scrollDecorations[] = {
+ {{202, 54, 232, 100}, nullptr, 0},
+ {{212, 154, 212, 100}, nullptr, 1},
+ {{202, 254, 236, 117}, nullptr, 2}
};
static uint8 scrollTextColors[] = { 65, 65, 65, 65, 65, 65, 65, 66, 66, 67, 67, 67, 67, 66, 66, 66 };
@@ -84,10 +84,10 @@ CDocumentAppearance scrollAppearance(
* ===================================================================== */
// options dialog window decorations
-WindowDecoration bookDecorations[] = {
- { WindowDecoration(Rect16(123, 76, 394, 88), 0) },
- { WindowDecoration(Rect16(123, 164, 394, 80), 1) },
- { WindowDecoration(Rect16(123, 244, 394, 77), 2) }
+static StaticWindow bookDecorations[] = {
+ {{123, 76, 394, 88}, nullptr, 0},
+ {{123, 164, 394, 80}, nullptr, 1},
+ {{123, 244, 394, 77}, nullptr, 2}
};
static uint8 bookTextColors[] = { 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 };
@@ -111,8 +111,9 @@ CDocumentAppearance bookAppearance(
* ===================================================================== */
// options dialog window decorations
-WindowDecoration parchDecorations[] =
-{ { WindowDecoration(Rect16(202, 54, 208, 256), 0) } };
+static StaticWindow parchDecorations[] = {
+ {{202, 54, 208, 256}, nullptr, 0}
+};
CDocumentAppearance parchAppearance(
Rect16(202, 54, 208, 256), // Window size
diff --git a/engines/saga2/document.h b/engines/saga2/document.h
index e800d0101b..c3c962fdb5 100644
--- a/engines/saga2/document.h
+++ b/engines/saga2/document.h
@@ -65,7 +65,7 @@ public:
uint8 *textColors; // Text color array
Rect16 pageRect[maxVisiblePages];// Array of visible page rects
Rect16 closeRect; // Close-box rectangle
- WindowDecoration *decoList; // List of decorator panels
+ StaticWindow *decoList; // List of decorator panels
int16 numDecos; // Number of decorator panels
hResID groupID; // Resource ID for decoration group
hResID decoID; // Resource ID for decorations
@@ -78,7 +78,7 @@ public:
Rect16 _pageRect_0,
Rect16 _pageRect_1,
Rect16 _closeRect,
- WindowDecoration *_decoList,
+ StaticWindow *_decoList,
int16 _numDecos,
hResID _groupID,
hResID _decoID)
Commit: 307e094d4fbd6c1ce712dd6f0a8e1e566a81cf74
https://github.com/scummvm/scummvm/commit/307e094d4fbd6c1ce712dd6f0a8e1e566a81cf74
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:42+02:00
Commit Message:
SAGA2: Stubbed musicBuffer methods
Changed paths:
engines/saga2/audiobuf.cpp
engines/saga2/keybored.cpp
engines/saga2/main.cpp
engines/saga2/tilemode.cpp
engines/saga2/vbacksav.cpp
engines/saga2/vpage.h
diff --git a/engines/saga2/audiobuf.cpp b/engines/saga2/audiobuf.cpp
index 9b425ac45b..1d54bab85e 100644
--- a/engines/saga2/audiobuf.cpp
+++ b/engines/saga2/audiobuf.cpp
@@ -110,19 +110,25 @@ musicBuffer::musicBuffer(size_t newSize, audioInterface *sd, int16 newID)
bufID = newID;
fillBuffer = 0;
targetSated = false;
+ warning("STUB: musicBuffer::musicBuffer()");
+#if 0
ailSampleHandle = AIL_allocate_sequence_handle(sd->mid);
if (ailSampleHandle == 0)
error("Unable to allocate music handle");
+#endif
data[1] = NULL;
audioSet = 0;
}
}
musicBuffer::~musicBuffer(void) {
+ warning("STUB: musicBuffer::~musicBuffer()");
+#if 0
assert(ailSampleHandle);
if (ailSampleHandle) {
AIL_release_sequence_handle(ailSampleHandle);
}
+#endif
}
@@ -215,7 +221,11 @@ uint32 workBuffer::sample_status(void) {
uint32 musicBuffer::sample_status(void) {
+ warning("STUB: musicBuffer::sample_status()");
+ return 0;
+#if 0
return (AIL_sequence_status(ailSampleHandle));
+#endif
}
/*******************************************************************/
@@ -374,10 +384,13 @@ void musicBuffer::abortsound(void) {
}
void musicBuffer::release(void) {
+ warning("STUB: musicBuffer::release()");
+#if 0
assert(ailSampleHandle);
// new
AIL_end_sequence(ailSampleHandle);
audioSet = 0;
+#endif
}
/*******************************************************************/
@@ -395,6 +408,8 @@ void workBuffer::play(int16 bufNo) {
}
void musicBuffer::play(int16 bufNo) {
+ warning("STUB: musicBuffer::play()");
+#if 0
assert(bufNo == 0);
assert(ailSampleHandle);
if (AIL_init_sequence(ailSampleHandle, rData, 0) <= 0) {
@@ -404,6 +419,7 @@ void musicBuffer::play(int16 bufNo) {
AIL_set_sequence_loop_count(ailSampleHandle, loopCount);
AIL_start_sequence(ailSampleHandle);
took(rSize);
+#endif
}
/*******************************************************************/
@@ -468,9 +484,12 @@ void workBuffer::reset(void) {
}
void musicBuffer::reset(void) {
+ warning("STUB: musicBuffer::reset()");
+#if 0
AIL_end_sequence(ailSampleHandle);
audioSet = 0;
activate(0);
+#endif
}
/*******************************************************************/
@@ -483,6 +502,8 @@ void workBuffer::setVolume(int8) {
}
void musicBuffer::setVolume(int8 v) {
+ warning("STUB: musicBuffer::setVolume()");
+#if 0
if (audioSet) {
if (AIL_sequence_volume(ailSampleHandle) != v) {
AIL_lock();
@@ -490,22 +511,29 @@ void musicBuffer::setVolume(int8 v) {
AIL_unlock();
}
}
+#endif
}
void musicBuffer::fadeUp(int16 time, int8 volume) {
+ warning("STUB: musicBuffer::fadeUp()");
+#if 0
if (audioSet) {
AIL_lock();
AIL_set_sequence_volume(ailSampleHandle, volume, time);
AIL_unlock();
}
+#endif
}
void musicBuffer::fadeDown(int16 time) {
+ warning("STUB: musicBuffer::fadeDown()");
+#if 0
if (audioSet) {
AIL_lock();
AIL_set_sequence_volume(ailSampleHandle, 0, time);
AIL_unlock();
}
+#endif
}
} // end of namespace Saga2
diff --git a/engines/saga2/keybored.cpp b/engines/saga2/keybored.cpp
index ed2fe9f8e5..56afa6979d 100644
--- a/engines/saga2/keybored.cpp
+++ b/engines/saga2/keybored.cpp
@@ -80,8 +80,6 @@ void voiceTest2(void);
#endif
void toggleMusic(void);
-void RShowMem(void);
-
extern APPFUNCV(videoTest1);
extern APPFUNCV(videoTest2);
@@ -141,10 +139,6 @@ void TileModeHandleKey(int16 key, int16 /* qual */) {
if (a) MotionTask::jump(*a);
break;
- case 'l':
- RShowMem();
- break;
-
#ifdef WINKLUDGE
case 'm':
toggleMusic();
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 1d18377bd9..ffb785f75d 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -171,7 +171,6 @@ void mainDisable(void);
void lightsOut(void);
void cleanupGame(void); // auto-cleanup function
-void RShowMem(void);
void parseCommandLine(int argc, char *argv[]);
const char *getExeFromCommandLine(int argc, char *argv[]);
void WriteStatusF2(int16 line, const char *msg, ...);
diff --git a/engines/saga2/tilemode.cpp b/engines/saga2/tilemode.cpp
index c447e1965f..02c040682e 100644
--- a/engines/saga2/tilemode.cpp
+++ b/engines/saga2/tilemode.cpp
@@ -123,8 +123,6 @@ void voiceTest2(void);
void toggleMusic(void);
-void RShowMem(void);
-
#if CHEATMOVE
void cheatMove(int16 key);
#endif
@@ -148,9 +146,8 @@ Alarm dispObjNameAlarm; // Alarm used for time delay
Alarm containerObjTextAlarm; // time delay for container view object text
-#if DEBUG && TEST1
ObjectID pickedActor;
-#endif
+
#if CHEATMOVE
ObjectID selectedObject = Nothing;
bool nudge = false;
@@ -1019,42 +1016,6 @@ void TileModeHandleKey(int16 key, int16 qual) {
break;
#endif
-
-#if DEBUG
- case 'l':
- RShowMem();
- break;
-
- case 't':
- extern bool showTile;
- showTile = !showTile;
- break;
-
- // basically for changing the light level
-
- case 'c': {
- extern bool autoMapCheat;
- autoMapCheat = !autoMapCheat;
- }
- break;
-
- case 'h':
- calender.hour += 1;
-
- if (calender.hour >= 24) {
- calender.hour = 0;
- }
-
- break;
-
- case 'w':
- calender.hour = 9;
- calender.days++;
- dayNightUpdate();
-
- break;
-#endif
-
default:
if (uiKeysEnabled)
lastUnusedKey = key;
diff --git a/engines/saga2/vbacksav.cpp b/engines/saga2/vbacksav.cpp
index 68e2df0219..c9ce3b5b96 100644
--- a/engines/saga2/vbacksav.cpp
+++ b/engines/saga2/vbacksav.cpp
@@ -30,7 +30,7 @@
namespace Saga2 {
gBackSave::gBackSave(const Rect16 &extent) {
- Rect16 displayRect(0, 0, gDisplaySize.x, gDisplaySize.y);
+ Rect16 displayRect(0, 0, 640, 480);
// initialize the rectangle
diff --git a/engines/saga2/vpage.h b/engines/saga2/vpage.h
index 68cd5018e9..ba669e9662 100644
--- a/engines/saga2/vpage.h
+++ b/engines/saga2/vpage.h
@@ -62,13 +62,6 @@ public:
virtual void writeComplementPixels(Rect16 dispRect, uint8 *pixPtr, uint16 pixMod, uint8 color);
};
-extern Extent16 gDisplaySize;
-
-#if defined( USEWINDOWS )
-// For access to WinPause/ResumeTransfer()'s
-#include "WDisplay.h"
-#endif
-
} // end of namespace Saga2
#endif
Commit: b02941237d4e23cee1b65ff91f8a7eacd55742a6
https://github.com/scummvm/scummvm/commit/b02941237d4e23cee1b65ff91f8a7eacd55742a6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:42+02:00
Commit Message:
SAGA2: Fix unreferenced symbols
Changed paths:
engines/saga2/audiobuf.cpp
engines/saga2/tilemode.cpp
diff --git a/engines/saga2/audiobuf.cpp b/engines/saga2/audiobuf.cpp
index 1d54bab85e..5868efc40c 100644
--- a/engines/saga2/audiobuf.cpp
+++ b/engines/saga2/audiobuf.cpp
@@ -103,6 +103,8 @@ workBuffer::~workBuffer(void) {
musicBuffer::musicBuffer(size_t newSize, audioInterface *sd, int16 newID)
: Buffer(newSize) {
+ warning("STUB: musicBuffer::musicBuffer()");
+#if 0
if (sd && sd->enabled(volMusic)) {
assert(sd);
assert(sd->mid);
@@ -110,15 +112,13 @@ musicBuffer::musicBuffer(size_t newSize, audioInterface *sd, int16 newID)
bufID = newID;
fillBuffer = 0;
targetSated = false;
- warning("STUB: musicBuffer::musicBuffer()");
-#if 0
ailSampleHandle = AIL_allocate_sequence_handle(sd->mid);
if (ailSampleHandle == 0)
error("Unable to allocate music handle");
-#endif
data[1] = NULL;
audioSet = 0;
}
+#endif
}
musicBuffer::~musicBuffer(void) {
diff --git a/engines/saga2/tilemode.cpp b/engines/saga2/tilemode.cpp
index 02c040682e..1b697b9b48 100644
--- a/engines/saga2/tilemode.cpp
+++ b/engines/saga2/tilemode.cpp
@@ -50,11 +50,8 @@ namespace Saga2 {
#define TEST1 1 // enable test code
#define TEST2 1
#define TEST3 1
-#if DEBUG
+
#define CHEATMOVE 1 // For moving with keypad in 8 directions
-#else
-#define CHEATMOVE 0
-#endif
/* ===================================================================== *
gStickyDragControl class: a gGenericControl with a sticky mouse
Commit: 654964aad00c11c12212ec8d229e4962ccf25fd2
https://github.com/scummvm/scummvm/commit/654964aad00c11c12212ec8d229e4962ccf25fd2
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:42+02:00
Commit Message:
SAGA2: Fix global constructors in document.cpp
Changed paths:
engines/saga2/document.cpp
engines/saga2/document.h
diff --git a/engines/saga2/document.cpp b/engines/saga2/document.cpp
index e29b27abd9..0d6632f1b6 100644
--- a/engines/saga2/document.cpp
+++ b/engines/saga2/document.cpp
@@ -65,19 +65,18 @@ static StaticWindow scrollDecorations[] = {
static uint8 scrollTextColors[] = { 65, 65, 65, 65, 65, 65, 65, 66, 66, 67, 67, 67, 67, 66, 66, 66 };
-CDocumentAppearance scrollAppearance(
- Rect16(202, 54, 236, 317), // Window size
- 1,
- pageOrientVertical,
- scrollTextColors,
- Rect16(50, 64, 131, 169), // Page 1
- Rect16(0, 0, 0, 0), // (No page 2)
- Rect16(184, 206, 44, 42), // Close button rect
- scrollDecorations,
- ARRAYSIZE(scrollDecorations),
- MKTAG('S', 'C', 'R', 'L'),
- MKTAG('S', 'R', 'L', 0)
-);
+CDocumentAppearance scrollAppearance = {
+ {202, 54, 236, 317},
+ 1,
+ pageOrientVertical,
+ scrollTextColors,
+ { {50, 64, 131, 169}, {0, 0, 0, 0} },
+ {184, 206, 44, 42},
+ scrollDecorations,
+ ARRAYSIZE(scrollDecorations),
+ MKTAG('S', 'C', 'R', 'L'),
+ MKTAG('S', 'R', 'L', 0)
+};
/* ===================================================================== *
Book metrics
@@ -92,19 +91,18 @@ static StaticWindow bookDecorations[] = {
static uint8 bookTextColors[] = { 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 };
-CDocumentAppearance bookAppearance(
- Rect16(123, 76, 394, 252), // Window size
- 2,
- pageOrientHorizontal,
- bookTextColors,
- Rect16(40, 26, 135, 205), // Page 1
- Rect16(218, 26, 135, 205), // Page 2
- Rect16(231, 217, 34, 27), // Close button rect
- bookDecorations,
- ARRAYSIZE(bookDecorations),
- MKTAG('B', 'O', 'O', 'K'),
- MKTAG('B', 'K', 'D', 0)
-);
+CDocumentAppearance bookAppearance = {
+ {123, 76, 394, 252},
+ 2,
+ pageOrientHorizontal,
+ bookTextColors,
+ { {40, 26, 135, 205}, {218, 26, 135, 205} },
+ {231, 217, 34, 27},
+ bookDecorations,
+ ARRAYSIZE(bookDecorations),
+ MKTAG('B', 'O', 'O', 'K'),
+ MKTAG('B', 'K', 'D', 0)
+};
/* ===================================================================== *
Parchment metrics
@@ -115,19 +113,18 @@ static StaticWindow parchDecorations[] = {
{{202, 54, 208, 256}, nullptr, 0}
};
-CDocumentAppearance parchAppearance(
- Rect16(202, 54, 208, 256), // Window size
- 1,
- pageOrientVertical,
- bookTextColors,
- Rect16(27, 18, 149, 212), // Page 1
- Rect16(0, 0, 0, 0), // (No page 2)
- Rect16(164, 229, 20, 20), // Close button rect
- parchDecorations,
- ARRAYSIZE(parchDecorations),
- MKTAG('P', 'A', 'R', 'C'),
- MKTAG('P', 'C', 'H', 0)
-);
+CDocumentAppearance parchAppearance = {
+ {202, 54, 208, 256},
+ 1,
+ pageOrientVertical,
+ bookTextColors,
+ { {27, 18, 149, 212}, {0, 0, 0, 0} },
+ {64, 229, 20, 20},
+ parchDecorations,
+ ARRAYSIZE(parchDecorations),
+ MKTAG('P', 'A', 'R', 'C'),
+ MKTAG('P', 'C', 'H', 0)
+};
// deliminator defines
char deliminator = '@';
@@ -773,7 +770,7 @@ void CDocument::renderText(void) {
for (pageIndex = currentPage;
pageIndex - currentPage < app.numPages && pageIndex < pages;
pageIndex++) {
- Rect16 *pageRect = &app.pageRect[pageIndex % app.numPages];
+ StaticRect *pageRect = &app.pageRect[pageIndex % app.numPages];
// if there is an image on this page
if (images[pageIndex]) {
diff --git a/engines/saga2/document.h b/engines/saga2/document.h
index c3c962fdb5..672fccaeca 100644
--- a/engines/saga2/document.h
+++ b/engines/saga2/document.h
@@ -57,43 +57,17 @@ enum pageOrientation {
pageOrientHorizontal
};
-class CDocumentAppearance {
-public:
- Rect16 windowPos; // Position of window on screen
+struct CDocumentAppearance {
+ StaticRect windowPos; // Position of window on screen
int16 numPages; // Number of visible pages
int16 orientation; // Orientation of pages
uint8 *textColors; // Text color array
- Rect16 pageRect[maxVisiblePages];// Array of visible page rects
- Rect16 closeRect; // Close-box rectangle
+ StaticRect pageRect[maxVisiblePages];// Array of visible page rects
+ StaticRect closeRect; // Close-box rectangle
StaticWindow *decoList; // List of decorator panels
int16 numDecos; // Number of decorator panels
hResID groupID; // Resource ID for decoration group
hResID decoID; // Resource ID for decorations
-
- CDocumentAppearance(
- Rect16 _windowPos,
- int16 _numPages,
- int16 _orientation,
- uint8 *_textColors,
- Rect16 _pageRect_0,
- Rect16 _pageRect_1,
- Rect16 _closeRect,
- StaticWindow *_decoList,
- int16 _numDecos,
- hResID _groupID,
- hResID _decoID)
- : windowPos(_windowPos),
- numPages(_numPages),
- orientation(_orientation),
- textColors(_textColors),
- closeRect(_closeRect),
- decoList(_decoList),
- numDecos(_numDecos),
- groupID(_groupID),
- decoID(_decoID) {
- pageRect[0] = _pageRect_0;
- pageRect[1] = _pageRect_1;
- }
};
// Base class for scrolls, books, and parchments
Commit: 6f70073b566e959040f583839601e6a403b731fb
https://github.com/scummvm/scummvm/commit/6f70073b566e959040f583839601e6a403b731fb
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:42+02:00
Commit Message:
SAGA2: Fix initializer list warnings
Changed paths:
engines/saga2/uidialog.cpp
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index a5f1806ed4..a5ac62e907 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -1519,14 +1519,18 @@ void placardWindow(int8 type, char *text) {
145);
// decoration information
- WindowDecoration plaqDecWood[1] =
- { { WindowDecoration(plaqRectWood, 0) } };
+ WindowDecoration plaqDecWood[1] = {
+ WindowDecoration(plaqRectWood, 0)
+ };
- WindowDecoration plaqDecStone[1] =
- { { WindowDecoration(plaqRectStone, 1) } };
+ WindowDecoration plaqDecStone[1] = {
+ WindowDecoration(plaqRectStone, 1)
+ };
- WindowDecoration plaqDecBrass[2] =
- { { WindowDecoration(plaqRectBrass, 2) } };
+ WindowDecoration plaqDecBrass[2] = {
+ WindowDecoration(plaqRectBrass, 2),
+ WindowDecoration(plaqRectBrass, 2)
+ };
// used to hold the coloration of the text for a give type
textPallete pal;
Commit: 07153ec2cb63f07845714a90bc7a907fad0c27c8
https://github.com/scummvm/scummvm/commit/07153ec2cb63f07845714a90bc7a907fad0c27c8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:42+02:00
Commit Message:
SAGA2: Remove unneeded file
Changed paths:
R engines/saga2/keybored.cpp
engines/saga2/module.mk
diff --git a/engines/saga2/keybored.cpp b/engines/saga2/keybored.cpp
deleted file mode 100644
index 56afa6979d..0000000000
--- a/engines/saga2/keybored.cpp
+++ /dev/null
@@ -1,399 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * aint32 with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Based on the original sources
- * Faery Tale II -- The Halls of the Dead
- * (c) 1993-1996 The Wyrmkeep Entertainment Co.
- */
-
-#include "saga2/saga2.h"
-#include "saga2/tilemode.h"
-#include "saga2/calender.h"
-
-#include "saga2/tile.h"
-#include "saga2/motion.h"
-#include "saga2/modal.h"
-#include "saga2/transit.h"
-#include "saga2/player.h"
-
-#define TEST1 1 // enable test code
-#define TEST2 1
-#define CHEATMOVE 1 // For moving with keypad in 8 directions
-
-#ifdef ALEXS
-#include "saga2/automap.h"
-#include "saga2/uidialog.h"
-
-uint8 temp = 0;
-uint16 secNum = 0;
-
-extern uint16 mapSizeU, mapSizeV;
-uint16 sumNum;
-TilePoint tilePos;
-
-#endif
-
-#ifdef WINKLUDGE
-#include "saga2/automap.h"
-#endif
-
-namespace Saga2 {
-
-extern int16 speechButtonCount; // count of speech buttons
-extern ObjectID viewCenterObject;
-extern ObjectID pickedObject; // which object picked by mouse
-#if TEST1
-extern ObjectID pickedActor;
-#endif
-
-//-----------------------------------------------------------------------
-// Handle keystrokes for main mode.
-
-extern int16 stageType;
-extern int16 shopType;
-void sentenceGenerator(char *sentence);
-void createTestPalette();//For Key Testing 'f'
-void deleteSpeech(ObjectID id); // voice sound sample ID
-#if DEBUG
-void soundTest1(void);
-void soundTest2(void);
-void voiceTest1(void);
-void voiceTest2(void);
-#endif
-void toggleMusic(void);
-
-extern APPFUNCV(videoTest1);
-extern APPFUNCV(videoTest2);
-
-extern PlayerActor playerList[]; // Master list of all PlayerActors
-
-void queueActorSpeech(GameObject *obj,
- char *text,
- int count,
- int32 sampleID,
- int flags
- ); // voice sound sample ID
-
-void cheatMove(int16 key);
-
-
-//-----------------------------------------------------------------------
-
-void TileModeHandleKey(int16 key, int16 /* qual */) {
-#if DINO
- ReadyContainerView *tradeNathanCV,
- *tradeOtherCV;
-#endif
-
- TilePoint Pos, ActorTP;
- Actor *a = getCenterActor();
- Location l(a->getLocation(), a->IDParent());
-
-#ifdef FTA
- static int Object = 2;
-#endif
-
- //This is for moving center actor in cardinal directions
- //by amount specified by loc const int moveDist and using keypad
- //without num lock on
-
-#if CHEATMOVE
- cheatMove(key);
-#endif
- // If there is currently a speech balloon up, and the
- // speech balloon has embedded buttons, then disallow
- // user input -- except that for now we will still allow
- // the special 'quit' key.
- if (speechButtonCount > 0) {
- if (key != 0x1b && key != 'b') return;
- }
-
- //-----------------------------------------------------------------------
-
- switch (tolower(key)) {
-
- case 'q':
- case 0x1b:
- gameRunning = false;
- break;
-
- case 'j':
- if (a) MotionTask::jump(*a);
- break;
-
-#ifdef WINKLUDGE
- case 'm':
- toggleMusic();
- break;
- case '\\':
- openAutoMap();
- break;
-#endif
-
- case 'e':
- a->takeMana(manaIDRed, -20);
- a->takeMana(manaIDOrange, -20);
- a->takeMana(manaIDYellow, -20);
- a->takeMana(manaIDGreen, -20);
- a->takeMana(manaIDBlue, -20);
- a->takeMana(manaIDViolet, -20);
- a->effectiveStats.spellcraft = 3;
- break;
-
-#ifdef __WATCOMC__
- case 'm':
- toggleMusic();
- break;
-#endif
-
-#if TEST1
- case 'v':
- if (viewCenterObject == getCenterActorID()) {
- if (pickedActor != Nothing) viewCenterObject = pickedActor;
- } else
- viewCenterObject = getCenterActorID();
- break;
-#endif
-
-
-#ifdef FTA
- case 'a':
- if (++Object < 8) {
- GameObject *obj1 = GameObject::objectAddress(Object);
- ActorTP = a->getLocation();
- obj1->move(ActorTP);
- } else
- Object = 2;
- break;
-
-#endif
-
-#if DINO
-#ifdef GENE
- case '~':
- WriteStatusF(2, "Switching to Trice");
-
- GameMode *gameModes[] = {&PlayMode, &TriceMode};
- GameMode::SetStack(gameModes, 2);
- GameMode::update();
- break;
-#endif
-#ifdef FRANKC
- case '~':
- buttonList[tradeButton]->enable(true);
- buttonList[tradeBackButton]->enable(true);
- buttonList[tradeButton]->invalidate();
- buttonList[tradeBackButton]->invalidate();
- tradeNathanCV = new ReadyContainerView(*playControls,
- Rect16(259, 360,
- iconOriginX * 2 + iconWidth * 1 + iconSpacingY * (1 - 1),
- iconOriginY + (iconOriginY * 1) + (1 * iconHeight)),
- NULL, 0,
- Point16(iconOriginX, iconOriginY),
- Point16(iconSpacingX, iconSpacingY),
- 1,
- 1,
- 1,
- 0);
-
- tradeOtherCV = new ReadyContainerView(*playControls,
- Rect16(300, 360,
- iconOriginX * 2 + iconWidth * 1 + iconSpacingY * (1 - 1),
- iconOriginY + (iconOriginY * 1) + (1 * iconHeight)),
- NULL, 0,
- Point16(iconOriginX, iconOriginY),
- Point16(iconSpacingX, iconSpacingY),
- 1,
- 1,
- 1,
- 0);
-
- tradeNathanCV->setContainer(GameObject::objectAddress(0x8001));
- tradeNathanCV->draw();
-
- tradeOtherCV->setContainer(GameObject::objectAddress(0x8002));
- tradeOtherCV->draw();
- break;
-#endif
-#endif
-
-#ifdef FRANKC
- /* Took Out For Milestone
- case 'y':
- tilePickPos.u += 100;
- tilePickPos.v += 100;
- MotionTask::walkToDirect((Actor &)*GameObject::objectAddress( 32817 ) , tilePickPos, false );
- break;
- case 'z':
-
- Target subTarget;
- subTarget.setTargetObject( a->thisID() );
- ((Actor *)GameObject::objectAddress( 32791 ))->setupTarget( subTarget ,
- Actor::huntToBeNear,
- false,
- Actor::priorityMedium );
- break;
- */
-#endif
-
-#ifdef DAVIDR
- case 't':
- extern bool showTile;
- showTile = !showTile;
- break;
-#endif
-
-
- // basically for changing the light level
-
- case 'b':
- calender.hour += 1;
-
- if (calender.hour > 24) {
- calender.hour = 0;
- }
-
- break;
-
- case 'w':
- calender.hour = 9;
- calender.days++;
- dayNightUpdate();
-
- break;
-
-
-#ifdef ALEXS
- int16 FileDialog(int16);
- int16 OptionsDialog(void);
- int16 openScroll(uint16);
- extern char bookText[];
- extern uint8 weight;
- extern uint8 encum;
- extern uint16 writeStatusFX;
- extern uint16 writeStatusFY;
- extern Point16 manaStarSizes[];
- extern Point16 manaStarSec[];
- extern Point16 manaStarCentXY;
- extern gCompImage *weightEncum;
-
- case 'd':
- openAutoMap();
- //FileDialog( 0 );
- break;
-
- case 'o':
- OptionsDialog();
- break;
-
- case 'u':
- //userDialog( "title", " This is a message", "btn 1", "btn 2", NULL );
- break;
-
- case 'f':
- if (pickedActor != Nothing)
- new ((Actor *)GameObject::objectAddress(pickedActor)) HuntToBeNearActorAssignment(SpecificActorTarget(getCenterActor()), 16, true);
- break;
-
- case '[':
- //writeStatusFX = 0;
- //writeStatusFY = 0;
- //mapSizeU--;
- sumNum--;
- break;
-
- case ']':
- //writeStatusFX = 468;
- //mapSizeU++;
- //sumNum++;
- playerList[0].skillAdvance(eBrawn, 200);
- break;
-
- case '=':
- writeStatusFY = 200;
- break;
-
- case '`':
- //StatusLine->setLine( "Goblins, and Ogres, and Giants, oh my!" );
- playerList[0].skillAdvance(eBrawn, 1);
- break;
-
-
- case 'h':
-
- //( ( Actor * )GameObject::objectAddress( 32768 ) )->effectiveStats.redMana -= 10;
- //( ( Actor * )GameObject::objectAddress( 32768 ) )->effectiveStats.vitality -= 10;
- //( ( Actor * )GameObject::objectAddress( 32768 ) )->effectiveStats.brawn -= 10;
- playerList[0].setTestBrawn();
- break;
-
- case 'y':
- playerList[0].recBrawnSome();
- break;
-
- case 'c':
- playerList[0].decBrawnSome();
- break;
-
-
-#endif
-
-#ifdef JEFFL
- case 'z':
- soundTest1();
- break;
- case 'y':
- soundTest2();
- break;
- case 'r':
- voiceTest1();
- break;
- case 't':
- voiceTest2();
- break;
-#endif
-
-#ifdef EVANO
-#if DEBUG
- int16 OptionsDialog(void);
- case 'o':
- OptionsDialog();
- break;
-
- case 'z':
- soundTest1();
- break;
- case 'y':
- soundTest2();
- break;
- case 'r':
- voiceTest1();
- break;
- case 't':
- voiceTest2();
- break;
-#endif
-#endif
-
- }
-}
-
-} // end of namespace Saga2
diff --git a/engines/saga2/module.mk b/engines/saga2/module.mk
index cd89c17b97..8bf3135f3c 100644
--- a/engines/saga2/module.mk
+++ b/engines/saga2/module.mk
@@ -33,7 +33,6 @@ MODULE_OBJS := \
imagcach.o \
interp.o \
intrface.o \
- keybored.o \
loadmsg.o \
loadsave.o \
magic.o \
Commit: c14b9f93892ddbce8d2156c3a665dc4a51ea3078
https://github.com/scummvm/scummvm/commit/c14b9f93892ddbce8d2156c3a665dc4a51ea3078
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:42+02:00
Commit Message:
SAGA2: Fix MSVC compilation
Changed paths:
engines/saga2/sagafunc.cpp
engines/saga2/speech.cpp
engines/saga2/tilemode.h
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index bc0f26acdb..95bb1bf705 100644
--- a/engines/saga2/sagafunc.cpp
+++ b/engines/saga2/sagafunc.cpp
@@ -49,6 +49,7 @@
#include "saga2/transit.h"
#include "saga2/contain.h"
#include "saga2/tile.h"
+#include "saga2/tilemode.h"
void drawMainDisplay(void);
@@ -3817,9 +3818,6 @@ int16 scriptTransportCenterBand(int16 *args) {
// void "c" lockUI( int locked )
int16 scriptLockUI(int16 *args) {
- extern void LockUI(bool state);
- extern void noStickyMap(void);
-
MONOLOG(lockUI);
noStickyMap();
diff --git a/engines/saga2/speech.cpp b/engines/saga2/speech.cpp
index b8d69f314a..13cf995913 100644
--- a/engines/saga2/speech.cpp
+++ b/engines/saga2/speech.cpp
@@ -37,6 +37,7 @@
#include "saga2/annoy.h"
#include "saga2/savefile.h"
#include "saga2/cmisc.h"
+#include "saga2/tilemode.h"
namespace Saga2 {
@@ -1096,8 +1097,6 @@ Speech *SpeechTaskList::newTask(ObjectID id, uint16 flags) {
void SpeechTaskList::SetLock(int newState) {
if (newState && lockFlag == false) {
- extern void noStickyMap(void);
-
noStickyMap();
LockUI(true);
lockFlag = true;
diff --git a/engines/saga2/tilemode.h b/engines/saga2/tilemode.h
index e4179adeda..577573951c 100644
--- a/engines/saga2/tilemode.h
+++ b/engines/saga2/tilemode.h
@@ -60,6 +60,8 @@ inline void cleanupTileModeState(void) { /* do nothing */ }
void TileModeSetup(void); // alloc tile resources
void TileModeCleanup(void); // free tile resources
+void noStickyMap(void);
+
} // end of namespace Saga2
#endif
Commit: 3c14a99f7cd54bae7e6da40472f496fb983ed48b
https://github.com/scummvm/scummvm/commit/3c14a99f7cd54bae7e6da40472f496fb983ed48b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:43+02:00
Commit Message:
SAGA2: Fix non-portable cast from pointer to long
Changed paths:
engines/saga2/interp.cpp
engines/saga2/sagafunc.cpp
engines/saga2/script.h
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 6e1f29565e..335ba34b09 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -1633,9 +1633,9 @@ void Thread::dispatch(void) {
break;
case waitTagSemaphore:
- if (((ActiveItem *)th->waitParam)->isExclusive() == false) {
+ if (th->waitParam->isExclusive() == false) {
th->flags &= ~waiting;
- ((ActiveItem *)th->waitParam)->setExclusive(true);
+ th->waitParam->setExclusive(true);
}
break;
default:
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index 95bb1bf705..2350873d5c 100644
--- a/engines/saga2/sagafunc.cpp
+++ b/engines/saga2/sagafunc.cpp
@@ -2571,7 +2571,7 @@ int16 scriptTagObtainLock(int16 *) {
WriteStatusF(15, "Locked: %d\n", lockCount);
#endif
} else {
- thisThread->waitForEvent(Thread::waitTagSemaphore, (long)ai);
+ thisThread->waitForEvent(Thread::waitTagSemaphore, ai);
#if DEBUG*0
lockCount += 1;
WriteStatusF(15, "Locked: %d\n", lockCount);
diff --git a/engines/saga2/script.h b/engines/saga2/script.h
index dc294a1071..9336ea70b9 100644
--- a/engines/saga2/script.h
+++ b/engines/saga2/script.h
@@ -232,7 +232,7 @@ public:
union {
Alarm waitAlarm; // for time-delay
FrameAlarm waitFrameAlarm; // for frame count delay
- long waitParam; // for other waiting
+ ActiveItem *waitParam; // for other waiting
};
scriptCallFrame threadArgs; // arguments from C to thread
@@ -265,7 +265,7 @@ public:
scriptResult run(void);
// Tells thread to wait for an event
- void waitForEvent(enum WaitTypes wt, long param) {
+ void waitForEvent(enum WaitTypes wt, ActiveItem *param) {
flags |= waiting;
waitType = wt;
waitParam = param;
Commit: e9671a73eb505d7d7ad8262a65adfd372b8209f2
https://github.com/scummvm/scummvm/commit/e9671a73eb505d7d7ad8262a65adfd372b8209f2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:43+02:00
Commit Message:
SAGA2: Fix MSVC warnings
Changed paths:
engines/saga2/actor.cpp
engines/saga2/intrface.cpp
engines/saga2/motion.cpp
engines/saga2/objects.cpp
engines/saga2/panel.cpp
engines/saga2/path.cpp
engines/saga2/sensor.cpp
engines/saga2/speech.cpp
engines/saga2/spellio.cpp
engines/saga2/tile.cpp
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index e9a1b5134b..61eff99309 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -656,7 +656,7 @@ bool ActorProto::acceptInsertionAtAction(
heldInRightHand,
worn
} inUseType;
- int wornWhere;
+ int wornWhere = 0;
assert(isActor(dObj));
assert(isObject(item));
@@ -1378,7 +1378,7 @@ Actor *Actor::newActor(
uint8 factionNum,
uint8 initFlags) {
GameObject *limbo = objectAddress(ActorLimbo);
- Actor *a;
+ Actor *a = nullptr;
debugC(2, kDebugActors, "Actor::newActor(protoNum = %d, nameIndex = %d, scriptIndex = %d, appearanceNum = %d, colorSchemeIndex = %d, factionNum = %d, initFlags = %d)",
protoNum, nameIndex, scriptIndex, appearanceNum, colorSchemeIndex, factionNum, initFlags);
@@ -1399,12 +1399,16 @@ Actor *Actor::newActor(
// REM: If things start getting really tight, we can
// start recycling common objects...
- if (i >= actorCount) return NULL;
+ if (i >= actorCount)
+ return nullptr;
} else {
actorLimboCount--;
a = (Actor *)limbo->child();
}
+ if (!a)
+ return nullptr;
+
a->setLocation(Location(0, 0, 0, Nothing));
a->init(
protoNum,
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index fc3b56908a..831b7be16e 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -2574,7 +2574,7 @@ APPFUNC(cmdManaInd) {
int manaType = -1;
int numManaRegions = ManaIndicator->getNumManaRegions();
int i;
- int curMana, baseMana;
+ int curMana = 0, baseMana = 0;
PlayerActor *player = &playerList[getCenterActorPlayerID()];
ActorAttributes *stats = player->getEffStats();
ActorAttributes baseStatsRef = player->getBaseStats();
@@ -2598,46 +2598,28 @@ APPFUNC(cmdManaInd) {
}
switch (manaType) {
-#define RED_MANA "Red Mana:"
-#define ORANGE_MANA "Orange Mana:"
-
-
-
-#define YELLOW_MANA "Yellow Mana:"
-
-
-
-#define GREEN_MANA "Green Mana:"
-
-
-
-#define BLUE_MANA "Blue Mana:"
-
-
-
-#define VIOLET_MANA "Purple Mana:"
case 0:
- sprintf(textBuffer, "%s %d/%d", RED_MANA, curMana, baseMana);
+ sprintf(textBuffer, "%s %d/%d", "Red Mana:", curMana, baseMana);
break;
case 1:
- sprintf(textBuffer, "%s %d/%d", ORANGE_MANA, curMana, baseMana);
+ sprintf(textBuffer, "%s %d/%d", "Orange Mana:", curMana, baseMana);
break;
case 2:
- sprintf(textBuffer, "%s %d/%d", YELLOW_MANA, curMana, baseMana);
+ sprintf(textBuffer, "%s %d/%d", "Yellow Mana:", curMana, baseMana);
break;
case 3:
- sprintf(textBuffer, "%s %d/%d", GREEN_MANA, curMana, baseMana);
+ sprintf(textBuffer, "%s %d/%d", "Green Mana:", curMana, baseMana);
break;
case 4:
- sprintf(textBuffer, "%s %d/%d", BLUE_MANA, curMana, baseMana);
+ sprintf(textBuffer, "%s %d/%d", "Blue Mana:", curMana, baseMana);
break;
case 5:
- sprintf(textBuffer, "%s %d/%d", VIOLET_MANA, curMana, baseMana);
+ sprintf(textBuffer, "%s %d/%d", "Purple Mana:", curMana, baseMana);
break;
case -1:
diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp
index ca61971203..ff62651d87 100644
--- a/engines/saga2/motion.cpp
+++ b/engines/saga2/motion.cpp
@@ -2491,12 +2491,12 @@ void MotionTask::walkAction(void) {
TilePoint immediateTarget = getImmediateTarget(),
newPos,
targetVector;
- int16 targetDist;
+ int16 targetDist = 0;
int16 movementDirection,
directionAngle;
int16 moveBlocked,
- speed,
- speedScale;
+ speed = walkSpeed,
+ speedScale = 2;
Actor *a;
ActorAppearance *aa;
StandingTileInfo sti;
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 5f4f93ab05..141ce15088 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -1167,7 +1167,7 @@ ObjectID GameObject::makeAlias(const Location &l) {
// return it's address
GameObject *GameObject::newObject(void) { // get a newly created object
GameObject *limbo = objectAddress(ObjectLimbo),
- *obj;
+ *obj = nullptr;
if (limbo->_data.childID == Nothing) {
int16 i;
@@ -1185,7 +1185,8 @@ GameObject *GameObject::newObject(void) { // get a newly created object
// REM: If things start getting really tight, we can
// start recycling common objects...
- if (i >= objectCount) return nullptr;
+ if (i >= objectCount)
+ return nullptr;
} else {
objectLimboCount--;
obj = limbo->child();
@@ -3453,19 +3454,19 @@ ObjectID RadialObjectIterator::first(GameObject **obj, int16 *dist) {
// Return the next object within the specified region
ObjectID RadialObjectIterator::next(GameObject **obj, int16 *dist) {
- GameObject *currentObject;
+ GameObject *currentObject = nullptr;
ObjectID currentObjectID;
- int16 currentDist;
+ int16 currentDist = 0;
do {
currentObjectID = SectorRegionObjectIterator::next(¤tObject);
} while (currentObjectID != Nothing
- && (currentDist =
- computeDist(currentObject->getLocation()))
- > radius);
+ && (currentDist = computeDist(currentObject->getLocation())) > radius);
- if (dist != nullptr) *dist = currentDist;
- if (obj != nullptr) *obj = currentObject;
+ if (dist != nullptr)
+ *dist = currentDist;
+ if (obj != nullptr)
+ *obj = currentObject;
return currentObjectID;
}
diff --git a/engines/saga2/panel.cpp b/engines/saga2/panel.cpp
index 420db50071..d949e95b8c 100644
--- a/engines/saga2/panel.cpp
+++ b/engines/saga2/panel.cpp
@@ -182,9 +182,10 @@ void gPanel::invalidate(Rect16 *) {
void gPanel::drawTitle(enum text_positions placement) {
gPort &port = window.windowPort;
Rect16 r = extent;
- const gPixelMap *img;
+ const gPixelMap *img = nullptr;
- if (title == NULL) return;
+ if (title == NULL)
+ return;
if (imageLabel) {
img = (const gPixelMap *)title;
diff --git a/engines/saga2/path.cpp b/engines/saga2/path.cpp
index 80da6a10cf..85054c96b3 100644
--- a/engines/saga2/path.cpp
+++ b/engines/saga2/path.cpp
@@ -124,6 +124,8 @@ static StaticTilePoint tDirTable3[8] = {
struct PathTileInfo {
TileInfo *surfaceTile;
int16 surfaceHeight;
+
+ PathTileInfo() : surfaceTile(nullptr), surfaceHeight(0) {}
};
typedef PathTileInfo PathTilePosInfo[maxPlatforms];
@@ -1582,7 +1584,7 @@ big_break:
void PathRequest::finish(void) {
Direction prevDir;
- int16 prevHeight;
+ int16 prevHeight = 0;
StaticTilePoint *resultSteps = path,
coords;
int16 stepCount = 0;
diff --git a/engines/saga2/sensor.cpp b/engines/saga2/sensor.cpp
index f18543b08a..729654888f 100644
--- a/engines/saga2/sensor.cpp
+++ b/engines/saga2/sensor.cpp
@@ -90,7 +90,7 @@ void deleteSensor(Sensor *p) {
void *constructSensor(int16 ctr, void *buf) {
int16 type;
- Sensor *sensor;
+ Sensor *sensor = nullptr;
SensorList *sl;
// Get the sensor type
@@ -123,12 +123,12 @@ void *constructSensor(int16 ctr, void *buf) {
break;
}
- assert(sensor != NULL);
+ assert(sensor != nullptr);
// Get the sensor list
sl = fetchSensorList(sensor->getObject());
- assert(sl != NULL);
+ assert(sl != nullptr);
// Append this Sensor to the sensor list
sl->_list.push_back(sensor);
diff --git a/engines/saga2/speech.cpp b/engines/saga2/speech.cpp
index 13cf995913..00ef910cc7 100644
--- a/engines/saga2/speech.cpp
+++ b/engines/saga2/speech.cpp
@@ -622,7 +622,7 @@ int16 TextWrap(
int16 i, // loop counter
line_start, // start of current line
last_space, // last space encountered
- last_space_pixels, // pixel pos of last space
+ last_space_pixels = 0, // pixel pos of last space
pixel_len, // pixel length of line
line_count = 0; // number of lines
@@ -688,7 +688,7 @@ int16 buttonWrap(
int16 i, // loop counter
line_start, // start of current line
last_space, // last space encountered
- last_space_pixels, // pixel pos of last space
+ last_space_pixels = 0, // pixel pos of last space
charPixels, // pixel length of character
linePixels, // pixels in current line
buttonPixels, // pixels in current button
diff --git a/engines/saga2/spellio.cpp b/engines/saga2/spellio.cpp
index f1db67695e..87d718ebe4 100644
--- a/engines/saga2/spellio.cpp
+++ b/engines/saga2/spellio.cpp
@@ -98,7 +98,7 @@ void SpellStuff::setupFromResource(ResourceSpellItem *rsi) {
// add spell internal effect
void SpellStuff::addEffect(ResourceSpellEffect *rse) {
- ProtoEffect *pe;
+ ProtoEffect *pe = nullptr;
assert(rse && rse->spell == master);
switch (rse->effectGroup) {
case effectNone :
@@ -197,11 +197,10 @@ void SpellStuff::addEffect(ResourceSpellEffect *rse) {
break;
}
}
- if (pe == NULL)
+ if (pe == nullptr)
error("failed to alloc protoEffect");
-
- if (effects == NULL)
+ if (effects == nullptr)
effects = pe;
else {
ProtoEffect *tail;
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 604915a6a1..9c917fb6ea 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -2646,7 +2646,7 @@ inline void drawMetaRow(TilePoint coords, Point16 pos) {
pos.x += kMetaTileWidth
) {
TilePoint clipCoords;
- int16 mtile;
+ int16 mtile = 0;
MetaTilePtr metaPtr;
clipCoords.u = (uint16)coords.u % curMap->mapSize;
@@ -3283,7 +3283,7 @@ void maskMetaRow(
pos.x += kMetaTileWidth
) {
TilePoint clipCoords;
- int16 mtile;
+ int16 mtile = 0;
MetaTilePtr metaPtr;
clipCoords.u = (uint16)coords.u % curMap->mapSize;
@@ -3311,9 +3311,11 @@ void maskMetaRow(
mtile = mapData[clipCoords.u * curMap->mapSize + clipCoords.v] & ~metaTileVisited;
break;
}
- } else mtile = mapData[clipCoords.u * curMap->mapSize + clipCoords.v] & ~metaTileVisited;
+ } else
+ mtile = mapData[clipCoords.u * curMap->mapSize + clipCoords.v] & ~metaTileVisited;
- if (mtile >= curMap->metaCount) mtile = curMap->metaCount - 1;
+ if (mtile >= curMap->metaCount)
+ mtile = curMap->metaCount - 1;
metaPtr = metaArray[mtile];
put = drawList;
@@ -4071,7 +4073,7 @@ TilePoint pickTile(Point32 pos,
testCoords,
deltaP;
MetaTile *mt;
- ActiveItemPtr bestTileTAI;
+ ActiveItemPtr bestTileTAI = nullptr;
TileInfo *ti,
*bestTile = nullptr;
uint8 *imageData;
@@ -4190,36 +4192,21 @@ TilePoint pickTile(Point32 pos,
if (sti.surfaceTAG == nullptr) {
if (surface != surfaceHoriz
- && pointOnHiddenSurface(
- tCoords + origin,
- pCoords,
- surface)) {
- surface = surface == surfaceVertU
- ? surfaceVertV
- : surfaceVertU;
+ && pointOnHiddenSurface(tCoords + origin, pCoords, surface)) {
+ surface = surface == surfaceVertU ? surfaceVertV : surfaceVertU;
}
// If pick point is on vertical surface
// not facing protaganist, reject tile
- if (surface == surfaceVertU
- && pCoords.v < protagPos.v)
+ if (surface == surfaceVertU && pCoords.v < protagPos.v)
continue;
- if (surface == surfaceVertV
- && pCoords.u < protagPos.u)
+ if (surface == surfaceVertV && pCoords.u < protagPos.u)
continue;
- /* // Make sure surface is exposed, else reject it
- if ( surface != surfaceHoriz
- && !validSurface( tCoords + origin, pCoords ) )
- continue;*/
}
pickCoords = pCoords;
floorCoords = fCoords;
bestTile = ti;
-#ifdef DAVIDR
- bestTP = tCoords + origin;
- bestTP.z = sti.surfaceHeight;
-#endif
bestTileTAI = sti.surfaceTAG;
}
}
@@ -4263,51 +4250,6 @@ TilePoint pickTile(Point32 pos,
return pickCoords;
}
-#ifdef DAVIDR
- if (showTile) {
- if (bestTile) {
- bestTP.u <<= kTileUVShift;
- bestTP.v <<= kTileUVShift;
- showAbstractTile(bestTP, bestTile);
-
- TilePoint pt1, pt2;
- pt1 = pt2 = pickCoords;
- pt1.u += 3;
- pt2.u -= 3;
- TPLine(pt1, pt2);
- pt1 = pt2 = pickCoords;
- pt1.v += 3;
- pt2.v -= 3;
- TPLine(pt1, pt2);
-
- pt1 = pt2 = floorCoords;
- pt1.u += 2;
- pt1.v += 2;
- pt2.u -= 2;
- pt2.v -= 2;
- TPLine(pt1, pt2);
- pt1 = pt2 = floorCoords;
- pt1.u += 2;
- pt1.v -= 2;
- pt2.u -= 2;
- pt2.v += 2;
- TPLine(pt1, pt2);
-
- pt1 = pt2 = pickCoords;
- pt1.z = bestTP.z;
- TPLine(pt1, pt2);
- pt2.z = bestTP.z;
- pt2.u = pt1.u & 0xFFF0;
- TPLine(pt1, pt2);
- pt2.u = pt1.u;
- pt2.v = pt1.v & 0xFFF0;
- TPLine(pt1, pt2);
-
- WriteStatusF(8, "%4.4x:%4.4x:%4.4x", pickCoords.u, pickCoords.v, pickCoords.z);
- }
- }
-#endif
-
if (floorResult) *floorResult = floorCoords;
if (pickTAI) *pickTAI = bestTileTAI;
return pickCoords;
Commit: 16356103a44ae7877ddc6f9ffeb939453663b2b1
https://github.com/scummvm/scummvm/commit/16356103a44ae7877ddc6f9ffeb939453663b2b1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-01T01:37:43+02:00
Commit Message:
SAGA2: Fix codacy warnings
Changed paths:
engines/saga2/actor.cpp
engines/saga2/audiores.cpp
engines/saga2/beegee.cpp
engines/saga2/blitters.cpp
engines/saga2/interp.cpp
engines/saga2/path.cpp
engines/saga2/playmode.cpp
engines/saga2/property.cpp
engines/saga2/sagafunc.cpp
engines/saga2/tile.cpp
engines/saga2/tilemode.cpp
engines/saga2/timers.cpp
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 61eff99309..7807db1352 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -320,28 +320,18 @@ bool ActorProto::acceptDropAction(
if (dropType & isIntangible) {
// Set up the arguments we want to pass to the script
- scf.value = droppedObj->proto()->lockType
- + senseIdeaGreeting;
+ scf.value = droppedObj->proto()->lockType + senseIdeaGreeting;
// Invoke the script...
if (dropType & isConcept) {
- result = runObjectMethod(dObj, Method_Actor_onTalkTo, scf);
+ runObjectMethod(dObj, Method_Actor_onTalkTo, scf);
} else if (dropType & isPsych) {
// What to do???
} else if (dropType & (isSpell | isSkill)) {
// What to do???
// Cast the spell on the actor?
}
-
- /* isConcept = (1<< 9),
- isPsych = (1<<10),
- isSpell = (1<<11),
- isSkill = (1<<12),
- isEnchantment = (1<<13),
- isTargetable = (1<<14), */
-
-// mouseInfo.setIntent( GrabInfo::WalkTo );
} else {
scf.value = count;
@@ -3073,25 +3063,6 @@ uint8 Actor::evaluateFollowerNeeds(Actor *follower) {
return actorGoalFollowLeader;
}
-#if DEBUG
-
-uint32 objectTerrain(GameObject *obj, StandingTileInfo &);
-
-void showObjectTerrain(GameObject *obj) {
- StandingTileInfo sti;
- uint32 terrain = objectTerrain(obj, sti);
- char terrLetters[] = "NERWSHWFRSL0000";
- char str[33];
-
- for (int i = 0; i < 32; i++) {
- str[i] = terrain & (1 << i) ? terrLetters[i] : '-';
- }
- str[32] = '\0';
-
-// WriteStatusF( 4, str );
-}
-#endif
-
// Returns 0 if not moving, 1 if path being calculated,
// 2 if path being followed.
bool Actor::pathFindState(void) {
diff --git a/engines/saga2/audiores.cpp b/engines/saga2/audiores.cpp
index a921fa7157..71da54b526 100644
--- a/engines/saga2/audiores.cpp
+++ b/engines/saga2/audiores.cpp
@@ -63,14 +63,13 @@ bool hResCheckResID(hResContext *hrc, uint32 s) {
}
bool hResCheckResID(hResContext *hrc, uint32 s[]) {
- int i = 0;
if (s != NULL) {
if (s[0] == 0)
return false;
- while (s[i]) {
+
+ for (int i = 0; s[i]; i++) {
if (!hResCheckResID(hrc, s[i]))
return false;
- i++;
}
}
return true;
diff --git a/engines/saga2/beegee.cpp b/engines/saga2/beegee.cpp
index 68867a85bc..acc89f898e 100644
--- a/engines/saga2/beegee.cpp
+++ b/engines/saga2/beegee.cpp
@@ -255,7 +255,7 @@ void setAreaSound(const TilePoint &) {
loopID = 0;
}
audioEnvironmentUseSet(loopID, ss, themePos << kPlatShift);
- } else if (!playingExternalLoop) {
+ } else if (playingExternalLoop) {
audioEnvironmentUseSet(playingExternalLoop, 0, Point16(0, 0)); //themePos << kPlatShift);
}
}
diff --git a/engines/saga2/blitters.cpp b/engines/saga2/blitters.cpp
index 9df23116d8..7f632d232b 100644
--- a/engines/saga2/blitters.cpp
+++ b/engines/saga2/blitters.cpp
@@ -132,7 +132,6 @@ void unpackSprite(gPixelMap *map, uint8 *sprData, uint32 dataSize) {
#if DEBUGPACK
warning("unpackSprite: too many trans %d < %d for %dx%d (src %d bytes)", bytes, trans, map->size.x, map->size.y, dataSize);
#endif
- trans = bytes;
fail = true;
break;
}
@@ -196,7 +195,7 @@ void drawTile(gPixelMap *map, int32 x, int32 y, int32 height, uint8 *srcData, bo
const byte *readPointer;
byte *drawPointer;
Point32 drawPoint;
- int widthCount = 0;
+ int widthCount;
int row, col, count, lowBound;
int bgRunCount;
int fgRunCount;
diff --git a/engines/saga2/interp.cpp b/engines/saga2/interp.cpp
index 335ba34b09..1b54b4c090 100644
--- a/engines/saga2/interp.cpp
+++ b/engines/saga2/interp.cpp
@@ -465,8 +465,7 @@ class RandomGenerator {
static const uint32 b; // arbitrary constant
public:
- RandomGenerator(void) {
- a = 1;
+ RandomGenerator(void) : a(1) {
}
RandomGenerator(uint16 seed) {
a = (uint32)seed << 16;
@@ -603,7 +602,7 @@ bool Thread::interpret(void) {
case op_getflag: // get a flag
D_OP(op_getflag);
addr = bitAddress(this, &pc, &w); // get address of bit
- *--stack = (*addr) & w ? 1 : 0; // true or false if bit set
+ *--stack = ((*addr) & w) ? 1 : 0; // true or false if bit set
break;
case op_getint: // read from integer field (mode)
@@ -1923,7 +1922,7 @@ scriptResult runObjectMethod(
scriptCallFrame &args) {
GameObject *obj;
- assert(obj = GameObject::objectAddress(id));
+ obj = GameObject::objectAddress(id);
return runMethod(obj->scriptClass(),
builtinTypeObject,
@@ -1941,7 +1940,7 @@ scriptResult runTagMethod(
scriptCallFrame &args) {
ActiveItemPtr aItem;
- assert(aItem = ActiveItem::activeItemAddress(index));
+ aItem = ActiveItem::activeItemAddress(index);
if (!aItem->_data.scriptClassID)
return scriptResultNoScript;
diff --git a/engines/saga2/path.cpp b/engines/saga2/path.cpp
index 85054c96b3..82b0283414 100644
--- a/engines/saga2/path.cpp
+++ b/engines/saga2/path.cpp
@@ -2304,7 +2304,7 @@ void addPathRequestToQueue(PathRequest *pr) {
if (isPlayerActor(a)) {
Common::List<PathRequest *>::iterator it;
- for (it = g_vm->_pathQueue.begin(); it != g_vm->_pathQueue.end(); it++) {
+ for (it = g_vm->_pathQueue.begin(); it != g_vm->_pathQueue.end(); ++it) {
Actor *prActor = (*it)->actor;
if (prActor != centerActor || !isPlayerActor(prActor))
diff --git a/engines/saga2/playmode.cpp b/engines/saga2/playmode.cpp
index d8e9da5670..3dc5c97299 100644
--- a/engines/saga2/playmode.cpp
+++ b/engines/saga2/playmode.cpp
@@ -191,7 +191,7 @@ void PlayModeSetup(void) {
// for tile mode.
// NOTE: Make sure these are allocated first, so that they
// can over-ride other controls.
- assert(speakButtonControls = new gPanelList(*mainWindow));
+ speakButtonControls = new gPanelList(*mainWindow);
// Create a control covering the map area.
speakButtonPanel = new gGenericControl(*speakButtonControls,
@@ -202,11 +202,11 @@ void PlayModeSetup(void) {
// Create a panelList to contain all controls created
// for play mode.
- assert(playControls = new gPanelList(*mainWindow));
+ playControls = new gPanelList(*mainWindow);
// Create a panelList to contain all controls created
// for tile mode.
- assert(tileControls = new gPanelList(*mainWindow));
+ tileControls = new gPanelList(*mainWindow);
// Create a panelList to contain all controls created
// for stage mode.
diff --git a/engines/saga2/property.cpp b/engines/saga2/property.cpp
index d2e68fb015..1c3b06fdd4 100644
--- a/engines/saga2/property.cpp
+++ b/engines/saga2/property.cpp
@@ -142,7 +142,7 @@ const ActorProperty *actorPropArray[actorPropIDCount] = {
// Determine if this tile has water
static bool tileHasWater(TileInfo *ti) {
- return ti->combinedTerrainMask() & terrainWater ? true : false;
+ return (ti->combinedTerrainMask() & terrainWater) ? true : false;
}
const SimpleTileProperty tilePropHasWater(tileHasWater);
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index 2350873d5c..e329447dbe 100644
--- a/engines/saga2/sagafunc.cpp
+++ b/engines/saga2/sagafunc.cpp
@@ -2097,7 +2097,6 @@ int16 scriptActorDeductPayment(int16 *args) {
if (massCount > paymentAmount) {
obj->setExtra(massCount - paymentAmount);
globalContainerList.setUpdate(obj->IDParent());
- paymentAmount = 0;
break;
} else {
if (delObj) {
@@ -2107,7 +2106,8 @@ int16 scriptActorDeductPayment(int16 *args) {
}
paymentAmount -= massCount;
delObj = obj;
- if (paymentAmount == 0) break;
+ if (paymentAmount == 0)
+ break;
}
} else {
// Non-mergeable objects count as 1
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 9c917fb6ea..3108cd362c 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -2225,6 +2225,7 @@ RipTable *RipTable::ripTableAddress(RipTableID id) {
// Return a rip table's ID
RipTableID RipTable::thisID(void) {
+ warning("RipTable::thisID(): Unsafe pointer arithmetics");
return this - ripTableList;
}
diff --git a/engines/saga2/tilemode.cpp b/engines/saga2/tilemode.cpp
index 1b697b9b48..edccba5937 100644
--- a/engines/saga2/tilemode.cpp
+++ b/engines/saga2/tilemode.cpp
@@ -111,7 +111,6 @@ void drawMainDisplay(void);
void updateMainDisplay(void);
#if DEBUG
-void showObjectTerrain(GameObject *obj);
void soundTest1(void);
void soundTest2(void);
void voiceTest1(void);
@@ -157,8 +156,7 @@ static struct _delayedNavigation {
bool pathFindFlag;
Alarm delay;
- // Visual C++ complains about this not having a constructor.
- _delayedNavigation(void) {;}
+ _delayedNavigation(void) : pathFindFlag(false) {}
} delayedNavigation;
static bool navigationDelayed = false;
@@ -786,10 +784,6 @@ void TileModeHandleTask(void) {
if (G_BASE.isMousePanel(tileMapControl)) {
-#if DEBUG
- showObjectTerrain(a);
-#endif
-
// If mouse is near edge of screen, then run.
runFlag = lastMousePos.x < runThreshhold
|| lastMousePos.x >= tileRect.width - runThreshhold
diff --git a/engines/saga2/timers.cpp b/engines/saga2/timers.cpp
index 7ef797b83e..ffd4dd36b9 100644
--- a/engines/saga2/timers.cpp
+++ b/engines/saga2/timers.cpp
@@ -115,7 +115,7 @@ void checkTimers(void) {
for (Common::List<Timer *>::iterator it = g_vm->_timers.begin(); it != g_vm->_timers.end(); it = nextIt) {
nextIt = it;
- nextIt++;
+ ++nextIt;
if ((*it)->check()) {
debugC(2, kDebugTimers, "Timer tick for %p (%s): %p (duration %d)", (void *)(*it)->getObject(), (*it)->getObject()->objName(), (void *)(*it), (*it)->getInterval());
(*it)->reset();
Commit: f8b24c5e588a060a6d4497e5067120b953e13ca4
https://github.com/scummvm/scummvm/commit/f8b24c5e588a060a6d4497e5067120b953e13ca4
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:43+02:00
Commit Message:
SAGA2: Fix initialization warning in path.cpp
Changed paths:
engines/saga2/path.cpp
diff --git a/engines/saga2/path.cpp b/engines/saga2/path.cpp
index 82b0283414..0047a29b54 100644
--- a/engines/saga2/path.cpp
+++ b/engines/saga2/path.cpp
@@ -1066,13 +1066,18 @@ protected:
enum pathFlags {
aborted = (1 << 0), // path request has been aborted
+
completed = (1 << 1), // pathfinder has found best path
run = (1 << 2)
};
+ enum {
+ kPathSize = 16
+ };
+
// These static members are initialized when the path request
// becomes the current active request being serviced.
- static StaticTilePoint path[16];
+ static TilePoint *path;
static int16 pathLength;
static StaticTilePoint baseCoords,
@@ -1110,7 +1115,12 @@ protected:
PathRequest(Actor *a, int16 howSmart);
public:
- virtual ~PathRequest() {}
+ virtual ~PathRequest() {
+ if (path)
+ delete[] path;
+
+ path = nullptr;
+ }
void requestAbort(void) {
flags |= aborted;
@@ -1271,7 +1281,7 @@ struct VolumeLookupNode {
static VolumeLookupNode volumeLookupNodePool[256];
static VolumeLookupNode *volumeLookupTable[searchDiameter][searchDiameter];
-StaticTilePoint PathRequest::path[16] = {0, 0, 0};
+TilePoint *PathRequest::path = nullptr;
int16 PathRequest::pathLength;
StaticTilePoint PathRequest::baseCoords = {0, 0, 0},
@@ -1387,6 +1397,9 @@ PathRequest::PathRequest(Actor *a, int16 howSmart) {
mTask = actor->moveTask;
flags = mTask->flags & MotionTask::requestRun ? run : 0;
+ if (path == nullptr)
+ path = new TilePoint[kPathSize]();
+
mTask->pathFindTask = this;
}
@@ -1585,13 +1598,13 @@ big_break:
void PathRequest::finish(void) {
Direction prevDir;
int16 prevHeight = 0;
- StaticTilePoint *resultSteps = path,
- coords;
+ TilePoint *resultSteps = path,
+ coords;
int16 stepCount = 0;
- StaticTilePoint *res;
+ TilePoint *res;
PathCell *cell;
- static StaticTilePoint tempResult[32];
+ static TilePoint tempResult[32];
debugC(2, kDebugPath, "Finishing Path Request: %p", (void *)this);
@@ -1641,7 +1654,7 @@ void PathRequest::finish(void) {
}
if (resultSteps) {
- while (stepCount < ARRAYSIZE(path)
+ while (stepCount < kPathSize
&& res < &tempResult[ARRAYSIZE(tempResult)]) {
*resultSteps++ = *res++;
stepCount++;
Commit: 176c81b0744889b95ed6a7987299b2813a63166e
https://github.com/scummvm/scummvm/commit/176c81b0744889b95ed6a7987299b2813a63166e
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:43+02:00
Commit Message:
SAGA2: Fix StaticWindow warnings
Changed paths:
engines/saga2/automap.cpp
engines/saga2/uidialog.cpp
diff --git a/engines/saga2/automap.cpp b/engines/saga2/automap.cpp
index 5582b17634..b7562b8de1 100644
--- a/engines/saga2/automap.cpp
+++ b/engines/saga2/automap.cpp
@@ -143,9 +143,9 @@ static const StaticRect scrollBtnRect = {
StaticWindow autoMapDecorations[numAutoMapPanels] = {
- {*autoMapPanelRects[0], nullptr, autoMapTopPanelResID},
- {*autoMapPanelRects[1], nullptr, autoMapMidPanelResID},
- {*autoMapPanelRects[2], nullptr, autoMapBotPanelResID}
+ {*(autoMapPanelRects[0]), NULL, autoMapTopPanelResID},
+ {*(autoMapPanelRects[1]), NULL, autoMapMidPanelResID},
+ {*(autoMapPanelRects[2]), NULL, autoMapBotPanelResID}
};
diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp
index a5ac62e907..2419650af3 100644
--- a/engines/saga2/uidialog.cpp
+++ b/engines/saga2/uidialog.cpp
@@ -231,9 +231,9 @@ static const StaticRect *saveLoadTextRects[kNumSaveLoadTexts] = {
// save/load dialog window decorations
static StaticWindow saveWindowDecorations[kNumSaveLoadPanels] = {
- {*saveLoadPanelRects[0], nullptr, SLTopPanelResID},
- {*saveLoadPanelRects[1], nullptr, SLMidPanelResID},
- {*saveLoadPanelRects[2], nullptr, SLBotPanelResID}
+ {*(saveLoadPanelRects[0]), NULL, SLTopPanelResID},
+ {*(saveLoadPanelRects[1]), NULL, SLMidPanelResID},
+ {*(saveLoadPanelRects[2]), NULL, SLBotPanelResID}
};
@@ -473,9 +473,9 @@ static const StaticRect *optionsTextRects[] = {
// options dialog window decorations
static StaticWindow optionsDecorations[kNumOptionsPanels] = {
- {*optionsPanelRects[0], nullptr, optTopPanelResID},
- {*optionsPanelRects[1], nullptr, optMidPanelResID},
- {*optionsPanelRects[2], nullptr, optBotPanelResID}
+ {*(optionsPanelRects[0]), NULL, optTopPanelResID},
+ {*(optionsPanelRects[1]), NULL, optMidPanelResID},
+ {*(optionsPanelRects[2]), NULL, optBotPanelResID}
};
Commit: 4a8f7d500fd926f54b2709f4a240e133151b27d7
https://github.com/scummvm/scummvm/commit/4a8f7d500fd926f54b2709f4a240e133151b27d7
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:43+02:00
Commit Message:
SAGA2: Fix uninitialized variables
Changed paths:
engines/saga2/sprite.cpp
diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp
index fd29f752d1..aa5daf529a 100644
--- a/engines/saga2/sprite.cpp
+++ b/engines/saga2/sprite.cpp
@@ -139,10 +139,10 @@ void DrawCompositeMaskedSprite(
int16 effects, // effects flags
bool *obscured) { // set if object obscured by terrain
SpriteComponent *sc; // sprite component
- int16 xMax, // extent of composite
- xMin,
- yMax,
- yMin;
+ int16 xMax = 0, // extent of composite
+ xMin = 0,
+ yMax = 0,
+ yMin = 0;
Rect16 clip; // clip rect of port
gPixelMap compMap, // pixel map for composite
sprMap; // sprite map
Commit: 4048869485f2e293360cd052bf194bf507565cb4
https://github.com/scummvm/scummvm/commit/4048869485f2e293360cd052bf194bf507565cb4
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:44+02:00
Commit Message:
SAGA2: Move mainPort to Saga2Engine
Changed paths:
engines/saga2/automap.cpp
engines/saga2/display.cpp
engines/saga2/document.cpp
engines/saga2/floating.cpp
engines/saga2/fta.h
engines/saga2/main.cpp
engines/saga2/msgbox.cpp
engines/saga2/panel.cpp
engines/saga2/saga2.h
engines/saga2/tile.cpp
engines/saga2/tileline.cpp
engines/saga2/towerfta.cpp
engines/saga2/vdraw.h
engines/saga2/videobox.cpp
diff --git a/engines/saga2/automap.cpp b/engines/saga2/automap.cpp
index b7562b8de1..5d7a643b95 100644
--- a/engines/saga2/automap.cpp
+++ b/engines/saga2/automap.cpp
@@ -427,7 +427,7 @@ void CAutoMap::drawClipped(
void CAutoMap::draw(void) { // redraw the window
// draw the entire panel
- drawClipped(mainPort, Point16(0, 0), extent);
+ drawClipped(g_vm->_mainPort, Point16(0, 0), extent);
}
// ------------------------------------------------------------------------
diff --git a/engines/saga2/display.cpp b/engines/saga2/display.cpp
index ea02d28218..28c61067bd 100644
--- a/engines/saga2/display.cpp
+++ b/engines/saga2/display.cpp
@@ -34,7 +34,6 @@ namespace Saga2 {
extern bool gameRunning;
extern bool delayReDraw;
-extern gDisplayPort mainPort; // default rendering port
extern BackWindow *mainWindow; // main window...
/* ===================================================================== *
@@ -246,9 +245,9 @@ void reDrawScreen(void) {
* ===================================================================== */
void blackOut(void) {
- mainPort.drawMode = drawModeReplace;
- mainPort.setColor(0); // fill screen with color
- mainPort.fillRect(Rect16(0, 0, 640, 480));
+ g_vm->_mainPort.drawMode = drawModeReplace;
+ g_vm->_mainPort.setColor(0); // fill screen with color
+ g_vm->_mainPort.fillRect(Rect16(0, 0, 640, 480));
lightsOut();
}
diff --git a/engines/saga2/document.cpp b/engines/saga2/document.cpp
index 0d6632f1b6..1d3f3e630b 100644
--- a/engines/saga2/document.cpp
+++ b/engines/saga2/document.cpp
@@ -827,7 +827,7 @@ void CDocument::drawClipped(
void CDocument::draw(void) { // redraw the window
// draw the book image
- drawClipped(mainPort, Point16(0, 0), extent);
+ drawClipped(g_vm->_mainPort, Point16(0, 0), extent);
// draw the text onto the book
renderText();
diff --git a/engines/saga2/floating.cpp b/engines/saga2/floating.cpp
index 8e3505dca9..638bc3aa48 100644
--- a/engines/saga2/floating.cpp
+++ b/engines/saga2/floating.cpp
@@ -61,7 +61,6 @@ extern Rect16 tileRect;
extern gPixelMap tileDrawMap;
extern Point16 fineScroll;
extern gFont *mainFont;
-extern gDisplayPort mainPort;
extern bool allPlayerActorsDead;
@@ -253,7 +252,7 @@ void DecoratedWindow::removeDecorations(void) {
void DecoratedWindow::draw(void) { // redraw the window
pointer.hide();
if (displayEnabled())
- drawClipped(mainPort, Point16(0, 0), extent);
+ drawClipped(g_vm->_mainPort, Point16(0, 0), extent);
pointer.show();
}
@@ -691,13 +690,13 @@ void updateWindowSection(const Rect16 &r) {
}
// Now, blit the temporary bitmap to the main screen.
- mainPort.setMode(drawModeReplace);
- pointer.hide(mainPort, clip);
- mainPort.bltPixels(tempMap,
+ g_vm->_mainPort.setMode(drawModeReplace);
+ pointer.hide(g_vm->_mainPort, clip);
+ g_vm->_mainPort.bltPixels(tempMap,
0, 0,
clip.x, clip.y, clip.width, clip.height);
- pointer.show(mainPort, clip);
- mainPort.setMode(drawModeMatte);
+ pointer.show(g_vm->_mainPort, clip);
+ g_vm->_mainPort.setMode(drawModeMatte);
delete[] tempMap.data;
}
diff --git a/engines/saga2/fta.h b/engines/saga2/fta.h
index 55db92e8a0..073e697043 100644
--- a/engines/saga2/fta.h
+++ b/engines/saga2/fta.h
@@ -227,7 +227,6 @@ extern int16 extendedThreadLevel;
extern bool gameRunning; // true while game running
-extern gDisplayPort mainPort; // main drawing port
extern gMousePointer pointer; // the mouse pointer
extern volatile int32 gameTime; // current timer
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index ffb785f75d..30a263b6a6 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -80,8 +80,7 @@ uint32 cliMemory = 0;
gMouseState mouseState;
// Display variables
-gDisplayPort mainPort; // default rendering port
-gMousePointer pointer(mainPort); // the actual pointer
+gMousePointer pointer(g_vm->_mainPort); // the actual pointer
BackWindow *mainWindow; // main window...
// Memory allocation heap
@@ -725,14 +724,14 @@ bool initGUIMessagers(void) {
for (int i = 0; i < 10; i++) {
char debItem[16];
sprintf(debItem, "Status%1.1d", i);
- Status[i] = new StatusLineMessager(debItem, i, &mainPort);
+ Status[i] = new StatusLineMessager(debItem, i, &g_vm->_mainPort);
if (Status[i] == NULL)
return false;
sprintf(debItem, "Status%2.2d", i + 10);
- Status2[i] = new StatusLineMessager(debItem, i, &mainPort, 468, 21 + (11 * i));
+ Status2[i] = new StatusLineMessager(debItem, i, &g_vm->_mainPort, 468, 21 + (11 * i));
}
for (int j = 0; j < 3; j++)
- ratemess[j] = new StatusLineMessager("FrameRates", j, &mainPort, 5, 450 + (11 * j), 500);
+ ratemess[j] = new StatusLineMessager("FrameRates", j, &g_vm->_mainPort, 5, 450 + (11 * j), 500);
return true;
}
diff --git a/engines/saga2/msgbox.cpp b/engines/saga2/msgbox.cpp
index 10b60ac159..569668d7f0 100644
--- a/engines/saga2/msgbox.cpp
+++ b/engines/saga2/msgbox.cpp
@@ -236,9 +236,9 @@ void SimpleWindow::update(const Rect16 &) {
}
void SimpleWindow::draw(void) {
- pointer.hide(mainPort, extent); // hide mouse pointer
- drawClipped(mainPort, Point16(0, 0), extent);
- pointer.show(mainPort, extent); // show mouse pointer
+ pointer.hide(g_vm->_mainPort, extent); // hide mouse pointer
+ drawClipped(g_vm->_mainPort, Point16(0, 0), extent);
+ pointer.show(g_vm->_mainPort, extent); // show mouse pointer
}
void SimpleWindow::drawClipped(
diff --git a/engines/saga2/panel.cpp b/engines/saga2/panel.cpp
index d949e95b8c..e3a183eeaf 100644
--- a/engines/saga2/panel.cpp
+++ b/engines/saga2/panel.cpp
@@ -500,7 +500,7 @@ void gWindow::setPos(Point16 pos) {
windowPort.origin.y = extent.y;
// set port's clip
- newClip = intersect(extent, mainPort.clip);
+ newClip = intersect(extent, g_vm->_mainPort.clip);
newClip.x -= extent.x;
newClip.y -= extent.y;
windowPort.setClip(newClip);
diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h
index 858e39328c..516cc84278 100644
--- a/engines/saga2/saga2.h
+++ b/engines/saga2/saga2.h
@@ -32,6 +32,7 @@
#include "saga2/idtypes.h"
#include "saga2/weapons.h"
+#include "saga2/vdraw.h"
namespace Video {
class SmackerDecoder;
@@ -99,6 +100,7 @@ public:
Common::List<PathRequest *> _pathQueue;
BandList *_bandList;
+ gDisplayPort _mainPort;
bool _autoAggression;
bool _autoWeapon;
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index 3108cd362c..5af94ad051 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -4719,11 +4719,11 @@ extern int32 gameTime;
}
}
- pointer.hide( mainPort, tileRect );
+ pointer.hide( g_vm->_mainPort, tileRect );
drawPage->writePixels( tileRect,
tileDrawMap.data,
tileDrawMap.size.x );
- pointer.show( mainPort, tileRect );
+ pointer.show( g_vm->_mainPort, tileRect );
}
*/
#endif
diff --git a/engines/saga2/tileline.cpp b/engines/saga2/tileline.cpp
index f036eca572..97c14ce91c 100644
--- a/engines/saga2/tileline.cpp
+++ b/engines/saga2/tileline.cpp
@@ -70,9 +70,9 @@ void TPLine(const TilePoint &start, const TilePoint &stop) {
startPt.y += tileRect.y;
stopPt.y += tileRect.y;
- mainPort.setColor(1);
- mainPort.moveTo(startPt);
- mainPort.drawTo(stopPt);
+ g_vm->_mainPort.setColor(1);
+ g_vm->_mainPort.moveTo(startPt);
+ g_vm->_mainPort.drawTo(stopPt);
}
void TPLine(const TilePoint &start, const TilePoint &stop, int16 color);
@@ -89,9 +89,9 @@ void TPLine(const TilePoint &start, const TilePoint &stop, int16 color) {
startPt.y += tileRect.y;
stopPt.y += tileRect.y;
- mainPort.setColor(color);
- mainPort.moveTo(startPt);
- mainPort.drawTo(stopPt);
+ g_vm->_mainPort.setColor(color);
+ g_vm->_mainPort.moveTo(startPt);
+ g_vm->_mainPort.drawTo(stopPt);
}
#endif
diff --git a/engines/saga2/towerfta.cpp b/engines/saga2/towerfta.cpp
index b1c3635ad9..ff01c80b74 100644
--- a/engines/saga2/towerfta.cpp
+++ b/engines/saga2/towerfta.cpp
@@ -273,12 +273,12 @@ TERMINATOR(termDisplayPort) {
// ------------------------------------------------------------------------
INITIALIZER(initPanelSystem) {
- initPanels(mainPort);
- if (mainPort.map == nullptr) {
+ initPanels(g_vm->_mainPort);
+ if (g_vm->_mainPort.map == nullptr) {
gPixelMap *tmap = new gPixelMap;
tmap->size = Point16(screenWidth, screenHeight);
tmap->data = new uint8[tmap->bytes()];
- mainPort.setMap(tmap);
+ g_vm->_mainPort.setMap(tmap);
}
return true;
}
@@ -324,11 +324,11 @@ TERMINATOR(termMousePointer) {
// ------------------------------------------------------------------------
INITIALIZER(initDisplay) {
- mainPort.setColor(0); // fill screen with color
- drawPage = &mainPort.protoPage;
- mainPort.setDisplayPage(drawPage);
+ g_vm->_mainPort.setColor(0); // fill screen with color
+ drawPage = &g_vm->_mainPort.protoPage;
+ g_vm->_mainPort.setDisplayPage(drawPage);
//lightsOut();
- //mainPort.fillRect( Rect16( 0, 0, screenWidth, screenHeight ) );
+ //g_vm->_mainPort.fillRect( Rect16( 0, 0, screenWidth, screenHeight ) );
// Create a panelList to contain the controls which are
// only active when all three brothers are shown
diff --git a/engines/saga2/vdraw.h b/engines/saga2/vdraw.h
index e0a03fcf5e..2da85aa4ea 100644
--- a/engines/saga2/vdraw.h
+++ b/engines/saga2/vdraw.h
@@ -65,9 +65,6 @@ public:
void scrollPixels(const Rect16 r, int dx, int dy);
};
-extern void initVGAGraphics(gDisplayPort &mainPort);
-extern void cleanupVGAGraphics(void);
-
extern vDisplayPage *drawPage;
} // end of namespace Saga2
diff --git a/engines/saga2/videobox.cpp b/engines/saga2/videobox.cpp
index 10fa48c9cd..fe5d0ce24a 100644
--- a/engines/saga2/videobox.cpp
+++ b/engines/saga2/videobox.cpp
@@ -119,7 +119,7 @@ void CVideoBox::drawClipped(
void CVideoBox::draw(void) { // redraw the window
// draw the decoration stuff
- drawClipped(mainPort, Point16(0, 0), extent);
+ drawClipped(g_vm->_mainPort, Point16(0, 0), extent);
}
Commit: 19c3be9104e2a239e695efdf0274a78e3e1c5775
https://github.com/scummvm/scummvm/commit/19c3be9104e2a239e695efdf0274a78e3e1c5775
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:44+02:00
Commit Message:
SAGA2: Fix some global constructor warnings
Changed paths:
engines/saga2/motion.cpp
engines/saga2/motion.h
engines/saga2/objects.cpp
engines/saga2/objproto.cpp
engines/saga2/sagafunc.cpp
engines/saga2/tcoords.h
diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp
index ff62651d87..d9f31aeaf0 100644
--- a/engines/saga2/motion.cpp
+++ b/engines/saga2/motion.cpp
@@ -110,27 +110,27 @@ x Single
Motion Constants
* ===================================================================== */
-TilePoint dirTable[8] = {
- TilePoint(2, 2, 0),
- TilePoint(0, 3, 0),
- TilePoint(-2, 2, 0),
- TilePoint(-3, 0, 0),
- TilePoint(-2, -2, 0),
- TilePoint(0, -3, 0),
- TilePoint(2, -2, 0),
- TilePoint(3, 0, 0)
+const StaticTilePoint dirTable[8] = {
+ { 2, 2, 0},
+ { 0, 3, 0},
+ {-2, 2, 0},
+ {-3, 0, 0},
+ {-2, -2, 0},
+ { 0, -3, 0},
+ { 2, -2, 0},
+ { 3, 0, 0}
};
// Incremental direction table
-TilePoint incDirTable[8] = {
- TilePoint(1, 1, 0),
- TilePoint(0, 1, 0),
- TilePoint(-1, 1, 0),
- TilePoint(-1, 0, 0),
- TilePoint(-1, -1, 0),
- TilePoint(0, -1, 0),
- TilePoint(1, -1, 0),
- TilePoint(1, 0, 0)
+const StaticTilePoint incDirTable[8] = {
+ { 1, 1, 0},
+ { 0, 1, 0},
+ {-1, 1, 0},
+ {-1, 0, 0},
+ {-1, -1, 0},
+ { 0, -1, 0},
+ { 1, -1, 0},
+ { 1, 0, 0}
};
extern uint16 uMaxMasks[4],
diff --git a/engines/saga2/motion.h b/engines/saga2/motion.h
index f7124eb259..d246d4f5f1 100644
--- a/engines/saga2/motion.h
+++ b/engines/saga2/motion.h
@@ -34,7 +34,8 @@ namespace Saga2 {
class PathRequest;
struct StandingTileInfo;
-extern TilePoint dirTable[];
+extern const StaticTilePoint dirTable[];
+extern const StaticTilePoint incDirTable[];
const int gravity = 2;
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 141ce15088..1b672a3805 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -146,8 +146,6 @@ extern ObjectID pickedObject;
const uint32 imageGroupID = MKTAG('I', 'M', 'A', 'G');
-extern TilePoint incDirTable[];
-
bool unstickObject(GameObject *obj);
/* ===================================================================== *
diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp
index 75fcf3a260..c8fdd61bc9 100644
--- a/engines/saga2/objproto.cpp
+++ b/engines/saga2/objproto.cpp
@@ -55,8 +55,6 @@ extern PlayerActor playerList[]; // Master list of all PlayerActors
extern ObjectSoundFXs *objectSoundFXTable; // the global object sound effects table
-extern TilePoint incDirTable[];
-
#if DEBUG
extern bool massAndBulkCount;
#endif
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index e329447dbe..de60e26670 100644
--- a/engines/saga2/sagafunc.cpp
+++ b/engines/saga2/sagafunc.cpp
@@ -193,7 +193,7 @@ int16 scriptActorMove(int16 *args) {
// parameter is for actor facing, only used by actors)
// void "c" moveRel( GameObject id baseObj, int angle, int distance, ... );
-extern TilePoint dirTable[8];
+extern const StaticTilePoint dirTable[8];
int16 scriptActorMoveRel(int16 *args) {
OBJLOG(MoveRel);
diff --git a/engines/saga2/tcoords.h b/engines/saga2/tcoords.h
index 113fbe7a2a..7471471f03 100644
--- a/engines/saga2/tcoords.h
+++ b/engines/saga2/tcoords.h
@@ -79,6 +79,15 @@ struct StaticTilePoint {
return p;
}
+ friend StaticTilePoint operator/(StaticTilePoint a, int b) {
+ int16 nu = a.u / b;
+ int16 nv = a.v / b;
+ int16 nz = a.z / b;
+ StaticTilePoint p = {nu, nv, nz};
+
+ return p;
+ }
+
void operator+=(StaticTilePoint a) {
u += a.u;
v += a.v;
Commit: 53b4eb47a6a9f29c457b0c8df3c64d202496e083
https://github.com/scummvm/scummvm/commit/53b4eb47a6a9f29c457b0c8df3c64d202496e083
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:44+02:00
Commit Message:
SAGA2: Fix some warnings in motion.cpp
Changed paths:
engines/saga2/motion.cpp
engines/saga2/saga2.h
diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp
index d9f31aeaf0..4f957c77be 100644
--- a/engines/saga2/motion.cpp
+++ b/engines/saga2/motion.cpp
@@ -350,8 +350,7 @@ uint8 computeTurnFrames(Direction fromDir, Direction toDir) {
//-----------------------------------------------------------------------
// The list of active motion tasks for all actors
-static MotionTaskList mTaskList;
-static Common::List<MotionTask *>::iterator nextMT;
+static MotionTaskList *mTaskList;
//-----------------------------------------------------------------------
// Initialize the MotionTaskList
@@ -1175,8 +1174,8 @@ void *MotionTask::archive(void *buf) {
// When a motion task is finished, call this function to delete it.
void MotionTask::remove(int16 returnVal) {
- if (nextMT != mTaskList._list.end() && *nextMT == this)
- ++nextMT;
+ if (g_vm->_nextMT != mTaskList->_list.end() && *(g_vm->_nextMT) == this)
+ ++g_vm->_nextMT;
object->_data.objectFlags &= ~objectMoving;
if (objObscured(object))
@@ -1196,7 +1195,7 @@ void MotionTask::remove(int16 returnVal) {
a->setInterruptablity(true);
}
- mTaskList._list.remove(this);
+ mTaskList->_list.remove(this);
abortPathFind(this);
pathFindTask = NULL;
@@ -1264,7 +1263,7 @@ void MotionTask::turn(Actor &obj, Direction dir) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&obj)) != NULL) {
+ if ((mt = mTaskList->newTask(&obj)) != NULL) {
mt->direction = dir;
mt->motionType = motionTypeTurn;
mt->flags = reset;
@@ -1277,7 +1276,7 @@ void MotionTask::turn(Actor &obj, Direction dir) {
void MotionTask::turnTowards(Actor &obj, const TilePoint &where) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&obj)) != NULL) {
+ if ((mt = mTaskList->newTask(&obj)) != NULL) {
mt->direction = (where - obj.getLocation()).quickDir();
mt->motionType = motionTypeTurn;
mt->flags = reset;
@@ -1291,7 +1290,7 @@ void MotionTask::turnTowards(Actor &obj, const TilePoint &where) {
void MotionTask::give(Actor &actor, Actor &givee) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&actor)) != NULL) {
+ if ((mt = mTaskList->newTask(&actor)) != NULL) {
mt->targetObj = &givee;
mt->motionType = motionTypeGive;
mt->flags = reset;
@@ -1304,7 +1303,7 @@ void MotionTask::give(Actor &actor, Actor &givee) {
void MotionTask::throwObject(GameObject &obj, const TilePoint &velocity) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&obj)) != NULL) {
+ if ((mt = mTaskList->newTask(&obj)) != NULL) {
if (obj.isMissile()) obj._data.missileFacing = missileNoFacing;
mt->velocity = velocity;
mt->motionType = motionTypeThrown;
@@ -1322,7 +1321,7 @@ void MotionTask::throwObjectTo(GameObject &obj, const TilePoint &where) {
MotionTask *mt;
const int16 turns = 15;
- if ((mt = mTaskList.newTask(&obj)) != NULL) {
+ if ((mt = mTaskList->newTask(&obj)) != NULL) {
if (obj.isMissile()) obj._data.missileFacing = missileNoFacing;
mt->calcVelocity(where - obj.getLocation(), turns);
mt->motionType = motionTypeThrown;
@@ -1340,7 +1339,7 @@ void MotionTask::shootObject(
int16 speed) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&obj)) != NULL) {
+ if ((mt = mTaskList->newTask(&obj)) != NULL) {
TilePoint targetLoc = target.getLocation();
targetLoc.z += target.proto()->height / 2;
@@ -1380,7 +1379,7 @@ void MotionTask::walkTo(
bool canAgitate) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&actor)) != NULL) {
+ if ((mt = mTaskList->newTask(&actor)) != NULL) {
if (!mt->isReflex() && !actor.isImmobile()) {
unstickObject(&actor);
mt->finalTarget = mt->immediateLocation = target;
@@ -1409,7 +1408,7 @@ void MotionTask::walkToDirect(
bool canAgitate) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&actor)) != NULL) {
+ if ((mt = mTaskList->newTask(&actor)) != NULL) {
if (!mt->isReflex() && !actor.isImmobile()) {
// Abort any pending path finding task
abortPathFind(mt);
@@ -1438,7 +1437,7 @@ void MotionTask::wander(
bool run) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&actor)) != NULL) {
+ if ((mt = mTaskList->newTask(&actor)) != NULL) {
if (!mt->isReflex() && !actor.isImmobile()) {
// Abort any pending path finding task
abortPathFind(mt);
@@ -1468,7 +1467,7 @@ void MotionTask::tetheredWander(
bool run) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&actor)) != NULL) {
+ if ((mt = mTaskList->newTask(&actor)) != NULL) {
if (!mt->isReflex() && !actor.isImmobile()) {
// Abort any pending path finding task
abortPathFind(mt);
@@ -1499,7 +1498,7 @@ void MotionTask::tetheredWander(
void MotionTask::upLadder(Actor &actor) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&actor)) != NULL) {
+ if ((mt = mTaskList->newTask(&actor)) != NULL) {
if (mt->motionType != motionTypeClimbUp) {
mt->motionType = motionTypeClimbUp;
mt->flags = reset;
@@ -1513,7 +1512,7 @@ void MotionTask::upLadder(Actor &actor) {
void MotionTask::downLadder(Actor &actor) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&actor)) != NULL) {
+ if ((mt = mTaskList->newTask(&actor)) != NULL) {
if (mt->motionType != motionTypeClimbDown) {
mt->motionType = motionTypeClimbDown;
mt->flags = reset;
@@ -1527,7 +1526,7 @@ void MotionTask::downLadder(Actor &actor) {
void MotionTask::talk(Actor &actor) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&actor)) != NULL) {
+ if ((mt = mTaskList->newTask(&actor)) != NULL) {
if (mt->motionType != motionTypeTalk) {
mt->motionType = motionTypeTalk;
mt->flags = reset;
@@ -1542,7 +1541,7 @@ void MotionTask::talk(Actor &actor) {
void MotionTask::jump(Actor &actor) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&actor)) != NULL) {
+ if ((mt = mTaskList->newTask(&actor)) != NULL) {
if (mt->motionType != motionTypeThrown) {
mt->velocity.z = 10;
mt->motionType = motionTypeJump;
@@ -1558,7 +1557,7 @@ void MotionTask::jump(Actor &actor) {
void MotionTask::wait(Actor &a) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&a)) != NULL) {
+ if ((mt = mTaskList->newTask(&a)) != NULL) {
if (mt->motionType != motionTypeWait) {
mt->motionType = motionTypeWait;
mt->flags = reset;
@@ -1572,7 +1571,7 @@ void MotionTask::wait(Actor &a) {
void MotionTask::useObject(Actor &a, GameObject &dObj) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&a)) != NULL) {
+ if ((mt = mTaskList->newTask(&a)) != NULL) {
if (mt->motionType != motionTypeUseObject) {
mt->motionType = motionTypeUseObject;
mt->o.directObject = &dObj;
@@ -1591,7 +1590,7 @@ void MotionTask::useObjectOnObject(
GameObject &target) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&a)) != NULL) {
+ if ((mt = mTaskList->newTask(&a)) != NULL) {
if (mt->motionType != motionTypeUseObjectOnObject) {
mt->motionType = motionTypeUseObjectOnObject;
mt->o.directObject = &dObj;
@@ -1611,7 +1610,7 @@ void MotionTask::useObjectOnTAI(
ActiveItem &target) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&a)) != NULL) {
+ if ((mt = mTaskList->newTask(&a)) != NULL) {
if (mt->motionType != motionTypeUseObjectOnTAI) {
mt->motionType = motionTypeUseObjectOnTAI;
mt->o.directObject = &dObj;
@@ -1630,7 +1629,7 @@ void MotionTask::useObjectOnLocation(
const Location &target) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&a)) != NULL) {
+ if ((mt = mTaskList->newTask(&a)) != NULL) {
if (mt->motionType != motionTypeUseObjectOnLocation) {
mt->motionType = motionTypeUseObjectOnLocation;
mt->o.directObject = &dObj;
@@ -1646,7 +1645,7 @@ void MotionTask::useObjectOnLocation(
void MotionTask::useTAI(Actor &a, ActiveItem &dTAI) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&a)) != NULL) {
+ if ((mt = mTaskList->newTask(&a)) != NULL) {
if (mt->motionType != motionTypeUseTAI) {
mt->motionType = motionTypeUseTAI;
mt->o.TAI = &dTAI;
@@ -1664,7 +1663,7 @@ void MotionTask::dropObject(Actor &a,
int16 num) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&a)) != NULL) {
+ if ((mt = mTaskList->newTask(&a)) != NULL) {
if (mt->motionType != motionTypeDropObject) {
mt->motionType = motionTypeDropObject;
mt->o.directObject = &dObj;
@@ -1699,7 +1698,7 @@ void MotionTask::dropObjectOnObject(
// Otherwise, drop it on the object
- if ((mt = mTaskList.newTask(&a)) != NULL) {
+ if ((mt = mTaskList->newTask(&a)) != NULL) {
if (mt->motionType != motionTypeDropObjectOnObject) {
mt->motionType = motionTypeDropObjectOnObject;
mt->o.directObject = &dObj;
@@ -1720,7 +1719,7 @@ void MotionTask::dropObjectOnTAI(
const Location &loc) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&a)) != NULL) {
+ if ((mt = mTaskList->newTask(&a)) != NULL) {
if (mt->motionType != motionTypeDropObjectOnTAI) {
mt->motionType = motionTypeDropObjectOnTAI;
mt->o.directObject = &dObj;
@@ -1752,7 +1751,7 @@ bool MotionTask::isReflex(void) {
void MotionTask::twoHandedSwing(Actor &a, GameObject &target) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&a)) != NULL) {
+ if ((mt = mTaskList->newTask(&a)) != NULL) {
if (mt->motionType != motionTypeTwoHandedSwing) {
mt->motionType = motionTypeTwoHandedSwing;
mt->targetObj = ⌖
@@ -1767,7 +1766,7 @@ void MotionTask::twoHandedSwing(Actor &a, GameObject &target) {
void MotionTask::oneHandedSwing(Actor &a, GameObject &target) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&a)) != NULL) {
+ if ((mt = mTaskList->newTask(&a)) != NULL) {
if (mt->motionType != motionTypeOneHandedSwing) {
mt->motionType = motionTypeOneHandedSwing;
mt->targetObj = ⌖
@@ -1782,7 +1781,7 @@ void MotionTask::oneHandedSwing(Actor &a, GameObject &target) {
void MotionTask::fireBow(Actor &a, GameObject &target) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&a)) != NULL) {
+ if ((mt = mTaskList->newTask(&a)) != NULL) {
if (mt->motionType != motionTypeFireBow) {
mt->motionType = motionTypeFireBow;
mt->targetObj = ⌖
@@ -1802,7 +1801,7 @@ void MotionTask::castSpell(Actor &a, SkillProto &spell, GameObject &target) {
motionTypeCastSpell;
- if ((mt = mTaskList.newTask(&a)) != NULL) {
+ if ((mt = mTaskList->newTask(&a)) != NULL) {
if (mt->motionType != type) {
mt->motionType = type;
mt->spellObj = &spell;
@@ -1821,7 +1820,7 @@ void MotionTask::castSpell(Actor &a, SkillProto &spell, Location &target) {
motionTypeGive :
motionTypeCastSpell;
- if ((mt = mTaskList.newTask(&a)) != NULL) {
+ if ((mt = mTaskList->newTask(&a)) != NULL) {
if (mt->motionType != type) {
mt->motionType = type;
mt->spellObj = &spell;
@@ -1840,7 +1839,7 @@ void MotionTask::castSpell(Actor &a, SkillProto &spell, ActiveItem &target) {
motionTypeGive :
motionTypeCastSpell;
- if ((mt = mTaskList.newTask(&a)) != NULL) {
+ if ((mt = mTaskList->newTask(&a)) != NULL) {
if (mt->motionType != type) {
Location loc;
assert(target._data.itemType == activeTypeInstance);
@@ -1866,7 +1865,7 @@ void MotionTask::castSpell(Actor &a, SkillProto &spell, ActiveItem &target) {
void MotionTask::useWand(Actor &a, GameObject &target) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&a)) != NULL) {
+ if ((mt = mTaskList->newTask(&a)) != NULL) {
if (mt->motionType != motionTypeUseWand) {
mt->motionType = motionTypeUseWand;
mt->targetObj = ⌖
@@ -1886,7 +1885,7 @@ void MotionTask::twoHandedParry(
Actor &opponent) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&a)) != NULL) {
+ if ((mt = mTaskList->newTask(&a)) != NULL) {
if (mt->motionType != motionTypeTwoHandedParry) {
mt->motionType = motionTypeTwoHandedParry;
mt->d.attacker = &opponent;
@@ -1906,7 +1905,7 @@ void MotionTask::oneHandedParry(
Actor &opponent) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&a)) != NULL) {
+ if ((mt = mTaskList->newTask(&a)) != NULL) {
if (mt->motionType != motionTypeOneHandedParry) {
mt->motionType = motionTypeOneHandedParry;
mt->d.attacker = &opponent;
@@ -1926,7 +1925,7 @@ void MotionTask::shieldParry(
Actor &opponent) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&a)) != NULL) {
+ if ((mt = mTaskList->newTask(&a)) != NULL) {
if (mt->motionType != motionTypeShieldParry) {
mt->motionType = motionTypeShieldParry;
mt->d.attacker = &opponent;
@@ -1943,7 +1942,7 @@ void MotionTask::shieldParry(
void MotionTask::dodge(Actor &a, Actor &opponent) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&a)) != NULL) {
+ if ((mt = mTaskList->newTask(&a)) != NULL) {
if (mt->motionType != motionTypeDodge) {
mt->motionType = motionTypeDodge;
mt->d.attacker = &opponent;
@@ -1961,7 +1960,7 @@ void MotionTask::dodge(Actor &a, Actor &opponent) {
void MotionTask::acceptHit(Actor &a, Actor &opponent) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&a)) != NULL) {
+ if ((mt = mTaskList->newTask(&a)) != NULL) {
if (mt->motionType != motionTypeAcceptHit) {
mt->motionType = motionTypeAcceptHit;
mt->d.attacker = &opponent;
@@ -1976,7 +1975,7 @@ void MotionTask::acceptHit(Actor &a, Actor &opponent) {
void MotionTask::fallDown(Actor &a, Actor &opponent) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&a)) != NULL) {
+ if ((mt = mTaskList->newTask(&a)) != NULL) {
if (mt->motionType != motionTypeFallDown) {
mt->motionType = motionTypeFallDown;
mt->d.attacker = &opponent;
@@ -1991,7 +1990,7 @@ void MotionTask::fallDown(Actor &a, Actor &opponent) {
void MotionTask::die(Actor &a) {
MotionTask *mt;
- if ((mt = mTaskList.newTask(&a)) != NULL) {
+ if ((mt = mTaskList->newTask(&a)) != NULL) {
if (mt->motionType != motionTypeDie) {
mt->motionType = motionTypeDie;
mt->flags = reset;
@@ -4151,15 +4150,15 @@ void MotionTask::updatePositions(void) {
int16 targetDist;
StandingTileInfo sti;
- for (Common::List<MotionTask *>::iterator it = mTaskList._list.begin(); it != mTaskList._list.end(); it = nextMT) {
+ for (Common::List<MotionTask *>::iterator it = mTaskList->_list.begin(); it != mTaskList->_list.end(); it = g_vm->_nextMT) {
MotionTask *mt = *it;
GameObject *obj = mt->object;
ProtoObj *proto = obj->proto();
Actor *a = (Actor *)obj;
bool moveTaskDone = false;
- nextMT = it;
- nextMT++;
+ g_vm->_nextMT = it;
+ g_vm->_nextMT++;
if (!isWorld(obj->IDParent())) {
mt->remove();
@@ -4236,7 +4235,7 @@ void MotionTask::updatePositions(void) {
mt->finalTarget,
(mt->flags & requestRun) != 0);
}
- nextMT = it;
+ g_vm->_nextMT = it;
}
} else {
a->setAction(newAction, 0);
@@ -4255,7 +4254,7 @@ void MotionTask::updatePositions(void) {
mt->finalTarget,
(mt->flags & requestRun) != 0);
}
- nextMT = it;
+ g_vm->_nextMT = it;
} else if (mt->freeFall(obj->_data.location, sti) == false)
moveTaskDone = true;
} else {
@@ -4276,7 +4275,7 @@ void MotionTask::updatePositions(void) {
mt->finalTarget,
(mt->flags & requestRun) != 0);
}
- nextMT = it;
+ g_vm->_nextMT = it;
}
}
break;
@@ -4317,7 +4316,7 @@ void MotionTask::updatePositions(void) {
if (targetDist > kTileUVSize) {
mt->motionType = mt->prevMotionType;
mt->flags |= reset;
- nextMT = it;
+ g_vm->_nextMT = it;
} else
moveTaskDone = true;
}
@@ -4337,7 +4336,7 @@ void MotionTask::updatePositions(void) {
// This will be uninterrutable for 2 frames
a->setActionPoints(2);
mt->o.directObject->use(a->thisID());
- //nextMT=mt;
+ //g_vm->_nextMT=mt;
moveTaskDone = true;
break;
@@ -4365,7 +4364,7 @@ void MotionTask::updatePositions(void) {
if (mt && mt->motionType == motionTypeUseObjectOnObject)
moveTaskDone = true;
else
- nextMT = it;
+ g_vm->_nextMT = it;
}
}
} else {
@@ -4377,7 +4376,7 @@ void MotionTask::updatePositions(void) {
if (mt && mt->motionType == motionTypeUseObjectOnObject)
moveTaskDone = true;
else
- nextMT = it;
+ g_vm->_nextMT = it;
}
break;
@@ -4418,7 +4417,7 @@ void MotionTask::updatePositions(void) {
if (mt && mt->motionType == motionTypeUseObjectOnTAI)
moveTaskDone = true;
else
- nextMT = it;
+ g_vm->_nextMT = it;
}
break;
@@ -4438,7 +4437,7 @@ void MotionTask::updatePositions(void) {
if (mt && mt->motionType == motionTypeUseObjectOnLocation)
moveTaskDone = true;
else
- nextMT = it;
+ g_vm->_nextMT = it;
}
break;
@@ -4498,7 +4497,7 @@ void MotionTask::updatePositions(void) {
if (mt && mt->motionType == motionTypeDropObject)
moveTaskDone = true;
else
- nextMT = it;
+ g_vm->_nextMT = it;
}
} else {
// The actor will now be uniterruptable
@@ -4509,7 +4508,7 @@ void MotionTask::updatePositions(void) {
if (mt && mt->motionType == motionTypeDropObject)
moveTaskDone = true;
else
- nextMT = it;
+ g_vm->_nextMT = it;
}
CMassWeightIndicator::bRedraw = true; // tell the mass/weight indicators to refresh
@@ -4533,7 +4532,7 @@ void MotionTask::updatePositions(void) {
if (mt && mt->motionType == motionTypeDropObjectOnObject)
moveTaskDone = true;
else
- nextMT = it;
+ g_vm->_nextMT = it;
}
} else {
// The actor will now be uniterruptable
@@ -4545,7 +4544,7 @@ void MotionTask::updatePositions(void) {
if (mt && mt->motionType == motionTypeDropObjectOnObject)
moveTaskDone = true;
else
- nextMT = it;
+ g_vm->_nextMT = it;
}
CMassWeightIndicator::bRedraw = true; // tell the mass/weight indicators to refresh
@@ -4571,7 +4570,7 @@ void MotionTask::updatePositions(void) {
if (mt && mt->motionType == motionTypeDropObjectOnTAI)
moveTaskDone = true;
else
- nextMT = it;
+ g_vm->_nextMT = it;
}
break;
@@ -4933,7 +4932,7 @@ void resumeInterruptableMotions(void) {
void initMotionTasks(void) {
// Simply call the default MotionTaskList constructor
- new (&mTaskList) MotionTaskList;
+ mTaskList = new MotionTaskList;
}
//-----------------------------------------------------------------------
@@ -4943,13 +4942,13 @@ void saveMotionTasks(SaveFileConstructor &saveGame) {
int32 archiveBufSize;
void *archiveBuffer;
- archiveBufSize = mTaskList.archiveSize();
+ archiveBufSize = mTaskList->archiveSize();
archiveBuffer = malloc(archiveBufSize);
if (archiveBuffer == NULL)
error("Unable to allocate motion task archive buffer");
- mTaskList.archive(archiveBuffer);
+ mTaskList->archive(archiveBuffer);
saveGame.writeChunk(
MakeID('M', 'O', 'T', 'N'),
@@ -4995,7 +4994,8 @@ void loadMotionTasks(SaveFileReader &saveGame) {
void cleanupMotionTasks(void) {
// Simply call stackList's cleanup
- mTaskList.cleanup();
+ mTaskList->cleanup();
+ delete mTaskList;
}
} // end of namespace Saga2
diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h
index 516cc84278..d31bed48ce 100644
--- a/engines/saga2/saga2.h
+++ b/engines/saga2/saga2.h
@@ -45,6 +45,7 @@ class TimerList;
class BandList;
class ActorAppearance;
class PathRequest;
+class MotionTask;
enum {
kDebugResources = 1 << 0,
@@ -98,6 +99,7 @@ public:
Common::List<Timer *> _timers;
Common::List<ActorAppearance *> _appearanceLRU;
Common::List<PathRequest *> _pathQueue;
+ Common::List<MotionTask *>::iterator _nextMT;
BandList *_bandList;
gDisplayPort _mainPort;
Commit: 1d88f03012bb4e5ef49a200aa7179b666cc1b106
https://github.com/scummvm/scummvm/commit/1d88f03012bb4e5ef49a200aa7179b666cc1b106
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:44+02:00
Commit Message:
SAGA2: Fix global constructor warnings in motion.cpp
Changed paths:
engines/saga2/motion.cpp
diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp
index 4f957c77be..2ecb791818 100644
--- a/engines/saga2/motion.cpp
+++ b/engines/saga2/motion.cpp
@@ -3228,12 +3228,6 @@ struct CombatMotionSet {
const uint8 *list; // Array of motion types
uint16 listSize; // Size of array
- // Constructor
- CombatMotionSet(const uint8 *l, uint16 sz) :
- list(l),
- listSize(sz) {
- }
-
// Select randome element from the array
uint8 selectRandom(void) const {
return list[rand() % listSize];
@@ -3252,10 +3246,10 @@ const uint8 twoHandedSwingArray[] = {
MotionTask::twoHandedSwingRightLow,
};
-const CombatMotionSet twoHandedSwingSet =
- CombatMotionSet(
- twoHandedSwingArray,
- ARRAYSIZE(twoHandedSwingArray));
+const CombatMotionSet twoHandedSwingSet = {
+ twoHandedSwingArray,
+ ARRAYSIZE(twoHandedSwingArray)
+};
// Construct a subset of all high two handed swing types
const uint8 twoHandedHighSwingArray[] = {
@@ -3264,10 +3258,10 @@ const uint8 twoHandedHighSwingArray[] = {
MotionTask::twoHandedSwingRightHigh,
};
-const CombatMotionSet twoHandedHighSwingSet =
- CombatMotionSet(
- twoHandedHighSwingArray,
- ARRAYSIZE(twoHandedHighSwingArray));
+const CombatMotionSet twoHandedHighSwingSet = {
+ twoHandedHighSwingArray,
+ ARRAYSIZE(twoHandedHighSwingArray)
+};
// Construct a subset of all low two handed swing types
const uint8 twoHandedLowSwingArray[] = {
@@ -3276,10 +3270,10 @@ const uint8 twoHandedLowSwingArray[] = {
MotionTask::twoHandedSwingRightLow,
};
-const CombatMotionSet twoHandedLowSwingSet =
- CombatMotionSet(
- twoHandedLowSwingArray,
- ARRAYSIZE(twoHandedLowSwingArray));
+const CombatMotionSet twoHandedLowSwingSet = {
+ twoHandedLowSwingArray,
+ ARRAYSIZE(twoHandedLowSwingArray)
+};
//-----------------------------------------------------------------------
// Handle all two handed swing motions
@@ -3371,30 +3365,30 @@ const uint8 oneHandedSwingArray[] = {
// MotionTask::oneHandedThrust,
};
-const CombatMotionSet oneHandedSwingSet =
- CombatMotionSet(
- oneHandedSwingArray,
- ARRAYSIZE(oneHandedSwingArray));
+const CombatMotionSet oneHandedSwingSet = {
+ oneHandedSwingArray,
+ ARRAYSIZE(oneHandedSwingArray)
+};
// Construct a subset of all high one handed swing types
const uint8 oneHandedHighSwingArray[] = {
MotionTask::oneHandedSwingHigh,
};
-const CombatMotionSet oneHandedHighSwingSet =
- CombatMotionSet(
- oneHandedHighSwingArray,
- ARRAYSIZE(oneHandedHighSwingArray));
+const CombatMotionSet oneHandedHighSwingSet = {
+ oneHandedHighSwingArray,
+ ARRAYSIZE(oneHandedHighSwingArray)
+};
// Construct a subset of all low one handed swing types
const uint8 oneHandedLowSwingArray[] = {
MotionTask::oneHandedSwingLow,
};
-const CombatMotionSet oneHandedLowSwingSet =
- CombatMotionSet(
- oneHandedLowSwingArray,
- ARRAYSIZE(oneHandedLowSwingArray));
+const CombatMotionSet oneHandedLowSwingSet = {
+ oneHandedLowSwingArray,
+ ARRAYSIZE(oneHandedLowSwingArray)
+};
//-----------------------------------------------------------------------
// Handle all one handed swing motions
Commit: 85b1c8e842c733dd3d87f7f894cb18d66328533a
https://github.com/scummvm/scummvm/commit/85b1c8e842c733dd3d87f7f894cb18d66328533a
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:44+02:00
Commit Message:
SAGA2: Move mouseInfo to Saga2Engine
Changed paths:
engines/saga2/automap.cpp
engines/saga2/contain.cpp
engines/saga2/display.cpp
engines/saga2/floating.cpp
engines/saga2/grabinfo.cpp
engines/saga2/grabinfo.h
engines/saga2/intrface.cpp
engines/saga2/modal.cpp
engines/saga2/objects.cpp
engines/saga2/objproto.cpp
engines/saga2/playmode.cpp
engines/saga2/saga2.cpp
engines/saga2/saga2.h
engines/saga2/speech.cpp
engines/saga2/tilemode.cpp
diff --git a/engines/saga2/automap.cpp b/engines/saga2/automap.cpp
index 5d7a643b95..4aa5a925c8 100644
--- a/engines/saga2/automap.cpp
+++ b/engines/saga2/automap.cpp
@@ -302,8 +302,6 @@ gPanel *CAutoMap::keyTest(int16 key) {
// ------------------------------------------------------------------------
// mouse movement event handler
-extern GrabInfo mouseInfo;
-
void CAutoMap::pointerMove(gPanelMessage &msg) {
Point16 pos = msg.pickAbsPos;
@@ -318,7 +316,7 @@ void CAutoMap::pointerMove(gPanelMessage &msg) {
viewRegion.min.v = MAX(localAreaRegion.min.v, baseCoords.v);
viewRegion.max.v = MIN<int16>(localAreaRegion.max.v, baseCoords.v + (int16)summaryDiameter) - 1;
char *mtext = getMapFeaturesText(viewRegion, currentWorld->mapNum, baseCoords, pos) ;
- mouseInfo.setText(mtext);
+ g_vm->_mouseInfo->setText(mtext);
} else {
notify(gEventMouseMove, 0);
}
diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index 491eac9b3f..db12d008e5 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -610,13 +610,13 @@ void ContainerView::pointerMove(gPanelMessage &msg) {
if (msg.pointerLeave) {
lastPickedObjectID = Nothing;
lastPickedObjectQuantity = -1;
- mouseInfo.setText(NULL);
+ g_vm->_mouseInfo->setText(NULL);
mouseText[0] = 0;
// static bool that tells if the mouse cursor
// is in a panel
mouseInView = false;
- mouseInfo.setDoable(true);
+ g_vm->_mouseInfo->setDoable(true);
} else {
// if( msg.pointerEnter )
{
@@ -625,14 +625,14 @@ void ContainerView::pointerMove(gPanelMessage &msg) {
mouseInView = true;
GameObject *mouseObject;
- mouseObject = mouseInfo.getObject();
+ mouseObject = g_vm->_mouseInfo->getObject();
if (!node.isAccessable(getCenterActorID())) {
- mouseInfo.setDoable(false);
+ g_vm->_mouseInfo->setDoable(false);
} else if (mouseObject == NULL) {
- mouseInfo.setDoable(true);
+ g_vm->_mouseInfo->setDoable(true);
} else {
- mouseInfo.setDoable(containerObject->canContain(mouseObject->thisID()));
+ g_vm->_mouseInfo->setDoable(containerObject->canContain(mouseObject->thisID()));
}
}
@@ -647,10 +647,10 @@ bool ContainerView::pointerHit(gPanelMessage &msg) {
uint16 mouseSet;
slotObject = pickObject(msg.pickPos);
- mouseObject = mouseInfo.getObject();
+ mouseObject = g_vm->_mouseInfo->getObject();
mouseSet = mouseObject ? mouseObject->containmentSet() : 0;
- if (!mouseInfo.getDoable()) return false;
+ if (!g_vm->_mouseInfo->getDoable()) return false;
if (msg.doubleClick && !alreadyDone) {
dblClick(mouseObject, slotObject, msg);
@@ -658,9 +658,9 @@ bool ContainerView::pointerHit(gPanelMessage &msg) {
if (mouseObject != NULL) {
alreadyDone = true; // if object then no doubleClick
- if (mouseInfo.getIntent() == GrabInfo::Drop) {
+ if (g_vm->_mouseInfo->getIntent() == GrabInfo::Drop) {
if (mouseSet & ProtoObj::isTangible) {
- dropPhysical(msg, mouseObject, slotObject, mouseInfo.getMoveCount());
+ dropPhysical(msg, mouseObject, slotObject, g_vm->_mouseInfo->getMoveCount());
}
// intangibles are used by dropping them
@@ -671,20 +671,20 @@ bool ContainerView::pointerHit(gPanelMessage &msg) {
useConcept(msg, mouseObject, slotObject);
} else {
// !!!! bad state, reset cursor
- mouseInfo.replaceObject();
+ g_vm->_mouseInfo->replaceObject();
}
- } else if (mouseInfo.getIntent() == GrabInfo::Use) {
+ } else if (g_vm->_mouseInfo->getIntent() == GrabInfo::Use) {
if (mouseSet & ProtoObj::isTangible) {
usePhysical(msg, mouseObject, slotObject);
} else if ((mouseSet & ProtoObj::isSpell) ||
(mouseSet & ProtoObj::isSkill)) {
- mouseInfo.replaceObject();
+ g_vm->_mouseInfo->replaceObject();
} else {
useConcept(msg, mouseObject, slotObject);
}
} else {
// !!!! bad state, reset cursor
- mouseInfo.replaceObject();
+ g_vm->_mouseInfo->replaceObject();
}
} else {
// default to doubleClick active
@@ -757,7 +757,7 @@ void ContainerView::clickOn(
} else {
// activate multi-object get interface if a mergeable object
getMerged(cObj);
- mouseInfo.setText(NULL);
+ g_vm->_mouseInfo->setText(NULL);
mouseText[0] = 0;
}
} else {
@@ -788,7 +788,7 @@ void ContainerView::dblClickOn(
// Only player actors can be possessors as far as the UI is concerned
if (actorIDToPlayerID(possessor, pID) == false) possessor = Nothing;
- mouseInfo.replaceObject(); //Put Object Back
+ g_vm->_mouseInfo->replaceObject(); //Put Object Back
if (!(proto->setUseCursor(mObj->thisID()))) {
MotionTask::useObject(
possessor == Nothing ? *getCenterActor() : * (Actor *)GameObject::objectAddress(possessor),
@@ -803,11 +803,11 @@ void ContainerView::dropPhysical(
GameObject *mObj,
GameObject *cObj,
int16 num) {
- assert(mouseInfo.getObject() == mObj);
+ assert(g_vm->_mouseInfo->getObject() == mObj);
assert(mObj->containmentSet() & ProtoObj::isTangible);
// Place object back where it came from, temporarily
- mouseInfo.replaceObject();
+ g_vm->_mouseInfo->replaceObject();
// test to check if item is accepted by container
if (containerObject->canContain(mObj->thisID())) {
@@ -834,13 +834,13 @@ void ContainerView::usePhysical(
gPanelMessage &msg,
GameObject *mObj,
GameObject *cObj) {
- assert(mouseInfo.getObject() == mObj);
+ assert(g_vm->_mouseInfo->getObject() == mObj);
assert(mObj->containmentSet() & ProtoObj::isTangible);
if (cObj == NULL) {
dropPhysical(msg, mObj, cObj);
} else {
- mouseInfo.replaceObject();
+ g_vm->_mouseInfo->replaceObject();
// Use mouse object on container object
MotionTask::useObjectOnObject(*getCenterActor(), *mObj, *cObj);
}
@@ -851,10 +851,10 @@ void ContainerView::useConcept(
gPanelMessage &msg,
GameObject *mObj,
GameObject *cObj) {
- assert(mouseInfo.getObject() == mObj);
+ assert(g_vm->_mouseInfo->getObject() == mObj);
assert(mObj->containmentSet() & ProtoObj::isIntangible);
- mouseInfo.replaceObject();
+ g_vm->_mouseInfo->replaceObject();
// Determine if this object can go into this container
if (containerObject->canContain(mObj->thisID())) {
@@ -892,7 +892,7 @@ void ContainerView::updateMouseText(Point16 &pickPos) {
// set the mouse text to null if there is no object to get hints about
if (slotID == Nothing) {
// clear out the mouse text
- mouseInfo.setText(NULL);
+ g_vm->_mouseInfo->setText(NULL);
mouseText[0] = 0;
// reset the last picked thingy
@@ -916,7 +916,7 @@ void ContainerView::updateMouseText(Point16 &pickPos) {
lastPickedObjectQuantity = slotObject->getExtra();
// clear out the mouse text
- mouseInfo.setText(NULL);
+ g_vm->_mouseInfo->setText(NULL);
mouseText[0] = 0;
// reset the alarm flag
@@ -942,12 +942,12 @@ void ContainerView::setCursorText(GameObject *obj) {
// put the normalized text into cursorText
obj->objCursorText(cursorText, bufSize);
- mouseInfo.setText(cursorText);
+ g_vm->_mouseInfo->setText(cursorText);
}
void ContainerView::setDelayedCursorText(GameObject *obj) {
// clear out the mouse text
- mouseInfo.setText(NULL);
+ g_vm->_mouseInfo->setText(NULL);
mouseText[0] = 0;
// reset the alarm flag
@@ -2003,11 +2003,11 @@ APPFUNC(cmdMindContainerFunc) {
}
// set the text in the cursor
- mouseInfo.setText(textBuffer);
+ g_vm->_mouseInfo->setText(textBuffer);
}
if (ev.value == gCompImage::leave) {
- mouseInfo.setText(NULL);
+ g_vm->_mouseInfo->setText(NULL);
}
}
}
@@ -2024,14 +2024,14 @@ APPFUNC(cmdCloseButtonFunc) {
updateContainerWindows();
// make sure the hint text goes away
- if (mouseInfo.getObject() == NULL) {
- mouseInfo.setText(NULL);
+ if (g_vm->_mouseInfo->getObject() == NULL) {
+ g_vm->_mouseInfo->setText(NULL);
}
} else if (ev.eventType == gEventMouseMove) {
if (ev.value == gCompImage::enter) {
- mouseInfo.setText(CLOSE_MOUSE);
+ g_vm->_mouseInfo->setText(CLOSE_MOUSE);
} else if (ev.value == gCompImage::leave) {
- mouseInfo.setText(NULL);
+ g_vm->_mouseInfo->setText(NULL);
}
}
}
@@ -2049,9 +2049,9 @@ APPFUNC(cmdScrollFunc) {
ev.window->update(cw->getView().getExtent());
} else if (ev.eventType == gEventMouseMove) {
if (ev.value == gCompImage::enter) {
- mouseInfo.setText(SCROLL_MOUSE);
+ g_vm->_mouseInfo->setText(SCROLL_MOUSE);
} else if (ev.value == gCompImage::leave) {
- mouseInfo.setText(NULL);
+ g_vm->_mouseInfo->setText(NULL);
}
}
}
diff --git a/engines/saga2/display.cpp b/engines/saga2/display.cpp
index 28c61067bd..fd85fd9c1b 100644
--- a/engines/saga2/display.cpp
+++ b/engines/saga2/display.cpp
@@ -102,10 +102,10 @@ void niceScreenStartup(void) {
//pointer.show();
updateAllUserControls();
reDrawScreen();
- mouseInfo.replaceObject();
- mouseInfo.clearGauge();
- mouseInfo.setText(NULL);
- mouseInfo.setIntent(GrabInfo::WalkTo);
+ g_vm->_mouseInfo->replaceObject();
+ g_vm->_mouseInfo->clearGauge();
+ g_vm->_mouseInfo->setText(NULL);
+ g_vm->_mouseInfo->setIntent(GrabInfo::WalkTo);
resetInputDevices();
}
diff --git a/engines/saga2/floating.cpp b/engines/saga2/floating.cpp
index 638bc3aa48..c9ae12e419 100644
--- a/engines/saga2/floating.cpp
+++ b/engines/saga2/floating.cpp
@@ -587,10 +587,10 @@ void FloatingWindow::setExtent(const Rect16 &r) {
bool FloatingWindow::open(void) {
db->moveToBack(*this);
- mouseInfo.replaceObject();
- mouseInfo.clearGauge();
- mouseInfo.setText(NULL);
- mouseInfo.setIntent(GrabInfo::WalkTo);
+ g_vm->_mouseInfo->replaceObject();
+ g_vm->_mouseInfo->clearGauge();
+ g_vm->_mouseInfo->setText(NULL);
+ g_vm->_mouseInfo->setIntent(GrabInfo::WalkTo);
return gWindow::open();
}
diff --git a/engines/saga2/grabinfo.cpp b/engines/saga2/grabinfo.cpp
index 1c95845605..af11c6d38b 100644
--- a/engines/saga2/grabinfo.cpp
+++ b/engines/saga2/grabinfo.cpp
@@ -33,8 +33,6 @@
namespace Saga2 {
-GrabInfo mouseInfo;
-
/* ===================================================================== *
GrabInfo members
* ===================================================================== */
@@ -356,19 +354,19 @@ extern bool walkEnabled;
void cycleCursor() {
- if (! mouseInfo.cursorCyclingEnabled)
+ if (! g_vm->_mouseInfo.cursorCyclingEnabled)
return;
uint8 curIntent;
- curIntent = mouseInfo.getIntent();
+ curIntent = g_vm->_mouseInfo.getIntent();
if (++curIntent == GrabInfo::IntentCounts)
- mouseInfo.setIntent(1); //Set Cursor First State Skip None
+ g_vm->_mouseInfo.setIntent(1); //Set Cursor First State Skip None
else {
if (!walkEnabled && curIntent == GrabInfo::WalkTo)
++curIntent;
- if (curIntent == GrabInfo::PickUp && mouseInfo.getObject() != nullptr)
+ if (curIntent == GrabInfo::PickUp && g_vm->_mouseInfo.getObject() != nullptr)
++curIntent;
- if (curIntent == GrabInfo::Drop && mouseInfo.getObject() == nullptr)
+ if (curIntent == GrabInfo::Drop && g_vm->_mouseInfo.getObject() == nullptr)
++curIntent;
if (!eyeEnabled && curIntent == GrabInfo::LookAt)
++curIntent;
@@ -377,11 +375,11 @@ void cycleCursor() {
curIntent = 1; //Set Cursor First State Skip None
else {
curIntent = 2;
- if (curIntent == GrabInfo::PickUp && mouseInfo.getObject() != nullptr)
+ if (curIntent == GrabInfo::PickUp && g_vm->_mouseInfo.getObject() != nullptr)
++curIntent;
}
}
- mouseInfo.setIntent(curIntent); //Set Cursor To Next State
+ g_vm->_mouseInfo.setIntent(curIntent); //Set Cursor To Next State
}
}
diff --git a/engines/saga2/grabinfo.h b/engines/saga2/grabinfo.h
index dc015404fd..908aa83621 100644
--- a/engines/saga2/grabinfo.h
+++ b/engines/saga2/grabinfo.h
@@ -145,8 +145,6 @@ public:
void clearGauge(void);
};
-extern GrabInfo mouseInfo;
-
} // end of namespace Saga2
#endif
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index 831b7be16e..22dc7a56d7 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -2013,7 +2013,7 @@ void toggleIndivMode(void) {
void setCenterBrother(uint16 whichBrother) {
// If we picked up anything, then put it back.
- mouseInfo.replaceObject();
+ g_vm->_mouseInfo->replaceObject();
// set the new center actor
setCenterActor(&playerList[whichBrother]);
@@ -2172,7 +2172,7 @@ APPFUNC(cmdPortrait) {
const int stateBufSize = 60;
uint16 panID = ev.panel->id;
- GameObject *mouseObject = mouseInfo.getObject(); // object being dragged
+ GameObject *mouseObject = g_vm->_mouseInfo->getObject(); // object being dragged
switch (ev.eventType) {
@@ -2183,10 +2183,10 @@ APPFUNC(cmdPortrait) {
Actor *centerActorPtr = getCenterActor();
// we dropped the object onto another object
- if (mouseInfo.getDoable()) {
- int16 intent = mouseInfo.getIntent();
+ if (g_vm->_mouseInfo->getDoable()) {
+ int16 intent = g_vm->_mouseInfo->getIntent();
- mouseInfo.replaceObject();
+ g_vm->_mouseInfo->replaceObject();
if (intent == GrabInfo::Use) {
// If we are using an intangible object (spell) then consider
// the owner of the spell to be the center actor for the rest
@@ -2208,13 +2208,13 @@ APPFUNC(cmdPortrait) {
*centerActorPtr,
*mouseObject,
*pa->getActor(),
- mouseInfo.getMoveCount());
+ g_vm->_mouseInfo->getMoveCount());
}
// ( ( gGenericControl * )ev.panel )->disableDblClick();
// clickActionDone = true;
- } else if (mouseInfo.getIntent() == GrabInfo::Use) {
- mouseInfo.replaceObject();
+ } else if (g_vm->_mouseInfo->getIntent() == GrabInfo::Use) {
+ g_vm->_mouseInfo->replaceObject();
// clickActionDone = true;
}
} else if (panID != uiIndiv) {
@@ -2230,8 +2230,8 @@ APPFUNC(cmdPortrait) {
case gEventMouseMove:
if (ev.value == gCompImage::leave) {
- mouseInfo.setText(nullptr);
- mouseInfo.setDoable(true);
+ g_vm->_mouseInfo->setText(nullptr);
+ g_vm->_mouseInfo->setDoable(true);
break;
}
@@ -2242,12 +2242,12 @@ APPFUNC(cmdPortrait) {
Actor *targetActor = pa->getActor(),
*enactor = getCenterActor();
- mouseInfo.setText(nullptr);
+ g_vm->_mouseInfo->setText(nullptr);
if ((enactor->getLocation() - targetActor->getLocation()).quickHDistance() > 96) {
- mouseInfo.setDoable(false);
+ g_vm->_mouseInfo->setDoable(false);
} else {
- mouseInfo.setDoable(true);
+ g_vm->_mouseInfo->setDoable(true);
}
} else {
@@ -2270,7 +2270,7 @@ APPFUNC(cmdPortrait) {
break;
}
// set the text in the cursor
- mouseInfo.setText(buf);
+ g_vm->_mouseInfo->setText(buf);
}
}
break;
@@ -2307,11 +2307,11 @@ APPFUNC(cmdAggressive) {
} else if (ev.eventType == gEventMouseMove) {
if (ev.value == gCompImage::enter) {
// set the text in the cursor
- mouseInfo.setText(isAggressive(transBroID)
+ g_vm->_mouseInfo->setText(isAggressive(transBroID)
? ON_AGRESS
: OFF_AGRESS);
} else if (ev.value == gCompImage::leave) {
- mouseInfo.setText(nullptr);
+ g_vm->_mouseInfo->setText(nullptr);
}
}
}
@@ -2344,7 +2344,7 @@ APPFUNC(cmdArmor) {
if (gai->attr.damageAbsorbtion == 0
&& gai->attr.defenseBonus == 0) {
- mouseInfo.setText(NO_ARMOR);
+ g_vm->_mouseInfo->setText(NO_ARMOR);
} else {
sprintf(buf,
DESC_ARMOR,
@@ -2353,10 +2353,10 @@ APPFUNC(cmdArmor) {
gai->attr.defenseBonus);
// set the text in the cursor
- mouseInfo.setText(buf);
+ g_vm->_mouseInfo->setText(buf);
}
} else if (ev.value == gCompImage::leave) {
- mouseInfo.setText(nullptr);
+ g_vm->_mouseInfo->setText(nullptr);
}
}
}
@@ -2372,11 +2372,11 @@ APPFUNC(cmdCenter) {
if (ev.eventType == gEventMouseMove) {
if (ev.value == gCompImage::enter) {
// set the text in the cursor
- mouseInfo.setText(getCenterActorPlayerID() == transBroID
+ g_vm->_mouseInfo->setText(getCenterActorPlayerID() == transBroID
? ON_CENTER
: OFF_CENTER);
} else if (ev.value == gCompImage::leave) {
- mouseInfo.setText(nullptr);
+ g_vm->_mouseInfo->setText(nullptr);
}
}
}
@@ -2406,11 +2406,11 @@ APPFUNC(cmdBand) {
} else if (ev.eventType == gEventMouseMove) {
if (ev.value == gCompImage::enter) {
// set the text in the cursor
- mouseInfo.setText(isBanded(transBroID)
+ g_vm->_mouseInfo->setText(isBanded(transBroID)
? ON_BANDED
: OFF_BANDED);
} else if (ev.value == gCompImage::leave) {
- mouseInfo.setText(nullptr);
+ g_vm->_mouseInfo->setText(nullptr);
}
}
}
@@ -2420,8 +2420,8 @@ APPFUNC(cmdOptions) {
OptionsDialog();
//openOptionsPanel();
} else if (ev.eventType == gEventMouseMove) {
- if (ev.value == gCompImage::enter) mouseInfo.setText(OPTIONS_PANEL);
- else if (ev.value == gCompImage::leave) mouseInfo.setText(nullptr);
+ if (ev.value == gCompImage::enter) g_vm->_mouseInfo->setText(OPTIONS_PANEL);
+ else if (ev.value == gCompImage::leave) g_vm->_mouseInfo->setText(nullptr);
}
}
@@ -2460,9 +2460,9 @@ APPFUNC(cmdBroChange) {
break;
}
// set the text in the cursor
- mouseInfo.setText(buf);
+ g_vm->_mouseInfo->setText(buf);
} else if (ev.value == gCompImage::leave) {
- mouseInfo.setText(nullptr);
+ g_vm->_mouseInfo->setText(nullptr);
}
}
}
@@ -2472,7 +2472,7 @@ APPFUNC(cmdHealthStar) {
if (ev.eventType == gEventMouseMove) {
if (ev.value == gCompImage::leave) {
- mouseInfo.setText(nullptr);
+ g_vm->_mouseInfo->setText(nullptr);
return;
}
@@ -2487,7 +2487,7 @@ APPFUNC(cmdHealthStar) {
char buf[40];
sprintf(buf, "%s %d/%d", HEALTH_HINT, currVitality, baseVitality);
- mouseInfo.setText(buf);
+ g_vm->_mouseInfo->setText(buf);
}
}
@@ -2519,11 +2519,11 @@ APPFUNC(cmdMassInd) {
if (baseWeight != unlimitedCapacity) {
sprintf(buf, "%s %d/%d", WEIGHT_HINT, curWeight, baseWeight);
- mouseInfo.setText(buf);
+ g_vm->_mouseInfo->setText(buf);
} else
- mouseInfo.setText(UNK_WEIGHT_HINT);
+ g_vm->_mouseInfo->setText(UNK_WEIGHT_HINT);
} else if (ev.value == gCompImage::leave) {
- mouseInfo.setText(nullptr);
+ g_vm->_mouseInfo->setText(nullptr);
}
}
}
@@ -2557,11 +2557,11 @@ APPFUNC(cmdBulkInd) {
if (baseBulk != unlimitedCapacity) {
sprintf(buf, "%s %d/%d", BULK_HINT, curBulk, baseBulk);
- mouseInfo.setText(buf);
+ g_vm->_mouseInfo->setText(buf);
} else
- mouseInfo.setText(UNK_BULK_HINT);
+ g_vm->_mouseInfo->setText(UNK_BULK_HINT);
} else if (ev.value == gCompImage::leave) {
- mouseInfo.setText(nullptr);
+ g_vm->_mouseInfo->setText(nullptr);
}
}
}
@@ -2633,9 +2633,9 @@ APPFUNC(cmdManaInd) {
}
// set the text in the cursor
- mouseInfo.setText(textBuffer);
+ g_vm->_mouseInfo->setText(textBuffer);
} else
- mouseInfo.setText(nullptr);
+ g_vm->_mouseInfo->setText(nullptr);
}
}
@@ -2761,7 +2761,7 @@ void gEnchantmentDisplay::drawClipped(gPort &port, const Point16 &offset, con
void gEnchantmentDisplay::pointerMove(gPanelMessage &msg) {
if (msg.pointerLeave) {
- mouseInfo.setText(nullptr);
+ g_vm->_mouseInfo->setText(nullptr);
} else {
int16 x = extent.width - 10;
@@ -2780,7 +2780,7 @@ void gEnchantmentDisplay::pointerMove(gPanelMessage &msg) {
if (iconFlags[i] == 255)
sprintf(buf, "%s", enchantmentNames[i]);
else sprintf(buf, "%s : %d", enchantmentNames[i], iconFlags[i]);
- mouseInfo.setText(buf);
+ g_vm->_mouseInfo->setText(buf);
return;
}
}
diff --git a/engines/saga2/modal.cpp b/engines/saga2/modal.cpp
index 38e5d1b7a6..5c313197ff 100644
--- a/engines/saga2/modal.cpp
+++ b/engines/saga2/modal.cpp
@@ -81,10 +81,10 @@ bool ModalWindow::isModal(void) {
}
bool ModalWindow::open(void) {
- mouseInfo.replaceObject();
- mouseInfo.clearGauge();
- mouseInfo.setText(NULL);
- mouseInfo.setIntent(GrabInfo::WalkTo);
+ g_vm->_mouseInfo->replaceObject();
+ g_vm->_mouseInfo->clearGauge();
+ g_vm->_mouseInfo->setText(NULL);
+ g_vm->_mouseInfo->setIntent(GrabInfo::WalkTo);
prevModeStackCtr = GameMode::getStack(prevModeStackPtr);
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 1b672a3805..320d0c869d 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -1248,8 +1248,8 @@ void GameObject::deleteObject(void) {
unstack();
- if (mouseInfo.getObject() == this)
- mouseInfo.replaceObject();
+ if (g_vm->_mouseInfo->getObject() == this)
+ g_vm->_mouseInfo->replaceObject();
if (pickedObject == thisID())
pickedObject = Nothing;
@@ -4342,12 +4342,12 @@ APPFUNC(cmdBrain) {
}
} else if (ev.eventType == gEventMouseMove) {
if (ev.value == gCompImage::leave) {
- mouseInfo.setText(nullptr);
+ g_vm->_mouseInfo->setText(nullptr);
} else { //if (ev.value == gCompImage::enter)
// set the text in the cursor
- if (part == 0) mouseInfo.setText(IDEAS_INVENT);
- else if (part == 1) mouseInfo.setText(SPELL_INVENT);
- else mouseInfo.setText(SKILL_INVENT);
+ if (part == 0) g_vm->_mouseInfo->setText(IDEAS_INVENT);
+ else if (part == 1) g_vm->_mouseInfo->setText(SPELL_INVENT);
+ else g_vm->_mouseInfo->setText(SKILL_INVENT);
}
}
}
diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp
index c8fdd61bc9..14c118ad1f 100644
--- a/engines/saga2/objproto.cpp
+++ b/engines/saga2/objproto.cpp
@@ -305,7 +305,7 @@ bool ProtoObj::closeAction(ObjectID, ObjectID) {
// Take this object
bool ProtoObj::take(ObjectID dObj, ObjectID enactor, int16 num) {
assert(dObj != Nothing);
- assert(mouseInfo.getObjectId() == Nothing);
+ assert(g_vm->_mouseInfo->getObjectId() == Nothing);
// >>> this needs to be dynamic!
if (mass > 200 || bulk > 200) return false;
@@ -1011,7 +1011,7 @@ uint16 InventoryProto::containmentSet(void) {
}
bool InventoryProto::takeAction(ObjectID dObj, ObjectID enactor, int16 num) {
- mouseInfo.copyObject(dObj, GrabInfo::Drop, num);
+ g_vm->_mouseInfo->copyObject(dObj, GrabInfo::Drop, num);
return true;
}
@@ -1438,8 +1438,8 @@ uint16 PhysicalContainerProto::bulkCapacity(GameObject *) {
// Put key into mouse with intention to use
bool KeyProto::setUseCursor(ObjectID dObj) {
- assert(mouseInfo.getObjectId() == Nothing);
- mouseInfo.copyObject(GameObject::objectAddress(dObj), GrabInfo::Use);
+ assert(g_vm->_mouseInfo->getObjectId() == Nothing);
+ g_vm->_mouseInfo->copyObject(GameObject::objectAddress(dObj), GrabInfo::Use);
return true;
}
@@ -2411,8 +2411,8 @@ uint8 ShieldProto::getDamageSound(const ObjectSoundFXs &soundFXs) {
// Put tool into mouse with intention to use
bool ToolProto::setUseCursor(ObjectID dObj) {
- assert(mouseInfo.getObjectId() == Nothing);
- mouseInfo.copyObject(GameObject::objectAddress(dObj), GrabInfo::Use);
+ assert(g_vm->_mouseInfo->getObjectId() == Nothing);
+ g_vm->_mouseInfo->copyObject(GameObject::objectAddress(dObj), GrabInfo::Use);
return true;
}
@@ -2492,14 +2492,14 @@ bool IntangibleObjProto::useAction(ObjectID dObj, ObjectID enactor) {
bool IntangibleObjProto::takeAction(ObjectID dObj, ObjectID enactor, int16) {
assert(isObject(dObj));
- assert(mouseInfo.getObjectId() == Nothing);
+ assert(g_vm->_mouseInfo->getObjectId() == Nothing);
GameObject *dObjPtr = GameObject::objectAddress(dObj);
if (dObjPtr->isTrueSkill())
return false;
- mouseInfo.copyObject(dObj);
+ g_vm->_mouseInfo->copyObject(dObj);
return true;
}
@@ -2641,7 +2641,7 @@ bool SkillProto::useAction(ObjectID dObj, ObjectID enactor) {
Actor *attackerPtr = (Actor *) GameObject::objectAddress(enactor);
return castUntargetedSpell(attackerPtr, this);
}
- mouseInfo.copyObject(dObj, GrabInfo::Use);
+ g_vm->_mouseInfo->copyObject(dObj, GrabInfo::Use);
return true;
}
diff --git a/engines/saga2/playmode.cpp b/engines/saga2/playmode.cpp
index 3dc5c97299..17801d1117 100644
--- a/engines/saga2/playmode.cpp
+++ b/engines/saga2/playmode.cpp
@@ -239,7 +239,8 @@ void PlayModeSetup(void) {
// Set up mouse cursor
- mouseInfo.setIntent(GrabInfo::WalkTo);
+ g_vm->_mouseInfo = new GrabInfo;
+ g_vm->_mouseInfo->setIntent(GrabInfo::WalkTo);
// Start by displaying first frame stright off, no delay
frameAlarm.set(0);
@@ -274,6 +275,7 @@ void PlayModeCleanup(void) {
delete MassWeightIndicator;
delete HealthIndicator;
+ delete g_vm->_mouseInfo;
// dallocate compressed button images
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index c1ae34e31c..23c147e66d 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -53,6 +53,7 @@ Saga2Engine::Saga2Engine(OSystem *syst)
g_vm = this;
_bandList = nullptr;
+ _mouseInfo = nullptr;
_smkDecoder = nullptr;
_videoX = _videoY = 0;
_loadedWeapons = 0;
diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h
index d31bed48ce..940cb4ddad 100644
--- a/engines/saga2/saga2.h
+++ b/engines/saga2/saga2.h
@@ -46,6 +46,7 @@ class BandList;
class ActorAppearance;
class PathRequest;
class MotionTask;
+class GrabInfo;
enum {
kDebugResources = 1 << 0,
@@ -101,6 +102,7 @@ public:
Common::List<PathRequest *> _pathQueue;
Common::List<MotionTask *>::iterator _nextMT;
BandList *_bandList;
+ GrabInfo *_mouseInfo;
gDisplayPort _mainPort;
diff --git a/engines/saga2/speech.cpp b/engines/saga2/speech.cpp
index 00ef910cc7..eee2d260c5 100644
--- a/engines/saga2/speech.cpp
+++ b/engines/saga2/speech.cpp
@@ -409,8 +409,8 @@ bool Speech::setupActive(void) {
if (speechButtonCount > 0) {
// REM: Also set pointer to arrow shape.
- mouseInfo.setIntent(GrabInfo::WalkTo);
-// mouseInfo.setDoable( tileRect.ptInside( ev.mouse ) );
+ g_vm->_mouseInfo->setIntent(GrabInfo::WalkTo);
+// g_vm->_mouseInfo->setDoable( tileRect.ptInside( ev.mouse ) );
speakButtonControls->enable(true);
speechList.SetLock(false);
@@ -1135,7 +1135,7 @@ APPFUNC(cmdClickSpeech) {
case gEventMouseMove:
case gEventMouseDrag:
- mouseInfo.setDoable(tileRect.ptInside(ev.mouse));
+ g_vm->_mouseInfo->setDoable(tileRect.ptInside(ev.mouse));
break;
case gEventMouseDown:
diff --git a/engines/saga2/tilemode.cpp b/engines/saga2/tilemode.cpp
index edccba5937..b16a833d36 100644
--- a/engines/saga2/tilemode.cpp
+++ b/engines/saga2/tilemode.cpp
@@ -424,24 +424,24 @@ static void evalMouseState(void) {
Actor *a = getCenterActor();
bool interruptable = a->isInterruptable();
- mouseInfo.setDoable(interruptable);
+ g_vm->_mouseInfo->setDoable(interruptable);
- if (mouseInfo.getObject() != NULL) {
- GameObject *mObj = mouseInfo.getObject();
+ if (g_vm->_mouseInfo->getObject() != NULL) {
+ GameObject *mObj = g_vm->_mouseInfo->getObject();
// If the mouse pointer has an object and the intention
// is set to use, modify the doable setting depending
// on wether the mouse is pointing at another object
// and if so, wether the other object is within the
// use range of the center actor
- if (mouseInfo.getIntent() == GrabInfo::Use) {
+ if (g_vm->_mouseInfo->getIntent() == GrabInfo::Use) {
assert(obj != NULL);
if (mObj->containmentSet() & (ProtoObj::isSkill | ProtoObj::isSpell)) {
GameObject *tob = pickedObject != Nothing ? obj : NULL;
// If it's a spell we need to do more complex testing
// to see if the current target is valid
- mouseInfo.setDoable(
+ g_vm->_mouseInfo->setDoable(
interruptable
&& validTarget(
a,
@@ -450,7 +450,7 @@ static void evalMouseState(void) {
(SkillProto *)GameObject::protoAddress(
mObj->thisID())));
} else {
- mouseInfo.setDoable(
+ g_vm->_mouseInfo->setDoable(
interruptable
&& (pickedObject == Nothing
|| (a->inUseRange(
@@ -478,9 +478,9 @@ static void evalMouseState(void) {
if (a->inAttackRange(obj->getLocation())
&& (a->inRange(obj->getLocation(), 8)
|| lineOfSight(a, obj, terrainTransparent)))
- mouseInfo.setIntent(GrabInfo::Attack);
+ g_vm->_mouseInfo->setIntent(GrabInfo::Attack);
else {
- mouseInfo.setIntent(GrabInfo::WalkTo);
+ g_vm->_mouseInfo->setIntent(GrabInfo::WalkTo);
walkToPos = obj->getLocation();
}
} else
@@ -491,7 +491,7 @@ static void evalMouseState(void) {
// finished can initiate a new action, if so, set
// the intention to walk to the mouse pointer
if (interruptable) {
- mouseInfo.setIntent(GrabInfo::WalkTo);
+ g_vm->_mouseInfo->setIntent(GrabInfo::WalkTo);
if (tileMapControl->isSticky())
setMouseImage(kMouseAutoWalkImage, -8, -8);
walkToPos = tilePickPos;
@@ -502,7 +502,7 @@ static void evalMouseState(void) {
{
// Set the intention to walk to the mouse
// pointer
- mouseInfo.setIntent(GrabInfo::WalkTo);
+ g_vm->_mouseInfo->setIntent(GrabInfo::WalkTo);
if (tileMapControl->isSticky())
setMouseImage(kMouseAutoWalkImage, -8, -8);
walkToPos = tilePickPos;
@@ -522,10 +522,10 @@ static void evalMouseState(void) {
if (a->inAttackRange(obj->getLocation())
&& (a->inRange(obj->getLocation(), 8)
|| lineOfSight(a, obj, terrainTransparent))) {
- mouseInfo.setIntent(GrabInfo::Attack);
- mouseInfo.setDoable(true);
+ g_vm->_mouseInfo->setIntent(GrabInfo::Attack);
+ g_vm->_mouseInfo->setDoable(true);
} else {
- mouseInfo.setIntent(GrabInfo::WalkTo);
+ g_vm->_mouseInfo->setIntent(GrabInfo::WalkTo);
walkToPos = obj->getLocation();
}
} else
@@ -537,16 +537,16 @@ static void evalMouseState(void) {
if (isActor(pickedObject)) {
a = (Actor *)obj;
- mouseInfo.setIntent(
+ g_vm->_mouseInfo->setIntent(
!a->isDead()
? GrabInfo::WalkTo
: GrabInfo::Open);
walkToPos = obj->getLocation();
} else {
- mouseInfo.setIntent(obj->isCarryable()
+ g_vm->_mouseInfo->setIntent(obj->isCarryable()
? GrabInfo::PickUp
: GrabInfo::Open);
- mouseInfo.setDoable(
+ g_vm->_mouseInfo->setDoable(
interruptable
&& a->inReach(obj->getLocation())
&& (a->inRange(obj->getLocation(), 8)
@@ -558,7 +558,7 @@ static void evalMouseState(void) {
{
// Simply set the intention to walk to the mouse
// pointer
- mouseInfo.setIntent(GrabInfo::WalkTo);
+ g_vm->_mouseInfo->setIntent(GrabInfo::WalkTo);
if (tileMapControl->isSticky())
setMouseImage(kMouseAutoWalkImage, -8, -8);
walkToPos = tilePickPos;
@@ -568,14 +568,14 @@ static void evalMouseState(void) {
if (mousePressed
&& !clickActionDone
- && mouseInfo.getObject() == NULL) {
+ && g_vm->_mouseInfo->getObject() == NULL) {
a = getCenterActor();
// Since the mouse is being dragged, initiate
// the effects of the mouse drag
- if (mouseInfo.getIntent() == GrabInfo::WalkTo) {
- if (mouseInfo.getDoable()
+ if (g_vm->_mouseInfo->getIntent() == GrabInfo::WalkTo) {
+ if (g_vm->_mouseInfo->getDoable()
&& !navigationDelayed) {
MotionTask *mt = a->moveTask;
@@ -588,8 +588,8 @@ static void evalMouseState(void) {
updateAlarm.set(ticksPerSecond / 2);
}
}
- } else if (mouseInfo.getIntent() == GrabInfo::Attack) {
- if (mouseInfo.getDoable())
+ } else if (g_vm->_mouseInfo->getIntent() == GrabInfo::Attack) {
+ if (g_vm->_mouseInfo->getDoable())
a->attack(GameObject::objectAddress(pickedObject));
}
}
@@ -778,7 +778,7 @@ void TileModeHandleTask(void) {
if (ContainerView::objTextAlarm == true) {
// if the mouse is in a container...
if (ContainerView::mouseInView) {
- mouseInfo.setText(ContainerView::mouseText);
+ g_vm->_mouseInfo->setText(ContainerView::mouseText);
}
}
@@ -827,8 +827,8 @@ void TileModeHandleTask(void) {
lastPickedObject = pickedObject;
// Remove current mouse cursor text and gauge
- mouseInfo.setText(NULL);
- mouseInfo.clearGauge();
+ g_vm->_mouseInfo->setText(NULL);
+ g_vm->_mouseInfo->clearGauge();
// If mouse in on object set alarm to determine when
// to display the object's name
@@ -846,12 +846,12 @@ void TileModeHandleTask(void) {
// get the object text into the buffer
item->objCursorText(cursorText, bufSize);
- mouseInfo.setText(cursorText);
+ g_vm->_mouseInfo->setText(cursorText);
if (isActor(pickedObject)) {
a = (Actor *)GameObject::objectAddress(pickedObject);
- mouseInfo.setGauge(a->getStats()->vitality, a->getBaseStats()->vitality);
+ g_vm->_mouseInfo->setGauge(a->getStats()->vitality, a->getBaseStats()->vitality);
} else {
- mouseInfo.clearGauge();
+ g_vm->_mouseInfo->clearGauge();
}
}
}
@@ -1060,14 +1060,14 @@ static APPFUNC(cmdClickTileMap) {
if (ev.value & gGenericControl::leave) {
mousePressed = false;
- if (mouseInfo.getObject() == NULL)
- mouseInfo.setIntent(GrabInfo::WalkTo);
- mouseInfo.setDoable(true);
+ if (g_vm->_mouseInfo->getObject() == NULL)
+ g_vm->_mouseInfo->setIntent(GrabInfo::WalkTo);
+ g_vm->_mouseInfo->setDoable(true);
// Remove any mouse text
lastPickedObject = Nothing;
- mouseInfo.setText(NULL);
- mouseInfo.clearGauge();
+ g_vm->_mouseInfo->setText(NULL);
+ g_vm->_mouseInfo->clearGauge();
}
lastMousePos = ev.mouse;
break;
@@ -1085,7 +1085,7 @@ static APPFUNC(cmdClickTileMap) {
Actor *centerActorPtr =
(Actor *)GameObject::objectAddress(centerActorID);
- if ((mouseObject = mouseInfo.getObject()) != NULL) {
+ if ((mouseObject = g_vm->_mouseInfo->getObject()) != NULL) {
// If we are using an intangible object (spell) then consider
// the owner of the spell to be the center actor for the rest
// of this action.
@@ -1100,10 +1100,10 @@ static APPFUNC(cmdClickTileMap) {
if (pickedObject != Nothing) {
// we dropped the object onto another object
- if (mouseInfo.getDoable()) {
- int16 intent = mouseInfo.getIntent();
+ if (g_vm->_mouseInfo->getDoable()) {
+ int16 intent = g_vm->_mouseInfo->getIntent();
- mouseInfo.replaceObject();
+ g_vm->_mouseInfo->replaceObject();
if (intent == GrabInfo::Use) {
MotionTask::useObjectOnObject(
*centerActorPtr,
@@ -1114,24 +1114,24 @@ static APPFUNC(cmdClickTileMap) {
*centerActorPtr,
*mouseObject,
*GameObject::objectAddress(pickedObject),
- mouseInfo.getMoveCount());
+ g_vm->_mouseInfo->getMoveCount());
}
((gGenericControl *)ev.panel)->disableDblClick();
clickActionDone = true;
- } else if (mouseInfo.getIntent() == GrabInfo::Use) {
- mouseInfo.replaceObject();
+ } else if (g_vm->_mouseInfo->getIntent() == GrabInfo::Use) {
+ g_vm->_mouseInfo->replaceObject();
clickActionDone = true;
}
} else if (pickedTAI != NULL) {
// we dropped the object onto active terrain
- if (mouseInfo.getDoable()) {
- if (mouseInfo.getIntent() == GrabInfo::Drop
- || mouseInfo.getIntent() == GrabInfo::Use) {
- int16 intent = mouseInfo.getIntent();
+ if (g_vm->_mouseInfo->getDoable()) {
+ if (g_vm->_mouseInfo->getIntent() == GrabInfo::Drop
+ || g_vm->_mouseInfo->getIntent() == GrabInfo::Use) {
+ int16 intent = g_vm->_mouseInfo->getIntent();
- mouseInfo.replaceObject();
+ g_vm->_mouseInfo->replaceObject();
if (intent == GrabInfo::Drop) {
MotionTask::dropObjectOnTAI(
*centerActorPtr,
@@ -1158,49 +1158,49 @@ static APPFUNC(cmdClickTileMap) {
((gGenericControl *)ev.panel)->disableDblClick();
clickActionDone = true;
}
- } else if (mouseInfo.getIntent() == GrabInfo::Use) {
- mouseInfo.replaceObject();
+ } else if (g_vm->_mouseInfo->getIntent() == GrabInfo::Use) {
+ g_vm->_mouseInfo->replaceObject();
clickActionDone = true;
}
} else if (pickedObject == Nothing) {
// we dropped the object on the ground
- if (mouseInfo.getIntent() == GrabInfo::Drop
- && mouseInfo.getDoable()) {
- mouseInfo.replaceObject();
+ if (g_vm->_mouseInfo->getIntent() == GrabInfo::Drop
+ && g_vm->_mouseInfo->getDoable()) {
+ g_vm->_mouseInfo->replaceObject();
MotionTask::dropObject(
*centerActorPtr,
*mouseObject,
Location(tilePickPos, currentWorld->thisID()),
- mouseInfo.getMoveCount());
+ g_vm->_mouseInfo->getMoveCount());
((gGenericControl *)ev.panel)->disableDblClick();
clickActionDone = true;
- } else if (mouseInfo.getIntent() == GrabInfo::Use
- && mouseInfo.getDoable()) {
+ } else if (g_vm->_mouseInfo->getIntent() == GrabInfo::Use
+ && g_vm->_mouseInfo->getDoable()) {
// New for spells - this enables objects to be used on a
// general location (for area spells etc)
- mouseInfo.replaceObject();
+ g_vm->_mouseInfo->replaceObject();
MotionTask::useObjectOnLocation(
*centerActorPtr,
*mouseObject,
Location(tilePickPos, currentWorld->thisID()));
clickActionDone = true;
- } else if (mouseInfo.getIntent() == GrabInfo::Use) {
- mouseInfo.replaceObject();
+ } else if (g_vm->_mouseInfo->getIntent() == GrabInfo::Use) {
+ g_vm->_mouseInfo->replaceObject();
clickActionDone = true;
}
}
} else if (pickedObject != Nothing) {
//GameObject *obj = GameObject::objectAddress(pickedObject);
- if (mouseInfo.getDoable()) {
+ if (g_vm->_mouseInfo->getDoable()) {
PlayerActorID pID;
if (actorIDToPlayerID(pickedObject, pID) && !isBrotherDead(pID)) {
setCenterBrother(pID);
clickActionDone = true;
- } else if (mouseInfo.getIntent() == GrabInfo::PickUp
- || mouseInfo.getIntent() == GrabInfo::Open) {
+ } else if (g_vm->_mouseInfo->getIntent() == GrabInfo::PickUp
+ || g_vm->_mouseInfo->getIntent() == GrabInfo::Open) {
GameObject *pickedObjPtr =
GameObject::objectAddress(pickedObject);
int16 quantity = 1;
@@ -1214,7 +1214,7 @@ static APPFUNC(cmdClickTileMap) {
if (pickedObjPtr->take(centerActorID, quantity))
clickActionDone = true;
- } else if (mouseInfo.getIntent() == GrabInfo::Attack) {
+ } else if (g_vm->_mouseInfo->getIntent() == GrabInfo::Attack) {
centerActorPtr->attack(
GameObject::objectAddress(pickedObject));
((gGenericControl *)ev.panel)->disableDblClick();
@@ -1230,8 +1230,8 @@ static APPFUNC(cmdClickTileMap) {
// We're not pointing at an object and the mouse cursor
// does not have an object
else {
- if (mouseInfo.getIntent() == GrabInfo::WalkTo
- && mouseInfo.getDoable()) {
+ if (g_vm->_mouseInfo->getIntent() == GrabInfo::WalkTo
+ && g_vm->_mouseInfo->getDoable()) {
if (pickedTAI == NULL) {
navigateDirect(walkToPos, false);
// ( ( gGenericControl * )ev.panel )->disableDblClick();
@@ -1255,7 +1255,7 @@ static APPFUNC(cmdClickTileMap) {
dblClick = false;
else {
if (pathFindAlarm.check()) { // mouse click was too long for path find
- if (mouseInfo.getIntent() == GrabInfo::WalkTo) {
+ if (g_vm->_mouseInfo->getIntent() == GrabInfo::WalkTo) {
Actor *a = getCenterActor();
if (a->moveTask && a->moveTask->isWalk())
@@ -1285,13 +1285,13 @@ static APPFUNC(cmdClickTileMap) {
navigationDelayed = false;
- if ((mouseObject = mouseInfo.getObject()) != NULL) {
- mouseInfo.replaceObject();
+ if ((mouseObject = g_vm->_mouseInfo->getObject()) != NULL) {
+ g_vm->_mouseInfo->replaceObject();
MotionTask::useObject(*getCenterActor(), *mouseObject);
} else if (pickedObject != Nothing) {
GameObject *obj = GameObject::objectAddress(pickedObject);
- if (mouseInfo.getDoable()) {
+ if (g_vm->_mouseInfo->getDoable()) {
// Double-click on an actor is the same as "greet".
if (isActor(pickedObject)
&& !((Actor *)obj)->isDead()
@@ -1299,8 +1299,8 @@ static APPFUNC(cmdClickTileMap) {
ActorProto *proto = (ActorProto *)obj->proto();
proto->greetActor(pickedObject, getCenterActorID());
- } else if (mouseInfo.getIntent() == GrabInfo::PickUp
- || mouseInfo.getIntent() == GrabInfo::Open
+ } else if (g_vm->_mouseInfo->getIntent() == GrabInfo::PickUp
+ || g_vm->_mouseInfo->getIntent() == GrabInfo::Open
|| (isActor(pickedObject) && ((Actor *)obj)->isDead())) {
GameObject *pickedObjPtr =
GameObject::objectAddress(pickedObject);
Commit: 30071b6046d37368d6cf291ba63e555189828d69
https://github.com/scummvm/scummvm/commit/30071b6046d37368d6cf291ba63e555189828d69
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:44+02:00
Commit Message:
SAGA2: Move ImageCache to Saga2Engine
Changed paths:
engines/saga2/contain.cpp
engines/saga2/floating.cpp
engines/saga2/imagcach.cpp
engines/saga2/imagcach.h
engines/saga2/intrface.cpp
engines/saga2/loadsave.cpp
engines/saga2/saga2.cpp
engines/saga2/saga2.h
diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index db12d008e5..121586e12e 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -1762,11 +1762,11 @@ void initContainers(void) {
if (containerRes == NULL)
containerRes = resFile->newContext(MKTAG('C', 'O', 'N', 'T'), "cont.resources");
- selImage = ImageCache.requestImage(imageRes, MKTAG('A', 'M', 'N', 'T'));
+ selImage = g_vm->_imageCache->requestImage(imageRes, MKTAG('A', 'M', 'N', 'T'));
}
void cleanupContainers(void) {
- if (selImage) ImageCache.releaseImage(selImage);
+ if (selImage) g_vm->_imageCache->releaseImage(selImage);
if (containerRes) resFile->disposeContext(containerRes);
selImage = NULL;
diff --git a/engines/saga2/floating.cpp b/engines/saga2/floating.cpp
index c9ae12e419..ba938df7bc 100644
--- a/engines/saga2/floating.cpp
+++ b/engines/saga2/floating.cpp
@@ -132,7 +132,7 @@ void DecoratedWindow::setDecorations(
for (i = 0; i < numDecorations; i++, dec++) {
// request an image pointer from the image Cache
- dec->image = ImageCache.requestImage(con,
+ dec->image = g_vm->_imageCache->requestImage(con,
MKTAG('B', 'R', 'D', dec->imageNumber));
decorations[i].extent = dec->extent;
decorations[i].image = dec->image;
@@ -158,7 +158,7 @@ void DecoratedWindow::setDecorations(
for (i = 0; i < numDecorations; i++, dec++) {
// request an image pointer from the image Cache
- dec->image = ImageCache.requestImage(con, id_ | MKTAG(0, 0, 0, dec->imageNumber));
+ dec->image = g_vm->_imageCache->requestImage(con, id_ | MKTAG(0, 0, 0, dec->imageNumber));
decorations[i].extent = dec->extent;
decorations[i].image = dec->image;
decorations[i].imageNumber = dec->imageNumber;
@@ -190,7 +190,7 @@ void DecoratedWindow::setDecorations(
for (i = 0; i < numDecorations; i++, dec++) {
// request an image pointer from the image Cache
- dec->image = ImageCache.requestImage(con,
+ dec->image = g_vm->_imageCache->requestImage(con,
MKTAG('B', 'R', 'D', dec->imageNumber));
decorations[i].extent = dec->extent;
decorations[i].image = dec->image;
@@ -216,7 +216,7 @@ void DecoratedWindow::setDecorations(
for (i = 0; i < numDecorations; i++, dec++) {
// request an image pointer from the image Cache
- dec->image = ImageCache.requestImage(con, id_ | MKTAG(0, 0, 0, dec->imageNumber));
+ dec->image = g_vm->_imageCache->requestImage(con, id_ | MKTAG(0, 0, 0, dec->imageNumber));
decorations[i].extent = dec->extent;
decorations[i].image = dec->image;
decorations[i].imageNumber = dec->imageNumber;
@@ -239,7 +239,7 @@ void DecoratedWindow::removeDecorations(void) {
// release requests made to the Image Cache
for (dec = decorations, i = 0; i < numDecorations; i++, dec++) {
- ImageCache.releaseImage(dec->image);
+ g_vm->_imageCache->releaseImage(dec->image);
}
if (decorations)
diff --git a/engines/saga2/imagcach.cpp b/engines/saga2/imagcach.cpp
index ec87e633bf..d428b8cca5 100644
--- a/engines/saga2/imagcach.cpp
+++ b/engines/saga2/imagcach.cpp
@@ -36,6 +36,14 @@ namespace Saga2 {
extern char *idname(long s);
#endif
+void initImageCache() {
+ g_vm->_imageCache = new CImageCache;
+}
+
+void cleanupImageCache() {
+ delete g_vm->_imageCache;
+}
+
CImageNode::CImageNode(hResContext *con, uint32 resID) {
if (con) {
#if DEBUG
@@ -184,7 +192,4 @@ void *CImageCache::requestImage(hResContext *con, uint32 resID) {
return imageNode->getImagePtr();
}
-// global declarations
-CImageCache ImageCache;
-
} // end of namespace Saga2
diff --git a/engines/saga2/imagcach.h b/engines/saga2/imagcach.h
index 2b880e924c..7aa00a670a 100644
--- a/engines/saga2/imagcach.h
+++ b/engines/saga2/imagcach.h
@@ -29,6 +29,9 @@
namespace Saga2 {
+void initImageCache(void);
+void cleanupImageCache(void);
+
/* ===================================================================== *
ImageNode class which defines a re-entrant image resource
* ===================================================================== */
@@ -73,10 +76,6 @@ public:
void releaseImage(void *);
};
-
-// global declarations
-extern CImageCache ImageCache;
-
} // end of namespace Saga2
#endif
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index 22dc7a56d7..5f080a3ea7 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -811,12 +811,12 @@ CMassWeightIndicator::CMassWeightIndicator(gPanelList *panel, const Point16 &pos
// setup mass/bulk indicator imagery
if (death) {
- massBulkImag = ImageCache.requestImage(containerRes, MKTAG('D', 'J', 'B', massBulkResNum));
+ massBulkImag = g_vm->_imageCache->requestImage(containerRes, MKTAG('D', 'J', 'B', massBulkResNum));
pieIndImag = loadImageRes(containerRes, pieIndResNum, numPieIndImages, 'D', 'A', 'J');
} else {
- massBulkImag = ImageCache.requestImage(containerRes, MKTAG('G', 'J', 'B', massBulkResNum));
+ massBulkImag = g_vm->_imageCache->requestImage(containerRes, MKTAG('G', 'J', 'B', massBulkResNum));
pieIndImag = loadImageRes(containerRes, pieIndResNum, numPieIndImages, 'G', 'A', 'J');
}
@@ -869,7 +869,7 @@ CMassWeightIndicator::~CMassWeightIndicator(void) {
indList.remove(this);
unloadImageRes(pieIndImag, numPieIndImages);
- ImageCache.releaseImage(massBulkImag);
+ g_vm->_imageCache->releaseImage(massBulkImag);
}
/*****************************************************************************
@@ -948,9 +948,9 @@ CManaIndicator::CManaIndicator(gPanelList &list) : gCompImage(list,
// load in the ring images
ringImages = loadImageRes(resContext, ringResNum, numRings, 'R', 'N', 'G');
- backImage = ImageCache.requestImage(resContext, MKTAG('B', 'A', 'C', 'K'));
+ backImage = g_vm->_imageCache->requestImage(resContext, MKTAG('B', 'A', 'C', 'K'));
- wellImage = ImageCache.requestImage(resContext, MKTAG('W', 'E', 'L', 'L'));
+ wellImage = g_vm->_imageCache->requestImage(resContext, MKTAG('W', 'E', 'L', 'L'));
// hmm this could be cleaner...
starRingEndPos[0] = Point16(redEndX, redEndY);
@@ -998,8 +998,8 @@ CManaIndicator::~CManaIndicator(void) {
unloadImageRes(ringImages, numRings);
// release back image
- ImageCache.releaseImage(backImage);
- ImageCache.releaseImage(wellImage);
+ g_vm->_imageCache->releaseImage(backImage);
+ g_vm->_imageCache->releaseImage(wellImage);
// release the saved map
if (savedMap.data)
@@ -1321,7 +1321,7 @@ CHealthIndicator::CHealthIndicator(AppFunc *cmd) {
starImag = loadButtonRes(healthRes, starStart, starNum, 'S', 'T', 'A');
// load in the health star border
- starFrameImag = ImageCache.requestImage(healthRes, MKTAG('B', 'T', 'N', starFrameResNum));
+ starFrameImag = g_vm->_imageCache->requestImage(healthRes, MKTAG('B', 'T', 'N', starFrameResNum));
// set the image indexes to nominal startup values
for (i = 0; i < numControls + 1; i++) {
@@ -1397,7 +1397,7 @@ CHealthIndicator::~CHealthIndicator(void) {
unloadImageRes(starImag, starNum);
// release star frame imagery
- ImageCache.releaseImage(starFrameImag);
+ g_vm->_imageCache->releaseImage(starFrameImag);
}
// Recalculate and update the health star for a particular brother
@@ -1578,7 +1578,7 @@ void **loadButtonRes(hResContext *con, int16 resID, int16 numRes) {
for (i = 0, k = resID; i < numRes; i++, k++) {
// get an image from the image cache
- images[i] = ImageCache.requestImage(con, MKTAG('B', 'T', 'N', k));
+ images[i] = g_vm->_imageCache->requestImage(con, MKTAG('B', 'T', 'N', k));
}
return images;
@@ -1594,7 +1594,7 @@ void **loadButtonRes(hResContext *con, int16 resID, int16 numRes, char a, char b
void **images = (void **)malloc(sizeof(void *)*numRes);
for (i = 0, k = resID; i < numRes; i++, k++) {
- images[i] = ImageCache.requestImage(con, MKTAG(a, b, c, k));
+ images[i] = g_vm->_imageCache->requestImage(con, MKTAG(a, b, c, k));
}
return images;
@@ -1612,7 +1612,7 @@ void unloadImageRes(void **images, int16 numRes) {
if (images) {
for (i = 0; i < numRes; i++) {
- ImageCache.releaseImage(images[i]);
+ g_vm->_imageCache->releaseImage(images[i]);
}
free(images);
@@ -1655,17 +1655,17 @@ void SetupUserControls(void) {
julBtnImag = loadButtonRes(imageRes, julBtnResNum, numBtnImages);
phiBtnImag = loadButtonRes(imageRes, phiBtnResNum, numBtnImages);
kevBtnImag = loadButtonRes(imageRes, kevBtnResNum, numBtnImages);
- broBtnFrameImag = ImageCache.requestImage(imageRes, MKTAG('F', 'R', 'A', 'M'));
+ broBtnFrameImag = g_vm->_imageCache->requestImage(imageRes, MKTAG('F', 'R', 'A', 'M'));
// set up the portrait name plates
for (n = 0; n < kNumViews; n++) {
- namePlateImages[n] = ImageCache.requestImage(imageRes, MKTAG('B', 'T', 'N', namePlateResNum[n]));
+ namePlateImages[n] = g_vm->_imageCache->requestImage(imageRes, MKTAG('B', 'T', 'N', namePlateResNum[n]));
}
// get the frame image
- namePlateFrameImag = ImageCache.requestImage(imageRes, MKTAG('B', 'T', 'N', 15));
- armorImag = ImageCache.requestImage(imageRes, MKTAG('B', 'T', 'N', 34));
+ namePlateFrameImag = g_vm->_imageCache->requestImage(imageRes, MKTAG('B', 'T', 'N', 15));
+ armorImag = g_vm->_imageCache->requestImage(imageRes, MKTAG('B', 'T', 'N', 34));
// clean out the old context
if (imageRes) resFile->disposeContext(imageRes);
@@ -1824,15 +1824,15 @@ void CleanupButtonImages(void) {
}
// name plate frame
- ImageCache.releaseImage(namePlateFrameImag);
- ImageCache.releaseImage(armorImag);
+ g_vm->_imageCache->releaseImage(namePlateFrameImag);
+ g_vm->_imageCache->releaseImage(armorImag);
// release name frames
- ImageCache.releaseImage(broBtnFrameImag);
+ g_vm->_imageCache->releaseImage(broBtnFrameImag);
// name plates
for (i = 0; i < kNumViews; i++) {
- ImageCache.releaseImage(namePlateImages[i]);
+ g_vm->_imageCache->releaseImage(namePlateImages[i]);
}
}
diff --git a/engines/saga2/loadsave.cpp b/engines/saga2/loadsave.cpp
index bad6e31dde..a835fb22ac 100644
--- a/engines/saga2/loadsave.cpp
+++ b/engines/saga2/loadsave.cpp
@@ -45,6 +45,7 @@
#include "saga2/vpal.h"
#include "saga2/palette.h"
#include "saga2/contain.h"
+#include "saga2/imagcach.h"
namespace Saga2 {
@@ -91,6 +92,7 @@ void initGameState(void) {
pauseTimer();
initGlobals();
+ initImageCache();
initTimer();
initAudio();
initCalender();
@@ -484,6 +486,7 @@ void cleanupGameState(void) {
cleanupWorlds();
cleanupAudio();
cleanupTimer();
+ cleanupImageCache();
cleanupGlobals();
}
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index 23c147e66d..965273c9b1 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -53,6 +53,7 @@ Saga2Engine::Saga2Engine(OSystem *syst)
g_vm = this;
_bandList = nullptr;
+ _imageCache = nullptr;
_mouseInfo = nullptr;
_smkDecoder = nullptr;
_videoX = _videoY = 0;
diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h
index 940cb4ddad..14c04454aa 100644
--- a/engines/saga2/saga2.h
+++ b/engines/saga2/saga2.h
@@ -47,6 +47,7 @@ class ActorAppearance;
class PathRequest;
class MotionTask;
class GrabInfo;
+class CImageCache;
enum {
kDebugResources = 1 << 0,
@@ -102,6 +103,7 @@ public:
Common::List<PathRequest *> _pathQueue;
Common::List<MotionTask *>::iterator _nextMT;
BandList *_bandList;
+ CImageCache *_imageCache;
GrabInfo *_mouseInfo;
gDisplayPort _mainPort;
Commit: b0031f51bb463d0c0d9a2c9e6610b37035ec176d
https://github.com/scummvm/scummvm/commit/b0031f51bb463d0c0d9a2c9e6610b37035ec176d
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:44+02:00
Commit Message:
SAGA2: Fix some global constructor warnings
Changed paths:
engines/saga2/contain.cpp
engines/saga2/contain.h
diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index 121586e12e..0b932ab963 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -114,22 +114,20 @@ ContainerList globalContainerList;
//-----------------------------------------------------------------------
// Physical container appearance
-ContainerAppearanceDef physicalContainerAppearance(
- Rect16(250, 60, 268, 304 + 16), // Default window position
- Rect16(17 + 4, 87, 268 - 2, 304 - 87), // view rectangle
- Rect16(13 + 8, 37, 44, 42), // close button rectangle
- Rect16(13 + 8 + 44, 37, 44, 42), // scroll button rectangle
- Rect16(13 + 118, 50, 36, 36), // icon rectangle
- Rect16(13 + 139, 37, 88, 43), // massBulk rectangle
- MKTAG('P', 'C', 'L', 0), // CloseBox normal image
- MKTAG('P', 'C', 'L', 1), // CloseBox selected image
- MKTAG('P', 'S', 'L', 0), // Scroll button normal image
- MKTAG('P', 'S', 'L', 1), // Scroll button selected image
- Point16(13, 8), // Icon origin
- Point16(22, 22), // Icon spacing
- 0, 0, // Visible rows and columns (filled in later)
- 0 // Total rows
-);
+static ContainerAppearanceDef physicalContainerAppearance = {
+ {250, 60, 268, 304 + 16},
+ {17 + 4, 87, 268 - 2, 304 - 87},
+ {13 + 8, 37, 44, 42},
+ {13 + 8 + 44, 37, 44, 42},
+ {13 + 118, 50, 36, 36},
+ {13 + 139, 37, 88, 43},
+ { MKTAG('P', 'C', 'L', 0), MKTAG('P', 'C', 'L', 1) },
+ { MKTAG('P', 'S', 'L', 0), MKTAG('P', 'S', 'L', 1) },
+ {13, 8},
+ {22, 22},
+ 0, 0,
+ 0
+};
static StaticWindow brassDecorations[] = {
{{0, 0, 268, 86}, nullptr, 3},
@@ -158,22 +156,20 @@ static StaticWindow woodDecorations[] = {
//-----------------------------------------------------------------------
// Death container appearance
-ContainerAppearanceDef deathContainerAppearance(
- Rect16(260, 60, 206, 250), // Default window position
- Rect16(2, 87, 206 - 22, 250 - 87 - 32), // view rectangle
- Rect16(16, 24, 44, 42), // close button rectangle
- Rect16(120 + 18, 24, 44, 42), // scroll button rectangle
- Rect16(0, 0, 0, 0), // icon rectangle
- Rect16(0, 0, 0, 0), // massBulk rectangle
- MKTAG('D', 'C', 'L', 0), // CloseBox normal image
- MKTAG('D', 'C', 'L', 1), // CloseBox selected image
- MKTAG('D', 'S', 'L', 0), // Scroll button normal image
- MKTAG('D', 'S', 'L', 1), // Scroll button selected image
- Point16(27, -4), // Icon origin
- Point16(22, 22), // Icon spacing
- 0, 0, // Visible rows and columns (filled in later)
- 0 // Total rows
-);
+ContainerAppearanceDef deathContainerAppearance = {
+ {260, 60, 206, 250},
+ {2, 87, 206 - 22, 250 - 87 - 32},
+ {16, 24, 44, 42},
+ {120 + 18, 24, 44, 42},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
+ { MKTAG('D', 'C', 'L', 0), MKTAG('D', 'C', 'L', 1) },
+ { MKTAG('D', 'S', 'L', 0), MKTAG('D', 'S', 'L', 1) },
+ {27, -4},
+ {22, 22},
+ 0, 0,
+ 0
+};
// physal dialog window decorations
static StaticWindow deathDecorations[] = {
@@ -183,42 +179,38 @@ static StaticWindow deathDecorations[] = {
//-----------------------------------------------------------------------
// ReadyContainer appearance
-ContainerAppearanceDef readyContainerAppearance(
- Rect16(0, 0, 0, 0), // Default window position
- Rect16(476, 105, 0, 0), // view rectangle
- Rect16(0, 0, 0, 0), // close button rectangle
- Rect16(0, 0, 0, 0), // scroll button rectangle
- Rect16(0, 0, 0, 0), // icon rectangle
- Rect16(0, 0, 0, 0), // massBulk rectangle
- 0, // CloseBox normal image
- 0, // CloseBox selected image
- 0, // Scroll button normal image
- 0, // Scroll button selected image
- Point16(iconOriginX - 1, iconOriginY - 1 - 8), // Icon origin
- Point16(iconSpacingX, iconSpacingY), // Icon spacing
- 1, 3, // Visible rows and columns
- 3 // Total rows
-);
+ContainerAppearanceDef readyContainerAppearance = {
+ {0, 0, 0, 0},
+ {476, 105, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
+ { 0, 0 },
+ { 0, 0 },
+ {iconOriginX - 1, iconOriginY - 1 - 8},
+ {iconSpacingX, iconSpacingY},
+ 1, 3,
+ 3
+};
//-----------------------------------------------------------------------
// Mental Container appearance
-ContainerAppearanceDef mentalContainerAppearance(
- Rect16(478, 168 - 54, 158, 215), // Default window position
- Rect16(2, 86 - 18 - 4, 158 - 2, 215 - 66), // view rectangle
- Rect16(2, 19, 44, 44), // close button rectangle
- Rect16(103, 40 - 18 - 4, 44, 44), // scroll button rectangle
- Rect16(0, 0, 0, 0), // icon rectangle
- Rect16(0, 0, 0, 0), // massBulk rectangle
- MKTAG('C', 'L', 'S', 0), // CloseBox normal image
- MKTAG('C', 'L', 'S', 1), // CloseBox selected image
- MKTAG('S', 'E', 'L', 0), // Scroll button normal image
- MKTAG('S', 'E', 'L', 1), // Scroll button selected image
- Point16(3, 0), // Icon origin
- Point16(4, 4), // Icon spacing
- 4, 4, // Visible rows and columns
- 20 // Total rows
-);
+ContainerAppearanceDef mentalContainerAppearance = {
+ {478, 168 - 54, 158, 215},
+ {2, 86 - 18 - 4, 158 - 2, 215 - 66},
+ {2, 19, 44, 44},
+ {103, 40 - 18 - 4, 44, 44},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
+ { MKTAG('C', 'L', 'S', 0), MKTAG('C', 'L', 'S', 1) },
+ { MKTAG('S', 'E', 'L', 0), MKTAG('S', 'E', 'L', 1) },
+ {3, 0},
+ {4, 4},
+ 4, 4,
+ 20
+};
static StaticWindow mentalDecorations[] = {
{{0, 0, 158, 215}, nullptr, 0} // Bottom decoration panel
@@ -226,22 +218,20 @@ static StaticWindow mentalDecorations[] = {
//-----------------------------------------------------------------------
// Enchantment container appearance
-ContainerAppearanceDef enchantmentContainerAppearance(
- Rect16(262, 92, 116, 202), // Default window position
- Rect16(2, 87, 116 - 2, 202 - 87), // view rectangle
- Rect16(7, 50, 44, 43), // close button rectangle
- Rect16(57, 50, 44, 43), // scroll button rectangle
- Rect16(38, 7, 32, 32), // icon rectangle
- Rect16(0, 0, 0, 0), // massBulk rectangle
- MKTAG('A', 'A', 'A', 0), // CloseBox normal image
- MKTAG('A', 'A', 'A', 0), // CloseBox selected image
- MKTAG('A', 'A', 'A', 0), // Scroll button normal image
- MKTAG('A', 'A', 'A', 0), // Scroll button selected image
- Point16(12, 98), // Icon origin
- Point16(16, 13), // Icon spacing
- 2, 2, // Visible rows and columns
- 2 // Total rows
-);
+ContainerAppearanceDef enchantmentContainerAppearance = {
+ {262, 92, 116, 202},
+ {2, 87, 116 - 2, 202 - 87},
+ {7, 50, 44, 43},
+ {57, 50, 44, 43},
+ {38, 7, 32, 32},
+ {0, 0, 0, 0},
+ { MKTAG('A', 'A', 'A', 0), MKTAG('A', 'A', 'A', 0) },
+ { MKTAG('A', 'A', 'A', 0), MKTAG('A', 'A', 'A', 0) },
+ {12, 98},
+ {16, 13},
+ 2, 2,
+ 2
+};
//-----------------------------------------------------------------------
// ContainerView class
diff --git a/engines/saga2/contain.h b/engines/saga2/contain.h
index 39f4d02c13..9939f3632a 100644
--- a/engines/saga2/contain.h
+++ b/engines/saga2/contain.h
@@ -375,39 +375,6 @@ struct ContainerAppearanceDef {
uint16 rows,
cols,
totRows;
-
- ContainerAppearanceDef(
- Rect16 _defaultWindowPos,
- Rect16 _viewRect,
- Rect16 _closeRect,
- Rect16 _scrollRect,
- Rect16 _iconRect,
- Rect16 _massRect,
- hResID _closeResID_0,
- hResID _closeResID_1,
- hResID _scrollResID_0,
- hResID _scrollResID_1,
- Point16 _iconOrigin,
- Point16 _iconSpacing,
- uint16 _rows,
- uint16 _cols,
- uint16 _totRows)
- : defaultWindowPos(_defaultWindowPos),
- viewRect(_viewRect),
- closeRect(_closeRect),
- scrollRect(_scrollRect),
- iconRect(_iconRect),
- massRect(_massRect),
- iconOrigin(_iconOrigin),
- iconSpacing(_iconSpacing),
- rows(_rows),
- cols(_cols),
- totRows(_totRows) {
- closeResID[0] = _closeResID_0;
- closeResID[1] = _closeResID_1;
- scrollResID[0] = _scrollResID_0;
- scrollResID[1] = _scrollResID_1;
- }
};
/* ===================================================================== *
Commit: e5ebcd44b4d3ce9665ce3321343aaefa73f43ae6
https://github.com/scummvm/scummvm/commit/e5ebcd44b4d3ce9665ce3321343aaefa73f43ae6
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-01T01:37:44+02:00
Commit Message:
SAGA2: Fix code formatting
Changed paths:
engines/saga2/contain.cpp
diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index 0b932ab963..480954334c 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -115,18 +115,18 @@ ContainerList globalContainerList;
// Physical container appearance
static ContainerAppearanceDef physicalContainerAppearance = {
- {250, 60, 268, 304 + 16},
- {17 + 4, 87, 268 - 2, 304 - 87},
- {13 + 8, 37, 44, 42},
- {13 + 8 + 44, 37, 44, 42},
- {13 + 118, 50, 36, 36},
- {13 + 139, 37, 88, 43},
+ {250, 60, 268, 304 + 16},
+ {17 + 4, 87, 268 - 2, 304 - 87},
+ {13 + 8, 37, 44, 42},
+ {13 + 8 + 44, 37, 44, 42},
+ {13 + 118, 50, 36, 36},
+ {13 + 139, 37, 88, 43},
{ MKTAG('P', 'C', 'L', 0), MKTAG('P', 'C', 'L', 1) },
{ MKTAG('P', 'S', 'L', 0), MKTAG('P', 'S', 'L', 1) },
- {13, 8},
- {22, 22},
- 0, 0,
- 0
+ {13, 8},
+ {22, 22},
+ 0, 0,
+ 0
};
static StaticWindow brassDecorations[] = {
@@ -157,18 +157,18 @@ static StaticWindow woodDecorations[] = {
// Death container appearance
ContainerAppearanceDef deathContainerAppearance = {
- {260, 60, 206, 250},
- {2, 87, 206 - 22, 250 - 87 - 32},
- {16, 24, 44, 42},
- {120 + 18, 24, 44, 42},
- {0, 0, 0, 0},
- {0, 0, 0, 0},
+ {260, 60, 206, 250},
+ {2, 87, 206 - 22, 250 - 87 - 32},
+ {16, 24, 44, 42},
+ {120 + 18, 24, 44, 42},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
{ MKTAG('D', 'C', 'L', 0), MKTAG('D', 'C', 'L', 1) },
{ MKTAG('D', 'S', 'L', 0), MKTAG('D', 'S', 'L', 1) },
- {27, -4},
- {22, 22},
- 0, 0,
- 0
+ {27, -4},
+ {22, 22},
+ 0, 0,
+ 0
};
// physal dialog window decorations
@@ -180,36 +180,36 @@ static StaticWindow deathDecorations[] = {
// ReadyContainer appearance
ContainerAppearanceDef readyContainerAppearance = {
- {0, 0, 0, 0},
- {476, 105, 0, 0},
- {0, 0, 0, 0},
- {0, 0, 0, 0},
- {0, 0, 0, 0},
- {0, 0, 0, 0},
+ {0, 0, 0, 0},
+ {476, 105, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
{ 0, 0 },
{ 0, 0 },
- {iconOriginX - 1, iconOriginY - 1 - 8},
- {iconSpacingX, iconSpacingY},
- 1, 3,
- 3
+ {iconOriginX - 1, iconOriginY - 1 - 8},
+ {iconSpacingX, iconSpacingY},
+ 1, 3,
+ 3
};
//-----------------------------------------------------------------------
// Mental Container appearance
ContainerAppearanceDef mentalContainerAppearance = {
- {478, 168 - 54, 158, 215},
- {2, 86 - 18 - 4, 158 - 2, 215 - 66},
- {2, 19, 44, 44},
- {103, 40 - 18 - 4, 44, 44},
- {0, 0, 0, 0},
- {0, 0, 0, 0},
+ {478, 168 - 54, 158, 215},
+ {2, 86 - 18 - 4, 158 - 2, 215 - 66},
+ {2, 19, 44, 44},
+ {103, 40 - 18 - 4, 44, 44},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
{ MKTAG('C', 'L', 'S', 0), MKTAG('C', 'L', 'S', 1) },
{ MKTAG('S', 'E', 'L', 0), MKTAG('S', 'E', 'L', 1) },
{3, 0},
{4, 4},
- 4, 4,
- 20
+ 4, 4,
+ 20
};
static StaticWindow mentalDecorations[] = {
@@ -219,18 +219,18 @@ static StaticWindow mentalDecorations[] = {
// Enchantment container appearance
ContainerAppearanceDef enchantmentContainerAppearance = {
- {262, 92, 116, 202},
- {2, 87, 116 - 2, 202 - 87},
- {7, 50, 44, 43},
- {57, 50, 44, 43},
- {38, 7, 32, 32},
- {0, 0, 0, 0},
+ {262, 92, 116, 202},
+ {2, 87, 116 - 2, 202 - 87},
+ {7, 50, 44, 43},
+ {57, 50, 44, 43},
+ {38, 7, 32, 32},
+ {0, 0, 0, 0},
{ MKTAG('A', 'A', 'A', 0), MKTAG('A', 'A', 'A', 0) },
{ MKTAG('A', 'A', 'A', 0), MKTAG('A', 'A', 'A', 0) },
{12, 98},
{16, 13},
- 2, 2,
- 2
+ 2, 2,
+ 2
};
//-----------------------------------------------------------------------
More information about the Scummvm-git-logs
mailing list