Skip to content

Commit

Permalink
All the changes
Browse files Browse the repository at this point in the history
  • Loading branch information
seroperson committed Apr 26, 2023
1 parent cd9beeb commit 6403838
Show file tree
Hide file tree
Showing 15 changed files with 37 additions and 25 deletions.
2 changes: 1 addition & 1 deletion (3a) EUI Compatibility Files/LUA/CityStateStatusHelper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ function GetCityStateStatusToolTip( majorPlayerID, minorPlayerID, isFullInfo )
end
end
if #wars > 0 then
table_insert( tips, L("TXT_KEY_AT_WAR_WITH", table_concat(wars, ", ") ) )
table_insert( tips, L("TXT_KEY_AT_WAR_WITH_CP", table_concat(wars, ", ") ) )
end
end
Expand Down
6 changes: 3 additions & 3 deletions CvGameCoreDLL_Expansion2/CvAStar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2822,7 +2822,7 @@ map<CvPlot*,SPath> CvPathFinder::GetMultiplePaths(const CvPlot* pStartPlot, vect
{
bool operator()(const CvPlot* lhs, const CvPlot* rhs) const { return lhs->GetPlotIndex() < rhs->GetPlotIndex(); }
};
std::sort( vDestPlots.begin(), vDestPlots.end(), PrSortByPlotIndex() );
std::stable_sort( vDestPlots.begin(), vDestPlots.end(), PrSortByPlotIndex() );

//there is no destination! the return value will always be false
CvAStar::FindPathWithCurrentConfiguration(pStartPlot->getX(),pStartPlot->getY(), -1, -1, data);
Expand Down Expand Up @@ -3639,7 +3639,7 @@ void ReachablePlots::createIndex()
lookup.reserve(storage.size());
for (size_t i = 0; i < storage.size(); i++)
lookup.push_back( make_pair(storage[i].iPlotIndex,i) );
sort(lookup.begin(), lookup.end(), PairCompareFirst());
stable_sort(lookup.begin(), lookup.end(), PairCompareFirst());
}

struct EqualRangeComparison
Expand Down Expand Up @@ -3678,7 +3678,7 @@ void ReachablePlots::insertWithIndex(const SMovePlot& plot)
{
lookup.push_back( make_pair(plot.iPlotIndex,storage.size()) );
storage.push_back(plot);
sort(lookup.begin(), lookup.end(), PairCompareFirst());
stable_sort(lookup.begin(), lookup.end(), PairCompareFirst());
}

FDataStream & operator >> (FDataStream & kStream, CvPathNode & node)
Expand Down
2 changes: 1 addition & 1 deletion CvGameCoreDLL_Expansion2/CvArmyAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ CvPlot* CvArmyAI::GetCenterOfMass(bool bClampToUnit, float* pfVarX, float* pfVar
return NULL;

//this sorts ascending!
std::sort(vPlots.begin(),vPlots.end());
std::stable_sort(vPlots.begin(),vPlots.end());
return vPlots.front().pPlot;
}
else
Expand Down
2 changes: 1 addition & 1 deletion CvGameCoreDLL_Expansion2/CvBuilderTaskingAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ BuilderDirective CvBuilderTaskingAI::EvaluateBuilder(CvUnit* pUnit, const map<Cv
}
}

sort(m_aDirectives.begin(), m_aDirectives.end());
stable_sort(m_aDirectives.begin(), m_aDirectives.end());
LogDirectives(pUnit);

//nothing found?
Expand Down
2 changes: 0 additions & 2 deletions CvGameCoreDLL_Expansion2/CvPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4098,7 +4098,6 @@ SYNC_ARCHIVE_VAR(int, m_iMinorResourceBonusCount)
SYNC_ARCHIVE_VAR(int, m_iAbleToAnnexCityStatesCount)
SYNC_ARCHIVE_VAR(int, m_iOnlyTradeSameIdeology)
SYNC_ARCHIVE_VAR(int, m_iSupplyFreeUnits)
SYNC_ARCHIVE_VAR(std::vector<CvString>, m_aistrInstantYield)
SYNC_ARCHIVE_VAR(std::vector<bool>, m_abActiveContract)
SYNC_ARCHIVE_VAR(int, m_iJFDReformCooldownRate)
SYNC_ARCHIVE_VAR(int, m_iJFDGovernmentCooldownRate)
Expand Down Expand Up @@ -4221,7 +4220,6 @@ SYNC_ARCHIVE_VAR(int, m_iMedianTechPercentage)
SYNC_ARCHIVE_VAR(int, m_iNumFreePolicies)
SYNC_ARCHIVE_VAR(int, m_iNumFreePoliciesEver)
SYNC_ARCHIVE_VAR(int, m_iNumFreeTenets)
SYNC_ARCHIVE_VAR(int, m_iLastSliceMoved)
SYNC_ARCHIVE_VAR(uint, m_uiStartTime)
SYNC_ARCHIVE_VAR(bool, m_bHasUUPeriod)
SYNC_ARCHIVE_VAR(bool, m_bNoNewWars)
Expand Down
4 changes: 2 additions & 2 deletions CvGameCoreDLL_Expansion2/CvPlayerAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ void CvPlayerAI::AI_considerAnnex()
if (!options.empty())
{
//descending by default
sort(options.begin(), options.end());
std::stable_sort(options.begin(), options.end());

CvCity* pTargetCity = options.front().option;
if (pTargetCity)
Expand Down Expand Up @@ -1926,7 +1926,7 @@ CvPlot* CvPlayerAI::FindBestMerchantTargetPlotForCash(CvUnit* pMerchant)
}
}

sort(vCandidates.begin(), vCandidates.end());
std::stable_sort(vCandidates.begin(), vCandidates.end());

int iFlags = CvUnit::MOVEFLAG_NO_ENEMY_TERRITORY | CvUnit::MOVEFLAG_APPROX_TARGET_RING1 | CvUnit::MOVEFLAG_APPROX_TARGET_NATIVE_DOMAIN;
for (size_t i = 0; i < vCandidates.size(); i++)
Expand Down
13 changes: 11 additions & 2 deletions CvGameCoreDLL_Expansion2/CvSerialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,11 @@ class CvSyncVar : public CvSyncVarBase<typename VarTraits::ValueType>
typedef typename VarTraits::ValueType ValueType;
typedef typename VarTraits::ContainerType ContainerType;
typedef typename VarTraits::SyncVarsType SyncVarsType;
std::string nameStr;

CvSyncVar()
: CvSyncVarBase<ValueType>(EmptyString, getContainer().getSyncArchive(), currentValue())
: CvSyncVarBase<ValueType>(nameStr, getContainer().getSyncArchive(), currentValue()),
nameStr(VarTraits::name())
{}
~CvSyncVar() {}

Expand Down Expand Up @@ -273,6 +275,12 @@ class CvSyncVar : public CvSyncVarBase<typename VarTraits::ValueType>
ValueType other;
otherValue >> other;
const bool result = other == currentValue();

if (!result) {
// std::string desyncValues = std::string("Desync values, current ") + FSerialization::toString(currentValue()) + "; other " + FSerialization::toString(other) + std::string("\n");
// gGlobals.getDLLIFace()->netMessageDebugLog(desyncValues);
}

return result; // Place a conditional breakpoint here to help debug sync errors.
}
virtual void reset()
Expand All @@ -281,7 +289,7 @@ class CvSyncVar : public CvSyncVarBase<typename VarTraits::ValueType>
}
virtual const std::string& name() const
{
return EmptyString;
return nameStr;
}
virtual void setStackTraceRemark()
{
Expand Down Expand Up @@ -407,6 +415,7 @@ private: \
typedef CvSyncArchive<ContainerType>::SyncVars SyncVarsType; \
static inline const ValueType& Get(const ContainerType& container) { return container.memberName; } \
static inline ValueType& Get(ContainerType& container) { return container.memberName; } \
static inline const char* name() { return #memberName; } \
static inline const SyncVarsType& GetStorage(const CvSyncVar<memberName##_Traits>& var) { \
return *reinterpret_cast<const SyncVarsType*>(reinterpret_cast<const char*>(&var) - offsetof(SyncVarsType, memberName)); \
} \
Expand Down
6 changes: 3 additions & 3 deletions CvGameCoreDLL_Expansion2/CvTacticalAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5703,7 +5703,7 @@ CvPlot* CvTacticalAI::FindNearbyTarget(CvUnit* pUnit, int iMaxTurns, bool bOffen
}

//second round. default sort order is descending
std::sort(candidates.begin(), candidates.end());
std::stable_sort(candidates.begin(), candidates.end());
std::reverse(candidates.begin(), candidates.end());

for (size_t i=0; i<candidates.size(); i++)
Expand Down Expand Up @@ -6132,7 +6132,7 @@ bool TacticalAIHelpers::PerformOpportunityAttack(CvUnit* pUnit, bool bAllowMovem
if (meleeTargets.empty())
return false;

std::sort(meleeTargets.begin(), meleeTargets.end());
std::stable_sort(meleeTargets.begin(), meleeTargets.end());

//we will never do attacks with negative scores!
if (meleeTargets.back().score < iScoreThreshold)
Expand Down Expand Up @@ -8572,7 +8572,7 @@ void CvTacticalPosition::getPreferredAssignmentsForUnit(const SUnitStats& unit,
gPossibleMoves.insert(gPossibleMoves.begin(), STacticalAssignment(unit.iPlotIndex, unit.iPlotIndex, unit.iUnitID, 0, unit.eStrategy, 0, A_BLOCKED));

//need to return in sorted order. note that we don't filter out bad (negative moves) they just are unlikely to get picked
std::sort(gPossibleMoves.begin(),gPossibleMoves.end());
std::stable_sort(gPossibleMoves.begin(),gPossibleMoves.end());

//don't return more than requested
if (gPossibleMoves.size() > (size_t)nMaxCount)
Expand Down
6 changes: 3 additions & 3 deletions CvGameCoreDLL_Expansion2/CvUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5664,7 +5664,7 @@ bool CvUnit::jumpToNearestValidPlot()
}

//we want lowest scores first
std::sort(candidates.begin(), candidates.end());
std::stable_sort(candidates.begin(), candidates.end());

for (size_t i = 0; i < candidates.size(); i++)
{
Expand Down Expand Up @@ -15911,7 +15911,7 @@ void CvUnit::DoSquadMovement(CvPlot* pDestPlot)
int dist = plotDistance(*pLoopUnit->plot(), *pDestPlot);
unitsToMoveByDistance.push_back(ScoredUnit(dist, pLoopUnit));
}
std::sort(unitsToMoveByDistance.begin(), unitsToMoveByDistance.end(), greater<ScoredUnit>());
std::stable_sort(unitsToMoveByDistance.begin(), unitsToMoveByDistance.end(), greater<ScoredUnit>());

// Generate a list of eligible plots for these units, only adding another
// ring when there are still insufficient plots for the current selection
Expand Down Expand Up @@ -29698,7 +29698,7 @@ int CvUnit::ComputePath(const CvPlot* pToPlot, int iFlags, int iMaxTurns, bool b
}
}

std::sort(eligiblePlots.begin(), eligiblePlots.end(), less<ScoredPlot>());
std::stable_sort(eligiblePlots.begin(), eligiblePlots.end(), less<ScoredPlot>());
if (!eligiblePlots.empty())
{
pDestPlot = eligiblePlots.front().plot;
Expand Down
6 changes: 3 additions & 3 deletions CvGameCoreDLL_Expansion2/CvVotingClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6007,7 +6007,7 @@ CvString CvLeague::GetResolutionVoteOpinionDetails(ResolutionTypes eResolution,
}
}
}
std::sort(vScores.begin(), vScores.end());
std::stable_sort(vScores.begin(), vScores.end());
std::reverse(vScores.begin(), vScores.end());
bool bPositiveDone = false;
bool bNegativeDone = false;
Expand Down Expand Up @@ -6109,7 +6109,7 @@ CvString CvLeague::GetResolutionProposeOpinionDetails(ResolutionTypes eResolutio
vScores.push_back(std::make_pair(iScore, it->ePlayer));
}
}
std::sort(vScores.begin(), vScores.end());
std::stable_sort(vScores.begin(), vScores.end());
std::reverse(vScores.begin(), vScores.end());
bool bPositiveDone = false;
bool bNegativeDone = false;
Expand Down Expand Up @@ -6217,7 +6217,7 @@ CvString CvLeague::GetResolutionProposeOpinionDetails(int iTargetResolutionID, P
}
}
}
std::sort(vScores.begin(), vScores.end());
std::stable_sort(vScores.begin(), vScores.end());
std::reverse(vScores.begin(), vScores.end());
bool bPositiveDone = false;
bool bNegativeDone = false;
Expand Down
2 changes: 1 addition & 1 deletion CvGameCoreDLL_Expansion2/VoxPopuli.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<AdditionalIncludeDirectories>$(SolutionDir)CvGameCoreDLL_Expansion2\;$(SolutionDir)CvWorldBuilderMap\include\;$(SolutionDir)CvGameCoreDLLUtil\include\;$(SolutionDir)CvLocalization\include\;$(SolutionDir)CvGameDatabase\include\;$(SolutionDir)FirePlace\include\;$(SolutionDir)FirePlace\include\FireWorks\;$(SolutionDir)ThirdPartyLibs\Lua51\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>CvGameCoreDLLPCH.h</PrecompiledHeaderFile>
<AdditionalOptions>/Zm211 %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions>/Zm250 %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
Expand Down
5 changes: 5 additions & 0 deletions FirePlace/include/FireWorks/FAutoVariableBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ namespace FSerialization
static const std::string result("UNKNOWN");
return result;
}

template<typename ValueType>
std::string toString(const CvString & source) {
return source.c_str();
}
}

class FAutoVariableBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ function GetCityStateStatusToolTip( majorPlayerID, minorPlayerID, isFullInfo )
end
end
if #wars > 0 then
table_insert( tips, L("TXT_KEY_AT_WAR_WITH", table_concat(wars, ", ") ) )
table_insert( tips, L("TXT_KEY_AT_WAR_WITH_CP", table_concat(wars, ", ") ) )
end

end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2642,7 +2642,7 @@ local function GetMoodInfo( playerID )
tips:insertIf( #backstabs > 0 and "[ICON_PIRATE]" .. L( "TXT_KEY_DIPLO_BACKSTABBED", backstabs:concat(", ") ) )
tips:insertIf( #denouncements > 0 and "[ICON_DENOUNCE]" .. L( "TXT_KEY_DIPLO_DENOUNCED", denouncements:concat(", ") ) )
tips:insertIf( #denouncedBy > 0 and "[ICON_DENOUNCE]" .. TextColor( negativeOrPositiveTextColor[false], L( "TXT_KEY_NTFN_DENOUNCED_US_S", denouncedBy:concat(", ") ) ) )
tips:insertIf( #wars > 0 and "[ICON_WAR]" .. L( "TXT_KEY_AT_WAR_WITH", wars:concat(", ") ) )
tips:insertIf( #wars > 0 and "[ICON_WAR]" .. L( "TXT_KEY_AT_WAR_WITH_CP", wars:concat(", ") ) )

return tips:concat( "[NEWLINE]" )
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ local g_civListInstanceToolTips = { -- the tooltip function names need to match

War = function( control )
local player = FindPlayer( g_majorControlTable, control )
local tips = table( L( "TXT_KEY_AT_WAR_WITH", player:GetCivilizationShortDescriptionKey() ) )
local tips = table( L( "TXT_KEY_AT_WAR_WITH_CP", player:GetCivilizationShortDescriptionKey() ) )
local teamID = player:GetTeam()
local lockedWarTurns = g_activeTeam:GetNumTurnsLockedIntoWar( teamID )
if lockedWarTurns > 0 then
Expand Down

0 comments on commit 6403838

Please sign in to comment.