Autoplay questions

Pazyryk

Deity
Joined
Jun 13, 2008
Messages
3,584
I've been doing a lot of Autoplay lately for mod development.

Question for DLL modders: Is the code for Game.SetAIAutoplay() accessible to us? The reason I'm asking is because this code (wherever it resides) is able to reset the minimap. That's something I'd like to be able to do but I've thought impossible for us.

Another question: Does anyone know how to stop autoplay in the middle of a run? The Live Tuner "stop" button doesn't work for me. It calls Game.SetAIAutoplay(0, returnPlayerID) which actually makes autoplay run forever (0=infinity apparently). If you use Game.SetAIAutoplay(5, 0), then it will run for 5 turns and stop with Game.GetAIAutoplay() reporting 5, 4, 3, 2, 1, 0, 0,... However, if you use Game.SetAIAutoplay(0, 0), then autoplay runs forever with Game.GetAIAutoplay() reporting 0, 0, 0, 0, 0, 0,... Using -1 instead of 0 in the set command doesn't work either.
 
Yes, it is accessible, here is the function.

As you can see it does not reset the mini-map, it switches you over to the observer.

Code:
//	--------------------------------------------------------------------------------
void CvGame::setAIAutoPlay(int iNewValue, PlayerTypes eReturnAsPlayer)
{
	int iOldValue;

	iOldValue = getAIAutoPlay();

	if(iOldValue != iNewValue)
	{
		m_iAIAutoPlay = std::max(0, iNewValue);
		m_eAIAutoPlayReturnPlayer = eReturnAsPlayer;

		if((iOldValue == 0) && (getAIAutoPlay() > 0))
		{
			if(CanMoveActivePlayerToObserver())
			{
				ActivateObserverSlot();
			}

			else
			{
				GET_PLAYER(getActivePlayer()).killUnits();
				GET_PLAYER(getActivePlayer()).killCities();
				CvPreGame::setSlotStatus(getActivePlayer(), SS_OBSERVER);
			}
		}
	}
}
 
Does auto-play use parts of the hotseat functions ?
 
Does auto-play use parts of the hotseat functions ?

Yes.

Code:
//	--------------------------------------------------------------------------------
/// Return control to the user after an autoplay
void CvGame::ReviveActivePlayer()
{
	if(!(GET_PLAYER(getActivePlayer()).isAlive()))
	{
		setAIAutoPlay(0, m_eAIAutoPlayReturnPlayer);

		// If no player specified, returning as an observer
		if(m_eAIAutoPlayReturnPlayer == NO_PLAYER)
		{
			CvPreGame::setSlotClaim(getActivePlayer(), SLOTCLAIM_ASSIGNED);
			CvPreGame::setSlotStatus(getActivePlayer(), SS_OBSERVER);
		}

		// Want to return as a specific player
		else
		{
			// Reset observer slot
			CvPreGame::setSlotClaim(getActivePlayer(), SLOTCLAIM_UNASSIGNED);
			CvPreGame::setSlotStatus(getActivePlayer(), SS_OBSERVER);

			// Move the active player to the desired slot
			CvPreGame::setSlotStatus(m_eAIAutoPlayReturnPlayer, SS_TAKEN);
			[B]setActivePlayer(m_eAIAutoPlayReturnPlayer, false /*bForceHotSeat*/, true /*bAutoplaySwitch*/);[/B]
		}
	}
}
 
The reason I'm asking is because this code (wherever it resides) is able to reset the minimap.

Is it possible to just reset the dirty bit? DLLUI->setDirty(MinimapSection_DIRTY_BIT, true);
 
Is it possible to just reset the dirty bit? DLLUI->setDirty(MinimapSection_DIRTY_BIT, true);

I'll have to wait for one of you DLL modders to tell me. From various posts I gathered that the minimap could not be reset in any way by modders. I guess there is nothing special about autoplay regarding minimap. It's just a player change I'm seeing.
 
Back
Top Bottom