Thanks Martin,
Will do the stuff tonight (after I get the most recent update etc)
My compiler came with my C++ for dumies I think its Visual Basic 6.0 or something to that affect.
I'll also refresh the CanSettleOn issue but HasResource keeps bugging me that it has something to do with checking or assigning a resource(good) to a city and that it could be used to do a needsCityGood function...
and
Will do the stuff tonight (after I get the most recent update etc)
My compiler came with my C++ for dumies I think its Visual Basic 6.0 or something to that affect.
I'll also refresh the CanSettleOn issue but HasResource keeps bugging me that it has something to do with checking or assigning a resource(good) to a city and that it could be used to do a needsCityGood function...
Code:
IN CITYDATA.CPP BOOL CityData::HasResource(sint32 resource) const { return m_collectingResources[resource] > m_sellingResources[resource]; } BOOL CityData::IsLocalResource(sint32 resource) const { return m_collectingResources[resource] > 0; } bool CityData::GetResourceTradeRoute(sint32 resource, TradeRoute & route) const { sint32 i; for(i = 0; i < m_tradeSourceList.Num(); i++) { ROUTE_TYPE type; sint32 rr; m_tradeSourceList[i].GetSourceResource(type, rr); if(type != ROUTE_TYPE_RESOURCE) continue; if(rr != resource) continue; route = m_tradeSourceList[i]; return true; } return false; } bool CityData::IsSellingResourceTo(sint32 resource, Unit & destination) const { sint32 i; for(i = 0; i < m_tradeSourceList.Num(); i++) { ROUTE_TYPE type; sint32 rr; m_tradeSourceList[i].GetSourceResource(type, rr); if(type != ROUTE_TYPE_RESOURCE) continue; if(rr != resource) continue; destination.m_id = m_tradeSourceList[i].GetDestination().m_id; return true; } destination.m_id = 0; return false; }
Code:
GOVERNOR.CPP void Governor::ManageGoodsTradeRoutes() { Assert(g_player[m_playerId] != NULL); Player *player_ptr = g_player[m_playerId]; sint32 cur_round = player_ptr->GetCurRound(); Unit city; sint16 i,g,d;; UnitDynamicArray *city_list = player_ptr->GetAllCitiesList(); double unused_freight = player_ptr->GetUnusedFreight(); double total_freight = player_ptr->GetTotalFreight(); GoodsRoute new_route; GoodsRouteList new_routes; m_neededFreight = 0.0; for (i = 0; i < city_list->Num(); i++) { city = city_list->Access(i); for(g = 0; g < g_theResourceDB->NumRecords(); g++) { if(city.CD()->IsLocalResource(g)) { sint32 op; Unit maxCity; sint32 maxPrice = 0; sint32 bestPrice = 0; double maxCost = 0.0; double maxNeededFreight = 0.0; sint32 sellingPrice = -1; TradeRoute curDestRoute; [b]if( city.CD()->HasResource(g) == FALSE && [/b]city.CD()->GetResourceTradeRoute(g, curDestRoute)) { sellingPrice = tradeutil_GetTradeValue(m_playerId, curDestRoute->GetDestination(), g); } else { curDestRoute.m_id = 0; sellingPrice = -1; } for(op = 1; op < k_MAX_PLAYERS; op++) {
Comment