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/C++ tutorial discussion thread

Discussion in 'Civ5 - SDK / LUA' started by whoward69, Dec 6, 2013.

  1. Serp

    Serp King

    Joined:
    Apr 1, 2015
    Messages:
    646
    @whoward69 can you please link me a tutorial how to compile your DLL ?
    The one linked in your signature (from 2012) only talks about the orignial DLL and it seems the first post is not up to date and there are thousands of posts afterwards from you and other modders discovering the dll. While this is an interesting journey, I would prefer a direct tutorial step by step.

    Is it necessary to have Civ5 or the SDK installed at the machine I'm compiling the dll?

    Eg. I opened your "CvGameCoreDLL.vs2015.sln" project with Visual Studio 2019 trial version and directly received these errors (and have no clue how to deal with them):
    Code:
    C:\Users\User\Desktop\DLL-VMC-master_original\CvGameCoreDLL_Expansion2\CvGameCoreDLL_Expansion2.vs2010.vcxproj : warning  : The build tools for v90 cannot be found. Install v90 to build using the v90 build tools.
    
    C:\Users\User\Desktop\DLL-VMC-master_original\CvGameCoreDLL_Expansion2\CvGameCoreDLL_Expansion2.vs2010.vcxproj : warning  : Platform 'Win32' referenced in the project file 'CvGameCoreDLL_Expansion2' cannot be found.
    
    error : Designtime build failed for project 'C:\Users\User\Desktop\DLL-VMC-master_original\CvGameCoreDLL_Expansion2\CvGameCoreDLL_Expansion2.vs2010.vcxproj' configuration 'Mod|Win32'. IntelliSense might be unavailable.
       Set environment variable TRACEDESIGNTIME = true and restart Visual Studio to investigate.
    error : Designtime build failed for project 'C:\Users\User\Desktop\DLL-VMC-master_original\CvGameCoreDLL_Expansion2\CvGameCoreDLL_Expansion2.vs2010.vcxproj' configuration 'Mod|Win32'. IntelliSense might be unavailable.
       Set environment variable TRACEDESIGNTIME = true and restart Visual Studio to investigate.
    error : Designtime build failed for project 'C:\Users\User\Desktop\DLL-VMC-master_original\CvGameCoreDLL_Expansion2\CvGameCoreDLL_Expansion2.vs2010.vcxproj' configuration 'Mod|Win32'. IntelliSense might be unavailable.
       Set environment variable TRACEDESIGNTIME = true and restart Visual Studio to investigate.
    error : Designtime build failed for project 'C:\Users\User\Desktop\DLL-VMC-master_original\CvGameCoreDLL_Expansion2\CvGameCoreDLL_Expansion2.vs2010.vcxproj' configuration 'Mod|Win32'. IntelliSense might be unavailable.
       Set environment variable TRACEDESIGNTIME = true and restart Visual Studio to investigate.
    error : Designtime build failed for project 'C:\Users\User\Desktop\DLL-VMC-master_original\CvGameCoreDLL_Expansion2\CvGameCoreDLL_Expansion2.vs2010.vcxproj' configuration 'Mod|Win32'. IntelliSense might be unavailable.
       Set environment variable TRACEDESIGNTIME = true and restart Visual Studio to investigate.
    error : Designtime build failed for project 'C:\Users\User\Desktop\DLL-VMC-master_original\CvGameCoreDLL_Expansion2\CvGameCoreDLL_Expansion2.vs2010.vcxproj' configuration 'Mod|Win32'. IntelliSense might be unavailable.
       Set environment variable TRACEDESIGNTIME = true and restart Visual Studio to investigate.
    error : Designtime build failed for project 'C:\Users\User\Desktop\DLL-VMC-master_original\CvGameCoreDLL_Expansion2\CvGameCoreDLL_Expansion2.vs2010.vcxproj' configuration 'Mod|Win32'. IntelliSense might be unavailable.
       Set environment variable TRACEDESIGNTIME = true and restart Visual Studio to investigate.
    error : Designtime build failed for project 'C:\Users\User\Desktop\DLL-VMC-master_original\CvGameCoreDLL_Expansion2\CvGameCoreDLL_Expansion2.vs2010.vcxproj' configuration 'Mod|Win32'. IntelliSense might be unavailable.
       Set environment variable TRACEDESIGNTIME = true and restart Visual Studio to investigate.
    error : Designtime build failed for project 'C:\Users\User\Desktop\DLL-VMC-master_original\CvGameCoreDLL_Expansion2\CvGameCoreDLL_Expansion2.vs2010.vcxproj' configuration 'Mod|Win32'. IntelliSense might be unavailable.
       Set environment variable TRACEDESIGNTIME = true and restart Visual Studio to investigate.
    error : Designtime build failed for project 'C:\Users\User\Desktop\DLL-VMC-master_original\CvGameCoreDLL_Expansion2\CvGameCoreDLL_Expansion2.vs2010.vcxproj' configuration 'Mod|Win32'. IntelliSense might be unavailable.
       Set environment variable TRACEDESIGNTIME = true and restart Visual Studio to investigate.
    
    
    
     
  2. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,529
    Location:
    Near Portsmouth, UK
    Serp likes this.
  3. Serp

    Serp King

    Joined:
    Apr 1, 2015
    Messages:
    646
    @whoward69 is there also a tutorial how to debug crashes?
    I already had 2 crashes within short time from your original v94 dll (edit: it is a vanilla bug, crash when founding a pantheon, but not have a capital)

    About debuggin in community patch github is written:
    But this does not really help a newbie like me :D No clue where should I build what and where to find a debug configuration or the release config (might also be related to that english is not my native and I really dont understand that sentence). And is this generated dll a seperate one, or is it basically the same dll, but with debugging enabled? If the last, has your shipped dll already debugging enabled? And would the steps for debugging your dll be the same?
    Would be very great if you have a step by step guide, I'm really lost here.

    edit:
    btw your picknmix website is up again, but your "mod utilities and tutorials" are not working, I tried to see if there is something written about debugging http://www.picknmixmods.com/parts/utilities.html#debug but it only shows me a white page with the categories on the left.

    edit2: found a guide: https://forums.civfanatics.com/threads/a-guide-to-debugging-crashes-with-a-custom-dll.506328/ , will try it now.
     
    Last edited: Apr 15, 2020
  4. Serp

    Serp King

    Joined:
    Apr 1, 2015
    Messages:
    646
    @whoward69 :
    Your tutorial explains why we use "#if defined("Mod_XY")" in the dll code. But it does not explain the difference to the default code "if (Mod_XY)".
    For example for your radaring fix:

    #if defined(MOD_BUGFIX_RADARING)
    if (MOD_BUGFIX_RADARING) {...

    Why these 2 checks? Why isnt the first one enough, or the last one?
    And why:
    #define MOD_BUGFIX_RADARING gCustomMods.isBUGFIX_RADARING()

    Ok, lets try it logically:
    "if defined" is only checking if something is defined, not what value it is. So even if we do
    #define MOD_BUGFIX_RADARING (false)
    the first line will be executed?
    So the "#if defined" is really only to be able to fast "remove" code for testing purpose. And when I want code to be actived by custommodptions, then I need:
    if (MOD_BUGFIX_RADARING) {...

    Ok... I think I understood, I just wondered why sometimes we have this double line (defined and chekcing the value), while other times we only check "defined" and not the value. I would expect that we should always use the double lines, to only alter the dll code if forced by a custom mod.

    (I will send this post in case someone else also wonders in the future)


    edit:
    Ah one last question I was not able to answer myself yet:
    When using:
    #if defined(...)
    how does the code know which one is closed with "#endif", if we nested these?
    Like:
    Code:
    #if defined(A)
    // code...
    #if defined(B)
    // code...
    #endif
    //code...
    #endif
    
    which one got closed now with the first #endif?
    edit3: ok, it seems always the inner part is closed first, so LIFO.

    edit2:
    I tried to add a new event, but for whatever reason
    if (MOD_EVENTS_VISCOUNT_CHANGED) is always false. I added it to CustomMod.h like this:
    #define MOD_EVENTS_VISCOUNT_CHANGED gCustomMods.isEVENTS_VISCOUNT_CHANGED()

    and I' sure the xml with
    <CustomModOptions>
    <Update>
    <Where Name="EVENTS_VISCOUNT_CHANGED"/>
    <Set Value="1"/>
    </Update>
    </CustomModOptions>
    is properly loaded after the dll mod.

    I also have the MOD_OPT_DECL and MOD_OPT_CACHE things, although I dont know what they do...
    I tested "#define MOD_EVENTS_VISCOUNT_CHANGED (true)", then everything works as intended.
    hm... this is the only problem left, no clue how to use those custommodoptions...
     
    Last edited: Apr 16, 2020

Share This Page