How to compile the DLL

OH so I edit the files in visual C++, build and put the new dll in the root of my modbuddy mod. Got ya thanks.
:)
 
You can write to your own log file under the logs sub-directory with code similiar to ...

place this in a .h file

Code:
// Comment this line out to switch off all custom mod logging
#define CUSTOMLOGDEBUG "CustomMods.log"

// Custom mod logger
#ifdef CUSTOMLOGDEBUG
#define CUSTOMLOG(sFmt, ...) {  \
  CvString sMsg;  \
  CvString::format(sMsg, sFmt, __VA_ARGS__);  \
  LOGFILEMGR.GetLog(CUSTOMLOGDEBUG, FILogFile::kDontTimeStamp)->Msg(sMsg.c_str());  \
}
#else
#define	CUSTOMLOG(sFmt, ...) ((void)0)
#endif

and then in your cpp code, call it like

Code:
CUSTOMLOG("Load: %s = %d", szName, iValue);

Whoward - I can honestly say that if it weren't for your contributions on this forum (several other people as well, believe me I recognize what people here are doing for me! but especially whoward) - I would have almost no chance at successfully pulling off the mod I'm doing.
 
The DLL is build from all files, they should already been included in the project file.
 
I've added the update fix (thanks whoward69 !) to the first post.

@DaveMcW: feel free to edit if needed, of course.
 
Wow, this worked immediately for me (just had to remove the 0kb files manually) and I have my first mod running!
Changing the C++ code is much easier for me than working with the lua or xml.

Can I assume that any mod that has no dll in its folder doesn't change the dll?
Then there is no problem to use this mod with others, I guess.
 
Wow, this worked immediately for me (just had to remove the 0kb files manually) and I have my first mod running!
Changing the C++ code is much easier for me than working with the lua or xml.

Can I assume that any mod that has no dll in its folder doesn't change the dll?
Then there is no problem to use this mod with others, I guess.

If it doesn't include a dll, it doesn't change the dll.

There are lots of ways you can have compatibility problems, but the most common are probably: two mods with dlls are automatically not compatible, and you can only use one mod that changes a given UI element at a time (e.g. only one mod can change how the TopPanel works at a time).
 
Just finished ripping what little hair I've got left out.

If you want to use VS-2010 to build the DLL (which I was) you need to install VS-2008 FIRST and then VS-2010 (installing VS-2008 after VS-2010 because you forgot to do it doesn't seem to work!)
 
The VS 2008 Express downloads have been removed. Will try to see if the vc90 sp1 will let me install things, if not it is debugging template code for the lua references.
 
I'm having some difficulty deploying a new DLL mod. After some coercing, it is loading my custom DLL, but the game crashes immediately. (Between hitting "Next" on the mod selection screen and when the sound effect plays for the button press, which is, I would think, when the mod is loaded.) Attempting to find this error, I've stripped out basically all of my code. (Commented out) The only changes (that git diff can see and I can remember) are the two "afrxes.h" -> "windows.h" and I've created a new GUID using the VS2010 GUID creator and added it to CvDllContext.cpp (replacing the old GUID).

I get the following, lone error in the GameCore.log file:

[49977.509] GetProcAddress('DllGetGameContext') failed with error 127: The specified procedure could not be found.


I've looked at that function (DllGetGameContext), and it's definitely still there. It's all got me a bit stumped.
 
The DLL MUST have the correct name "CvGameCore_Expansion1.dll" - note that the default name from the build is NOT correct. The DLL MUST be in the root of the mod (and not a sub-folder). The DLL MUST only have VFS=true - do not try to use the GetDLLEntry stuff in ModBuddy as it's broken.

If that doesn't fix it, try using a copy of the standard dll in your mod (ie replacing the dll with itself) - if you still get crashes you've probably got a permissions error and Windoze doesn't want to execute code from your user (sub-)directory.
 
Very good suggestions, I hadn't thought of the windows permissions issues. But I'm still stuck, unfortunately. I've rolled back to the only changes are now the "afrxes.h" headers in the .rc files and the GUID in CvDllContext.cpp and it still crashes on load. The mod only has one other file, which is a lua script that runs when the map loads, but that never runs before the crash.

Oddly enough, the mod does work if I include the standard expansion dll, so it doesn't seem to be a permissions problem.

EDIT: I've also tried it without the GUID change (using the default one) and that gives me the same crash.

EDIT 2: Fixed! Turns out I hadn't done the vcproj file changes from the first post properly. :mischief:
 
Yep, I've put that back. I had some fun with some binary files being committed to git by accident and Visual Studio didn't much like them changing without its supervision.

Now I'm off to poke around and see if I can induce a terrain graphics refresh without reloading the whole game.
 
Now I'm off to poke around and see if I can induce a terrain graphics refresh without reloading the whole game.

A number of us will be very grateful if you can! Search for "layoutdirty" in CvPlot.cpp
 
How do we get a "debug" DLL? In civ4 there was a different makefile for it. Here though I've not seen anything about it.

Following the directions in the 1st post I generated a CvGameCore_Expansion1.dll and CvGameCore_Expansion1.pdb. I added them to my mod (at the level below the mod name), with the dll having VFS = true, but I haven't set the pds with the same. Using "Visual Studio 9.0" "attach to process" it can stop on the CtDs, but I don't get any Asserts (civ4 had quite a few usually), and then the failure is almost always outside of the symbols territory, so there isn't even any source code to look at to help figure out where things are going wrong.

What else is there to this?

Debug dll, you're my only hope! That is unless someone can explain how to start a game. Really what I'd like to do is to load a .civ5map file that contains only terrain, and specify everything else in Lua files, but I can't figure out how to load a .civ5map and then a lua file to set the civs/unit/cities. Instead then I've created a "map script" which loads a Lua file which contains the base map, and then overrides the other map script functions (eg AddGoodies, GenerateTerrain, AddRivers, StartPlotSystem, AddFeatures, DetermineContinents, GeneratePlotTypes, GetMapScriptInfo, and GetMapInitData). Prior to the map script the lua file containing the PreGame settings is loaded (ala MedievalScenarioLoadScreen.lua). The game CtDs during Events.SerialEventStartGame(), but I've no idea why. The lua.log shows that my code has run, and that my civs are alive, so that part all looks clean. Still though, CtD!
 
The new DLL compiles fine out of the box with the exception that you need to replace the afxres.h with windows.h in the resource file. Everything else seems to work correctly now in the build.

Edit: It also looks like the requirement to make a GUID has been removed.
 
Top Bottom