need help reading .ini file

For code related discussions and questions
User avatar
Duha
Trained
Trained
Posts: 287
Joined: 25 Mar 2012, 20:05
Location: SPb, Russia

Re: need help reading .ini file

Post by Duha » 05 Jun 2013, 23:33

https://github.com/Warzone2100/warzone2 ... ts/ecm.ini
"body" should be "bodyPoints"?

https://github.com/Warzone2100/warzone2 ... ulsion.ini
"hitpoints" should be "bodyPoints"?

Merge propulsionsounds.ini to propulsions.ini?

may be we can merge propulsiontype.ini to propulsions.ini
+ simple strucure
+ easy to adjust each propulsions settings
- can`t change all type at once

https://github.com/Warzone2100/warzone2 ... s.ini#L247
"LightWorld" should be "lightWorld" or "highlightArea"
"body" should be "bodyPoints"

https://github.com/Warzone2100/warzone2 ... ucture.ini
some fields missed in header comments:
powerPoints, productionPoint, rearmPoints, repairPoints, researchPoints
baseWidth, baseBreadth => width, breadth (as in features.ini)


different name styles in structures and templates:

Code: Select all

"name": "sensorID",
"name": "compSensor",


May be we can simplify structures.ini:

We have some field that depends from type:
productionPoints, rearmPoints, repairPoints

I suggest to replace them all with one field power.

If type == REPAIR FACILITY then power means repairPoints
If type == GENERATOR then power means poewrPoints
etc.

PS.
Looks like I finished researching stats.
current docs example.: https://googledrive.com/host/0B12sy1FQt ... hWUFQzSzA/
http://addons.wz2100.net/ developer

User avatar
Ezio
Trained
Trained
Posts: 305
Joined: 24 Apr 2010, 16:42

Re: need help reading .ini file

Post by Ezio » 04 Sep 2013, 20:27

Per, current body.ini use CyborgLightBody and CyborgHeavyBody while names.txt has nothing about them (it still use old names while guide parser needs it). is it going to be updated?, currently i used hack so cyborg would be generated in guide..
Last edited by Ezio on 04 Sep 2013, 20:41, edited 1 time in total.
Image
Please Read FAQ, Dev Wiki and Search forum for same post before posting

Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3775
Joined: 03 Aug 2006, 19:39

Re: need help reading .ini file

Post by Per » 04 Sep 2013, 20:32

Most names are now read from the .ini files, not names.txt. I am hoping that names.txt will soon be obsoleted.

I have made a note to look at your other suggestions later.

User avatar
Ezio
Trained
Trained
Posts: 305
Joined: 24 Apr 2010, 16:42

Re: need help reading .ini file

Post by Ezio » 04 Sep 2013, 22:07

Per wrote:Most names are now read from the .ini files, not names.txt. I am hoping that names.txt will soon be obsoleted.

I have made a note to look at your other suggestions later.
1. Ok, currently only templates.inc which still use data from names.txt.
2. about accuracy, according to .ini only mortar variant (indirect weapon) which have a longHit and shortHit (i use them for % accuracy) direct like machine gun would have a 0/0% accuracy. is there a default accuracy if not set? :hmm:
3. we need an image for hardcrete gate and nexus link turret :)
Image
Please Read FAQ, Dev Wiki and Search forum for same post before posting

Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3775
Joined: 03 Aug 2006, 19:39

Re: need help reading .ini file

Post by Per » 04 Sep 2013, 23:25

There is no shortHit anymore in 3.2. longHit is used for all ranges.

User avatar
Duha
Trained
Trained
Posts: 287
Joined: 25 Mar 2012, 20:05
Location: SPb, Russia

Re: need help reading .ini file

Post by Duha » 01 Oct 2013, 22:47

Hi, I am successfully cloned wz repo(my internet connection became better :)) and can make some pull requests.

https://github.com/Warzone2100/warzone2100/pull/36

Things I can do with stats:
1. rename bodyPoint and hitppoints fields to body in all files (that name used in stats.cpp: psStats->body)

2. rename width and breadth in structures to baseWidth and baseBreadth (that name used in features.cpp: p->baseBreadth)
http://addons.wz2100.net/ developer

crab_
Trained
Trained
Posts: 349
Joined: 29 Jul 2013, 18:09

Re: need help reading .ini file

Post by crab_ » 01 Oct 2013, 23:29

Duha wrote:1. rename bodyPoint and hitppoints fields to body in all files (that name used in stats.cpp: psStats->body)
Plese do not do that.
"body" is bad name for property, it's obvious.
We have Body object already, so we cannot use object name as name of property.
Droid.body = Body.body? :)
Warzone2100 Guide - http://betaguide.wz2100.net/

User avatar
Duha
Trained
Trained
Posts: 287
Joined: 25 Mar 2012, 20:05
Location: SPb, Russia

Re: need help reading .ini file

Post by Duha » 01 Oct 2013, 23:52

crab_ wrote:
Duha wrote:1. rename bodyPoint and hitppoints fields to body in all files (that name used in stats.cpp: psStats->body)
Plese do not do that.
"body" is bad name for property, it's obvious.
We have Body object already, so we cannot use object name as name of property.
Droid.body = Body.body? :)
All "body", "hitpoints" and "bodyPoints" must have same name in ini files.
In C++ code this property called "body".
IMHO body is not best name, but for integrity with other code it is OK. I like hitpoint more.
http://addons.wz2100.net/ developer

crab_
Trained
Trained
Posts: 349
Joined: 29 Jul 2013, 18:09

Re: need help reading .ini file

Post by crab_ » 01 Oct 2013, 23:56

Duha wrote: All "body", "hitpoints" and "bodyPoints" must have same name in ini files.
In C++ code this property called "body".
IMHO body is not best name, but for integrity with other code it is OK. I like hitpoint more.
Why not just rename "->body" in low-level c-code?
I think it is even more simplier because compiler will help with renaming.
so please rename body to hitPoints or something similar (Health, LifePoints?)

C++ code should be should not be considered as "god written" code XD
Warzone2100 Guide - http://betaguide.wz2100.net/

User avatar
Duha
Trained
Trained
Posts: 287
Joined: 25 Mar 2012, 20:05
Location: SPb, Russia

Re: need help reading .ini file

Post by Duha » 02 Oct 2013, 00:15

crab_ wrote:
Duha wrote: All "body", "hitpoints" and "bodyPoints" must have same name in ini files.
In C++ code this property called "body".
IMHO body is not best name, but for integrity with other code it is OK. I like hitpoint more.
Why not just rename "->body" in low-level c-code?
I think it is even more simplier because compiler will help with renaming.
so please rename body to hitPoints or something similar (Health, LifePoints?)

C++ code should be should not be considered as "god written" code XD
I have some trouble with compilers: I don`t like them and my windows don`t want to work with them properly

May be you know what will happen with this code if "maxDroids" is not specified in ini section.

Code: Select all

psStats->maxDroids = ini.value("maxDroids").toInt();
https://github.com/Warzone2100/warzone2 ... s.cpp#L582

ini example: https://github.com/Warzone2100/warzone2 ... /brain.ini
http://addons.wz2100.net/ developer

User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: need help reading .ini file

Post by NoQ » 02 Oct 2013, 05:36

Duha wrote: May be you know what will happen with this code if "maxDroids" is not specified in ini section.

Code: Select all

psStats->maxDroids = ini.value("maxDroids").toInt();
value returns invalid QVariant. If you give value an optional second parameter, it will be returned instead. Proof link. Then toInt returns 0, indicating "not ok" (false) in its optional bool* parameter. Proof link. (checked the last part of it just in case).

crab_
Trained
Trained
Posts: 349
Joined: 29 Jul 2013, 18:09

Re: need help reading .ini file

Post by crab_ » 02 Oct 2013, 15:09

Duha wrote: I have some trouble with compilers: I don`t like them and my windows don`t want to work with them properly
Did you tried Visual Studio as compiler for Warzone?
I have troubles with compiling Warzone in Visual Studio after i re-installed windows, but i believe if i spend some days i will be able to compile warzone :)
Duha wrote:May be you know what will happen with this code if "maxDroids" is not specified in ini section.
As far i understand each parameter has "default value" (as NoQ said above)
Warzone2100 Guide - http://betaguide.wz2100.net/

User avatar
Duha
Trained
Trained
Posts: 287
Joined: 25 Mar 2012, 20:05
Location: SPb, Russia

Re: need help reading .ini file

Post by Duha » 02 Oct 2013, 16:51

crab_ wrote:
Duha wrote: I have some trouble with compilers: I don`t like them and my windows don`t want to work with them properly
Did you tried Visual Studio as compiler for Warzone?
I have troubles with compiling Warzone in Visual Studio after i re-installed windows, but i believe if i spend some days i will be able to compile warzone :)
I tied to install compiler to compile PIL form python packages (gcc and some from visual studio)
As far i understand each parameter has "default value" (as NoQ said above)
Both values has default = 0, little inconsistency in code style.

Code: Select all

psStats->weight = ini.value("weight", 0).toInt();
psStats->maxDroids = ini.value("maxDroids").toInt();
http://addons.wz2100.net/ developer

Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3775
Joined: 03 Aug 2006, 19:39

Re: need help reading .ini file

Post by Per » 02 Oct 2013, 20:46

I've been trying to slowly convert 'body' meaning 'how much damage something can take' to 'hitpoints', because, really, nobody understands 'body' to mean that. Patches to complete the transition are welcome.

User avatar
Duha
Trained
Trained
Posts: 287
Joined: 25 Mar 2012, 20:05
Location: SPb, Russia

Re: need help reading .ini file

Post by Duha » 02 Oct 2013, 21:37

baseWidth in structures and "width" in features handled in different way is it OK?


Structures:

Code: Select all

psStats->baseWidth = ini.value("baseWidth", 0).toUInt();
		ASSERT_OR_RETURN(false, psStats->baseWidth <= 100, "Invalid baseWidth '%d' for structure '%s'", psStats->baseWidth, getID(psStats));
Features:

Code: Select all

p->baseWidth = ini.value("width", 1).toInt();
http://addons.wz2100.net/ developer

Post Reply