mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-02-17 01:22:18 +00:00
Added: basic support for automatic user variables from ZScript classes, currently only for int variables (as supported by GZDoom).
This commit is contained in:
parent
0d43a7be12
commit
1382d144fe
4 changed files with 79 additions and 6 deletions
|
@ -30,6 +30,6 @@ using CodeImp.DoomBuilder;
|
|||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("2.3.0.2866")]
|
||||
[assembly: AssemblyVersion("2.3.0.2872")]
|
||||
[assembly: NeutralResourcesLanguageAttribute("en")]
|
||||
[assembly: AssemblyHash("34d1af9")]
|
||||
[assembly: AssemblyHash("0d43a7b")]
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using CodeImp.DoomBuilder.Types;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
@ -443,7 +444,7 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
while (true)
|
||||
{
|
||||
string name = null;
|
||||
int arraylen = 0;
|
||||
int arraylen = -1;
|
||||
|
||||
// read in the method/field name
|
||||
tokenizer.SkipWhitespace();
|
||||
|
@ -586,9 +587,53 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
|
||||
string _args = "";
|
||||
if (args != null) _args = " (" + ZScriptTokenizer.TokensToString(args) + ")";
|
||||
else if (arraylen != 0) _args = " [" + arraylen.ToString() + "]";
|
||||
else if (arraylen != -1) _args = " [" + arraylen.ToString() + "]";
|
||||
parser.LogWarning(string.Format("{0} {1} {2}{3}", string.Join(" ", modifiers.ToArray()), string.Join(", ", types.ToArray()), name, _args));
|
||||
}*/
|
||||
|
||||
// update 08.02.17: add user variables from ZScript actors.
|
||||
if (args == null && types.Count == 1) // it's a field
|
||||
{
|
||||
// we support:
|
||||
// - float
|
||||
// - int
|
||||
// - double
|
||||
// - bool
|
||||
string type = types[0];
|
||||
UniversalType utype;
|
||||
switch (type)
|
||||
{
|
||||
case "int":
|
||||
utype = UniversalType.Integer;
|
||||
break;
|
||||
/*case "float":
|
||||
case "double":
|
||||
utype = UniversalType.Float;
|
||||
break;
|
||||
case "bool":
|
||||
utype = UniversalType.Integer;
|
||||
break;
|
||||
case "string":
|
||||
utype = UniversalType.String;
|
||||
break;
|
||||
// todo test if class names and colors will work*/
|
||||
// [ZZ] currently only integer variable works.
|
||||
default:
|
||||
continue; // go read next field
|
||||
}
|
||||
|
||||
for (int i = 0; i < names.Count; i++)
|
||||
{
|
||||
string name = names[i];
|
||||
int arraylen = arraylens[i];
|
||||
if (arraylen != -1)
|
||||
continue; // we don't process arrays
|
||||
if (!name.StartsWith("user_"))
|
||||
continue; // we don't process non-user_ fields (because ZScript won't pick them up anyway)
|
||||
// parent class is not guaranteed to be loaded already, so handle collisions later
|
||||
uservars.Add(name, utype);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -883,6 +883,10 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
return false;
|
||||
}
|
||||
|
||||
// set datastream to null so that log messages aren't output using incorrect line numbers
|
||||
Stream odatastream = datastream;
|
||||
datastream = null;
|
||||
|
||||
// inject superclasses, since everything is parsed by now
|
||||
Dictionary<int, ThingTypeInfo> things = General.Map.Config.GetThingTypes();
|
||||
foreach (ZScriptClassStructure cls in allclasseslist)
|
||||
|
@ -930,6 +934,30 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
}
|
||||
}
|
||||
|
||||
// validate user variables (no variables should shadow parent variables)
|
||||
foreach (ZScriptClassStructure cls in allclasseslist)
|
||||
{
|
||||
ActorStructure actor = cls.Actor;
|
||||
if (actor == null)
|
||||
continue;
|
||||
ActorStructure actorbase = actor.baseclass;
|
||||
while (actorbase != null)
|
||||
{
|
||||
foreach (string uservar in actor.uservars.Keys)
|
||||
{
|
||||
if (actorbase.uservars.ContainsKey(uservar))
|
||||
{
|
||||
actor.uservars.Clear();
|
||||
ReportError("Variable \"" + uservar + "\" in class \"" + actor.classname + "\" shadows variable \"" + uservar + "\" in base class \"" + actorbase.classname + "\". This is not supported");
|
||||
goto stopValidatingCompletely;
|
||||
}
|
||||
}
|
||||
|
||||
actorbase = actorbase.baseclass;
|
||||
}
|
||||
}
|
||||
stopValidatingCompletely:
|
||||
datastream = odatastream;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,5 +29,5 @@ using System.Resources;
|
|||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("2.3.0.2866")]
|
||||
[assembly: AssemblyVersion("2.3.0.2872")]
|
||||
[assembly: NeutralResourcesLanguageAttribute("en")]
|
||||
|
|
Loading…
Reference in a new issue