Fix to prevent rain and storm from happening at once

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1534 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Overhaul
2007-10-20 08:28:50 +00:00
parent 035359edf0
commit 4bb41616eb
16 changed files with 249 additions and 142 deletions
+113 -27
View File
@@ -22,6 +22,12 @@ UINT8 gubBuildingInfo[ WORLD_MAX ];
BUILDING gBuildings[ MAX_BUILDINGS ]; BUILDING gBuildings[ MAX_BUILDINGS ];
UINT8 gubNumberOfBuildings; UINT8 gubNumberOfBuildings;
#ifdef ROOF_DEBUG
extern INT16 gsCoverValue[WORLD_MAX];
#include "video.h"
#include "renderworld.h"
#endif
BUILDING * CreateNewBuilding( UINT8 * pubBuilding ) BUILDING * CreateNewBuilding( UINT8 * pubBuilding )
{ {
if (gubNumberOfBuildings + 1 >= MAX_BUILDINGS) if (gubNumberOfBuildings + 1 >= MAX_BUILDINGS)
@@ -40,6 +46,7 @@ BUILDING * CreateNewBuilding( UINT8 * pubBuilding )
BUILDING * GenerateBuilding( INT16 sDesiredSpot ) BUILDING * GenerateBuilding( INT16 sDesiredSpot )
{ {
#if 0
UINT32 uiLoop; UINT32 uiLoop;
UINT32 uiLoop2; UINT32 uiLoop2;
INT16 sTempGridNo, sNextTempGridNo, sVeryTemporaryGridNo; INT16 sTempGridNo, sNextTempGridNo, sVeryTemporaryGridNo;
@@ -51,9 +58,10 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
INT8 bDesiredOrientation; INT8 bDesiredOrientation;
INT8 bSkipSpots = 0; INT8 bSkipSpots = 0;
SOLDIERTYPE FakeSoldier; SOLDIERTYPE FakeSoldier;
#endif
BUILDING * pBuilding; BUILDING * pBuilding;
UINT8 ubBuildingID = 0; UINT8 ubBuildingID = 0;
INT32 iLoopCount = 0; //INT32 iLoopCount = 0;
pBuilding = CreateNewBuilding( &ubBuildingID ); pBuilding = CreateNewBuilding( &ubBuildingID );
if (!pBuilding) if (!pBuilding)
@@ -64,18 +72,21 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
// WDS - Clean up inventory handling // WDS - Clean up inventory handling
// set up fake soldier for location testing // set up fake soldier for location testing
// memset( &FakeSoldier, 0, SIZEOF_SOLDIERTYPE ); // memset( &FakeSoldier, 0, SIZEOF_SOLDIERTYPE );
#if 0
FakeSoldier.initialize(); FakeSoldier.initialize();
FakeSoldier.sGridNo = sDesiredSpot; FakeSoldier.sGridNo = sDesiredSpot;
FakeSoldier.bLevel = 1; FakeSoldier.bLevel = 1;
FakeSoldier.bTeam = 1; FakeSoldier.bTeam = 1;
#ifdef ROOF_DEBUG
memset( gsCoverValue, 0x7F, sizeof( INT16 ) * WORLD_MAX );
#endif #endif
// Set reachable // Set reachable
RoofReachableTest( sDesiredSpot, ubBuildingID ); RoofReachableTest( sDesiredSpot, ubBuildingID );
// 0verhaul: The RoofReachableTest now finds ALL of the climb points for each climbable building, instead of a max of
// 21 climb points (and a min of 0) for each building. It claims an extended map flag to mark a tile as a climb point.
// So the array of up-climbs and down-climbs is now obsolete. FindClosestClimbPoint is now updated to search the map
// for these flags.
#if 0
// From sGridNo, search until we find a spot that isn't part of the building // From sGridNo, search until we find a spot that isn't part of the building
ubDirection = NORTHWEST; ubDirection = NORTHWEST;
sTempGridNo = sDesiredSpot; sTempGridNo = sDesiredSpot;
@@ -196,7 +207,7 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
gsCoverValue[sCurrGridNo]++; gsCoverValue[sCurrGridNo]++;
} }
DebugAI( String( "Roof code visits %d", sCurrGridNo ) ); //DebugAI( String( "Roof code visits %d", sCurrGridNo ) );
#endif #endif
if (sCurrGridNo == sStartGridNo) if (sCurrGridNo == sStartGridNo)
@@ -219,8 +230,13 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
// if south or west, the wall would be in the gridno two clockwise // if south or west, the wall would be in the gridno two clockwise
fFoundWall = FALSE; fFoundWall = FALSE;
switch( ubDirection ) // There must not be roof here either. There are places where a pitched roof butts up against a flat roof.
// Don't mark such a border as a climb point. Otherwise AI units will get stuck.
if (FindStructure( sCurrGridNo, STRUCTURE_ROOF ) == NULL &&
NewOKDestination( &FakeSoldier, sCurrGridNo, FALSE, 0 ) )
{ {
switch( ubDirection )
{
case NORTH: case NORTH:
sWallGridNo = sCurrGridNo; sWallGridNo = sCurrGridNo;
bDesiredOrientation = OUTSIDE_TOP_RIGHT; bDesiredOrientation = OUTSIDE_TOP_RIGHT;
@@ -240,25 +256,28 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
default: default:
// what the heck? // what the heck?
return( NULL ); return( NULL );
} }
if (bDesiredOrientation == OUTSIDE_TOP_LEFT) if (bDesiredOrientation == OUTSIDE_TOP_LEFT)
{
if (WallExistsOfTopLeftOrientation( sWallGridNo ))
{ {
fFoundWall = TRUE; if (WallExistsOfTopLeftOrientation( sWallGridNo ))
{
fFoundWall = TRUE;
}
}
else
{
if (WallExistsOfTopRightOrientation( sWallGridNo ))
{
fFoundWall = TRUE;
}
} }
} }
else
{
if (WallExistsOfTopRightOrientation( sWallGridNo ))
{
fFoundWall = TRUE;
}
}
if (fFoundWall) if (fFoundWall)
{ {
#ifdef ROOF_DEBUG
gsCoverValue[sCurrGridNo] = 50;
#endif
if (bSkipSpots > 0) if (bSkipSpots > 0)
{ {
bSkipSpots--; bSkipSpots--;
@@ -266,7 +285,7 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
else if ( Random( uiChanceIn ) == 0 ) else if ( Random( uiChanceIn ) == 0 )
{ {
// don't consider people as obstacles // don't consider people as obstacles
if ( NewOKDestination( &FakeSoldier, sCurrGridNo, FALSE, 0 ) ) //if ( NewOKDestination( &FakeSoldier, sCurrGridNo, FALSE, 0 ) )
{ {
pBuilding->sUpClimbSpots[ pBuilding->ubNumClimbSpots ] = sCurrGridNo; pBuilding->sUpClimbSpots[ pBuilding->ubNumClimbSpots ] = sCurrGridNo;
pBuilding->sDownClimbSpots[ pBuilding->ubNumClimbSpots ] = sRightGridNo; pBuilding->sDownClimbSpots[ pBuilding->ubNumClimbSpots ] = sRightGridNo;
@@ -286,13 +305,13 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
// skip the next spot // skip the next spot
bSkipSpots = 1; bSkipSpots = 1;
} }
else //else
{ //{
// if location is not added, 100% chance of handling next location // if location is not added, 100% chance of handling next location
// and the next until we can add one // and the next until we can add one
uiChanceIn = 1; // uiChanceIn = 1;
} //}
} }
else else
{ {
@@ -326,7 +345,6 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
// skip the next gridno // skip the next gridno
bSkipSpots = 1; bSkipSpots = 1;
} }
} }
uiLoop2++; uiLoop2++;
} }
@@ -351,12 +369,13 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
#ifdef ROOF_DEBUG #ifdef ROOF_DEBUG
SetRenderFlags( RENDER_FLAG_FULL ); SetRenderFlags( RENDER_FLAG_FULL );
RenderWorld(); RenderWorld();
RenderCoverDebug( ); //RenderCoverDebug( );
InvalidateScreen( ); InvalidateScreen( );
EndFrameBufferRender(); EndFrameBufferRender();
RefreshScreen( NULL ); RefreshScreen( NULL );
#endif #endif
*/ */
#endif
return( pBuilding ); return( pBuilding );
} }
@@ -422,6 +441,10 @@ void GenerateBuildings( void )
return; return;
} }
#ifdef ROOF_DEBUG
memset( gsCoverValue, 0x7F, sizeof( INT16 ) * WORLD_MAX );
#endif
// reset ALL reachable flags // reset ALL reachable flags
// do once before we start building generation for // do once before we start building generation for
// whole map // whole map
@@ -445,9 +468,15 @@ void GenerateBuildings( void )
INT16 FindClosestClimbPoint( SOLDIERTYPE *pSoldier, INT16 sStartGridNo, INT16 sDesiredGridNo, BOOLEAN fClimbUp ) INT16 FindClosestClimbPoint( SOLDIERTYPE *pSoldier, INT16 sStartGridNo, INT16 sDesiredGridNo, BOOLEAN fClimbUp )
{ {
BUILDING * pBuilding; BUILDING * pBuilding;
#if 1
INT16 sGridNo;
INT16 sTestGridNo;
UINT8 ubTestDir;
#else
UINT8 ubNumClimbSpots; UINT8 ubNumClimbSpots;
INT16 * psClimbSpots; INT16 * psClimbSpots;
UINT8 ubLoop; UINT8 ubLoop;
#endif
INT16 sDistance, sClosestDistance = 1000, sClosestSpot= NOWHERE; INT16 sDistance, sClosestDistance = 1000, sClosestSpot= NOWHERE;
pBuilding = FindBuilding( sDesiredGridNo ); pBuilding = FindBuilding( sDesiredGridNo );
@@ -456,6 +485,62 @@ INT16 FindClosestClimbPoint( SOLDIERTYPE *pSoldier, INT16 sStartGridNo, INT16 sD
return( NOWHERE ); return( NOWHERE );
} }
#if 1
for (sGridNo = 0; sGridNo < WORLD_MAX; sGridNo++)
{
if (gubBuildingInfo[ sGridNo ] == gubBuildingInfo[ sDesiredGridNo ] &&
gpWorldLevelData[ sGridNo ].ubExtFlags[1] & MAPELEMENT_EXT_CLIMBPOINT)
{
// Found a climb point for this building
if (fClimbUp)
{
for (ubTestDir = 0; ubTestDir < 8; ubTestDir += 2)
{
sTestGridNo = NewGridNo( sGridNo, DirectionInc( ubTestDir));
if (gpWorldLevelData[ sTestGridNo ].ubExtFlags[0] & MAPELEMENT_EXT_CLIMBPOINT)
{
// Found a matching climb point
if ( (WhoIsThere2( sTestGridNo, 0 ) == NOBODY || sTestGridNo == pSoldier->sGridNo)
&& (WhoIsThere2( sGridNo, 1 ) == NOBODY) &&
(!pSoldier || !InGas( pSoldier, sTestGridNo ) ) )
{
// And it's open
sDistance = PythSpacesAway( sStartGridNo, sTestGridNo );
if (sDistance < sClosestDistance )
{
sClosestDistance = sDistance;
sClosestSpot = sTestGridNo;
}
}
}
}
}
else
{
for (ubTestDir = 0; ubTestDir < 8; ubTestDir += 2)
{
sTestGridNo = NewGridNo( sGridNo, DirectionInc( ubTestDir));
if (gpWorldLevelData[ sTestGridNo ].ubExtFlags[0] & MAPELEMENT_EXT_CLIMBPOINT)
{
// Found a matching climb point
if ( (WhoIsThere2( sTestGridNo, 0 ) == NOBODY) &&
(WhoIsThere2( sGridNo, 1 ) == NOBODY || sGridNo == pSoldier->sGridNo) &&
(!pSoldier || !InGas( pSoldier, sTestGridNo ) ) )
{
// And it's open
sDistance = PythSpacesAway( sStartGridNo, sGridNo );
if (sDistance < sClosestDistance )
{
sClosestDistance = sDistance;
sClosestSpot = sGridNo;
}
}
}
}
}
}
}
#else
ubNumClimbSpots = pBuilding->ubNumClimbSpots; ubNumClimbSpots = pBuilding->ubNumClimbSpots;
if (fClimbUp) if (fClimbUp)
@@ -481,6 +566,7 @@ INT16 FindClosestClimbPoint( SOLDIERTYPE *pSoldier, INT16 sStartGridNo, INT16 sD
} }
} }
} }
#endif
return( sClosestSpot ); return( sClosestSpot );
} }
+4 -5
View File
@@ -246,9 +246,6 @@ UINT16 FindGridNoFromSweetSpotCloseToExitGrid( SOLDIERTYPE *pSoldier, INT16 sSwe
EXITGRID ExitGrid; EXITGRID ExitGrid;
UINT8 ubGotoSectorX, ubGotoSectorY, ubGotoSectorZ; UINT8 ubGotoSectorX, ubGotoSectorY, ubGotoSectorZ;
// Turn off at end of function...
gfPlotPathToExitGrid = TRUE;
//Save AI pathing vars. changing the distlimit restricts how //Save AI pathing vars. changing the distlimit restricts how
//far away the pathing will consider. //far away the pathing will consider.
ubSaveNPCAPBudget = gubNPCAPBudget; ubSaveNPCAPBudget = gubNPCAPBudget;
@@ -296,10 +293,14 @@ UINT16 FindGridNoFromSweetSpotCloseToExitGrid( SOLDIERTYPE *pSoldier, INT16 sSwe
} }
} }
gfPlotPathToExitGrid = TRUE;
//Now, find out which of these gridnos are reachable //Now, find out which of these gridnos are reachable
//(use the fake soldier and the pathing settings) //(use the fake soldier and the pathing settings)
FindBestPath( &soldier, NOWHERE, 0, WALKING, COPYREACHABLE, PATH_THROUGH_PEOPLE ); FindBestPath( &soldier, NOWHERE, 0, WALKING, COPYREACHABLE, PATH_THROUGH_PEOPLE );
gfPlotPathToExitGrid = FALSE;
uiLowestRange = 999999; uiLowestRange = 999999;
for( cnt1 = sBottom; cnt1 <= sTop; cnt1++ ) for( cnt1 = sBottom; cnt1 <= sTop; cnt1++ )
@@ -339,8 +340,6 @@ UINT16 FindGridNoFromSweetSpotCloseToExitGrid( SOLDIERTYPE *pSoldier, INT16 sSwe
gubNPCAPBudget = ubSaveNPCAPBudget; gubNPCAPBudget = ubSaveNPCAPBudget;
gubNPCDistLimit = ubSaveNPCDistLimit; gubNPCDistLimit = ubSaveNPCDistLimit;
gfPlotPathToExitGrid = FALSE;
if ( fFound ) if ( fFound )
{ {
// Set direction to center of map! // Set direction to center of map!
+16 -11
View File
@@ -500,8 +500,8 @@ void UpdateExplosionFrame( INT32 iIndex, INT16 sCurrentFrame )
if ( gExplosionData[iIndex].iLightID != -1 ) if ( gExplosionData[iIndex].iLightID != -1 )
{ {
INT16 iX, iY; INT16 iX, iY;
iX = gExplosionData[iIndex].Params.sX/CELL_X_SIZE + Random(3) - 1; iX = (INT16) (gExplosionData[iIndex].Params.sX/CELL_X_SIZE + Random(3) - 1);
iY = gExplosionData[iIndex].Params.sY/CELL_Y_SIZE + Random(3) - 1; iY = (INT16) (gExplosionData[iIndex].Params.sY/CELL_Y_SIZE + Random(3) - 1);
LightSpritePosition( gExplosionData[iIndex].iLightID, iX, iY); LightSpritePosition( gExplosionData[iIndex].iLightID, iX, iY);
} }
} }
@@ -1523,12 +1523,14 @@ BOOLEAN DishOutGasDamage( SOLDIERTYPE * pSoldier, EXPLOSIVETYPE * pExplosive, IN
if ( sWoundAmt > 1 ) if ( sWoundAmt > 1 )
{ {
pSoldier->inv[ bPosOfMask ].ItemData.Generic.bStatus[0] -= (INT8) Random( 4 ); pSoldier->inv[ bPosOfMask ].ItemData.Generic.bStatus[0] =
pSoldier->inv[ bPosOfMask ].ItemData.Generic.bStatus[0] - (INT8) Random( 4 );
sWoundAmt = ( sWoundAmt * ( 100 - pSoldier->inv[ bPosOfMask ].ItemData.Generic.bStatus[0] ) ) / 100; sWoundAmt = ( sWoundAmt * ( 100 - pSoldier->inv[ bPosOfMask ].ItemData.Generic.bStatus[0] ) ) / 100;
} }
else if ( sWoundAmt == 1 ) else if ( sWoundAmt == 1 )
{ {
pSoldier->inv[ bPosOfMask ].ItemData.Generic.bStatus[0] -= (INT8) Random( 2 ); pSoldier->inv[ bPosOfMask ].ItemData.Generic.bStatus[0] =
pSoldier->inv[ bPosOfMask ].ItemData.Generic.bStatus[0] - (INT8) Random( 2 );
} }
} }
} }
@@ -1539,12 +1541,14 @@ BOOLEAN DishOutGasDamage( SOLDIERTYPE * pSoldier, EXPLOSIVETYPE * pExplosive, IN
{ {
if ( sWoundAmt == 1 ) if ( sWoundAmt == 1 )
{ {
pSoldier->inv[ bPosOfMask ].ItemData.Generic.bStatus[0] -= (INT8) Random( 2 ); pSoldier->inv[ bPosOfMask ].ItemData.Generic.bStatus[0] =
pSoldier->inv[ bPosOfMask ].ItemData.Generic.bStatus[0] - (INT8) Random( 2 );
} }
else else
{ {
// use up gas mask // use up gas mask
pSoldier->inv[ bPosOfMask ].ItemData.Generic.bStatus[0] -= (INT8) Random( 4 ); pSoldier->inv[ bPosOfMask ].ItemData.Generic.bStatus[0] =
pSoldier->inv[ bPosOfMask ].ItemData.Generic.bStatus[0] - (INT8) Random( 4 );
} }
} }
sWoundAmt = 0; sWoundAmt = 0;
@@ -1593,7 +1597,7 @@ BOOLEAN DishOutGasDamage( SOLDIERTYPE * pSoldier, EXPLOSIVETYPE * pExplosive, IN
BOOLEAN ExpAffect( INT16 sBombGridNo, INT16 sGridNo, UINT32 uiDist, UINT16 usItem, UINT8 ubOwner, INT16 sSubsequent, BOOLEAN *pfMercHit, INT8 bLevel, INT32 iSmokeEffectID ) BOOLEAN ExpAffect( INT16 sBombGridNo, INT16 sGridNo, UINT32 uiDist, UINT16 usItem, UINT8 ubOwner, INT16 sSubsequent, BOOLEAN *pfMercHit, INT8 bLevel, INT32 iSmokeEffectID )
{ {
INT16 sWoundAmt = 0,sBreathAmt = 0, sNewWoundAmt = 0, sNewBreathAmt = 0, sStructDmgAmt; INT16 sWoundAmt = 0,sBreathAmt = 0, /* sNewWoundAmt = 0, sNewBreathAmt = 0, */ sStructDmgAmt;
UINT8 ubPerson; UINT8 ubPerson;
SOLDIERTYPE *pSoldier; SOLDIERTYPE *pSoldier;
EXPLOSIVETYPE *pExplosive; EXPLOSIVETYPE *pExplosive;
@@ -1701,8 +1705,8 @@ BOOLEAN ExpAffect( INT16 sBombGridNo, INT16 sGridNo, UINT32 uiDist, UINT16 usIte
else if (uiDist < pExplosive->ubRadius) else if (uiDist < pExplosive->ubRadius)
{ {
// if radius is 5, go down by 5ths ~ 20% // if radius is 5, go down by 5ths ~ 20%
sWoundAmt -= (INT16) (sWoundAmt * uiDist / pExplosive->ubRadius ); sWoundAmt = sWoundAmt - (INT16) (sWoundAmt * uiDist / pExplosive->ubRadius );
sBreathAmt -= (INT16) (sBreathAmt * uiDist / pExplosive->ubRadius ); sBreathAmt = sBreathAmt - (INT16) (sBreathAmt * uiDist / pExplosive->ubRadius );
} }
else else
{ {
@@ -3400,7 +3404,7 @@ BOOLEAN SaveExplosionTableToSaveGameFile( HWFILE hFile )
BOOLEAN LoadExplosionTableFromSavedGameFile( HWFILE hFile ) BOOLEAN LoadExplosionTableFromSavedGameFile( HWFILE hFile )
{ {
UINT32 uiNumBytesRead; UINT32 uiNumBytesRead;
UINT32 uiExplosionCount=0; //UINT32 uiExplosionCount=0;
UINT32 uiCnt; UINT32 uiCnt;
@@ -3508,7 +3512,8 @@ void UpdateAndDamageSAMIfFound( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ,
if ( StrategicMap[ sSectorNo ].bSAMCondition >= ubDamage ) if ( StrategicMap[ sSectorNo ].bSAMCondition >= ubDamage )
{ {
StrategicMap[ sSectorNo ].bSAMCondition -= ubDamage; StrategicMap[ sSectorNo ].bSAMCondition =
StrategicMap[ sSectorNo ].bSAMCondition - ubDamage;
} }
else else
{ {
+5 -5
View File
@@ -219,7 +219,7 @@ BOOLEAN SoldierHandleInteractiveObject( SOLDIERTYPE *pSoldier )
void HandleStructChangeFromGridNo( SOLDIERTYPE *pSoldier, INT16 sGridNo ) void HandleStructChangeFromGridNo( SOLDIERTYPE *pSoldier, INT16 sGridNo )
{ {
STRUCTURE *pStructure, *pNewStructure; STRUCTURE *pStructure, *pNewStructure;
INT16 sAPCost = 0, sBPCost = 0; //INT16 sAPCost = 0, sBPCost = 0;
ITEM_POOL *pItemPool; ITEM_POOL *pItemPool;
BOOLEAN fDidMissingQuote = FALSE; BOOLEAN fDidMissingQuote = FALSE;
@@ -472,9 +472,9 @@ void GetLevelNodeScreenRect( LEVELNODE *pNode, SGPRect *pRect, INT16 sXPos, INT1
sScreenY = ( ( gsVIEWPORT_END_Y - gsVIEWPORT_START_Y ) /2 ) + (INT16)sTempY_S; sScreenY = ( ( gsVIEWPORT_END_Y - gsVIEWPORT_START_Y ) /2 ) + (INT16)sTempY_S;
// Adjust for offset position on screen // Adjust for offset position on screen
sScreenX -= gsRenderWorldOffsetX; sScreenX = sScreenX - gsRenderWorldOffsetX;
sScreenY -= gsRenderWorldOffsetY; sScreenY = sScreenY - gsRenderWorldOffsetY;
sScreenY -= gpWorldLevelData[ sGridNo ].sHeight; sScreenY = sScreenY - gpWorldLevelData[ sGridNo ].sHeight;
// Adjust based on interface level // Adjust based on interface level
if ( gsInterfaceLevel > 0 ) if ( gsInterfaceLevel > 0 )
@@ -483,7 +483,7 @@ void GetLevelNodeScreenRect( LEVELNODE *pNode, SGPRect *pRect, INT16 sXPos, INT1
} }
// Adjust for render height // Adjust for render height
sScreenY += gsRenderHeight; sScreenY = sScreenY + gsRenderHeight;
+18 -15
View File
@@ -186,6 +186,9 @@ UINT8 gPurpendicularDirection[ NUM_WORLD_DIRECTIONS ][ NUM_WORLD_DIRECTIONS ] =
}; };
GridNode::MapXY_t GridNode::MapXY;
static GridNode::MapXY_t *pMapXY = GridNode::initGridNodes(); // A hack to initialize the MapXY grid
void FromCellToScreenCoordinates( INT16 sCellX, INT16 sCellY, INT16 *psScreenX, INT16 *psScreenY ) void FromCellToScreenCoordinates( INT16 sCellX, INT16 sCellY, INT16 *psScreenX, INT16 *psScreenY )
{ {
*psScreenX = ( 2 * sCellX ) - ( 2 * sCellY ); *psScreenX = ( 2 * sCellX ) - ( 2 * sCellY );
@@ -457,8 +460,8 @@ void GetWorldXYAbsoluteScreenXY( INT32 sWorldCellX, INT32 sWorldCellY, INT16 *ps
INT16 sDistToCenterY, sDistToCenterX; INT16 sDistToCenterY, sDistToCenterX;
// Find the diustance from render center to true world center // Find the diustance from render center to true world center
sDistToCenterX = ( sWorldCellX * CELL_X_SIZE ) - gCenterWorldX; sDistToCenterX = (INT16) ( ( sWorldCellX * CELL_X_SIZE ) - gCenterWorldX);
sDistToCenterY = ( sWorldCellY * CELL_Y_SIZE ) - gCenterWorldY; sDistToCenterY = (INT16) ( ( sWorldCellY * CELL_Y_SIZE ) - gCenterWorldY);
// From render center in world coords, convert to render center in "screen" coords // From render center in world coords, convert to render center in "screen" coords
@@ -551,7 +554,7 @@ INT16 NewGridNo(INT16 sGridno, INT16 sDirInc)
INT16 DirectionInc(UINT8 ubDirection) INT16 DirectionInc(UINT8 ubDirection)
{ {
if ((ubDirection < 0) || (ubDirection > 7)) if (ubDirection > 7)
{ {
//#ifdef BETAVERSION //#ifdef BETAVERSION
@@ -559,7 +562,7 @@ INT16 DirectionInc(UINT8 ubDirection)
//#endif //#endif
//direction = random(8); // replace garbage with random direction //direction = random(8); // replace garbage with random direction
ubDirection = 1; ubDirection = 0;
} }
@@ -653,7 +656,7 @@ BOOLEAN IsPointInScreenRectWithRelative( INT16 sXPos, INT16 sYPos, SGPRect *pRec
{ {
if ( (sXPos >= pRect->iLeft) && (sXPos <= pRect->iRight) && (sYPos >= pRect->iTop) && (sYPos <= pRect->iBottom) ) if ( (sXPos >= pRect->iLeft) && (sXPos <= pRect->iRight) && (sYPos >= pRect->iTop) && (sYPos <= pRect->iBottom) )
{ {
(*sXRel) = pRect->iLeft - sXPos; (*sXRel) = (INT16) pRect->iLeft - sXPos;
(*sYRel) = sYPos - (INT16)pRect->iTop; (*sYRel) = sYPos - (INT16)pRect->iTop;
return( TRUE ); return( TRUE );
@@ -669,8 +672,8 @@ INT16 PythSpacesAway(INT16 sOrigin, INT16 sDest)
{ {
INT16 sRows,sCols,sResult; INT16 sRows,sCols,sResult;
sRows = abs((sOrigin / MAXCOL) - (sDest / MAXCOL)); sRows = (INT16) abs((sOrigin / MAXCOL) - (sDest / MAXCOL));
sCols = abs((sOrigin % MAXROW) - (sDest % MAXROW)); sCols = (INT16) abs((sOrigin % MAXROW) - (sDest % MAXROW));
// apply Pythagoras's theorem for right-handed triangle: // apply Pythagoras's theorem for right-handed triangle:
@@ -685,8 +688,8 @@ INT16 SpacesAway(INT16 sOrigin, INT16 sDest)
{ {
INT16 sRows,sCols; INT16 sRows,sCols;
sRows = abs((sOrigin / MAXCOL) - (sDest / MAXCOL)); sRows = (INT16) abs((sOrigin / MAXCOL) - (sDest / MAXCOL));
sCols = abs((sOrigin % MAXROW) - (sDest % MAXROW)); sCols = (INT16) abs((sOrigin % MAXROW) - (sDest % MAXROW));
return( __max( sRows, sCols ) ); return( __max( sRows, sCols ) );
} }
@@ -696,8 +699,8 @@ INT16 CardinalSpacesAway(INT16 sOrigin, INT16 sDest)
{ {
INT16 sRows,sCols; INT16 sRows,sCols;
sRows = abs((sOrigin / MAXCOL) - (sDest / MAXCOL)); sRows = (INT16) abs((sOrigin / MAXCOL) - (sDest / MAXCOL));
sCols = abs((sOrigin % MAXROW) - (sDest % MAXROW)); sCols = (INT16) abs((sOrigin % MAXROW) - (sDest % MAXROW));
return( (INT16)( sRows + sCols ) ); return( (INT16)( sRows + sCols ) );
} }
@@ -853,7 +856,7 @@ INT16 QuickestDirection(INT16 origin, INT16 dest)
else else
if (origin > dest) if (origin > dest)
{ {
v1 = abs(origin - dest); v1 = (INT16) abs(origin - dest);
v2 = (8 - origin) + dest; v2 = (8 - origin) + dest;
if (v1 > v2) if (v1 > v2)
return(1); return(1);
@@ -862,7 +865,7 @@ INT16 QuickestDirection(INT16 origin, INT16 dest)
} }
else else
{ {
v1 = abs(origin - dest); v1 = (INT16) abs(origin - dest);
v2 = (8 - dest) + origin; v2 = (8 - dest) + origin;
if (v1 > v2) if (v1 > v2)
return(-1); return(-1);
@@ -884,7 +887,7 @@ INT16 ExtQuickestDirection(INT16 origin, INT16 dest)
else else
if (origin > dest) if (origin > dest)
{ {
v1 = abs(origin - dest); v1 = (INT16) abs(origin - dest);
v2 = (32 - origin) + dest; v2 = (32 - origin) + dest;
if (v1 > v2) if (v1 > v2)
return(1); return(1);
@@ -893,7 +896,7 @@ INT16 ExtQuickestDirection(INT16 origin, INT16 dest)
} }
else else
{ {
v1 = abs(origin - dest); v1 = (INT16) abs(origin - dest);
v2 = (32 - dest) + origin; v2 = (32 - dest) + origin;
if (v1 > v2) if (v1 > v2)
return(-1); return(-1);
+21 -1
View File
@@ -33,7 +33,7 @@ extern UINT8 gPurpendicularDirection[ NUM_WORLD_DIRECTIONS ][ NUM_WORLD_DIRECTIO
// |Check for map bounds------------------------------------------| |Invalid-| |Valid-------------------| // |Check for map bounds------------------------------------------| |Invalid-| |Valid-------------------|
#define MAPROWCOLTOPOS( r, c ) ( ( (r < 0) || (r >= WORLD_ROWS) || (c < 0) || (c >= WORLD_COLS) ) ? ( 0xffff ) : ( (r) * WORLD_COLS + (c) ) ) #define MAPROWCOLTOPOS( r, c ) ( ( (r < 0) || (r >= WORLD_ROWS) || (c < 0) || (c >= WORLD_COLS) ) ? ( 0xffff ) : ( (r) * WORLD_COLS + (c) ) )
#define GETWORLDINDEXFROMWORLDCOORDS( r, c ) ( (INT16) ( r / CELL_X_SIZE ) ) * WORLD_COLS + ( (INT16) ( c / CELL_Y_SIZE ) ) #define GETWORLDINDEXFROMWORLDCOORDS( y, x ) ( (INT16) ( x / CELL_X_SIZE ) ) + WORLD_COLS * ( (INT16) ( y / CELL_Y_SIZE ) )
void ConvertGridNoToXY( INT16 sGridNo, INT16 *sXPos, INT16 *sYPos ); void ConvertGridNoToXY( INT16 sGridNo, INT16 *sXPos, INT16 *sYPos );
void ConvertGridNoToCellXY( INT16 sGridNo, INT16 *sXPos, INT16 *sYPos ); void ConvertGridNoToCellXY( INT16 sGridNo, INT16 *sXPos, INT16 *sYPos );
@@ -112,4 +112,24 @@ INT16 RandomGridNo();
extern UINT32 guiForceRefreshMousePositionCalculation; extern UINT32 guiForceRefreshMousePositionCalculation;
//ADB I'm tired of seeing a 5 digit number when looking at something's gridno.
//I need to see an x and y. I created this class for the AStar,
//but moved it here as you can convert a regular INT16 gridno to a GridNode then print it out for debugging.
//Don't switch between the 2 types too often, IntToGridNode is especially slow
//0verhaul: It's not good to give the computer extra work just for readability's sake. So this should be a
//good compromise. Possibly even more useful. Just add a watch variable for GridNode.MapXY[ mygridvar ] and
//see its X,Y in the watch window.
class GridNode
{
public:
typedef GridNode MapXY_t[WORLD_MAX];
static MapXY_t MapXY;
INT16 x;
INT16 y;
static MapXY_t *initGridNodes() { for (INT16 i=0; i<WORLD_MAX; i++){ConvertGridNoToXY(i, &MapXY[i].x, &MapXY[i].y); } return &MapXY; };
};
#endif #endif
+9 -9
View File
@@ -174,10 +174,10 @@ typedef struct TAG_STRUCTURE
UINT8 ubHitPoints; UINT8 ubHitPoints;
UINT8 ubLockStrength; UINT8 ubLockStrength;
}; };
struct //struct
{ //{
INT16 sBaseGridNo; INT16 sBaseGridNo;
}; //};
}; // 2 bytes }; // 2 bytes
INT16 sCubeOffset;// height of bottom of object in profile "cubes" INT16 sCubeOffset;// height of bottom of object in profile "cubes"
UINT32 fFlags; // need to have something to indicate base tile/not UINT32 fFlags; // need to have something to indicate base tile/not
@@ -216,14 +216,14 @@ typedef struct TAG_STRUCTURE_FILE_HEADER
CHAR8 szId[4]; CHAR8 szId[4];
union union
{ {
struct //struct
{ //{
UINT16 usNumberOfStructures; UINT16 usNumberOfStructures;
}; //};
struct //struct
{ //{
UINT16 usNumberOfImages; UINT16 usNumberOfImages;
}; //};
}; };
UINT16 usNumberOfStructuresStored; UINT16 usNumberOfStructuresStored;
UINT16 usStructureDataSize; UINT16 usStructureDataSize;
+2 -2
View File
@@ -68,8 +68,8 @@ UINT32 iTPButtons[ NUM_TP_BUTTONS ];
extern BOOLEAN gfOverheadMapDirty; extern BOOLEAN gfOverheadMapDirty;
extern BOOLEAN GetOverheadMouseGridNo( INT16 *psGridNo ); extern BOOLEAN GetOverheadMouseGridNo( INT16 *psGridNo );
extern int iOffsetHorizontal; extern UINT16 iOffsetHorizontal;
extern int iOffsetVertical; extern UINT16 iOffsetVertical;
UINT8 gubDefaultButton = CLEAR_BUTTON; UINT8 gubDefaultButton = CLEAR_BUTTON;
BOOLEAN gfTacticalPlacementGUIActive = FALSE; BOOLEAN gfTacticalPlacementGUIActive = FALSE;
+1 -1
View File
@@ -7,7 +7,7 @@ extern TILE_IMAGERY *gTileSurfaceArray[ NUMBEROFTILETYPES ];
extern UINT8 gbDefaultSurfaceUsed[ NUMBEROFTILETYPES ]; extern UINT8 gbDefaultSurfaceUsed[ NUMBEROFTILETYPES ];
extern UINT8 gbSameAsDefaultSurfaceUsed[ NUMBEROFTILETYPES ]; extern UINT8 gbSameAsDefaultSurfaceUsed[ NUMBEROFTILETYPES ];
TILE_IMAGERY *LoadTileSurface( char * cFilename ); TILE_IMAGERY *LoadTileSurface( STR8 cFilename );
void DeleteTileSurface( PTILE_IMAGERY pTileSurf ); void DeleteTileSurface( PTILE_IMAGERY pTileSurf );
+1 -1
View File
@@ -233,4 +233,4 @@ void SetTilesetFourTerrainValues( )
// NOW ANY TERRAIN MODIFYING DEBRIS // NOW ANY TERRAIN MODIFYING DEBRIS
} }
+4 -4
View File
@@ -24,10 +24,10 @@ struct
CHAR8 szCharData[MAX_CHAR_DATA_LENGTH+1]; CHAR8 szCharData[MAX_CHAR_DATA_LENGTH+1];
EXPLOSION_DATA expData; EXPLOSION_DATA expData;
UINT32 maxArraySize; INT32 maxArraySize;
UINT32 curIndex; INT32 curIndex;
UINT32 currentDepth; INT32 currentDepth;
UINT32 maxReadDepth; INT32 maxReadDepth;
} }
typedef explosionDataParseData; typedef explosionDataParseData;
+3
View File
@@ -701,6 +701,9 @@ void EnvBeginRainStorm( UINT8 ubIntensity )
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_TESTVERSION, L"Starting Rain...." ); ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_TESTVERSION, L"Starting Rain...." );
#endif #endif
// First turn off whatever rain it is, then turn on the requested rain
guiEnvWeather &= ~(WEATHER_FORECAST_THUNDERSHOWERS | WEATHER_FORECAST_SHOWERS);
if ( ubIntensity == 1 ) if ( ubIntensity == 1 )
{ {
// Turn on rain storms // Turn on rain storms
+1 -1
View File
@@ -71,7 +71,7 @@ void TurnOffPrimeLights();
//effects whether or not time of day effects the lighting. Underground //affects whether or not time of day affects the lighting. Underground
//maps have an ambient light level that is saved in the map, and doesn't change. //maps have an ambient light level that is saved in the map, and doesn't change.
extern BOOLEAN gfCaves; extern BOOLEAN gfCaves;
extern BOOLEAN gfBasement; extern BOOLEAN gfBasement;
+11 -9
View File
@@ -573,10 +573,12 @@ UINT8 ubTravelCost;
//bDirection = atan8( iX, iY, iSrcX, iSrcY ); //bDirection = atan8( iX, iY, iSrcX, iSrcY );
bDirection = atan8( iSrcX, iSrcY, iX, iY ); bDirection = atan8( iSrcX, iSrcY, iX, iY );
#if 0
if ( usTileNo == 20415 && bDirection == 3 ) if ( usTileNo == 20415 && bDirection == 3 )
{ {
int i = 0; int i = 0;
} }
#endif
ubTravelCost = gubWorldMovementCosts[ usTileNo ][ bDirection ][ 0 ]; ubTravelCost = gubWorldMovementCosts[ usTileNo ][ bDirection ][ 0 ];
@@ -781,10 +783,10 @@ void LightAddTileNode(LEVELNODE *pNode, UINT32 uiLightType, UINT8 ubShadeAdd, BO
{ {
INT16 sSum; INT16 sSum;
pNode->ubSumLights += ubShadeAdd; pNode->ubSumLights = pNode->ubSumLights + ubShadeAdd;
if (fFake) if (fFake)
{ {
pNode->ubFakeShadeLevel += ubShadeAdd; pNode->ubFakeShadeLevel = pNode->ubFakeShadeLevel + ubShadeAdd;
} }
// Now set max // Now set max
@@ -815,7 +817,7 @@ INT16 sSum;
} }
else else
{ {
pNode->ubSumLights -= ubShadeSubtract; pNode->ubSumLights = pNode->ubSumLights - ubShadeSubtract;
} }
if (fFake) if (fFake)
{ {
@@ -825,7 +827,7 @@ INT16 sSum;
} }
else else
{ {
pNode->ubFakeShadeLevel -= ubShadeSubtract; pNode->ubFakeShadeLevel = pNode->ubFakeShadeLevel - ubShadeSubtract;
} }
} }
@@ -950,7 +952,7 @@ BOOLEAN fFake;
} }
if(uiFlags&LIGHT_BACKLIGHT) if(uiFlags&LIGHT_BACKLIGHT)
ubShadeAdd=(INT16)ubShade*7/10; ubShadeAdd=(UINT8)((UINT16)ubShade*7/10);
pMerc = gpWorldLevelData[uiTile].pMercHead; pMerc = gpWorldLevelData[uiTile].pMercHead;
while(pMerc!=NULL) while(pMerc!=NULL)
@@ -1093,7 +1095,7 @@ BOOLEAN fFake; // only passed in to land and roof layers; others get fed FALSE
} }
if(uiFlags&LIGHT_BACKLIGHT) if(uiFlags&LIGHT_BACKLIGHT)
ubShadeSubtract=(INT16)ubShade*7/10; ubShadeSubtract=(UINT8) ((UINT16)ubShade*7/10);
pMerc = gpWorldLevelData[uiTile].pMercHead; pMerc = gpWorldLevelData[uiTile].pMercHead;
while(pMerc!=NULL) while(pMerc!=NULL)
@@ -1423,7 +1425,7 @@ UINT16 LightGetLastNode(INT32 iLight)
***************************************************************************************/ ***************************************************************************************/
BOOLEAN LightAddNode(INT32 iLight, INT16 iHotSpotX, INT16 iHotSpotY, INT16 iX, INT16 iY, UINT8 ubIntensity, UINT16 uiFlags) BOOLEAN LightAddNode(INT32 iLight, INT16 iHotSpotX, INT16 iHotSpotY, INT16 iX, INT16 iY, UINT8 ubIntensity, UINT16 uiFlags)
{ {
BOOLEAN fDuplicate=FALSE; //BOOLEAN fDuplicate=FALSE;
DOUBLE dDistance; DOUBLE dDistance;
UINT8 ubShade; UINT8 ubShade;
INT32 iLightDecay; INT32 iLightDecay;
@@ -1585,7 +1587,7 @@ BOOLEAN fInsertNodes=FALSE;
for (i=0; i<=XDelta; i++) for (i=0; i<=XDelta; i++)
{ {
LightInsertNode(iLight, usCurNode, iStartX, iStartY, iXPos, iYPos, ubStartIntens, usFlags); LightInsertNode(iLight, usCurNode, iStartX, iStartY, iXPos, iYPos, ubStartIntens, usFlags);
iXPos+=XAdvance; iXPos=iXPos+XAdvance;
} }
} }
else else
@@ -1593,7 +1595,7 @@ BOOLEAN fInsertNodes=FALSE;
for (i=0; i<=XDelta; i++) for (i=0; i<=XDelta; i++)
{ {
LightAddNode(iLight, iStartX, iStartY, iXPos, iYPos, ubStartIntens, usFlags); LightAddNode(iLight, iStartX, iStartY, iXPos, iYPos, ubStartIntens, usFlags);
iXPos+=XAdvance; iXPos=iXPos+XAdvance;
} }
} }
return(TRUE); return(TRUE);
+2 -2
View File
@@ -91,8 +91,8 @@ INT16 gsStartRestrictedX, gsStartRestrictedY;
BOOLEAN gfOverItemPool = FALSE; BOOLEAN gfOverItemPool = FALSE;
INT16 gsOveritemPoolGridNo; INT16 gsOveritemPoolGridNo;
int iOffsetHorizontal; // Horizontal start postion of the overview map UINT16 iOffsetHorizontal; // Horizontal start postion of the overview map
int iOffsetVertical; // Vertical start position of the overview map UINT16 iOffsetVertical; // Vertical start position of the overview map
void HandleOverheadUI( ); void HandleOverheadUI( );
+38 -49
View File
@@ -19,27 +19,6 @@
#define WORLD_BASE_HEIGHT 0 #define WORLD_BASE_HEIGHT 0
#define WORLD_CLIFF_HEIGHT 80 #define WORLD_CLIFF_HEIGHT 80
//ADB I'm tired of seeing a 5 digit number when looking at something's gridno.
//I need to see an x and y. I created this class for the AStar,
//but moved it here as you can convert a regular INT16 gridno to a GridNode then print it out for debugging.
//Don't switch between the 2 types too often, IntToGridNode is especially slow
class GridNode
{
public:
GridNode () {x = -1; y = -1;};
GridNode (INT16 const loc) {this->x = loc % WORLD_COLS; this->y = loc / WORLD_COLS;};
GridNode (int x, int y) {GridNode::x = x; GridNode::y = y;};
GridNode operator + (const GridNode& point) const {return GridNode(this->x + point.x, this->y + point.y);};
bool operator == (const GridNode& point) const {return this->x == point.x && this->y == point.y;};
bool operator != (const GridNode& point) const {return !(*this == point);};
INT16 GridNodeToInt() {return (this->x + this->y * WORLD_COLS);};
void IntToGridNode(INT16 const loc) {this->x = loc % WORLD_COLS; this->y = loc / WORLD_COLS;};
bool isInWorld() {return (this->x < WORLD_COLS && this->x >= 0 &&
this->y < WORLD_ROWS && this->y >= 0);};
int x;
int y;
};
//A macro that actually memcpy's over data and increments the pointer automatically //A macro that actually memcpy's over data and increments the pointer automatically
//based on the size. Works like a FileRead except with a buffer instead of a file pointer. //based on the size. Works like a FileRead except with a buffer instead of a file pointer.
@@ -116,7 +95,8 @@ public:
#define MAPELEMENT_EXT_NOBURN_STRUCT 0x0020 //0x20 #define MAPELEMENT_EXT_NOBURN_STRUCT 0x0020 //0x20
#define MAPELEMENT_EXT_ROOFCODE_VISITED 0x0040 //0x40 #define MAPELEMENT_EXT_ROOFCODE_VISITED 0x0040 //0x40
#define MAPELEMENT_EXT_CREATUREGAS 0x0080 //0x80 #define MAPELEMENT_EXT_CREATUREGAS 0x0080 //0x80
#define MAPELEMENT_EXT_BURNABLEGAS 0x0100 //0x60 #define MAPELEMENT_EXT_BURNABLEGAS 0x0100 //0x100
#define MAPELEMENT_EXT_CLIMBPOINT 0x0200 //0x200
#define FIRST_LEVEL 0 #define FIRST_LEVEL 0
#define SECOND_LEVEL 1 #define SECOND_LEVEL 1
@@ -165,27 +145,27 @@ struct LEVELNODE
}; };
// Some can contains index values into dead corpses // Some can contains index values into dead corpses
struct //struct
{ //{
INT32 iCorpseID; // Index into corpse ID INT32 iCorpseID; // Index into corpse ID
}; //};
struct //struct
{ //{
UINT32 uiAnimHitLocationFlags; // Animation profile flags for soldier placeholders ( prone merc hit location values ) UINT32 uiAnimHitLocationFlags; // Animation profile flags for soldier placeholders ( prone merc hit location values )
}; //};
// Some can contains index values into animated tile data // Some can contains index values into animated tile data
struct //struct
{ //{
struct TAG_anitile *pAniTile; struct TAG_anitile *pAniTile;
}; //};
// Can be an item pool as well... // Can be an item pool as well...
struct //struct
{ //{
ITEM_POOL *pItemPool; // ITEM POOLS ITEM_POOL *pItemPool; // ITEM POOLS
}; //};
}; };
@@ -207,33 +187,42 @@ struct LEVELNODE
#define ONROOF_START_INDEX 7 #define ONROOF_START_INDEX 7
#define TOPMOST_START_INDEX 8 #define TOPMOST_START_INDEX 8
#define pLandHead pLevelNodes[ 0 ]
#define pLandStart pLevelNodes[ 1 ]
#define pObjectHead pLevelNodes[ 2 ]
#define pStructHead pLevelNodes[ 3 ]
#define pShadowHead pLevelNodes[ 4 ]
#define pMercHead pLevelNodes[ 5 ]
#define pRoofHead pLevelNodes[ 6 ]
#define pOnRoofHead pLevelNodes[ 7 ]
#define pTopmostHead pLevelNodes[ 8 ]
typedef struct typedef struct
{ {
union //union
{ //{
struct //struct
{ //{
LEVELNODE *pLandHead; //0 //LEVELNODE *pLandHead; //0
LEVELNODE *pLandStart; //1 //LEVELNODE *pLandStart; //1
LEVELNODE *pObjectHead; //2 //LEVELNODE *pObjectHead; //2
LEVELNODE *pStructHead; //3 //LEVELNODE *pStructHead; //3
LEVELNODE *pShadowHead; //4 //LEVELNODE *pShadowHead; //4
LEVELNODE *pMercHead; //5 //LEVELNODE *pMercHead; //5
LEVELNODE *pRoofHead; //6 //LEVELNODE *pRoofHead; //6
LEVELNODE *pOnRoofHead; //7 //LEVELNODE *pOnRoofHead; //7
LEVELNODE *pTopmostHead; //8 //LEVELNODE *pTopmostHead; //8
}; //};
LEVELNODE *pLevelNodes[ 9 ]; LEVELNODE *pLevelNodes[ 9 ];
}; //};
STRUCTURE *pStructureHead; STRUCTURE *pStructureHead;
STRUCTURE *pStructureTail; STRUCTURE *pStructureTail;