mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
Fixed buffer overrun for LUA strings
Made direction variables more consistent as unsigned chars. Several function prototypes updated for this. Many memory leaks plugged: External options, video overlays, laptop file lists, tactical message queue, strategic pathing, autobandage, merc hiring, detailed placements, crate in Drassen, tactical placement New functions and attributes for soldiers in LUA (still for debugging at best): Soldier.APs (current APs), Soldier.changestance (changes stance, uses game heights) File catalog ignores .SVN directories (game load speedup) Fix CTD in mouse regions JA2 window now refuses to move to negative coords Checks to prevent DirectX-related infinite loops due to minimizing and task switching Invading enemies should now appear on the borders even when reinforcements disabled in .ini Suppression should no longer work on mercs in medium water Infant/Young creatures use restored spit instead of Molotov Creatures begin with their 'guns' (spit) 'locked and loaded' (cartridge in chamber) Further fix to AXP and AlaarDB's weapon ready check: Now 'firing' is always counted as 'ready'. Prevent mercs from falling and flying back through obstacles Check whether battle group is even set before testing its location for battle setup Burst spread locations now limited to 6, the limit within the soldier struct Extra burst spread locations zeroed out so that they aren't used unless necessary Spread code now only shoots at locations in the spread, and will shoot at all 6 Only mercs in the sector where autobandage happens will be made to stand up after it's done Throwing a grenade at the tail of the plane in Drassen should not result in a CTD Reset attack busy count when loading a new sector git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1347 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -406,7 +406,7 @@ void GenerateExplosionFromExplosionPointer( EXPLOSIONTYPE *pExplosion )
|
||||
AniParams.sStartFrame = pExplosion->sCurrentFrame;
|
||||
AniParams.uiFlags = ANITILE_CACHEDTILE | ANITILE_FORWARD | ANITILE_EXPLOSION;
|
||||
|
||||
if ( ubTerrainType == LOW_WATER || ubTerrainType == MED_WATER || ubTerrainType == DEEP_WATER )
|
||||
if ( TERRAIN_IS_WATER(ubTerrainType) )
|
||||
{
|
||||
// Change type to water explosion...
|
||||
ubTypeID = WATER_BLAST;
|
||||
@@ -1209,7 +1209,6 @@ BOOLEAN ExplosiveDamageStructureAtGridNo( STRUCTURE * pCurrent, STRUCTURE **ppNe
|
||||
|
||||
STRUCTURE *gStruct;
|
||||
|
||||
// Lesh: somewhere here once I got CTD when militia stepped on mine in cambria sam
|
||||
void ExplosiveDamageGridNo( INT16 sGridNo, INT16 sWoundAmt, UINT32 uiDist, BOOLEAN *pfRecompileMovementCosts, BOOLEAN fOnlyWalls, INT8 bMultiStructSpecialFlag, BOOLEAN fSubSequentMultiTilesTransitionDamage, UINT8 ubOwner, INT8 bLevel )
|
||||
{
|
||||
STRUCTURE * pCurrent, *pNextCurrent, *pStructure;
|
||||
@@ -1233,7 +1232,7 @@ void ExplosiveDamageGridNo( INT16 sGridNo, INT16 sWoundAmt, UINT32 uiDist, BOOLE
|
||||
// (1) we might need to destroy the currently-examined structure
|
||||
while (pCurrent != NULL)
|
||||
{
|
||||
// ATE: These are for the chacks below for multi-structs....
|
||||
// ATE: These are for the checks below for multi-structs....
|
||||
pBaseStructure = FindBaseStructure( pCurrent );
|
||||
|
||||
if ( pBaseStructure )
|
||||
@@ -1243,7 +1242,6 @@ void ExplosiveDamageGridNo( INT16 sGridNo, INT16 sWoundAmt, UINT32 uiDist, BOOLE
|
||||
fMultiStructure = ( ( pBaseStructure->fFlags & STRUCTURE_MULTI ) != 0 );
|
||||
ppTile = (DB_STRUCTURE_TILE **) MemAlloc( sizeof( DB_STRUCTURE_TILE* ) * ubNumberOfTiles );
|
||||
|
||||
// Lesh: CTD was in next line once
|
||||
memcpy( ppTile, pBaseStructure->pDBStructureRef->ppTile, sizeof( DB_STRUCTURE_TILE* ) * ubNumberOfTiles );
|
||||
|
||||
if ( bMultiStructSpecialFlag == -1 )
|
||||
@@ -1271,7 +1269,7 @@ void ExplosiveDamageGridNo( INT16 sGridNo, INT16 sWoundAmt, UINT32 uiDist, BOOLE
|
||||
{
|
||||
fExplodeDamageReturn = ExplosiveDamageStructureAtGridNo( pCurrent, &pNextCurrent, sGridNo, sWoundAmt, uiDist, pfRecompileMovementCosts, fOnlyWalls, 0, ubOwner, bLevel );
|
||||
|
||||
// Are we overwritting damage due to multi-tile...?
|
||||
// Are we overwriting damage due to multi-tile...?
|
||||
if ( fExplodeDamageReturn )
|
||||
{
|
||||
if ( fSubSequentMultiTilesTransitionDamage == 2)
|
||||
@@ -1288,65 +1286,74 @@ void ExplosiveDamageGridNo( INT16 sGridNo, INT16 sWoundAmt, UINT32 uiDist, BOOLE
|
||||
{
|
||||
fToBreak = TRUE;
|
||||
}
|
||||
}
|
||||
//}
|
||||
|
||||
// OK, for multi-structs...
|
||||
// AND we took damage...
|
||||
if ( fMultiStructure && !fOnlyWalls && fExplodeDamageReturn == 0 )
|
||||
{
|
||||
// ATE: Don't after first attack...
|
||||
if ( uiDist > 1 )
|
||||
// 0verhaul: The following was combined with the previous code block. I don't think they intended to execute this
|
||||
// part unless fExplodeDamageReturn was actually set. When it was being executed, tossing a grenade just behind the
|
||||
// plane in Drassen, for instance, would cause an infinite recursion in this code. The reason is that the plane's
|
||||
// armor is (amazingly enough) stronger than a grenade blast can even damage. This code here seems to rely on the
|
||||
// structure in question being destroyed by the blast since it indiscriminently recurses on neighbors, creating a
|
||||
// ping pong on two adjacent parts of the plane. Probably the reason this was not found before is that fExplodeDamageReturn
|
||||
// was uninitialized before and usually was non-zero. Now it is initialized to false.
|
||||
|
||||
// OK, for multi-structs...
|
||||
// AND we took damage...
|
||||
if ( fMultiStructure && !fOnlyWalls && fExplodeDamageReturn == 0 )
|
||||
{
|
||||
if ( pBaseStructure )
|
||||
// ATE: Don't after first attack...
|
||||
if ( uiDist > 1 )
|
||||
{
|
||||
MemFree( ppTile );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
for ( ubLoop = BASE_TILE; ubLoop < ubNumberOfTiles; ubLoop++)
|
||||
{
|
||||
sNewGridNo = sBaseGridNo + ppTile[ubLoop]->sPosRelToBase;
|
||||
|
||||
// look in adjacent tiles
|
||||
for ( ubLoop2 = 0; ubLoop2 < NUM_WORLD_DIRECTIONS; ubLoop2++ )
|
||||
if ( pBaseStructure )
|
||||
{
|
||||
sNewGridNo2 = NewGridNo( sNewGridNo, DirectionInc( ubLoop2 ) );
|
||||
if ( sNewGridNo2 != sNewGridNo && sNewGridNo2 != sGridNo )
|
||||
MemFree( ppTile );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
for ( ubLoop = BASE_TILE; ubLoop < ubNumberOfTiles; ubLoop++)
|
||||
{
|
||||
sNewGridNo = sBaseGridNo + ppTile[ubLoop]->sPosRelToBase;
|
||||
|
||||
// look in adjacent tiles
|
||||
for ( ubLoop2 = 0; ubLoop2 < NUM_WORLD_DIRECTIONS; ubLoop2++ )
|
||||
{
|
||||
pStructure = FindStructure( sNewGridNo2, STRUCTURE_MULTI );
|
||||
if ( pStructure )
|
||||
sNewGridNo2 = NewGridNo( sNewGridNo, DirectionInc( ubLoop2 ) );
|
||||
if ( sNewGridNo2 != sNewGridNo && sNewGridNo2 != sGridNo )
|
||||
{
|
||||
fMultiStructSpecialFlag = ( ( pStructure->fFlags & STRUCTURE_SPECIAL ) != 0 );
|
||||
|
||||
if ( ( bMultiStructSpecialFlag == fMultiStructSpecialFlag ) )
|
||||
pStructure = FindStructure( sNewGridNo2, STRUCTURE_MULTI );
|
||||
if ( pStructure )
|
||||
{
|
||||
// If we just damaged it, use same damage value....
|
||||
if ( fMultiStructSpecialFlag )
|
||||
{
|
||||
ExplosiveDamageGridNo( sNewGridNo2, sWoundAmt, uiDist, pfRecompileMovementCosts, fOnlyWalls, bMultiStructSpecialFlag, 1, ubOwner, bLevel );
|
||||
}
|
||||
else
|
||||
{
|
||||
ExplosiveDamageGridNo( sNewGridNo2, sWoundAmt, uiDist, pfRecompileMovementCosts, fOnlyWalls, bMultiStructSpecialFlag, 2, ubOwner, bLevel );
|
||||
}
|
||||
fMultiStructSpecialFlag = ( ( pStructure->fFlags & STRUCTURE_SPECIAL ) != 0 );
|
||||
|
||||
if ( ( bMultiStructSpecialFlag == fMultiStructSpecialFlag ) )
|
||||
{
|
||||
InternalIgniteExplosion( ubOwner, CenterX( sNewGridNo2 ), CenterY( sNewGridNo2 ), 0, sNewGridNo2, RDX, FALSE, bLevel );
|
||||
}
|
||||
// If we just damaged it, use same damage value....
|
||||
if ( fMultiStructSpecialFlag )
|
||||
{
|
||||
ExplosiveDamageGridNo( sNewGridNo2, sWoundAmt, uiDist, pfRecompileMovementCosts, fOnlyWalls, bMultiStructSpecialFlag, 1, ubOwner, bLevel );
|
||||
}
|
||||
else
|
||||
{
|
||||
ExplosiveDamageGridNo( sNewGridNo2, sWoundAmt, uiDist, pfRecompileMovementCosts, fOnlyWalls, bMultiStructSpecialFlag, 2, ubOwner, bLevel );
|
||||
}
|
||||
|
||||
fToBreak = TRUE;
|
||||
{
|
||||
InternalIgniteExplosion( ubOwner, CenterX( sNewGridNo2 ), CenterY( sNewGridNo2 ), 0, sNewGridNo2, RDX, FALSE, bLevel );
|
||||
}
|
||||
|
||||
fToBreak = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( fToBreak )
|
||||
{
|
||||
break;
|
||||
if ( fToBreak )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2862,7 +2869,7 @@ void PerformItemAction( INT16 sGridNo, OBJECTTYPE * pObj )
|
||||
{
|
||||
|
||||
// stop the merc...
|
||||
EVENT_StopMerc( MercPtrs[ ubID ], MercPtrs[ ubID ]->sGridNo, MercPtrs[ ubID ]->bDirection );
|
||||
EVENT_StopMerc( MercPtrs[ ubID ], MercPtrs[ ubID ]->sGridNo, MercPtrs[ ubID ]->ubDirection );
|
||||
|
||||
switch( sGridNo )
|
||||
{
|
||||
@@ -3673,7 +3680,7 @@ UINT8 DetermineFlashbangEffect( SOLDIERTYPE *pSoldier, INT8 ubExplosionDir, BOOL
|
||||
INT8 bNumTurns;
|
||||
UINT16 usHeadItem1, usHeadItem2;
|
||||
|
||||
bNumTurns = FindNumTurnsBetweenDirs(pSoldier->bDirection, ubExplosionDir);
|
||||
bNumTurns = FindNumTurnsBetweenDirs(pSoldier->ubDirection, ubExplosionDir);
|
||||
usHeadItem1 = pSoldier->inv[ HEAD1POS ].usItem;
|
||||
usHeadItem2 = pSoldier->inv[ HEAD2POS ].usItem;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user