Hunting the "Fall of France" crash, I need your help.

Status
Not open for further replies.
The crash still occurs, but looking in the log, you'll see it now crashes on a different line, which is:

[516563.687] RedMain: ListenerSerialEventCityCreated: table: AAF62090 4 139280 3 2 4 2 1 2

Idk what it means but i hope it helps you
 

Attachments

Thank you again, another suspect is cleaned.

Now we're going to start the serious stuff.

Next candidates are the units moving around when the territory and the cities are flipping side.

We're going to try a simple test first : kill all allied units before anything else (don't worry, they're virtual)

You can restore
Code:
Events.SerialEventHexCultureChanged.Add( CheckCultureChange )
as it was.

Next file to open is ScriptEuro1940.lua in "..\Documents\my games\Sid Meier's Civilization 5\MODS\R.E.D. WWII Edition (v 39)\Lua\Europe1940"

Find this bit of code (starting at line 344)

Code:
	Dprint("- Each U.K. unit on french territory get 50% chance to go back to London (or die trying)", bDebug)
	for unit in pEngland:Units() do 
		if unit:GetPlot():GetOwner() == iFrance then
			if math.random( 1, 100 ) > 50 or unit:GetDomainType() == DomainTypes.DOMAIN_SEA then
				Dprint("  Killed : " .. unit:GetName(), bDebug)
				unit:Kill(false, -1)
			else
				Dprint("  Escape : " .. unit:GetName(), bDebug)
				CleanOrdersRED (unit)
				unit:SetXY(iEnglandCityX, iEnglandCityY)
			end
		end
	end
to
Code:
	Dprint("- Each U.K. unit on french territory get 50% chance to go back to London (or die trying)", bDebug)
	for unit in pEngland:Units() do 
		if unit:GetPlot():GetOwner() == iFrance then
			Dprint("  Killed : " .. unit:GetName(), bDebug)
			unit:Kill(false, -1)
		end
	end

that's should take care of the british

and then, a few lines after, change the following:
Code:
	for unit in pFrance:Units() do 
		--local newUnit = ChangeUnitOwner (unit, iVichy)
		if (unit:GetUnitType() == CONVOY or unit:GetUnitType() == FORTIFIED_GUN) then
			Dprint(" - Killing " .. unit:GetName(), bDebug)
			unit:Kill(false, -1)
		elseif not unit:IsDead() then
			if unit:GetDomainType() == DomainTypes.DOMAIN_AIR then
				table.insert(Air, { Unit = unit, XP = unit:GetExperience() })
			elseif unit:GetDomainType() == DomainTypes.DOMAIN_SEA then
				table.insert(Sea, { Unit = unit, XP = unit:GetExperience() })
			else
				table.insert(Land, { Unit = unit, XP = unit:GetExperience() })
			end
		end
	end

to

Code:
	for unit in pFrance:Units() do 

		Dprint(" - Killing " .. unit:GetName(), bDebug)
		unit:Kill(false, -1)

	end

Save the file, and please, try again.
 
and yes, it really helps a lot :goodjob:
 
There was no crash. But whatever you had us remove, I'm guessing that just made it so the event wouldn't fire? Because after that nothing happened. I assigned a bit of production after capturing the city, but then left.
 

Attachments

I'm afraid I'll have to stop Testing now, however I have one small question for Gedemon:

How would I go about changing the unit supply limit in the lua files (for each civ)

TIA
 
There was no crash. But whatever you had us remove, I'm guessing that just made it so the event wouldn't fire? Because after that nothing happened. I assigned a bit of production after capturing the city, but then left.
Nop, the file is not loaded at all there, there is one "end" missing somewhere, check if you've not removed too many lines (the indentation should help you)

(and tell me when you have to stop too please :) )
 
I'm afraid I'll have to stop Testing now, however I have one small question for Gedemon:

How would I go about changing the unit supply limit in the lua files (for each civ)

TIA

Answered in the development thread :)
 
Ah allright... now we're going somewhere... kinda... i don't know. The game crashed again, same line of code, the one where it places culture on 28,33 and then removes it.
 

Attachments

Okay, thanks, just one last thing for tonight, further down, found this bit of code:

Code:
	Dprint("- Change french cities ownership ...", bDebug)	
	for city in pFrance:Cities() do  -- todo : handle french owned cities in colonies
		local plot = city:Plot()
		local plotKey = GetPlotKey ( plot )
		local originalOwner = GetPlotFirstOwner(plotKey)
		if originalOwner ~= iFrance then -- liberate cities captured by France
			Dprint(" - liberate city captured by France: " .. city:GetName(), bDebug )
			local originalPlayer = Players[originalOwner]
			EscapeUnitsFromPlot(plot)			
			coroutine.yield()
			originalPlayer:AcquireCity(city, false, true)
			--city:SetOccupied(false) -- needed in this case ?
			coroutine.yield()

		else
			local x, y = city:GetX(), city:GetY()
			if ((x < 24 and y > 32) or (y > 42 and x < 33)) then -- occupied territory
				Dprint("   - " .. city:GetName() .. " in occupied territory at (".. x ..",".. y ..")", bDebug)
				if city:GetOwner() ~= newPlayerID then 
					EscapeUnitsFromPlot(plot)
					coroutine.yield()
					pAxis:AcquireCity(city, false, true)
					coroutine.yield()
					city:SetPuppet(false)
					city:ChangeResistanceTurns(-city:GetResistanceTurns())
				else -- just remove resistance if city was already occupied
					city:ChangeResistanceTurns(-city:GetResistanceTurns())
				end
			elseif (y > 32 and x < 32) then -- Vichy territory
				Dprint("   - " .. city:GetName() .. " in Vichy territory at (".. x ..",".. y ..")", bDebug)
				EscapeUnitsFromPlot(plot)
				coroutine.yield()
				pVichy:AcquireCity(city, false, true)
				coroutine.yield()
				--city:SetOccupied(false)
				city:SetPuppet(false)
				city:SetNumRealBuilding(COURTHOUSE, 1) -- above won't work, try workaround...
				city:ChangeResistanceTurns(-city:GetResistanceTurns())
			elseif (y > 26 and x > 32 and y < 35 and x < 34) then -- Nice, Ajaccio to Italy
				Dprint("   - " .. city:GetName() .. " in Italy occupied territory at (".. x ..",".. y ..")", bDebug)
				if city:GetOwner() ~= iItaly then
					EscapeUnitsFromPlot(plot)
					coroutine.yield()
					pItaly:AcquireCity(city, false, true)
					coroutine.yield()
					city:SetPuppet(false)
					city:ChangeResistanceTurns(-city:GetResistanceTurns())
				end
			elseif (y > 44 and x > 32 and y < 47 and x < 37) then -- Metz, Strasbourg to Germany
				Dprint("   - " .. city:GetName() .. " in Germany occupied territory at (".. x ..",".. y ..")", bDebug)
				if city:GetOwner() ~= iGermany then
					EscapeUnitsFromPlot(plot)
					coroutine.yield()
					pGermany:AcquireCity(city, false, true)
					coroutine.yield()
					city:SetPuppet(false)
					city:ChangeResistanceTurns(-city:GetResistanceTurns())
				end
			end					
		end
	end

and remove it entirely.

and thanks again for testing.
 
And if you have time, in RedMain.lua :

Code:
Events.SerialEventCityCreated.Add(ListenerSerialEventCityCreated)

to

Code:
--Events.SerialEventCityCreated.Add(ListenerSerialEventCityCreated)
 
Allright, it started to work! When i captured Paris, nothing happened for a small second, and then France's land was partitioned between Vichy France and I, unfortunately, it crashed right afterwards.

This is the line it crashed on:

[523224.421] RedMain: Finalizing Fall of France ...


And this was after making both of the edits
 

Attachments

okay, so it could be in those lines if it's not a delayed crash :

Code:
	Dprint("Finalizing Fall of France ...", bDebug)	

	-- remove resistance from Paris
	pParis:ChangeResistanceTurns(-pParis:GetResistanceTurns())

	-- french may try to restart...
	if Game.GetActivePlayer() ~= iFrance then
		Players[Game.GetActivePlayer()]:AddNotification(NotificationTypes.NOTIFICATION_DIPLOMACY_DECLARATION, pFrance:GetName() .. " has fled from Paris with all the gold of France promising to continue the fight from french colonies.", pFrance:GetName() .. " in exil !", -1, -1)
	end
	pFrance:SetGold(pFrance:GetGold() + 5000)

	--savedData.SetValue("FranceHasFallen", 1) -- at the begining of the script to prevent duplicate call now that we use coroutine
				
	Dprint("Fall of France event completed...", bDebug)

3 things to try:

1/ remove
Code:
--pParis:ChangeResistanceTurns(-pParis:GetResistanceTurns())

2/ remove
Code:
	if Game.GetActivePlayer() ~= iFrance then
		Players[Game.GetActivePlayer()]:AddNotification(NotificationTypes.NOTIFICATION_DIPLOMACY_DECLARATION, pFrance:GetName() .. " has fled from Paris with all the gold of France promising to continue the fight from french colonies.", pFrance:GetName() .. " in exil !", -1, -1)
	end

3/ remove
Code:
pFrance:SetGold(pFrance:GetGold() + 5000)

let's hope it's one of those...
 
okay, so it could be in those lines if it's not a delayed crash :

Code:
	Dprint("Finalizing Fall of France ...", bDebug)	

	-- remove resistance from Paris
	pParis:ChangeResistanceTurns(-pParis:GetResistanceTurns())

	-- french may try to restart...
	if Game.GetActivePlayer() ~= iFrance then
		Players[Game.GetActivePlayer()]:AddNotification(NotificationTypes.NOTIFICATION_DIPLOMACY_DECLARATION, pFrance:GetName() .. " has fled from Paris with all the gold of France promising to continue the fight from french colonies.", pFrance:GetName() .. " in exil !", -1, -1)
	end
	pFrance:SetGold(pFrance:GetGold() + 5000)

	--savedData.SetValue("FranceHasFallen", 1) -- at the begining of the script to prevent duplicate call now that we use coroutine
				
	Dprint("Fall of France event completed...", bDebug)

3 things to try:

1/ remove
Code:
--pParis:ChangeResistanceTurns(-pParis:GetResistanceTurns())

2/ remove
Code:
	if Game.GetActivePlayer() ~= iFrance then
		Players[Game.GetActivePlayer()]:AddNotification(NotificationTypes.NOTIFICATION_DIPLOMACY_DECLARATION, pFrance:GetName() .. " has fled from Paris with all the gold of France promising to continue the fight from french colonies.", pFrance:GetName() .. " in exil !", -1, -1)
	end

3/ remove
Code:
pFrance:SetGold(pFrance:GetGold() + 5000)

let's hope it's one of those...

do I have to put the code that I originally deleted back into it? Cuz i don't remember where it went

EDIT: nevermind i reinstalled it
 
On the first one, did you want me to REMOVE the line, or simply type the two dashes infront of it?
 
On the first one, did you want me to REMOVE the line, or simply type the two dashes infront of it?

as you want same effect :)

putting/removing the 2 dashes is easier to restore

for multiple lines of code you can use:

before the first line to be removed
Code:
--[[


after the last line to be removed
Code:
--]]

using an advanced editor like notepad++ help to see which parts are "commented out"
 
Crash on the first one, here is the log. I am undoing it and starting the second one now
 

Attachments

Crash on the second one, here us the log. I am undoing it and starting the third one now.
 

Attachments

Status
Not open for further replies.
Back
Top Bottom