Home » PLAYER'S HQ 1.13 » JA2 Complete Mods & Sequels » Stracciatella Project (Platform Independent JA2) » Bug: looking for enemies in adjacent sectors
Bug: looking for enemies in adjacent sectors[message #250880] Sun, 02 May 2010 20:10 Go to next message
mgl is currently offline mgl

 
Messages:255
Registered:December 2007
Location: France
My game triggered an assertion failure on the sector's coordinates when I arrived in sector (16, Cool. After investigation, it was because it looked in the non-existing sector to the right to see if there were enemies there able to notice my mercs.

The function to scan the adjacent sectors when one of your teams arrive somewhere is in 'Build/Strategic/Strategic_AI.cc'. A comment says that the function will look for patrols and garrisons able to notice you in the four directions.


The problem is with the x coordinates:
The code to scan the sector to the right does nothing if you are on the right edge. Otherwise it looks for a patrol to the right, and if no patrol is found, it looks for a garrison to the left. It triggers an assertion failure when you are on the left edge.

The code to scan the sector on the left mimics this behaviour by looking for a garrison to the right and triggers an assertion failure when you are on the right edge. It's the bug I had.

The code for the sectors above and below is correct.

This is the patch:
Index: Build/Strategic/Strategic_AI.cc
===================================================================
--- Build/Strategic/Strategic_AI.cc	(revision 7059)
+++ Build/Strategic/Strategic_AI.cc	(working copy)
@@ -1962,6 +1973,7 @@
 			return FALSE;
 		if( pPlayerGroup->ubSectorY > 1 )
 		{
+			/* Adjacent sector to look: above */
 			GROUP* const pEnemyGroup = FindEnemyMovementGroupInSector(pPlayerGroup->ubSectorX, pPlayerGroup->ubSectorY - 1);
 			if( pEnemyGroup && AttemptToNoticeAdjacentGroupSucceeds() )
 			{
@@ -1978,22 +1990,26 @@
 		}
 		if( pPlayerGroup->ubSectorX < 16 )
 		{
-			GROUP* const pEnemyGroup = FindEnemyMovementGroupInSector(pPlayerGroup->ubSectorX + 1, pPlayerGroup->ubSectorY);
+			/* Adjacent sector where to look: right */
+			UINT8 const ubAdjX = pPlayerGroup->ubSectorX + 1;
+			
+			GROUP* const pEnemyGroup = FindEnemyMovementGroupInSector(ubAdjX, pPlayerGroup->ubSectorY);
 			if( pEnemyGroup && AttemptToNoticeAdjacentGroupSucceeds() )
 			{
 				HandlePlayerGroupNoticedByPatrolGroup( pPlayerGroup, pEnemyGroup );
 				return FALSE;
 			}
-			pSector = &SectorInfo[ SECTOR( pPlayerGroup->ubSectorX-1, pPlayerGroup->ubSectorY ) ];
+			pSector = &SectorInfo[SECTOR(ubAdjX, pPlayerGroup->ubSectorY)];
 			ubNumEnemies = pSector->ubNumAdmins + pSector->ubNumTroops + pSector->ubNumElites;
 			if( ubNumEnemies && pSector->ubGarrisonID != NO_GARRISON && AttemptToNoticeAdjacentGroupSucceeds() )
 			{
-				HandlePlayerGroupNoticedByGarrison( pPlayerGroup, (UINT8)SECTOR( pPlayerGroup->ubSectorX-1, pPlayerGroup->ubSectorY ) );
+				HandlePlayerGroupNoticedByGarrison(pPlayerGroup, (UINT8)SECTOR(ubAdjX, pPlayerGroup->ubSectorY));
 				return FALSE;
 			}
 		}
 		if( pPlayerGroup->ubSectorY < 16 )
 		{
+			/* Adjacent sector to look: below */
 			GROUP* const pEnemyGroup = FindEnemyMovementGroupInSector(pPlayerGroup->ubSectorX, pPlayerGroup->ubSectorY + 1);
 			if( pEnemyGroup && AttemptToNoticeAdjacentGroupSucceeds() )
 			{
@@ -2010,17 +2026,20 @@
 		}
 		if( pPlayerGroup->ubSectorX > 1 )
 		{
-			GROUP* const pEnemyGroup = FindEnemyMovementGroupInSector(pPlayerGroup->ubSectorX - 1, pPlayerGroup->ubSectorY);
+			/* Adjacent sector where to look: left */
+			UINT8 ubAdjX = pPlayerGroup->ubSectorX - 1;
+
+			GROUP* const pEnemyGroup = FindEnemyMovementGroupInSector(ubAdjX, pPlayerGroup->ubSectorY);
 			if( pEnemyGroup && AttemptToNoticeAdjacentGroupSucceeds() )
 			{
 				HandlePlayerGroupNoticedByPatrolGroup( pPlayerGroup, pEnemyGroup );
 				return FALSE;
 			}
-			pSector = &SectorInfo[ SECTOR( pPlayerGroup->ubSectorX+1, pPlayerGroup->ubSectorY ) ];
+			pSector = &SectorInfo[SECTOR(ubAdjX, pPlayerGroup->ubSectorY)];
 			ubNumEnemies = pSector->ubNumAdmins + pSector->ubNumTroops + pSector->ubNumElites;
 			if( ubNumEnemies && pSector->ubGarrisonID != NO_GARRISON && AttemptToNoticeAdjacentGroupSucceeds() )
 			{
-				HandlePlayerGroupNoticedByGarrison( pPlayerGroup, (UINT8)SECTOR( pPlayerGroup->ubSectorX+1, pPlayerGroup->ubSectorY ) );
+				HandlePlayerGroupNoticedByGarrison(pPlayerGroup, (UINT8)SECTOR(ubAdjX, pPlayerGroup->ubSectorY));
 				return FALSE;
 			}
 		}

I have fixed a number of "pPlayerGroup->ubSectorX +/- 1".
Although the "y" are correct, I think I will do the same to them.

Report message to a moderator

Master Sergeant
Re: Bug: looking for enemies in adjacent sectors[message #250883] Sun, 02 May 2010 22:02 Go to previous messageGo to next message
olol is currently offline olol

 
Messages:28
Registered:March 2009
hi,mgl

look this topic,please

http://www.ja-galaxy-forum.com/board/ubbthreads.php?ubb=showflat&Number=243866#Post243866


hope you can fix.

Report message to a moderator

Private 1st Class
Re: Bug: looking for enemies in adjacent sectors[message #250914] Mon, 03 May 2010 20:39 Go to previous messageGo to next message
Ddass is currently offline Ddass

 
Messages:26
Registered:April 2010
Yay for mgl :up:

olol look here in a thread right below.

[Updated on: Mon, 03 May 2010 20:39] by Moderator

Report message to a moderator

Private 1st Class
Re: Bug: looking for enemies in adjacent sectors[message #250936] Tue, 04 May 2010 05:59 Go to previous messageGo to next message
olol is currently offline olol

 
Messages:28
Registered:March 2009
Ddass
Yay for mgl :up:

olol look here in a thread right below.




used hotfix3 build,still crash

Report message to a moderator

Private 1st Class
Re: Bug: looking for enemies in adjacent sectors[message #250943] Tue, 04 May 2010 10:46 Go to previous messageGo to next message
Tron

 
Messages:225
Registered:August 2007
Location: Germany
I corrected this vanilla bug in r7062. Thanks for reporting and providing a patch.

Report message to a moderator

Sergeant 1st Class
Re: Bug: looking for enemies in adjacent sectors[message #251035] Thu, 06 May 2010 22:22 Go to previous message
mgl is currently offline mgl

 
Messages:255
Registered:December 2007
Location: France
I looked at this bug in 1.13 too and a comment says they fixed it in 2008.

There are probably a lot of bugs, fixed in a project and still there in the other.

Report message to a moderator

Master Sergeant
Previous Topic: Crash when going into tactical screen on mine sectors
Next Topic: lots of compile warnings in 7063
Goto Forum:
  


Current Time: Wed Jan 22 14:45:17 GMT+2 2025

Total time taken to generate the page: 0.00953 seconds