Merge branch 'general-devel' into fishoutnpc-event

This commit is contained in:
Patrikkk 2020-05-30 10:53:51 +02:00 committed by GitHub
commit 9a49f6ad15
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 116 additions and 32 deletions

View file

@ -559,6 +559,8 @@ namespace TShockAPI
return;
}
bool changed = false;
bool failed = false;
try
{
var tiles = new NetTile[size, size];
@ -570,7 +572,6 @@ namespace TShockAPI
}
}
bool changed = false;
for (int x = 0; x < size; x++)
{
int realx = tileX + x;
@ -710,9 +711,10 @@ namespace TShockAPI
catch
{
args.Player.SendTileSquare(tileX, tileY, size);
failed = true;
}
TShock.Log.ConsoleDebug("Bouncer / SendTileSquare reimplemented from spaghetti from {0}", args.Player.Name);
TShock.Log.ConsoleDebug("Bouncer / SendTileSquare from {0} {1} {2}", args.Player.Name, changed, failed);
args.Handled = true;
}
@ -1539,7 +1541,7 @@ namespace TShockAPI
if (npc.townNPC && npc.netID != NPCID.Guide && npc.netID != NPCID.Clothier)
{
if (type != BuffID.Lovestruck && type != BuffID.Stinky && type != BuffID.DryadsWard &&
type != BuffID.Wet && type != BuffID.Slimed)
type != BuffID.Wet && type != BuffID.Slimed && type != BuffID.GelBalloonBuff)
{
detectedNPCBuffTimeCheat = true;
}
@ -2099,7 +2101,7 @@ namespace TShockAPI
/// <param name="args"></param>
internal void OnFoodPlatterTryPlacing(object sender, GetDataHandlers.FoodPlatterTryPlacingEventArgs args)
{
if (args.Player.ItemInHand.type != args.ItemID)
if ((args.Player.SelectedItem.type != args.ItemID && args.Player.ItemInHand.type != args.ItemID))
{
TShock.Log.ConsoleDebug("Bouncer / OnFoodPlatterTryPlacing rejected item not placed by hand from {0}", args.Player.Name);
args.Player.SendTileSquare(args.TileX, args.TileY, 1);
@ -2128,12 +2130,9 @@ namespace TShockAPI
return;
}
if (!args.Player.IsInRange(args.TileX, args.TileY))
if (!args.Player.IsInRange(args.TileX, args.TileY, range: 13)) // To my knowledge, max legit tile reach with accessories.
{
TShock.Log.ConsoleDebug("Bouncer / OnFoodPlatterTryPlacing rejected range checks from {0}", args.Player.Name);
Item item = new Item();
item.netDefaults(args.ItemID);
args.Player.GiveItemCheck(args.ItemID, item.Name, args.Stack, args.Prefix);
args.Player.SendTileSquare(args.TileX, args.TileY, 1);
args.Handled = true;
return;

View file

@ -589,6 +589,10 @@ namespace TShockAPI
{
HelpText = "Creates a reference tables for Terraria data types and the TShock permission system in the server folder."
});
add(new Command(Permissions.synclocalarea, SyncLocalArea, "sync")
{
HelpText = "Sends all tiles from the server to the player to resync the client with the actual world state."
});
#endregion
add(new Command(Aliases, "aliases")
@ -2378,7 +2382,7 @@ namespace TShockAPI
{
case "*":
case "all":
int[] npcIds = { 4, 13, 35, 50, 125, 126, 127, 134, 222, 245, 262, 266, 370, 398 };
int[] npcIds = { 4, 13, 35, 50, 125, 126, 127, 134, 222, 245, 262, 266, 370, 398, 636, 657 };
TSPlayer.Server.SetTime(false, 0.0);
foreach (int i in npcIds)
{
@ -2442,7 +2446,6 @@ namespace TShockAPI
TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY);
TSPlayer.All.SendSuccessMessage("{0} has spawned Skeletron Prime {1} time(s).", args.Player.Name, amount);
return;
case "queen":
case "queen bee":
npc.SetDefaults(222);
TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY);
@ -2483,6 +2486,17 @@ namespace TShockAPI
TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY);
TSPlayer.All.SendSuccessMessage("{0} has spawned the Moon Lord {1} time(s).", args.Player.Name, amount);
return;
case "empress":
case "empress of light":
npc.SetDefaults(636);
TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY);
TSPlayer.All.SendSuccessMessage("{0} has spawned the Empress of Light {1} time(s).", args.Player.Name, amount);
return;
case "queen slime":
npc.SetDefaults(657);
TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY);
TSPlayer.All.SendSuccessMessage("{0} has spawned the Queen Slime {1} time(s).", args.Player.Name, amount);
return;
default:
args.Player.SendErrorMessage("Invalid boss type!");
return;
@ -5302,6 +5316,13 @@ namespace TShockAPI
return;
}
private static void SyncLocalArea(CommandArgs args)
{
args.Player.SendTileSquare((int) args.Player.TileX, (int) args.Player.TileY, 32);
args.Player.SendWarningMessage("Sync'd!");
return;
}
#endregion General Commands
#region Cheat Commands

View file

@ -64,7 +64,8 @@ namespace TShockAPI.DB
Permissions.canlogin,
Permissions.canpartychat,
Permissions.cantalkinthird,
Permissions.canchat));
Permissions.canchat,
Permissions.synclocalarea));
AddDefaultGroup("default", "guest",
string.Join(",",
@ -172,7 +173,19 @@ namespace TShockAPI.DB
Permissions.settempgroup,
Permissions.spawnrate,
Permissions.tpoverride,
Permissions.createdumps));
Permissions.createdumps,
Permissions.journey_timefreeze,
Permissions.journey_timeset,
Permissions.journey_timespeed,
Permissions.journey_godmode,
Permissions.journey_windstrength,
Permissions.journey_windfreeze,
Permissions.journey_rainstrength,
Permissions.journey_rainfreeze,
Permissions.journey_placementrange,
Permissions.journey_setdifficulty,
Permissions.journey_biomespreadfreeze,
Permissions.journey_setspawnrate));
}
// Load Permissions from the DB

View file

@ -152,7 +152,8 @@ namespace TShockAPI
{ PacketTypes.PlayerHurtV2, HandlePlayerDamageV2 },
{ PacketTypes.PlayerDeathV2, HandlePlayerKillMeV2 },
{ PacketTypes.FishOutNPC, HandleFishOutNPC },
{ PacketTypes.FoodPlatterTryPlacing, HandleFoodPlatterTryPlacing }
{ PacketTypes.FoodPlatterTryPlacing, HandleFoodPlatterTryPlacing },
{ PacketTypes.SyncRevengeMarker, HandleSyncRevengeMarker }
};
}
@ -2356,6 +2357,14 @@ namespace TShockAPI
{
var player = args.Player;
var size = args.Data.ReadInt16();
var changeType = TileChangeType.None;
bool hasChangeType = ((size & 0x7FFF) & 0x8000) != 0;
if (hasChangeType)
{
changeType = (TileChangeType)args.Data.ReadInt8();
}
var tileX = args.Data.ReadInt16();
var tileY = args.Data.ReadInt16();
var data = args.Data;
@ -3415,24 +3424,38 @@ namespace TShockAPI
private static bool HandleSyncExtraValue(GetDataHandlerArgs args)
{
var npcIndex = args.Data.ReadInt16();
var extraValue = args.Data.ReadSingle();
var extraValue = args.Data.ReadInt32();
var position = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle());
if (position.X < 0 || position.X >= Main.maxTilesX || position.Y < 0 || position.Y >= Main.maxTilesY)
if (position.X < 0 || position.X >= (Main.maxTilesX * 16.0f) || position.Y < 0 || position.Y >= (Main.maxTilesY * 16.0f))
{
TShock.Log.ConsoleDebug("GetDataHandlers / HandleSyncExtraValue rejected extents check {0}", args.Player.Name);
return true;
}
if (!Main.expertMode)
if (!Main.expertMode && !Main.masterMode)
{
TShock.Log.ConsoleDebug("GetDataHandlers / HandleSyncExtraValue rejected expert mode check {0}", args.Player.Name);
TShock.Log.ConsoleDebug("GetDataHandlers / HandleSyncExtraValue rejected expert/master mode check {0}", args.Player.Name);
return true;
}
if (!args.Player.IsInRange((int)position.X, (int)position.Y))
if (npcIndex < 0 || npcIndex >= Main.npc.Length)
{
TShock.Log.ConsoleDebug("GetDataHandlers / HandleSyncExtraValue rejected range check {0}", args.Player.Name);
TShock.Log.ConsoleDebug("GetDataHandlers / HandleSyncExtraValue rejected npc id out of bounds check - NPC ID: {0}", npcIndex);
return true;
}
var npc = Main.npc[npcIndex];
if (npc == null)
{
TShock.Log.ConsoleDebug("GetDataHandlers / HandleSyncExtraValue rejected npc is null - NPC ID: {0}", npcIndex);
return true;
}
var distanceFromCoinPacketToNpc = Utils.Distance(position, npc.position);
if (distanceFromCoinPacketToNpc >= (5*16f)) //5 tile range
{
TShock.Log.ConsoleDebug("GetDataHandlers / HandleSyncExtraValue rejected range check {0},{1} vs {2},{3} which is {4}", npc.position.X, npc.position.Y, position.X, position.Y, distanceFromCoinPacketToNpc);
return true;
}
@ -3673,6 +3696,21 @@ namespace TShockAPI
return false;
}
private static bool HandleSyncRevengeMarker(GetDataHandlerArgs args)
{
int uniqueID = args.Data.ReadInt32();
Vector2 location = args.Data.ReadVector2();
int netId = args.Data.ReadInt32();
float npcHpPercent = args.Data.ReadSingle();
int npcTypeAgainstDiscouragement = args.Data.ReadInt32(); //tfw the argument is Type Against Discouragement
int npcAiStyleAgainstDiscouragement = args.Data.ReadInt32(); //see ^
int coinsValue = args.Data.ReadInt32();
float baseValue = args.Data.ReadSingle();
bool spawnedFromStatus = args.Data.ReadBoolean();
return false;
}
public enum EditAction
{
KillTile = 0,

View file

@ -30,7 +30,7 @@ namespace TShockAPI.Net
public short FrameX { get; set; }
public short FrameY { get; set; }
public bool Lighted { get; set; }
public byte Wall { get; set; }
public ushort Wall { get; set; }
public byte Liquid { get; set; }
public byte LiquidType { get; set; }
public bool Wire { get; set; }
@ -175,7 +175,7 @@ namespace TShockAPI.Net
}
if (HasWall)
stream.WriteInt8(Wall);
stream.WriteInt16((short)Wall);;
if (HasLiquid)
{
@ -218,7 +218,7 @@ namespace TShockAPI.Net
if (flags[2])
{
Wall = stream.ReadInt8();
Wall = stream.ReadUInt16();
}
if (flags[3])

View file

@ -465,6 +465,9 @@ namespace TShockAPI
[Description("Player can see advanced information about any user account.")]
public static readonly string advaccountinfo = "tshock.accountinfo.details";
[Description("Player can resync themselves with server state.")]
public static readonly string synclocalarea = "tshock.synclocalarea";
#endregion
/// <summary>
/// Lists all commands associated with a given permission

View file

@ -685,7 +685,7 @@ namespace TShockAPI
/// <returns>True if they can paint.</returns>
public bool HasPaintPermission(int x, int y)
{
return HasBuildPermission(x, y) || HasPermission(Permissions.canpaint);
return HasBuildPermission(x, y) && HasPermission(Permissions.canpaint);
}
/// <summary>Checks if a player can place ice, and if they can, tracks ice placements and removals.</summary>

View file

@ -1493,8 +1493,6 @@ namespace TShockAPI
PacketTypes type = e.MsgID;
Log.ConsoleDebug("Recv: {0:X}: {2} ({1:XX})", e.Msg.whoAmI, (byte)type, type);
var player = Players[e.Msg.whoAmI];
if (player == null || !player.ConnectionAlive)
{
@ -1635,7 +1633,8 @@ namespace TShockAPI
e.Handled = true;
return;
}
} else if (e.MsgId == PacketTypes.ProjectileNew)
}
else if (e.MsgId == PacketTypes.ProjectileNew)
{
if (e.number >= 0 && e.number < Main.projectile.Length)
{
@ -1660,7 +1659,6 @@ namespace TShockAPI
}
}
}
}
}