Éa III, Sword & Sorcery: Bugs/Crashes thread

@ls612, here's another hotfix that should fix Vinnz's errors from selling/rendering slaves. It also fixes some other problem that would be very obscure to debug (non-GP action makes previous GP stop current action). It's a big block of code in EaActions.lua.

Replace this (line 965 to 1027):
Spoiler :
Code:
	g_eaPerson.gotoPlotIndex = -1	
	g_eaPerson.gotoEaActionID = -1

	if g_bGreatPerson then
		if g_eaPerson.eaActionID ~= -1 and g_eaPerson.eaActionID ~= eaActionID then					--GP had a previous action that needs to be interrupted
			InterruptEaAction(iPlayer, iPerson)
		elseif not bTest and g_eaPerson.eaActionID == eaActionID then								--this was an ongoing action that needs to be interrupted
			InterruptEaAction(iPlayer, iPerson)
			--ReappearGP(iPlayer, iPerson)
		end
	end
	if not bTest then return false end	--action cannot be done for some reason; GP will reappear for instructions (human or AI)

	--add generic table tag effects here

	if Do[eaActionID] then
		if not Do[eaActionID]() then	--this is the call to action-specific Do function if it exists
			print("!!!! Warning: TestEaAction said OK but action specific Do function did not return a true value")
			InterruptEaAction(iPlayer, g_iPerson)
			return false		--Warning! AI might go into infinite loop if Test keeps passing true (fail from Do only possible for DoMoveToPlot at this time)
		end
	end

	if g_bGreatPerson then
		--Memory for AI specialization
		if g_eaAction.GPModType1 then
			local memValue = 2 ^ (g_gameTurn / MOD_MEMORY_HALFLIFE)
			local modID = GameInfoTypes[g_eaAction.GPModType1]
			g_eaPerson.modMemory[modID] = (g_eaPerson.modMemory[modID] or 0) + memValue
			if g_eaAction.GPModType2 then
				local modID = GameInfoTypes[g_eaAction.GPModType2]
				g_eaPerson.modMemory[modID] = (g_eaPerson.modMemory[modID] or 0) + memValue
			end
		end
	end

	if g_eaAction.StayInvisible then
		g_unit:SetInvisibleType(INVISIBLE_SUBMARINE)
	else 
		g_unit:SetInvisibleType(-1)
	end

	--Alt unit upgrades
	if g_eaAction.UnitUpgradeTypePrefix then
		local newUnit = g_player:InitUnit(g_int1, g_x, g_y)
		MapModData.bBypassOnCanSaveUnit = true
		newUnit:Convert(g_unit, true)
		g_unit = newUnit		--this will finish moves below; watch out because g_unitTypeID is no longer correct
		g_player:ChangeGold(-g_int2)
	end

	--Effects on unit
	if g_eaAction.DoXP > 0 then
		g_unit:ChangeExperience(g_eaAction.DoXP)
	end
	if g_eaAction.DoGainPromotion then
		g_unit:SetHasPromotion(GameInfoTypes[g_eaAction.DoGainPromotion], true)
	end

	--Finish moves
	if g_eaAction.FinishMoves  then
		g_unit:FinishMoves()
	end
with this...
Spoiler :
Code:
	if g_bGreatPerson then
		g_eaPerson.gotoPlotIndex = -1	
		g_eaPerson.gotoEaActionID = -1	
		if g_eaPerson.eaActionID ~= -1 and g_eaPerson.eaActionID ~= eaActionID then					--GP had a previous action that needs to be interrupted
			InterruptEaAction(iPlayer, iPerson)
		elseif not bTest and g_eaPerson.eaActionID == eaActionID then								--this was an ongoing action that needs to be interrupted
			InterruptEaAction(iPlayer, iPerson)
			--ReappearGP(iPlayer, iPerson)
		end
	end
	if not bTest then return false end	--action cannot be done for some reason; GP will reappear for instructions (human or AI)

	--add generic table tag effects here

	if Do[eaActionID] then
		if not Do[eaActionID]() then	--this is the call to action-specific Do function if it exists
			print("!!!! Warning: TestEaAction said OK but action specific Do function did not return a true value")
			InterruptEaAction(iPlayer, g_iPerson)
			return false		--Warning! AI might go into infinite loop if Test keeps passing true (fail from Do only possible for DoMoveToPlot at this time)
		end
	end

	if g_bGreatPerson then
		--Memory for AI specialization
		if g_eaAction.GPModType1 then
			local memValue = 2 ^ (g_gameTurn / MOD_MEMORY_HALFLIFE)
			local modID = GameInfoTypes[g_eaAction.GPModType1]
			g_eaPerson.modMemory[modID] = (g_eaPerson.modMemory[modID] or 0) + memValue
			if g_eaAction.GPModType2 then
				local modID = GameInfoTypes[g_eaAction.GPModType2]
				g_eaPerson.modMemory[modID] = (g_eaPerson.modMemory[modID] or 0) + memValue
			end
		end
		if g_eaAction.StayInvisible then
			g_unit:SetInvisibleType(INVISIBLE_SUBMARINE)
		else 
			g_unit:SetInvisibleType(-1)
		end	
	end

	--Alt unit upgrades
	if g_eaAction.UnitUpgradeTypePrefix then
		local newUnit = g_player:InitUnit(g_int1, g_x, g_y)
		MapModData.bBypassOnCanSaveUnit = true
		newUnit:Convert(g_unit, true)
		g_unit = newUnit		--this will finish moves below; watch out because g_unitTypeID is no longer correct
		g_player:ChangeGold(-g_int2)
	end

	--Effects on unit
	if g_eaAction.DoXP > 0 then
		g_unit:ChangeExperience(g_eaAction.DoXP)
	end
	if g_eaAction.DoGainPromotion then
		g_unit:SetHasPromotion(GameInfoTypes[g_eaAction.DoGainPromotion], true)
	end

	--Finish moves
	if g_eaAction.FinishMoves and g_unit then
		g_unit:FinishMoves()
	end
 
Update: I've been unable to reproduce the bug in my two newer games (Hotfixes H and I - I annoyed the AI with buying tiles close to their cities, what seemed to be the trigger in the old one, in both of them), so I'm starting to think it is indeed a corrupt save.
 
Got a bunch of errors on main screen including some attempt to index local 'capital' (a nil value) when a civilization lost their cap (so i guess it's related).
Lua log

Could continue playing but trying to load a save from that game later resulted in errors related to table-saver-loader (EaMain\TableSaverLoader.lua:319: attempt to concatenate field '?' (a nil value)). Whether it's related or not, i don't know. Here is the log when trying to load such a save (after rebooting and deleting the cache so this shouldn't be caused by corrupted data, i also tried multiple regular and auto-saves with the same error).
Lua log
 
@Bob Morane,

Found and fixed error for v3. Don't bother playing past these (or loading from saves after such an error). It will be bad 90% of the time.

I think we are done hotfixing since v3 is a couple days away. But you can patch this yourself if you want. Go into EaMain/EaPeople.lua and insert the line in red below (at line 1164):
Code:
function AIInturruptGPsForLeadershipOpportunity(iPlayer)	--TO DO: Make this better by selecting good leader for civ
	local player = Players[iPlayer]
	local capital = player:GetCapitalCity()
	[COLOR="Red"]if not capital then return end[/COLOR]
If you do that then try loading a save from before the error. Post if you have problems after that.
 
Well, i started another test (still trying to go for evil domination). I don't think i could have found which autosave to load anyway.

I have another error thought. Looks like someone is trying to blight the land (there are worse guys than me in this game :p) and the result is ugly ... but not as it should
Code:
[34218.453] EaMain: BlightPlot 	table: 5CC36140	5	47	0	true
[34218.453] EaMain: All target tests passed
[34218.453] EaMain: E:\Documents\My Games\Sid Meier's Civilization 5\MODS\Éa III, Sword and Sorcery (v 2)\EaMain\EaSpells.lua:2269: attempt to perform arithmetic on a nil value
Full log is here
 
In my newest game (on hotfix I), I am getting seemingly random crashes. They happen most often, but not exclusively and not all the time, when giving my mages Necromancy spells.

Included are the lua.log, the CvMinidump.dmp and the last autosave (one of my Necromancers finishes the Lich spell next turn and gets multiple levels).
 

Attachments

@Shadowling,

The CTD above is just that d*** Learn Spell popup CTD (sorry for the profanity). We never figure it out, but I think it may have fixed itself in v3 when I moved Learn Spell to an action rather than a promotion alternative. I clicked it 10 times in newest v3 build without crash, which is a good sign.


@Bob Morane, that error is from 0-offset/1-offset confusion in my NIMBY function causing nil return for map edge cases. Will be fixed in v3. Manual fix: in EaUtilities/EaNIMBY.lua...

Change this:
Code:
local iW5, iH5 = Floor(iW/5), Floor(iH/5)
to this:
Code:
local iW5, iH5 = Floor(iW/5) + 1, Floor(iH/5) + 1
And this:
Code:
local dist = PlotDistance(x, y, x5*5, y5*5)
to this:
Code:
local dist = PlotDistance(x, y, (x5-1)*5, (y5-1)*5)
And this:
Code:
return g_playerNimbyGrids[iPlayer][Floor(x/5)][Floor(y/5)]
to this:
Code:
return g_playerNimbyGrids[iPlayer][Floor(x/5) + 1][Floor(y/5) + 1]

Also, I can see that you are loading a lot of games without exiting Civ5. Didn't seem to cause any problems for you here, but I'm pretty sure it does sometimes. And at the very top of your log it looks like you started the mod and then backed up (or something like that) causing a bunch of errors. Someday we'll sort this out, but for now treat such activities as potentially hazardous.
 
Also, I can see that you are loading a lot of games without exiting Civ5. Didn't seem to cause any problems for you here, but I'm pretty sure it does sometimes. And at the very top of your log it looks like you started the mod and then backed up (or something like that) causing a bunch of errors. Someday we'll sort this out, but for now treat such activities as potentially hazardous.
Thanks, i will apply the fix. Yep, reloading without exiting didn't seem to cause issues with Ea (though it did with other mods) but maybe i was just lucky. I expected errors to show up if a save doesn't load correctly (and in such situation, i would exit before loading), is there a risk of "silent errors"?.

If i remember correctly, i backed up when i realized i didn't apply the last hot-fix (Fay&co were still visible in advanced setup). Of course, it would have been safer to exit completely. Could this be the cause of the "invisible warrior bug"? :rolleyes: I've just noticed a civ i'm at war with was attacking me with an apparently invisible unit, i moved a great warrior close and the unit is right under one of my rangers :eek: Looks like that unit received the invisibility that GP have.
Spoiler :
Ea-error-screen0611.jpg
 
@Shadowling,

The CTD above is just that d*** Learn Spell popup CTD (sorry for the profanity). We never figure it out, but I think it may have fixed itself in v3 when I moved Learn Spell to an action rather than a promotion alternative. I clicked it 10 times in newest v3 build without crash, which is a good sign.

Ah, okay. Odd that I only ran into it with this game - I only have 2 mages so far and had a lot more in other games. Ah well, random CTD bugs are random.
And don't worry about 'profanity'. I don't belief in bad words, only bad people :p.
 
Started yet another new game and found another odd thing. This time, I can't improve cinnabar. I thought at first that this was because I was missing Alchemy (which I was) but after that research completed I still couldn't build on it.
If I were to guess I'd say that it has something to do with me being pantheistic this time (as I wasn't in the previous game and it worked fine there).

Enclosed is the lua.log and the latest save, with a free worker on top of cinnabar in my territory (and, in my game, no option to build anything there that I can't build on a resource-free tile as a pantheistic civ).
 

Attachments

Oh my! I just discovered what I think is a very big Civ5 bug (problem was noticed by tester way up this thread). All player modifiers for tech costs are only used for UI! They are not applied for actual tech discovery.
 
Oh my! I just discovered what I think is a very big Civ5 bug (problem was noticed by tester way up this thread). All player modifiers for tech costs are only used for UI! They are not applied for actual tech discovery.

I don't think so. Check out CvPlayerTechs::GetResearchCost and CvTeamTechs::GetResearchCost. Those look like they get everything.
 
I don't think so. Check out CvPlayerTechs::GetResearchCost and CvTeamTechs::GetResearchCost. Those look like they get everything.
Sometimes Firaxis codes things in strange ways...

CvPlayerTechs::GetResearchCost is used for UI only. It has player-specific modifiers (such as base Civ5 penalty for city number). But, rather than use this method for the actual game effect, they cut/paste the player-specific calculations elsewhere to get the cost for actual game effect (I haven't tracked down exactly where, but searching for the base Civ5 #city penalty might be a good way to find it).

I know this from a test game where I gave exactly 50% discount to even numbered techs. The UI totally reflects the discount, but then you need 2x more research points (i.e., the unmodded amount) to actually get the tech.

What this means for the mod is that all tech cost mods (including knowledge maintenance, tomes and civ favored tech) are not really applied. They only change appearance in UI. I think there were >1 posts here from testers that suspected something fishy here, but I had to test it to believe it.

I'll fix this for v3, which I think will be out late tomorrow...
 
Well, it's probably inaccurate for me to call it a "bug" for base Civ5. I suspect that #city penalty still works in Civ5. The bug was me expecting this calculation to occur in one place in the method named to do it. But the way they actually did it was to add the code twice, once in this method (used only for UI) and then separately in whatever code actually does the job.

Of course, the whole purpose of a method is to do something in one place so you only have to get it right once. My understanding is that the firm that coded healthcare.gov didn't know this which is why it was 500 million lines of code that didn't exactly do anything for a while.
 
Well, it's probably inaccurate for me to call it a "bug" for base Civ5. I suspect that #city penalty still works in Civ5. The bug was me expecting this calculation to occur in one place in the method named to do it. But the way they actually did it was to add the code twice, once in this method (used only for UI) and then separately in whatever code actually does the job.

Of course, the whole purpose of a method is to do something in one place so you only have to get it right once. My understanding is that the firm that coded healthcare.gov didn't know this which is why it was 500 million lines of code that didn't exactly do anything for a while.

Looking around it looks like the base game's modifiers are correctly accounted for. Only the new stuff added by Ea is not being handled properly. :crazyeye:
 
Back
Top Bottom