Due to 5.2 changes, importing a hold that contains a character crashes the game.
This happens in CDbRoom::ClearMonsters. Due to the addition of character behaviors allow characters to be monster targets, characters with these behaviors need to be removed from the monster enemy list when deleted. This requires the CMonster pointer to the character to be cast to CCharacter to check for these behaviors. Due to the particulars of how monsters are imported, this cast fails during importing, and the game crashes when trying to access an invalid pointer.
This can be avoided by checking if the room is attached to a game. Characters cannot gain behaviors until their game is set, and this does not happen during importing. Therefore, the check for monster target behaviors can be safely skipped.
Due to 5.2 changes, importing a hold that contains a character crashes the game.
This happens in
CDbRoom::ClearMonsters
. Due to the addition of character behaviors allow characters to be monster targets, characters with these behaviors need to be removed from the monster enemy list when deleted. This requires theCMonster
pointer to the character to be cast toCCharacter
to check for these behaviors. Due to the particulars of how monsters are imported, this cast fails during importing, and the game crashes when trying to access an invalid pointer.This can be avoided by checking if the room is attached to a game. Characters cannot gain behaviors until their game is set, and this does not happen during importing. Therefore, the check for monster target behaviors can be safely skipped.
Thread: https://forum.caravelgames.com/viewtopic.php?TopicID=45937