Home » PLAYER'S HQ 1.13 » JA2 Complete Mods & Sequels » Stracciatella Project (Platform Independent JA2) » Crash when going into tactical screen on mine sectors
Re: Crash when going into tactical screen on mine sectors[message #250723] Fri, 30 April 2010 12:28 Go to previous messageGo to previous message
mgl is currently offline 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

Master Sergeant
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Bus Error @ Tactical screen
Next Topic: Bug: looking for enemies in adjacent sectors
Goto Forum:
  


Current Time: Sat Jan 11 01:57:01 GMT+2 2025

Total time taken to generate the page: 0.01425 seconds