1 #include "Campaign_Types.h"
2 #include "Strategic_Movement.h"
3 #include "Strategic_Movement_Costs.h"
4 #include "GameInstance.h"
5 #include "DefaultContentManager.h"
6 #include "MovementCostsModel.h"
7 
8 
InitStrategicMovementCosts()9 void InitStrategicMovementCosts()
10 {
11 	auto movementCosts = GCM->getMovementCosts();
12 	for (INT32 y = 0; y < 16; ++y)
13 	{
14 		for (INT32 x = 0; x < 16; ++x)
15 		{
16 			SECTORINFO& s = SectorInfo[SECTOR(x + 1, y + 1)];
17 			s.ubTravelRating                           = movementCosts->getTravelRating(x, y);
18 			s.ubTraversability[WEST_STRATEGIC_MOVE]    = movementCosts->getTraversibilityWestEast(x, y);
19 			s.ubTraversability[EAST_STRATEGIC_MOVE]    = movementCosts->getTraversibilityWestEast(x + 1, y);
20 			s.ubTraversability[NORTH_STRATEGIC_MOVE]   = movementCosts->getTraversibilityNorthSouth(x, y);
21 			s.ubTraversability[SOUTH_STRATEGIC_MOVE]   = movementCosts->getTraversibilityNorthSouth(x, y + 1);
22 			s.ubTraversability[THROUGH_STRATEGIC_MOVE] = movementCosts->getTraversibilityThrough(x, y);
23 		}
24 	}
25 }
26 
27 
GetTraversability(INT16 sStartSector,INT16 sEndSector)28 UINT8 GetTraversability( INT16 sStartSector, INT16 sEndSector )
29 {
30 	UINT8 ubDirection = 0;
31 	INT16 sDifference = 0;
32 
33 	// given start and end sectors
34 	sDifference = sEndSector - sStartSector;
35 
36 
37 	if( sDifference == -1 )
38 	{
39 		ubDirection = WEST_STRATEGIC_MOVE;
40 	}
41 	else if( sDifference == 1 )
42 	{
43 		ubDirection = EAST_STRATEGIC_MOVE;
44 	}
45 	else if( sDifference == 16 )
46 	{
47 		ubDirection = SOUTH_STRATEGIC_MOVE;
48 	}
49 	else
50 	{
51 		ubDirection = NORTH_STRATEGIC_MOVE;
52 	}
53 
54 	return( SectorInfo[ sStartSector ].ubTraversability[ ubDirection ] );
55 }
56 
57 
SectorIsPassable(INT16 const sSector)58 bool SectorIsPassable(INT16 const sSector)
59 {
60 	// returns true if the sector is impassable in all directions
61 	const UINT8 t = SectorInfo[sSector].ubTraversability[THROUGH_STRATEGIC_MOVE];
62 	return t != GROUNDBARRIER && t != EDGEOFWORLD;
63 }
64 
65