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

DLL decompilation

Discussion in 'Civ4 - Caveman 2 Cosmos' started by Joij21, May 15, 2020.

  1. Joij21

    Joij21 Prince

    Joined:
    Jul 21, 2016
    Messages:
    432
    What do you guys use to decompile the DLL? Just curious.
     
  2. Thunderbrd

    Thunderbrd C2C War Dog

    Joined:
    Jan 2, 2010
    Messages:
    27,684
    Gender:
    Male
    Location:
    Las Vegas
    Nothing. You really can't achieve a decompile. That's a big reason we don't have access to the EXE. However, we do have the original source codes as far as the dll is provided and it's located in the source folder in the git repository.

    EDIT: If you were asking what program we use to compile the dll, VS2019 is what most of us are on most recently. That said, it's not actually necessary to use it aside from the benefits and tools it comes with, many which help with debugging a LOT. Bill managed to build us some tools that compile the dll for us so source files really just need to be edited and saved then trying to start the game thereafter will automatically compile them into a functional DLL.

    He has a guide to getting setup to program the dll somewhere around here... maybe @raxo2222 can point the way to it? I think it's on the github so getting started with a git upload is really the first step. He has yet another guide on that somewhere on the forum here that I think is up to date... not sure.
     
    Last edited: May 15, 2020
  3. raxo2222

    raxo2222 Time Traveller

    Joined:
    Jun 10, 2011
    Messages:
    7,585
    Location:
    Poland
    You can create account on Github and make fork of Caveman2Cosmos, this way you will have source code and tools.

    Alternatively you can download Tools archive and source code from here: https://github.com/caveman2cosmos
     
  4. Joij21

    Joij21 Prince

    Joined:
    Jul 21, 2016
    Messages:
    432
  5. raxo2222

    raxo2222 Time Traveller

    Joined:
    Jun 10, 2011
    Messages:
    7,585
    Location:
    Poland
    Era infos, civilization infos, leaderhead infos have references to music files.
    Audio folder (Assets\XML\Audio) contains sound defines.
     
  6. Joij21

    Joij21 Prince

    Joined:
    Jul 21, 2016
    Messages:
    432
    I meant the files that handle the soundtrack in the DLL.
     
  7. Thunderbrd

    Thunderbrd C2C War Dog

    Joined:
    Jan 2, 2010
    Messages:
    27,684
    Gender:
    Male
    Location:
    Las Vegas
    I've never looked into that before.

    But a cursory look into it shows in CvGameInterface.cpp
    Code:
    
    
    
    int CvGame::getNextSoundtrack(EraTypes eLastEra, int iLastSoundtrack) const
    {
        EraTypes eCurEra = GET_PLAYER(getActivePlayer()).getCurrentEra();
        CvEraInfo& kCurrentEra = GC.getEraInfo(eCurEra);
        if (kCurrentEra.getNumSoundtracks() == 0)
        {
            return -1;
        }
        else if (kCurrentEra.getNumSoundtracks() == 1 || (eLastEra != eCurEra && kCurrentEra.isFirstSoundtrackFirst()))
        {
            return kCurrentEra.getSoundtracks(0);
        }
        else 
        {
            return kCurrentEra.getSoundtracks(GC.getASyncRand().get(kCurrentEra.getNumSoundtracks(), "Pick Song ASYNC"));
        }
    }
    
    int CvGame::getSoundtrackSpace() const
    {
        return std::max(1, GC.getEraInfo(GET_PLAYER(getActivePlayer()).getCurrentEra()).getSoundtrackSpace());
    }
    
    bool CvGame::isSoundtrackOverride(CvString& strSoundtrack) const
    {
        if (GC.getDefineINT("VICTORY_SOUNDTRACK_AVAILABLE") != 0)
        {
            if (getGameState() == GAMESTATE_EXTENDED || getGameState() == GAMESTATE_OVER)
            {
                if (getWinner() == getActiveTeam())
                {
                    strSoundtrack = "AS2D_VICTORY";
                }
                else
                {
                    strSoundtrack = "AS2D_DEFEAT";
                }
                return true;
            }
        }
        return false;
    }
    Looks to be some central coding regarding defining which soundtrack is in use. Looks like the era tags are primarily guiding the soundtrack selection. You could add some tags to Civilization Infos, using the same format as you find in the era tags (in CvInfos.h and CvInfos.cpp) and possibly a game option to switch it to using civilization info tags instead if you wished. I did a 'how to add a tag' tutorial around here somewhere...
     
  8. MattCA

    MattCA Warlord

    Joined:
    Jan 25, 2019
    Messages:
    293
    Gender:
    Male
    glider1 likes this.

Share This Page