Fix firework command failing without color

After updates to the firework command, a guard was lost, allowing the
switch statement that selected the color to execute on a parameter that
was empty. A guard was added to prevent falling into the switch
statement without enough arguments to match a color.

The default type of firework was manually set to a red firework.

Fixes #2507
This commit is contained in:
Lucas Nicodemus 2021-11-22 22:14:55 -08:00
parent a01b48ead5
commit e303071dce
2 changed files with 41 additions and 37 deletions

View file

@ -14,6 +14,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
## Upcoming changes
* Removed `TShockAPI/DB/DBTools.cs`. This appears to have been dead code and not used by anything. (@hakusaro, @DeathCradle)
* Fixed the `/firework` command not sending fireworks when specified without a firework color. The firework command now correctly sends red fireworks to a target if a color is not specified. (@hakusaro, @Kojirremer)
## TShock 4.5.7
* Fixed the `/respawn` command to permit respawning players from the console. (@hakusaro, @Kojirremer)

View file

@ -5546,7 +5546,9 @@ namespace TShockAPI
user.SendMultipleMatchError(players.Select(p => p.Name));
else
{
int type = 0;
int type = ProjectileID.RocketFireworkRed;
if (args.Parameters.Count > 1)
{
switch (args.Parameters[1].ToLower())
{
case "red":
@ -5585,6 +5587,7 @@ namespace TShockAPI
type = ProjectileID.RocketFireworkRed;
break;
}
}
var target = players[0];
int p = Projectile.NewProjectile(Projectile.GetNoneSource(), target.TPlayer.position.X, target.TPlayer.position.Y - 64f, 0f, -8f, type, 0, 0);
Main.projectile[p].Kill();