Limit to # of Bonuses in TGA GameFont & SDK

if you use a debug dll, you can put a breakpoint into the loop and then mouseover the variable to display the current value. Else you could log it into a textfile.

The value you need is iCurSymbolID the first time the loop is run.

Okay, I know about that, maybe I'm just dense, but that doesn't tell me much.

First off, WHY does the extra bonuses cause issues?

HOW did you fix it? How did you know that it was turning into garbage at that point?
 
Valkrionn, since you basically use the same tga file, 8825 should work for you too. But if you one day add a whole new line to the tga file you probably need to change the number.

@Afforess

The function has been written to load the BTS tga file, not the WoC one. What exactly goes wrong, I don't care at the moment. I am happy I could track down the problem and "fix" it. This is the modification I am using.
Code:
void CvGameTextMgr::assignFontIds(int iFirstSymbolCode, int iPadAmount)
{
	int iCurSymbolID = iFirstSymbolCode;

	// set yield symbols
	for (int i = 0; i < NUM_YIELD_TYPES; i++)
	{
		GC.getYieldInfo((YieldTypes) i).setChar(iCurSymbolID);
		++iCurSymbolID;
	}

	do
	{
		++iCurSymbolID;
	} while (iCurSymbolID % iPadAmount != 0);

	// set commerce symbols
	for (i=0;i<GC.getNUM_COMMERCE_TYPES();i++)
	{
		GC.getCommerceInfo((CommerceTypes) i).setChar(iCurSymbolID);
		++iCurSymbolID;
	}

	do
	{
		++iCurSymbolID;
	} while (iCurSymbolID % iPadAmount != 0);

	if (NUM_COMMERCE_TYPES < iPadAmount)
	{
		do
		{
			++iCurSymbolID;
		} while (iCurSymbolID % iPadAmount != 0);
	}

	for (int i = 0; i < GC.getNumReligionInfos(); i++)
	{
		GC.getReligionInfo((ReligionTypes) i).setChar(iCurSymbolID);
		++iCurSymbolID;
		GC.getReligionInfo((ReligionTypes) i).setHolyCityChar(iCurSymbolID);
		++iCurSymbolID;
	}
	for (i = 0; i < GC.getNumCorporationInfos(); i++)
	{
		GC.getCorporationInfo((CorporationTypes) i).setChar(iCurSymbolID);
		++iCurSymbolID;
		GC.getCorporationInfo((CorporationTypes) i).setHeadquarterChar(iCurSymbolID);
		++iCurSymbolID;
	}

	do
	{
		++iCurSymbolID;
	} while (iCurSymbolID % iPadAmount != 0);

	if (2 * (GC.getNumReligionInfos() + GC.getNumCorporationInfos()) < iPadAmount)
	{
		do
		{
			++iCurSymbolID;
		} while (iCurSymbolID % iPadAmount != 0);
	}

	// set bonus symbols
	int bonusBaseID = iCurSymbolID;
	++iCurSymbolID;
	for (int i = 0; i < GC.getNumBonusInfos(); i++)
	{
		int bonusID = bonusBaseID + GC.getBonusInfo((BonusTypes) i).getArtInfo()->getFontButtonIndex();
		GC.getBonusInfo((BonusTypes) i).setChar(bonusID);
		++iCurSymbolID;
	}

	do
	{
		++iCurSymbolID;
	} while (iCurSymbolID % iPadAmount != 0);

	if(GC.getNumBonusInfos() < iPadAmount)
	{
		do
		{
			++iCurSymbolID;
		} while (iCurSymbolID % iPadAmount != 0);
	}

	if(GC.getNumBonusInfos() < 2 * iPadAmount)
	{
		do
		{
			++iCurSymbolID;
		} while (iCurSymbolID % iPadAmount != 0);
	}

// TEMPFIX Sephi
	iCurSymbolID=8825;
// TEMPFIX Sephi

	// set extra symbols
	for (int i=0; i < MAX_NUM_SYMBOLS; i++)
	{
		gDLL->setSymbolID(i, iCurSymbolID);
		++iCurSymbolID;
	}
}
 
Valkrionn, since you basically use the same tga file, 8825 should work for you too. But if you one day add a whole new line to the tga file you probably need to change the number.

@Afforess

The function has been written to load the BTS tga file, not the WoC one. What exactly goes wrong, I don't care at the moment. I am happy I could track down the problem and "fix" it. This is the modification I am using.
Code:
void CvGameTextMgr::assignFontIds(int iFirstSymbolCode, int iPadAmount)
{
    int iCurSymbolID = iFirstSymbolCode;

    // set yield symbols
    for (int i = 0; i < NUM_YIELD_TYPES; i++)
    {
        GC.getYieldInfo((YieldTypes) i).setChar(iCurSymbolID);
        ++iCurSymbolID;
    }

    do
    {
        ++iCurSymbolID;
    } while (iCurSymbolID % iPadAmount != 0);

    // set commerce symbols
    for (i=0;i<GC.getNUM_COMMERCE_TYPES();i++)
    {
        GC.getCommerceInfo((CommerceTypes) i).setChar(iCurSymbolID);
        ++iCurSymbolID;
    }

    do
    {
        ++iCurSymbolID;
    } while (iCurSymbolID % iPadAmount != 0);

    if (NUM_COMMERCE_TYPES < iPadAmount)
    {
        do
        {
            ++iCurSymbolID;
        } while (iCurSymbolID % iPadAmount != 0);
    }

    for (int i = 0; i < GC.getNumReligionInfos(); i++)
    {
        GC.getReligionInfo((ReligionTypes) i).setChar(iCurSymbolID);
        ++iCurSymbolID;
        GC.getReligionInfo((ReligionTypes) i).setHolyCityChar(iCurSymbolID);
        ++iCurSymbolID;
    }
    for (i = 0; i < GC.getNumCorporationInfos(); i++)
    {
        GC.getCorporationInfo((CorporationTypes) i).setChar(iCurSymbolID);
        ++iCurSymbolID;
        GC.getCorporationInfo((CorporationTypes) i).setHeadquarterChar(iCurSymbolID);
        ++iCurSymbolID;
    }

    do
    {
        ++iCurSymbolID;
    } while (iCurSymbolID % iPadAmount != 0);

    if (2 * (GC.getNumReligionInfos() + GC.getNumCorporationInfos()) < iPadAmount)
    {
        do
        {
            ++iCurSymbolID;
        } while (iCurSymbolID % iPadAmount != 0);
    }

    // set bonus symbols
    int bonusBaseID = iCurSymbolID;
    ++iCurSymbolID;
    for (int i = 0; i < GC.getNumBonusInfos(); i++)
    {
        int bonusID = bonusBaseID + GC.getBonusInfo((BonusTypes) i).getArtInfo()->getFontButtonIndex();
        GC.getBonusInfo((BonusTypes) i).setChar(bonusID);
        ++iCurSymbolID;
    }

    do
    {
        ++iCurSymbolID;
    } while (iCurSymbolID % iPadAmount != 0);

    if(GC.getNumBonusInfos() < iPadAmount)
    {
        do
        {
            ++iCurSymbolID;
        } while (iCurSymbolID % iPadAmount != 0);
    }

    if(GC.getNumBonusInfos() < 2 * iPadAmount)
    {
        do
        {
            ++iCurSymbolID;
        } while (iCurSymbolID % iPadAmount != 0);
    }

// TEMPFIX Sephi
    iCurSymbolID=8825;
// TEMPFIX Sephi

    // set extra symbols
    for (int i=0; i < MAX_NUM_SYMBOLS; i++)
    {
        gDLL->setSymbolID(i, iCurSymbolID);
        ++iCurSymbolID;
    }
}

I found the function fine, but your fix didn't work (It just messed the icons up). I guess my real my question is what is significant about the # 8825? AFAIK, the Gamefont's RoM and FFH2 uses are nearly identical in size, but just has different icons in different places.

See for yourself:
View attachment Fonts.rar
 
Every Icon in the tga file has a position. It is iFirstSymbolCode + number of icons before in the tga. Maybe another fancy value added in, the code to actually use the number is in the exe.

And the RoM tga has a lot more icons before the first symbol, so you definetly need a different number. just put a breakpoint into the
// set extra symbols
loop when the game reads the fonts correctly (that means not too many bonuses in the game) and you will get your needed number.
 
Every Icon in the tga file has a position. It is iFirstSymbolCode + number of icons before in the tga. Maybe another fancy value added in, the code to actually use the number is in the exe.

And the RoM tga has a lot more icons before the first symbol, so you definetly need a different number. just put a breakpoint into the
// set extra symbols
loop when the game reads the fonts correctly (that means not too many bonuses in the game) and you will get your needed number.

I did finally figure out the number for RoM's gamefont's. (9200, if you're curious). I was just being thick-headed. As soon as I re-read your instructions, I realized what to do.

A question though, if I add a new resource to my gamefont, am I going to have to adjust this number? Or should it be good indefinitely?
 
From what Sephi has said, you're good until you add an entirely new line to the fonts file; Somehow, I doubt that will be necessary any time soon. ;)

Whew, got that worry over. RoM's game font for resources just started a new line, so we should be good for 80 or so more resources.
 
you only need to modify the number if you change the size of the tga file, and only if you add new boxes above the Bonuses.
 
I walked through the AssignFontID's function and figured out (What I think) is going wrong. The WOC GameFont loads the Extra Symbols (Movement, Trade Chars...etc..) BEFORE the resources, where the BTS Gamefont loads the Extra Symbols AFTER. So, using that, I came up with a real "fix". It seems to work for me, but I would love to see if it really works for everyone.

Sephi, could you replace your tempfix line with this:
Code:
	iCurSymbolID -= MAX_NUM_SYMBOLS;
	if (MAX_NUM_SYMBOLS > iPadAmount)
	{
		do 
		{
			++iCurSymbolID;
		} while (iCurSymbolID % iPadAmount != 0);
	}

And tell me if your symbols still work okay.


Also, with this fix and the harcoding, I've still had an issue where the icons on the city bar are corrupted. They are off by 5 symbols, so the defense icon shows the Golden Age icon, etc... Anyone else have this? I have other places where the Defense Icon shows up fine, so I'm confused.
 
Does this directly replace Sephi's code? As in, same location? Because I got a crash when trying to use it....

It goes right overtop his Sephi's code. For comparison:

Code:
...
    if(GC.getNumBonusInfos() < iPadAmount)
    {
        do 
        {
            ++iCurSymbolID;
        } while (iCurSymbolID % iPadAmount != 0);
    }
    if(GC.getNumBonusInfos() < 2 * iPadAmount)
    {
        do 
        {
            ++iCurSymbolID;
        } while (iCurSymbolID % iPadAmount != 0);
    }

//The order for symbols was changed in WoC. In normal BTS, Extra Symbols are loaded last, but in WoC, they are
//loaded right before resources. So we need to go back and load them. Order matters to the exe, which is why I can't
//re-order the way the exe loads the symbols.
    iCurSymbolID -= MAX_NUM_SYMBOLS;
    if (MAX_NUM_SYMBOLS > iPadAmount)
    {
        do 
        {
            ++iCurSymbolID;
        } while (iCurSymbolID % iPadAmount != 0);
    }

    for (int i=0; i < MAX_NUM_SYMBOLS; i++)
    {
        gDLL->setSymbolID(i, iCurSymbolID);
        ++iCurSymbolID;
    }
}

It shouldn't crash, I can't think of a reason it would...
 
Also, with this fix and the harcoding, I've still had an issue where the icons on the city bar are corrupted. They are off by 5 symbols, so the defense icon shows the Golden Age icon, etc... Anyone else have this? I have other places where the Defense Icon shows up fine, so I'm confused.

yeah, I know this. I had the exact same problem when I added some corporations but forgot to gave them correct values for the tga index (or whatever the WoC tag is called).
 
yeah, I know this. I had the exact same problem when I added some corporations but forgot to gave them correct values for the tga index (or whatever the WoC tag is called).

Hmm. That's not my issue. I just don't understand why calls to getSymbolId are returning different values for different functions, despite exactly the same parameters.

As for my earlier post, does my fix work for you guys, or is it just crashing?
 
After testing my last code proposal, I found the flaws. I think this one should work, but I'm not 100% positive. It works for me when I go back below RoM's resource limit, and still works after I go above it. I'd appreciate it if someone could test it, it should just replace Sephi's fix.
Code:
	iCurSymbolID -= MAX_NUM_SYMBOLS;
	if(GC.getNumBonusInfos() < 3 * iPadAmount)
	{
		do 
		{
			++iCurSymbolID;
		} while (iCurSymbolID % iPadAmount != 0);
	}
	do 
	{
		++iCurSymbolID;
	} while (iCurSymbolID % iPadAmount != 0);
 
that doesn't work always. The Position of the Extra Symbols has nothing to do with GC.getNumBonusInfos() as Bonuses are listed later in the tga file.

You should be able to use this one. 125 is hardcoded in WoC loading at other places.

Code:
// modified Sephi
// Symbol loading adjusted to WoC.
	int iSavePosition=iCurSymbolID;

	// set bonus symbols
	int bonusBaseID = iCurSymbolID;
	++iCurSymbolID;
	for (int i = 0; i < GC.getNumBonusInfos(); i++)
	{
		int bonusID = bonusBaseID + GC.getBonusInfo((BonusTypes) i).getArtInfo()->getFontButtonIndex();
		GC.getBonusInfo((BonusTypes) i).setChar(bonusID);
		++iCurSymbolID;
	}

	iCurSymbolID=iSavePosition+125;
	iCurSymbolID-=MAX_NUM_SYMBOLS;
	do
	{
		--iCurSymbolID;
	} while (iCurSymbolID % iPadAmount != 0);

// modified Sephi

	// set extra symbols
	for (int i=0; i < MAX_NUM_SYMBOLS; i++)
	{
		gDLL->setSymbolID(i, iCurSymbolID);
		++iCurSymbolID;
	}
 
Hmm. That's not my issue. I just don't understand why calls to getSymbolId are returning different values for different functions, despite exactly the same parameters.
getSymbolId returns an int, not a symbol. There are different functions which use this int value.
 
Top Bottom