make game struct consistent cross platform#4594
Draft
PieterVdc wants to merge 19 commits intodkfans:masterfrom
Draft
make game struct consistent cross platform#4594PieterVdc wants to merge 19 commits intodkfans:masterfrom
PieterVdc wants to merge 19 commits intodkfans:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR makes the game struct layout consistent across platforms by replacing platform-dependent types (long, unsigned long, pointers) with fixed-width types (int32_t, uint32_t) and accessor functions. This is needed for multiplayer synchronization and cross-platform savegame compatibility.
Changes:
- Replace all
long/unsigned longfields in serialized structs withint32_t/uint32_tfor consistent cross-platform layout - Remove pointer fields from serialized structs (
dungeon *, palette pointers,TbFileHandle,char *paths) replacing them with indices and local static variables accessed through getter/setter functions - Remove unused structs (
Columns,Persons,GuiMessage_OLD) and update format strings to match new types
Reviewed changes
Copilot reviewed 45 out of 45 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/player_data.h/c | Remove palette pointers from PlayerInfo, add get/set accessors using static locals |
| src/player_computer.h/c | Replace struct Dungeon *dungeon with PlayerNumber dungeon_plyr_idx and computer_dungeon() macro |
| src/player_comptask.c | Update ~70+ references from comp->dungeon->owner to comp->dungeon_plyr_idx |
| src/player_compprocs.c | Update computer process functions to use new dungeon accessor |
| src/player_compevents.c | Update computer event functions to use new dungeon accessor |
| src/player_compchecks.c | Update computer check functions to use new dungeon accessor |
| src/packets_misc.c | Move packet_save_fp file handle out of game struct into static local |
| src/game_legacy.h | Remove process_turn_time and packet_save_fp from Game struct |
| src/main.cpp | Add process_turn_time as file-scope variable, update palette accessors |
| src/game_saves.c | Update palette accessors for load game |
| src/sounds.h/c | Remove char * path fields from SoundSettings |
| src/dungeon_stats.h | Replace all unsigned long with uint32_t in LevelStats |
| src/lvl_script.h/c | Replace platform-dependent types with fixed-width types in script structs |
| src/config_*.h | Replace long/unsigned long with int32_t/uint32_t in config structs |
| src/creature_*.h | Replace long/unsigned long with int32_t/uint32_t in creature structs |
| src/engine_camera.h | Replace long with int32_t in Camera and MinMax structs |
| src/ariadne.h | Replace long with int32_t in Ariadne and Navigation structs |
| src/map_events.h | Replace unsigned long with uint32_t in Event struct |
| src/gui_msgs.h | Remove old GuiMessage_OLD struct, use GameTurn type for expiration |
| src/map_columns.h | Remove unused Columns struct |
| src/creature_control.h | Remove unused Persons struct |
| src/config_magic.h | Add #pragma pack(1) to PowerConfigStats and reorder fields |
| src/vidfade.c | Update palette access to use getter |
| src/kfx/lense/PaletteEffect.cpp | Update palette access to use setter |
| src/thing_creature.c | Update dungeon access to use computer_dungeon() |
| src/player_utils.c | Update palette and format string changes |
| src/bflib_datetm.cpp | Update process_turn_time reference |
| src/frontmenu_ingame_map.c | Update process_turn_time reference |
| src/console_cmd.c | Update format string for uint32_t |
| src/light_data.c | Update format string for uint32_t |
| src/lvl_script_commands.c | Update format string for uint32_t |
| src/game_merge.h | Replace long with int32_t in TextScrollWindow and IntralevelData |
| src/room_data.h | Replace unsigned long with uint32_t |
| src/thing_list.h | Replace unsigned long with uint32_t in StructureList |
| src/player_complookup.h | Replace unsigned long with uint32_t in GoldLookup |
| src/creature_battle.h | Replace unsigned long with uint32_t in CreatureBattle |
| src/creature_groups.h | Replace long/unsigned long with int32_t/uint32_t |
| src/creature_instances.h | Replace long with int32_t in InstanceInfo |
| src/power_hand.h | Replace long with int32_t in HandRule |
| src/config_slabsets.h | Replace long with int32_t in ColumnConfig |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
remove all pointers, replace all longs with int32_t etc,
this is needed to be able to sync multiplayer, and share savegames cross platform