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

I want to help this mod

Discussion in 'Civ4 - Caveman 2 Cosmos' started by strategyonly, Aug 8, 2016.

  1. MattCA

    MattCA Warlord

    Joined:
    Jan 25, 2019
    Messages:
    260
    Gender:
    Male
    Github issue: Remove all erroneous DllExport declarations. #199

    Completed by Anq, inspired by that same post.
     
    Osk21 and billw2015 like this.
  2. MattCA

    MattCA Warlord

    Joined:
    Jan 25, 2019
    Messages:
    260
    Gender:
    Male
    Code:
    import SystemPaths as SP
    import os
    import os.path
    
    def verifyModDir(szModPath):
        git_directory = os.path.join(szModPath, "git_directory.txt")
        if os.path.isfile(git_directory):
            pFile = open(git_directory)
            szModPath = pFile.read().rstrip("\n")
            pFile.close()
        return szModPath
    
    g_szModPath = verifyModDir(SP.modDir)
    
    
    def initPackage(szFolderName):
        for szPath in os.listdir(os.path.join(g_szModPath, "Assets", "Python", szFolderName)):
            try:
                initModule = getattr(__import__(szPath[0:len(szPath) -3]), "init")
            except:
                continue
    
            initModule()
    
     
  3. billw2015

    billw2015 King

    Joined:
    Jun 22, 2015
    Messages:
    837
    What is it for?
     
  4. MattCA

    MattCA Warlord

    Joined:
    Jan 25, 2019
    Messages:
    260
    Gender:
    Male
    if your asking what it does:
    def 1. switches mod path for dev versions of the mod to use the one in the git_directory file.
    def 2. Attempts to call init on all modules found in the folder that is passed as arg.

    if your asking what's it could be used for:
    1. I got some other thing I wanted the correct path for, but you guys can easily hook it up to BugPath and the python stuff like user settings will follow that git_directory.txt.
    2. I'm gonna call that during init, giving it my folder's name. No more config folder for me.

    however:
    1. having multiple copies of the user settings seems kinda pointless to me.
    2. Extra automation for programmers convenience is usually seen as not such a great idea, and that makes sense to me.

    so...
    not sure.
     
  5. MattCA

    MattCA Warlord

    Joined:
    Jan 25, 2019
    Messages:
    260
    Gender:
    Male
    Code:
    void cvInternalGlobals::deleteInfoArrays()
    {
        deleteInfoArray(m_paBuildingClassInfo);
        deleteInfoArray(m_paBuildingInfo);
        deleteInfoArray(m_paSpecialBuildingInfo);
    
    When would all the info arrays be deleted? All I can think of is when the game is exited, so if a few tiny arrays were missing that wouldn't matter much right?
     
  6. billw2015

    billw2015 King

    Joined:
    Jun 22, 2015
    Messages:
    837
    Yeah I think so, there is no reload of xml as far as I know? However I'm definitely going to replace all these with vectors so no more deletes!
     
  7. MattCA

    MattCA Warlord

    Joined:
    Jan 25, 2019
    Messages:
    260
    Gender:
    Male
    Attempting to delete various info objects is actually one of my stranger ideas I'd like to try.
    Code:
    void cvInternalGlobals::deleteSpawnInfo(SpawnTypes eIndex)
    {
        delete m_paSpawnInfo[eIndex];
    
        for (int iI = eIndex; iI < (int)m_paSpawnInfo.size() -1; iI++)
        {
            m_paSpawnInfo[iI] = m_paSpawnInfo[iI +1];
        }
        m_paSpawnInfo.pop_back();
    }
    
    I was think spawn info would be a simple place to start because of how it's used.
    Id just need to find where the expire date is checked and call my delete function there.
    Then i'd need something to record that info was deleted, and then something to reload the xml if a new game is loaded or started. But that's stuff for later.

    Code:
    void CvCorporationInfo::setChar(int i)
    {
    /************************************************************************************************/
    /* TGA_INDEXATION                          01/21/08                                MRGENIE      */
    /*                                                                                              */
    /*                                                                                              */
    /************************************************************************************************/
    /*
        m_iChar = i;
    */
        m_iChar = 8550 + (TGA_RELIGIONS + m_iTGAIndex) * 2;
    /************************************************************************************************/
    /* TGA_INDEXATION                          END                                                  */
    /************************************************************************************************/
    }
    
    void CvCorporationInfo::setHeadquarterChar(int i)
    {
    /************************************************************************************************/
    /* TGA_INDEXATION                          01/21/08                                MRGENIE      */
    /*                                                                                              */
    /*                                                                                              */
    /************************************************************************************************/
    /*
        m_iHeadquarterChar = i;
    */
        m_iHeadquarterChar = 8551 + (TGA_RELIGIONS + m_iTGAIndex) * 2;
    /************************************************************************************************/
    /* TGA_INDEXATION                          END                                                  */
    /************************************************************************************************/
    }
    
    I've mentioned this before but nobody knew much about this stuff at the time. Now that bill's here I mention again.
    Corporation and religion are mixed up. No idea if it's a mistake.
     
  8. Toffer90

    Toffer90 C2C Modder

    Joined:
    Oct 16, 2011
    Messages:
    6,717
    Location:
    Norway
    Don't you think anyone would have mentioned it if the corporatuion icon on the city bar was using religion icons...
    No, I don't think there's a mistake there. TGA_RELIGIONS is just an number that one can derive the corporation icon start index from.
     
  9. MattCA

    MattCA Warlord

    Joined:
    Jan 25, 2019
    Messages:
    260
    Gender:
    Male
    // Only two places this method is called:
    CvUnit * pBestSacrifice = AI_getBestGroupSacrifice(pDestPlot, false, false, bNoBlitz, bStealth);
    CvUnit * pBestSacrifice = AI_getBestGroupSacrifice(pDestPlot, false, false, bNoBlitz, bStealth);

    Header:
    virtual CvUnit* AI_getBestGroupSacrifice(const CvPlot* pPlot, bool bPotentialEnemy, bool bForce = false, bool bNoBlitz = false, bool bSuprise = false) const = 0;

    Code:
    CvUnit* CvSelectionGroupAI::AI_getBestGroupSacrifice(const CvPlot* pPlot, bool bPotentialEnemy, bool bForce, bool bNoBlitz, bool bSuprise) const
    {
        int iBestValue = 0;
        CvUnit* pBestUnit = NULL;
    
        CLLNode<IDInfo>* pUnitNode = headUnitNode();
        while (pUnitNode != NULL)
        {
            CvUnit* pLoopUnit = ::getUnit(pUnitNode->m_data);
            pUnitNode = nextUnitNode(pUnitNode);
    
            if (!pLoopUnit->isDead())
            {
                if ((pLoopUnit->getDomainType() == DOMAIN_AIR && pLoopUnit->canAirAttack())
                    || (pLoopUnit->canAttack() && !(bNoBlitz && pLoopUnit->isBlitz() && pLoopUnit->isMadeAttack())))
                {
                    if (bForce || (pLoopUnit->canMove() && pLoopUnit->canMoveInto(pPlot, true)))
                    {
                        const int iValue = pLoopUnit->AI_sacrificeValue(pPlot);
                        FAssertMsg(iValue >= 0, "iValue is expected to be greater than 0");
    
                        // we want to pick the last unit of highest value, so pick the last unit with a good value
                        if (iValue > 0 && iValue >= iBestValue)
                        {
                            iBestValue = iValue;
                            pBestUnit = pLoopUnit;
                        }
                    }
                }
            }
        }
    
        return pBestUnit;
    }
    
    Just some extra args I wanna remove but it's a virtual in CvSelectionGroup.h.
    I know removing and switching the order of those can cause crash but does anyone know about changing the args?
     
  10. billw2015

    billw2015 King

    Joined:
    Jun 22, 2015
    Messages:
    837
    This function doesn't exist in the vanilla CvUnit.h so removing it shouldn't cause a crash.
     
  11. JosEPh_II

    JosEPh_II TBS WarLord

    Joined:
    Jun 20, 2007
    Messages:
    16,027
    Gender:
    Male
    Location:
    Western IL. cornfields
    This is probably a function T-brd set up for his Hide and Seek Combat mod. Have you considered that? He would have lots of code for his Combat mods that would not exist in vanilla BtS. Just sayin'....
     
  12. Thunderbrd

    Thunderbrd C2C War Dog

    Joined:
    Jan 2, 2010
    Messages:
    27,412
    Gender:
    Male
    Location:
    Las Vegas
    I haven't manipulated unit sacrifice coding with any intent to change or alter it at all. I'm not sure how the AI is best suited to thinking that sort of move through and I have always suspected it may be poor at wise choices there, since I rarely sack any units in play ever. But even trying to consider when and why they'd want to and so on seems easily done wrong, so I have veered away from it. I believe that's what this function involves, which means it didn't involve me.
     
  13. JosEPh_II

    JosEPh_II TBS WarLord

    Joined:
    Jun 20, 2007
    Messages:
    16,027
    Gender:
    Male
    Location:
    Western IL. cornfields
    Okay then.
     
  14. MattCA

    MattCA Warlord

    Joined:
    Jan 25, 2019
    Messages:
    260
    Gender:
    Male
    Code:
    bool CvSelectionGroup::canEnterArea(TeamTypes eTeam, const CvArea* pArea, bool bIgnoreRightOfPassage) const
    {
        if (getNumUnits() > 0)
        {
            for (unit_iterator unitItr = beginUnits(); unitItr != endUnits(); ++unitItr)
            {
                if (!(*unitItr)->canEnterArea(eTeam, pArea, bIgnoreRightOfPassage))
                {
                    return false;
                }
            }
    
            return true;
        }
    
        return false;
    }
    
    That first check seems odd to me. y would code run on a selection group with 0 or less units.

    Code:
    bool CvSelectionGroup::isBusy()
    {
        if (getNumUnits() == 0 || getMissionTimer() > 0)
        {
            return true;
        }
    
        for (unit_iterator unitItr = beginUnits(); unitItr != endUnits(); ++unitItr)
        {
            const CvUnit* pLoopUnit = *unitItr;
            if (pLoopUnit != NULL && pLoopUnit->isCombat())
            {
                return true;
            }
        }
    
        return false;
    }
    
    After switching to a for loop here I can get rid of the pLoopUnit != NULL right?
     
  15. Thunderbrd

    Thunderbrd C2C War Dog

    Joined:
    Jan 2, 2010
    Messages:
    27,412
    Gender:
    Male
    Location:
    Las Vegas
    While they shouldn't exist for long, there are points where they do legally, and worse, there have been times when empty selection groups have haunted the gamestate and we had no way to determine where that becomes possible. IF such an empty selection group hit certain routines, it might cause a bug, and at such a time, a debug effort like this may have been put in place to ensure that such a 'ghost' selection group can just chill without causing a collapse of the code in progress. AKA, there was cause at the time... it's possible that these ghost cases have been solved at this point too.
     
    MattCA likes this.
  16. billw2015

    billw2015 King

    Joined:
    Jun 22, 2015
    Messages:
    837
    Yeah, it can be got rid of regardless, there shouldn't be anywhere where units in a selection group can be null. If it happens its a bug and I will fix the root cause, although I have yet to see it.

    /edit also @MattCA join discord :D
     
    MattCA likes this.
  17. MattCA

    MattCA Warlord

    Joined:
    Jan 25, 2019
    Messages:
    260
    Gender:
    Male
    @billw2015 can you merge branch pr297-merge without CvPlayer.cpp, CvPlayer.h, CvPlot.cpp, and CvPlot.h.
    There's errors in those. Make sure they end up in the trash.

    Edit: I also mixed up the call between CvAppInterface and BugGameUtils. I made one getBaseUtils() and the other getBasicUtils(). Nothing bad happens tho. Just error msg.
     

    Attached Files:

    Last edited: Dec 19, 2019
  18. billw2015

    billw2015 King

    Joined:
    Jun 22, 2015
    Messages:
    837
    If those files shouldn't be in it then just remove those changes, you can revert them, or you can create a new branch and remove them.
     
    MattCA likes this.
  19. MattCA

    MattCA Warlord

    Joined:
    Jan 25, 2019
    Messages:
    260
    Gender:
    Male
    100 civ dll. Seems to work, I didn't test much tho. It should be possible to open CvDefines.h and change MAX_PLAYERS to whatever.
     

    Attached Files:

  20. raxo2222

    raxo2222 Time Traveller

    Joined:
    Jun 10, 2011
    Messages:
    7,519
    Location:
    Poland
    Did you moved NPC defines somehow?
    Civs 40 - 50 were meant to be reserved for NPCs
    I think this WILL break saves and scenarios.
     

Share This Page