How to copy CfgElemRef into struct?
Posted: Mon Aug 06, 2007 2:02 am
I have a config file which contains object (spell) properties:
Some properties are not mandatory, they are present only if I want to override default setting. I read the entry using
cspell now contains something named ConfigElemRef. It's the config element. I can access cspell's properties like I'd do with struct: cspell.Animation for example. It's not a struct however. Since I want to change some values from symbolic values (like Animation - "Target") into numeric (0x10), I need to be able to modify values. "Ok", I thought, "let's copy it into real struct". Sounds easy, but as hard as I tried, I found it impossible to do.
There is a function ListConfigElemProps which returns names of all element's properties. Good. But How do I read specific property in a generic way when I don't know its type and there are only type-specific functions like GetConfigString or GetConfigInt? I'd do something like
... but it can't be done in a generic way unless I'm missing something obvious. Any help would be appreciated.
Code: Select all
Spell 1
{
Name Ultimate Spell Of Mass Destruction
PowerWords Kal Vas Mon Ty Pyt Hon
ManaCost 50
Difficulty 50
CastType Normal
TargetType Mobile
Notoriety Harmful
ResistType Damage
Animation Target
Sound 0x209
CastCycles 4
CycleDuration 800
}Code: Select all
var spellcfg := ReadConfigFile(":NpcSpells:NpcSpells");
var cspell := spellcfg[id];There is a function ListConfigElemProps which returns names of all element's properties. Good. But How do I read specific property in a generic way when I don't know its type and there are only type-specific functions like GetConfigString or GetConfigInt? I'd do something like
Code: Select all
var spell := struct;
foreach prop in (ListConfigElemProps(cspell))
spell.Insert(prop, GetConfigXXX(cspell, prop));
endforeach