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
+19 -19
View File
@@ -44,7 +44,7 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
UINT32 uiLoop2;
INT16 sTempGridNo, sNextTempGridNo, sVeryTemporaryGridNo;
INT16 sStartGridNo, sCurrGridNo, sPrevGridNo = NOWHERE, sRightGridNo;
INT8 bDirection, bTempDirection;
UINT8 ubDirection, ubTempDirection;
BOOLEAN fFoundDir, fFoundWall;
UINT32 uiChanceIn = ROOF_LOCATION_CHANCE; // chance of a location being considered
INT16 sWallGridNo;
@@ -77,13 +77,13 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
RoofReachableTest( sDesiredSpot, ubBuildingID );
// From sGridNo, search until we find a spot that isn't part of the building
bDirection = NORTHWEST;
ubDirection = NORTHWEST;
sTempGridNo = sDesiredSpot;
// using diagonal directions to hopefully prevent picking a
// spot that
while( (gpWorldLevelData[ sTempGridNo ].uiFlags & MAPELEMENT_REACHABLE ) )
{
sNextTempGridNo = NewGridNo( sTempGridNo, DirectionInc( bDirection ) );
sNextTempGridNo = NewGridNo( sTempGridNo, DirectionInc( ubDirection ) );
if ( sTempGridNo == sNextTempGridNo )
{
// hit edge of map!??!
@@ -103,12 +103,12 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
if ( gpWorldLevelData[ sVeryTemporaryGridNo ].uiFlags & MAPELEMENT_REACHABLE )
{
// go north first
bDirection = NORTH;
ubDirection = NORTH;
}
else
{
// go that way (east)
bDirection = EAST;
ubDirection = EAST;
}
gpWorldLevelData[ sStartGridNo ].ubExtFlags[0] |= MAPELEMENT_EXT_ROOFCODE_VISITED;
@@ -118,7 +118,7 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
{
// if point to (2 clockwise) is not part of building and is not visited,
// or is starting point, turn!
sRightGridNo = NewGridNo( sCurrGridNo, DirectionInc( gTwoCDirection[ bDirection ] ) );
sRightGridNo = NewGridNo( sCurrGridNo, DirectionInc( gTwoCDirection[ ubDirection ] ) );
sTempGridNo = sRightGridNo;
if ( ( ( !(gpWorldLevelData[ sTempGridNo ].uiFlags & MAPELEMENT_REACHABLE) && !(gpWorldLevelData[ sTempGridNo ].ubExtFlags[0] & MAPELEMENT_EXT_ROOFCODE_VISITED) ) || (sTempGridNo == sStartGridNo) ) && (sCurrGridNo != sStartGridNo) )
{
@@ -128,47 +128,47 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
{
return( NULL );
}
bDirection = gTwoCDirection[ bDirection ];
ubDirection = gTwoCDirection[ ubDirection ];
// try in that direction
continue;
}
iLoopCount = 0;
// if spot ahead is part of building, turn
sTempGridNo = NewGridNo( sCurrGridNo, DirectionInc( bDirection ) );
sTempGridNo = NewGridNo( sCurrGridNo, DirectionInc( ubDirection ) );
if ( gpWorldLevelData[ sTempGridNo ].uiFlags & MAPELEMENT_REACHABLE )
{
// first search for a spot that is neither part of the building or visited
// we KNOW that the spot in the original direction is blocked, so only loop 3 times
bTempDirection = gTwoCDirection[ bDirection ];
ubTempDirection = gTwoCDirection[ ubDirection ];
fFoundDir = FALSE;
for ( uiLoop = 0; uiLoop < 3; uiLoop++ )
{
sTempGridNo = NewGridNo( sCurrGridNo, DirectionInc( bTempDirection ) );
sTempGridNo = NewGridNo( sCurrGridNo, DirectionInc( ubTempDirection ) );
if ( !(gpWorldLevelData[ sTempGridNo ].uiFlags & MAPELEMENT_REACHABLE) && !(gpWorldLevelData[ sTempGridNo ].ubExtFlags[0] & MAPELEMENT_EXT_ROOFCODE_VISITED) )
{
// this is the way to go!
fFoundDir = TRUE;
break;
}
bTempDirection = gTwoCDirection[ bTempDirection ];
ubTempDirection = gTwoCDirection[ ubTempDirection ];
}
if (!fFoundDir)
{
// now search for a spot that is just not part of the building
bTempDirection = gTwoCDirection[ bDirection ];
ubTempDirection = gTwoCDirection[ ubDirection ];
fFoundDir = FALSE;
for ( uiLoop = 0; uiLoop < 3; uiLoop++ )
{
sTempGridNo = NewGridNo( sCurrGridNo, DirectionInc( bTempDirection ) );
sTempGridNo = NewGridNo( sCurrGridNo, DirectionInc( ubTempDirection ) );
if ( !(gpWorldLevelData[ sTempGridNo ].uiFlags & MAPELEMENT_REACHABLE) )
{
// this is the way to go!
fFoundDir = TRUE;
break;
}
bTempDirection = gTwoCDirection[ bTempDirection ];
ubTempDirection = gTwoCDirection[ ubTempDirection ];
}
if (!fFoundDir)
{
@@ -176,7 +176,7 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
return( NULL );
}
}
bDirection = bTempDirection;
ubDirection = ubTempDirection;
// try in that direction
continue;
}
@@ -184,7 +184,7 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
// move ahead
sPrevGridNo = sCurrGridNo;
sCurrGridNo = sTempGridNo;
sRightGridNo = NewGridNo( sCurrGridNo, DirectionInc( gTwoCDirection[ bDirection ] ) );
sRightGridNo = NewGridNo( sCurrGridNo, DirectionInc( gTwoCDirection[ ubDirection ] ) );
#ifdef ROOF_DEBUG
if (gsCoverValue[sCurrGridNo] == 0x7F7F)
@@ -219,7 +219,7 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
// if south or west, the wall would be in the gridno two clockwise
fFoundWall = FALSE;
switch( bDirection )
switch( ubDirection )
{
case NORTH:
sWallGridNo = sCurrGridNo;
@@ -230,11 +230,11 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
bDesiredOrientation = OUTSIDE_TOP_LEFT;
break;
case SOUTH:
sWallGridNo = (INT16) ( sCurrGridNo + DirectionInc( gTwoCDirection[ bDirection ] ) );
sWallGridNo = (INT16) ( sCurrGridNo + DirectionInc( gTwoCDirection[ ubDirection ] ) );
bDesiredOrientation = OUTSIDE_TOP_RIGHT;
break;
case WEST:
sWallGridNo = (INT16) ( sCurrGridNo + DirectionInc( gTwoCDirection[ bDirection ] ) );
sWallGridNo = (INT16) ( sCurrGridNo + DirectionInc( gTwoCDirection[ ubDirection ] ) );
bDesiredOrientation = OUTSIDE_TOP_LEFT;
break;
default: