Update GetDataHandlers ExtraValue packet handling to match the network protocol.
Update the validation logic to be accurate: * use pixels and not tiles * allow master mode * use npc position and not player position Cleanup some style inconsistencies in NetHooks_SendData.
This commit is contained in:
parent
0c3242a6f5
commit
fd6913f7df
2 changed files with 39 additions and 9 deletions
|
|
@ -151,7 +151,8 @@ namespace TShockAPI
|
||||||
{ PacketTypes.CrystalInvasionStart, HandleOldOnesArmy },
|
{ PacketTypes.CrystalInvasionStart, HandleOldOnesArmy },
|
||||||
{ PacketTypes.PlayerHurtV2, HandlePlayerDamageV2 },
|
{ PacketTypes.PlayerHurtV2, HandlePlayerDamageV2 },
|
||||||
{ PacketTypes.PlayerDeathV2, HandlePlayerKillMeV2 },
|
{ PacketTypes.PlayerDeathV2, HandlePlayerKillMeV2 },
|
||||||
{ PacketTypes.FoodPlatterTryPlacing, HandleFoodPlatterTryPlacing }
|
{ PacketTypes.FoodPlatterTryPlacing, HandleFoodPlatterTryPlacing },
|
||||||
|
{ PacketTypes.SyncRevengeMarker, HandleSyncRevengeMarker }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3383,24 +3384,38 @@ namespace TShockAPI
|
||||||
private static bool HandleSyncExtraValue(GetDataHandlerArgs args)
|
private static bool HandleSyncExtraValue(GetDataHandlerArgs args)
|
||||||
{
|
{
|
||||||
var npcIndex = args.Data.ReadInt16();
|
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());
|
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);
|
TShock.Log.ConsoleDebug("GetDataHandlers / HandleSyncExtraValue rejected extents check {0}", args.Player.Name);
|
||||||
return true;
|
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;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3628,6 +3643,21 @@ namespace TShockAPI
|
||||||
return false;
|
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
|
public enum EditAction
|
||||||
{
|
{
|
||||||
KillTile = 0,
|
KillTile = 0,
|
||||||
|
|
|
||||||
|
|
@ -1635,7 +1635,8 @@ namespace TShockAPI
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (e.MsgId == PacketTypes.ProjectileNew)
|
}
|
||||||
|
else if (e.MsgId == PacketTypes.ProjectileNew)
|
||||||
{
|
{
|
||||||
if (e.number >= 0 && e.number < Main.projectile.Length)
|
if (e.number >= 0 && e.number < Main.projectile.Length)
|
||||||
{
|
{
|
||||||
|
|
@ -1660,7 +1661,6 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue