New Feature: Added shift hotkey to move all when assigning militia (by vertax)

- Completely removes / puts the militia when you click while holding the SHIFT

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5822 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Wanne
2013-01-28 14:26:28 +00:00
parent 9ed906a553
commit 95588dcf81
+42 -13
View File
@@ -5364,9 +5364,6 @@ void DisplayLevelString( void )
// function to manipulate the number of towns people on the cursor // function to manipulate the number of towns people on the cursor
BOOLEAN PickUpATownPersonFromSector( UINT8 ubType, INT16 sX, INT16 sY ) BOOLEAN PickUpATownPersonFromSector( UINT8 ubType, INT16 sX, INT16 sY )
{ {
// see if there are any militia of this type in this sector // see if there are any militia of this type in this sector
if( !SectorInfo[ SECTOR( sX, sY ) ].ubNumberOfCivsAtLevel[ ubType ] ) if( !SectorInfo[ SECTOR( sX, sY ) ].ubNumberOfCivsAtLevel[ ubType ] )
{ {
@@ -5390,22 +5387,27 @@ BOOLEAN PickUpATownPersonFromSector( UINT8 ubType, INT16 sX, INT16 sY )
gfStrategicMilitiaChangesMade = TRUE; gfStrategicMilitiaChangesMade = TRUE;
} }
// the number of units transferred
INT16 countMovedCivs = 1;
if (_KeyDown(SHIFT))
countMovedCivs = SectorInfo[ SECTOR( sX, sY )].ubNumberOfCivsAtLevel[ ubType ];
// otherwise pick this guy up // otherwise pick this guy up
switch( ubType ) switch( ubType )
{ {
case( GREEN_MILITIA ): case( GREEN_MILITIA ):
sGreensOnCursor++; sGreensOnCursor += countMovedCivs;
break; break;
case( REGULAR_MILITIA ): case( REGULAR_MILITIA ):
sRegularsOnCursor++; sRegularsOnCursor += countMovedCivs;
break; break;
case( ELITE_MILITIA ): case( ELITE_MILITIA ):
sElitesOnCursor++; sElitesOnCursor += countMovedCivs;
break; break;
} }
// reduce number in this sector // reduce number in this sector
SectorInfo[ SECTOR( sX, sY )].ubNumberOfCivsAtLevel[ ubType ]--; SectorInfo[ SECTOR( sX, sY )].ubNumberOfCivsAtLevel[ ubType ] -= countMovedCivs;
fMapPanelDirty = TRUE; fMapPanelDirty = TRUE;
@@ -5422,8 +5424,11 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Map Screen2");
return( FALSE ); return( FALSE );
} }
if( SectorInfo[ SECTOR( sX, sY )].ubNumberOfCivsAtLevel[ GREEN_MILITIA ] + SectorInfo[ SECTOR( sX, sY )].ubNumberOfCivsAtLevel[ REGULAR_MILITIA ] // to move a group of militia
+ SectorInfo[ SECTOR( sX, sY )].ubNumberOfCivsAtLevel[ ELITE_MILITIA ] >= iMaxMilitiaPerSector ) INT32 countFreeCivPlace = iMaxMilitiaPerSector - SectorInfo[ SECTOR( sX, sY )].ubNumberOfCivsAtLevel[ GREEN_MILITIA ]
- SectorInfo[ SECTOR( sX, sY )].ubNumberOfCivsAtLevel[ REGULAR_MILITIA ] - SectorInfo[ SECTOR( sX, sY )].ubNumberOfCivsAtLevel[ ELITE_MILITIA ];
if( countFreeCivPlace <= 0 )
{ {
return( FALSE ); return( FALSE );
} }
@@ -5438,6 +5443,9 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Map Screen2");
gfStrategicMilitiaChangesMade = TRUE; gfStrategicMilitiaChangesMade = TRUE;
} }
// the number of units transferred
INT16 countMovedCivs = 1;
// drop the guy into this sector // drop the guy into this sector
switch( ubType ) switch( ubType )
{ {
@@ -5448,14 +5456,29 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Map Screen2");
return( FALSE ); return( FALSE );
} }
sGreensOnCursor--; if (_KeyDown(SHIFT))
{
if (countFreeCivPlace <= sGreensOnCursor)
countMovedCivs = countFreeCivPlace;
else
countMovedCivs = sGreensOnCursor;
}
sGreensOnCursor -= countMovedCivs;
break; break;
case( REGULAR_MILITIA ): case( REGULAR_MILITIA ):
if( !sRegularsOnCursor ) if( !sRegularsOnCursor )
{ {
return( FALSE ); return( FALSE );
} }
sRegularsOnCursor--;
if (_KeyDown(SHIFT))
{
if (countFreeCivPlace <= sRegularsOnCursor) countMovedCivs = countFreeCivPlace;
else countMovedCivs = sRegularsOnCursor;
}
sRegularsOnCursor -= countMovedCivs;
break; break;
case( ELITE_MILITIA ): case( ELITE_MILITIA ):
if( !sElitesOnCursor ) if( !sElitesOnCursor )
@@ -5463,12 +5486,18 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Map Screen2");
return( FALSE ); return( FALSE );
} }
sElitesOnCursor--; if (_KeyDown(SHIFT))
{
if (countFreeCivPlace <= sElitesOnCursor) countMovedCivs = countFreeCivPlace;
else countMovedCivs = sElitesOnCursor;
}
sElitesOnCursor -= countMovedCivs;
break; break;
} }
// up the number in this sector of this type of militia // up the number in this sector of this type of militia
SectorInfo[ SECTOR( sX, sY )].ubNumberOfCivsAtLevel[ ubType ]++; SectorInfo[ SECTOR( sX, sY )].ubNumberOfCivsAtLevel[ ubType ] += countMovedCivs;
fMapPanelDirty = TRUE; fMapPanelDirty = TRUE;