- Fix: security check for underflows when adding reinforcements

- Fix: added defined heights for kid's heads and torsos to correctly apply headshots
- Fix: While filling canteens, poisoned water from sectors is only consumed if no water drum is found

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5684 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2012-11-12 20:10:28 +00:00
parent 004728d2e4
commit 1a7e900df5
4 changed files with 79 additions and 22 deletions
+7 -1
View File
@@ -1529,7 +1529,13 @@ void AddPossiblePendingEnemiesToBattle()
ubGroupIndex = Random( ubNumGroupsInSector);
pGroup = pGroupInSectorList[ ubGroupIndex];
ubNumAvailable = pGroup->ubGroupSize - pGroup->pEnemyGroup->ubElitesInBattle - pGroup->pEnemyGroup->ubTroopsInBattle - pGroup->pEnemyGroup->ubAdminsInBattle;
// Flugente fix: check for underflow...
UINT8 currentgroupsize = pGroup->pEnemyGroup->ubElitesInBattle + pGroup->pEnemyGroup->ubTroopsInBattle + pGroup->pEnemyGroup->ubAdminsInBattle;
if ( currentgroupsize > pGroup->ubGroupSize )
ubNumAvailable = 0;
else
ubNumAvailable = pGroup->ubGroupSize - currentgroupsize;
if (!ubNumAvailable)
{
// Looks like we picked an empty group. Make a note of it
+9 -6
View File
@@ -759,7 +759,14 @@ void SectorFillCanteens( void )
// If not, see if there is a water drum, and fill up the canteens from that one
UINT8 waterquality = GetWaterQuality(gWorldSectorX, gWorldSectorY, gbWorldSectorZ);
if ( waterquality == WATER_DRINKABLE || waterquality == WATER_POISONOUS )
// search for a water drum
BOOLEAN waterdrumfound = FALSE;
OBJECTTYPE* pWaterDrum = GetUsableWaterDrumInSector();
if ( !pWaterDrum || !(pWaterDrum->exists()) )
waterdrumfound = TRUE;
// drink from sector if water is ok, or it is poisonous but we haven't found a useable water drum
if ( waterquality == WATER_DRINKABLE || (waterquality == WATER_POISONOUS && !waterdrumfound) )
{
// the temperature of the water in this sector (temperature reflects the quality)
FLOAT addtemperature = OVERHEATING_MAX_TEMPERATURE;
@@ -837,12 +844,8 @@ void SectorFillCanteens( void )
}
}
}
else
else if ( waterdrumfound )
{
OBJECTTYPE* pWaterDrum = GetUsableWaterDrumInSector();
if ( !pWaterDrum || !(pWaterDrum->exists()) )
return;
INT32 drumsize = Food[Item[pWaterDrum->usItem].foodtype].bDrinkPoints;
// first step: fill all canteens in inventories
+57 -15
View File
@@ -2460,6 +2460,9 @@ BOOLEAN BulletHitMerc( BULLET * pBullet, STRUCTURE * pStructure, BOOLEAN fIntend
}
else
{
// Flugente: kids are smaller. We have to keep hat in mind... otherwise we will never make a sucessful headshot
BOOLEAN iskid = ( pTarget->ubBodyType == HATKIDCIV || pTarget->ubBodyType == KIDCIV );
switch (gAnimControl[ pTarget->usAnimState ].ubEndHeight)
{
case ANIM_STAND:
@@ -2471,17 +2474,36 @@ BOOLEAN BulletHitMerc( BULLET * pBullet, STRUCTURE * pStructure, BOOLEAN fIntend
{
dZPosRelToMerc -= HEIGHT_UNITS;
}
if (dZPosRelToMerc > STANDING_HEAD_BOTTOM_POS)
if ( iskid )
{
ubHitLocation = AIM_SHOT_HEAD;
}
else if (dZPosRelToMerc < STANDING_TORSO_BOTTOM_POS )
{
ubHitLocation = AIM_SHOT_LEGS;
if (dZPosRelToMerc > STANDING_HEAD_BOTTOM_POS_KID)
{
ubHitLocation = AIM_SHOT_HEAD;
}
else if (dZPosRelToMerc < STANDING_TORSO_BOTTOM_POS_KID )
{
ubHitLocation = AIM_SHOT_LEGS;
}
else
{
ubHitLocation = AIM_SHOT_TORSO;
}
}
else
{
ubHitLocation = AIM_SHOT_TORSO;
if (dZPosRelToMerc > STANDING_HEAD_BOTTOM_POS)
{
ubHitLocation = AIM_SHOT_HEAD;
}
else if (dZPosRelToMerc < STANDING_TORSO_BOTTOM_POS )
{
ubHitLocation = AIM_SHOT_LEGS;
}
else
{
ubHitLocation = AIM_SHOT_TORSO;
}
}
break;
}
@@ -2491,18 +2513,38 @@ BOOLEAN BulletHitMerc( BULLET * pBullet, STRUCTURE * pStructure, BOOLEAN fIntend
{
dZPosRelToMerc -= HEIGHT_UNITS;
}
if (dZPosRelToMerc > CROUCHED_HEAD_BOTTOM_POS)
if ( iskid )
{
ubHitLocation = AIM_SHOT_HEAD;
}
else if ( dZPosRelToMerc < CROUCHED_TORSO_BOTTOM_POS )
{
// prevent targets in water from being hit in legs
ubHitLocation = AIM_SHOT_LEGS;
if (dZPosRelToMerc > CROUCHED_HEAD_BOTTOM_POS_KID)
{
ubHitLocation = AIM_SHOT_HEAD;
}
else if ( dZPosRelToMerc < CROUCHED_TORSO_BOTTOM_POS_KID )
{
// prevent targets in water from being hit in legs
ubHitLocation = AIM_SHOT_LEGS;
}
else
{
ubHitLocation = AIM_SHOT_TORSO;
}
}
else
{
ubHitLocation = AIM_SHOT_TORSO;
if (dZPosRelToMerc > CROUCHED_HEAD_BOTTOM_POS)
{
ubHitLocation = AIM_SHOT_HEAD;
}
else if ( dZPosRelToMerc < CROUCHED_TORSO_BOTTOM_POS )
{
// prevent targets in water from being hit in legs
ubHitLocation = AIM_SHOT_LEGS;
}
else
{
ubHitLocation = AIM_SHOT_TORSO;
}
}
break;
case ANIM_PRONE:
+6
View File
@@ -122,6 +122,12 @@ BOOLEAN CalculateSoldierZPos( SOLDIERTYPE * pSoldier, UINT8 ubPosType, FLOAT * p
#define STANDING_LEGS_TARGET_POS 47.0f
#define STANDING_TARGET_POS STANDING_HEAD_TARGET_POS
// Flugente: new defines for kid bodytypes
#define STANDING_HEAD_BOTTOM_POS_KID 111.0f
#define STANDING_TORSO_BOTTOM_POS_KID 67.0f
#define CROUCHED_HEAD_BOTTOM_POS_KID 78.0f
#define CROUCHED_TORSO_BOTTOM_POS_KID 33.0f
#define CROUCHED_HEIGHT 130.0f
#define CROUCHED_LOS_POS 111.0f
#define CROUCHED_FIRING_POS 111.0f