Creating a semi-permanent effect

You know, I checked and it is present all the way back to plain vanilla no-expansion Civ4. I could have sworn that at some point a Town would pillage completely out of existence in a single pillage. So there you go. :dunno:
 
maybe pillaging with a group? or a bug? thanks anyway!
 
don't know if you got around to doing anything for this asaf, but I am going to try my hand at it now :p
 
so this is what I have so far (where the PermanentEffectInfo just has a plot and effect)

Code:
std::vector <PermanentEffectInfo *> m_apEffectInfos;


std::vector <PermanentEffectInfo *> CvGame::getEffectInstances()
{
	return m_apEffectInfos;
}

void CvGame::addSemiPermanentEffect(PermanentEffectInfo * eEffect)
{
	m_apEffectInfos.push_back(eEffect);
}

void CvGame::clearPlotEffects()
{
	pausePermanentEffects(true);
	m_apEffectInfos.clear();
}

static bool bPauseEffects;

static void CvGame::pausePermanentEffects()
{
	bPauseEffects = true;
}

DWORD WINAPI CvGame::loopEffects()
{
	bPauseEffects = false;
	std::vector <PermanentEffectInfo *> effects = getEffectInstances();
	while (!bPauseEffects)
	{	
		for (int i = 0; i < effects.size(); i++)
		{
			gDLL->getEngineIFace()->TriggerEffect(effects[i]->eEffect, effects[i]->pPlot->getPoint());
		}
		Sleep(long(effects[0]->eEffect->getIntervalLooping() * 1000));
	}
}

where the vector is in the CvGame,

on the beginning of the game turn the thread is paused (need to make that non-evil without statics ;)) by the clearing of the vector. The vector is propagated with this turns effects and then fired at the end of the custom code function.

there are some problems with this though.

All effects MUST be the same length interval, and if I'm honest I don't know how I could make it more dynamic short of more threads... :rolleyes:

also there might be the need for mutexes on the vector (but possibly not as the thread is paused before the vector is manipulated...
 
I couldn't get mine to work... Are you still around here asaf?
 
From time to time, but I didn't really touch this issue. I don't have the time. Maybe in a few weeks. Or months. We'll see...
 
Back
Top Bottom