[patch] Remove all references before deleting a factory January 01, 2010, 10:10:29 pm ai_goods_t holds several references to factories (fabrik_t objects). If player 'public service' removes a factory invalid pointers in ai_goods remain. Saving such a game may work, but produces invalid coordinates. Loading such a game produces NULL pointers in ai_goods_t. The next attempt to save this game crashes because of these NULL pointers.This patch cleans up ai_goods_t before a factory is deleted and checks, whether loaded forbidden_connections contain valid data. Invalid data is ignored, which is safe for game play as such no longer existing connections won't be checked again at all.How it works:- hausbauer_t calls the new method spieler_t::notification(notification_t info, fabrik_t &fab) to inform the players, that a fab is going to be deleted.- enum notification_t is declared in new header file utils/notification.h- TODO(?): I'm not sure, what ai_goods_t must and/or should do in states NR_*_SUCCESS. - Just skip the message, as everythings should have been done automatically by hausbauer_t? - Undo the whole new convoys and ways etc.?BTW: The use of more (overloaded) methods notification() can help to solve analog referencing problems as well. Quote Selected
Re: [patch] Remove all references before deleting a factory Reply #1 – January 02, 2010, 12:56:41 pm thank you. Quote Selected
Re: [patch] Remove all references before deleting a factory Reply #2 – January 20, 2010, 07:58:22 pm incorporated in 3044. I hope I did not break your implementation.. Quote Selected