1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Single Player bugs and crashes v38 plus (SVN) - After the 20th of February 2018

Discussion in 'Bugs and Crashes' started by Dancing Hoskuld, Feb 24, 2018.

  1. raxo2222

    raxo2222 Warlord

    Joined:
    Jun 10, 2011
    Messages:
    5,181
    Location:
    Poland
    It looks like it was fix for NPC civs, as they could have problems with one tile start.
    Code:
    bool bFound = false;
        if (GC.getGameINLINE().isOption(GAMEOPTION_PERSONALIZED_MAP) && GET_PLAYER(getOwnerINLINE()).isModderOption(MODDEROPTION_USE_LANDMARK_NAMES))
        {
            for (int iI = 0; iI < NUM_CITY_PLOTS_2; iI++)
            {
                CvPlot* pLoopPlot = getCityIndexPlot(iI);
                if (!pLoopPlot->getLandmarkName().empty() && pLoopPlot->getLandmarkType() != NO_LANDMARK)
                {
                    setName(pLoopPlot->getLandmarkName());
                    if (!getName().empty())
                    {
                        bFound = true;
                        break;
                    }
                }
            }
        }
        if (!bFound)
    /************************************************************************************************/
    /* Afforess                         END                                                            */
    /************************************************************************************************/
    ------------------------------------------------------------------------------------------------------------------
        setName(GET_PLAYER(getOwnerINLINE()).getNewCityName());
    
        setEverOwned(getOwnerINLINE(), true);
    
        pPlot->setImprovementType(NO_IMPROVEMENT);
        pPlot->setOwner(getOwnerINLINE(), bBumpUnits, false);
        pPlot->setPlotCity(this);
    
        updateCultureLevel(false);
    ----------------------------------------------------------------------------------------------------------
    Should be this ^ in {} brackets at least for multiline entry?
    
        if (pPlot->getCulture(getOwnerINLINE()) < GC.getDefineINT("FREE_CITY_CULTURE"))
        {
            pPlot->setCulture(getOwnerINLINE(), GC.getDefineINT("FREE_CITY_CULTURE"), bBumpUnits, false);
        }
    
        for (iI = 0; iI < NUM_DIRECTION_TYPES; iI++)
        {
            pAdjacentPlot = plotDirection(getX_INLINE(), getY_INLINE(), ((DirectionTypes)iI));
    
            if (pAdjacentPlot != NULL)
            {
                if (pAdjacentPlot->getCulture(getOwnerINLINE()) < GC.getDefineINT("FREE_CITY_ADJACENT_CULTURE"))
                {
                    pAdjacentPlot->setCulture(getOwnerINLINE(), GC.getDefineINT("FREE_CITY_ADJACENT_CULTURE"), bBumpUnits, false);
                }
                pAdjacentPlot->updateCulture(bBumpUnits, false);
            }
        }
    This thing starts on 319th line in CvCity.cpp
     
    Last edited: Dec 14, 2018
  2. Usul13

    Usul13 Chieftain

    Joined:
    Jan 15, 2016
    Messages:
    147
    It's actually

    if (A) B=A;

    After the if statement there can be any number of whitespace characters. The new line is just a whitespace character like a space or a tab for example. Also the rounded brackets are mandatory.
     
    Toffer90 likes this.
  3. Toffer90

    Toffer90 C2C Modder

    Joined:
    Oct 16, 2011
    Messages:
    5,473
    Location:
    Norway
    That's the code that made me think it had something to do with the issue. And how is it meant to help the NPC, the free culture is added to all plots surrounding a city when its founded regardless of what team that owns the city.
     
  4. raxo2222

    raxo2222 Warlord

    Joined:
    Jun 10, 2011
    Messages:
    5,181
    Location:
    Poland
    I was guessing before I looked into code - probably that was meant to be added and it never was added.
     
  5. JosEPh_II

    JosEPh_II TBS WarLord

    Joined:
    Jun 20, 2007
    Messages:
    15,148
    Gender:
    Male
    Location:
    Western IL. cornfields
    Yeah I just got done verifying that.
    I will do so.
     
  6. JosEPh_II

    JosEPh_II TBS WarLord

    Joined:
    Jun 20, 2007
    Messages:
    15,148
    Gender:
    Male
    Location:
    Western IL. cornfields
    Is this a recent change?
     
  7. Thunderbrd

    Thunderbrd C2C War Dog

    Joined:
    Jan 2, 2010
    Messages:
    25,226
    Gender:
    Male
    Location:
    Las Vegas
    I suppose conquered cities on RCS and Fixed Borders would probably work a bit differently for One Tile City start as well based on what I saw. Again, if you turn off fixed borders in that case you'd probably see things work as you'd think they should. Though I wasn't researching anything about One Tile City Start when I was looking into this either.
    4-5 are unavailable if 3 is unavailable. I suppose the pedia doesn't understand this naturaly inherited rule huh? That might be something to look into.
    Don't really know how to do that. Missions are tremendously complex and I've never been able to decipher the code that's allowing this for some of them. As for hotkeys, I THINK there's a way to define a hotkey in the XML but I don't have a map of what hotkeys are what so I don't ever add any in case there's some conflict.

    I know. It's a longshot. But if something is strange afoot, I was mostly trying to come up with a theory as to how because it wouldn't be in what you had there.

    There's always a chance I'm wrong about what I'm reading in the code as I only did read so far into it but from what I gathered in only a few hours of research was what I explained. Some verification of this would be cool if you find it does behave differently as suspected.

    It's saying in natural speak: if the variable bFound is defined as false then consider everything in the brackets that follow. The () is the variable insertion of the if being evaluated. ! means 'not'. So if is not bFound. Or, if bFound is false. If there are no brackets then only the first next line is assumed to be the statement under the if switch, thus setName(GET_PLAYER(getOwnerINLINE()).getNewCityName()); is all that's under that if statement.

    It looks like the whole thing is designed to interrupt the normal automatic naming of the city since in the red portion it names the city after the landmark instead.

    I don't personally like this form of expression - much prefer it always adhere to using the brackets, even if you don't have to, just to be very clear about it.

    Ok, Usul already answered you - so why he's not helping us with bugs in the code I'm not sure... ;)
     
  8. JosEPh_II

    JosEPh_II TBS WarLord

    Joined:
    Jun 20, 2007
    Messages:
    15,148
    Gender:
    Male
    Location:
    Western IL. cornfields
    That did the trick. The cities sre now founding properly with only 1 tile.

    EDIT: Same game as before too, with cache cleared and GlobalDefine setting changed. Settings screenshot added with pertinent Options shown.
     

    Attached Files:

    Last edited: Dec 14, 2018
    KaTiON_PT and raxo2222 like this.
  9. Usul13

    Usul13 Chieftain

    Joined:
    Jan 15, 2016
    Messages:
    147
    I'll test it and I'll get back to you.


    Actually I'm already thinking about it, but first I'll have to learn some things about this Civ IV modding business. And I never did any serious coding I just dabble. I think the most serious piece of program I ever wrote was a Barnes-Hut simulation under Unity.

    Also my attention span can be relatively short which is not a good thing in a big project like this. I can get bored with things after a couple of weeks or something else can grab my attention so I can't make any promises. We'll see.
     
  10. JosEPh_II

    JosEPh_II TBS WarLord

    Joined:
    Jun 20, 2007
    Messages:
    15,148
    Gender:
    Male
    Location:
    Western IL. cornfields
    Questions: All players that want to use the I City Tile Start Option must now change the GlobalDefine for the line FREE_CITY_ADJACENT_CULTURE from the setting of 1 to "0" correct?
    Players that use this Option should also expect for the Barb cities to stay at 1 Tile as well?
    Will the NPC player Neanderthal also have it's Cities stay at 1 city tile if the Option Neanderthal Cities is On or Off?
     
  11. Thunderbrd

    Thunderbrd C2C War Dog

    Joined:
    Jan 2, 2010
    Messages:
    25,226
    Gender:
    Male
    Location:
    Las Vegas
    I don't think it's necessarily a bad thing to change it for all games but I'd test that to make sure it doesn't make the same effect if it's not on 1CTS.

    Have we still not given them some means to pump some culture simply for being barbarians?

    I would think it's fine for both to operate the same way. I'd expect them to start with 1 tile just like any other city but as neanders and barbs they should be getting some bonus culture, even just a little.
     
  12. Toffer90

    Toffer90 C2C Modder

    Joined:
    Oct 16, 2011
    Messages:
    5,473
    Location:
    Norway
    Not at all, the global define and its dll code was identical in vanilla.
    We have.
    They do.
    It would have to be tested a bit to ensure we don't introduce any glitches, there may very well be a good technical reason for why vanilla Civ added that free culture around a city when it's founded.

    Other than any technical reasons, I think the original intention was that if you settle a city at the edge of another nations border there would be a better chance of getting ownership of the other nations land that was adjacent to the newly founded city.

    I don't really like this, why should the colonizer be favoured over those who have owned the land for possibly much longer? I say, if you want to grab anothers land you must fight for it or out-culture your neighbours in the long run.

    I'm thinking we should just remove this vanilla code completly:
    Code:
        if (pPlot->getCulture(getOwnerINLINE()) < GC.getDefineINT("FREE_CITY_CULTURE"))
        {
            pPlot->setCulture(getOwnerINLINE(), GC.getDefineINT("FREE_CITY_CULTURE"), bBumpUnits, false);
        }
    
        for (iI = 0; iI < NUM_DIRECTION_TYPES; iI++)
        {
            pAdjacentPlot = plotDirection(getX_INLINE(), getY_INLINE(), ((DirectionTypes)iI));
    
            if (pAdjacentPlot != NULL)
            {
                if (pAdjacentPlot->getCulture(getOwnerINLINE()) < GC.getDefineINT("FREE_CITY_ADJACENT_CULTURE"))
                {
                    pAdjacentPlot->setCulture(getOwnerINLINE(), GC.getDefineINT("FREE_CITY_ADJACENT_CULTURE"), bBumpUnits, false);
                }
                pAdjacentPlot->updateCulture(bBumpUnits, false);
            }
        }
    If it doesn't cause any bugs that is.

    Before that code there is this line: updateCultureLevel(false);
    I'm pretty sure that handles all the culture related stuff when a city is founded.
     
    Last edited: Dec 14, 2018
    KaTiON_PT likes this.
  13. Thunderbrd

    Thunderbrd C2C War Dog

    Joined:
    Jan 2, 2010
    Messages:
    25,226
    Gender:
    Male
    Location:
    Las Vegas
    I don't think it is designed to boot another civ from those tiles so much as it is to establish a minimum amount of claiming culture there on founding. The first segment appears to be for the plot where the city is founded. It might be best, actually, if I go in and make the Free City Adjacent Culture call here depend on whether the 1CTS option is on or not rather than working with any global define that isn't really necessary given how unlikely it is to need further definition than 0 or 1. I suspect new cities without 1CTS may be founding without their first rung of tiles - at least for one round - if this global is turned to 0.
     
  14. makotech222

    makotech222 Chieftain

    Joined:
    Mar 18, 2012
    Messages:
    222
    @Thunderbrd Sorry I've been away for a while, just noticed my tags. It looks like you got everything working again? Would probably be good to document what you did in case anyone else has similar issues?
     
  15. Thunderbrd

    Thunderbrd C2C War Dog

    Joined:
    Jan 2, 2010
    Messages:
    25,226
    Gender:
    Male
    Location:
    Las Vegas
    There have been a few things - some help files I found helped me sort out some other stuff too. But I'm still having some annoying errors with it that I haven't been able to get rid of. I figured I should write a guide on this yes and should do it soon if I can remember the steps.
     
  16. Toffer90

    Toffer90 C2C Modder

    Joined:
    Oct 16, 2011
    Messages:
    5,473
    Location:
    Norway
    We could just add a gameoption switch there as you say, but...

    I did an in game test without the 1CTS option after setting both those global defines to zero.
    FREE_CITY_CULTURE = 0
    FREE_CITY_ADJACENT_CULTURE = 0

    I founded a city and it only got the center tile, it would go from poor to fledgling in 4 turns (Ultrafast GS).
    The next turn it got the first rung at the start of the turn, still the same culturelevel as it was last turn.

    I actually think it's how it should be when playing without the 1CTS, that the city is extra vulnerable the same turn it is founded and only gets that first rung after the other players have had their turn.
    I still vote that we remove the two globals and the dll code for them, what it does does not justify the extra globals and codelines imo.
     
    Last edited: Dec 14, 2018
  17. Morlark

    Morlark Chieftain

    Joined:
    Aug 6, 2009
    Messages:
    192
    Well that explains the behaviour I just saw. I conquered a few cities (with RCS on) and they're just expanding borders in rings, as if RCS is off. Came here to report it, and it looks like it's already the big topic of discussion this week.
     
  18. Thunderbrd

    Thunderbrd C2C War Dog

    Joined:
    Jan 2, 2010
    Messages:
    25,226
    Gender:
    Male
    Location:
    Las Vegas
    I would be fine with the global for the first rung being set to 0 but I think it would be problematic if the city didn't demand itself to at least be claimed. And I see no cause to remove code over it since opinions may change later. I'd say starvation would be an issue but it shouldn't be now with the added food if you have more pop.
     
  19. Toffer90

    Toffer90 C2C Modder

    Joined:
    Oct 16, 2011
    Messages:
    5,473
    Location:
    Norway
    It already does demand that the center tile is claimed without the global define helping.

    This line comes before any of that code.
    pPlot->setOwner(getOwnerINLINE(), bBumpUnits, false);

    If we use the switch as you want then I would still argue that we remove the global define.
    Code:
    if (!GC.getGameINLINE().isOption(GAMEOPTION_1_CITY_TILE_FOUNDING))
    {
        for (iI = 0; iI < NUM_DIRECTION_TYPES; iI++)
        {
            pAdjacentPlot = plotDirection(getX_INLINE(), getY_INLINE(), ((DirectionTypes)iI));
    
            if (pAdjacentPlot != NULL && pAdjacentPlot->getOwnerINLINE() == NO_PLAYER)
            {
                pAdjacentPlot->setOwner(getOwnerINLINE(), bBumpUnits, false);
            }
        }
    }
    I have no theory as to what the point of the below code is: Edit: I still don't.
    Code:
        if (pPlot->getCulture(getOwnerINLINE()) < GC.getDefineINT("FREE_CITY_CULTURE"))
        {
            pPlot->setCulture(getOwnerINLINE(), GC.getDefineINT("FREE_CITY_CULTURE"), bBumpUnits, false);
        }
     
    Last edited: Dec 14, 2018
  20. Thunderbrd

    Thunderbrd C2C War Dog

    Joined:
    Jan 2, 2010
    Messages:
    25,226
    Gender:
    Male
    Location:
    Las Vegas
    You can claim a plot for a city but not own it. It just means the city has dibs on it for when it has some culture and the plot is within its ownership range. (A claim is particularly more pertinent between competing cities of the same player or the same team.) The last bit of code is the part that gives it a minimum of 1 culture to that plot where the city was founded. That's the global I wouldn't mess with. I considered code along the lines you suggested, yes, which would then remove the need for that global at all and if you read back, I made that very suggestion. However, I think we could safely turn the FREE_CITY_ADJACENT_CULTURE global to 0 and not have to worry about it further in the slightest. No need to adjust the code at all but if we did want to reverse that then we could more easily react since it's still there to react with, or tell people to manipulate it locally, or whatever. Only if this becomes a bigger issue is it worth a recoding effort.
     

Share This Page