Weird results from IsEverAlive() at game start

whoward69

DLL Minion
Joined
May 30, 2011
Messages
8,727
Location
Near Portsmouth, UK
For a long time I've had the following code in one of my InGameUIAddin files

Code:
print("This is the 'My - Changes' mod script")

-- Add you own Lua code below here, and don't forget to check the log files for errors
for iPlayer = 0, GameDefines.MAX_MAJOR_CIVS-1, 1 do
  local pPlayer = Players[iPlayer]
  if (pPlayer:IsEverAlive()) then
    print(string.format("Player: %i (%s) : %i (%s)", pPlayer:GetID(), pPlayer:GetName(), pPlayer:GetCivilizationType(), pPlayer:GetCivilizationDescription()))
  end
end

print("-----")

Which most of the time prints (when there are 8 majors in the game)
Code:
[1223.515] MyLuaChanges: This is the 'My - Changes' mod script
[1223.515] MyLuaChanges: Player: 0 (Darius I) : 13 (Persian Empire)
[1223.515] MyLuaChanges: Player: 1 (Augustus Caesar) : 14 (Roman Empire)
[1223.515] MyLuaChanges: Player: 2 (Shaka) : 44 (Zulu Kingdom)
[1223.515] MyLuaChanges: Player: 3 (Gandhi) : 9 (Indian Empire)
[1223.515] MyLuaChanges: Player: 4 (Pacal) : 33 (Mayan Empire)
[1223.515] MyLuaChanges: Player: 5 (Sejong) : 25 (Korean Empire)
[1223.515] MyLuaChanges: Player: 6 (Dido) : 29 (Carthaginian Empire)
[1223.515] MyLuaChanges: Player: 7 (Pedro II) : 37 (Brazilian Empire)
[1223.515] MyLuaChanges: -----

BUT every once in a while I get (when there are still 8 majors in the game)
Code:
[1223.515] MyLuaChanges: This is the 'My - Changes' mod script
[1223.515] MyLuaChanges: Player: 0 (Darius I) : 13 (Persian Empire)
[1223.515] MyLuaChanges: -----

So I changed the code a couple of weeks back to
Code:
print("This is the 'My - Changes' mod script")

-- Add you own Lua code below here, and don't forget to check the log files for errors
for iPlayer = 0, GameDefines.MAX_MAJOR_CIVS-1, 1 do
  local pPlayer = Players[iPlayer]
  if (pPlayer:IsEverAlive()) then
    print(string.format("Player: %i (%s) : %i (%s)", pPlayer:GetID(), pPlayer:GetName(), pPlayer:GetCivilizationType(), pPlayer:GetCivilizationDescription()))
  end
end

print("-----")

for iSlot = 0, GameDefines.MAX_MAJOR_CIVS-1, 1 do
  local iSlotStatus = PreGame.GetSlotStatus(iSlot)
  if (iSlotStatus == SlotStatus.SS_TAKEN or iSlotStatus == SlotStatus.SS_COMPUTER) then
    local pPlayer = Players[iSlot]
    print(string.format("Player: %i (%s) : %i (%s)", pPlayer:GetID(), pPlayer:GetName(), pPlayer:GetCivilizationType(), pPlayer:GetCivilizationDescription()))
  end
end

print("-----")

Which most of the time prints
Code:
[1223.515] MyLuaChanges: This is the 'My - Changes' mod script
[1223.515] MyLuaChanges: Player: 0 (Darius I) : 13 (Persian Empire)
[1223.515] MyLuaChanges: Player: 1 (Augustus Caesar) : 14 (Roman Empire)
[1223.515] MyLuaChanges: Player: 2 (Shaka) : 44 (Zulu Kingdom)
[1223.515] MyLuaChanges: Player: 3 (Gandhi) : 9 (Indian Empire)
[1223.515] MyLuaChanges: Player: 4 (Pacal) : 33 (Mayan Empire)
[1223.515] MyLuaChanges: Player: 5 (Sejong) : 25 (Korean Empire)
[1223.515] MyLuaChanges: Player: 6 (Dido) : 29 (Carthaginian Empire)
[1223.515] MyLuaChanges: Player: 7 (Pedro II) : 37 (Brazilian Empire)
[1223.515] MyLuaChanges: -----
[1223.515] MyLuaChanges: Player: 0 (Darius I) : 13 (Persian Empire)
[1223.515] MyLuaChanges: Player: 1 (Augustus Caesar) : 14 (Roman Empire)
[1223.515] MyLuaChanges: Player: 2 (Shaka) : 44 (Zulu Kingdom)
[1223.515] MyLuaChanges: Player: 3 (Gandhi) : 9 (Indian Empire)
[1223.515] MyLuaChanges: Player: 4 (Pacal) : 33 (Mayan Empire)
[1223.515] MyLuaChanges: Player: 5 (Sejong) : 25 (Korean Empire)
[1223.515] MyLuaChanges: Player: 6 (Dido) : 29 (Carthaginian Empire)
[1223.515] MyLuaChanges: Player: 7 (Pedro II) : 37 (Brazilian Empire)
[1223.515] MyLuaChanges: -----

BUT again, every once in a while (eg, the last game I started) prints
Code:
[1223.515] MyLuaChanges: This is the 'My - Changes' mod script
[1223.515] MyLuaChanges: Player: 0 (Darius I) : 13 (Persian Empire)
[1223.515] MyLuaChanges: -----
[1223.515] MyLuaChanges: Player: 0 (Darius I) : 13 (Persian Empire)
[1223.515] MyLuaChanges: Player: 1 (Augustus Caesar) : 14 (Roman Empire)
[1223.515] MyLuaChanges: Player: 2 (Shaka) : 44 (Zulu Kingdom)
[1223.515] MyLuaChanges: Player: 3 (Gandhi) : 9 (Indian Empire)
[1223.515] MyLuaChanges: Player: 4 (Pacal) : 33 (Mayan Empire)
[1223.515] MyLuaChanges: Player: 5 (Sejong) : 25 (Korean Empire)
[1223.515] MyLuaChanges: Player: 6 (Dido) : 29 (Carthaginian Empire)
[1223.515] MyLuaChanges: Player: 7 (Pedro II) : 37 (Brazilian Empire)
[1223.515] MyLuaChanges: -----

So it looks like IsEverAlive() sometimes returns false if the capital hasn't been founded (or perhaps while another thread is still adding units - who knows!)

Anybody else seen this? Or is my machine just going :crazyeye:
 
Maybe. I have a similar print in my file loading code, but with IsAlive(). It always works on my setup, but I've seen Lua.logs from testers with what appear to be missing civs.

It's often the same players that have failure to load sql files or other problems that look like installation issues. So I always tell them to patch civ5, disable all other mods, reinstal civ5 if that doesn't work, and come back and report if problems persist. They never come back.
 
Maybe. I have a similar print in my file loading code, but with IsAlive(). It always works on my setup, but I've seen Lua.logs from testers with what appear to be missing civs.

It's often the same players that have failure to load sql files or other problems that look like installation issues. So I always tell them to patch civ5, disable all other mods, reinstal civ5 if that doesn't work, and come back and report if problems persist. They never come back.

Except I have no SQL/XML that's not loading, no Lua that's not executing, no custom civs active, pretty sure I'd know if I had the wrong version of the game or not up-to-date (according to Steam), it's not the combo of mods as I can shut-down Civ5 and the computer and use exactly the same set-up to start another game and it'll print fine.

I'm leaning towards a slow memory leak (I do stop/start Civ a lot during testing and Civ definitely dislikes having FireTuner attached during that sequence - FireTuner will sometimes crash while Civ is trying to detach itself from the process)

Still, the Pregame calls work, so I'm going to use them instead of IsEverAlive() for what I want to do
 
Sort of tangential: I needed to know what City States had ever been in the game. But it appears that player:IsEverAlive() is true for all CS slots!

On kicking this problem around a little, I think the best answer may be:
Code:
player:GetStartingPlot() ~= nil
Seems like that would work for full civs too.
 
Sort of tangential: I needed to know what City States had ever been in the game. But it appears that player:IsEverAlive() is true for all CS slots
Weird. As stated above EUI uses this without problems for all civs, including city states. Malfunction would be prominently visible, thousands are using EUI, and I never any got bug report on this aspect.
 
Back
Top Bottom