Announcement

Collapse
No announcement yet.

PROJECT: Good Specific Terrain Improvements

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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...

    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;
    }
    and
    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++) {
    Last edited by Ekmek; May 6, 2005, 18:29.
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

    Comment


    • Well the first four methods seem to be accurate for your project, but your next task is to get the game to compile on your computer.

      Your compiler can't be Visual Basic 6.0 that's a compiler for another language, so it must be Visual C++ 6.0 including Microsoft Visual Studio and of course the introductory version.

      But for testing your code it is enough.

      To answer your other question what I had to correct. Actual the answer is very easy if you use the Show Log feature of TortoiseSVN and mark there on the list Revision 346 and right click on the CityData.cpp and use from there the Show Differences option.

      In CityData.cpp I corrected wrong cases. You have to figure out on your own what I have done.

      And you have to make sure that in the settings of TortoiseMerge the option Ignore All Whitespaces is used.

      In Player.cpp I didn't fix anything at your code, I just removed .NET warnings in other parts of the file.

      In terrainutil.cpp I fixed something at your code, again you have to figure this out on your own. And I added an #include "Civilisation.h".

      And in the *.cdb files I fixed some syntax errors, again you have to find them on your own but with TortoiseMerge this should be easy.

      All these fixes have in common is that they are very hard to catch especially this #include "Civilisation.h" as long as you don't try to compile your changes, therefore you need a compiler.

      -Martin
      Civ2 military advisor: "No complaints, Sir!"

      Comment

      Working...
      X