Refactor code that relies on the number of action args being exactly 5

This commit is contained in:
MascaraSnake 2022-12-28 23:04:32 +01:00
parent 51d56016f3
commit d29bd54034
22 changed files with 107 additions and 172 deletions

View file

@ -464,7 +464,7 @@ namespace CodeImp.DoomBuilder.Config
planeequationsupport = cfg.ReadSetting("planeequationsupport", false);
distinctfloorandceilingbrightness = cfg.ReadSetting("distinctfloorandceilingbrightness", false);
distinctwallbrightness = cfg.ReadSetting("distinctwallbrightness", false);
for (int i = 0; i < Linedef.NUM_ARGS; i++) makedoorargs[i] = cfg.ReadSetting("makedoorarg" + i.ToString(CultureInfo.InvariantCulture), 0);
for (int i = 0; i < makedoorargs.Length; i++) makedoorargs[i] = cfg.ReadSetting("makedoorarg" + i.ToString(CultureInfo.InvariantCulture), 0);
//mxd. Update map format flags
universalmapformat = (formatinterface == "UniversalMapSetIO");

View file

@ -122,7 +122,7 @@ namespace CodeImp.DoomBuilder.Config
this.errorcheckerexemptions.FloorRaiseToHighest = cfg.ReadSetting(actionsetting + ".errorchecker.floorraisetohighest", false);
// Read the args
for (int i = 0; i < Linedef.NUM_ARGS; i++)
for (int i = 0; i < this.args.Length; i++)
this.args[i] = new ArgumentInfo(cfg, actionsetting, i, enums);
// We have no destructor
@ -138,7 +138,7 @@ namespace CodeImp.DoomBuilder.Config
this.requiresactivation = true; //mxd. Unused, set for consistency sake.
this.title = title;
this.args = new ArgumentInfo[Linedef.NUM_ARGS];
for(int i = 0; i < Linedef.NUM_ARGS; i++)
for(int i = 0; i < this.args.Length; i++)
this.args[i] = new ArgumentInfo(i);
}

View file

@ -734,11 +734,8 @@ namespace CodeImp.DoomBuilder.Config
ThingTypeInfo tti = General.Map.Data.GetThingInfoEx(t.Type);
if(tti != null)
{
t.Args[0] = (int)tti.Args[0].DefaultValue;
t.Args[1] = (int)tti.Args[1].DefaultValue;
t.Args[2] = (int)tti.Args[2].DefaultValue;
t.Args[3] = (int)tti.Args[3].DefaultValue;
t.Args[4] = (int)tti.Args[4].DefaultValue;
for (int i = 0; i < t.Args.Length; i++)
t.Args[i] = (int)tti.Args[i].DefaultValue;
}
}
@ -764,11 +761,8 @@ namespace CodeImp.DoomBuilder.Config
ThingTypeInfo tti = General.Map.Data.GetThingInfoEx(t.Type);
if (tti != null)
{
t.Args[0] = (int)tti.Args[0].DefaultValue;
t.Args[1] = (int)tti.Args[1].DefaultValue;
t.Args[2] = (int)tti.Args[2].DefaultValue;
t.Args[3] = (int)tti.Args[3].DefaultValue;
t.Args[4] = (int)tti.Args[4].DefaultValue;
for (int i = 0; i < t.Args.Length; i++)
t.Args[i] = (int)tti.Args[i].DefaultValue;
}
}

View file

@ -261,7 +261,7 @@ namespace CodeImp.DoomBuilder.Config
}
// Read the args
for(int i = 0; i < Linedef.NUM_ARGS; i++)
for(int i = 0; i < this.args.Length; i++)
this.args[i] = new ArgumentInfo(cfg, "thingtypes." + cat.Name + "." + key, i, enums);
// Safety
@ -294,7 +294,7 @@ namespace CodeImp.DoomBuilder.Config
this.bright = false; //mxd
this.distancechecksq = double.MaxValue;
this.args = new ArgumentInfo[Linedef.NUM_ARGS];
for(int i = 0; i < Linedef.NUM_ARGS; i++) this.args[i] = new ArgumentInfo(i);
for(int i = 0; i < this.args.Length; i++) this.args[i] = new ArgumentInfo(i);
// Read properties
this.sprite = cat.Sprite;
@ -341,7 +341,7 @@ namespace CodeImp.DoomBuilder.Config
this.bright = false; //mxd
this.distancechecksq = double.MaxValue;
this.args = new ArgumentInfo[Linedef.NUM_ARGS];
for(int i = 0; i < Linedef.NUM_ARGS; i++) this.args[i] = new ArgumentInfo(i);
for(int i = 0; i < this.args.Length; i++) this.args[i] = new ArgumentInfo(i);
// Read properties
this.sprite = cat.Sprite;
@ -390,7 +390,7 @@ namespace CodeImp.DoomBuilder.Config
this.bright = false; //mxd
this.distancechecksq = double.MaxValue;
this.args = new ArgumentInfo[Linedef.NUM_ARGS];
for(int i = 0; i < Linedef.NUM_ARGS; i++) this.args[i] = new ArgumentInfo(i);
for(int i = 0; i < this.args.Length; i++) this.args[i] = new ArgumentInfo(i);
// Read properties
this.sprite = cat.Sprite;
@ -438,7 +438,7 @@ namespace CodeImp.DoomBuilder.Config
this.classname = other.classname; //mxd
this.isknown = true;
this.args = new ArgumentInfo[Linedef.NUM_ARGS];
for(int i = 0; i < Linedef.NUM_ARGS; i++)
for(int i = 0; i < this.args.Length; i++)
this.args[i] = other.args[i];
// Copy properties

View file

@ -45,6 +45,8 @@ namespace CodeImp.DoomBuilder.Controls
private int action;
private ArgumentInfo[] arginfo;
private ArgZeroMode argzeromode;
private Label[] labels;
private ArgumentBox[] args;
private ArgZeroMode Arg0Mode
{
get { return argzeromode; }
@ -64,6 +66,9 @@ namespace CodeImp.DoomBuilder.Controls
InitializeComponent();
Reset();
labels = new Label[] { arg0label, arg1label, arg2label, arg3label, arg4label };
args = new ArgumentBox[] { arg0, arg1, arg2, arg3, arg4 };
}
#endregion
@ -89,7 +94,7 @@ namespace CodeImp.DoomBuilder.Controls
SetValue(t.Fields, t.Args, first);
}
private void SetValue(UniFields fields, int[] args, bool first)
private void SetValue(UniFields fields, int[] newargs, bool first)
{
if(first)
{
@ -100,11 +105,8 @@ namespace CodeImp.DoomBuilder.Controls
}
// Update arguments
arg0.SetValue(args[0]);
arg1.SetValue(args[1]);
arg2.SetValue(args[2]);
arg3.SetValue(args[3]);
arg4.SetValue(args[4]);
for (int i = 0; i < args.Length; i++)
args[i].SetValue(newargs[i]);
}
else
{
@ -118,11 +120,8 @@ namespace CodeImp.DoomBuilder.Controls
}
// Update arguments
if(!string.IsNullOrEmpty(arg0.Text) && args[0] != arg0.GetResult(int.MinValue)) arg0.ClearValue();
if(!string.IsNullOrEmpty(arg1.Text) && args[1] != arg1.GetResult(int.MinValue)) arg1.ClearValue();
if(!string.IsNullOrEmpty(arg2.Text) && args[2] != arg2.GetResult(int.MinValue)) arg2.ClearValue();
if(!string.IsNullOrEmpty(arg3.Text) && args[3] != arg3.GetResult(int.MinValue)) arg3.ClearValue();
if(!string.IsNullOrEmpty(arg4.Text) && args[4] != arg4.GetResult(int.MinValue)) arg4.ClearValue();
for (int i = 0; i < args.Length; i++)
if (!string.IsNullOrEmpty(args[i].Text) && newargs[i] != args[i].GetResult(int.MinValue)) args[i].ClearValue();
}
}
@ -178,10 +177,8 @@ namespace CodeImp.DoomBuilder.Controls
}
// Apply the rest of args
l.Args[1] = arg1.GetResult(l.Args[1], step);
l.Args[2] = arg2.GetResult(l.Args[2], step);
l.Args[3] = arg3.GetResult(l.Args[3], step);
l.Args[4] = arg4.GetResult(l.Args[4], step);
for (int i = 1; i < args.Length; i++)
l.Args[i] = args[i].GetResult(l.Args[i], step);
}
public void Apply(Thing t, int step)
@ -232,10 +229,8 @@ namespace CodeImp.DoomBuilder.Controls
}
// Apply the rest of args
t.Args[1] = arg1.GetResult(t.Args[1], step);
t.Args[2] = arg2.GetResult(t.Args[2], step);
t.Args[3] = arg3.GetResult(t.Args[3], step);
t.Args[4] = arg4.GetResult(t.Args[4], step);
for (int i = 1; i < args.Length; i++)
t.Args[i] = args[i].GetResult(t.Args[i], step);
}
#endregion
@ -269,30 +264,21 @@ namespace CodeImp.DoomBuilder.Controls
// Change the argument descriptions
this.BeginUpdate();
UpdateArgument(arg0, arg0label, arginfo[0]);
UpdateArgument(arg1, arg1label, arginfo[1]);
UpdateArgument(arg2, arg2label, arginfo[2]);
UpdateArgument(arg3, arg3label, arginfo[3]);
UpdateArgument(arg4, arg4label, arginfo[4]);
for (int i = 0; i < args.Length; i++)
UpdateArgument(args[i], labels[i], arginfo[i]);
if(!setuponly)
{
// Apply action's or thing's default arguments
if(showaction != 0 || info != null)
{
arg0.SetDefaultValue();
arg1.SetDefaultValue();
arg2.SetDefaultValue();
arg3.SetDefaultValue();
arg4.SetDefaultValue();
for (int i = 0; i < args.Length; i++)
args[i].SetDefaultValue();
}
else //or set them to 0
{
arg0.SetValue(0);
arg1.SetValue(0);
arg2.SetValue(0);
arg3.SetValue(0);
arg4.SetValue(0);
for (int i = 0; i < args.Length; i++)
args[i].SetValue(0);
}
// arg0str currently can't have any default
arg0named.Text = arg0strval = " ";
@ -436,8 +422,6 @@ namespace CodeImp.DoomBuilder.Controls
private void UpdateScriptArguments(ScriptItem item)
{
Label[] labels = { arg0label, arg1label, arg2label, arg3label, arg4label };
ArgumentBox[] args = { arg0, arg1, arg2, arg3, arg4 };
if(item != null)
{
int first;

View file

@ -36,6 +36,8 @@ namespace CodeImp.DoomBuilder.Controls
{
private readonly int hexenformatwidth;
private readonly int doomformatwidth;
private Label[] arglabels;
private Label[] args;
// Constructor
public LinedefInfoPanel()
@ -48,6 +50,9 @@ namespace CodeImp.DoomBuilder.Controls
hexenformatwidth = infopanel.Width;
doomformatwidth = infopanel.Width - 190;
arglabels = new Label[] { arglbl1, arglbl2, arglbl3, arglbl4, arglbl5 };
args = new Label[] { arg1, arg2, arg3, arg4, arg5 };
// We have to set the parernt (and subsequently the new location relative to the parent) here since
// we can't set the parent in the designer. And if the parent is not set to the ConfigurablePictureBox
// the Label's background alpha will not work correctly
@ -80,34 +85,13 @@ namespace CodeImp.DoomBuilder.Controls
string peggedness;
// Show/hide stuff depending on format
if(!General.Map.FormatInterface.HasActionArgs)
bool hasArgs = General.Map.FormatInterface.HasActionArgs;
for (int i = 0; i < args.Length; i++)
{
arglbl1.Visible = false;
arglbl2.Visible = false;
arglbl3.Visible = false;
arglbl4.Visible = false;
arglbl5.Visible = false;
arg1.Visible = false;
arg2.Visible = false;
arg3.Visible = false;
arg4.Visible = false;
arg5.Visible = false;
infopanel.Width = doomformatwidth;
}
else
{
arglbl1.Visible = true;
arglbl2.Visible = true;
arglbl3.Visible = true;
arglbl4.Visible = true;
arglbl5.Visible = true;
arg1.Visible = true;
arg2.Visible = true;
arg3.Visible = true;
arg4.Visible = true;
arg5.Visible = true;
infopanel.Width = hexenformatwidth;
arglabels[i].Visible = hasArgs;
args[i].Visible = hasArgs;
}
infopanel.Width = (hasArgs ? hexenformatwidth : doomformatwidth);
//mxd. Hide activation or tag and rearrange labels
if(!General.Map.FormatInterface.HasBuiltInActivations && General.Map.FormatInterface.HasNumericLinedefActivations) //Hexen map format?
@ -251,9 +235,6 @@ namespace CodeImp.DoomBuilder.Controls
}
// Apply script args?
Label[] arglabels = { arglbl1, arglbl2, arglbl3, arglbl4, arglbl5 };
Label[] args = { arg1, arg2, arg3, arg4, arg5 };
if(scriptitem != null)
{
int first;
@ -302,10 +283,8 @@ namespace CodeImp.DoomBuilder.Controls
//mxd. Set argument value and label
if(isarg0str) arg1.Text = arg0str;
else SetArgumentText(act.Args[0], arg1, l.Args[0]);
SetArgumentText(act.Args[1], arg2, l.Args[1]);
SetArgumentText(act.Args[2], arg3, l.Args[2]);
SetArgumentText(act.Args[3], arg4, l.Args[3]);
SetArgumentText(act.Args[4], arg5, l.Args[4]);
for (int i = 1; i < args.Length; i++)
SetArgumentText(act.Args[i], args[i], l.Args[i]);
// Front side available?
if(l.Front != null)

View file

@ -36,6 +36,8 @@ namespace CodeImp.DoomBuilder.Controls
{
private readonly int hexenformatwidth;
private readonly int doomformatwidth;
private Label[] arglabels;
private Label[] args;
// Constructor
public ThingInfoPanel()
@ -47,6 +49,9 @@ namespace CodeImp.DoomBuilder.Controls
// Hide stuff when in Doom format
hexenformatwidth = infopanel.Width;
doomformatwidth = infopanel.Width - 190;
arglabels = new Label[] { arglbl1, arglbl2, arglbl3, arglbl4, arglbl5 };
args = new Label[] { arg1, arg2, arg3, arg4, arg5 };
}
// This shows the info
@ -54,16 +59,11 @@ namespace CodeImp.DoomBuilder.Controls
{
// Show/hide stuff depending on format
bool hasArgs = General.Map.FormatInterface.HasActionArgs;
arglbl1.Visible = hasArgs;
arglbl2.Visible = hasArgs;
arglbl3.Visible = hasArgs;
arglbl4.Visible = hasArgs;
arglbl5.Visible = hasArgs;
arg1.Visible = hasArgs;
arg2.Visible = hasArgs;
arg3.Visible = hasArgs;
arg4.Visible = hasArgs;
arg5.Visible = hasArgs;
for (int i = 0; i < args.Length; i++)
{
arglabels[i].Visible = hasArgs;
args[i].Visible = hasArgs;
}
infopanel.Width = (hasArgs ? hexenformatwidth : doomformatwidth);
//mxd
@ -158,9 +158,6 @@ namespace CodeImp.DoomBuilder.Controls
}
// Apply script args?
Label[] arglabels = { arglbl1, arglbl2, arglbl3, arglbl4, arglbl5 };
Label[] args = { arg1, arg2, arg3, arg4, arg5 };
if (scriptitem != null)
{
int first;
@ -209,10 +206,8 @@ namespace CodeImp.DoomBuilder.Controls
//mxd. Set argument value and label
if (isarg0str) arg1.Text = arg0str;
else SetArgumentText(act.Args[0], arg1, t.Args[0]);
SetArgumentText(arginfo[1], arg2, t.Args[1]);
SetArgumentText(arginfo[2], arg3, t.Args[2]);
SetArgumentText(arginfo[3], arg4, t.Args[3]);
SetArgumentText(arginfo[4], arg5, t.Args[4]);
for (int i = 1; i < args.Length; i++)
SetArgumentText(arginfo[i], args[i], t.Args[i]);
//mxd. Flags
flags.Items.Clear();

View file

@ -93,7 +93,7 @@ namespace CodeImp.DoomBuilder.Editing
internal int ThingAngle { get { return thingangle; } set { thingangle = value; } }
internal int ThingZHeight { get { return thingzheight; } set { thingzheight = value; } }
internal int ThingAction { get { return thingaction; } set { thingaction = value; } }
internal int[] ThingArgs { get { return thingargs; } set { Array.Copy(value, thingargs, Thing.NUM_ARGS); } }
internal int[] ThingArgs { get { return thingargs; } set { Array.Copy(value, thingargs, thingargs.Length); } }
internal int ThingTag { get { return thingtag; } set { thingtag = value; } }
internal UniFields ThingCustomFields { get { return customfields; } set { customfields = new UniFields(value); } }
internal ICollection<string> RequiredFields { get { return requiredfields; } }
@ -120,7 +120,7 @@ namespace CodeImp.DoomBuilder.Editing
thingangle = f.thingangle;
thingaction = f.thingaction;
thingargs = new int[Thing.NUM_ARGS];
Array.Copy(f.thingargs, thingargs, Thing.NUM_ARGS);
Array.Copy(f.thingargs, thingargs, thingargs.Length);
thingtag = f.thingtag;
customfields = new UniFields(f.customfields);
requiredfields = new List<string>(f.requiredfields);
@ -150,7 +150,7 @@ namespace CodeImp.DoomBuilder.Editing
thingangle = cfg.ReadSetting(path + ".angle", -1);
thingzheight = cfg.ReadSetting(path + ".zheight", int.MinValue);
thingaction = cfg.ReadSetting(path + ".action", -1);
for(int i = 0; i < Thing.NUM_ARGS; i++)
for(int i = 0; i < thingargs.Length; i++)
thingargs[i] = cfg.ReadSetting(path + ".arg" + i.ToString(CultureInfo.InvariantCulture), -1);
thingtag = cfg.ReadSetting(path + ".tag", -1);
@ -194,7 +194,7 @@ namespace CodeImp.DoomBuilder.Editing
thingzheight = int.MinValue;
thingaction = -1;
thingargs = new int[Thing.NUM_ARGS];
for(int i = 0 ; i < Thing.NUM_ARGS; i++) thingargs[i] = -1;
for(int i = 0 ; i < thingargs.Length; i++) thingargs[i] = -1;
thingtag = -1;
name = DEFAULT_NAME;
@ -233,7 +233,7 @@ namespace CodeImp.DoomBuilder.Editing
if(!General.Map.FormatInterface.HasThingTag) thingtag = -1;
if(!General.Map.FormatInterface.HasActionArgs)
{
for(int i = 0; i < Thing.NUM_ARGS; i++) thingargs[i] = -1;
for(int i = 0; i < thingargs.Length; i++) thingargs[i] = -1;
}
if(!General.Map.FormatInterface.HasCustomFields) customfields.Clear();
}
@ -309,7 +309,7 @@ namespace CodeImp.DoomBuilder.Editing
cfg.WriteSetting(path + ".angle", thingangle);
cfg.WriteSetting(path + ".zheight", thingzheight);
cfg.WriteSetting(path + ".action", thingaction);
for(int i = 0; i < Thing.NUM_ARGS; i++)
for(int i = 0; i < thingargs.Length; i++)
cfg.WriteSetting(path + ".arg" + i.ToString(CultureInfo.InvariantCulture), thingargs[i]);
cfg.WriteSetting(path + ".tag", thingtag);
@ -369,7 +369,7 @@ namespace CodeImp.DoomBuilder.Editing
qualifies &= (thingzheight == int.MinValue) || ((int)(t.Position.z) == thingzheight);
qualifies &= (thingaction == -1) || (t.Action == thingaction);
qualifies &= (thingtag == -1) || (t.Tag == thingtag);
for(int i = 0; i < Thing.NUM_ARGS; i++)
for(int i = 0; i < thingargs.Length; i++)
qualifies &= (thingargs[i] == -1) || (t.Args[i] == thingargs[i]);
// Still qualifies?

View file

@ -2087,7 +2087,7 @@ namespace CodeImp.DoomBuilder.Geometry
if(t.Marked)
{
t.Action = 0;
for(int i = 0; i < Thing.NUM_ARGS; i++) t.Args[i] = 0;
for(int i = 0; i < t.Args.Length; i++) t.Args[i] = 0;
}
}
@ -2097,7 +2097,7 @@ namespace CodeImp.DoomBuilder.Geometry
if(l.Marked)
{
l.Action = 0;
for(int i = 0; i < Linedef.NUM_ARGS; i++) l.Args[i] = 0;
for(int i = 0; i < l.Args.Length; i++) l.Args[i] = 0;
}
}
}

View file

@ -214,7 +214,7 @@ namespace CodeImp.DoomBuilder.IO
int s1 = reader.ReadInt32();
int s2 = reader.ReadInt32();
int special = reader.ReadInt32();
for(int a = 0; a < Linedef.NUM_ARGS; a++) args[a] = reader.ReadInt32();
for(int a = 0; a < args.Length; a++) args[a] = reader.ReadInt32();
int numtags = reader.ReadInt32(); //mxd
List<int> tags = new List<int>(numtags); //mxd
for(int a = 0; a < numtags; a++) tags.Add(reader.ReadInt32()); //mxd
@ -362,7 +362,7 @@ namespace CodeImp.DoomBuilder.IO
double scaleY = reader.ReadDouble(); //mxd
int type = reader.ReadInt32();
int special = reader.ReadInt32();
for(int a = 0; a < Linedef.NUM_ARGS; a++) args[a] = reader.ReadInt32();
for(int a = 0; a < args.Length; a++) args[a] = reader.ReadInt32();
//flags
Dictionary<string, bool> stringflags = new Dictionary<string, bool>(StringComparer.Ordinal);

View file

@ -194,11 +194,8 @@ namespace CodeImp.DoomBuilder.IO
double scale = GetCollectionEntry(c, "scale", false, 0.0, where); //mxd
int type = GetCollectionEntry(c, "type", true, 0, where);
int special = GetCollectionEntry(c, "special", false, 0, where);
args[0] = GetCollectionEntry(c, "arg0", false, 0, where);
args[1] = GetCollectionEntry(c, "arg1", false, 0, where);
args[2] = GetCollectionEntry(c, "arg2", false, 0, where);
args[3] = GetCollectionEntry(c, "arg3", false, 0, where);
args[4] = GetCollectionEntry(c, "arg4", false, 0, where);
for (int j = 0; j < args.Length; j++)
args[j] = GetCollectionEntry(c, "arg" + j, false, 0, where);
if(scale != 0) //mxd
{
@ -256,11 +253,8 @@ namespace CodeImp.DoomBuilder.IO
int tag = GetCollectionEntry(lc, "id", false, 0, where);
int special = GetCollectionEntry(lc, "special", false, 0, where);
args[0] = GetCollectionEntry(lc, "arg0", false, 0, where);
args[1] = GetCollectionEntry(lc, "arg1", false, 0, where);
args[2] = GetCollectionEntry(lc, "arg2", false, 0, where);
args[3] = GetCollectionEntry(lc, "arg3", false, 0, where);
args[4] = GetCollectionEntry(lc, "arg4", false, 0, where);
for (int j = 0; j < args.Length; j++)
args[j] = GetCollectionEntry(lc, "arg" + j, false, 0, where);
int s1 = GetCollectionEntry(lc, "sidefront", false, -1, where);
int s2 = GetCollectionEntry(lc, "sideback", false, -1, where);

View file

@ -224,11 +224,10 @@ namespace CodeImp.DoomBuilder.IO
// Special
if(l.Action != 0) coll.Add("special", l.Action);
if(l.Args[0] != 0) coll.Add("arg0", l.Args[0]);
if(l.Args[1] != 0) coll.Add("arg1", l.Args[1]);
if(l.Args[2] != 0) coll.Add("arg2", l.Args[2]);
if(l.Args[3] != 0) coll.Add("arg3", l.Args[3]);
if(l.Args[4] != 0) coll.Add("arg4", l.Args[4]);
for (int i = 0; i < l.Args.Length; i++)
{
if (l.Args[i] != 0) coll.Add("arg" + i, l.Args[i]);
}
// Flags
foreach(KeyValuePair<string, bool> flag in l.Flags)
@ -346,11 +345,10 @@ namespace CodeImp.DoomBuilder.IO
if(t.ScaleY != 0 && t.ScaleY != 1.0f) coll.Add("scaley", t.ScaleY); //mxd
coll.Add("type", t.Type);
if(t.Action != 0) coll.Add("special", t.Action);
if(t.Args[0] != 0) coll.Add("arg0", t.Args[0]);
if(t.Args[1] != 0) coll.Add("arg1", t.Args[1]);
if(t.Args[2] != 0) coll.Add("arg2", t.Args[2]);
if(t.Args[3] != 0) coll.Add("arg3", t.Args[3]);
if(t.Args[4] != 0) coll.Add("arg4", t.Args[4]);
for (int i = 0; i < t.Args.Length; i++)
{
if (t.Args[i] != 0) coll.Add("arg" + i, t.Args[i]);
}
coll.Comment = t.Index.ToString();
// Flags

View file

@ -247,7 +247,7 @@ namespace CodeImp.DoomBuilder.Map
}
}
for(int i = 0; i < NUM_ARGS; i++) s.rwInt(ref args[i]);
for(int i = 0; i < args.Length; i++) s.rwInt(ref args[i]);
//mxd
if(!s.IsWriting) UpdateColorPreset();

View file

@ -3923,7 +3923,7 @@ namespace CodeImp.DoomBuilder.Map
if(t.Marked == marked)
{
LinedefActionInfo info = General.Map.Config.GetLinedefActionInfo(t.Action);
for(int i = 0; i < Thing.NUM_ARGS; i++)
for(int i = 0; i < info.Args.Length; i++)
{
if(info.Args[i].Used && CheckIsTagType(info.Args[i].Type))
{
@ -3971,7 +3971,7 @@ namespace CodeImp.DoomBuilder.Map
if(l.Marked == marked)
{
LinedefActionInfo info = General.Map.Config.GetLinedefActionInfo(l.Action);
for(int i = 0; i < Linedef.NUM_ARGS; i++)
for(int i = 0; i < info.Args.Length; i++)
{
if(info.Args[i].Used && CheckIsTagType(info.Args[i].Type))
{

View file

@ -220,7 +220,7 @@ namespace CodeImp.DoomBuilder.Map
s.rwDouble(ref scaleY); //mxd
s.rwInt(ref tag);
s.rwInt(ref action);
for(int i = 0; i < NUM_ARGS; i++) s.rwInt(ref args[i]);
for(int i = 0; i < args.Length; i++) s.rwInt(ref args[i]);
if(!s.IsWriting)
{

View file

@ -319,7 +319,7 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
{
sd.Line.Action = 0;
for (int i = 0; i < 5; i++)
for (int i = 0; i < sd.Line.Args.Length; i++)
sd.Line.Args[i] = 0;
}

View file

@ -1884,7 +1884,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
// Set the linedef args
for(int i = 0; i < Linedef.NUM_ARGS; i++)
for(int i = 0; i < General.Map.Config.MakeDoorArgs.Length; i++)
{
// A -1 arg indicates that the arg must be set to the new sector tag
// and only in this case we set the tag on the sector, because only

View file

@ -91,7 +91,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(info.IsKnown && !info.IsNull)
{
// Go for all args
for(int i = 0; i < Linedef.NUM_ARGS; i++)
for(int i = 0; i < info.Args.Length; i++)
{
// Argument type matches?
if(info.Args[i].Used && (info.Args[i].Type == (int)UniversalType.SectorTag))

View file

@ -91,7 +91,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(info.IsKnown && !info.IsNull)
{
// Go for all args
for(int i = 0; i < Linedef.NUM_ARGS; i++)
for(int i = 0; i < info.Args.Length; i++)
{
// Argument type matches?
if(info.Args[i].Used && (info.Args[i].Type == (int)UniversalType.ThingTag))

View file

@ -94,7 +94,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(info.IsKnown && !info.IsNull)
{
// Go for all args
for(int i = 0; i < Linedef.NUM_ARGS; i++)
for(int i = 0; i < info.Args.Length; i++)
{
// Argument type matches?
if(info.Args[i].Used && (info.Args[i].Type == (int)UniversalType.SectorTag))

View file

@ -94,7 +94,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(info.IsKnown && !info.IsNull)
{
// Go for all args
for(int i = 0; i < Linedef.NUM_ARGS; i++)
for(int i = 0; i < info.Args.Length; i++)
{
// Argument type matches?
if(info.Args[i].Used && (info.Args[i].Type == (int)UniversalType.ThingTag))

View file

@ -525,7 +525,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
// Collect what map element the action arguments are referencing. Ignore the argument if it's 0, so that they
// are not associated to everything untagged
for (int i = 0; i < Linedef.NUM_ARGS; i++)
for (int i = 0; i < action.Args.Length; i++)
{
if ((action.Args[i].Type == (int)UniversalType.SectorTag ||
action.Args[i].Type == (int)UniversalType.LinedefTag ||
@ -548,7 +548,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if (ti != null && directlinktype >= 0 && Math.Abs(directlinktype) != t.Type)
{
for (int i = 0; i < Linedef.NUM_ARGS; i++)
for (int i = 0; i < ti.Args.Length; i++)
{
if ((ti.Args[i].Type == (int)UniversalType.SectorTag ||
ti.Args[i].Type == (int)UniversalType.LinedefTag ||
@ -585,12 +585,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
if ((linedef.Action > 0) && General.Map.Config.LinedefActions.ContainsKey(linedef.Action))
{
LinedefActionInfo action = General.Map.Config.LinedefActions[linedef.Action];
if (((action.Args[0].Type == (int)type) && (linedef.Args[0] != 0) && (tags.Contains(linedef.Args[0]))) ||
((action.Args[1].Type == (int)type) && (linedef.Args[1] != 0) && (tags.Contains(linedef.Args[1]))) ||
((action.Args[2].Type == (int)type) && (linedef.Args[2] != 0) && (tags.Contains(linedef.Args[2]))) ||
((action.Args[3].Type == (int)type) && (linedef.Args[3] != 0) && (tags.Contains(linedef.Args[3]))) ||
((action.Args[4].Type == (int)type) && (linedef.Args[4] != 0) && (tags.Contains(linedef.Args[4]))))
for (int i = 0; i < action.Args.Length; i++)
{
if ((action.Args[i].Type == (int)type) && (linedef.Args[i] != 0) && (tags.Contains(linedef.Args[i])))
return true;
}
}
@ -617,12 +614,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
return false;
LinedefActionInfo action = General.Map.Config.LinedefActions[thing.Action];
if (((action.Args[0].Type == (int)type) && (tags.Contains(thing.Args[0]))) ||
((action.Args[1].Type == (int)type) && (tags.Contains(thing.Args[1]))) ||
((action.Args[2].Type == (int)type) && (tags.Contains(thing.Args[2]))) ||
((action.Args[3].Type == (int)type) && (tags.Contains(thing.Args[3]))) ||
((action.Args[4].Type == (int)type) && (tags.Contains(thing.Args[4]))))
for (int i = 0; i < ti.Args.Length; i++)
{
if ((action.Args[i].Type == (int)type) && (tags.Contains(thing.Args[i])))
return true;
}
@ -639,12 +633,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
// This prevents a reverse link to a thing via an argument, when it should be a direct tag-to-tag link instead.
if (ti != null && directlinktype >= 0 && Math.Abs(directlinktype) != thing.Type)
{
if (((ti.Args[0].Type == (int)type) && (tags.Contains(thing.Args[0]))) ||
((ti.Args[1].Type == (int)type) && (tags.Contains(thing.Args[1]))) ||
((ti.Args[2].Type == (int)type) && (tags.Contains(thing.Args[2]))) ||
((ti.Args[3].Type == (int)type) && (tags.Contains(thing.Args[3]))) ||
((ti.Args[4].Type == (int)type) && (tags.Contains(thing.Args[4]))))
for (int i = 0; i < ti.Args.Length; i++)
{
if ((ti.Args[i].Type == (int)type) && (tags.Contains(thing.Args[i])))
return true;
}
}