mirror of
https://github.com/1dot13/source.git
synced 2026-09-09 14:46:05 +02:00
When clicking on a sector to start militia pathing, and the sector does not have static militia but militia groups, select the last militia group instead of creating a new empty one.
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7742 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
+26
-16
@@ -16474,26 +16474,31 @@ BOOLEAN RequestGiveMilitiaNewDestination( void )
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if there is already a travelling group in this sector, pick them up instead
|
// if there are no more static militia in this sector, but a group is, select the last group
|
||||||
/*UINT8 groupid = 0;
|
|
||||||
BOOLEAN fGroupAlreadyExists = FALSE;
|
BOOLEAN fGroupAlreadyExists = FALSE;
|
||||||
if ( GetMilitiaGroupInSector( sSelMapX, sSelMapY, groupid ) )
|
if ( MilitiaInSectorOfRankStationary( sSelMapX, sSelMapY, GREEN_MILITIA ) + MilitiaInSectorOfRankStationary( sSelMapX, sSelMapY, REGULAR_MILITIA ) + MilitiaInSectorOfRankStationary( sSelMapX, sSelMapY, ELITE_MILITIA ) == 0 )
|
||||||
{
|
{
|
||||||
INT16 internalslot = GetMilitiaPathSlot( groupid );
|
UINT8 groupid = 0;
|
||||||
|
if ( GetLastMilitiaGroupInSector( sSelMapX, sSelMapY, groupid ) )
|
||||||
if ( internalslot > -1 )
|
|
||||||
{
|
{
|
||||||
fGroupAlreadyExists = TRUE;
|
INT16 internalslot = GetMilitiaPathSlot( groupid );
|
||||||
|
|
||||||
gMilitiaGroupId = internalslot;
|
if ( internalslot > -1 )
|
||||||
|
{
|
||||||
|
fGroupAlreadyExists = TRUE;
|
||||||
|
|
||||||
|
gMilitiaGroupId = internalslot;
|
||||||
|
|
||||||
|
gNewMilitiaGroupId = gMilitiaPath[gMilitiaGroupId].sGroupid;
|
||||||
|
|
||||||
// yes, we intentionally use a different sector number here
|
// yes, we intentionally use a different sector number here
|
||||||
gMilitiaPlotStartSector = (INT16)(sSelMapX + sSelMapY*(MAP_WORLD_X));
|
gMilitiaPlotStartSector = (INT16)(sSelMapX + sSelMapY*(MAP_WORLD_X));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
// we can actually fail here if there aren't any slots left
|
// if we don't use a previously existing group and can't creae a new one, abort
|
||||||
if ( !MilitiaPlotStart( ) )
|
if ( !fGroupAlreadyExists && !MilitiaPlotStart( ) )
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -16679,20 +16684,25 @@ void DeleteAllMilitiaPaths()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if a militia group is in this sector, return TRUE, group id will be stored in arId
|
// return the last militia group in this sector, group id will be stored in arId. return FALSE if none found
|
||||||
BOOLEAN GetMilitiaGroupInSector( INT16 sMapX, INT16 sMapY, UINT8& arId )
|
BOOLEAN GetLastMilitiaGroupInSector( INT16 sMapX, INT16 sMapY, UINT8& arId )
|
||||||
{
|
{
|
||||||
|
BOOLEAN fFound = FALSE;
|
||||||
|
|
||||||
GROUP *pGroup = gpGroupList;
|
GROUP *pGroup = gpGroupList;
|
||||||
while ( pGroup )
|
while ( pGroup )
|
||||||
{
|
{
|
||||||
if ( pGroup->usGroupTeam == MILITIA_TEAM && pGroup->ubSectorX == sMapX && pGroup->ubSectorY == sMapY )
|
if ( pGroup->usGroupTeam == MILITIA_TEAM && pGroup->ubSectorX == sMapX && pGroup->ubSectorY == sMapY )
|
||||||
{
|
{
|
||||||
arId = pGroup->ubGroupID;
|
arId = pGroup->ubGroupID;
|
||||||
return TRUE;
|
fFound = TRUE;
|
||||||
}
|
}
|
||||||
pGroup = pGroup->next;
|
pGroup = pGroup->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( fFound )
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -153,8 +153,8 @@ INT16 GetMilitiaPathSlot(UINT8 uGroupId);
|
|||||||
|
|
||||||
void DeleteAllMilitiaPaths();
|
void DeleteAllMilitiaPaths();
|
||||||
|
|
||||||
// if a militia group is in this sector, return TRUE, group id will be stored in arId
|
// return the last militia group in this sector, group id will be stored in arId. return FALSE if none found
|
||||||
BOOLEAN GetMilitiaGroupInSector( INT16 sMapX, INT16 sMapY, UINT8& arId );
|
BOOLEAN GetLastMilitiaGroupInSector( INT16 sMapX, INT16 sMapY, UINT8& arId );
|
||||||
|
|
||||||
BOOLEAN CanGiveStrategicMilitiaMoveOrder( INT16 sMapX, INT16 sMapY );
|
BOOLEAN CanGiveStrategicMilitiaMoveOrder( INT16 sMapX, INT16 sMapY );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user