I want to help this mod

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()
 
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...
What is it for?
not sure.
 
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?
 
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!
 
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.
 
Corporation and religion are mixed up. No idea if it's a mistake.
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.
 
// 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?
 
I know removing and switching the order of those can cause crash but does anyone know about changing the args?
This function doesn't exist in the vanilla CvUnit.h so removing it shouldn't cause a crash.
 
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'....
 
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.
 
Okay then.
 
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?
 
That first check seems odd to me. y would code run on a selection group with 0 or less units.
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.
 
After switching to a for loop here I can get rid of the pLoopUnit != NULL right?
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
 
@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.
 

Attachments

  • CvAppInterface.py.txt
    5.4 KB · Views: 104
Last edited:
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.
 
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.
 

Attachments

  • MaxPlayers.7z
    256.2 KB · Views: 297
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.
Did you moved NPC defines somehow?
Civs 40 - 50 were meant to be reserved for NPCs
I think this WILL break saves and scenarios.
 
Top Bottom