Write an Morrowind.ini to openmw.cfg converter

Everything about development and the OpenMW source code.
User avatar
lgromanowski
Site Admin
Posts: 1193
Joined: 05 Aug 2011, 22:21
Location: Wroclaw, Poland
Contact:

Re: Write an Morrowind.ini to openmw.cfg converter

Post by lgromanowski » 30 Mar 2012, 19:44

swick wrote:is there some documentation for the ini and the cfg file syntax?
openmw.cfg file is similar to windows ini with one exception - in ini file ';' character is used for comments.

//EDIT: Also there are sections with "[]" brackets , i.e:
[video]
resolution=800x600
best regards,
Lukasz

User avatar
ap0
Posts: 289
Joined: 11 Aug 2011, 18:47
Contact:

Re: Write an Morrowind.ini to openmw.cfg converter

Post by ap0 » 30 Mar 2012, 20:19

The officious documentation about ini is here : http://www.cloanto.com/specs/ini/
The wikipedia's article is actually realy nice too.

swick
Posts: 96
Joined: 06 Aug 2011, 13:00

Re: Write an Morrowind.ini to openmw.cfg converter

Post by swick » 30 Mar 2012, 21:04

what should I do with sections?
Also, when comparing the keys, should it be case sensetive?

User avatar
Zini
Posts: 5536
Joined: 06 Aug 2011, 15:16

Re: Write an Morrowind.ini to openmw.cfg converter

Post by Zini » 30 Mar 2012, 21:26

what should I do with sections?
We don't have sections in openmw.cfg. Combine the key and the section in Morrowind.ini into a new key and map these to plain openmw.cfg keys.
Also, when comparing the keys, should it be case sensetive?
No idea if ini file keys are case sensitive (if you have MW at hand you could try it out by changing the case of an important key). However openmw.cfg definitely are.

swick
Posts: 96
Joined: 06 Aug 2011, 13:00

Re: Write an Morrowind.ini to openmw.cfg converter

Post by swick » 30 Mar 2012, 22:24

That's it for today. It allready works, sort of. I'm not sure about spaces in keys and error handling is definitly wrong. Is it better to throw an error and/or exit if the syntax of a file is wrong or silently ignore it?
btw, branch is here: https://github.com/swick/openmw/tree/initocfg

User avatar
Zini
Posts: 5536
Joined: 06 Aug 2011, 15:16

Re: Write an Morrowind.ini to openmw.cfg converter

Post by Zini » 30 Mar 2012, 23:44

Will look at the code tomorrow.

Abort error handling: Let's be tolerant here. If you can recover from an error and continue, then do so.

User avatar
Zini
Posts: 5536
Joined: 06 Aug 2011, 15:16

Re: Write an Morrowind.ini to openmw.cfg converter

Post by Zini » 31 Mar 2012, 10:32

Didn't compile at first. Required a minor comparability fix for older boost version (see my initcfg branch).

After fixing that, it crashes:
marc:~/OpenMW/build$ ./mwiniimport -i Morrowind.ini -c openmw2.cfg -o openmw3.cfg
load ini file: Morrowind.ini
terminate called after throwing an instance of 'IniParseException'
what(): unexpected end of line
Aborted
It seems you are not considering lines that only contain whitespaces.

Also, your merge function needs to be rewritten. The key names in openmw.cfg and Morrowind.ini do not necessarily match. And even when a key is not present in the cfg file, it still needs to be filled in when there is an equivalent in the ini file (this case is actually the main purpose of the importer).

swick
Posts: 96
Joined: 06 Aug 2011, 13:00

Re: Write an Morrowind.ini to openmw.cfg converter

Post by swick » 31 Mar 2012, 11:33

Zini wrote:Also, your merge function needs to be rewritten. The key names in openmw.cfg and Morrowind.ini do not necessarily match.
Does it work if I just delete all spaces in the ini-keys? Also I need to know if the ini keys are case sensetive (I can't check, lost my 2 cds somehow).
Zini wrote:And even when a key is not present in the cfg file, it still needs to be filled in when there is an equivalent in the ini file (this case is actually the main purpose of the importer).
Every key-value pair from the ini should go in the cfg file? I thought it should only update the values of the cfg file...

User avatar
Zini
Posts: 5536
Joined: 06 Aug 2011, 15:16

Re: Write an Morrowind.ini to openmw.cfg converter

Post by Zini » 31 Mar 2012, 11:59

Does it work if I just delete all spaces in the ini-keys? Also I need to know if the ini keys are case sensetive (I can't check, lost my 2 cds somehow).
No. ini-key can have spaces. I am talking about empty lines, that aren't fully empty.
Every key-value pair from the ini should go in the cfg file? I thought it should only update the values of the cfg file...
No. Both wrong. You need to map certain ini-keys to certain cfg-keys. If they are present in the cfg file or not doesn't matter (and it is irrelevant in the first place, since the names won't match always).

Basically you need to examine for each cfg key, if there is an ini equivalent and then hardcode this mapping into the importer.

For now that is only fps, master and plugin (both master and plugin need a special treatment; we can look into that once the basic importer works).


Post Reply