Skip to content

make game struct consistent cross platform#4594

Draft
PieterVdc wants to merge 19 commits intodkfans:masterfrom
PieterVdc:crossplay
Draft

make game struct consistent cross platform#4594
PieterVdc wants to merge 19 commits intodkfans:masterfrom
PieterVdc:crossplay

Conversation

@PieterVdc
Copy link
Member

@PieterVdc PieterVdc commented Mar 2, 2026

remove all pointers, replace all longs with int32_t etc,

this is needed to be able to sync multiplayer, and share savegames cross platform

@PieterVdc PieterVdc changed the title make game struct consistent make game struct consistent cross platform Mar 2, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 long fields in serialized structs with int32_t/uint32_t for 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants