Pazyryk
Deity
- Joined
- Jun 13, 2008
- Messages
- 3,584
I added whoward69's building unhappiness above (which is fine) but I also added two new events:
GameEvents.GetModHappiness(iPlayer) in CvPlayer::DoUpdateHappiness
GameEvents.GetModUnhappiness(iPlayer) in CvPlayer::GetUnhappiness
They are accumulators that would allow easy Lua control of player happiness. Sounds fine, right? Problem is, GetModUnhappiness fires at least 26 times and sometimes up to well over 100 times per player per turn (even for a minors!). And this is in the first 10 turns of a game. Jeez! Who coded this?
I said a while back that Lua can be faster than C++ (the same way a Honda can be faster than a Ferrari). This is exactly what I was thinking about.
Well, I'm not going to fix the dll. But this is probably not a good place for a GameEvent. So I pulled both of these back out. Probably should do this with new persisted members in CvPlayers.
Edit:
@ls612, if you want a dll job, you could recode this for me with two new persisted CvPlayer members:
m_iHappinessFromMod
m_iUnhappinessFromMod
and new Set and Get C++/Lua methods for both. Need it in a day or two though for me to use it on the Lua side.
GameEvents.GetModHappiness(iPlayer) in CvPlayer::DoUpdateHappiness
GameEvents.GetModUnhappiness(iPlayer) in CvPlayer::GetUnhappiness
They are accumulators that would allow easy Lua control of player happiness. Sounds fine, right? Problem is, GetModUnhappiness fires at least 26 times and sometimes up to well over 100 times per player per turn (even for a minors!). And this is in the first 10 turns of a game. Jeez! Who coded this?
I said a while back that Lua can be faster than C++ (the same way a Honda can be faster than a Ferrari). This is exactly what I was thinking about.
Well, I'm not going to fix the dll. But this is probably not a good place for a GameEvent. So I pulled both of these back out. Probably should do this with new persisted members in CvPlayers.
Edit:
@ls612, if you want a dll job, you could recode this for me with two new persisted CvPlayer members:
m_iHappinessFromMod
m_iUnhappinessFromMod
and new Set and Get C++/Lua methods for both. Need it in a day or two though for me to use it on the Lua side.