Sloppy programming

Started by Art Blade, August 29, 2011, 08:53:55 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Art Blade

:)

Having checked some of those ominous XML files, I realised how sloppy the programmers of FC2 worked as far as creating XML libraries is concerned. This is the reason modding isn't just a walk in the park. For instance:

The file \Far Cry 2\modding\libraries\world1\30_player.xml is roughly 11 mega bytes long. 11MB! Why? Because they had to define characteristics for all those buddies you can play as, like Warren. Every bit he could be involved in the game needs to be framed by rules and definitions, values, parameters and so forth. Now the next random buddy, say Frank, needs the same set of data. So what did they do? Define those again.  Which means, you get to see like 10 times the same sets of identical data. Why on earth didn't they create an index and a template and refer to them rather than defining the same crap over and over again?  :D

Obviously, crap like that leads to countless sources where to modify things, probably needs to be done in the same stupid way, like: Let's change one bullet. For every character there is, so rather than making one change, do it a hundred times because it's so much fun to find the bits and pieces you missed when you first did it.  ??? :D

Alright.. need more Valium and a few packs of Prozac and a bottle of gasoline to wash it down with.  :-D

Seriously, to get things going, we should keep in mind that anybody who wishes to mod what we did needs to be able to easily access the files and make modifications necessary. In order to do so, we need to provide one another with exact locations of files and a pasted sample of the code. I tried an example given in that forum:

source:

\Far Cry 2\modding\libraries\world1\30_player.xml

of course we need to know where to copy the file to:

copy it to \Far Cry 2\modding\mymod\patch and rename it to player.xml

and then what to look for, like:

<value name="fJumpHeight" type="Float">1</value>

and then what to change it to:

<value name="fJumpHeight" type="Float">100</value>

This caused my character to indeed jump into the sky and stay there. Silly.

By the way, I didn't have the problems TheStranger described, I just started the build_patch.bat which created both patch files inside the modding folder. I then copied them to the Data_Win32 folder and was able to run the modded game. But it was laggy as hell, no idea why. Need to find out what it was.

What I'd like to know is which files and which lines to alter to get those weapon modifications done.. TheStranger, your help needed, please  :)
[titlebar]Vision without action is a daydream. Action without vision is a nightmare.[/titlebar]What doesn't kill us, makes us weirder.

PZ

Quote from: Art Blade on August 29, 2011, 08:53:55 AM
... Let's change one bullet. For every character there is, so rather than making one change, do it a hundred times ...

Of course, we could pretend that we have only one sharpshooting character and change the characteristics only for that buddy.  :-()

I can see that there will certainly be a learning curve, but might be kind of fun anyway.

Art Blade

 :)

I found something interesting in gamemodesconfig.xml:

<Gadget archetype="gadgets.Equipped.Watch" count="0" />

There is the watch we used to admire in early pre-release pictures of the game. :) They left so many old things in those files, like one comment (something along the line of) "For testing unit, remove before release!"  ::) They clearly ran out of time.
[titlebar]Vision without action is a daydream. Action without vision is a nightmare.[/titlebar]What doesn't kill us, makes us weirder.

PZ

Fascinating - did you try to set the value to count="1"?  ????

There might be some cool things to activate in those .xml files

Art Blade

I was tempted to but no, not yet. Things that are disabled usually don't w%&k if you enable them and might screw up the game badly :)

First I need to understand how the modding process actually works and do things I can immediately notice (like, jump higher) so I know I did it right. I did create a new mod which didn't lag (no idea what had happened before to cause that slideshow effect) but didn't do anything else.  ^+-+

I see different challenges in understanding what's going on.

First, the mod program extracts all files from the 1.03-patch.dat/fat and creates various folders to store the stuff. As far as I understand it, it also converts those otherwise inedible files so you can read them (which means it has to convert them again when creating the actual mod). You needed to add an updated kind of library ("bootstrap" v60) that allows the programs to do said conversions, so we have a) original files and b) files created for the mod program to w%&k.

The challenges for me are to find out:
-whether there are redundant (not needed) files
-if we can delete most of the stuff in those files we want to edit so only changes made remain

Apparently the "mymod" folder contains files for "a basic mod" (what is that and why?) which to me translates to "these files are already there with the actual patch and you can play around with them." So, most of those files are useless for me, so why keep them in my mod if they're going to be slapped back on from the archives anyway?

Reading the original patch and checking / comparing the structure of it leads me to believe that we may put just the file(s) we actually want to alter into the mymod folder and change the file "patch.xml" to contain nothing else. Next, the file(s) we want to alter could possibly be stripped of most of its content (which will be there again by default if we don't do anything to it) so the actual mod files might be significantly smaller than what I see on the net.

If I'm right, we could indeed create stripped slim versions of the modded xml files and upload them to our site -- or even post them by way of quoting the content, using the "data" button plus spoiler button so our posts remain readable. All you'd need to do is create said files in your local mymod folder by either downloading our files or simply paste their content into an empty file and then run the batch file to create your actual mod (which is called "patch.dat/fat").

The principle behind modding is to override existing files with new content. That's why I try to focus on new content and skip all the template crap that comes with the mymod folder  ;D

We'll see :)
[titlebar]Vision without action is a daydream. Action without vision is a nightmare.[/titlebar]What doesn't kill us, makes us weirder.

Art Blade

Quote from: Art Blade on August 29, 2011, 12:14:22 PMYou needed to add an updated kind of library

Oh, and also "bin-rev52.zip" //no, my mistake -- it updated older bootstrap versions but now bootstrap v60 contains all new files.

However, man, the devs must have been crazy. I keep reading gazillions of lines of code that contain nothing else but repetitive stuff and often just simple hexadecimal data injections (basically parameters needed by the hardcoded game file but for reasons unknown are bound to xml format) and no descriptions at all. I bet even they don't know what that code means any more by now if they had to read it. How about self-explanatory and well-documented code, let alone efficient programming.. I could shake a stick at them!  >:(( That's why no-one ever tried to actually mod that stuff >:(
[titlebar]Vision without action is a daydream. Action without vision is a nightmare.[/titlebar]What doesn't kill us, makes us weirder.

PZ

Quote from: Art Blade on August 29, 2011, 01:07:54 PM
... I bet even they don't know what that code means any more by now if they had to read it...

I'll bet that's why they can't fix the tape glitch  :-()

That's a great idea about stripping down the code - I hope that works out.  Even though we can only generate single patch files for the modification to the game, it would be far easier to create a patch that contained all the features we personally want.  :-X

Art Blade

Their poor helpdesk ^+-+ Indeed, no wonder they did diddly-squat about our request  ;D

However, it's getting even worse. I'm looking at the code on my PC retail version. Did I say I played on a PC? Oh yeah? So why is it I'm looking at an entire section (that goes a couple of MB down the file) for AGORA and XBOX?  ??? :D

Oh, one more. There are two folders called world1 and world2 which contain a truckload of files.. that are apparently identical. It dawned on me that it is for Leboa and Bowa.. they duplicated the code for each map! :o
[titlebar]Vision without action is a daydream. Action without vision is a nightmare.[/titlebar]What doesn't kill us, makes us weirder.

gibbed

Quote from: Art Blade on August 29, 2011, 08:53:55 AM
:)

Having checked some of those ominous XML files, I realised how sloppy the programmers of FC2 worked as far as creating XML libraries is concerned. This is the reason modding isn't just a walk in the park. For instance:

The file \Far Cry 2\modding\libraries\world1\30_player.xml is roughly 11 mega bytes long. 11MB! Why? Because they had to define characteristics for all those buddies you can play as, like Warren. Every bit he could be involved in the game needs to be framed by rules and definitions, values, parameters and so forth. Now the next random buddy, say Frank, needs the same set of data. So what did they do? Define those again.  Which means, you get to see like 10 times the same sets of identical data. Why on earth didn't they create an index and a template and refer to them rather than defining the same crap over and over again?  :D
This is actually my fault: not the developers. The original format is a binary definition (entitylibrarypatchoverride.fcb is typically only ~2.5MiB!) and I convert it to an XML-like format because that suits it the most. There *is* a way to reference duplicated data, and they do use it -- I don't, because of the complexity of generating the data as well as editing the data by hand (if you had to constantly looked up referenced data it will be a PITA). This kind of references would make more sense in a visual editor (maybe if I ever get around to creating one).

Art Blade

With that explanation, you're excused.  :-D
[titlebar]Vision without action is a daydream. Action without vision is a nightmare.[/titlebar]What doesn't kill us, makes us weirder.

Tags:
🡱 🡳