Need help with strange bug

deanej

Deity
Joined
Apr 8, 2006
Messages
4,859
Location
New York State
I recently converted my Star Trek mod to use Final Frontier Plus as a base and I have a strange bug. A few turns in to the game, I get messages saying a bunch of civs have been killed. However, those civs were never even on the map. In fact, I'm pretty sure it consists of EVERY civ that isn't on the map. I'm not sure what could possibly cause this to happen.

You can download 4.0 here; it does require Star Trek installed, but if you rename the "Star Trek 400" folder (and the ini) to just "Star Trek" you can get away with installing just the .fpk files in the Assets folder (note that this will give you errors with the music, but it should otherwise function normally).
 
It's never on the same turn (not always in the game, either), but when it happens it's always between 5 and 15 turns (possibly between 5 and 10, I didn't keep track of the ones that happened just after I did the conversion).

Could it be in any way related to the isVictory python callback? It was changed in Final Frontier Plus as cities start pre-founded, so there shouldn't be a need for the 10 turn delay that Firaxis put in.
 
You have the Inhabited Planets goodies on, correct? Do you have the "spawn new civ" one set up?

The only thing I can possibly think of it is related to the untested code I have to spawn new civs for that goody. That goody in Final Frontier Plus is disabled. If you have it enabled, try disabling it (removing it from CIV4HandicapInfos.xml).
 
Oh, I know what it is. I'm not breaking after I find a civ to create. So I suspect what's happening is every single civilization-leader combo that can be created is being created, destroying the previous civilization....

Here's the code in the DLL, at the bottom of CvPlayer::receiveGoody():

Code:
	if (GC.getGoodyInfo(eGoody).isNewCiv())
	{
		int iNumTries = 50;		//(There aren't 50 civs in the game, so this should be plenty.
		for (int i = 0; i < iNumTries; ++i)
		{
			CivilizationTypes eCiv = (CivilizationTypes)GC.getGame().getSorenRandNum(GC.getNumCivilizationInfos()-1, "Goodies!");
			if (eCiv != (CivilizationTypes)GC.getDefineINT("BARBARIAN_PLAYER"))
			{
				if (GC.getCivilizationInfo(eCiv).isAlien())
				{
					if (goodyCanSpawnCiv(eCiv))
					{
						PlayerTypes eSlot;
						for (int iPlayer = 0; iPlayer < GC.getMAX_PLAYERS(); ++iPlayer)
						{
							PlayerTypes ePlayer = (PlayerTypes)iPlayer;
							if (ePlayer != NO_PLAYER)
							{
								if (!(GET_PLAYER(ePlayer).isEverAlive()))
								{
									eSlot = ePlayer;
								}
							}
						}
						LeaderHeadTypes eLeader = (LeaderHeadTypes)goodyGetLeaderForCiv(eCiv);
						GC.getGame().addPlayer(eSlot, eLeader, eCiv);
						[COLOR="Red"]break;[/COLOR]
					}
				}
			}
		}
	}

If you add the break statement in red it should be fixed.
 
Did that; I still get the message that one civ has been destroyed when that goody triggers; I think the ship on the solar system kills the civ.

I can't seem to fix the Xindi UW bug. It's not adding the population to newly colonized systems, even though I have this code at the bottom of onCityBuilt before the AI city update:
Code:
		#Xindi Council
		iBath = gc.getInfoTypeForString("BUILDING_XC")
		if (pPlayer.getBuildingClassCount(iBath) > 0):
                        pCity.changePopulation(1)
 
I was digging around in some old python mods and I found this:

http://forums.civfanatics.com/downloads.php?do=file&id=12917

And I wonder if this could be something of what is going on. I looked in the .py and it declares that it "kills" off a bunch of civilizations so that it can later create new ones. Maybe there is something similar in your mod?
 
I believe I tried killing the unit, either in the DLL or in onGoodyReceived in the Python, and I'm pretty sure that caused a crash.

The only thing I can think of is to try moving the unit off of the tile before creating the city. Or maybe not create the city until after the unit moves off of the tile? I don't know.

I don't know why the Xindi thing isn't working, but I know what I'd do is first make sure the check for the Xindi Council is working (something like print "Got here!").

I was digging around in some old python mods and I found this:

http://forums.civfanatics.com/downloads.php?do=file&id=12917

And I wonder if this could be something of what is going on. I looked in the .py and it declares that it "kills" off a bunch of civilizations so that it can later create new ones. Maybe there is something similar in your mod?

No, I don't think so (I did not use Revolutions as a base for this part of the mod). The first problem has been dealt with, and I'm pretty sure deanej is right that the ship on the tile is killing the civ when it spawns.
 
I figured out the Xindi Council bug: it was a building/buildingclass mixup (which means that the bug existed since 3.0 but I could have sworn I tested the UWs).

I think I'll have the goody event move the unit to the left (it's easiest to compensate for the map that way) and make the Borg changes then re-release 4.0; at the very least, the Borg stuff will probably need balancing.

EDIT: This doesn't fix the problem because the unit doesn't say put once moved. I have this code put in right at the start of the new civ goody code:
Code:
		int iX = 0;
		int iY = pPlot->getY();

		if((pPlot->getX() - 1) < 0)
			iX = pPlot->getX() + 1;
		else
			iX = pPlot->getX() - 1;

		CvPlot* pNewPlot = GC.getMap().plot(iX,iY);
		pUnit->MoveTo(pNewPlot);
But the unit doesn't stay on the new plot - it immediately moves to the plot the goody was on, killing the new civ.
 
Top Bottom