Announcement

Collapse
No announcement yet.

DEBUG: Revolting Cities Keep Revolting

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

  • DEBUG: Revolting Cities Keep Revolting

    No Crash to post but I believe this is the pertinent code

    Code:
    void CityData::Revolt(sint32 &playerToJoin, BOOL causeIsExternal)
    {
    	sint32 i,
    	       n;
    
    	PLAYER_INDEX const  orgowner    = m_owner;
    
    	CellUnitList army;
    
    	MapPoint     city_pos,
    	             new_city;
    
    	BOOL         joined_egalatarians = FALSE;
    
    	g_player[m_owner]->m_score->AddRevolution();
    
    	m_home_city.GetPos(city_pos) ;
    	
    	if(!causeIsExternal && g_network.IsActive()) {
    		g_network.Block(m_owner);
    	}
    	
    	PLAYER_INDEX        newowner    = PLAYER_UNASSIGNED;
    
    	if(wonderutil_GetRevoltingCitiesJoinPlayer(g_theWonderTracker->GetBuiltWonders())) {
    		sint32 p;
    		for(p = 0; p < k_MAX_PLAYERS; p++) {
    			if(g_player[p]) {
    				if(wonderutil_GetRevoltingCitiesJoinPlayer(
    					g_player[p]->m_builtWonders)) {
    					newowner = p;
    					
    					
    					
    					
    					
    					if(newowner == m_owner) {
    						newowner = PLAYER_UNASSIGNED;
    					} else {
    						joined_egalatarians = TRUE;
    					}
    					break;
    				}
    			}
    		}
    	}
    
    	if(newowner < 0) {
    		if(playerToJoin < 0) {
    			newowner = civilisation_NewCivilisationOrVandals(m_owner);
    			playerToJoin = newowner;
    		} else {
    			newowner = playerToJoin;
    		}
    	}
    
    	if (orgowner != newowner)
    	{
    		if(g_network.IsHost()) {
    			g_network.Block(orgowner);
    			g_network.Enqueue(new NetInfo(NET_INFO_CODE_REVOLT_NOTICES,
    			                              orgowner, newowner,
    			                              m_home_city.m_id,
    			                              joined_egalatarians));
    			g_network.Unblock(orgowner);
    		}
    
    		SlicObject *so = new SlicObject("010NewCiv");
    		so->AddAllRecipients();
    		so->AddCivilisation(orgowner);
    		so->AddCivilisation(newowner);
    		so->AddCity(m_home_city);
    		g_slicEngine->Execute(so) ;
    
    		if (joined_egalatarians) {
    			so = new SlicObject("011CityJoinedYourCiv");
    			so->AddRecipient(newowner);
    			so->AddCivilisation(orgowner);
    			so->AddCivilisation(newowner);
    			so->AddCity(m_home_city);
    			g_slicEngine->Execute(so) ;
    		}
    
    	}
    
    	if(!causeIsExternal && g_network.IsActive()) {
    		g_network.Unblock(m_owner);
    	}
    	
    	m_home_city.ResetCityOwner(newowner, FALSE, CAUSE_REMOVE_CITY_HAPPINESS_REVOLT);
    	m_build_queue.Clear();
    
    #if 0
    	AddHappyTimer(50, 100, HAPPY_REASON_POST_REVOULTION_BLISS);
    #endif
    
    	g_theWorld->GetCell(city_pos)->GetArmy(army) ;
    	n=army.Num() ;
    	for (i=0; iAddEvent(GEV_INSERT_AfterCurrent, GEV_KillUnit,
    		                       GEA_Unit, army[i].m_id,
    		                       GEA_Int, CAUSE_REMOVE_ARMY_UPRISING,
    		                       GEA_Player, newowner,
    		                       GEA_End);
    	}
    
    
    	SpecialAttackInfoRecord const * specRec = 
            unitutil_GetSpecialAttack(SPECATTACK_REVOLUTION);
    
    	if (specRec) 
        {
        	sint32 const soundID = specRec->GetSoundIDIndex();
    
            if (soundID >= 0)
            {
    		    sint32 const spriteID = specRec->GetSpriteID()->GetValue();
    
                if (spriteID >= 0)
                {
                    g_director->AddSpecialAttack
                        (m_home_city.GetActor()->GetUnitID(), m_home_city, SPECATTACK_REVOLUTION);
                }
                else
                {
    			    sint32 const visiblePlayer = g_selected_item->GetVisiblePlayer();
    			    if ((visiblePlayer == m_owner) || 
    				    (m_home_city.GetVisibility() & (1 << visiblePlayer))
                       ) 
                    {
        				g_soundManager->AddSound(SOUNDTYPE_SFX, (uint32)0, 	soundID, 
    				                             m_home_city.RetPos().x, m_home_city.RetPos().y);
    	    		}
                }
                
            }
    	}
    
    	// Modified by kaan to address bug # 12
    	// Prevent city from revolting twice in the same turn.
    	m_min_turns_revolt = static_cast(g_theConstDB->GetMinTurnsBetweenRevolt()); 
    }

    As you can see there is supposed to be a post revolution bliss and some other stuff preventing these cities from revolting over and over again. I don't think the code is broken, I think the new civ just cant handle the city after the bliss period ends.

    I think we may have to do one or more of the following

    - Check if Capitol exists for the new civ and create the capitol, I think the lack of the capitol makes it tough to continue

    - Cut the population of the revolting city (casualties of the revolution). Large population seems to be thesource of the constant revolts.

    - Create additional units that impose martial law

    - Just give it to the Barbarians

    - RevoltingCitiesJoinPlayer should be given to a wonder earlier in the game


    - Accept it as is. I know Bureaubert has cringed. I think its kind of a nice touch. it is a bit much but never hurt my game.
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com
Working...
X