Skip to content

Commit

Permalink
Implement: enable the pioneer to build a road to the selected point (W…
Browse files Browse the repository at this point in the history
…e-the-People-civ4col-mod#427) [1] - still crashes!
  • Loading branch information
jo-oe committed Apr 14, 2023
1 parent 2f447be commit a3393d0
Show file tree
Hide file tree
Showing 11 changed files with 285 additions and 95 deletions.
Binary file modified Assets/CvGameCoreDLL.dll
Binary file not shown.
Binary file modified Assets/CvGameCoreDLL.pdb
Binary file not shown.
46 changes: 46 additions & 0 deletions Assets/XML/Interface/CIV4InterfaceModeInfos.xml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,52 @@
<bSelectAll>0</bSelectAll>
<Button>Art/Interface/Game Hud/Actions/route_to_high_res.dds</Button>
</InterfaceModeInfo>
<InterfaceModeInfo>
<Type>INTERFACEMODE_ROUTE_TO_ROAD</Type>
<Description>TXT_KEY_INTERFACEMODE_ROUTE_TO_ROAD</Description>
<Help>TXT_KEY_INTERFACEMODE_ROUTE_TO_ROAD_HELP</Help>
<CursorType>CURSOR_ROUTE_TO</CursorType>
<Mission>MISSION_ROUTE_TO_ROAD</Mission>
<HotKey>KB_R</HotKey>
<bAltDown>1</bAltDown>
<bShiftDown>1</bShiftDown>
<bCtrlDown>0</bCtrlDown>
<iHotKeyPriority>0</iHotKeyPriority>
<HotKeyAlt/>
<bAltDownAlt>0</bAltDownAlt>
<bShiftDownAlt>0</bShiftDownAlt>
<bCtrlDownAlt>0</bCtrlDownAlt>
<iHotKeyPriorityAlt>0</iHotKeyPriorityAlt>
<bVisible>1</bVisible>
<bGotoPlot>1</bGotoPlot>
<bHighlightPlot>0</bHighlightPlot>
<bSelectType>0</bSelectType>
<bSelectAll>0</bSelectAll>
<Button>Art/Interface/Game Hud/Actions/route_to_road.dds</Button>
</InterfaceModeInfo>
<InterfaceModeInfo>
<Type>INTERFACEMODE_ROUTE_TO_PLASTERED_ROAD</Type>
<Description>TXT_KEY_INTERFACEMODE_ROUTE_TO_PLASTERED_ROAD</Description>
<Help>TXT_KEY_INTERFACEMODE_ROUTE_TO_PLASTERED_ROAD_HELP</Help>
<CursorType>CURSOR_ROUTE_TO</CursorType>
<Mission>MISSION_ROUTE_TO_PLASTERED_ROAD</Mission>
<HotKey>KB_R</HotKey>
<bAltDown>1</bAltDown>
<bShiftDown>0</bShiftDown>
<bCtrlDown>1</bCtrlDown>
<iHotKeyPriority>0</iHotKeyPriority>
<HotKeyAlt/>
<bAltDownAlt>0</bAltDownAlt>
<bShiftDownAlt>0</bShiftDownAlt>
<bCtrlDownAlt>0</bCtrlDownAlt>
<iHotKeyPriorityAlt>0</iHotKeyPriorityAlt>
<bVisible>1</bVisible>
<bGotoPlot>1</bGotoPlot>
<bHighlightPlot>0</bHighlightPlot>
<bSelectType>0</bSelectType>
<bSelectAll>0</bSelectAll>
<Button>Art/Interface/Game Hud/Actions/route_to_plastered_road.dds</Button>
</InterfaceModeInfo>
<InterfaceModeInfo>
<Type>INTERFACEMODE_PYTHON_PICK_PLOT</Type>
<Description>TXT_KEY_INTERFACEMODE_PYTHON_PICK_PLOT</Description>
Expand Down
18 changes: 17 additions & 1 deletion Assets/XML/Text/XML_AUTO_UTF8_MissionInfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,28 @@
</TEXT>
<TEXT>
<Tag>TXT_KEY_MISSION_ROUTE_TO_HELP</Tag>
<English>This order causes the pioneer to build a road to the location selected. The pioneer will follow the shortest path to the location. The pioneer wakes when it has completed the assignment.</English>
<English>This order causes the pioneer to build the best road available to the location selected. The pioneer will follow the shortest path to the location. The pioneer wakes when it has completed the assignment.</English>
<French>Ordonne au pionnier de construire une route vers l'endroit indiqué. Il suivra le chemin le plus court et sera à nouveau disponible lorsqu'il aura terminé sa mission.</French>
<German>Befehlen Sie einem Pionier, eine Straße zur gewählten Position zu bauen. Ihr Pionier wählt nun den kürzesten Weg und wartet nach dem Bau auf weitere Befehle.</German>
<Italian>Questo comando fa in modo che il pioniere costruisca una strada fino alla destinazione scelta. L'unità seguirà il percorso più breve verso la destinazione e si renderà nuovamente disponibile una volta completato l'incarico.</Italian>
<Spanish>Con esta orden hacéis que un Pionero construya una carretera al lugar seleccionado. El Pionero seguirá el camino más corto hasta dicho lugar. Se podrá seleccionar cuando haya cumplido su cometido.</Spanish>
</TEXT>
<TEXT>
<Tag>TXT_KEY_MISSION_ROUTE_TO_ROAD</Tag>
<English>Route to (country road)</English>
</TEXT>
<TEXT>
<Tag>TXT_KEY_MISSION_ROUTE_TO_ROAD_HELP</Tag>
<English>This order causes the pioneer to build a country road to the location selected. The pioneer will follow the shortest path to the location. The pioneer wakes when it has completed the assignment.</English>
</TEXT>
<TEXT>
<Tag>TXT_KEY_MISSION_ROUTE_TO_PLASTERED_ROAD</Tag>
<English>Route to (plastered road)</English>
</TEXT>
<TEXT>
<Tag>TXT_KEY_MISSION_ROUTE_TO_PLASTERED_ROAD_HELP</Tag>
<English>This order causes the pioneer to build a plastered road to the location selected. The pioneer will follow the shortest path to the location. The pioneer wakes when it has completed the assignment.</English>
</TEXT>
<TEXT>
<Tag>TXT_KEY_MISSION_SENTRY</Tag>
<English>Sentry</English>
Expand Down
20 changes: 20 additions & 0 deletions Assets/XML/Units/CIV4MissionInfos.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,26 @@
<bBuild>0</bBuild>
<bSound>1</bSound>
</MissionInfo>
<MissionInfo>
<Type>MISSION_ROUTE_TO_ROAD</Type>
<Description>TXT_KEY_MISSION_ROUTE_TO_ROAD</Description>
<Help>TXT_KEY_MISSION_ROUTE_TO_ROAD_HELP</Help>
<Waypoint>EFFECT_FOOTSTEP_ON</Waypoint>
<iTime>4</iTime>
<bTarget>1</bTarget>
<bBuild>0</bBuild>
<bSound>1</bSound>
</MissionInfo>
<MissionInfo>
<Type>MISSION_ROUTE_TO_PLASTERED_ROAD</Type>
<Description>TXT_KEY_MISSION_ROUTE_TO_PLASTERED_ROAD</Description>
<Help>TXT_KEY_MISSION_ROUTE_TO_PLASTERED_ROAD_HELP</Help>
<Waypoint>EFFECT_FOOTSTEP_ON</Waypoint>
<iTime>4</iTime>
<bTarget>1</bTarget>
<bBuild>0</bBuild>
<bSound>1</bSound>
</MissionInfo>
<MissionInfo>
<Type>MISSION_MOVE_TO_UNIT</Type>
<Description>TXT_KEY_MISSION_MOVE_TO_UNIT</Description>
Expand Down
46 changes: 24 additions & 22 deletions Project Files/DLLSources/CvGameCoreUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ bool shouldMoveBefore(const CvUnit* pUnitA, const CvUnit* pUnitB)

const int iMovePriorityA = (pUnitA != NULL) ? pUnitA->AI_getMovePriority() : 0;
const int iMovePriorityB = (pUnitB != NULL) ? pUnitB->AI_getMovePriority() : 0;

const int iDiff = iMovePriorityA - iMovePriorityB;
if (iDiff > 0)
{
Expand Down Expand Up @@ -946,11 +946,11 @@ int pathDestValid(int iToX, int iToY, const void* pointer, FAStar* finder)
{
return FALSE;
}
}
}
if (!(iFlags & MOVE_IGNORE_DANGER))
{
if (!isPlotSafe(*pSelectionGroup, iToX, iToY))
return FALSE;
return FALSE;

if (!AI_allowMove(*pSelectionGroup, kToPlot))
return FALSE;
Expand Down Expand Up @@ -1105,7 +1105,7 @@ int pathCost(FAStarNode* parent, FAStarNode* node, int data, const void* pointer
else
{
CvPlot* pAdjacentPlot;

for (int iI = 0; iI < NUM_DIRECTION_TYPES; iI++)
{
pAdjacentPlot = plotDirection(pToPlot->getX_INLINE(), pToPlot->getY_INLINE(), ((DirectionTypes)iI));
Expand Down Expand Up @@ -1134,7 +1134,7 @@ int pathCost(FAStarNode* parent, FAStarNode* node, int data, const void* pointer
for (iI = 0; iI < NUM_DIRECTION_TYPES; iI++)
{
pAdjacentPlot = plotDirection(pToPlot->getX_INLINE(), pToPlot->getY_INLINE(), ((DirectionTypes)iI));

if( pAdjacentPlot != NULL )
{
if (pAdjacentPlot->isOwned() && (atWar(pAdjacentPlot->getTeam(), pSelectionGroup->getHeadTeam()) || (pAdjacentPlot->getTeam() != pLoopUnit->getTeam() && pLoopUnit->isAlwaysHostile(pAdjacentPlot))))
Expand Down Expand Up @@ -1488,7 +1488,7 @@ int pathCost(FAStarNode* parent, FAStarNode* node, int data, const void* pointer
GC.getMAX_HIT_POINTS();
}

/* WTP: Not supported
/* WTP: Not supported
if (kToPlot.getExtraMovePathCost() > 0)
{
iWorstCost += (PATH_MOVEMENT_WEIGHT * kToPlot.getExtraMovePathCost());
Expand Down Expand Up @@ -1618,7 +1618,7 @@ int pathValid_join(FAStarNode* parent, FAStarNode* node, CvSelectionGroup* pSele
CvMap const& kMap = GC.getMap();
CvPlot const& kFromPlot = kMap.getPlot(parent->m_iX, parent->m_iY);
CvPlot const& kToPlot = kMap.getPlot(node->m_iX, node->m_iY);
// Ship can't cross isthmus
// Ship can't cross isthmus
if (pSelectionGroup->getDomainType() == DOMAIN_SEA &&
kFromPlot.isWater() && kToPlot.isWater() &&
!kMap.getPlot(kFromPlot.getX(), kToPlot.getY()).isWater() &&
Expand Down Expand Up @@ -1656,13 +1656,13 @@ int pathValid_source(FAStarNode* parent, CvSelectionGroup* pSelectionGroup, int
return FALSE;
}
} // </advc.049>

if (iFlags & MOVE_NO_ENEMY_TERRITORY && kFromPlot.isOwned() &&
atWar(kFromPlot.getTeam(), pSelectionGroup->getHeadTeam()))
return FALSE;

bool const bAIControl = pSelectionGroup->AI_isControlled();

if (bAIControl)
{
if (parent->m_iData2 > 1 || parent->m_iData1 == 0)
Expand Down Expand Up @@ -1788,7 +1788,7 @@ int pathAdd(FAStarNode* parent, FAStarNode* node, int data, const void* pointer,
{
// K-Mod. I've moved the code from here into separate functions.
iMoves = bMoveMaxMoves ? pSelectionGroup->maxMoves() : pSelectionGroup->movesLeft();

#if GLOBAL_DEFINE_USE_CLASSIC_MOVEMENT_SYSTEM == 0
while (iMoves <= 0)
{
Expand Down Expand Up @@ -1820,7 +1820,7 @@ int pathAdd(FAStarNode* parent, FAStarNode* node, int data, const void* pointer,
// the original code would consistently underestimate the remaining moves at every step.)
#if GLOBAL_DEFINE_USE_CLASSIC_MOVEMENT_SYSTEM == 1
const bool bNewTurn = iMoves == 0;

if (bNewTurn)
{
++iTurns;
Expand Down Expand Up @@ -1954,9 +1954,9 @@ int stepValid(FAStarNode* parent, FAStarNode* node, int data, const void* pointe
{
return FALSE;
}


// Super Forts begin *choke*

// Super Forts begin *choke*
int iInvalidPlot = gDLL->getFAStarIFace()->GetInfo(finder);
if(iInvalidPlot > 0)
{
Expand Down Expand Up @@ -2044,7 +2044,7 @@ int routeValid(FAStarNode* parent, FAStarNode* node, int data, const void* point
int coastalRouteValid(FAStarNode* parent, FAStarNode* node, int data, const void* pointer, FAStar* finder)
{
CvPlot* pNewPlot;

if (parent == NULL)
{
return true;
Expand All @@ -2071,14 +2071,14 @@ int coastalRouteValid(FAStarNode* parent, FAStarNode* node, int data, const void
const TeamTypes eTeam = GET_PLAYER(ePlayer).getTeam();

if (pNewPlot->isWater() && pNewPlot->isRevealed(eTeam, false) && !pNewPlot->isImpassable())
{
{
const FeatureTypes featureType = pNewPlot->getFeatureType();

// Erik: If the plot has a feature it can't be impassable
if (featureType != NO_FEATURE)
{
const CvFeatureInfo& kFeatureInfo = GC.getFeatureInfo(featureType);

// Erik: Just in case impassable terrain is added to the game (unused in WTP)
if (!kFeatureInfo.isImpassable())
{
Expand Down Expand Up @@ -2305,6 +2305,8 @@ void getMissionTypeString(CvWString& szString, MissionTypes eMissionType)

case MISSION_MOVE_TO: szString = L"MISSION_MOVE_TO"; break;
case MISSION_ROUTE_TO: szString = L"MISSION_ROUTE_TO"; break;
case MISSION_ROUTE_TO_ROAD: szString = L"MISSION_ROUTE_TO_ROAD"; break;
case MISSION_ROUTE_TO_PLASTERED_ROAD: szString = L"MISSION_ROUTE_TO_PLASTERED_ROAD"; break;
case MISSION_MOVE_TO_UNIT: szString = L"MISSION_MOVE_TO_UNIT"; break;
case MISSION_SKIP: szString = L"MISSION_SKIP"; break;
case MISSION_SLEEP: szString = L"MISSION_SLEEP"; break;
Expand Down Expand Up @@ -2451,7 +2453,7 @@ void postLoadGameFixes()
CvMap& kMap = GC.getMap();
kMap.updateWaterPlotTerrainTypes(); // autodetect lakes
const int iNumPlots = kMap.numPlotsINLINE();

// reset visibility count as it is garbage right now
// this might not be needed anymore, but keep it just to be safe
// Nightinggale
Expand All @@ -2471,29 +2473,29 @@ void postLoadGameFixes()
for (PlayerTypes ePlayer = FIRST_PLAYER; ePlayer < NUM_PLAYER_TYPES; ++ePlayer)
{
// deal with each players' cities

int iLoop;
for (CvCity* pLoopCity = GET_PLAYER(ePlayer).firstCity(&iLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER(ePlayer).nextCity(&iLoop))
{
pLoopCity->updateSlaveWorkerProductionBonus();
}

CvPlayer& kPlayer = GET_PLAYER(ePlayer);

// calculate power and assets
kPlayer.checkPower(true);

// prepare list of city professions (aka citizens)
if (kPlayer.getCivilizationType() != NO_CIVILIZATION)
{
kPlayer.m_validCityJobProfessions.clear();
// Notes from Nightinggale
// The xml data (all files) is ready at the end of CvXMLLoadUtility::readXMLfiles when bFirst is False
// CvXMLLoadUtility::readXMLfiles is in CvXMLLoadUtilitySet.cpp
//
//
// The CivEffect branch affects this in two ways:
// 1: it adds CvPlayer::canUseProfession (which might change during the game due to CivEffects)
// 2: it adds a class where the intended purpose is precisely what kValidCityJobs does (but it stores ProfessionTypes, not int)
// 2: it adds a class where the intended purpose is precisely what kValidCityJobs does (but it stores ProfessionTypes, not int)
// Combine those two and CvPlayer can generate/cache kValidCityJobs whenever CivEffects change (rare event)
//
// Proposal: split kValidCityJobs into two and use bIndoorOnly to pick which one to use.
Expand Down
Loading

0 comments on commit a3393d0

Please sign in to comment.