Home » PLAYER'S HQ 1.13 » JA2 Complete Mods & Sequels » Stracciatella Project (Platform Independent JA2) » Crash when going into tactical screen on mine sectors
Crash when going into tactical screen on mine sectors[message #248222]
|
Wed, 31 March 2010 11:33
|
|
bbun |
|
Messages:74
Registered:April 2004 Location: Amsterdam |
|
|
For some reason my compiled version on OSX would crash when going into tactical view on maps with mines (at least for drassen mine and alma mine), but only the 2nd time I entered them (and had already captured them).
I tracked this down to a Bus Error in SET_MOVEMENTCOST, triggered from:
StrategicMap.cc -> SetCurrentWorldSector
Keys.cc -> UpdateDoorGraphicsFromStatus
Keys.cc -> SyncronizeDoorStatusToStructureData
WorldDef.cc -> RecompileLocalMovementCosts
WorldDef.cc -> CompileTileMovementCosts
seems like some problem calculating movement costs for mine entrances.
Anyhow, for people running into the same problem, I fixed this by replacing
SET_MOVEMENTCOST( usGridNo, ubDirLoop, 0, TRAVELCOST_OFF_MAP );
SET_MOVEMENTCOST( usGridNo, ubDirLoop, 1, TRAVELCOST_OFF_MAP );
with
FORCE_SET_MOVEMENTCOST( usGridNo, ubDirLoop, 0, TRAVELCOST_OFF_MAP );
FORCE_SET_MOVEMENTCOST( usGridNo, ubDirLoop, 1, TRAVELCOST_OFF_MAP );
at lines 426-427 of TileEngine/WorldDef.cc
Hope this helps others.
Report message to a moderator
|
Corporal
|
|
|
|
|
|
|
|
|
|
Re: Crash when going into tactical screen on mine sectors[message #250170]
|
Sat, 24 April 2010 12:03
|
|
mgl |
|
Messages:255
Registered:December 2007 Location: France |
|
|
Thank you, people from 1.13. It promises to be annoying.
@bbun
I changed all the "usGridno" variables involved in a call to the MAPROWCOLTOPOS() macro in this source file to be unsigned, so that the MAPROWCOLTOPOS() macro and the test "if (usGridNo < WORLD_MAX)" are used in the spirit in which they seem to have been originally written. It's not clear why they changed it in some places and there are still some signed gridno variables in that file, but they aren't used with the macro.
Try this instead of your fix, please, because I have never seen this bug myself and can't reproduce it. The crash may be linked to the fact that a signed gridno value of -1 is used as an index to an array, which may violate a memory policy on OSX but not on other OSes.
unsigned_gridno.diff (it's only 3 extra "U"):
Index: Build/TileEngine/WorldDef.cc
===================================================================
--- Build/TileEngine/WorldDef.cc (revision 7059)
+++ Build/TileEngine/WorldDef.cc (working copy)
@@ -1067,7 +1067,7 @@
void RecompileLocalMovementCosts( INT16 sCentreGridNo )
{
- INT16 usGridNo;
+ UINT16 usGridNo;
INT16 sGridX, sGridY;
INT16 sCentreGridX, sCentreGridY;
INT8 bDirLoop;
@@ -1109,7 +1109,7 @@
void RecompileLocalMovementCostsFromRadius( INT16 sCentreGridNo, INT8 bRadius )
{
- INT16 usGridNo;
+ UINT16 usGridNo;
INT16 sGridX, sGridY;
INT16 sCentreGridX, sCentreGridY;
INT8 bDirLoop;
@@ -1204,7 +1204,7 @@
void RecompileLocalMovementCostsInAreaWithFlags( void )
{
- INT16 usGridNo;
+ UINT16 usGridNo;
INT16 sGridX, sGridY;
INT8 bDirLoop;
Report message to a moderator
|
|
|
|
|
Re: Crash when going into tactical screen on mine sectors[message #250604]
|
Wed, 28 April 2010 22:48
|
|
bbun |
|
Messages:74
Registered:April 2004 Location: Amsterdam |
|
|
So this fix works, but my game crashed again today, entering a sector (meduna airport).
HOWEVER, it seems this is because of a TOTALLY DIFFERENT issue. Would love someone's idea about this.
Stack:
The game crashes in the function
FloorAtGridNo [WorldDef.cc]
called from
LoadRottingCorpsesFromTempCorpseFile [Tactical_Save.cc]
called from
LoadCurrentSectorsInformationFromTempItemsFile [Tactical_Save.cc]
bool FloorAtGridNo(UINT32 const map_idx)
{
DebugMsg(TOPIC_JA2, DBG_LEVEL_0, String("MAP_IDX: %d", map_idx));
for (LEVELNODE const* i = gpWorldLevelData[map_idx].pLandHead; i;)
{
DebugMsg(TOPIC_JA2, DBG_LEVEL_0, String("i->usIndex: %d", i->usIndex));
The DebugMsg calls are mine. Game crashes between those, so I assume gpWorldLevelData[map_idx].pLandHead causes the Segmentation Fault by faulty access.
This happens for map_idx 25601 => gpWorldLevelData[25601].pLandHead => Crash
Anyone? Idea's?
Report message to a moderator
|
Corporal
|
|
|
|
|
Re: Crash when going into tactical screen on mine sectors[message #250723]
|
Fri, 30 April 2010 12:28
|
|
mgl |
|
Messages:255
Registered:December 2007 Location: France |
|
|
The function "FindNearestAvailableGridNoForCorpse()" in 'Build/Tactical/Tactical_Save.cc' returns a gridno or the value "NOWHERE" (= WORLD_MAX + 1) if it can't find one.
Its caller, the function "LoadRottingCorpsesFromTempCorpseFile()", which is the caller of the function "FloorAtGridNo()" too, has a comment which says that they will force their way through the code to the function which adds a corpse on the map despise an invalid gridno because that function could do interesting things with it anyway. Indeed, if that function sees "NOWHERE" as a gridno, it returns immediately!
This is the change I suggest:
Index: Build/Tactical/Tactical_Save.cc
===================================================================
--- Build/Tactical/Tactical_Save.cc (revision 7059)
+++ Build/Tactical/Tactical_Save.cc (working copy)
@@ -720,9 +720,19 @@
def.sGridNo = FindNearestAvailableGridNoForCorpse(&def, 5);
if (def.sGridNo == NOWHERE)
def.sGridNo = FindNearestAvailableGridNoForCorpse(&def, 15);
- /* ATE: Here we still could have a bad location, but send in NOWHERE to
- * corpse function anyway, 'cause it will iwth not drop it or use a map
- * edgepoint */
+ /* ATE: Here we still could have a bad location, but send in NOWHERE to
+ * corpse function anyway, 'cause it will iwth not drop it or use a map
+ * edgepoint */
+
+ /* 2010-04-29:
+ * The corpse func does nothing from NOWHERE.
+ * No need to force our way to it as the
+ * comment above suggests.
+ * NOWHERE is (WORLD_MAX + 1), and would
+ * fail the next test but I leave this line
+ * for clarity.
+ */
+ if (def.sGridNo == NOWHERE) { continue; }
}
else if (def.usFlags & ROTTING_CORPSE_USE_NORTH_ENTRY_POINT)
{
@@ -741,6 +751,9 @@
def.sGridNo = gMapInformation.sWestGridNo;
}
+ /* 2010-04-29: Don't add a corpse on an invalid gridno */
+ if (def.sGridNo >= WORLD_MAX || def.sGridNo < 0) { continue; }
+
/* ATE: Don't place corpses if not loading a savegame, in town, indoors and
* the corpse is too old */
if (maybe_dont_add &&
I have added a line to stop trying to add a corpse on a "NOWHERE" gridno value and, later, a general check on the gridno obtained from the savegame or from the map north/south/east/west entry points because I don't trust them. Since the gridno is signed in this file, it needs to be compared to 0 as well as the usual WORLD_MAX.
The way the gridnos are managed is really confusing: sometimes signed, sometimes not, sometimes on 16 bits, sometimes on 32... A general function to check the validity of a gridno would be welcome.
Edit: You are in the NOWHERE case, bbun. No suitable gridno was found on a radius of 15 tiles around the original location chosen for the corpse. How can it be possible ?
Report message to a moderator
|
|
|
|
|
|
|
|
|
|
Re: Crash when going into tactical screen on mine sectors[message #250983]
|
Wed, 05 May 2010 13:49
|
|
Helios |
|
Messages:25
Registered:April 2010 |
|
|
mgl check your messages under 'my stuff' when you have the time
Report message to a moderator
|
Private 1st Class
|
|
|
Goto Forum:
Current Time: Sat Jan 25 20:01:00 GMT+2 2025
Total time taken to generate the page: 0.01331 seconds
|