mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
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:
+113
-27
@@ -22,6 +22,12 @@ UINT8 gubBuildingInfo[ WORLD_MAX ];
|
||||
BUILDING gBuildings[ MAX_BUILDINGS ];
|
||||
UINT8 gubNumberOfBuildings;
|
||||
|
||||
#ifdef ROOF_DEBUG
|
||||
extern INT16 gsCoverValue[WORLD_MAX];
|
||||
#include "video.h"
|
||||
#include "renderworld.h"
|
||||
#endif
|
||||
|
||||
BUILDING * CreateNewBuilding( UINT8 * pubBuilding )
|
||||
{
|
||||
if (gubNumberOfBuildings + 1 >= MAX_BUILDINGS)
|
||||
@@ -40,6 +46,7 @@ BUILDING * CreateNewBuilding( UINT8 * pubBuilding )
|
||||
BUILDING * GenerateBuilding( INT16 sDesiredSpot )
|
||||
{
|
||||
|
||||
#if 0
|
||||
UINT32 uiLoop;
|
||||
UINT32 uiLoop2;
|
||||
INT16 sTempGridNo, sNextTempGridNo, sVeryTemporaryGridNo;
|
||||
@@ -51,9 +58,10 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
|
||||
INT8 bDesiredOrientation;
|
||||
INT8 bSkipSpots = 0;
|
||||
SOLDIERTYPE FakeSoldier;
|
||||
#endif
|
||||
BUILDING * pBuilding;
|
||||
UINT8 ubBuildingID = 0;
|
||||
INT32 iLoopCount = 0;
|
||||
//INT32 iLoopCount = 0;
|
||||
|
||||
pBuilding = CreateNewBuilding( &ubBuildingID );
|
||||
if (!pBuilding)
|
||||
@@ -64,18 +72,21 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
|
||||
// WDS - Clean up inventory handling
|
||||
// set up fake soldier for location testing
|
||||
// memset( &FakeSoldier, 0, SIZEOF_SOLDIERTYPE );
|
||||
#if 0
|
||||
FakeSoldier.initialize();
|
||||
FakeSoldier.sGridNo = sDesiredSpot;
|
||||
FakeSoldier.bLevel = 1;
|
||||
FakeSoldier.bTeam = 1;
|
||||
|
||||
#ifdef ROOF_DEBUG
|
||||
memset( gsCoverValue, 0x7F, sizeof( INT16 ) * WORLD_MAX );
|
||||
#endif
|
||||
|
||||
// Set reachable
|
||||
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
|
||||
ubDirection = NORTHWEST;
|
||||
sTempGridNo = sDesiredSpot;
|
||||
@@ -196,7 +207,7 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
|
||||
gsCoverValue[sCurrGridNo]++;
|
||||
}
|
||||
|
||||
DebugAI( String( "Roof code visits %d", sCurrGridNo ) );
|
||||
//DebugAI( String( "Roof code visits %d", sCurrGridNo ) );
|
||||
#endif
|
||||
|
||||
if (sCurrGridNo == sStartGridNo)
|
||||
@@ -219,8 +230,13 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
|
||||
// if south or west, the wall would be in the gridno two clockwise
|
||||
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:
|
||||
sWallGridNo = sCurrGridNo;
|
||||
bDesiredOrientation = OUTSIDE_TOP_RIGHT;
|
||||
@@ -240,25 +256,28 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
|
||||
default:
|
||||
// what the heck?
|
||||
return( NULL );
|
||||
}
|
||||
}
|
||||
|
||||
if (bDesiredOrientation == OUTSIDE_TOP_LEFT)
|
||||
{
|
||||
if (WallExistsOfTopLeftOrientation( sWallGridNo ))
|
||||
if (bDesiredOrientation == OUTSIDE_TOP_LEFT)
|
||||
{
|
||||
fFoundWall = TRUE;
|
||||
if (WallExistsOfTopLeftOrientation( sWallGridNo ))
|
||||
{
|
||||
fFoundWall = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (WallExistsOfTopRightOrientation( sWallGridNo ))
|
||||
{
|
||||
fFoundWall = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (WallExistsOfTopRightOrientation( sWallGridNo ))
|
||||
{
|
||||
fFoundWall = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (fFoundWall)
|
||||
{
|
||||
#ifdef ROOF_DEBUG
|
||||
gsCoverValue[sCurrGridNo] = 50;
|
||||
#endif
|
||||
if (bSkipSpots > 0)
|
||||
{
|
||||
bSkipSpots--;
|
||||
@@ -266,7 +285,7 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
|
||||
else if ( Random( uiChanceIn ) == 0 )
|
||||
{
|
||||
// don't consider people as obstacles
|
||||
if ( NewOKDestination( &FakeSoldier, sCurrGridNo, FALSE, 0 ) )
|
||||
//if ( NewOKDestination( &FakeSoldier, sCurrGridNo, FALSE, 0 ) )
|
||||
{
|
||||
pBuilding->sUpClimbSpots[ pBuilding->ubNumClimbSpots ] = sCurrGridNo;
|
||||
pBuilding->sDownClimbSpots[ pBuilding->ubNumClimbSpots ] = sRightGridNo;
|
||||
@@ -286,13 +305,13 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
|
||||
// skip the next spot
|
||||
bSkipSpots = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
//else
|
||||
//{
|
||||
// if location is not added, 100% chance of handling next location
|
||||
// and the next until we can add one
|
||||
uiChanceIn = 1;
|
||||
|
||||
}
|
||||
// uiChanceIn = 1;
|
||||
|
||||
//}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -326,7 +345,6 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
|
||||
// skip the next gridno
|
||||
bSkipSpots = 1;
|
||||
}
|
||||
|
||||
}
|
||||
uiLoop2++;
|
||||
}
|
||||
@@ -351,12 +369,13 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot )
|
||||
#ifdef ROOF_DEBUG
|
||||
SetRenderFlags( RENDER_FLAG_FULL );
|
||||
RenderWorld();
|
||||
RenderCoverDebug( );
|
||||
//RenderCoverDebug( );
|
||||
InvalidateScreen( );
|
||||
EndFrameBufferRender();
|
||||
RefreshScreen( NULL );
|
||||
#endif
|
||||
*/
|
||||
#endif
|
||||
return( pBuilding );
|
||||
}
|
||||
|
||||
@@ -422,6 +441,10 @@ void GenerateBuildings( void )
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef ROOF_DEBUG
|
||||
memset( gsCoverValue, 0x7F, sizeof( INT16 ) * WORLD_MAX );
|
||||
#endif
|
||||
|
||||
// reset ALL reachable flags
|
||||
// do once before we start building generation for
|
||||
// whole map
|
||||
@@ -445,9 +468,15 @@ void GenerateBuildings( void )
|
||||
INT16 FindClosestClimbPoint( SOLDIERTYPE *pSoldier, INT16 sStartGridNo, INT16 sDesiredGridNo, BOOLEAN fClimbUp )
|
||||
{
|
||||
BUILDING * pBuilding;
|
||||
#if 1
|
||||
INT16 sGridNo;
|
||||
INT16 sTestGridNo;
|
||||
UINT8 ubTestDir;
|
||||
#else
|
||||
UINT8 ubNumClimbSpots;
|
||||
INT16 * psClimbSpots;
|
||||
UINT8 ubLoop;
|
||||
#endif
|
||||
INT16 sDistance, sClosestDistance = 1000, sClosestSpot= NOWHERE;
|
||||
|
||||
pBuilding = FindBuilding( sDesiredGridNo );
|
||||
@@ -456,6 +485,62 @@ INT16 FindClosestClimbPoint( SOLDIERTYPE *pSoldier, INT16 sStartGridNo, INT16 sD
|
||||
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;
|
||||
|
||||
if (fClimbUp)
|
||||
@@ -481,6 +566,7 @@ INT16 FindClosestClimbPoint( SOLDIERTYPE *pSoldier, INT16 sStartGridNo, INT16 sD
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return( sClosestSpot );
|
||||
}
|
||||
|
||||
@@ -246,9 +246,6 @@ UINT16 FindGridNoFromSweetSpotCloseToExitGrid( SOLDIERTYPE *pSoldier, INT16 sSwe
|
||||
EXITGRID ExitGrid;
|
||||
UINT8 ubGotoSectorX, ubGotoSectorY, ubGotoSectorZ;
|
||||
|
||||
// Turn off at end of function...
|
||||
gfPlotPathToExitGrid = TRUE;
|
||||
|
||||
//Save AI pathing vars. changing the distlimit restricts how
|
||||
//far away the pathing will consider.
|
||||
ubSaveNPCAPBudget = gubNPCAPBudget;
|
||||
@@ -296,10 +293,14 @@ UINT16 FindGridNoFromSweetSpotCloseToExitGrid( SOLDIERTYPE *pSoldier, INT16 sSwe
|
||||
}
|
||||
}
|
||||
|
||||
gfPlotPathToExitGrid = TRUE;
|
||||
|
||||
//Now, find out which of these gridnos are reachable
|
||||
//(use the fake soldier and the pathing settings)
|
||||
FindBestPath( &soldier, NOWHERE, 0, WALKING, COPYREACHABLE, PATH_THROUGH_PEOPLE );
|
||||
|
||||
gfPlotPathToExitGrid = FALSE;
|
||||
|
||||
uiLowestRange = 999999;
|
||||
|
||||
for( cnt1 = sBottom; cnt1 <= sTop; cnt1++ )
|
||||
@@ -339,8 +340,6 @@ UINT16 FindGridNoFromSweetSpotCloseToExitGrid( SOLDIERTYPE *pSoldier, INT16 sSwe
|
||||
gubNPCAPBudget = ubSaveNPCAPBudget;
|
||||
gubNPCDistLimit = ubSaveNPCDistLimit;
|
||||
|
||||
gfPlotPathToExitGrid = FALSE;
|
||||
|
||||
if ( fFound )
|
||||
{
|
||||
// Set direction to center of map!
|
||||
|
||||
@@ -500,8 +500,8 @@ void UpdateExplosionFrame( INT32 iIndex, INT16 sCurrentFrame )
|
||||
if ( gExplosionData[iIndex].iLightID != -1 )
|
||||
{
|
||||
INT16 iX, iY;
|
||||
iX = gExplosionData[iIndex].Params.sX/CELL_X_SIZE + Random(3) - 1;
|
||||
iY = gExplosionData[iIndex].Params.sY/CELL_Y_SIZE + Random(3) - 1;
|
||||
iX = (INT16) (gExplosionData[iIndex].Params.sX/CELL_X_SIZE + Random(3) - 1);
|
||||
iY = (INT16) (gExplosionData[iIndex].Params.sY/CELL_Y_SIZE + Random(3) - 1);
|
||||
LightSpritePosition( gExplosionData[iIndex].iLightID, iX, iY);
|
||||
}
|
||||
}
|
||||
@@ -1523,12 +1523,14 @@ BOOLEAN DishOutGasDamage( SOLDIERTYPE * pSoldier, EXPLOSIVETYPE * pExplosive, IN
|
||||
|
||||
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;
|
||||
}
|
||||
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 )
|
||||
{
|
||||
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
|
||||
{
|
||||
// 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;
|
||||
@@ -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 )
|
||||
{
|
||||
INT16 sWoundAmt = 0,sBreathAmt = 0, sNewWoundAmt = 0, sNewBreathAmt = 0, sStructDmgAmt;
|
||||
INT16 sWoundAmt = 0,sBreathAmt = 0, /* sNewWoundAmt = 0, sNewBreathAmt = 0, */ sStructDmgAmt;
|
||||
UINT8 ubPerson;
|
||||
SOLDIERTYPE *pSoldier;
|
||||
EXPLOSIVETYPE *pExplosive;
|
||||
@@ -1701,8 +1705,8 @@ BOOLEAN ExpAffect( INT16 sBombGridNo, INT16 sGridNo, UINT32 uiDist, UINT16 usIte
|
||||
else if (uiDist < pExplosive->ubRadius)
|
||||
{
|
||||
// if radius is 5, go down by 5ths ~ 20%
|
||||
sWoundAmt -= (INT16) (sWoundAmt * uiDist / pExplosive->ubRadius );
|
||||
sBreathAmt -= (INT16) (sBreathAmt * uiDist / pExplosive->ubRadius );
|
||||
sWoundAmt = sWoundAmt - (INT16) (sWoundAmt * uiDist / pExplosive->ubRadius );
|
||||
sBreathAmt = sBreathAmt - (INT16) (sBreathAmt * uiDist / pExplosive->ubRadius );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3400,7 +3404,7 @@ BOOLEAN SaveExplosionTableToSaveGameFile( HWFILE hFile )
|
||||
BOOLEAN LoadExplosionTableFromSavedGameFile( HWFILE hFile )
|
||||
{
|
||||
UINT32 uiNumBytesRead;
|
||||
UINT32 uiExplosionCount=0;
|
||||
//UINT32 uiExplosionCount=0;
|
||||
UINT32 uiCnt;
|
||||
|
||||
|
||||
@@ -3508,7 +3512,8 @@ void UpdateAndDamageSAMIfFound( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ,
|
||||
|
||||
if ( StrategicMap[ sSectorNo ].bSAMCondition >= ubDamage )
|
||||
{
|
||||
StrategicMap[ sSectorNo ].bSAMCondition -= ubDamage;
|
||||
StrategicMap[ sSectorNo ].bSAMCondition =
|
||||
StrategicMap[ sSectorNo ].bSAMCondition - ubDamage;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -219,7 +219,7 @@ BOOLEAN SoldierHandleInteractiveObject( SOLDIERTYPE *pSoldier )
|
||||
void HandleStructChangeFromGridNo( SOLDIERTYPE *pSoldier, INT16 sGridNo )
|
||||
{
|
||||
STRUCTURE *pStructure, *pNewStructure;
|
||||
INT16 sAPCost = 0, sBPCost = 0;
|
||||
//INT16 sAPCost = 0, sBPCost = 0;
|
||||
ITEM_POOL *pItemPool;
|
||||
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;
|
||||
|
||||
// Adjust for offset position on screen
|
||||
sScreenX -= gsRenderWorldOffsetX;
|
||||
sScreenY -= gsRenderWorldOffsetY;
|
||||
sScreenY -= gpWorldLevelData[ sGridNo ].sHeight;
|
||||
sScreenX = sScreenX - gsRenderWorldOffsetX;
|
||||
sScreenY = sScreenY - gsRenderWorldOffsetY;
|
||||
sScreenY = sScreenY - gpWorldLevelData[ sGridNo ].sHeight;
|
||||
|
||||
// Adjust based on interface level
|
||||
if ( gsInterfaceLevel > 0 )
|
||||
@@ -483,7 +483,7 @@ void GetLevelNodeScreenRect( LEVELNODE *pNode, SGPRect *pRect, INT16 sXPos, INT1
|
||||
}
|
||||
|
||||
// Adjust for render height
|
||||
sScreenY += gsRenderHeight;
|
||||
sScreenY = sScreenY + gsRenderHeight;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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 )
|
||||
{
|
||||
*psScreenX = ( 2 * sCellX ) - ( 2 * sCellY );
|
||||
@@ -457,8 +460,8 @@ void GetWorldXYAbsoluteScreenXY( INT32 sWorldCellX, INT32 sWorldCellY, INT16 *ps
|
||||
INT16 sDistToCenterY, sDistToCenterX;
|
||||
|
||||
// Find the diustance from render center to true world center
|
||||
sDistToCenterX = ( sWorldCellX * CELL_X_SIZE ) - gCenterWorldX;
|
||||
sDistToCenterY = ( sWorldCellY * CELL_Y_SIZE ) - gCenterWorldY;
|
||||
sDistToCenterX = (INT16) ( ( sWorldCellX * CELL_X_SIZE ) - gCenterWorldX);
|
||||
sDistToCenterY = (INT16) ( ( sWorldCellY * CELL_Y_SIZE ) - gCenterWorldY);
|
||||
|
||||
|
||||
// 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)
|
||||
{
|
||||
if ((ubDirection < 0) || (ubDirection > 7))
|
||||
if (ubDirection > 7)
|
||||
{
|
||||
|
||||
//#ifdef BETAVERSION
|
||||
@@ -559,7 +562,7 @@ INT16 DirectionInc(UINT8 ubDirection)
|
||||
//#endif
|
||||
|
||||
//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) )
|
||||
{
|
||||
(*sXRel) = pRect->iLeft - sXPos;
|
||||
(*sXRel) = (INT16) pRect->iLeft - sXPos;
|
||||
(*sYRel) = sYPos - (INT16)pRect->iTop;
|
||||
|
||||
return( TRUE );
|
||||
@@ -669,8 +672,8 @@ INT16 PythSpacesAway(INT16 sOrigin, INT16 sDest)
|
||||
{
|
||||
INT16 sRows,sCols,sResult;
|
||||
|
||||
sRows = abs((sOrigin / MAXCOL) - (sDest / MAXCOL));
|
||||
sCols = abs((sOrigin % MAXROW) - (sDest % MAXROW));
|
||||
sRows = (INT16) abs((sOrigin / MAXCOL) - (sDest / MAXCOL));
|
||||
sCols = (INT16) abs((sOrigin % MAXROW) - (sDest % MAXROW));
|
||||
|
||||
|
||||
// apply Pythagoras's theorem for right-handed triangle:
|
||||
@@ -685,8 +688,8 @@ INT16 SpacesAway(INT16 sOrigin, INT16 sDest)
|
||||
{
|
||||
INT16 sRows,sCols;
|
||||
|
||||
sRows = abs((sOrigin / MAXCOL) - (sDest / MAXCOL));
|
||||
sCols = abs((sOrigin % MAXROW) - (sDest % MAXROW));
|
||||
sRows = (INT16) abs((sOrigin / MAXCOL) - (sDest / MAXCOL));
|
||||
sCols = (INT16) abs((sOrigin % MAXROW) - (sDest % MAXROW));
|
||||
|
||||
return( __max( sRows, sCols ) );
|
||||
}
|
||||
@@ -696,8 +699,8 @@ INT16 CardinalSpacesAway(INT16 sOrigin, INT16 sDest)
|
||||
{
|
||||
INT16 sRows,sCols;
|
||||
|
||||
sRows = abs((sOrigin / MAXCOL) - (sDest / MAXCOL));
|
||||
sCols = abs((sOrigin % MAXROW) - (sDest % MAXROW));
|
||||
sRows = (INT16) abs((sOrigin / MAXCOL) - (sDest / MAXCOL));
|
||||
sCols = (INT16) abs((sOrigin % MAXROW) - (sDest % MAXROW));
|
||||
|
||||
return( (INT16)( sRows + sCols ) );
|
||||
}
|
||||
@@ -853,7 +856,7 @@ INT16 QuickestDirection(INT16 origin, INT16 dest)
|
||||
else
|
||||
if (origin > dest)
|
||||
{
|
||||
v1 = abs(origin - dest);
|
||||
v1 = (INT16) abs(origin - dest);
|
||||
v2 = (8 - origin) + dest;
|
||||
if (v1 > v2)
|
||||
return(1);
|
||||
@@ -862,7 +865,7 @@ INT16 QuickestDirection(INT16 origin, INT16 dest)
|
||||
}
|
||||
else
|
||||
{
|
||||
v1 = abs(origin - dest);
|
||||
v1 = (INT16) abs(origin - dest);
|
||||
v2 = (8 - dest) + origin;
|
||||
if (v1 > v2)
|
||||
return(-1);
|
||||
@@ -884,7 +887,7 @@ INT16 ExtQuickestDirection(INT16 origin, INT16 dest)
|
||||
else
|
||||
if (origin > dest)
|
||||
{
|
||||
v1 = abs(origin - dest);
|
||||
v1 = (INT16) abs(origin - dest);
|
||||
v2 = (32 - origin) + dest;
|
||||
if (v1 > v2)
|
||||
return(1);
|
||||
@@ -893,7 +896,7 @@ INT16 ExtQuickestDirection(INT16 origin, INT16 dest)
|
||||
}
|
||||
else
|
||||
{
|
||||
v1 = abs(origin - dest);
|
||||
v1 = (INT16) abs(origin - dest);
|
||||
v2 = (32 - dest) + origin;
|
||||
if (v1 > v2)
|
||||
return(-1);
|
||||
|
||||
@@ -33,7 +33,7 @@ extern UINT8 gPurpendicularDirection[ NUM_WORLD_DIRECTIONS ][ NUM_WORLD_DIRECTIO
|
||||
// |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 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 ConvertGridNoToCellXY( INT16 sGridNo, INT16 *sXPos, INT16 *sYPos );
|
||||
@@ -112,4 +112,24 @@ INT16 RandomGridNo();
|
||||
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
|
||||
@@ -174,10 +174,10 @@ typedef struct TAG_STRUCTURE
|
||||
UINT8 ubHitPoints;
|
||||
UINT8 ubLockStrength;
|
||||
};
|
||||
struct
|
||||
{
|
||||
//struct
|
||||
//{
|
||||
INT16 sBaseGridNo;
|
||||
};
|
||||
//};
|
||||
}; // 2 bytes
|
||||
INT16 sCubeOffset;// height of bottom of object in profile "cubes"
|
||||
UINT32 fFlags; // need to have something to indicate base tile/not
|
||||
@@ -216,14 +216,14 @@ typedef struct TAG_STRUCTURE_FILE_HEADER
|
||||
CHAR8 szId[4];
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
//struct
|
||||
//{
|
||||
UINT16 usNumberOfStructures;
|
||||
};
|
||||
struct
|
||||
{
|
||||
//};
|
||||
//struct
|
||||
//{
|
||||
UINT16 usNumberOfImages;
|
||||
};
|
||||
//};
|
||||
};
|
||||
UINT16 usNumberOfStructuresStored;
|
||||
UINT16 usStructureDataSize;
|
||||
|
||||
@@ -68,8 +68,8 @@ UINT32 iTPButtons[ NUM_TP_BUTTONS ];
|
||||
extern BOOLEAN gfOverheadMapDirty;
|
||||
extern BOOLEAN GetOverheadMouseGridNo( INT16 *psGridNo );
|
||||
|
||||
extern int iOffsetHorizontal;
|
||||
extern int iOffsetVertical;
|
||||
extern UINT16 iOffsetHorizontal;
|
||||
extern UINT16 iOffsetVertical;
|
||||
|
||||
UINT8 gubDefaultButton = CLEAR_BUTTON;
|
||||
BOOLEAN gfTacticalPlacementGUIActive = FALSE;
|
||||
|
||||
@@ -7,7 +7,7 @@ extern TILE_IMAGERY *gTileSurfaceArray[ NUMBEROFTILETYPES ];
|
||||
extern UINT8 gbDefaultSurfaceUsed[ NUMBEROFTILETYPES ];
|
||||
extern UINT8 gbSameAsDefaultSurfaceUsed[ NUMBEROFTILETYPES ];
|
||||
|
||||
TILE_IMAGERY *LoadTileSurface( char * cFilename );
|
||||
TILE_IMAGERY *LoadTileSurface( STR8 cFilename );
|
||||
|
||||
void DeleteTileSurface( PTILE_IMAGERY pTileSurf );
|
||||
|
||||
|
||||
@@ -233,4 +233,4 @@ void SetTilesetFourTerrainValues( )
|
||||
|
||||
// NOW ANY TERRAIN MODIFYING DEBRIS
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,10 +24,10 @@ struct
|
||||
CHAR8 szCharData[MAX_CHAR_DATA_LENGTH+1];
|
||||
|
||||
EXPLOSION_DATA expData;
|
||||
UINT32 maxArraySize;
|
||||
UINT32 curIndex;
|
||||
UINT32 currentDepth;
|
||||
UINT32 maxReadDepth;
|
||||
INT32 maxArraySize;
|
||||
INT32 curIndex;
|
||||
INT32 currentDepth;
|
||||
INT32 maxReadDepth;
|
||||
}
|
||||
typedef explosionDataParseData;
|
||||
|
||||
|
||||
@@ -701,6 +701,9 @@ void EnvBeginRainStorm( UINT8 ubIntensity )
|
||||
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_TESTVERSION, L"Starting Rain...." );
|
||||
#endif
|
||||
|
||||
// First turn off whatever rain it is, then turn on the requested rain
|
||||
guiEnvWeather &= ~(WEATHER_FORECAST_THUNDERSHOWERS | WEATHER_FORECAST_SHOWERS);
|
||||
|
||||
if ( ubIntensity == 1 )
|
||||
{
|
||||
// Turn on rain storms
|
||||
|
||||
@@ -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.
|
||||
extern BOOLEAN gfCaves;
|
||||
extern BOOLEAN gfBasement;
|
||||
|
||||
+11
-9
@@ -573,10 +573,12 @@ UINT8 ubTravelCost;
|
||||
//bDirection = atan8( iX, iY, iSrcX, iSrcY );
|
||||
bDirection = atan8( iSrcX, iSrcY, iX, iY );
|
||||
|
||||
#if 0
|
||||
if ( usTileNo == 20415 && bDirection == 3 )
|
||||
{
|
||||
int i = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
ubTravelCost = gubWorldMovementCosts[ usTileNo ][ bDirection ][ 0 ];
|
||||
@@ -781,10 +783,10 @@ void LightAddTileNode(LEVELNODE *pNode, UINT32 uiLightType, UINT8 ubShadeAdd, BO
|
||||
{
|
||||
INT16 sSum;
|
||||
|
||||
pNode->ubSumLights += ubShadeAdd;
|
||||
pNode->ubSumLights = pNode->ubSumLights + ubShadeAdd;
|
||||
if (fFake)
|
||||
{
|
||||
pNode->ubFakeShadeLevel += ubShadeAdd;
|
||||
pNode->ubFakeShadeLevel = pNode->ubFakeShadeLevel + ubShadeAdd;
|
||||
}
|
||||
|
||||
// Now set max
|
||||
@@ -815,7 +817,7 @@ INT16 sSum;
|
||||
}
|
||||
else
|
||||
{
|
||||
pNode->ubSumLights -= ubShadeSubtract;
|
||||
pNode->ubSumLights = pNode->ubSumLights - ubShadeSubtract;
|
||||
}
|
||||
if (fFake)
|
||||
{
|
||||
@@ -825,7 +827,7 @@ INT16 sSum;
|
||||
}
|
||||
else
|
||||
{
|
||||
pNode->ubFakeShadeLevel -= ubShadeSubtract;
|
||||
pNode->ubFakeShadeLevel = pNode->ubFakeShadeLevel - ubShadeSubtract;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -950,7 +952,7 @@ BOOLEAN fFake;
|
||||
}
|
||||
|
||||
if(uiFlags&LIGHT_BACKLIGHT)
|
||||
ubShadeAdd=(INT16)ubShade*7/10;
|
||||
ubShadeAdd=(UINT8)((UINT16)ubShade*7/10);
|
||||
|
||||
pMerc = gpWorldLevelData[uiTile].pMercHead;
|
||||
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)
|
||||
ubShadeSubtract=(INT16)ubShade*7/10;
|
||||
ubShadeSubtract=(UINT8) ((UINT16)ubShade*7/10);
|
||||
|
||||
pMerc = gpWorldLevelData[uiTile].pMercHead;
|
||||
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 fDuplicate=FALSE;
|
||||
//BOOLEAN fDuplicate=FALSE;
|
||||
DOUBLE dDistance;
|
||||
UINT8 ubShade;
|
||||
INT32 iLightDecay;
|
||||
@@ -1585,7 +1587,7 @@ BOOLEAN fInsertNodes=FALSE;
|
||||
for (i=0; i<=XDelta; i++)
|
||||
{
|
||||
LightInsertNode(iLight, usCurNode, iStartX, iStartY, iXPos, iYPos, ubStartIntens, usFlags);
|
||||
iXPos+=XAdvance;
|
||||
iXPos=iXPos+XAdvance;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1593,7 +1595,7 @@ BOOLEAN fInsertNodes=FALSE;
|
||||
for (i=0; i<=XDelta; i++)
|
||||
{
|
||||
LightAddNode(iLight, iStartX, iStartY, iXPos, iYPos, ubStartIntens, usFlags);
|
||||
iXPos+=XAdvance;
|
||||
iXPos=iXPos+XAdvance;
|
||||
}
|
||||
}
|
||||
return(TRUE);
|
||||
|
||||
@@ -91,8 +91,8 @@ INT16 gsStartRestrictedX, gsStartRestrictedY;
|
||||
BOOLEAN gfOverItemPool = FALSE;
|
||||
INT16 gsOveritemPoolGridNo;
|
||||
|
||||
int iOffsetHorizontal; // Horizontal start postion of the overview map
|
||||
int iOffsetVertical; // Vertical start position of the overview map
|
||||
UINT16 iOffsetHorizontal; // Horizontal start postion of the overview map
|
||||
UINT16 iOffsetVertical; // Vertical start position of the overview map
|
||||
|
||||
|
||||
void HandleOverheadUI( );
|
||||
|
||||
+38
-49
@@ -19,27 +19,6 @@
|
||||
|
||||
#define WORLD_BASE_HEIGHT 0
|
||||
#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
|
||||
//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_ROOFCODE_VISITED 0x0040 //0x40
|
||||
#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 SECOND_LEVEL 1
|
||||
@@ -165,27 +145,27 @@ struct LEVELNODE
|
||||
};
|
||||
|
||||
// Some can contains index values into dead corpses
|
||||
struct
|
||||
{
|
||||
//struct
|
||||
//{
|
||||
INT32 iCorpseID; // Index into corpse ID
|
||||
};
|
||||
//};
|
||||
|
||||
struct
|
||||
{
|
||||
//struct
|
||||
//{
|
||||
UINT32 uiAnimHitLocationFlags; // Animation profile flags for soldier placeholders ( prone merc hit location values )
|
||||
};
|
||||
//};
|
||||
|
||||
// Some can contains index values into animated tile data
|
||||
struct
|
||||
{
|
||||
//struct
|
||||
//{
|
||||
struct TAG_anitile *pAniTile;
|
||||
};
|
||||
//};
|
||||
|
||||
// Can be an item pool as well...
|
||||
struct
|
||||
{
|
||||
//struct
|
||||
//{
|
||||
ITEM_POOL *pItemPool; // ITEM POOLS
|
||||
};
|
||||
//};
|
||||
|
||||
|
||||
};
|
||||
@@ -207,33 +187,42 @@ struct LEVELNODE
|
||||
#define ONROOF_START_INDEX 7
|
||||
#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
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
LEVELNODE *pLandHead; //0
|
||||
LEVELNODE *pLandStart; //1
|
||||
//union
|
||||
//{
|
||||
//struct
|
||||
//{
|
||||
//LEVELNODE *pLandHead; //0
|
||||
//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 ];
|
||||
};
|
||||
//};
|
||||
|
||||
STRUCTURE *pStructureHead;
|
||||
STRUCTURE *pStructureTail;
|
||||
|
||||
Reference in New Issue
Block a user