Editing Targets not preserved in saved games
From DoomWiki.org
Your changes will be displayed to readers once an authorized user accepts them. (help) |
Warning: You are not logged in. Your IP address will be recorded in this page's edit history.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 25: | Line 25: | ||
The cause of this effect can be found in the Doom source code in [[Doom source code files|p_saveg.c]], in the functions ''P_ArchiveThinkers'' and ''P_UnarchiveThinkers''. | The cause of this effect can be found in the Doom source code in [[Doom source code files|p_saveg.c]], in the functions ''P_ArchiveThinkers'' and ''P_UnarchiveThinkers''. | ||
− | In the Doom source code, the ''mobj_t'' structure is used to represent game objects such as monsters. Monster targets are stored in these structures as a field named ''target'', which is a pointer to another ''mobj_t'' that the monster is currently | + | In the Doom source code, the ''mobj_t'' structure is used to represent game objects such as monsters. Monster targets are stored in these structures as a field named ''target'', which is a pointer to another ''mobj_t'' that the monster is currently targetting. |
The Doom engine saves games by directly writing the raw structures used in memory to disk. When reloading saved games, pointers such as the ''target'' field are no longer valid (as the layout of structures within memory is different). When loading a game, the ''P_UnarchiveThinkers'' function deliberately sets ''target'' on all map objects to NULL in order to avoid crashes due to accessing invalid areas of memory. A null target indicates that a monster has no current target, causing active monsters to return to sleep. | The Doom engine saves games by directly writing the raw structures used in memory to disk. When reloading saved games, pointers such as the ''target'' field are no longer valid (as the layout of structures within memory is different). When loading a game, the ''P_UnarchiveThinkers'' function deliberately sets ''target'' on all map objects to NULL in order to avoid crashes due to accessing invalid areas of memory. A null target indicates that a monster has no current target, causing active monsters to return to sleep. |