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:
Overhaul
2007-09-11 11:19:03 +00:00
parent 63a7b27b29
commit ffc70e9723
81 changed files with 972 additions and 679 deletions
+29 -29
View File
@@ -1151,7 +1151,7 @@ INT16 DistanceVisible( SOLDIERTYPE *pSoldier, INT8 bFacingDir, INT8 bSubjectDir,
bSubjectDir = (INT8) GetDirectionToGridNoFromGridNo( pSoldier->sGridNo, sSubjectGridNo );
}
if (bFacingDir == DIRECTION_IRRELEVANT) {
bFacingDir = pSoldier->bDirection;
bFacingDir = pSoldier->ubDirection;
}
sDistVisible = gbLookDistance[bFacingDir][bSubjectDir];
@@ -1205,8 +1205,8 @@ INT16 DistanceVisible( SOLDIERTYPE *pSoldier, INT8 bFacingDir, INT8 bSubjectDir,
// valid map references then use the ambient light level instead.
if(0 > sSubjectGridNo || sSubjectGridNo > WORLD_MAX)
{
DebugMsg(TOPIC_JA2, DBG_LEVEL_3, String("113/UC Warning! Tried to detect the light level when character %ls[%d] looks at a location outside of the valid map (gridno %d). Assigning default %d",
pSoldier->name, pSoldier->ubID, pSoldier->sGridNo, ubAmbientLightLevel));
DebugMsg(TOPIC_JA2, DBG_LEVEL_3, String("113/UC Warning! Tried to detect the light level when character %ls[%d] looks at a location outside of the valid map (gridno %d). Assigning default %d",
pSoldier->name, pSoldier->ubID, pSoldier->sGridNo, ubAmbientLightLevel));
bLightLevel = ubAmbientLightLevel;
}
@@ -1232,7 +1232,7 @@ INT16 DistanceVisible( SOLDIERTYPE *pSoldier, INT8 bFacingDir, INT8 bSubjectDir,
sDistVisible += sDistVisible * GetTotalVisionRangeBonus(pSoldier, bLightLevel) / 100;
}
// give one step better vision for people with nightops
if (HAS_SKILL_TRAIT( pSoldier, NIGHTOPS ))
{
@@ -1254,7 +1254,7 @@ INT16 DistanceVisible( SOLDIERTYPE *pSoldier, INT8 bFacingDir, INT8 bSubjectDir,
if ( TANK(pSoldier) && sDistVisible > 0 && pSubject)
{
sDistVisible = __max( sDistVisible + 5, pSubject->GetMaxDistanceVisible(pSoldier->sGridNo, pSoldier->bLevel) );
}
}
else {
sDistVisible = __max( sDistVisible + 5, pSoldier->GetMaxDistanceVisible() );
}
@@ -2111,7 +2111,7 @@ void ManSeesMan(SOLDIERTYPE *pSoldier, SOLDIERTYPE *pOpponent, INT16 sOppGridno,
{
CancelAIAction( pSoldier, TRUE );
pSoldier->sAbsoluteFinalDestination = NOWHERE;
EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection );
EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->ubDirection );
TriggerNPCRecord( ANGEL, 20 );
// trigger Angel to walk off afterwards
//TriggerNPCRecord( ANGEL, 24 );
@@ -3852,7 +3852,7 @@ void DebugSoldierPage2( )
SetFontShade(LARGEFONT1, FONT_SHADE_GREEN);
gprintf( 0, LINE_HEIGHT * ubLine, L"Direction:");
SetFontShade(LARGEFONT1, FONT_SHADE_NEUTRAL);
gprintf( 150, LINE_HEIGHT * ubLine, L"%S", gzDirectionStr[ pSoldier->bDirection] );
gprintf( 150, LINE_HEIGHT * ubLine, L"%S", gzDirectionStr[ pSoldier->ubDirection] );
ubLine++;
SetFontShade(LARGEFONT1, FONT_SHADE_GREEN);
@@ -5688,14 +5688,14 @@ void HearNoise(SOLDIERTYPE *pSoldier, UINT8 ubNoiseMaker, UINT16 sGridNo, INT8 b
sNoiseX = CenterX(sGridNo);
sNoiseY = CenterY(sGridNo);
bDirection = atan8(pSoldier->sX,pSoldier->sY,sNoiseX,sNoiseY);
if ( pSoldier->bDirection != bDirection && pSoldier->bDirection != gOneCDirection[ bDirection ] && pSoldier->bDirection != gOneCCDirection[ bDirection ] )
if ( pSoldier->ubDirection != bDirection && pSoldier->ubDirection != gOneCDirection[ bDirection ] && pSoldier->ubDirection != gOneCCDirection[ bDirection ] )
{
// temporarily turn off muzzle flash so DistanceVisible can be calculated without it
MercPtrs[ ubNoiseMaker ]->fMuzzleFlash = FALSE;
fMuzzleFlash = TRUE;
}
}
int sDistVisible = pSoldier->GetMaxDistanceVisible(sGridNo, bLevel, CALC_FROM_WANTED_DIR );
if ( fMuzzleFlash )
@@ -5703,14 +5703,14 @@ void HearNoise(SOLDIERTYPE *pSoldier, UINT8 ubNoiseMaker, UINT16 sGridNo, INT8 b
// turn flash on again
MercPtrs[ ubNoiseMaker ]->fMuzzleFlash = TRUE;
}
if (PythSpacesAway(pSoldier->sGridNo,sGridNo) <= sDistVisible )
{
// just use the XXadjustedXX center of the gridno
sNoiseX = CenterX(sGridNo);
sNoiseY = CenterY(sGridNo);
if (pSoldier->bDirection != atan8(pSoldier->sX,pSoldier->sY,sNoiseX,sNoiseY))
if (pSoldier->ubDirection != atan8(pSoldier->sX,pSoldier->sY,sNoiseX,sNoiseY))
{
bHadToTurn = TRUE;
}
@@ -6530,27 +6530,27 @@ void NoticeUnseenAttacker( SOLDIERTYPE * pAttacker, SOLDIERTYPE * pDefender, INT
}
bOldOppList = pDefender->bOppList[ pAttacker->ubID ];
// check LOS, considering we are now aware of the attacker
// ignore muzzle flashes when must turning head
if ( pAttacker->fMuzzleFlash )
{
bDirection = atan8( pDefender->sX,pDefender->sY, pAttacker->sX, pAttacker->sY );
if ( pDefender->bDirection != bDirection && pDefender->bDirection != gOneCDirection[ bDirection ] && pDefender->bDirection != gOneCCDirection[ bDirection ] )
// check LOS, considering we are now aware of the attacker
// ignore muzzle flashes when must turning head
if ( pAttacker->fMuzzleFlash )
{
// temporarily turn off muzzle flash so DistanceVisible can be calculated without it
pAttacker->fMuzzleFlash = FALSE;
fMuzzleFlash = TRUE;
bDirection = atan8( pDefender->sX,pDefender->sY, pAttacker->sX, pAttacker->sY );
if ( pDefender->ubDirection != bDirection && pDefender->ubDirection != gOneCDirection[ bDirection ] && pDefender->ubDirection != gOneCCDirection[ bDirection ] )
{
// temporarily turn off muzzle flash so DistanceVisible can be calculated without it
pAttacker->fMuzzleFlash = FALSE;
fMuzzleFlash = TRUE;
}
}
}
if (SoldierToSoldierLineOfSightTest( pDefender, pAttacker, TRUE, CALC_FROM_WANTED_DIR ) != 0)
{
fSeesAttacker = TRUE;
}
if ( fMuzzleFlash )
{
pAttacker->fMuzzleFlash = TRUE;
}
{
fSeesAttacker = TRUE;
}
if ( fMuzzleFlash )
{
pAttacker->fMuzzleFlash = TRUE;
}
if (fSeesAttacker)
{
@@ -7011,4 +7011,4 @@ BOOLEAN SoldierHasLimitedVision(SOLDIERTYPE * pSoldier)
return TRUE;
else
return FALSE;
}
}