Announcement: Be excellent to each other.


Caravel Forum : Caravel Boards : Development : Note to self: Refactor drod source to not directly access TILE_LAYER array
New Topic New Poll Post Reply
Poster Message
kieranmillar
Level: Smitemaster
Rank Points: 3781
Registered: 07-11-2014
IP: Logged
icon Note to self: Refactor drod source to not directly access TILE_LAYER array (+3)  
DROD has a static array in TileConstants.h called TILE_LAYER, it's an array, indexed by the tile number, that returns what layer it is on. Any time DROD wants to know what layer a tile is on, it access this array with TILE_LAYER[tile]

This is bad because some tiles are virtual tiles, with negative values (then cast to be unsigned) which are massively out of bounds. We should be bounds checking this array everywhere we use it.

What makes more sense is to not allow access to this array directly, but rather via a static method GetLayerForTile(tileId) which bounds checks it every time it is used, and returns some value to represent an error if the tile was a virtual one out of the bounds of the array, then ASSERT or manage this wherever it is used.

Should be done for classic DROD and RPG.
06-14-2025 at 09:37 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
New Topic New Poll Post Reply
Caravel Forum : Caravel Boards : Development : Note to self: Refactor drod source to not directly access TILE_LAYER array
Surf To:


Forum Rules:
Can I post a new topic? No
Can I reply? No
Can I read? Yes
HTML Enabled? No
UBBC Enabled? Yes
Words Filter Enable? No

Contact Us | CaravelGames.com

Powered by: tForum tForumHacks Edition b0.98.9
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team and the Caravel team.