Added more sanity checks to GLDEFS light parsing logic.

Updated ZDoom_DECORATE.cfg.
Updated ZDoom_ACS.cfg.
Updated ZDoom ACC.
This commit is contained in:
MaxED 2016-08-23 08:07:04 +00:00
parent dbe05d594e
commit fb97d6fb44
5 changed files with 74 additions and 29 deletions

Binary file not shown.

View file

@ -48,7 +48,7 @@ special
41:Ceiling_RaiseByValue(3,4), 41:Ceiling_RaiseByValue(3,4),
42:Ceiling_CrushAndRaise(3,4), 42:Ceiling_CrushAndRaise(3,4),
43:Ceiling_LowerAndCrush(3,4), 43:Ceiling_LowerAndCrush(3,4),
44:Ceiling_CrushStop(1), 44:Ceiling_CrushStop(1,2),
45:Ceiling_CrushRaiseAndStay(3,4), 45:Ceiling_CrushRaiseAndStay(3,4),
46:Floor_CrushStop(1), 46:Floor_CrushStop(1),
47:Ceiling_MoveToValue(3,5), 47:Ceiling_MoveToValue(3,5),
@ -65,7 +65,7 @@ special
// 58: Sector_CopyScroller // 58: Sector_CopyScroller
59:Polyobj_OR_MoveToSpot(3), 59:Polyobj_OR_MoveToSpot(3),
60:Plat_PerpetualRaise(3), 60:Plat_PerpetualRaise(3),
61:Plat_Stop(1), 61:Plat_Stop(1,2),
62:Plat_DownWaitUpStay(3), 62:Plat_DownWaitUpStay(3),
63:Plat_DownByValue(4), 63:Plat_DownByValue(4),
64:Plat_UpWaitDownStay(3), 64:Plat_UpWaitDownStay(3),
@ -180,7 +180,7 @@ special
188:Sector_SetCeilingScale(5), 188:Sector_SetCeilingScale(5),
189:Sector_SetFloorScale(5), 189:Sector_SetFloorScale(5),
191:SetPlayerProperty(3), 191:SetPlayerProperty(3),
192:Ceiling_LowerToHighestFloor(2,4), 192:Ceiling_LowerToHighestFloor(2,5),
193:Ceiling_LowerInstant(3,5), 193:Ceiling_LowerInstant(3,5),
194:Ceiling_RaiseInstant(3,4), 194:Ceiling_RaiseInstant(3,4),
195:Ceiling_CrushRaiseAndStayA(4,5), 195:Ceiling_CrushRaiseAndStayA(4,5),
@ -226,7 +226,7 @@ special
235:Floor_TransferTrigger(1), 235:Floor_TransferTrigger(1),
236:Floor_TransferNumeric(1), 236:Floor_TransferNumeric(1),
237:ChangeCamera(3), 237:ChangeCamera(3),
238:Floor_RaiseToLowestCeiling(2,4), 238:Floor_RaiseToLowestCeiling(2,5),
239:Floor_RaiseByValueTxTy(3), 239:Floor_RaiseByValueTxTy(3),
240:Floor_RaiseByTexture(2,4), 240:Floor_RaiseByTexture(2,4),
241:Floor_LowerToLowestTxTy(2), 241:Floor_LowerToLowestTxTy(2),
@ -242,22 +242,22 @@ special
251:FloorAndCeiling_LowerRaise(3,4), 251:FloorAndCeiling_LowerRaise(3,4),
252:Ceiling_RaiseToNearest(2,3), 252:Ceiling_RaiseToNearest(2,3),
253:Ceiling_LowerToLowest(2,4), 253:Ceiling_LowerToLowest(2,4),
254:Ceiling_LowerToFloor(2,4), 254:Ceiling_LowerToFloor(2,5),
255:Ceiling_CrushRaiseAndStaySilA(4,5), 255:Ceiling_CrushRaiseAndStaySilA(4,5),
// These are specialized versions of the Generic_* specials which are defined for EE Extradata. // These are specialized versions of the Generic_* specials which are defined for EE Extradata.
256:Floor_LowerToHighestEE(2, 3), 256:Floor_LowerToHighestEE(2, 3),
257:Floor_RaiseToLowest(2, 3), 257:Floor_RaiseToLowest(2, 3),
258:Floor_LowerToLowestCeiling(2,3), 258:Floor_LowerToLowestCeiling(2,3),
259:Floor_RaiseToCeiling(2, 4), 259:Floor_RaiseToCeiling(2, 5),
260:Floor_ToCeilingInstant(1, 3), 260:Floor_ToCeilingInstant(1, 4),
261:Floor_LowerByTexture(2, 3), 261:Floor_LowerByTexture(2, 3),
262:Ceiling_RaiseToHighest(2, 3), 262:Ceiling_RaiseToHighest(2, 3),
263:Ceiling_ToHighestInstant(1, 3), 263:Ceiling_ToHighestInstant(1, 3),
264:Ceiling_LowerToNearest(2, 4), 264:Ceiling_LowerToNearest(2, 4),
265:Ceiling_RaiseToLowest(2, 3), 265:Ceiling_RaiseToLowest(2, 3),
266:Ceiling_RaiseToHighestFloor(2, 3), 266:Ceiling_RaiseToHighestFloor(2, 3),
267:Ceiling_ToFloorInstant(1, 3), 267:Ceiling_ToFloorInstant(1, 4),
268:Ceiling_RaiseByTexture(2, 3), 268:Ceiling_RaiseByTexture(2, 3),
269:Ceiling_LowerByTexture(2, 4), 269:Ceiling_LowerByTexture(2, 4),
270:Stairs_BuildDownDoom(5), 270:Stairs_BuildDownDoom(5),
@ -366,6 +366,7 @@ special
-96:SpawnParticle(1,16), -96:SpawnParticle(1,16),
-97:SetMusicVolume(1), -97:SetMusicVolume(1),
-98:CheckProximity(3, 6), -98:CheckProximity(3, 6),
-99:CheckActorState(2,3),
// Zandronum's // Zandronum's
-100:ResetMap(0), -100:ResetMap(0),

View file

@ -106,6 +106,7 @@ keywords
CheckActorFloorTexture = "bool CheckActorFloorTexture(int tid, str texture)"; CheckActorFloorTexture = "bool CheckActorFloorTexture(int tid, str texture)";
CheckActorInventory = "int CheckActorInventory(int tid, str inventory_item)\nChecks the given actor's inventory for the item specified by inventory_item"; CheckActorInventory = "int CheckActorInventory(int tid, str inventory_item)\nChecks the given actor's inventory for the item specified by inventory_item";
CheckActorProperty = "bool CheckActorProperty(int tid, int property, [int|float|str] value)"; CheckActorProperty = "bool CheckActorProperty(int tid, int property, [int|float|str] value)";
CheckActorState = "bool CheckActorState(int tid, str statename[, bool exact = false])";
CheckFlag = "bool CheckFlag(int tid, str flag)\nChecks to see if the actor with the matching tid has the specified actor flag set.\nIf tid is 0, the check is performed on the activator of the script."; CheckFlag = "bool CheckFlag(int tid, str flag)\nChecks to see if the actor with the matching tid has the specified actor flag set.\nIf tid is 0, the check is performed on the activator of the script.";
CheckFont = "bool CheckFont(str fontname)"; CheckFont = "bool CheckFont(str fontname)";
CheckInventory = "int CheckInventory(str inventory_item)\nChecks the inventory of the actor who activated the script for the item specified by inventory_item"; CheckInventory = "int CheckInventory(str inventory_item)\nChecks the inventory of the actor who activated the script for the item specified by inventory_item";

View file

@ -127,7 +127,7 @@ keywords
A_BasicAttack = "A_BasicAttack(int meleedamage, str meleesound, str missiletype, float missileheight)"; A_BasicAttack = "A_BasicAttack(int meleedamage, str meleesound, str missiletype, float missileheight)";
A_BulletAttack = "A_BulletAttack"; A_BulletAttack = "A_BulletAttack";
A_MonsterRail = "A_MonsterRail"; A_MonsterRail = "A_MonsterRail";
A_Explode = "A_Explode[(int explosiondamage = 128[, int explosionradius = 128[, int flags = XF_HURTSOURCE[, bool alert = false[, int fulldamageradius = 0[, int nails = 0[, int naildamage = 10[, str pufftype = \"BulletPuff\"]]]]]]])]"; A_Explode = "A_Explode[(int explosiondamage = 128[, int explosionradius = 128[, int flags = XF_HURTSOURCE[, bool alert = false[, int fulldamageradius = 0[, int nails = 0[, int naildamage = 10[, str pufftype = \"BulletPuff\"[, str damagetype = \"none\"]]]]]]]])]";
A_RadiusDamageSelf = "[(int damage = 128[, float distance = 128.0[, int flags = 0[, str flashtype = \"None\"]]])]\nflags: RDSF flags"; A_RadiusDamageSelf = "[(int damage = 128[, float distance = 128.0[, int flags = 0[, str flashtype = \"None\"]]])]\nflags: RDSF flags";
A_RadiusThrust = "A_RadiusThrust(int force, int distance[, int flags[, int fullthrustdistance]])"; A_RadiusThrust = "A_RadiusThrust(int force, int distance[, int flags[, int fullthrustdistance]])";
A_Detonate = "A_Detonate"; A_Detonate = "A_Detonate";
@ -285,7 +285,7 @@ keywords
A_GiveInventory = "bool A_GiveInventory(str type[, int count = 0[, int giveto = AAPTR_DEFAULT]])\ntype: the item to give. This should be a valid inventory item.\ncount: the number of samples of this item to give. Default is 0, which is interpreted as 1.\ngiveto: the actor to give the item to"; A_GiveInventory = "bool A_GiveInventory(str type[, int count = 0[, int giveto = AAPTR_DEFAULT]])\ntype: the item to give. This should be a valid inventory item.\ncount: the number of samples of this item to give. Default is 0, which is interpreted as 1.\ngiveto: the actor to give the item to";
A_GiveToChildren = "int A_GiveToChildren(str type[, int count = 0])\ntype: the item to give. This should be a valid inventory item.\ncount: the number of samples of this item to give. Default is 0, which is interpreted as 1."; A_GiveToChildren = "int A_GiveToChildren(str type[, int count = 0])\ntype: the item to give. This should be a valid inventory item.\ncount: the number of samples of this item to give. Default is 0, which is interpreted as 1.";
A_GiveToSiblings = "int A_GiveToSiblings(str type[, int count = 0])\ntype: the item to give. This should be a valid inventory item.\ncount: the number of samples of this item to give. Default is 0, which is interpreted as 1."; A_GiveToSiblings = "int A_GiveToSiblings(str type[, int count = 0])\ntype: the item to give. This should be a valid inventory item.\ncount: the number of samples of this item to give. Default is 0, which is interpreted as 1.";
A_GiveToTarget = "bool A_GiveToTarget(str type, int count[, int giveto = AAPTR_DEFAULT])"; A_GiveToTarget = "bool A_GiveToTarget(str type, [int count = 1[, int giveto = AAPTR_DEFAULT]])";
A_TakeInventory = "bool A_TakeInventory(str type, int count[, int flags[, int takefrom = AAPTR_DEFAULT]])"; A_TakeInventory = "bool A_TakeInventory(str type, int count[, int flags[, int takefrom = AAPTR_DEFAULT]])";
A_TakeFromChildren = "int A_TakeFromChildren(str type[, int count = 0])\ntype: the item to take. This should be a valid inventory item.\ncount: the number of samples of this item to take.\nIf this is 0, the item is cleared from the inventory unless it has the\nINVENTORY.KEEPDEPLETED flag set, and in which case, its amount is merely reduced to 0.\nDefault is 0."; A_TakeFromChildren = "int A_TakeFromChildren(str type[, int count = 0])\ntype: the item to take. This should be a valid inventory item.\ncount: the number of samples of this item to take.\nIf this is 0, the item is cleared from the inventory unless it has the\nINVENTORY.KEEPDEPLETED flag set, and in which case, its amount is merely reduced to 0.\nDefault is 0.";
A_TakeFromSiblings = "int A_TakeFromSiblings(str type[, int count = 0])\ntype: the item to take. This should be a valid inventory item.\ncount: the number of samples of this item to take.\nIf this is 0, the item is cleared from the inventory unless it has the\nINVENTORY.KEEPDEPLETED flag set, and in which case, its amount is merely reduced to 0.\nDefault is 0."; A_TakeFromSiblings = "int A_TakeFromSiblings(str type[, int count = 0])\ntype: the item to take. This should be a valid inventory item.\ncount: the number of samples of this item to take.\nIf this is 0, the item is cleared from the inventory unless it has the\nINVENTORY.KEEPDEPLETED flag set, and in which case, its amount is merely reduced to 0.\nDefault is 0.";
@ -1331,6 +1331,7 @@ constants
WARPF_COPYPITCH; WARPF_COPYPITCH;
XF_HURTSOURCE; XF_HURTSOURCE;
XF_NOTMISSILE; XF_NOTMISSILE;
XF_EXPLICITDAMAGETYPE;
////////////////////////// //////////////////////////
//Property-specific flags //Property-specific flags
////////////////////////// //////////////////////////

View file

@ -211,6 +211,30 @@ namespace CodeImp.DoomBuilder.ZDoom
ReportError("Expected Blue color value, but got \"" + token + "\""); ReportError("Expected Blue color value, but got \"" + token + "\"");
return false; return false;
} }
// Check the value
if(light.Color.Red == 0.0f && light.Color.Green == 0.0f && light.Color.Blue == 0.0f)
{
LogWarning("\"" + lightname + "\" light Color is "
+ light.Color.Red + "," + light.Color.Green + "," + light.Color.Blue
+ ". It won't be shown in GZDoom");
}
else if(light.Color.Red > 1.0f || light.Color.Green > 1.0f || light.Color.Blue > 1.0f ||
light.Color.Red < 0.0f || light.Color.Green < 0.0f || light.Color.Blue < 0.0f)
{
// Store borked colors
string oldcolors = light.Color.Red + ", " + light.Color.Green + ", " + light.Color.Blue;
// Clamp values
light.Color.Red = General.Clamp(light.Color.Red, 0.0f, 1.0f);
light.Color.Green = General.Clamp(light.Color.Green, 0.0f, 1.0f);
light.Color.Blue = General.Clamp(light.Color.Blue, 0.0f, 1.0f);
// Notify user
LogWarning("\"" + lightname + "\" light Color was clamped from " + oldcolors + " to "
+ light.Color.Red + ", " + light.Color.Green + ", " + light.Color.Blue
+ ". Color values must be in [0.0 .. 1.0] range");
}
break; break;
case "size": case "size":
@ -225,6 +249,13 @@ namespace CodeImp.DoomBuilder.ZDoom
ReportError("Expected Size value, but got \"" + token + "\""); ReportError("Expected Size value, but got \"" + token + "\"");
return false; return false;
} }
if(light.PrimaryRadius < 0)
{
ReportError("Size value should be positive, but is \"" + light.PrimaryRadius + "\"");
return false;
}
light.PrimaryRadius *= 2; light.PrimaryRadius *= 2;
} }
@ -304,15 +335,19 @@ namespace CodeImp.DoomBuilder.ZDoom
SkipWhitespace(true); SkipWhitespace(true);
token = ReadToken(); token = ReadToken();
float interval; float interval = 0f;
if(!float.TryParse(token, NumberStyles.Float, CultureInfo.InvariantCulture, out interval)) if(!ReadSignedFloat(token, ref interval))
{ {
// Not numeric! // Not numeric!
ReportError("Expected Interval value, but got \"" + token + "\""); ReportError("Expected Interval value, but got \"" + token + "\"");
return false; return false;
} }
if(interval == 0) LogWarning("Interval value should be greater than zero"); if(interval <= 0)
{
ReportError("Interval value should be greater than zero, but is \"" + interval + "\"");
return false;
}
//I wrote logic for dynamic lights animation first, so here I modify gldefs settings to fit in existing logic //I wrote logic for dynamic lights animation first, so here I modify gldefs settings to fit in existing logic
if(lighttype == GldefsLightType.PULSE) if(lighttype == GldefsLightType.PULSE)
@ -337,13 +372,19 @@ namespace CodeImp.DoomBuilder.ZDoom
SkipWhitespace(true); SkipWhitespace(true);
token = ReadToken(); token = ReadToken();
if(!int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out light.SecondaryRadius)) if(!ReadSignedInt(token, ref light.SecondaryRadius))
{ {
// Not numeric! // Not numeric!
ReportError("Expected SecondarySize value, but got \"" + token + "\""); ReportError("Expected SecondarySize value, but got \"" + token + "\"");
return false; return false;
} }
if(light.SecondaryRadius < 0)
{
ReportError("SecondarySize value should be positive, but is \"" + light.SecondaryRadius + "\"");
return false;
}
light.SecondaryRadius *= 2; light.SecondaryRadius *= 2;
} }
else else
@ -359,14 +400,21 @@ namespace CodeImp.DoomBuilder.ZDoom
SkipWhitespace(true); SkipWhitespace(true);
token = ReadToken(); token = ReadToken();
float chance; float chance = 0f;
if(!float.TryParse(token, NumberStyles.Float, CultureInfo.InvariantCulture, out chance)) if(!ReadSignedFloat(token, ref chance))
{ {
// Not numeric! // Not numeric!
ReportError("Expected Chance value, but got \"" + token + "\""); ReportError("Expected Chance value, but got \"" + token + "\"");
return false; return false;
} }
// Check range
if(chance > 1.0f || chance < 0.0f)
{
ReportError("Chance must be in [0.0 .. 1.0] range, but is " + chance);
return false;
}
// Transforming from 0.0 .. 1.0 to 0 .. 359 to fit in existing logic // Transforming from 0.0 .. 1.0 to 0 .. 359 to fit in existing logic
light.Interval = (int)(chance * 359.0f); light.Interval = (int)(chance * 359.0f);
} }
@ -383,17 +431,18 @@ namespace CodeImp.DoomBuilder.ZDoom
SkipWhitespace(true); SkipWhitespace(true);
token = ReadToken(); token = ReadToken();
float scale; float scale = 0f;
if(!float.TryParse(token, NumberStyles.Float, CultureInfo.InvariantCulture, out scale)) if(!ReadSignedFloat(token, ref scale))
{ {
// Not numeric! // Not numeric!
ReportError("Expected Scale value, but got \"" + token + "\""); ReportError("Expected Scale value, but got \"" + token + "\"");
return false; return false;
} }
if(scale > 1.0f) // Check range
if(scale > 1.0f || scale < 0.0f)
{ {
ReportError("Scale must be in 0.0 - 1.0 range, but is " + scale); ReportError("Scale must be in [0.0 .. 1.0] range, but is " + scale);
return false; return false;
} }
@ -410,14 +459,7 @@ namespace CodeImp.DoomBuilder.ZDoom
case "}": case "}":
{ {
bool skip = false; bool skip = (light.Color.Red == 0.0f && light.Color.Green == 0.0f && light.Color.Blue == 0.0f);
// General checks
if(light.Color.Red == 0.0f && light.Color.Green == 0.0f && light.Color.Blue == 0.0f)
{
LogWarning("\"" + lightname + "\" light Color is " + light.Color.Red + "," + light.Color.Green + "," + light.Color.Blue + ". It won't be shown in GZDoom");
skip = true;
}
// Light-type specific checks // Light-type specific checks
if(light.Type == DynamicLightType.NORMAL && light.PrimaryRadius == 0) if(light.Type == DynamicLightType.NORMAL && light.PrimaryRadius == 0)
@ -430,7 +472,7 @@ namespace CodeImp.DoomBuilder.ZDoom
{ {
if(light.PrimaryRadius == 0 && light.SecondaryRadius == 0) if(light.PrimaryRadius == 0 && light.SecondaryRadius == 0)
{ {
LogWarning("\"" + lightname + "\" light Size and SecondarySize are 0. This light won't be shown in GZDoom"); LogWarning("\"" + lightname + "\" light Size and SecondarySize are 0. It won't be shown in GZDoom");
skip = true; skip = true;
} }
} }