**********************************************************

** Big Maps Projects code (incl. Multiplayer v1.5 **
**********************************************************
- Merged Big Maps Project code from BMP+MP trunk (Revision: 3340)
o Complete SVN Revision history: https://81.169.133.124/source/ja2/branches/Wanne/JA2%201.13%20MP
- Before THIS merge, I made a branch of the existing 1.13 source
o SVN Branch: https://81.169.133.124/source/ja2/branches/JA2_rev.3336/src
- Removed old VS 6.0 and VS 2003 project and solutions files, because compilation is broken long time ago
- I will add VS 2010 projects and solution file in the next few days

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@3341 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Wanne
2010-02-28 18:38:52 +00:00
parent a98c44ac78
commit 14750c6903
461 changed files with 23615 additions and 120157 deletions
+67 -70
View File
@@ -34,32 +34,29 @@ extern INT16 DirYIncrementer[8];
// GoAsFarAsPossibleTowards - C.O. stuff related to current animation esp first aid
// SetCivilianDestination - C.O. stuff for if we don't control the civ
int LegalNPCDestination(SOLDIERTYPE *pSoldier, INT16 sGridno, UINT8 ubPathMode, UINT8 ubWaterOK, UINT8 fFlags)
int LegalNPCDestination(SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT8 ubPathMode, UINT8 ubWaterOK, UINT8 fFlags)
{
BOOLEAN fSkipTilesWithMercs;
if ((sGridno < 0) || (sGridno >= GRIDSIZE))
if ((sGridNo < 0) || (sGridNo >= GRIDSIZE))
{
#ifdef RECORDNET
fprintf(NetDebugFile,"LegalNPC->pathing.sDestination: ERROR - rcvd invalid gridno %d",gridno);
fprintf(NetDebugFile,"LegalNPC->pathing.sDestination: ERROR - rcvd invalid gridno %d",GridNo);
#endif
#ifdef BETAVERSION
NumMessage("LegalNPC->pathing.sDestination: ERROR - rcvd invalid gridno ",gridno);
NumMessage("LegalNPC->pathing.sDestination: ERROR - rcvd invalid gridno ",GridNo);
#endif
return(FALSE);
}
// return false if gridno on different level from merc
if ( GridNoOnVisibleWorldTile( pSoldier->sGridNo ) && gpWorldLevelData[ pSoldier->sGridNo ].sHeight != gpWorldLevelData[ sGridno ].sHeight )
{
return( FALSE );
}
//dnl ch53 121009 Return false if gridno on different level from merc or inside unvisible area
if ((GridNoOnVisibleWorldTile(pSoldier->sGridNo) && gpWorldLevelData[pSoldier->sGridNo].sHeight != gpWorldLevelData[sGridNo].sHeight) || !GridNoOnVisibleWorldTile(sGridNo))
return(FALSE);
// skip mercs if turnbased and adjacent AND not doing an IGNORE_PATH check (which is used almost exclusively by GoAsFarAsPossibleTowards)
fSkipTilesWithMercs = (gfTurnBasedAI && ubPathMode != IGNORE_PATH && SpacesAway( pSoldier->sGridNo, sGridno ) == 1 );
fSkipTilesWithMercs = (gfTurnBasedAI && ubPathMode != IGNORE_PATH && SpacesAway( pSoldier->sGridNo, sGridNo ) == 1 );
// if this gridno is an OK destination
// AND the gridno is NOT in a tear-gassed tile when we have no gas mask
@@ -68,10 +65,10 @@ int LegalNPCDestination(SOLDIERTYPE *pSoldier, INT16 sGridno, UINT8 ubPathMode,
// AND the gridno hasn't been black-listed for us
// Nov 28 98: skip people in destination tile if in turnbased
if ( ( NewOKDestination(pSoldier, sGridno, fSkipTilesWithMercs, pSoldier->pathing.bLevel ) ) &&
( !InGas( pSoldier, sGridno ) ) &&
( sGridno != pSoldier->sGridNo ) &&
( sGridno != pSoldier->pathing.sBlackList ) )
if ( ( NewOKDestination(pSoldier, sGridNo, fSkipTilesWithMercs, pSoldier->pathing.bLevel ) ) &&
( !InGas( pSoldier, sGridNo ) ) &&
( sGridNo != pSoldier->sGridNo ) &&
( sGridNo != pSoldier->pathing.sBlackList ) )
/*
if ( ( NewOKDestination(pSoldier, sGridno, FALSE, pSoldier->pathing.bLevel ) ) &&
( !(gpWorldLevelData[ sGridno ].ubExtFlags[0] & (MAPELEMENT_EXT_SMOKE | MAPELEMENT_EXT_TEARGAS | MAPELEMENT_EXT_MUSTARDGAS)) || ( pSoldier->inv[ HEAD1POS ].usItem == GASMASK || pSoldier->inv[ HEAD2POS ].usItem == GASMASK ) ) &&
@@ -86,16 +83,16 @@ int LegalNPCDestination(SOLDIERTYPE *pSoldier, INT16 sGridno, UINT8 ubPathMode,
{
// if water's a problem, and gridno is in a water tile (bridges are OK)
if (!ubWaterOK && Water(sGridno))
if (!ubWaterOK && Water(sGridNo))
return(FALSE);
//Madd: added to prevent people from running into gas and fire
if ( (gpWorldLevelData[sGridno].ubExtFlags[pSoldier->pathing.bLevel] & (MAPELEMENT_EXT_TEARGAS | MAPELEMENT_EXT_MUSTARDGAS)) &&
if ( (gpWorldLevelData[sGridNo].ubExtFlags[pSoldier->pathing.bLevel] & (MAPELEMENT_EXT_TEARGAS | MAPELEMENT_EXT_MUSTARDGAS)) &&
FindGasMask(pSoldier) == NO_SLOT )
{
return( FALSE );
}
if ( gpWorldLevelData[sGridno].ubExtFlags[pSoldier->pathing.bLevel] & MAPELEMENT_EXT_BURNABLEGAS )
if ( gpWorldLevelData[sGridNo].ubExtFlags[pSoldier->pathing.bLevel] & MAPELEMENT_EXT_BURNABLEGAS )
{
return( FALSE );
}
@@ -108,7 +105,7 @@ int LegalNPCDestination(SOLDIERTYPE *pSoldier, INT16 sGridno, UINT8 ubPathMode,
// for example), don't bother
case IGNORE_PATH : return(TRUE);
case ENSURE_PATH : if ( FindBestPath( pSoldier, sGridno, pSoldier->pathing.bLevel, WALKING, COPYROUTE, fFlags ) )
case ENSURE_PATH : if ( FindBestPath( pSoldier, sGridNo, pSoldier->pathing.bLevel, WALKING, COPYROUTE, fFlags ) )
{
return(TRUE); // legal destination
}
@@ -118,7 +115,7 @@ int LegalNPCDestination(SOLDIERTYPE *pSoldier, INT16 sGridno, UINT8 ubPathMode,
return(FALSE);
}
// *** NOTE: movement mode hardcoded to WALKING !!!!!
case ENSURE_PATH_COST: return(PlotPath(pSoldier,sGridno,FALSE,FALSE,FALSE,WALKING,FALSE,FALSE,0));
case ENSURE_PATH_COST: return(PlotPath(pSoldier,sGridNo,FALSE,FALSE,FALSE,WALKING,FALSE,FALSE,0));
default :
#ifdef BETAVERSION
@@ -134,7 +131,7 @@ int LegalNPCDestination(SOLDIERTYPE *pSoldier, INT16 sGridno, UINT8 ubPathMode,
int TryToResumeMovement(SOLDIERTYPE *pSoldier, INT16 sGridno)
int TryToResumeMovement(SOLDIERTYPE *pSoldier, INT32 sGridNo)
{
UINT8 ubGottaCancel = FALSE;
UINT8 ubSuccess = FALSE;
@@ -142,7 +139,7 @@ int TryToResumeMovement(SOLDIERTYPE *pSoldier, INT16 sGridno)
// have to make sure the old destination is still legal (somebody may
// have occupied the destination gridno in the meantime!)
if (LegalNPCDestination(pSoldier,sGridno,ENSURE_PATH,WATEROK,0))
if (LegalNPCDestination(pSoldier,sGridNo,ENSURE_PATH,WATEROK,0))
{
#ifdef DEBUGDECISIONS
STR tempstr;
@@ -153,12 +150,12 @@ int TryToResumeMovement(SOLDIERTYPE *pSoldier, INT16 sGridno)
pSoldier->pathing.bPathStored = TRUE; // optimization - Ian
// make him go to it (needed to continue movement across multiple turns)
NewDest(pSoldier,sGridno);
NewDest(pSoldier,sGridNo);
ubSuccess = TRUE;
// make sure that it worked (check that pSoldier->pathing.sDestination == pSoldier->sGridNo)
if (pSoldier->pathing.sDestination == sGridno)
if (pSoldier->pathing.sDestination == sGridNo)
{
ubSuccess = TRUE;
}
@@ -207,26 +204,26 @@ int TryToResumeMovement(SOLDIERTYPE *pSoldier, INT16 sGridno)
{
// this is an escorted NPC, don't want to just completely stop
// moving, try to find a nearby "next best" destination if possible
pSoldier->aiData.usActionData = GoAsFarAsPossibleTowards(pSoldier,sGridno,pSoldier->aiData.bAction);
pSoldier->aiData.usActionData = GoAsFarAsPossibleTowards(pSoldier,sGridNo,pSoldier->aiData.bAction);
// if it's not possible to get any closer
if (pSoldier->aiData.usActionData == NOWHERE)
// if it's not possible to get any closer
if (TileIsOutOfBounds(pSoldier->aiData.usActionData))
{
ubGottaCancel = TRUE;
}
else
{
// change his desired destination to this new one
sGridno = pSoldier->aiData.usActionData;
sGridNo = pSoldier->aiData.usActionData;
// GoAsFar... sets pathStored TRUE only if he could go all the way
// make him go to it (needed to continue movement across multiple turns)
NewDest(pSoldier,sGridno);
NewDest(pSoldier,sGridNo);
// make sure that it worked (check that pSoldier->pathing.sDestination == pSoldier->sGridNo)
if (pSoldier->pathing.sDestination == sGridno)
if (pSoldier->pathing.sDestination == sGridNo)
ubSuccess = TRUE;
else
ubGottaCancel = TRUE;
@@ -248,7 +245,7 @@ int TryToResumeMovement(SOLDIERTYPE *pSoldier, INT16 sGridno)
INT16 NextPatrolPoint(SOLDIERTYPE *pSoldier)
INT32 NextPatrolPoint(SOLDIERTYPE *pSoldier)
{
// patrol slot 0 is UNUSED, so max patrolCnt is actually only 9
if ((pSoldier->aiData.bPatrolCnt < 1) || (pSoldier->aiData.bPatrolCnt >= MAXPATROLGRIDS))
@@ -276,7 +273,7 @@ INT16 NextPatrolPoint(SOLDIERTYPE *pSoldier)
INT8 PointPatrolAI(SOLDIERTYPE *pSoldier)
{
INT16 sPatrolPoint;
INT32 sPatrolPoint;
INT8 bOldOrders;
#ifdef DEBUGDECISIONS
STR16 tempstr;
@@ -291,8 +288,8 @@ INT8 PointPatrolAI(SOLDIERTYPE *pSoldier)
do
{
sPatrolPoint = NextPatrolPoint(pSoldier);
}
while ((sPatrolPoint != NOWHERE) && (NewOKDestination(pSoldier,sPatrolPoint,IGNOREPEOPLE, pSoldier->pathing.bLevel) < 1));
}
while (( !TileIsOutOfBounds(sPatrolPoint)) && (NewOKDestination(pSoldier,sPatrolPoint,IGNOREPEOPLE, pSoldier->pathing.bLevel) < 1));
// if we're back where we started, then ALL other patrol points are junk!
if (pSoldier->sGridNo == sPatrolPoint)
@@ -305,8 +302,8 @@ INT8 PointPatrolAI(SOLDIERTYPE *pSoldier)
}
}
// if we don't have a legal patrol point
if (sPatrolPoint == NOWHERE)
// if we don't have a legal patrol point
if (TileIsOutOfBounds(sPatrolPoint))
{
#ifdef BETAVERSION
NumMessage("PointPatrolAI: ERROR - no legal patrol point for %d",pSoldier->ubID);
@@ -336,8 +333,8 @@ INT8 PointPatrolAI(SOLDIERTYPE *pSoldier)
pSoldier->aiData.bOrders = bOldOrders;
// if it's not possible to get any closer, that's OK, but fail this call
if (pSoldier->aiData.usActionData == NOWHERE)
// if it's not possible to get any closer, that's OK, but fail this call
if (TileIsOutOfBounds(pSoldier->aiData.usActionData))
return(FALSE);
}
@@ -356,7 +353,7 @@ INT8 RandomPointPatrolAI(SOLDIERTYPE *pSoldier)
#ifdef DEBUGDECISIONS
STR16 tempstr;
#endif
INT16 sPatrolPoint;
INT32 sPatrolPoint;
INT8 bOldOrders, bPatrolIndex;
INT8 bCnt;
@@ -375,8 +372,8 @@ INT8 RandomPointPatrolAI(SOLDIERTYPE *pSoldier)
bPatrolIndex = (INT8) PreRandom( pSoldier->aiData.bPatrolCnt ) + 1;
sPatrolPoint = pSoldier->aiData.sPatrolGrid[ bPatrolIndex];
bCnt++;
}
while ( (sPatrolPoint == pSoldier->sGridNo) || ( (sPatrolPoint != NOWHERE) && (bCnt < pSoldier->aiData.bPatrolCnt) && (NewOKDestination(pSoldier,sPatrolPoint,IGNOREPEOPLE, pSoldier->pathing.bLevel ) < 1)) );
}
while ( (sPatrolPoint == pSoldier->sGridNo) || ( (!TileIsOutOfBounds(sPatrolPoint)) && (bCnt < pSoldier->aiData.bPatrolCnt) && (NewOKDestination(pSoldier,sPatrolPoint,IGNOREPEOPLE, pSoldier->pathing.bLevel ) < 1)) );
if (bCnt == pSoldier->aiData.bPatrolCnt)
{
@@ -385,8 +382,8 @@ INT8 RandomPointPatrolAI(SOLDIERTYPE *pSoldier)
do
{
sPatrolPoint = NextPatrolPoint(pSoldier);
}
while ((sPatrolPoint != NOWHERE) && (NewOKDestination(pSoldier,sPatrolPoint,IGNOREPEOPLE, pSoldier->pathing.bLevel) < 1));
}
while ((!TileIsOutOfBounds(sPatrolPoint)) && (NewOKDestination(pSoldier,sPatrolPoint,IGNOREPEOPLE, pSoldier->pathing.bLevel) < 1));
}
// do nothing this time around
@@ -396,8 +393,8 @@ INT8 RandomPointPatrolAI(SOLDIERTYPE *pSoldier)
}
}
// if we don't have a legal patrol point
if (sPatrolPoint == NOWHERE)
// if we don't have a legal patrol point
if (TileIsOutOfBounds(sPatrolPoint))
{
#ifdef BETAVERSION
NumMessage("PointPatrolAI: ERROR - no legal patrol point for %d",pSoldier->ubID);
@@ -426,8 +423,8 @@ INT8 RandomPointPatrolAI(SOLDIERTYPE *pSoldier)
pSoldier->aiData.bOrders = bOldOrders;
// if it's not possible to get any closer, that's OK, but fail this call
if (pSoldier->aiData.usActionData == NOWHERE)
// if it's not possible to get any closer, that's OK, but fail this call
if (TileIsOutOfBounds(pSoldier->aiData.usActionData))
return(FALSE);
}
@@ -443,14 +440,14 @@ INT8 RandomPointPatrolAI(SOLDIERTYPE *pSoldier)
INT16 InternalGoAsFarAsPossibleTowards(SOLDIERTYPE *pSoldier, INT16 sDesGrid, INT16 bReserveAPs, INT8 bAction, INT8 fFlags )
INT32 InternalGoAsFarAsPossibleTowards(SOLDIERTYPE *pSoldier, INT32 sDesGrid, INT16 bReserveAPs, INT8 bAction, INT8 fFlags )
{
#ifdef DEBUGDECISIONS
STR16 tempstr;
#endif
INT16 sLoop,sAPCost;
INT16 sTempDest,sGoToGrid;
INT16 sOrigin;
INT32 sLoop,sAPCost;
INT32 sTempDest,sGoToGrid;
INT32 sOrigin;
UINT16 usMaxDist;
UINT8 ubDirection,ubDirsLeft,ubDirChecked[8],fFound = FALSE;
INT8 bAPsLeft, fPathFlags;
@@ -483,8 +480,8 @@ INT16 InternalGoAsFarAsPossibleTowards(SOLDIERTYPE *pSoldier, INT16 sDesGrid, IN
{
if ( InARoom( pSoldier->aiData.sPatrolGrid[0], &ubRoomRequired ) )
{
// make sure this doesn't interfere with pathing for scripts
if ( pSoldier->sAbsoluteFinalDestination != NOWHERE )
// make sure this doesn't interfere with pathing for scripts
if (!TileIsOutOfBounds(pSoldier->sAbsoluteFinalDestination))
{
ubRoomRequired = 0;
}
@@ -787,14 +784,14 @@ INT16 InternalGoAsFarAsPossibleTowards(SOLDIERTYPE *pSoldier, INT16 sDesGrid, IN
}
}
INT16 GoAsFarAsPossibleTowards(SOLDIERTYPE *pSoldier, INT16 sDesGrid, INT8 bAction)
INT32 GoAsFarAsPossibleTowards(SOLDIERTYPE *pSoldier, INT32 sDesGrid, INT8 bAction)
{
return( InternalGoAsFarAsPossibleTowards( pSoldier, sDesGrid, -1, bAction, 0 ) );
}
void SoldierTriesToContinueAlongPath(SOLDIERTYPE *pSoldier)
{
INT16 sNewGridNo,bAPCost;
INT32 usNewGridNo,bAPCost;
// turn off the flag now that we're going to do something about it...
@@ -807,7 +804,7 @@ void SoldierTriesToContinueAlongPath(SOLDIERTYPE *pSoldier)
return;
}
if (pSoldier->aiData.usActionData >= NOWHERE)
if (TileIsOutOfBounds(pSoldier->aiData.usActionData))
{
CancelAIAction(pSoldier,DONTFORCE);
return;
@@ -844,15 +841,15 @@ void SoldierTriesToContinueAlongPath(SOLDIERTYPE *pSoldier)
#endif
}
sNewGridNo = NewGridNo( (INT16)pSoldier->sGridNo, DirectionInc( (UINT8)pSoldier->pathing.usPathingData[ pSoldier->pathing.usPathIndex ] ) );
usNewGridNo = NewGridNo( pSoldier->sGridNo, DirectionInc( (UINT8)pSoldier->pathing.usPathingData[ pSoldier->pathing.usPathIndex ] ) );
// Find out how much it takes to move here!
bAPCost = EstimateActionPointCost( pSoldier, sNewGridNo, (INT8)pSoldier->pathing.usPathingData[ pSoldier->pathing.usPathIndex ], pSoldier->usUIMovementMode, (INT8) pSoldier->pathing.usPathIndex, (INT8) pSoldier->pathing.usPathDataSize );
bAPCost = EstimateActionPointCost( pSoldier, usNewGridNo, (INT8)pSoldier->pathing.usPathingData[ pSoldier->pathing.usPathIndex ], pSoldier->usUIMovementMode, (INT8) pSoldier->pathing.usPathIndex, (INT8) pSoldier->pathing.usPathDataSize );
if (pSoldier->bActionPoints >= bAPCost )
if (pSoldier->bActionPoints >= bAPCost)
{
// seems to have enough points...
NewDest(pSoldier,sNewGridNo);
NewDest(pSoldier,usNewGridNo);
// maybe we didn't actually start the action last turn...
pSoldier->aiData.bActionInProgress = TRUE;
#ifdef TESTAI
@@ -913,7 +910,7 @@ void HaltMoveForSoldierOutOfPoints(SOLDIERTYPE *pSoldier)
}
}
void SetCivilianDestination(UINT8 ubWho, INT16 sGridno)
void SetCivilianDestination(UINT8 ubWho, INT32 sGridNo)
{
SOLDIERTYPE *pSoldier;
@@ -926,10 +923,10 @@ void SetCivilianDestination(UINT8 ubWho, INT16 sGridno)
{
*/
// if the destination is different from what he has now
if (pSoldier->aiData.usActionData != sGridno)
if (pSoldier->aiData.usActionData != sGridNo)
{
// store his new destination
pSoldier->aiData.usActionData = sGridno;
pSoldier->aiData.usActionData = sGridNo;
// and cancel any movement in progress that he was still engaged in
pSoldier->aiData.bAction = AI_ACTION_NONE;
@@ -964,7 +961,7 @@ void SetCivilianDestination(UINT8 ubWho, INT16 sGridno)
#define RADIUS 3
INT16 TrackScent( SOLDIERTYPE * pSoldier )
INT32 TrackScent( SOLDIERTYPE * pSoldier )
{
// This function returns the best gridno to go to based on the scent being followed,
// and the soldier (creature/animal)'s current direction (which is used to resolve
@@ -1037,8 +1034,8 @@ INT16 TrackScent( SOLDIERTYPE * pSoldier )
}
}
else if (ubStrength == ubBestStrength)
{
if (iBestGridNo == NOWHERE)
{
if (TileIsOutOfBounds(iBestGridNo))
{
// first place we've found with the same strength
iBestGridNo = iGridNo;
@@ -1074,11 +1071,11 @@ INT16 TrackScent( SOLDIERTYPE * pSoldier )
else
{
// who else can track?
}
if (iBestGridNo != NOWHERE )
}
if (!TileIsOutOfBounds(iBestGridNo))
{
pSoldier->aiData.usActionData = (INT16) iBestGridNo;
return( (INT16) iBestGridNo );
pSoldier->aiData.usActionData = iBestGridNo;
return( iBestGridNo );
}
return( 0 );
}