Mod switcher

Oh this is a plesent suprise and so soon as well!

have been doing some thinking on diffing and merging several months ago and was toying around purely on paper with some merging algorithms and how to encode the information in XML, basicaly trying to re-invent what you had done. I also had some ideas conserning dependency, I myself have been burned many times by patches that change the XML some method of designating a change file as coming from a particular version might help.

Incorporating this into the DLL is a very bold dream at this point, it may not even be possible if the relavent comands are not in the DLL (I have already run up against problems that cant be resolved because they come from the Exe). The geneal plan was for the player to go to the "Load a Mod" page be able to select multiple radio buttons and have theses merged and imediatly launched into, in addition the new mergeing should be saved in some mannor so it can be reused quickly at a later date.

If incorporation directly into the DLL is successfull I would still like to see an outside standalone utility program without any Civ4 specific features developed for the general public. What do you think of licensing it under the GPL?

Go ahead and mail me the code if you like, or even better upload it to CivFanatics.
 
Releasing the code as GPL might be a good idea. It would also guarantee some degree of contingency in the case I disappear more permanently. I'll have to create a nice and easy source packaging system for myself first though.

A word of warning at this point: I'm developing the program on Linux, and it depends on a couple of my custom libraries. Getting all these compiled on Windows is not trivial.
 
My 2 cents:

I don't think that incorporating the mod combiner into the civ shell is really necessary. It sounds like a lot of work, and 3rd party program that did the merging and either created output files or just merged on a temp. basis and launched civ 4 would be fine.
 
As they say, every cloud has a silver lining - after a long pause with some project, I'm able to look at problems with new angles. I just had a great idea for enhancing the XML diffing engine, making it more generic, robust and easier to maintain.

I'll probably finish Dungeon Keeper 2 next weekend, so you can expect a new version of civ4modder in two or three of weeks. I hope to get the source released at that time as well.
 
Grats on beating DK2! I always lose interest about halfway through (often due to a red a-money beat down).

Have you ever played Majesty? V. similar, v. good.

Oh, and get to work!

EDIT: I doubt you really need to run it all through the game. A stand alone program worked (and works) just fine with Morrowind. In fact, I betcha there would be more utility in a stand alone program that simply compiled mods, especially since you could then upload the result.
 
Finished DK2 on Sunday (or actually Monday, like 2am), and after having to do all kinds of things this week I've finally got my hands on civ4modder code again. I should get something ready sometime next week unless something unforeseen happens. Next up on the list are mod priorities (for conflict resolution) and quick-merging functionality.

Hm, that Majesty game looks good... I'll have to try it... I have a soft spot for simulation-strategy games.

As for integration with Civ4, I'm not going to do it in any case. I don't need it (I build the mods once, then play a game for the next two weeks) and I don't have time to learn the DLL modding system (I have a full-time work and a model railway). Another strong factor is that I'm playing the game on Linux and getting a working cross-development environment for Windows programs is difficult at the very least. If someone else wants to try though, I'll offer support as well as I can.
 
WooHoo, glad to hear your back to work on this, I'll have to keep an eye on this thread. :D
 
I'm making pretty good progress, the new XML diffing and merging system is almost ready. I've also written a great deal more XML definitions for the program (due to the new system forcing me to do so), which will make it detect more changes.

So far I've hit one problem - namely, the file CIV4DiplomacyInfos.xml contains Response "objects", which however have no key that could be used to identify them. Thus the program is currently ignoring the file. I know how this can be fixed, but chances are the fix won't be in version 0.4.

I'm not sure if I can get both mod priorities and quick-merging done this week (I'll be unable to work on this during the weekend), but I'll try.
 
Ouch. I downloaded and extracted GreenMod in order to chop it up into smaller mods. Then I hit the file CIV4PlotLSystem.xml. It contains stuff like this:

Code:
        <ArtRef Name="art:crop">
            <Attribute Class="Scalar">NIF:Art/Structures/Improvements/Farm/crops_w.nif::2x1</Attribute>
            <Attribute Class="Improvement">IMPROVEMENT_FARM</Attribute>
            <Attribute Class="Bonus">NO_BONUS,BONUS_ALL,!BONUS_WHEAT,!BONUS_POTATO</Attribute>
            <Attribute Class="Scalar">bApplyRotation:1</Attribute>
            <Attribute Class="Scalar">bZMode_Ground:1</Attribute>
            <Attribute Class="Scalar">bCutTrees:1</Attribute>
            <Attribute Class="Scalar">bForceGround:1</Attribute>
            <Attribute Class="Scalar">bImprovementWorkedOnly:1</Attribute>
            <Attribute Class="Scalar">bIrrigatedOnly:0</Attribute>
            <Attribute Class="Scalar">szBatchGroup:farm_crop</Attribute>
            <Scale>0.5</Scale>
        </ArtRef>

Not only is that lacking any specific key, it's using XML element attributes as well. Couldn't they have at least been consistent... Nowhere else have I seen attributes been used. It will be some extra work to incorporate support for them in civ4modder.
 
I had suspected you worked off a "key" element whichin each element to determin if its modified or an addition. It should still be possible to do a comparison on on element that lacks a key, but it will require that all elements be searched for an identical match (and the search needs to be able to full hierachical down to bottom most element), initialize a boolean array to check off child elements that have been found so they can be excluded from further searching and thus save lots of time. Unless people start moving element around it will remain resonably efficient because elements will remain in the same order so the first comparison will get a match, exclude that element from searching, proceed to second element, match ect ect...

The Name="art:crop" would serve as a good key if you can use atributes as keys (I dont see why not, though it is more work like you said)

On a related note, the list of key values should be exposed to the user, idealy on an XML document itself with <ElementKey> listing the element name and the name of its key child element which is used to identify it. This would help make the program more flexible for non Civilization hierachy. The user would switch this file around to be able to work on any set of XML files.
 
Nope, there are multiple elements with the same Name value, but different contents. In fact, the Name attribute seems to be more like a class than a name. A quick grep reveals 16 elements with Name="art:crop" and 68 with Name="art:building".

As part of the revised XML diffing system, I did externalize the element list. It's currently a plain-text file (easier to parse), but I might turn it into XML. There are still some rules hardcoded in the program, due to the *Infos.xml files behaving in a consistent way with regard to element naming. With a few lines of code, I can match all those.

If you look at almost any xml file, it's pretty obvious that all "objects" (as I call them) have such a key. I'll be releasing some information about the algorithm along with the source once version 0.4 is ready.
 
I have a question for modders that is appropriate for this thread. Do you modders ever play with the sdk? Are changes to the main dll a part of your mod? Or are people who use the sdk and people who make mods generally separate themselves by generally doing one or the other.

The reason I ask is because I would think that some modders would want to change the source code if they want to make a really big mod. This is why I brough this topic up. I think it would be nice if a mod switcher was part of a modified version of the main game (i.e. the source code). That way modders could include changes to the source code as a separate code file that is part of the mod. For more information see this thread. I would like to know what others think of this idea. Is using the SDK common in modmaking? Is this idea important to modding? Is it just too complicated for most modders (because they are not programmers?)
 
I don't think it's necessary to incorporate the mod combiner in the game itself in order to use plugins. It should be easy enough to look for DLLs in a certain directory of the mod and use them as plugins.
 
The new diffing system and mod prioritizing looks pretty good. I'll polish it off tomorrow and compile a Windows version on Friday. Quick-merging will have to wait until next version.
 
Hm, more interesting problems, this time with Python files. Modified Special Domestic Advisor and Exotic Foreign Advisor both contain the file DomPyHelpers.py. They have much of the same content, and in fact the file in EFA file is a subset of the one in MSDA. However, civ4modder compares mods against the base set, not against each other, so it will see a conflict as both mods try to add the whole file.

I see two possible solutions to this problem:

1. Turn this file into a mod of its own, and make both advisor mods depend on it. This will be pretty easy on my part, but will require a bit of extra work from the mod makers.

2. Process Python files a bit like XML, splitting the files into classes and functions. If two diffs add the same things, they won't conflict. This won't require anything from modders, but will be a rather major thing for me, and may cause unforeseen difficulties in the future. (This solution has actually been suggested earlier.)

This won't affect the release schedule of 0.4, you'll still get it tomorrow.
 
Thanx tdb,

I installed version 0.4 and the library required and started to work. I use some EFA, MSDA mods and other non-game altering mods.

I set the preferences, and expected the mod directory that I set in the preferences to be the directory when I opened to look for a mod to create via CREATE MOD menu option. However it started in the standard mod dir.

I had to change the customassets folder name that comes with most mods to assest for your program to work. Is this the way to do it, or should it also work with the customassets dir-name.

BTW when I close the modder and reopen it, the mod I just created is not displayed, clicking refresh doesn't solve it, only when I click in the listbox, the mod-properties are displayed and if I say "save" the mod is displayed again.

It looks like there are some small glitches in the finishing in this gem. Or i'm doing something competely wrong ;)

BTW, where do you store the diff-info??

HTH
 
Back
Top Bottom