Single Player bugs and crashes v37 plus (SVN) - After the 24th of December 2016

I am not seeing that mission, "MISSION_BARBARIAN_ENVOY" being used anywhere in the XML or the Python.:confused:
Exactly. So how is it coming up as the mission that just got selected when watching the code in progress? Something is very wrong here. I'm saying it's wrong from inside the code, not necessarily the XML. And it's wrong in a very mystifying way that perhaps AIAndy, who wrote the code for it, might be able to sort out. At the moment, it's not making sense to me but I haven't tried to see how the game loads the info on these tags either.

I'm starting to think the bigger issue is... how does it work at all when it can't maintain a proper reference to what mission is in use?
 
The text "MISSION_BARBARIAN_ENVOY" is used three times in the mod: In
  • sources/CvEnums.h, line 1917 (MISSION_BARBARIAN_ENVOY,),
  • sources/CvGameCoreUtils.cpp, line 4833 (case MISSION_BARBARIAN_ENVOY: szString = L"MISSION_BARBARIAN_ENVOY"; break; ),
  • sources/CyEnumsInterface.cpp, line 1376 (.value("MISSION_BARBARIAN_ENVOY", MISSION_BARBARIAN_ENVOY)).
 
isPossible.GIF


When paused here during the execution of the Captive-Civilian's mission to add a population to the city,
Code:
           <Actions>
               <Action>
                   <MissionType>MISSION_JOIN_CITY_POPULATION</MissionType>
                   <ActionOutcomes>
                       <Outcome>
                           <OutcomeType>OUTCOME_JOIN_CITY_POPULATION</OutcomeType>
                           <iChance>100</iChance>
                           <EventTrigger>EVENTTRIGGER_ADD_ONE_POPULATION</EventTrigger>
                           <PlotCondition>
                               <IntegrateOr>
                                   <RelationType>RELATION_ASSOCIATED</RelationType>
                                   <GameObjectType>GAMEOBJECT_CITY</GameObjectType>
                                   <GreaterEqual>
                                       <Constant>7</Constant>
                                       <AttributeType>ATTRIBUTE_POPULATION</AttributeType>
                                   </GreaterEqual>
                               </IntegrateOr>
                           </PlotCondition>
                       </Outcome>
                   </ActionOutcomes>
               </Action>
               <Action>
                   <MissionType>MISSION_CAPTIVE_UPGRADE_TO_IMMIGRANT</MissionType>
                   <iCost>
                       <Adapt>
                           <ID>ADAPT_DEFAULT</ID>
                           <Constant>10</Constant>
                       </Adapt>
                   </iCost>
                   <ActionOutcomes>
                       <Outcome>
                           <OutcomeType>OUTCOME_UPGRADE_TO_IMMIGRANT</OutcomeType>
                           <iChance>100</iChance>
                           <UnitType>UNIT_CAPTIVE_IMMIGRANT</UnitType>
                           <bUnitToCity>
                               <Constant>0</Constant>
                           </bUnitToCity>
                           <PlotCondition>
                               <Not>
                                   <Is>TAG_ANARCHY</Is>
                               </Not>
                           </PlotCondition>
                       </Outcome>
                   </ActionOutcomes>
               </Action>
               <Action>
                   <MissionType>MISSION_CAPTIVE_UPGRADE_TO_SETTLER</MissionType>
                   <iCost>
                       <Adapt>
                           <ID>ADAPT_DEFAULT</ID>
                           <Constant>20</Constant>
                       </Adapt>
                   </iCost>
                   <ActionOutcomes>
                       <Outcome>
                           <OutcomeType>OUTCOME_UPGRADE_TO_SETTLER</OutcomeType>
                           <iChance>100</iChance>
                           <UnitType>UNIT_SETTLER</UnitType>
                           <bUnitToCity>
                               <Constant>0</Constant>
                           </bUnitToCity>
                           <PlotCondition>
                               <Not>
                                   <Is>TAG_ANARCHY</Is>
                               </Not>
                           </PlotCondition>
                       </Outcome>
                   </ActionOutcomes>
               </Action>
           </Actions>
What's interesting is I can back up and see what the mission was defined as when the call was made to reach the previous point depicted:
isPossible.GIF
Barbarian Envoy.GIF

As you can see from the tooltip as I hover over the eMission parameter that sets up this call, the mission has been defined as MISSION_BARBARIAN_ENVOY.

One thing I just noticed is this line: if ( eMission > MISSION_PRETARGET_NUKE) // Outcome missions

This is simply not a true statement anymore. In the enums we have:
Code:
enum MissionTypes               // Exposed to Python
{
   NO_MISSION = -1,

   MISSION_MOVE_TO,
   MISSION_ROUTE_TO,
   MISSION_MOVE_TO_UNIT,
   MISSION_SKIP,
   MISSION_SLEEP,
   MISSION_FORTIFY,
   MISSION_PLUNDER,
   MISSION_AIRPATROL,
   MISSION_SEAPATROL,
   MISSION_HEAL,
   MISSION_SENTRY,
   MISSION_AIRLIFT,
   MISSION_NUKE,
   MISSION_RECON,
   MISSION_PARADROP,
   MISSION_AIRBOMB,
   MISSION_RANGE_ATTACK,
   MISSION_BOMBARD,
   MISSION_PILLAGE,
   MISSION_SABOTAGE,
   MISSION_DESTROY,
   MISSION_STEAL_PLANS,
   MISSION_FOUND,
   MISSION_SPREAD,
   MISSION_SPREAD_CORPORATION,
   MISSION_JOIN,
   MISSION_CONSTRUCT,
   MISSION_DISCOVER,
   MISSION_HURRY,
   MISSION_TRADE,
   MISSION_GREAT_WORK,
   MISSION_INFILTRATE,
   MISSION_GOLDEN_AGE,
   MISSION_BUILD,
   MISSION_LEAD,
   MISSION_ESPIONAGE,
   MISSION_DIE_ANIMATION,

   MISSION_BEGIN_COMBAT,
   MISSION_END_COMBAT,
   MISSION_AIRSTRIKE,
   MISSION_SURRENDER,
   MISSION_CAPTURED,
   MISSION_IDLE,
   MISSION_DIE,
   MISSION_DAMAGE,
   MISSION_MULTI_SELECT,
   MISSION_MULTI_DESELECT,
/************************************************************************************************/
/* DCM                                     04/19/09                                Johny Smith  */
/************************************************************************************************/
   MISSION_AIRBOMB1,
   MISSION_AIRBOMB2,
   MISSION_AIRBOMB3,
   MISSION_AIRBOMB4,
   MISSION_AIRBOMB5,
   MISSION_RBOMBARD,
   MISSION_ABOMBARD,
   MISSION_FENGAGE,
/************************************************************************************************/
/* DCM                                     END                                                  */
/************************************************************************************************/
   //TSHEEP Assassin Mission
   //MISSION_ASSASSIN,
   //TSHEEP End

// BUG - Sentry Actions - start
#ifdef _MOD_SENTRY
   MISSION_MOVE_TO_SENTRY,
   MISSION_SENTRY_WHILE_HEAL,
   MISSION_SENTRY_NAVAL_UNITS,
   MISSION_SENTRY_LAND_UNITS,
#endif
// BUG - Sentry Actions - end
   
/************************************************************************************************/
/* Afforess                                     6/05/10                                         */
/*                                                                                              */
/*                                                                                              */
/************************************************************************************************/
   MISSION_INQUISITION,
   MISSION_CLAIM_TERRITORY,
   MISSION_HURRY_FOOD,
   MISSION_ESPIONAGE_SLEEP,
   MISSION_GREAT_COMMANDER,
   MISSION_SHADOW,
   MISSION_WAIT_FOR_TECH,
/************************************************************************************************/
/* Afforess                            END                                                        */
/************************************************************************************************/   

   //ls612: City Goto in Viewports
   MISSION_GOTO,
   // < M.A.D. Nukes Start >
   MISSION_PRETARGET_NUKE,
   // < M.A.D. Nukes End   >
   //TB Combat Mod and Mission fix begin
   MISSION_BUTCHER,
   MISSION_RECORD_TALE_ORAL,
   MISSION_RECORD_TALE_WRITTEN,
   MISSION_ANIMAL_COMBAT,
   MISSION_ANIMAL_STUDY,
   MISSION_ANIMAL_SACRIFICE,
   MISSION_BARBARIAN_ENVOY,
   MISSION_CURE,
   MISSION_ESTABLISH,
   MISSION_ESCAPE,
   MISSION_BUILDUP,
   MISSION_AUTO_BUILDUP,
   MISSION_HEAL_BUILDUP,
   MISSION_AMBUSH,
   MISSION_ASSASSINATE
   //TB Combat Mod and Mission fix end
#ifdef FIXED_MISSION_NUMBER
   NUM_MISSION_TYPES
#endif
};
So I'm thinking we need to now audit this list and see how many other places it was assumed that the final hardcoded/xml mission infos would be MISSION_PRETARGET_NUKE and perhaps just make sure that they all line up properly as well. I'm not sure if action outcome missions are defined beyond the interior of the Action tag on the units. But if that is the only place they are given definition, then it's probably important that the enums in the code align properly with the main mission xml infos list in our xml.

However, if anyone can enlighten me beyond that theory, I'm all ears. I won't be able to test the theory till tomorrow.
 
One thing I just noticed is this line: if ( eMission > MISSION_PRETARGET_NUKE) // Outcome missions

This is simply not a true statement anymore. In the enums we have:
...
...
// < M.A.D. Nukes Start >
MISSION_PRETARGET_NUKE,
// < M.A.D. Nukes End >
//TB Combat Mod and Mission fix begin
MISSION_BUTCHER,
MISSION_RECORD_TALE_ORAL,
MISSION_RECORD_TALE_WRITTEN,
MISSION_ANIMAL_COMBAT,
MISSION_ANIMAL_STUDY,
MISSION_ANIMAL_SACRIFICE,
MISSION_BARBARIAN_ENVOY,
MISSION_CURE,
MISSION_ESTABLISH,
MISSION_ESCAPE,
...

I'm not certain about the WHY it tests the envoy mission, but the statement is true. Enums are simply beautified ints (in this cpp case, anyway), so they get a number according to the order they were written. So if nuke has a value of 100, envoy will have a value of 107.
This is why it pass the IF statement you quoted. I think two possible solutions to test will be to either move change the order, or to set specific values (MISSION_PRETARGET_NUKE=9999 for example).
 
important that the enums in the code align properly with the main mission xml infos list in our xml
Would reordering the enums destroy savegame compatibility?

At least in the widget if loop, what about something like

Code:
else if (GC.getActionInfo(widgetDataStruct.m_iData1).getMissionType() == MISSION_BARBARIAN_ENVOY) {

}

early in the loop.
 
This is simply not a true statement anymore. In the enums we have:
Code:
enum MissionTypes               // Exposed to Python
{
   NO_MISSION = -1,

   MISSION_MOVE_TO,
   MISSION_ROUTE_TO,
   MISSION_MOVE_TO_UNIT,
   MISSION_SKIP,
   MISSION_SLEEP,
   MISSION_FORTIFY,
   MISSION_PLUNDER,
   MISSION_AIRPATROL,
   MISSION_SEAPATROL,
   MISSION_HEAL,
   MISSION_SENTRY,
   MISSION_AIRLIFT,
   MISSION_NUKE,
   MISSION_RECON,
   MISSION_PARADROP,
   MISSION_AIRBOMB,
   MISSION_RANGE_ATTACK,
   MISSION_BOMBARD,
   MISSION_PILLAGE,
   MISSION_SABOTAGE,
   MISSION_DESTROY,
   MISSION_STEAL_PLANS,
   MISSION_FOUND,
   MISSION_SPREAD,
   MISSION_SPREAD_CORPORATION,
   MISSION_JOIN,
   MISSION_CONSTRUCT,
   MISSION_DISCOVER,
   MISSION_HURRY,
   MISSION_TRADE,
   MISSION_GREAT_WORK,
   MISSION_INFILTRATE,
   MISSION_GOLDEN_AGE,
   MISSION_BUILD,
   MISSION_LEAD,
   MISSION_ESPIONAGE,
   MISSION_DIE_ANIMATION,

   MISSION_BEGIN_COMBAT,
   MISSION_END_COMBAT,
   MISSION_AIRSTRIKE,
   MISSION_SURRENDER,
   MISSION_CAPTURED,
   MISSION_IDLE,
   MISSION_DIE,
   MISSION_DAMAGE,
   MISSION_MULTI_SELECT,
   MISSION_MULTI_DESELECT,
/************************************************************************************************/
/* DCM                                     04/19/09                                Johny Smith  */
/************************************************************************************************/
   MISSION_AIRBOMB1,
   MISSION_AIRBOMB2,
   MISSION_AIRBOMB3,
   MISSION_AIRBOMB4,
   MISSION_AIRBOMB5,
   MISSION_RBOMBARD,
   MISSION_ABOMBARD,
   MISSION_FENGAGE,
/************************************************************************************************/
/* DCM                                     END                                                  */
/************************************************************************************************/
   //TSHEEP Assassin Mission
   //MISSION_ASSASSIN,
   //TSHEEP End

// BUG - Sentry Actions - start
#ifdef _MOD_SENTRY
   MISSION_MOVE_TO_SENTRY,
   MISSION_SENTRY_WHILE_HEAL,
   MISSION_SENTRY_NAVAL_UNITS,
   MISSION_SENTRY_LAND_UNITS,
#endif
// BUG - Sentry Actions - end

/************************************************************************************************/
/* Afforess                                     6/05/10                                         */
/*                                                                                              */
/*                                                                                              */
/************************************************************************************************/
   MISSION_INQUISITION,
   MISSION_CLAIM_TERRITORY,
   MISSION_HURRY_FOOD,
   MISSION_ESPIONAGE_SLEEP,
   MISSION_GREAT_COMMANDER,
   MISSION_SHADOW,
   MISSION_WAIT_FOR_TECH,
/************************************************************************************************/
/* Afforess                            END                                                        */
/************************************************************************************************/

   //ls612: City Goto in Viewports
   MISSION_GOTO,
   // < M.A.D. Nukes Start >
   MISSION_PRETARGET_NUKE,
   // < M.A.D. Nukes End   >
   //TB Combat Mod and Mission fix begin
   MISSION_BUTCHER,
   MISSION_RECORD_TALE_ORAL,
   MISSION_RECORD_TALE_WRITTEN,
   MISSION_ANIMAL_COMBAT,
   MISSION_ANIMAL_STUDY,
   MISSION_ANIMAL_SACRIFICE,
   MISSION_BARBARIAN_ENVOY,
   MISSION_CURE,
   MISSION_ESTABLISH,
   MISSION_ESCAPE,
   MISSION_BUILDUP,
   MISSION_AUTO_BUILDUP,
   MISSION_HEAL_BUILDUP,
   MISSION_AMBUSH,
   MISSION_ASSASSINATE
   //TB Combat Mod and Mission fix end
#ifdef FIXED_MISSION_NUMBER
   NUM_MISSION_TYPES
#endif
};
Isn't it a problem that the mission MISSION_JOIN_CITY_POPULATION is not defined as a mission enumeration in the dll?
Wouldn't the GC.getActionInfo(widgetDataStruct.m_iData1).getMissionType() function fail to find the mission type ID number if there is no number ID for it?
Wouldn't that explain why you are getting something as odd as the Barbarian envoy mission stored in the eMission variable?

The MISSION_JOIN_CITY_POPULATION only exist in xml, the dll doesn't know what that text line represent other than a string of letters.
 
Last edited:
"
View attachment 485234

When paused here during the execution of the Captive-Civilian's mission to add a population to the city,
Code:
           <Actions>
               <Action>
                   <MissionType>MISSION_JOIN_CITY_POPULATION</MissionType>
                   <ActionOutcomes>
                       <Outcome>
                           <OutcomeType>OUTCOME_JOIN_CITY_POPULATION</OutcomeType>
                           <iChance>100</iChance>
                           <EventTrigger>EVENTTRIGGER_ADD_ONE_POPULATION</EventTrigger>
                           <PlotCondition>
                               <IntegrateOr>
                                   <RelationType>RELATION_ASSOCIATED</RelationType>
                                   <GameObjectType>GAMEOBJECT_CITY</GameObjectType>
                                   <GreaterEqual>
                                       <Constant>7</Constant>
                                       <AttributeType>ATTRIBUTE_POPULATION</AttributeType>
                                   </GreaterEqual>
                               </IntegrateOr>
                           </PlotCondition>
                       </Outcome>
                   </ActionOutcomes>
               </Action>
               <Action>
                   <MissionType>MISSION_CAPTIVE_UPGRADE_TO_IMMIGRANT</MissionType>
                   <iCost>
                       <Adapt>
                           <ID>ADAPT_DEFAULT</ID>
                           <Constant>10</Constant>
                       </Adapt>
                   </iCost>
                   <ActionOutcomes>
                       <Outcome>
                           <OutcomeType>OUTCOME_UPGRADE_TO_IMMIGRANT</OutcomeType>
                           <iChance>100</iChance>
                           <UnitType>UNIT_CAPTIVE_IMMIGRANT</UnitType>
                           <bUnitToCity>
                               <Constant>0</Constant>
                           </bUnitToCity>
                           <PlotCondition>
                               <Not>
                                   <Is>TAG_ANARCHY</Is>
                               </Not>
                           </PlotCondition>
                       </Outcome>
                   </ActionOutcomes>
               </Action>
               <Action>
                   <MissionType>MISSION_CAPTIVE_UPGRADE_TO_SETTLER</MissionType>
                   <iCost>
                       <Adapt>
                           <ID>ADAPT_DEFAULT</ID>
                           <Constant>20</Constant>
                       </Adapt>
                   </iCost>
                   <ActionOutcomes>
                       <Outcome>
                           <OutcomeType>OUTCOME_UPGRADE_TO_SETTLER</OutcomeType>
                           <iChance>100</iChance>
                           <UnitType>UNIT_SETTLER</UnitType>
                           <bUnitToCity>
                               <Constant>0</Constant>
                           </bUnitToCity>
                           <PlotCondition>
                               <Not>
                                   <Is>TAG_ANARCHY</Is>
                               </Not>
                           </PlotCondition>
                       </Outcome>
                   </ActionOutcomes>
               </Action>
           </Actions>
What's interesting is I can back up and see what the mission was defined as when the call was made to reach the previous point depicted:
View attachment 485234 View attachment 485235
As you can see from the tooltip as I hover over the eMission parameter that sets up this call, the mission has been defined as MISSION_BARBARIAN_ENVOY.

One thing I just noticed is this line: if ( eMission > MISSION_PRETARGET_NUKE) // Outcome missions

This is simply not a true statement anymore. In the enums we have:
Code:
enum MissionTypes               // Exposed to Python
{
   NO_MISSION = -1,

   MISSION_MOVE_TO,
   MISSION_ROUTE_TO,
   MISSION_MOVE_TO_UNIT,
   MISSION_SKIP,
   MISSION_SLEEP,
   MISSION_FORTIFY,
   MISSION_PLUNDER,
   MISSION_AIRPATROL,
   MISSION_SEAPATROL,
   MISSION_HEAL,
   MISSION_SENTRY,
   MISSION_AIRLIFT,
   MISSION_NUKE,
   MISSION_RECON,
   MISSION_PARADROP,
   MISSION_AIRBOMB,
   MISSION_RANGE_ATTACK,
   MISSION_BOMBARD,
   MISSION_PILLAGE,
   MISSION_SABOTAGE,
   MISSION_DESTROY,
   MISSION_STEAL_PLANS,
   MISSION_FOUND,
   MISSION_SPREAD,
   MISSION_SPREAD_CORPORATION,
   MISSION_JOIN,
   MISSION_CONSTRUCT,
   MISSION_DISCOVER,
   MISSION_HURRY,
   MISSION_TRADE,
   MISSION_GREAT_WORK,
   MISSION_INFILTRATE,
   MISSION_GOLDEN_AGE,
   MISSION_BUILD,
   MISSION_LEAD,
   MISSION_ESPIONAGE,
   MISSION_DIE_ANIMATION,

   MISSION_BEGIN_COMBAT,
   MISSION_END_COMBAT,
   MISSION_AIRSTRIKE,
   MISSION_SURRENDER,
   MISSION_CAPTURED,
   MISSION_IDLE,
   MISSION_DIE,
   MISSION_DAMAGE,
   MISSION_MULTI_SELECT,
   MISSION_MULTI_DESELECT,
/************************************************************************************************/
/* DCM                                     04/19/09                                Johny Smith  */
/************************************************************************************************/
   MISSION_AIRBOMB1,
   MISSION_AIRBOMB2,
   MISSION_AIRBOMB3,
   MISSION_AIRBOMB4,
   MISSION_AIRBOMB5,
   MISSION_RBOMBARD,
   MISSION_ABOMBARD,
   MISSION_FENGAGE,
/************************************************************************************************/
/* DCM                                     END                                                  */
/************************************************************************************************/
   //TSHEEP Assassin Mission
   //MISSION_ASSASSIN,
   //TSHEEP End

// BUG - Sentry Actions - start
#ifdef _MOD_SENTRY
   MISSION_MOVE_TO_SENTRY,
   MISSION_SENTRY_WHILE_HEAL,
   MISSION_SENTRY_NAVAL_UNITS,
   MISSION_SENTRY_LAND_UNITS,
#endif
// BUG - Sentry Actions - end
 
/************************************************************************************************/
/* Afforess                                     6/05/10                                         */
/*                                                                                              */
/*                                                                                              */
/************************************************************************************************/
   MISSION_INQUISITION,
   MISSION_CLAIM_TERRITORY,
   MISSION_HURRY_FOOD,
   MISSION_ESPIONAGE_SLEEP,
   MISSION_GREAT_COMMANDER,
   MISSION_SHADOW,
   MISSION_WAIT_FOR_TECH,
/************************************************************************************************/
/* Afforess                            END                                                        */
/************************************************************************************************/

   //ls612: City Goto in Viewports
   MISSION_GOTO,
   // < M.A.D. Nukes Start >
   MISSION_PRETARGET_NUKE,
   // < M.A.D. Nukes End   >
   //TB Combat Mod and Mission fix begin
   MISSION_BUTCHER,
   MISSION_RECORD_TALE_ORAL,
   MISSION_RECORD_TALE_WRITTEN,
   MISSION_ANIMAL_COMBAT,
   MISSION_ANIMAL_STUDY,
   MISSION_ANIMAL_SACRIFICE,
   MISSION_BARBARIAN_ENVOY,
   MISSION_CURE,
   MISSION_ESTABLISH,
   MISSION_ESCAPE,
   MISSION_BUILDUP,
   MISSION_AUTO_BUILDUP,
   MISSION_HEAL_BUILDUP,
   MISSION_AMBUSH,
   MISSION_ASSASSINATE
   //TB Combat Mod and Mission fix end
#ifdef FIXED_MISSION_NUMBER
   NUM_MISSION_TYPES
#endif
};
So I'm thinking we need to now audit this list and see how many other places it was assumed that the final hardcoded/xml mission infos would be MISSION_PRETARGET_NUKE and perhaps just make sure that they all line up properly as well. I'm not sure if action outcome missions are defined beyond the interior of the Action tag on the units. But if that is the only place they are given definition, then it's probably important that the enums in the code align properly with the main mission xml infos list in our xml.

However, if anyone can enlighten me beyond that theory, I'm all ears. I won't be able to test the theory till tomorrow.
View attachment 485234

When paused here during the execution of the Captive-Civilian's mission to add a population to the city,
Code:
           <Actions>
               <Action>
                   <MissionType>MISSION_JOIN_CITY_POPULATION</MissionType>
                   <ActionOutcomes>
                       <Outcome>
                           <OutcomeType>OUTCOME_JOIN_CITY_POPULATION</OutcomeType>
                           <iChance>100</iChance>
                           <EventTrigger>EVENTTRIGGER_ADD_ONE_POPULATION</EventTrigger>
                           <PlotCondition>
                               <IntegrateOr>
                                   <RelationType>RELATION_ASSOCIATED</RelationType>
                                   <GameObjectType>GAMEOBJECT_CITY</GameObjectType>
                                   <GreaterEqual>
                                       <Constant>7</Constant>
                                       <AttributeType>ATTRIBUTE_POPULATION</AttributeType>
                                   </GreaterEqual>
                               </IntegrateOr>
                           </PlotCondition>
                       </Outcome>
                   </ActionOutcomes>
               </Action>
               <Action>
                   <MissionType>MISSION_CAPTIVE_UPGRADE_TO_IMMIGRANT</MissionType>
                   <iCost>
                       <Adapt>
                           <ID>ADAPT_DEFAULT</ID>
                           <Constant>10</Constant>
                       </Adapt>
                   </iCost>
                   <ActionOutcomes>
                       <Outcome>
                           <OutcomeType>OUTCOME_UPGRADE_TO_IMMIGRANT</OutcomeType>
                           <iChance>100</iChance>
                           <UnitType>UNIT_CAPTIVE_IMMIGRANT</UnitType>
                           <bUnitToCity>
                               <Constant>0</Constant>
                           </bUnitToCity>
                           <PlotCondition>
                               <Not>
                                   <Is>TAG_ANARCHY</Is>
                               </Not>
                           </PlotCondition>
                       </Outcome>
                   </ActionOutcomes>
               </Action>
               <Action>
                   <MissionType>MISSION_CAPTIVE_UPGRADE_TO_SETTLER</MissionType>
                   <iCost>
                       <Adapt>
                           <ID>ADAPT_DEFAULT</ID>
                           <Constant>20</Constant>
                       </Adapt>
                   </iCost>
                   <ActionOutcomes>
                       <Outcome>
                           <OutcomeType>OUTCOME_UPGRADE_TO_SETTLER</OutcomeType>
                           <iChance>100</iChance>
                           <UnitType>UNIT_SETTLER</UnitType>
                           <bUnitToCity>
                               <Constant>0</Constant>
                           </bUnitToCity>
                           <PlotCondition>
                               <Not>
                                   <Is>TAG_ANARCHY</Is>
                               </Not>
                           </PlotCondition>
                       </Outcome>
                   </ActionOutcomes>
               </Action>
           </Actions>
What's interesting is I can back up and see what the mission was defined as when the call was made to reach the previous point depicted:
View attachment 485234 View attachment 485235
As you can see from the tooltip as I hover over the eMission parameter that sets up this call, the mission has been defined as MISSION_BARBARIAN_ENVOY.

One thing I just noticed is this line: if ( eMission > MISSION_PRETARGET_NUKE) // Outcome missions

This is simply not a true statement anymore. In the enums we have:
Code:
enum MissionTypes               // Exposed to Python
{
   NO_MISSION = -1,

   MISSION_MOVE_TO,
   MISSION_ROUTE_TO,
   MISSION_MOVE_TO_UNIT,
   MISSION_SKIP,
   MISSION_SLEEP,
   MISSION_FORTIFY,
   MISSION_PLUNDER,
   MISSION_AIRPATROL,
   MISSION_SEAPATROL,
   MISSION_HEAL,
   MISSION_SENTRY,
   MISSION_AIRLIFT,
   MISSION_NUKE,
   MISSION_RECON,
   MISSION_PARADROP,
   MISSION_AIRBOMB,
   MISSION_RANGE_ATTACK,
   MISSION_BOMBARD,
   MISSION_PILLAGE,
   MISSION_SABOTAGE,
   MISSION_DESTROY,
   MISSION_STEAL_PLANS,
   MISSION_FOUND,
   MISSION_SPREAD,
   MISSION_SPREAD_CORPORATION,
   MISSION_JOIN,
   MISSION_CONSTRUCT,
   MISSION_DISCOVER,
   MISSION_HURRY,
   MISSION_TRADE,
   MISSION_GREAT_WORK,
   MISSION_INFILTRATE,
   MISSION_GOLDEN_AGE,
   MISSION_BUILD,
   MISSION_LEAD,
   MISSION_ESPIONAGE,
   MISSION_DIE_ANIMATION,

   MISSION_BEGIN_COMBAT,
   MISSION_END_COMBAT,
   MISSION_AIRSTRIKE,
   MISSION_SURRENDER,
   MISSION_CAPTURED,
   MISSION_IDLE,
   MISSION_DIE,
   MISSION_DAMAGE,
   MISSION_MULTI_SELECT,
   MISSION_MULTI_DESELECT,
/************************************************************************************************/
/* DCM                                     04/19/09                                Johny Smith  */
/************************************************************************************************/
   MISSION_AIRBOMB1,
   MISSION_AIRBOMB2,
   MISSION_AIRBOMB3,
   MISSION_AIRBOMB4,
   MISSION_AIRBOMB5,
   MISSION_RBOMBARD,
   MISSION_ABOMBARD,
   MISSION_FENGAGE,
/************************************************************************************************/
/* DCM                                     END                                                  */
/************************************************************************************************/
   //TSHEEP Assassin Mission
   //MISSION_ASSASSIN,
   //TSHEEP End

// BUG - Sentry Actions - start
#ifdef _MOD_SENTRY
   MISSION_MOVE_TO_SENTRY,
   MISSION_SENTRY_WHILE_HEAL,
   MISSION_SENTRY_NAVAL_UNITS,
   MISSION_SENTRY_LAND_UNITS,
#endif
// BUG - Sentry Actions - end
 
/************************************************************************************************/
/* Afforess                                     6/05/10                                         */
/*                                                                                              */
/*                                                                                              */
/************************************************************************************************/
   MISSION_INQUISITION,
   MISSION_CLAIM_TERRITORY,
   MISSION_HURRY_FOOD,
   MISSION_ESPIONAGE_SLEEP,
   MISSION_GREAT_COMMANDER,
   MISSION_SHADOW,
   MISSION_WAIT_FOR_TECH,
/************************************************************************************************/
/* Afforess                            END                                                        */
/************************************************************************************************/

   //ls612: City Goto in Viewports
   MISSION_GOTO,
   // < M.A.D. Nukes Start >
   MISSION_PRETARGET_NUKE,
   // < M.A.D. Nukes End   >
   //TB Combat Mod and Mission fix begin
   MISSION_BUTCHER,
   MISSION_RECORD_TALE_ORAL,
   MISSION_RECORD_TALE_WRITTEN,
   MISSION_ANIMAL_COMBAT,
   MISSION_ANIMAL_STUDY,
   MISSION_ANIMAL_SACRIFICE,
   MISSION_BARBARIAN_ENVOY,
   MISSION_CURE,
   MISSION_ESTABLISH,
   MISSION_ESCAPE,
   MISSION_BUILDUP,
   MISSION_AUTO_BUILDUP,
   MISSION_HEAL_BUILDUP,
   MISSION_AMBUSH,
   MISSION_ASSASSINATE
   //TB Combat Mod and Mission fix end
#ifdef FIXED_MISSION_NUMBER
   NUM_MISSION_TYPES
#endif
};
So I'm thinking we need to now audit this list and see how many other places it was assumed that the final hardcoded/xml mission infos would be MISSION_PRETARGET_NUKE and perhaps just make sure that they all line up properly as well. I'm not sure if action outcome missions are defined beyond the interior of the Action tag on the units. But if that is the only place they are given definition, then it's probably important that the enums in the code align properly with the main mission xml infos list in our xml.

However, if anyone can enlighten me beyond that theory, I'm all ears. I won't be able to test the theory till tomorrow.

At beginning of the CIV4MissionInfos.xml is a comment saying "Changes must be reflected in CvEnums.h". That's the situation same as it is for gameoptions and other things.

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>

<!-- edited with XMLSPY v2004 rel. 2 U (http://www.xmlspy.com) by Jon Shafer (Firaxis Games) -->

<!-- Sid Meier's Civilization 4 -->

<!-- Copyright Firaxis Games 2005 -->

<!-- -->

<!-- Mission Infos -->

-<Civ4MissionInfos xmlns="http://forums.civfanatics.com/showthread.php?t=288570" xsi:schemaLocation="http://forums.civfanatics.com/showthread.php?t=288570 ../Schema/C2C.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<!--Changes must be reflected in CvEnums.h-->



-<MissionInfos>


-<MissionInfo>
 
Isn't it a problem that the mission MISSION_JOIN_CITY_POPULATION is not defined as a mission enumeration in the dll?
Wouldn't the GC.getActionInfo(widgetDataStruct.m_iData1).getMissionType() function fail to find the mission type ID number if there is no number ID for it?
Wouldn't that explain why you are getting something as odd as the Barbarian envoy mission stored in the eMission variable?

The MISSION_JOIN_CITY_POPULATION only exist in xml, the dll doesn't know what that text line represent other than a string of letters.
I think it boils down to how it was setup to create the reference. I've got to research on the info side how @AIAndy planned this out but I'm thinking that it takes a unit's action mission definition and adds it to the enumeration but that it does so with a hardcoded belief that there will not be any further missions in the enums list past MISSION_PRETARGET_NUKE. So I'm thinking that the source of the error was to add to the mission list - he must have theorized we would have no further need to do this and would just build everything further through the action mission method. So I'm going to look into that angle of things. I'm hoping its that simple. Otherwise, the whole coding system of the Action Outcome Missions may be deeply bugged and requiring some serious retooling. It certainly is concerning that the mission isn't defined anywhere but the unit's xml. AIAndy is very good at knowing how and when he can bypass certain steps that seem like they should be required to a lesser programmer so I have some faith he's done it right and it's just my limited understanding that is running up against the rocks here. We messed up in the xml/coding somewhere I think, not knowing a rule that we breached a rule he might have failed to mention or if he said it we failed to understand it at the time.
 
"


At beginning of the CIV4MissionInfos.xml is a comment saying "Changes must be reflected in CvEnums.h". That's the situation same as it is for gameoptions and other things.

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>

<!-- edited with XMLSPY v2004 rel. 2 U (http://www.xmlspy.com) by Jon Shafer (Firaxis Games) -->

<!-- Sid Meier's Civilization 4 -->

<!-- Copyright Firaxis Games 2005 -->

<!-- -->

<!-- Mission Infos -->

-<Civ4MissionInfos xmlns="http://forums.civfanatics.com/showthread.php?t=288570" xsi:schemaLocation="http://forums.civfanatics.com/showthread.php?t=288570 ../Schema/C2C.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<!--Changes must be reflected in CvEnums.h-->



-<MissionInfos>


-<MissionInfo>
Yeah, normally that's totally true and the first place to start should be an audit to make sure that the xml lines up perfectly with the enums.

However, I suspect there's a bit more to it, being as the action outcome missions seem to only be defined on the units and are not in the xml nor the enums but are still somehow supposed to be enumerated, probably added to the end of the sequence during unit loading. (Which would mean they really get screwed up if the enums don't match up to the list in the missioninfos.xml!) Then there could also be some modules trying to load in new missions and throwing things off further.

BTW, noticed your recent efforts on the mod and I'd like to say welcome back! Your help here is always appreciated!
 
the first place to start should be an audit to make sure that the xml lines up perfectly with the enums.
It does not, I've checked that (Edit: only checked those after MISSION_PRETARGET_NUKE.).
Most other outcome missions have an entry in the dll enumeration for missions, but not MISSION_JOIN_CITY_POPULATION, the order missions are defined in XML does not sync up with the enums as far as I could see.
 
Last edited:
It does not at all, I've checked that.
Well... there's the first problem then. Possibly the only one. I think some were removed without removing them in the enums?

I can't do much directly about this at the moment but when I can I'll adjust the enums to match the xml mission list.
 
Well... there's the first problem then. Possibly the only one. I think some were removed without removing them in the enums?

I can't do much directly about this at the moment but when I can I'll adjust the enums to match the xml mission list.
I looked again just to be sure, the enums match up with the Mission XML up to MISSION_BUTCHER.

Edit: After MISSION_BUTCHER in chronological order.
Spoiler Enums :

MISSION_RECORD_TALE_ORAL
MISSION_RECORD_TALE_WRITTEN,
MISSION_ANIMAL_COMBAT,
MISSION_ANIMAL_STUDY,
MISSION_ANIMAL_SACRIFICE,
MISSION_BARBARIAN_ENVOY,
MISSION_CURE,
MISSION_ESTABLISH,
MISSION_ESCAPE,
MISSION_BUILDUP,
MISSION_AUTO_BUILDUP,
MISSION_HEAL_BUILDUP,
MISSION_AMBUSH,
MISSION_ASSASSINATE

Red = Not listed in XML
Spoiler XML :

MISSION_DIPLOMAT_ASSIMULATE_IND_PEOPLE
MISSION_DIPLOMAT_PRAISE_IND_PEOPLE
MISSION_DIPLOMAT_SPEAK_TO_BARBARIAN_LEADERS
MISSION_DIPLOMAT_SPREAD_RELIGION
MISSION_LAWYER_REMOVE_CORPORATIONS
MISSION_JOIN_CITY_POPULATION

MISSION_CURE
MISSION_ESTABLISH
MISSION_ESCAPE
MISSION_BUILDUP
MISSION_AUTO_BUILDUP
MISSION_HEAL_BUILDUP
MISSION_AMBUSH
MISSION_ASSASSINATE
MISSION_ENTERTAIN_CITY
MISSION_HURRY_PRODUCTION_CARAVAN
MISSION_CAPTIVE_UPGRADE_TO_SETTLER
MISSION_CAPTIVE_UPGRADE_TO_GATHERER
MISSION_CAPTIVE_UPGRADE_TO_WORKER
MISSION_CAPTIVE_UPGRADE_TO_IMMIGRANT
MISSION_CAPTIVE_UPGRADE_TO_STONE_THROWER
MISSION_CAPTIVE_UPGRADE_TO_ARCHER
MISSION_CAPTIVE_UPGRADE_TO_AXEMAN
MISSION_CAPTIVE_UPGRADE_TO_SPEARMAN
MISSION_CAPTIVE_UPGRADE_TO_NEANDERTHAL_WARRIOR
MISSION_SELL_CAPTIVE
MISSION_FREE_CAPTIVE
MISSION_JOIN_CITY_FREED_SLAVE
MISSION_RECORD_TALE

MISSION_RECORD_TALE_ORAL
MISSION_RECORD_TALE_WRITTEN
MISSION_ANIMAL_COMBAT
MISSION_ANIMAL_STUDY
MISSION_ANIMAL_SACRIFICE
MISSION_BUILD_DOMESTICATED_HERD

Red = Not listed in enums
@Thunderbrd: Just letting you know I made an edit to this post.
 
Last edited:
Oh... wow... MISSION_JOIN_CITY_POPULATION is in exactly the same slot as Barbarian Envoy... so apparently unit missions ARE requiring listing in the mission xml as well. Ok, so this should be a pretty easy fix then. I'm on it.
 
Also, shouldn't these lines switch place inside the mission XML?

MISSION_RECORD_TALE_ORAL
MISSION_RECORD_TALE_WRITTEN
MISSION_ANIMAL_COMBAT
MISSION_ANIMAL_STUDY
MISSION_ANIMAL_SACRIFICE
↓ with ↑
MISSION_DIPLOMAT_ASSIMULATE_IND_PEOPLE
MISSION_DIPLOMAT_PRAISE_IND_PEOPLE
MISSION_DIPLOMAT_SPEAK_TO_BARBARIAN_LEADERS
MISSION_DIPLOMAT_SPREAD_RELIGION
MISSION_LAWYER_REMOVE_CORPORATIONS

The top group work fine as it is, so it would only be for orders sake.
The dll just has the wrong names for the bottom group is all.
 
Last edited:
I was under the impression that the enum was no longer used or was only used for the vanilla missions. I have never added anything to the enum when adding missions. I have only added it to the missions XML.
 
I was under the impression that the enum was no longer used or was only used for the vanilla missions. I have never added anything to the enum when adding missions. I have only added it to the missions XML.
They only need to be listed in the enums if the dll needs to reference it somewhere in its code.
the enums isn't necessary when adding a new mission that is completely handled by xml (and python?).

Here's the main reason why some of the non-vanilla missions are inside the enum list
Code:
    case MISSION_BUTCHER: szString = L"MISSION_BUTCHER"; break;
    case MISSION_RECORD_TALE_ORAL: szString = L"MISSION_RECORD_TALE_ORAL"; break;
    case MISSION_RECORD_TALE_WRITTEN: szString = L"MISSION_RECORD_TALE_WRITTEN"; break;
    case MISSION_ANIMAL_COMBAT: szString = L"MISSION_ANIMAL_COMBAT"; break;
    case MISSION_ANIMAL_STUDY: szString = L"MISSION_ANIMAL_STUDY"; break;
    case MISSION_ANIMAL_SACRIFICE: szString = L"MISSION_ANIMAL_SACRIFICE"; break;
    case MISSION_BARBARIAN_ENVOY: szString = L"MISSION_BARBARIAN_ENVOY"; break;
    case MISSION_CURE: szString = L"MISSION_CURE"; break;
    case MISSION_ESTABLISH: szString = L"MISSION_ESTABLISH"; break;
    case MISSION_ESCAPE: szString = L"MISSION_ESCAPE"; break;
    case MISSION_AMBUSH: szString = L"MISSION_AMBUSH"; break;
    case MISSION_ASSASSINATE: szString = L"MISSION_ASSASSINATE"; break;
The dll deals with their in-game text in some way.
 
Last edited:
I tried loading a game while currently in one. I got an exception in cvinfo.cpp, CvLeaderHeadInfo::getDiploWarMusicScriptIds. I got this exception:
Exception thrown at 0x06469D5E (CvGameCoreDLL.dll) in Civ4BeyondSword.exe: 0xC0000005: Access violation reading location 0x00000005.
It seems that a value of 1 (location to read in an array) was passed, but for some reason that location was empty.
 
Back
Top Bottom