1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 17:19:56 +00:00
openmw-tes3mp/scene/gamesettings.d
nkorslund 714b724bf2 - added -debug option
- removed all logging and output per default
- updated to latest monster, bullet and ogre versions


git-svn-id: https://openmw.svn.sourceforge.net/svnroot/openmw/trunk@102 ea6a568a-9f4f-0410-981a-c910a81bb256
2009-05-09 16:08:00 +00:00

47 lines
1.4 KiB
D

module scene.gamesettings;
import monster.monster;
import esm.records : gameSettings;
import esm.defs : VarType;
import std.stdio;
import std.string;
MonsterObject *gmstObj;
void loadGameSettings()
{
// Load the GameSettings Monster class, and get the singleton
// instance
MonsterClass mc = vm.load("GMST");
gmstObj = mc.getSing();
foreach(a, b; gameSettings.names)
{
assert(a == b.id);
assert(a[0] == 'i' || a[0] == 'f' || a[0] == 's');
// There's three cases of variable names containing
// spaces. Since these are so seldom, it makes more sense to
// make special workarounds for them instead of searching every
// string.
char[] name = a;
if(name.length > 13 && (name[6] == ' ' || name[5] == ' '))
{
name = name.replace(" ", "_");
// Make sure we don't change the original string!
assert(name != a);
}
if(!mc.sc.lookupName(name).isVar)
{
writefln("WARNING: GMST %s not supported!", name);
continue;
}
if(b.type == VarType.Int) gmstObj.setInt(name, b.i);
else if(b.type == VarType.Float) gmstObj.setFloat(name, b.f);
// TODO: At some point we will probably translate strings into
// UTF32 at load time, so string8 will not be needed here.
else if(b.type == VarType.String) gmstObj.setString8(name, b.str);
}
}