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); planeequationsupport = cfg.ReadSetting("planeequationsupport", false);
distinctfloorandceilingbrightness = cfg.ReadSetting("distinctfloorandceilingbrightness", false); distinctfloorandceilingbrightness = cfg.ReadSetting("distinctfloorandceilingbrightness", false);
distinctwallbrightness = cfg.ReadSetting("distinctwallbrightness", 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 //mxd. Update map format flags
universalmapformat = (formatinterface == "UniversalMapSetIO"); universalmapformat = (formatinterface == "UniversalMapSetIO");

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -2087,7 +2087,7 @@ namespace CodeImp.DoomBuilder.Geometry
if(t.Marked) if(t.Marked)
{ {
t.Action = 0; 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) if(l.Marked)
{ {
l.Action = 0; 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 s1 = reader.ReadInt32();
int s2 = reader.ReadInt32(); int s2 = reader.ReadInt32();
int special = 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 int numtags = reader.ReadInt32(); //mxd
List<int> tags = new List<int>(numtags); //mxd List<int> tags = new List<int>(numtags); //mxd
for(int a = 0; a < numtags; a++) tags.Add(reader.ReadInt32()); //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 double scaleY = reader.ReadDouble(); //mxd
int type = reader.ReadInt32(); int type = reader.ReadInt32();
int special = 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 //flags
Dictionary<string, bool> stringflags = new Dictionary<string, bool>(StringComparer.Ordinal); 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 double scale = GetCollectionEntry(c, "scale", false, 0.0, where); //mxd
int type = GetCollectionEntry(c, "type", true, 0, where); int type = GetCollectionEntry(c, "type", true, 0, where);
int special = GetCollectionEntry(c, "special", false, 0, where); int special = GetCollectionEntry(c, "special", false, 0, where);
args[0] = GetCollectionEntry(c, "arg0", false, 0, where); for (int j = 0; j < args.Length; j++)
args[1] = GetCollectionEntry(c, "arg1", false, 0, where); args[j] = GetCollectionEntry(c, "arg" + j, 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);
if(scale != 0) //mxd if(scale != 0) //mxd
{ {
@ -256,11 +253,8 @@ namespace CodeImp.DoomBuilder.IO
int tag = GetCollectionEntry(lc, "id", false, 0, where); int tag = GetCollectionEntry(lc, "id", false, 0, where);
int special = GetCollectionEntry(lc, "special", false, 0, where); int special = GetCollectionEntry(lc, "special", false, 0, where);
args[0] = GetCollectionEntry(lc, "arg0", false, 0, where); for (int j = 0; j < args.Length; j++)
args[1] = GetCollectionEntry(lc, "arg1", false, 0, where); args[j] = GetCollectionEntry(lc, "arg" + j, 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);
int s1 = GetCollectionEntry(lc, "sidefront", false, -1, where); int s1 = GetCollectionEntry(lc, "sidefront", false, -1, where);
int s2 = GetCollectionEntry(lc, "sideback", false, -1, where); int s2 = GetCollectionEntry(lc, "sideback", false, -1, where);

View file

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

View file

@ -3923,7 +3923,7 @@ namespace CodeImp.DoomBuilder.Map
if(t.Marked == marked) if(t.Marked == marked)
{ {
LinedefActionInfo info = General.Map.Config.GetLinedefActionInfo(t.Action); 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)) if(info.Args[i].Used && CheckIsTagType(info.Args[i].Type))
{ {
@ -3971,7 +3971,7 @@ namespace CodeImp.DoomBuilder.Map
if(l.Marked == marked) if(l.Marked == marked)
{ {
LinedefActionInfo info = General.Map.Config.GetLinedefActionInfo(l.Action); 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)) 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.rwDouble(ref scaleY); //mxd
s.rwInt(ref tag); s.rwInt(ref tag);
s.rwInt(ref action); 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) if(!s.IsWriting)
{ {

View file

@ -319,7 +319,7 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
{ {
sd.Line.Action = 0; 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; sd.Line.Args[i] = 0;
} }

View file

@ -1884,7 +1884,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
// Set the linedef args // 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 // 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 // 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) if(info.IsKnown && !info.IsNull)
{ {
// Go for all args // 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? // Argument type matches?
if(info.Args[i].Used && (info.Args[i].Type == (int)UniversalType.SectorTag)) 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) if(info.IsKnown && !info.IsNull)
{ {
// Go for all args // 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? // Argument type matches?
if(info.Args[i].Used && (info.Args[i].Type == (int)UniversalType.ThingTag)) 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) if(info.IsKnown && !info.IsNull)
{ {
// Go for all args // 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? // Argument type matches?
if(info.Args[i].Used && (info.Args[i].Type == (int)UniversalType.SectorTag)) 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) if(info.IsKnown && !info.IsNull)
{ {
// Go for all args // 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? // Argument type matches?
if(info.Args[i].Used && (info.Args[i].Type == (int)UniversalType.ThingTag)) 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 // 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 // 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 || if ((action.Args[i].Type == (int)UniversalType.SectorTag ||
action.Args[i].Type == (int)UniversalType.LinedefTag || 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) 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 || if ((ti.Args[i].Type == (int)UniversalType.SectorTag ||
ti.Args[i].Type == (int)UniversalType.LinedefTag || 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)) if ((linedef.Action > 0) && General.Map.Config.LinedefActions.ContainsKey(linedef.Action))
{ {
LinedefActionInfo action = General.Map.Config.LinedefActions[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]))) || for (int i = 0; i < action.Args.Length; i++)
((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]))))
{ {
if ((action.Args[i].Type == (int)type) && (linedef.Args[i] != 0) && (tags.Contains(linedef.Args[i])))
return true; return true;
} }
} }
@ -617,12 +614,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
return false; return false;
LinedefActionInfo action = General.Map.Config.LinedefActions[thing.Action]; LinedefActionInfo action = General.Map.Config.LinedefActions[thing.Action];
if (((action.Args[0].Type == (int)type) && (tags.Contains(thing.Args[0]))) || for (int i = 0; i < ti.Args.Length; i++)
((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]))))
{ {
if ((action.Args[i].Type == (int)type) && (tags.Contains(thing.Args[i])))
return true; 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. // 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 != null && directlinktype >= 0 && Math.Abs(directlinktype) != thing.Type)
{ {
if (((ti.Args[0].Type == (int)type) && (tags.Contains(thing.Args[0]))) || for (int i = 0; i < ti.Args.Length; i++)
((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]))))
{ {
if ((ti.Args[i].Type == (int)type) && (tags.Contains(thing.Args[i])))
return true; return true;
} }
} }