Skip to content

Commit

Permalink
fprintf for debugging trade route loss
Browse files Browse the repository at this point in the history
  • Loading branch information
LynxAbraxas committed Oct 12, 2019
1 parent c51b39c commit 81ae687
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions ctp2_code/ai/CityManagement/governor.cpp
Expand Up @@ -5161,6 +5161,7 @@ void Governor::ManageGoodsTradeRoutes()
{
unused_freight += curDestRoute->GetCost();

fprintf(stderr, "%s L%d: sellingPrice: %d, maxPrice: %d, PiracyRisk: %d!\n", __FILE__, __LINE__, sellingPrice, maxPrice, Diplomat::GetDiplomat(m_playerId).GetTradeRoutePiracyRisk(city, curDestRoute->GetDestination()));
g_gevManager->AddEvent(GEV_INSERT_Tail, GEV_KillTradeRoute,
GEA_TradeRoute, curDestRoute.m_id,
GEA_Int, CAUSE_KILL_TRADE_ROUTE_SENDER_KILLED,
Expand Down
5 changes: 5 additions & 0 deletions ctp2_code/gs/gameobj/CityData.cpp
Expand Up @@ -4344,6 +4344,7 @@ void CityData::CalculateTradeRoutes(bool projectedOnly)
{
if(!projectedOnly)
{
fprintf(stderr, "%s L%d: deadRoutes, resource: %d, m_collectingResources: %d, m_sellingResources: %d, i: %d!\n", __FILE__, __LINE__, routeResource, m_collectingResources[routeResource], m_sellingResources[routeResource], i);
deadRoutes.Insert(route);
}
}
Expand All @@ -4354,6 +4355,7 @@ void CityData::CalculateTradeRoutes(bool projectedOnly)
{
if(m_food_delta < routeResource && !projectedOnly)
{
fprintf(stderr, "%s L%d: deadRoutes!\n", __FILE__, __LINE__);
deadRoutes.Insert(route);
}
break;
Expand Down Expand Up @@ -4387,6 +4389,7 @@ void CityData::CalculateTradeRoutes(bool projectedOnly)
{
if(g_player[m_owner]->GetGold() < route.GetGoldInReturn()) // kill route because of not enough gold to pay for the resource
{
fprintf(stderr, "%s L%d: deadRoutes!\n", __FILE__, __LINE__);
deadRoutes.Insert(route);
killRoute = true;
}
Expand Down Expand Up @@ -4415,13 +4418,15 @@ void CityData::CalculateTradeRoutes(bool projectedOnly)
{
if(deadRoutes[i].GetSource().m_id == m_home_city.m_id)
{
fprintf(stderr, "%s L%d: KillTradeRoute!\n", __FILE__, __LINE__);
g_gevManager->AddEvent(GEV_INSERT_Tail, GEV_KillTradeRoute,
GEA_TradeRoute, deadRoutes[i],
GEA_Int, CAUSE_KILL_TRADE_ROUTE_SENDER_KILLED,
GEA_End);
}
else
{
fprintf(stderr, "%s L%d: KillTradeRoute!\n", __FILE__, __LINE__);
g_gevManager->AddEvent(GEV_INSERT_Tail, GEV_KillTradeRoute,
GEA_TradeRoute, deadRoutes[i],
GEA_Int, CAUSE_KILL_TRADE_ROUTE_RECIPIENT_KILLED,
Expand Down
4 changes: 4 additions & 0 deletions ctp2_code/gs/gameobj/TradeRoute.cpp
Expand Up @@ -64,6 +64,10 @@ void TradeRoute::RemoveAllReferences(CAUSE_KILL_TRADE_ROUTE cause)
}
// }
}
ROUTE_TYPE type;
sint32 good;
GetSourceResource(type, good);
fprintf(stderr, "%s L%d: Kill trade route cause: %d, owner: %d, resource: %d!\n", __FILE__, __LINE__, cause, source.GetOwner(), good);

if ((NULL != g_player) &&
(NULL != g_player[GetPayingFor()])) {
Expand Down

0 comments on commit 81ae687

Please sign in to comment.