SC4 Devotion Forum Archives

SimCity 4 General Discussion and Tutorials => SimCity 4 General Discussion => Topic started by: fafalone on May 08, 2010, 07:23:19 PM

Title: Read/Write Game Files
Post by: fafalone on May 08, 2010, 07:23:19 PM
My programming skills are somewhere in between incompetent and advanced... probably closer to the former in the grand spectrum of programming ability, but nevertheless I know there's some useful things I could do if I could get over the hurdle of reading/writing exemplars to the DBPF containers. Are there any libraries, tutorials, or novice accessible documentation that would make such access available to the not-beginner-but-not-advanced programmer? Searching yielded only SimPE; which since it barely works with simcity 4 files and is way over on the highy advanced side of things, is of little help to me.

All I really need is the ability to read and write exemplars and there's lots of things I could do that would be use to at least a few people. But unfortunately I have precisely zero clue what do when it comes to read/writing something other than plain text to a file. One thing I am fairly good at is recognizing concepts in languages I don't know and converting them to languages I do know, so while my main strengths are BASIC-type languages, including Java, and a basic C++ ability, the actual language would be less important than simplicity, clarity, and extent of documentation/commenting.
Title: Re: Read/Write Game Files
Post by: RippleJet on May 09, 2010, 03:30:44 AM
Quote from: fafalone on May 08, 2010, 07:23:19 PM
All I really need is the ability to read and write exemplars

iLive's Reader... ::)
Title: Re: Read/Write Game Files
Post by: fafalone on May 09, 2010, 11:17:52 PM
I'm not an idiot.

On the off chance you're presuming I'm not an idiot and are referring to the NEW ilive reader, it's far harder to go into an unfamiliar language than the other way around. Especially with a lack of documentation of supported features and a complete lack of access to the Win32 API, which is essential to what I want to do.

To clarify, I'm talking about reading and writing programatically; through code in one of the languages I mentioned.
Title: Re: Read/Write Game Files
Post by: Jonathan on May 09, 2010, 11:48:04 PM
What exactly is the end result of what your trying to do?

Are you trying to read/write exemplars in bulk or something?

If you just want to edit an exemplar then you can use the ilive reader as Tage said, the new version does exactly what the old version does. For the user the new one has a couple new features and the UI is updated, but the core functionality is the exact same as the older one. Mods like the NAM that are that complex are created using the ilive reader, without it there wouldn't be a NAM so it can do a lot.

However if there is a particular reason you want to modify DBPFs programmitcally then there a few librarys you can use. There is one for Java, and there's one for .Net (vb and C#) although it's not the best way to manipulate DBPFs.
But there is also the infomation available out there to create you own. Like which bytes are what.
Title: Re: Read/Write Game Files
Post by: fafalone on May 10, 2010, 12:01:12 AM
Quote from: Jonathan on May 09, 2010, 11:48:04 PM
What exactly is the end result of what your trying to do?

Are you trying to read/write exemplars in bulk or something?

If you just want to edit an exemplar then you can use the ilive reader as Tage said, the new version does exactly what the old version does. For the user the new one has a couple new features and the UI is updated, but the core functionality is the exact same as the older one. Mods like the NAM that are that complex are created using the ilive reader, without it there wouldn't be a NAM so it can do a lot.

However if there is a particular reason you want to modify DBPFs programmitcally then there a few librarys you can use. There is one for Java, and there's one for .Net (vb and C#) although it's not the best way to manipulate DBPFs.
But there is also the infomation available out there to create you own. Like which bytes are what.

Exactly :)

I'd certainly prefer to use existing libraries; writing one from scratch would take quite a while just from byte positions. I tried searching but couldn't find any; I'd really appreciate a link to them... especially Java and VB.NET; since I already can program in those languages it would make my life a lot easier :)

I'm already quite familar with what to do with the exemplars themselves, I've done extensive work in Reader including making all my own building exemplars and drastically altering lot exemplars to compensate for the fact pimx does not work right on my system.

--
The new reader has LUA scripting to manipulate the files.
Title: Re: Read/Write Game Files
Post by: RippleJet on May 11, 2010, 08:46:40 AM
Quote from: fafalone on May 10, 2010, 12:01:12 AM
I'd certainly prefer to use existing libraries; writing one from scratch would take quite a while just from byte positions. I tried searching but couldn't find any; I'd really appreciate a link to them... especially Java and VB.NET; since I already can program in those languages it would make my life a lot easier :)

Try sending Wouanagaine a PM, asking what he used in SC4PIM. ;)
He's quite busy in RL at the moment, so it's not very likely that he'd find this thread by himself...
Title: Re: Read/Write Game Files
Post by: Jonathan on May 11, 2010, 01:21:42 PM
Sorry I had replied this morning on my phone but obviously it didn't post.

For the .net plugin you are looking for DatGen by DarkMatter it has a library called SynapticEffect.Simcity
There is a page about it here but I'm not sure which version is the best (I think you'll want the version that doesn't have anything to do with the Sims 2)
http://www.sims2wiki.info/wiki.php?title=DatGen

The SynapticEffect.Simcity library can also be found with Null45's FSHtools that can write to dats (most of them)

Also you can use .net reflector to get the source code of the library and work out how to use it easier (though I didn't find it easy to use but then I'm not a great programmer) There is no documentation of the library and the creator is inactive.

The java library is found with the SSPTool by Stefan79:
http://sc4devotion.com/forums/index.php?topic=6818.240

and the DBPF4J (the library Stefan made that SSPTool uses) is found on sourceforge:
http://sourceforge.net/projects/ssptool/files/

There is no documentation for this either but the creator is still active so you could probably ask him for some.

SC4PIM is written in python I believe and as far as I know, and any DBPF relevant stuff is either part of the program itself or in the library.zip (but I have no idea how python works or anything about it, but my point is I don't think you can just like get a DBPF library from it)
Title: Re: Read/Write Game Files
Post by: fafalone on May 12, 2010, 12:47:47 PM
Looks perfect. Thanks for pointing me in the right direction guys.