Game configuration: fixed a crash when using enums for universal field definitions

GZDoom game configuration: added enum list for the automapstyle UDMF linedef field
This commit is contained in:
biwa 2022-01-23 19:02:45 +01:00
parent 1b69dbe795
commit 8536eb1d95
2 changed files with 41 additions and 19 deletions

View file

@ -332,8 +332,24 @@ universalfields
automapstyle
{
type = 0;
type = 11;
default = 0;
enum
{
0 = "Default";
1 = "One-sided wall";
2 = "Two-sided wall";
3 = "Floor levels of front and back sectors are different";
4 = "Ceiling levels of front and back sectors are different";
5 = "3D floor border";
6 = "Wall with special non-door action";
7 = "Wall not seen yet";
9 = "Locked door";
10 = "Intra-level teleporter";
11 = "Inter-level or game-ending teleporter";
12 = "Unexplored secret wall";
13 = "Portal line";
}
}
arg0str

View file

@ -90,13 +90,36 @@ namespace CodeImp.DoomBuilder.Config
this.type = cfg.ReadSetting(setting + ".type", int.MinValue);
this.defaultvalue = cfg.ReadSettingObject(setting + ".default", null);
// Read enum
object enumsetting = cfg.ReadSettingObject(setting + ".enum", null);
if (enumsetting != null)
{
// Reference to existing enums list?
if (enumsetting is string)
{
// Link to it
enumlist = enums[enumsetting.ToString()];
}
else if (enumsetting is IDictionary)
{
// Make list
enumlist = new EnumList(enumsetting as IDictionary);
}
}
//mxd. Check type
if(this.type == int.MinValue)
if (this.type == int.MinValue)
{
General.ErrorLogger.Add(ErrorType.Warning, "No type is defined for universal field \"" + name + "\" defined in \"" + configname + "\". Integer type will be used.");
this.type = (int)UniversalType.Integer;
}
if(type == (int)UniversalType.EnumOption && enumsetting == null)
{
General.ErrorLogger.Add(ErrorType.Warning, "Universal field \"" + name + "\" defined in \"" + configname + "\" is of type enum (" + this.type + "), but has no enum values set. Falling back to integer type");
type = (int)UniversalType.Integer;
}
TypeHandler th = General.Types.GetFieldHandler(this);
if(th is NullHandler)
{
@ -107,23 +130,6 @@ namespace CodeImp.DoomBuilder.Config
//mxd. Default value is missing? Get it from typehandler
if(this.defaultvalue == null) this.defaultvalue = th.GetDefaultValue();
// Read enum
object enumsetting = cfg.ReadSettingObject(setting + ".enum", null);
if(enumsetting != null)
{
// Reference to existing enums list?
if(enumsetting is string)
{
// Link to it
enumlist = enums[enumsetting.ToString()];
}
else if(enumsetting is IDictionary)
{
// Make list
enumlist = new EnumList(enumsetting as IDictionary);
}
}
// Read associations
IDictionary assocdict = cfg.ReadSetting(setting + ".associations", new Hashtable());