mirror of
https://github.com/1dot13/source.git
synced 2026-07-29 13:52:17 +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 );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user