Announcement

Collapse
No announcement yet.

DEBUG: GetGovernment@StrategyRecord crash

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

  • DEBUG: GetGovernment@StrategyRecord crash

    I think this is the infamous 'standard' ctp2 crash but putting it out there, runs fine after re-load


    Code:
      0x005d752e  [?GetGovernment@StrategyRecord@@QBEPBVGovernmentRecord@@J@Z + 0x25]
      0x00896841  [?ComputeBestGovernment@Governor@@QBEJXZ + 0x78]
      0x008a1ca1  [?BeginTurn@CtpAi@@SAXJ@Z + 0x74]
      0x005380e9  [?GEVHookCallback@BeginTurnEvent@@EAE?AW4GAME_EVENT_HOOK_DISPOSITION@@W4GAME_EVENT@@PAVGameEventArgList@@@Z + 0x90]
      0x005bd91f  [?Run@GameEventHook@@AAE?AW4GAME_EVENT_ERR@@AAViterator@?$list@UNode@GameEventHook@@V?$allocator@UNode@GameEventHook@@@std@@@std@@PAVGameEventArgList@@AAJ@Z + 0x63]
      0x005bd8b6  [?Activate@GameEventHook@@QAE?AW4GAME_EVENT_ERR@@PAVGameEventArgList@@JAAJ@Z + 0x7e]
      0x005be50a  [?ActivateHook@GameEventManager@@QAE?AW4GAME_EVENT_ERR@@W4GAME_EVENT@@PAVGameEventArgList@@JAAJ@Z + 0x3a]
      0x005bc1d4  [?Process@GameEvent@@QAE?AW4GAME_EVENT_ERR@@AAH@Z + 0x2f]
      0x005be368  [?ProcessHead@GameEventManager@@QAE?AW4GAME_EVENT_ERR@@XZ + 0x33]
      0x005be30b  [?Process@GameEventManager@@QAE?AW4GAME_EVENT_ERR@@XZ + 0x7b]
      0x005be280  [?ArglistAddEvent@GameEventManager@@QAE?AW4GAME_EVENT_ERR@@W4GAME_EVENT_INSERT@@W4GAME_EVENT@@PAVGameEventArgList@@@Z + 0x13d]
      0x005be135  [?AddEvent@GameEventManager@@QAA?AW4GAME_EVENT_ERR@@W4GAME_EVENT_INSERT@@W4GAME_EVENT@@ZZ + 0xe5]
      0x0043e452  [?dh_endTurn@@YAXPAVDQAction@@PAVSequence@@W4DHEXECUTE@@@Z + 0x3c]
      0x004382ab  [?HandleNextAction@Director@@QAEXXZ + 0xfb]
      0x0041919d  [?Process@UnitActor@@UAEXXZ + 0x1e5]
      0x00438ee7  [?ProcessActiveUnits@Director@@QAEKXZ + 0x80]
      0x00438153  [?Process@Director@@QAEXXZ + 0x2d]
      0x0040ed06  [?ProcessUI@CivApp@@QAEJKAAK@Z + 0x22c]
      0x0040f025  [?Process@CivApp@@QAEJXZ + 0xa7]
      0x00407dd0  [?CivMain@@YGHPAUHINSTANCE__@@0PADH@Z + 0x3b6]
      0x00407847  [WinMain@16 + 0x74]
      0x008b079c  [WinMainCRTStartup + 0x134]
      0x7c816d4f  [__onexitbegin + 0x7bc66e77]
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  • #2
    background info, not sure what the issue is

    governor.cpp

    Code:
    sint32 Governor::ComputeBestGovernment() const
    {
    	const StrategyRecord & strategy = 
    		Diplomat::GetDiplomat(m_playerId).GetCurrentStrategy();
    
    	Player * player_ptr = g_player[m_playerId];
    	Assert(player_ptr != NULL);
    
    	bool config_found = false;
    	bool obsolete;
    	sint32 government_index = -1;
    	for (sint32 gov_index = 0; government_index == -1 && gov_index < strategy.GetNumGovernment(); gov_index++)
    		{
    			const GovernmentRecord *rec = strategy.GetGovernment(gov_index);
    			
    			
    			if (player_ptr->HasAdvance(rec->GetEnableAdvanceIndex()) == false)
    				continue;
    
    			
    			obsolete = false;
    			for (sint8 i=0; i < rec->GetNumObsoleteAdvance() && !obsolete; i++)
    				{
    					
    					if (player_ptr->HasAdvance(rec->GetObsoleteAdvance(i)->GetIndex())) 
    						{
    							obsolete = true;
    						}
    				}
    			if (obsolete)
    				continue;
    
    			
    			sint32 diff = rec->GetTooManyCitiesThreshold() - player_ptr->GetNumCities();
    			if (diff < 0)
    				continue;
    
    			
    			
    			
    
    			
    			government_index = rec->GetIndex();
    		}
    	
    	
    	return government_index;
    }
    I'm thinking if switch
    Code:
    			const GovernmentRecord *rec = strategy.GetGovernment(gov_index);
    with this

    Code:
    const GovernmentRecord *rec = strategy.GetGovernmentIndex; //would this fix the occasional crash?
    may fix the crash. the problem is that i cant test the crash since it happens randomly and you can restart without it bothering you.
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

    Comment

    Working...
    X