• Our friends from AlphaCentauri2.info are in need of technical assistance. If you have experience with the LAMP stack and some hours to spare, please help them out and post here.

CvGameTextMgr, BUG, and WorldBuilder Issues...

Afforess

The White Wizard
Joined
Jul 31, 2007
Messages
12,239
Location
Austin, Texas
I just finished added a boolean function in CvBuildingInfos that checks to see if the city is on a peak or not (Useful for Ski Resort Buildings, and such...). It works fine. (I can code things by myself. :))

However, I added this section to CvGameTextMgr to alert players that the building needs to be on a peak. The problem is that it gives a python exception and the worldbuilder UI is broken. I tested it again without the CvGameTextMgr code, and the problems went away...

Here's my code:

Code:
    if (kBuilding.isBuildOnlyOnPeaks())
    {
        if (!(pPlot->isPeak()) || pPlot == NULL)
        {
        szBuffer.append(NEWLINE);
        szBuffer.append(gDLL->getText("TXT_KEY_BUILDING_REQUIRES_MOUNTAIN_RED"));
        }
        else // else is here to catch errors, or rare cases...
        {
        szBuffer.append(NEWLINE);
        szBuffer.append(gDLL->getText("TXT_KEY_BUILDING_REQUIRES_MOUNTAIN"));
        }
    }

It compiles fine. I want to show red text when the requirement is not met, regular grey text when it is.
 
It helps to have the Python exception that you are seeing. Plus post a few lines of context around the failing line of code with that line bolded or in red or something.

If pPlot is NULL then the if() test will get a null pointer exception. Always check the pointer for NULL before using it with ->.

Code:
if (!pPlot || !pPlot->isPeak())

Also, the comment after the "else" is incorrect. The else block is for when the plot is a peak--not an error condition.

Does this extra text show up correctly in the Civilopedia or when hovering over the building action button in the bottom-center of the screen?
 
It helps to have the Python exception that you are seeing. Plus post a few lines of context around the failing line of code with that line bolded or in red or something.

If pPlot is NULL then the if() test will get a null pointer exception. Always check the pointer for NULL before using it with ->.

Code:
if (!pPlot || !pPlot->isPeak())
Also, the comment after the "else" is incorrect. The else block is for when the plot is a peak--not an error condition.

Thanks, I knew it was because of the NULL issue, I just wasn't sure why I was catching it.

Problem Solved. Everything works correctly.
 
Back
Top Bottom