lgeneral: Patch for Lgeneral 1.2.3 seg. fault bug
Good-looking and addictive OpenSource games
Brought to you by:
kulkanie
Segmentation fault that crashes the game on the AI "MOVE & ATTACK" phase.
Bug Reason:
In function "unit_get_damage" of unit.c, this line was causing the seg.fault:
if ( unit->terrain->flags[cur_weather] & SWAMP )
the reason is the flags pointer was missing. It seems a certain unit did not have the terrain set. From analyzing where terrain is written, I see it is not set when loading a savegame.
Bug Fix:
In function "load_unit" of slot.c I have added the following at line 609:
unit->terrain = map[unit->x][unit->y].terrain;
In this way the units always get the terrain filled upon loading a game, which was causing the above problem.
Patch attached and licensed as GPL.
Here is a savegame to reproduce the bug in stock lgeneral 1.2.3.
Just load the savegame and end the turn to see it.