Jump to content
Sign in to follow this  
VictorFarbau

Problems with upper/lower case config class names

Recommended Posts

Sorry, lengthy post. I'll try to be concise in describing what I want and what I did.

Here's the one line description of my problem:

I can get the ammo class name linked to a unit's weapon through the addon config file but cannot find the same names back in the unit magazines names so I won't know whether a unit has sufficient magazines left. And this behaviour occurs if class names are defined in an upper/lower case mix.

More details:

I am currently completely rewriting my Equipment.AI (VFAI) addon that allows units to independently take weapons and ammo as needed. One of the limitations so far was that I used fixed weapon and corresponding ammo class names. This caused 3rd party addon weapons to be not properly recognized and used.

Now I use the "weapons <unit>" command to query for the weapon class names, then I query the config file for the corresponding magazines using the "getArray (configFile >> ... >> magazines)" command. I have tested this with the built-in weapons as well as Skaven RACS and HD units and it reports back the required ammo class names fine in all cases.

So what's the problem? I have scripted this in a way that units would drop weapons for which they can't determine any magazine class or when they are out of magazines. So during test runs I noticed that it works with built-in weapons and also Skaven's RACS units. But the HD units from the same addon would drop their weapons rightaway.

A quick check in the config files showed that the HD units use a mix of upper/lower case weapon and magazine class names (sth like "Ska_HD_Ak74Mag" e.g.). So the script expects to find magazines with this exact name in the unit's inventory (using "magazines <unit>"). However the comparison between config name and magazines command result seem to differ. If I debug the values through "unit sidechat" then everything is being put into upper case letters; if I use hintC then upper/lower case is being shown correctly - and it even displays config and magazine command class names to be identical  confused_o.gif  Nonetheless a comparison such as (a == b) results in FALSE so the weapons get dropped still. The same comparison works fine if all class names are defined upper case.

I looked at Skaven RACS class weapons and they're all defined in upper case letters - lo and behold that all works brilliant. The same goes for the built-in weapons.

I begin to believe this is the root cause for these issues - any ideas anybody?

Cheers,

VictorFarbau

Share this post


Link to post
Share on other sites

To sum up, your basic issue you wish to convey to the masses is, ArmA is a tempermental beast, and is cAsE-sEnSiTiVe.

I imagine a work around for this issue, would be for all addon-makers to agree on a standard for their class-name cases, much like the OFPEC Tagging and Naming conventions. i.e. Weapons should be defined entirely in UPPER-CASE.

Share this post


Link to post
Share on other sites
Quote[/b] ]your basic issue you wish to convey to the masses is, ArmA is a tempermental beast, and is cAsE-sEnSiTiVe.

I am more pragmatic than this. I am looking for a way to query configs in a way I can match data to the "weapons" and "magazines" commands within the scripting environment.

VictorFarbau

Share this post


Link to post
Share on other sites
Quote[/b] ]your basic issue you wish to convey to the masses is, ArmA is a tempermental beast, and is cAsE-sEnSiTiVe.

I am more pragmatic than this. I am still looking for a way to query configs in a way I can match data to the "weapons" and "magazines" commands within the scripting environment.

VictorFarbau

Share this post


Link to post
Share on other sites

Sprry, I misunderstood you, I thought you were just bringing the issue to light so addon-makers become aware of ArmA's case-sensitive nature. Sorry for the misunderstanding. However, the issue I raised, if you/anyone else are/is unable to come up with a solution, may be a viable alternative for future releases.

Share this post


Link to post
Share on other sites
Quote[/b] ]the issue I raised

You mean addon makers using only upper case names? Yeah, I would subscribe to that. I am still not sure why this fails occasionally since the built in "Strela" works fine for example. But after hours of scripting it's easy to miss out on something so I thought I'll pick on some brains here. Didn't work out yet wink_o.gif

Regards,

VictorFarbau

Share this post


Link to post
Share on other sites

IIRC, string comparison like this should be case INsensitive:

"blah" == "BLAH" -> result is true

String comparison inside of arrays should be case SENSITIVE:

"blah" in ["BLAH"] -> result is false

Another trick you might try is to compare class data types, instead of strings. For example:

(configFile >> "cfgMagazines" >> "blah") == (configFile >> "cfgMagazines" >> "BLAH") -> result should be true?

Hope that helps,

GB

Share this post


Link to post
Share on other sites

Thanks General, I will give that with the config entries a go in my next improvements round on VFAI!

Will definitely need to understand which comparisons are handled strict or non-strict when it comes to case sensitivity.

Regards,

VictorFarbau

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×