• 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.

Problems with GameOptions and Globals.cpp

Is that constant being used anywhere already?

Not that I know of*. His implementation of the size three cities is different that anyone else's that I know...

See, here's what he changed in the defines.h
Code:
/*************************************************************************************************/
/** JOOYO_ADDON, Added by Jooyo, 06/17/09                                                        */
/**                                                                                              */
/**                                                                                              */
/*************************************************************************************************/
//#define NUM_CITY_PLOTS                                                (21)
#define NUM_CITY_PLOTS_1                                            (9)
#define NUM_CITY_PLOTS_2                                            (21)
#define NUM_CITY_PLOTS                                            (37)
#define CITY_HOME_PLOT                                                (0)
//#define CITY_PLOTS_RADIUS                                            (2)
#define CITY_PLOTS_RADIUS                                            (3)
/*************************************************************************************************/
/** JOOYO_ADDON                          END                                                     */
/*************************************************************************************************/

The only sad news is that he never is on anymore. He left a few months ago.

*I've never seen it, and I've been in most of the C++ files.
 
You should be able to use your IDE (Visual Studio or Code::Blocks) to find all references to the constant. In VS, right-click any symbol (constant, variable, or function)and select Find All References to see a list of all locations in all project files that reference it.
 
You should be able to use your IDE (Visual Studio or Code::Blocks) to find all references to the constant. In VS, right-click any symbol (constant, variable, or function)and select Find All References to see a list of all locations in all project files that reference it.

It's only used 4 times, including my usage. once in CvDefines.h, twice in this function Jooyo added (in CvCity.cpp):
Code:
int CvCity::getNumCityPlots() const
{
    int iRadius;
    int var_city_plots;
    if (getCultureLevel() == -1)
    {
        return NUM_CITY_PLOTS_1;
    }
    iRadius = GC.getCultureLevelInfo(getCultureLevel()).getCityRadius();
    switch (iRadius)
    {
    case 3:
        var_city_plots = NUM_CITY_PLOTS;
        break;
    case 2:
        var_city_plots = NUM_CITY_PLOTS_2;
        break;
    case 1:
        var_city_plots = NUM_CITY_PLOTS_1;
        break;
    default:
        var_city_plots = NUM_CITY_PLOTS_2;
        break;
    }
    return (var_city_plots);
}

And once more where I changed it. Otherwise, it never used again.
 
Jooyo replaced (almost) all of the NUM_CITY_PLOTS calls with that function.

Ah, this is the key. This is what I was getting at above (replace NUM_CITY_PLOTS constant with a variable), only slightly more flexible. This is where you would put the check for the game option if you went that route.
 
Ah, this is the key. This is what I was getting at above (replace NUM_CITY_PLOTS constant with a variable), only slightly more flexible. This is where you would put the check for the game option if you went that route.

That's okay. With that fix above, I my need for a game option has disappeared, since the city size is set in the XML. Thanks for the help.
 
Kael used the same approach, changing most calls for NUM_CITY_PLOTS to call a function like this. Then in Fall Further we figured out an easy formula to handle any city radius automatically instead of using all the defines.

int iNumPlots = (2*iRadius*iRadius) + (6*iRadius) + 1;
 
Kael used the same approach, changing most calls for NUM_CITY_PLOTS to call a function like this. Then in Fall Further we figured out an easy formula to handle any city radius automatically instead of using all the defines.

int iNumPlots = (2*iRadius*iRadius) + (6*iRadius) + 1;

Interesting. I'll have to grab those sources and take a look at that.
 
Back
Top Bottom