Additional coder brainpower needed (pagin Xienwolf, Snarko, etc)

Kael

Deity
Joined
May 6, 2002
Messages
17,401
Location
Ohio
Not an emergency but I've been troubleshooting some odd CtD's on 0.40. I dont know if they existed in 0.34 or not.

The first was the CtD when map trading. I made the following change to CvDeal::StartTrade to keep the crashes from happening:

Code:
	case TRADE_MAPS:

//FfH: Added by Kael 12/21/2008 (prevents a CtD when map trading)
        GC.getMapINLINE().updateVisibility();
//FfH: End Add

		for (iI = 0; iI < GC.getMapINLINE().numPlotsINLINE(); iI++)
		{
			pLoopPlot = GC.getMapINLINE().plotByIndexINLINE(iI);

			if (pLoopPlot->isRevealed(GET_PLAYER(eFromPlayer).getTeam(), false))
			{
				pLoopPlot->setRevealed(GET_PLAYER(eToPlayer).getTeam(), true, false, GET_PLAYER(eFromPlayer).getTeam(), false);
			}
		}

		for (iI = 0; iI < MAX_PLAYERS; iI++)
		{
			if (GET_PLAYER((PlayerTypes)iI).isAlive())
			{
				if (GET_PLAYER((PlayerTypes)iI).getTeam() == GET_PLAYER(eToPlayer).getTeam())
				{
					GET_PLAYER((PlayerTypes)iI).updatePlotGroups();
				}
			}
		}
		break;

I hit upon this solution when I noticed that the CtD never happened if I went into the worldbuilder and exited (took me forever to track that one down). I went through everything going into and out of the worldbuilder did and finally came up with the GC.getMapINLINE().updateVisibility() as what kept the crash from happening.

Doesn't make much sense to me, and I have no idea what would have changed. But at the time I just left it in and went on.

Then today Im checking out another CtD when a unit moves (a ship with the sentry promotion). Again going into worldbuilder keeps the crash from happening. So I insert the following in CvPlot::changeVisibilityCount:

Code:
        updateVisibility();

This jusr updates the visibility for that effected plot (changeVisibilityCount happens on all plots around a moving unit). The Map version of the function I pointed to above just runs this exact function on every plot on the map. This is what updateVisibility does:

Code:
void CvPlot::updateVisibility()
{
	PROFILE("CvPlot::updateVisibility");

	if (!GC.IsGraphicsInitialized())
	{
		return;
	}

	setLayoutDirty(true);

	updateSymbolVisibility();
	updateFeatureSymbolVisibility();
	updateRouteSymbol();

	CvCity* pCity = getPlotCity();
	if (pCity != NULL)
	{
		pCity->updateVisibility();
	}
}

It doesnt make any sense to me, and I wonder if their are more issues it is causing. So I thought I would see if you guys have any ideas. Let me know if you guys can think of anything.
 
If you check resmgr.log before and after the crash you'll notice it's trying to open a file called Art/Structures/Cities/an_meso.nif and failing. I copied an_bannor.nif file in that directory and renamed it an_meso.nif and everything worked.

Question in my mind isn't why it's crashing (trying to access an invalid file), but why it doesn't crash your way...

*edit*
I did this with the crash that was posted in the bug thread when moving a ship.
 
If you check resmgr.log before and after the crash you'll notice it's trying to open a file called Art/Structures/Cities/an_meso.nif and failing. I copied an_bannor.nif file in that directory and renamed it an_meso.nif and everything worked.

Question in my mind isn't why it's crashing (trying to access an invalid file), but why it doesn't crash your way...

*edit*
I did this with the crash that was posted in the bug thread when moving a ship.

Ahh, thats a great insight. I cleaned up all the references to an_meso.nif in the xml files and the crashes are avoided too. No idea why the visibilityupdate fixes the problem but at least now I understand why it was crashing. Im going to back out my work around. Thanks! Thats the real fix I was looking for.
 
Top Bottom