diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index c5e24156..7e231dcd 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -15,6 +15,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ + using System; using System.Collections.Generic; using System.Linq; @@ -165,11 +166,12 @@ namespace TShockAPI var usingBiomeTorches = player.UsingBiomeTorches; player.UsingBiomeTorches = true; // BiomeTorchPlaceStyle returns the place style of the player's current biome's biome torch - var biomeTorchPlaceStyle = player.BiomeTorchPlaceStyle(actualItemPlaceStyle); + var type = 114514; // Not used + player.BiomeTorchPlaceStyle(ref type ,ref actualItemPlaceStyle); // Reset UsingBiomeTorches value player.UsingBiomeTorches = usingBiomeTorches; - return biomeTorchPlaceStyle; + return actualItemPlaceStyle; } else { @@ -720,7 +722,7 @@ namespace TShockAPI if (action == EditAction.KillTile && !Main.tileCut[tile.type] && !breakableTiles.Contains(tile.type) && args.Player.RecentFuse == 0) { // If the tile is an axe tile and they aren't selecting an axe, they're hacking. - if (Main.tileAxe[tile.type] && ((args.Player.TPlayer.mount.Type != MountID.Drill && selectedItem.axe == 0) && !ItemID.Sets.Explosives[selectedItem.netID])) + if (Main.tileAxe[tile.type] && ((args.Player.TPlayer.mount.Type != MountID.Drill && selectedItem.axe == 0) && !ItemID.Sets.Explosives[selectedItem.type])) { TShock.Log.ConsoleDebug(GetString("Bouncer / OnTileEdit rejected from (axe) {0} {1} {2}", args.Player.Name, action, editData)); args.Player.SendTileSquareCentered(tileX, tileY, 4); @@ -728,7 +730,7 @@ namespace TShockAPI return; } // If the tile is a hammer tile and they aren't selecting a hammer, they're hacking. - else if (Main.tileHammer[tile.type] && ((args.Player.TPlayer.mount.Type != MountID.Drill && selectedItem.hammer == 0) && !ItemID.Sets.Explosives[selectedItem.netID])) + else if (Main.tileHammer[tile.type] && ((args.Player.TPlayer.mount.Type != MountID.Drill && selectedItem.hammer == 0) && !ItemID.Sets.Explosives[selectedItem.type])) { TShock.Log.ConsoleDebug(GetString("Bouncer / OnTileEdit rejected from (hammer) {0} {1} {2}", args.Player.Name, action, editData)); args.Player.SendTileSquareCentered(tileX, tileY, 4); @@ -740,7 +742,7 @@ namespace TShockAPI // also add an exception for snake coils, they can be removed when the player places a new one or after x amount of time // If the tile is part of the breakable when placing set, it might be getting broken by a placement. else if (tile.type != TileID.ItemFrame && tile.type != TileID.MysticSnakeRope - && !ItemID.Sets.Explosives[selectedItem.netID] + && !ItemID.Sets.Explosives[selectedItem.type] && !TileID.Sets.BreakableWhenPlacing[tile.type] && !Main.tileAxe[tile.type] && !Main.tileHammer[tile.type] && tile.wall == 0 && selectedItem.pick == 0 && selectedItem.type != ItemID.GravediggerShovel @@ -757,7 +759,7 @@ namespace TShockAPI else if (action == EditAction.KillWall) { // If they aren't selecting a hammer, they could be hacking. - if (selectedItem.hammer == 0 && !ItemID.Sets.Explosives[selectedItem.netID] && args.Player.RecentFuse == 0 && selectedItem.createWall == 0) + if (selectedItem.hammer == 0 && !ItemID.Sets.Explosives[selectedItem.type] && args.Player.RecentFuse == 0 && selectedItem.createWall == 0) { TShock.Log.ConsoleDebug(GetString("Bouncer / OnTileEdit rejected from (hammer2) {0} {1} {2}", args.Player.Name, action, editData)); args.Player.SendTileSquareCentered(tileX, tileY, 1); @@ -774,11 +776,11 @@ namespace TShockAPI // Handle placement if the user is placing rope that comes from a ropecoil, // but have not created the ropecoil projectile recently or the projectile was not at the correct coordinate, or the tile that the projectile places does not match the rope it is suposed to place // projectile should be the same X coordinate as all tile places (Note by @Olink) - if (ropeCoilPlacements.ContainsKey(selectedItem.netID) && + if (ropeCoilPlacements.ContainsKey(selectedItem.type) && !args.Player.RecentlyCreatedProjectiles.Any(p => GetDataHandlers.projectileCreatesTile.ContainsKey(p.Type) && GetDataHandlers.projectileCreatesTile[p.Type] == editData && !p.Killed && Math.Abs((int)(Main.projectile[p.Index].position.X / 16f) - tileX) <= Math.Abs(Main.projectile[p.Index].velocity.X))) { - TShock.Log.ConsoleDebug(GetString("Bouncer / OnTileEdit rejected from (inconceivable rope coil) {0} {1} {2} selectedItem:{3} itemCreateTile:{4}", args.Player.Name, action, editData, selectedItem.netID, selectedItem.createTile)); + TShock.Log.ConsoleDebug(GetString("Bouncer / OnTileEdit rejected from (inconceivable rope coil) {0} {1} {2} selectedItem:{3} itemCreateTile:{4}", args.Player.Name, action, editData, selectedItem.type, selectedItem.createTile)); args.Player.SendTileSquareCentered(tileX, tileY, 1); args.Handled = true; return; @@ -796,7 +798,7 @@ namespace TShockAPI } /// Handle placement action if the player is using an Ice Rod but not placing the iceblock. - if (selectedItem.netID == ItemID.IceRod && editData != TileID.MagicalIceBlock) + if (selectedItem.type == ItemID.IceRod && editData != TileID.MagicalIceBlock) { TShock.Log.ConsoleDebug(GetString("Bouncer / OnTileEdit rejected from using ice rod but not placing ice block {0} {1} {2}", args.Player.Name, action, editData)); args.Player.SendTileSquareCentered(tileX, tileY, 4); @@ -806,9 +808,9 @@ namespace TShockAPI if ((action == EditAction.PlaceTile || action == EditAction.ReplaceTile) && editData != selectedItem.createTile) { /// These would get caught up in the below check because Terraria does not set their createTile field. - if (selectedItem.netID != ItemID.IceRod && selectedItem.netID != ItemID.DirtBomb && selectedItem.netID != ItemID.StickyBomb && (args.Player.TPlayer.mount.Type != MountID.DiggingMoleMinecart || editData != TileID.MinecartTrack)) + if (selectedItem.type != ItemID.IceRod && selectedItem.type != ItemID.DirtBomb && selectedItem.type != ItemID.StickyBomb && (args.Player.TPlayer.mount.Type != MountID.DiggingMoleMinecart || editData != TileID.MinecartTrack)) { - TShock.Log.ConsoleDebug(GetString("Bouncer / OnTileEdit rejected from tile placement not matching selected item createTile {0} {1} {2} selectedItemID:{3} createTile:{4}", args.Player.Name, action, editData, selectedItem.netID, selectedItem.createTile)); + TShock.Log.ConsoleDebug(GetString("Bouncer / OnTileEdit rejected from tile placement not matching selected item createTile {0} {1} {2} selectedItemID:{3} createTile:{4}", args.Player.Name, action, editData, selectedItem.type, selectedItem.createTile)); args.Player.SendTileSquareCentered(tileX, tileY, 4); args.Handled = true; return; @@ -817,7 +819,7 @@ namespace TShockAPI /// If they aren't selecting the item which creates the wall, they're hacking. if ((action == EditAction.PlaceWall || action == EditAction.ReplaceWall) && editData != selectedItem.createWall) { - TShock.Log.ConsoleDebug(GetString("Bouncer / OnTileEdit rejected from wall placement not matching selected item createWall {0} {1} {2} selectedItemID:{3} createWall:{4}", args.Player.Name, action, editData, selectedItem.netID, selectedItem.createWall)); + TShock.Log.ConsoleDebug(GetString("Bouncer / OnTileEdit rejected from wall placement not matching selected item createWall {0} {1} {2} selectedItemID:{3} createWall:{4}", args.Player.Name, action, editData, selectedItem.type, selectedItem.createWall)); args.Player.SendTileSquareCentered(tileX, tileY, 4); args.Handled = true; return; @@ -917,7 +919,7 @@ namespace TShockAPI return; } - if (action == EditAction.KillTile || action == EditAction.KillWall && ItemID.Sets.Explosives[selectedItem.netID] && args.Player.RecentFuse == 0) + if (action == EditAction.KillTile || action == EditAction.KillWall && ItemID.Sets.Explosives[selectedItem.type] && args.Player.RecentFuse == 0) { args.Handled = false; return; @@ -1156,7 +1158,7 @@ namespace TShockAPI // stop the client from changing the item type of a drop but // only if the client isn't picking up the item - if (Main.item[id].active && Main.item[id].netID != type) + if (Main.item[id].active && Main.item[id].type != type) { TShock.Log.ConsoleDebug(GetString("Bouncer / OnItemDrop rejected from item drop/pickup check from {0}", args.Player.Name)); args.Player.SendData(PacketTypes.ItemDrop, "", id); @@ -1695,13 +1697,13 @@ namespace TShockAPI foreach (var npc in Main.npc) { - if (npc.netID == NPCID.LunarTowerSolar) + if (npc.type == NPCID.LunarTowerSolar) hasSolarTower = true; - else if (npc.netID == NPCID.LunarTowerVortex) + else if (npc.type == NPCID.LunarTowerVortex) hasVortexTower = true; - else if (npc.netID == NPCID.LunarTowerNebula) + else if (npc.type == NPCID.LunarTowerNebula) hasNebulaTower = true; - else if (npc.netID == NPCID.LunarTowerStardust) + else if (npc.type == NPCID.LunarTowerStardust) hasStardustTower = true; } @@ -2123,7 +2125,7 @@ namespace TShockAPI if (detectedNPCBuffTimeCheat) { - TShock.Log.ConsoleDebug(GetString("Bouncer / OnNPCAddBuff rejected abnormal buff ({0}, last for {4}) added to {1} ({2}) from {3}.", type, npc.TypeName, npc.netID, args.Player.Name, time)); + TShock.Log.ConsoleDebug(GetString("Bouncer / OnNPCAddBuff rejected abnormal buff ({0}, last for {4}) added to {1} ({2}) from {3}.", type, npc.TypeName, npc.type, args.Player.Name, time)); args.Player.Kick(GetString($"Added buff to {npc.TypeName} NPC abnormally."), true); args.Handled = true; } @@ -2404,8 +2406,11 @@ namespace TShockAPI if (args.Player.SelectedItem.placeStyle != style) { - var validTorch = args.Player.SelectedItem.createTile == TileID.Torches && args.Player.TPlayer.BiomeTorchPlaceStyle(args.Player.SelectedItem.placeStyle) == style; - var validCampfire = args.Player.SelectedItem.createTile == TileID.Campfire && args.Player.TPlayer.BiomeCampfirePlaceStyle(args.Player.SelectedItem.placeStyle) == style; + var uselessType = 114514; + args.Player.TPlayer.BiomeTorchPlaceStyle(ref uselessType, ref args.Player.SelectedItem.placeStyle); + + var validTorch = args.Player.SelectedItem.createTile == TileID.Torches && args.Player.SelectedItem.placeStyle == style; + var validCampfire = args.Player.SelectedItem.createTile == TileID.Campfire && args.Player.SelectedItem.placeStyle == style; if (!args.Player.TPlayer.unlockedBiomeTorches || (!validTorch && !validCampfire)) { TShock.Log.ConsoleError(GetString("Bouncer / OnPlaceObject rejected object placement with invalid style {1} (expected {2}) from {0}", args.Player.Name, style, args.Player.SelectedItem.placeStyle)); @@ -2994,19 +2999,19 @@ namespace TShockAPI { BuffID.Daybreak, 300 }, // BuffID: 189 Solar Eruption Item ID: 3473, Daybreak Item ID: 3543 { BuffID.BetsysCurse, 600 }, // BuffID: 203 { BuffID.Oiled, 540 }, // BuffID: 204 - { BuffID.BlandWhipEnemyDebuff, 240 }, // BuffID: 307 - { BuffID.SwordWhipNPCDebuff, 240 }, // BuffID: 309 + //{ BuffID.BlandWhipEnemyDebuff, 240 }, // BuffID: 307 + //{ BuffID.SwordWhipNPCDebuff, 240 }, // BuffID: 309 { BuffID.ScytheWhipEnemyDebuff, 240 }, // BuffID: 310 - { BuffID.FlameWhipEnemyDebuff, 240 }, // BuffID: 313 - { BuffID.ThornWhipNPCDebuff, 240 }, // BuffID: 315 - { BuffID.RainbowWhipNPCDebuff, 240 }, // BuffID: 316 - { BuffID.MaceWhipNPCDebuff, 240 }, // BuffID: 319 + //{ BuffID.FlameWhipEnemyDebuff, 240 }, // BuffID: 313 + // { BuffID.ThornWhipNPCDebuff, 240 }, // BuffID: 315 + // { BuffID.RainbowWhipNPCDebuff, 240 }, // BuffID: 316 + // { BuffID.MaceWhipNPCDebuff, 240 }, // BuffID: 319 { BuffID.GelBalloonBuff, 1800 }, // BuffID: 320 { BuffID.OnFire3, 1200 }, // BuffID: 323 { BuffID.Frostburn2, 1200 }, // BuffID: 324 - { BuffID.BoneWhipNPCDebuff, 240 }, // BuffID: 326 + //{ BuffID.BoneWhipNPCDebuff, 240 }, // BuffID: 326 { BuffID.TentacleSpike, 540 }, // BuffID: 337 - { BuffID.CoolWhipNPCDebuff, 240 }, // BuffID: 340 + //{ BuffID.CoolWhipNPCDebuff, 240 }, // BuffID: 340 { BuffID.BloodButcherer, 540 }, // BuffID: 344 { BuffID.Shimmer, 100 }, // BuffID: 353 }; diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 98cc639d..6191e171 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -1265,7 +1265,7 @@ namespace TShockAPI args.Player.SendInfoMessage(GetString($"Name: {(TShock.Config.Settings.UseServerName ? TShock.Config.Settings.ServerName : Main.worldName)}")); args.Player.SendInfoMessage(GetString("Size: {0}x{1}", Main.maxTilesX, Main.maxTilesY)); args.Player.SendInfoMessage(GetString($"ID: {Main.worldID}")); - args.Player.SendInfoMessage(GetString($"Seed: {WorldGen.currentWorldSeed}")); + args.Player.SendInfoMessage(GetString($"Seed: {Main.ActiveWorldFileData.SeedText}")); args.Player.SendInfoMessage(GetString($"Mode: {Main.GameMode}")); args.Player.SendInfoMessage(GetString($"Path: {Main.worldPathName}")); } @@ -2901,7 +2901,7 @@ namespace TShockAPI var npc = npcs[0]; if (npc.type >= 1 && npc.type < Terraria.ID.NPCID.Count && npc.type != 113) { - TSPlayer.Server.SpawnNPC(npc.netID, npc.FullName, amount, args.Player.TileX, args.Player.TileY, 50, 20); + TSPlayer.Server.SpawnNPC(npc.type, npc.FullName, amount, args.Player.TileX, args.Player.TileY, 50, 20); if (args.Silent) { args.Player.SendSuccessMessage(GetPluralString("Spawned {0} {1} time.", "Spawned {0} {1} times.", amount, npc.FullName, amount)); @@ -3141,7 +3141,7 @@ namespace TShockAPI var matches = new List(); foreach (var npc in Main.npc.Where(npc => npc.active)) { - var englishName = EnglishLanguage.GetNpcNameById(npc.netID); + var englishName = EnglishLanguage.GetNpcNameById(npc.type); if (string.Equals(npc.FullName, npcStr, StringComparison.InvariantCultureIgnoreCase) || string.Equals(englishName, npcStr, StringComparison.InvariantCultureIgnoreCase)) @@ -3841,7 +3841,7 @@ namespace TShockAPI } else if (items.Count > 1) { - args.Player.SendMultipleMatchError(items.Select(i => $"{i.Name}({i.netID})")); + args.Player.SendMultipleMatchError(items.Select(i => $"{i.Name}({i.type})")); } else { @@ -3892,7 +3892,7 @@ namespace TShockAPI } else if (items.Count > 1) { - args.Player.SendMultipleMatchError(items.Select(i => $"{i.Name}({i.netID})")); + args.Player.SendMultipleMatchError(items.Select(i => $"{i.Name}({i.type})")); } else { @@ -3937,7 +3937,7 @@ namespace TShockAPI } else if (items.Count > 1) { - args.Player.SendMultipleMatchError(items.Select(i => $"{i.Name}({i.netID})")); + args.Player.SendMultipleMatchError(items.Select(i => $"{i.Name}({i.type})")); } else { @@ -3963,7 +3963,7 @@ namespace TShockAPI } else if (items.Count > 1) { - args.Player.SendMultipleMatchError(items.Select(i => $"{i.Name}({i.netID})")); + args.Player.SendMultipleMatchError(items.Select(i => $"{i.Name}({i.type})")); } else { @@ -5919,7 +5919,7 @@ namespace TShockAPI if (Main.item[i].active && dX * dX + dY * dY <= radius * radius * 256f) { - Main.item[i].active = false; + Main.item[i].TurnToAir(); everyone.SendData(PacketTypes.ItemDrop, "", i); cleared++; } @@ -6109,13 +6109,13 @@ namespace TShockAPI user.SendMultipleMatchError(npcs.Select(n => $"{n.FullName}({n.type})")); return; } - npcId = npcs[0].netID; + npcId = npcs[0].type; } int kills = 0; for (int i = 0; i < Main.npc.Length; i++) { - if (Main.npc[i].active && ((npcId == 0 && !Main.npc[i].townNPC && Main.npc[i].netID != NPCID.TargetDummy) || Main.npc[i].netID == npcId)) + if (Main.npc[i].active && ((npcId == 0 && !Main.npc[i].townNPC && Main.npc[i].type != NPCID.TargetDummy) || Main.npc[i].type == npcId)) { TSPlayer.Server.StrikeNPC(i, (int)(Main.npc[i].life + (Main.npc[i].defense * 0.6)), 0, 0); kills++; @@ -6162,7 +6162,7 @@ namespace TShockAPI } else if (matchedItems.Count > 1) { - args.Player.SendMultipleMatchError(matchedItems.Select(i => $"{i.Name}({i.netID})")); + args.Player.SendMultipleMatchError(matchedItems.Select(i => $"{i.Name}({i.type})")); return; } else @@ -6255,13 +6255,13 @@ namespace TShockAPI } else { - npcId = npcs[0].netID; + npcId = npcs[0].type; } } int done = 0; for (int i = 0; i < Main.npc.Length; i++) { - if (Main.npc[i].active && ((npcId == 0 && !Main.npc[i].townNPC) || (Main.npc[i].netID == npcId && Main.npc[i].townNPC))) + if (Main.npc[i].active && ((npcId == 0 && !Main.npc[i].townNPC) || (Main.npc[i].type == npcId && Main.npc[i].townNPC))) { Main.npc[i].GivenName = args.Parameters[1]; NetMessage.SendData(56, -1, -1, NetworkText.FromLiteral(args.Parameters[1]), i, 0f, 0f, 0f, 0); @@ -6310,7 +6310,7 @@ namespace TShockAPI } else if (items.Count > 1) { - args.Player.SendMultipleMatchError(items.Select(i => $"{i.Name}({i.netID})")); + args.Player.SendMultipleMatchError(items.Select(i => $"{i.Name}({i.type})")); } else { diff --git a/TShockAPI/DB/CharacterManager.cs b/TShockAPI/DB/CharacterManager.cs index db14488c..69546797 100644 --- a/TShockAPI/DB/CharacterManager.cs +++ b/TShockAPI/DB/CharacterManager.cs @@ -71,7 +71,9 @@ namespace TShockAPI.DB new SqlColumn("unlockedSuperCart", MySqlDbType.Int32), new SqlColumn("enabledSuperCart", MySqlDbType.Int32), new SqlColumn("deathsPVE", MySqlDbType.Int32), - new SqlColumn("deathsPVP", MySqlDbType.Int32) + new SqlColumn("deathsPVP", MySqlDbType.Int32), + new SqlColumn("voiceVariant", MySqlDbType.Int32), + new SqlColumn("voicePitchOffset", MySqlDbType.Float) ); SqlTableCreator creator = new(db, db.GetSqlQueryBuilder()); @@ -136,6 +138,8 @@ namespace TShockAPI.DB playerData.enabledSuperCart = reader.Get("enabledSuperCart"); playerData.deathsPVE = reader.Get("deathsPVE"); playerData.deathsPVP = reader.Get("deathsPVP"); + playerData.voiceVariant = reader.Get("voiceVariant"); + playerData.voicePitchOffset = reader.Get("voicePitchOffset"); return playerData; } } @@ -204,8 +208,8 @@ namespace TShockAPI.DB try { database.Query( - "INSERT INTO tsCharacter (Account, Health, MaxHealth, Mana, MaxMana, Inventory, extraSlot, spawnX, spawnY, skinVariant, hair, hairDye, hairColor, pantsColor, shirtColor, underShirtColor, shoeColor, hideVisuals, skinColor, eyeColor, questsCompleted, usingBiomeTorches, happyFunTorchTime, unlockedBiomeTorches, currentLoadoutIndex,ateArtisanBread, usedAegisCrystal, usedAegisFruit, usedArcaneCrystal, usedGalaxyPearl, usedGummyWorm, usedAmbrosia, unlockedSuperCart, enabledSuperCart, deathsPVE, deathsPVP) VALUES (@0, @1, @2, @3, @4, @5, @6, @7, @8, @9, @10, @11, @12, @13, @14, @15, @16, @17, @18, @19, @20, @21, @22, @23, @24, @25, @26, @27, @28, @29, @30, @31, @32, @33, @34, @35);", - player.Account.ID, playerData.health, playerData.maxHealth, playerData.mana, playerData.maxMana, string.Join("~", playerData.inventory), playerData.extraSlot, player.TPlayer.SpawnX, player.TPlayer.SpawnY, player.TPlayer.skinVariant, player.TPlayer.hair, player.TPlayer.hairDye, TShock.Utils.EncodeColor(player.TPlayer.hairColor), TShock.Utils.EncodeColor(player.TPlayer.pantsColor),TShock.Utils.EncodeColor(player.TPlayer.shirtColor), TShock.Utils.EncodeColor(player.TPlayer.underShirtColor), TShock.Utils.EncodeColor(player.TPlayer.shoeColor), TShock.Utils.EncodeBoolArray(player.TPlayer.hideVisibleAccessory), TShock.Utils.EncodeColor(player.TPlayer.skinColor),TShock.Utils.EncodeColor(player.TPlayer.eyeColor), player.TPlayer.anglerQuestsFinished, player.TPlayer.UsingBiomeTorches ? 1 : 0, player.TPlayer.happyFunTorchTime ? 1 : 0, player.TPlayer.unlockedBiomeTorches ? 1 : 0, player.TPlayer.CurrentLoadoutIndex, player.TPlayer.ateArtisanBread ? 1 : 0, player.TPlayer.usedAegisCrystal ? 1 : 0, player.TPlayer.usedAegisFruit ? 1 : 0, player.TPlayer.usedArcaneCrystal ? 1 : 0, player.TPlayer.usedGalaxyPearl ? 1 : 0, player.TPlayer.usedGummyWorm ? 1 : 0, player.TPlayer.usedAmbrosia ? 1 : 0, player.TPlayer.unlockedSuperCart ? 1 : 0, player.TPlayer.enabledSuperCart ? 1 : 0, player.sscDeathsPVE, player.sscDeathsPVP); + "INSERT INTO tsCharacter (Account, Health, MaxHealth, Mana, MaxMana, Inventory, extraSlot, spawnX, spawnY, skinVariant, hair, hairDye, hairColor, pantsColor, shirtColor, underShirtColor, shoeColor, hideVisuals, skinColor, eyeColor, questsCompleted, usingBiomeTorches, happyFunTorchTime, unlockedBiomeTorches, currentLoadoutIndex,ateArtisanBread, usedAegisCrystal, usedAegisFruit, usedArcaneCrystal, usedGalaxyPearl, usedGummyWorm, usedAmbrosia, unlockedSuperCart, enabledSuperCart, deathsPVE, deathsPVP, voiceVariant, voicePitchOffset) VALUES (@0, @1, @2, @3, @4, @5, @6, @7, @8, @9, @10, @11, @12, @13, @14, @15, @16, @17, @18, @19, @20, @21, @22, @23, @24, @25, @26, @27, @28, @29, @30, @31, @32, @33, @34, @35, @36, @37);", + player.Account.ID, playerData.health, playerData.maxHealth, playerData.mana, playerData.maxMana, string.Join("~", playerData.inventory), playerData.extraSlot, player.TPlayer.SpawnX, player.TPlayer.SpawnY, player.TPlayer.skinVariant, player.TPlayer.hair, player.TPlayer.hairDye, TShock.Utils.EncodeColor(player.TPlayer.hairColor), TShock.Utils.EncodeColor(player.TPlayer.pantsColor),TShock.Utils.EncodeColor(player.TPlayer.shirtColor), TShock.Utils.EncodeColor(player.TPlayer.underShirtColor), TShock.Utils.EncodeColor(player.TPlayer.shoeColor), TShock.Utils.EncodeBoolArray(player.TPlayer.hideVisibleAccessory), TShock.Utils.EncodeColor(player.TPlayer.skinColor),TShock.Utils.EncodeColor(player.TPlayer.eyeColor), player.TPlayer.anglerQuestsFinished, player.TPlayer.UsingBiomeTorches ? 1 : 0, player.TPlayer.happyFunTorchTime ? 1 : 0, player.TPlayer.unlockedBiomeTorches ? 1 : 0, player.TPlayer.CurrentLoadoutIndex, player.TPlayer.ateArtisanBread ? 1 : 0, player.TPlayer.usedAegisCrystal ? 1 : 0, player.TPlayer.usedAegisFruit ? 1 : 0, player.TPlayer.usedArcaneCrystal ? 1 : 0, player.TPlayer.usedGalaxyPearl ? 1 : 0, player.TPlayer.usedGummyWorm ? 1 : 0, player.TPlayer.usedAmbrosia ? 1 : 0, player.TPlayer.unlockedSuperCart ? 1 : 0, player.TPlayer.enabledSuperCart ? 1 : 0, player.sscDeathsPVE, player.sscDeathsPVP, player.TPlayer.voiceVariant, player.TPlayer.voicePitchOffset); return true; } catch (Exception ex) @@ -218,8 +222,8 @@ namespace TShockAPI.DB try { database.Query( - "UPDATE tsCharacter SET Health = @0, MaxHealth = @1, Mana = @2, MaxMana = @3, Inventory = @4, spawnX = @6, spawnY = @7, hair = @8, hairDye = @9, hairColor = @10, pantsColor = @11, shirtColor = @12, underShirtColor = @13, shoeColor = @14, hideVisuals = @15, skinColor = @16, eyeColor = @17, questsCompleted = @18, skinVariant = @19, extraSlot = @20, usingBiomeTorches = @21, happyFunTorchTime = @22, unlockedBiomeTorches = @23, currentLoadoutIndex = @24, ateArtisanBread = @25, usedAegisCrystal = @26, usedAegisFruit = @27, usedArcaneCrystal = @28, usedGalaxyPearl = @29, usedGummyWorm = @30, usedAmbrosia = @31, unlockedSuperCart = @32, enabledSuperCart = @33, deathsPVE = @34, deathsPVP = @35 WHERE Account = @5;", - playerData.health, playerData.maxHealth, playerData.mana, playerData.maxMana, string.Join("~", playerData.inventory), player.Account.ID, player.TPlayer.SpawnX, player.TPlayer.SpawnY, player.TPlayer.hair, player.TPlayer.hairDye, TShock.Utils.EncodeColor(player.TPlayer.hairColor), TShock.Utils.EncodeColor(player.TPlayer.pantsColor), TShock.Utils.EncodeColor(player.TPlayer.shirtColor), TShock.Utils.EncodeColor(player.TPlayer.underShirtColor), TShock.Utils.EncodeColor(player.TPlayer.shoeColor), TShock.Utils.EncodeBoolArray(player.TPlayer.hideVisibleAccessory), TShock.Utils.EncodeColor(player.TPlayer.skinColor), TShock.Utils.EncodeColor(player.TPlayer.eyeColor), player.TPlayer.anglerQuestsFinished, player.TPlayer.skinVariant, player.TPlayer.extraAccessory ? 1 : 0, player.TPlayer.UsingBiomeTorches ? 1 : 0, player.TPlayer.happyFunTorchTime ? 1 : 0, player.TPlayer.unlockedBiomeTorches ? 1 : 0, player.TPlayer.CurrentLoadoutIndex, player.TPlayer.ateArtisanBread ? 1 : 0, player.TPlayer.usedAegisCrystal ? 1 : 0, player.TPlayer.usedAegisFruit ? 1 : 0, player.TPlayer.usedArcaneCrystal ? 1 : 0, player.TPlayer.usedGalaxyPearl ? 1 : 0, player.TPlayer.usedGummyWorm ? 1 : 0, player.TPlayer.usedAmbrosia ? 1 : 0, player.TPlayer.unlockedSuperCart ? 1 : 0, player.TPlayer.enabledSuperCart ? 1 : 0, player.sscDeathsPVE, player.sscDeathsPVP); + "UPDATE tsCharacter SET Health = @0, MaxHealth = @1, Mana = @2, MaxMana = @3, Inventory = @4, spawnX = @6, spawnY = @7, hair = @8, hairDye = @9, hairColor = @10, pantsColor = @11, shirtColor = @12, underShirtColor = @13, shoeColor = @14, hideVisuals = @15, skinColor = @16, eyeColor = @17, questsCompleted = @18, skinVariant = @19, extraSlot = @20, usingBiomeTorches = @21, happyFunTorchTime = @22, unlockedBiomeTorches = @23, currentLoadoutIndex = @24, ateArtisanBread = @25, usedAegisCrystal = @26, usedAegisFruit = @27, usedArcaneCrystal = @28, usedGalaxyPearl = @29, usedGummyWorm = @30, usedAmbrosia = @31, unlockedSuperCart = @32, enabledSuperCart = @33, deathsPVE = @34, deathsPVP = @35, voiceVariant = @36, voicePitchOffset= @37 WHERE Account = @5;", + playerData.health, playerData.maxHealth, playerData.mana, playerData.maxMana, string.Join("~", playerData.inventory), player.Account.ID, player.TPlayer.SpawnX, player.TPlayer.SpawnY, player.TPlayer.hair, player.TPlayer.hairDye, TShock.Utils.EncodeColor(player.TPlayer.hairColor), TShock.Utils.EncodeColor(player.TPlayer.pantsColor), TShock.Utils.EncodeColor(player.TPlayer.shirtColor), TShock.Utils.EncodeColor(player.TPlayer.underShirtColor), TShock.Utils.EncodeColor(player.TPlayer.shoeColor), TShock.Utils.EncodeBoolArray(player.TPlayer.hideVisibleAccessory), TShock.Utils.EncodeColor(player.TPlayer.skinColor), TShock.Utils.EncodeColor(player.TPlayer.eyeColor), player.TPlayer.anglerQuestsFinished, player.TPlayer.skinVariant, player.TPlayer.extraAccessory ? 1 : 0, player.TPlayer.UsingBiomeTorches ? 1 : 0, player.TPlayer.happyFunTorchTime ? 1 : 0, player.TPlayer.unlockedBiomeTorches ? 1 : 0, player.TPlayer.CurrentLoadoutIndex, player.TPlayer.ateArtisanBread ? 1 : 0, player.TPlayer.usedAegisCrystal ? 1 : 0, player.TPlayer.usedAegisFruit ? 1 : 0, player.TPlayer.usedArcaneCrystal ? 1 : 0, player.TPlayer.usedGalaxyPearl ? 1 : 0, player.TPlayer.usedGummyWorm ? 1 : 0, player.TPlayer.usedAmbrosia ? 1 : 0, player.TPlayer.unlockedSuperCart ? 1 : 0, player.TPlayer.enabledSuperCart ? 1 : 0, player.sscDeathsPVE, player.sscDeathsPVP, player.TPlayer.voiceVariant, player.TPlayer.voicePitchOffset); return true; } catch (Exception ex) @@ -274,7 +278,7 @@ namespace TShockAPI.DB try { database.Query( - "INSERT INTO tsCharacter (Account, Health, MaxHealth, Mana, MaxMana, Inventory, extraSlot, spawnX, spawnY, skinVariant, hair, hairDye, hairColor, pantsColor, shirtColor, underShirtColor, shoeColor, hideVisuals, skinColor, eyeColor, questsCompleted, usingBiomeTorches, happyFunTorchTime, unlockedBiomeTorches, currentLoadoutIndex, ateArtisanBread, usedAegisCrystal, usedAegisFruit, usedArcaneCrystal, usedGalaxyPearl, usedGummyWorm, usedAmbrosia, unlockedSuperCart, enabledSuperCart) VALUES (@0, @1, @2, @3, @4, @5, @6, @7, @8, @9, @10, @11, @12, @13, @14, @15, @16, @17, @18, @19, @20, @21, @22, @23, @24, @25, @26, @27, @28, @29, @30, @31, @32, @33, @34, @35);", + "INSERT INTO tsCharacter (Account, Health, MaxHealth, Mana, MaxMana, Inventory, extraSlot, spawnX, spawnY, skinVariant, hair, hairDye, hairColor, pantsColor, shirtColor, underShirtColor, shoeColor, hideVisuals, skinColor, eyeColor, questsCompleted, usingBiomeTorches, happyFunTorchTime, unlockedBiomeTorches, currentLoadoutIndex, ateArtisanBread, usedAegisCrystal, usedAegisFruit, usedArcaneCrystal, usedGalaxyPearl, usedGummyWorm, usedAmbrosia, unlockedSuperCart, enabledSuperCart,deathsPVE, deathsPVP, voiceVariant, voicePitchOffset) VALUES (@0, @1, @2, @3, @4, @5, @6, @7, @8, @9, @10, @11, @12, @13, @14, @15, @16, @17, @18, @19, @20, @21, @22, @23, @24, @25, @26, @27, @28, @29, @30, @31, @32, @33, @34, @35, @36, @37);", player.Account.ID, playerData.health, playerData.maxHealth, @@ -310,7 +314,9 @@ namespace TShockAPI.DB playerData.unlockedSuperCart, playerData.enabledSuperCart, playerData.deathsPVE, - playerData.deathsPVP + playerData.deathsPVP, + player.TPlayer.voiceVariant, + player.TPlayer.voicePitchOffset ); return true; } @@ -324,7 +330,7 @@ namespace TShockAPI.DB try { database.Query( - "UPDATE tsCharacter SET Health = @0, MaxHealth = @1, Mana = @2, MaxMana = @3, Inventory = @4, spawnX = @6, spawnY = @7, hair = @8, hairDye = @9, hairColor = @10, pantsColor = @11, shirtColor = @12, underShirtColor = @13, shoeColor = @14, hideVisuals = @15, skinColor = @16, eyeColor = @17, questsCompleted = @18, skinVariant = @19, extraSlot = @20, usingBiomeTorches = @21, happyFunTorchTime = @22, unlockedBiomeTorches = @23, currentLoadoutIndex = @24, ateArtisanBread = @25, usedAegisCrystal = @26, usedAegisFruit = @27, usedArcaneCrystal = @28, usedGalaxyPearl = @29, usedGummyWorm = @30, usedAmbrosia = @31, unlockedSuperCart = @32, enabledSuperCart = @33, deathsPVE = @34, deathsPVP = @35 WHERE Account = @5;", + "UPDATE tsCharacter SET Health = @0, MaxHealth = @1, Mana = @2, MaxMana = @3, Inventory = @4, spawnX = @6, spawnY = @7, hair = @8, hairDye = @9, hairColor = @10, pantsColor = @11, shirtColor = @12, underShirtColor = @13, shoeColor = @14, hideVisuals = @15, skinColor = @16, eyeColor = @17, questsCompleted = @18, skinVariant = @19, extraSlot = @20, usingBiomeTorches = @21, happyFunTorchTime = @22, unlockedBiomeTorches = @23, currentLoadoutIndex = @24, ateArtisanBread = @25, usedAegisCrystal = @26, usedAegisFruit = @27, usedArcaneCrystal = @28, usedGalaxyPearl = @29, usedGummyWorm = @30, usedAmbrosia = @31, unlockedSuperCart = @32, enabledSuperCart = @33, deathsPVE = @34, deathsPVP = @35, voiceVariant = @36, voicePitchOffset= @37 WHERE Account = @5;", playerData.health, playerData.maxHealth, playerData.mana, @@ -360,7 +366,9 @@ namespace TShockAPI.DB playerData.unlockedSuperCart, playerData.enabledSuperCart, playerData.deathsPVE, - playerData.deathsPVP + playerData.deathsPVP, + player.TPlayer.voiceVariant, + player.TPlayer.voicePitchOffset ); return true; } diff --git a/TShockAPI/DB/UserManager.cs b/TShockAPI/DB/UserManager.cs index e705e3fc..20d19dee 100644 --- a/TShockAPI/DB/UserManager.cs +++ b/TShockAPI/DB/UserManager.cs @@ -20,16 +20,15 @@ using System; using System.Data; using System.Collections.Generic; using System.Linq; -using System.Text; using MySql.Data.MySqlClient; using System.Text.RegularExpressions; using BCrypt.Net; -using System.Security.Cryptography; -using TShockAPI.DB.Queries; using TShockAPI.Hooks; namespace TShockAPI.DB { + extern alias BCryptNext; + /// UserAccountManager - Methods for dealing with database user accounts and other related functionality within TShock. public class UserAccountManager { @@ -465,14 +464,14 @@ namespace TShockAPI.DB { try { - if (BCrypt.Net.BCrypt.Verify(password, Password)) + if (BCryptNext::BCrypt.Net.BCrypt.Verify(password, Password)) { // If necessary, perform an upgrade to the highest work factor. UpgradePasswordWorkFactor(password); return true; } } - catch (SaltParseException) + catch (BCryptNext::BCrypt.Net.SaltParseException) { TShock.Log.ConsoleError(GetString($"Unable to verify the password hash for user {Name} ({ID})")); return false; @@ -520,12 +519,12 @@ namespace TShockAPI.DB } try { - Password = BCrypt.Net.BCrypt.HashPassword(password.Trim(), TShock.Config.Settings.BCryptWorkFactor); + Password = BCryptNext::BCrypt.Net.BCrypt.HashPassword(password.Trim(), TShock.Config.Settings.BCryptWorkFactor); } catch (ArgumentOutOfRangeException) { TShock.Log.ConsoleError(GetString("Invalid BCrypt work factor in config file! Creating new hash using default work factor.")); - Password = BCrypt.Net.BCrypt.HashPassword(password.Trim()); + Password = BCryptNext::BCrypt.Net.BCrypt.HashPassword(password.Trim()); } } @@ -539,7 +538,7 @@ namespace TShockAPI.DB int minLength = TShock.Config.Settings.MinimumPasswordLength; throw new ArgumentOutOfRangeException("password", GetString($"Password must be at least {minLength} characters.")); } - Password = BCrypt.Net.BCrypt.HashPassword(password.Trim(), workFactor); + Password = BCryptNext::BCrypt.Net.BCrypt.HashPassword(password.Trim(), workFactor); } #region IEquatable diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 402270fd..2d5d7f00 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -2435,6 +2435,8 @@ namespace TShockAPI byte playerid = args.Data.ReadInt8(); // 0-3 male; 4-7 female int skinVariant = args.Data.ReadByte(); + int voiceVariant = args.Data.ReadByte(); + float voicePitchOffset = args.Data.ReadSingle(); var hair = args.Data.ReadInt8(); string name = args.Data.ReadString(); byte hairDye = args.Data.ReadInt8(); @@ -2509,6 +2511,8 @@ namespace TShockAPI args.Player.TPlayer.hairColor = hairColor; args.Player.TPlayer.hairDye = hairDye; args.Player.TPlayer.skinVariant = skinVariant; + args.Player.TPlayer.voiceVariant = voiceVariant; + args.Player.TPlayer.voicePitchOffset = voicePitchOffset; args.Player.TPlayer.skinColor = skinColor; args.Player.TPlayer.eyeColor = eyeColor; args.Player.TPlayer.pantsColor = pantsColor; @@ -2743,14 +2747,14 @@ namespace TShockAPI if (Main.ServerSideCharacter) { // As long as the player has not changed his spawnpoint since initial connection, - // we should not use the client's spawnpoint value. This is because the spawnpoint - // value is not saved on the client when SSC is enabled. Hence, we have to assert - // the server-saved spawnpoint value until we can detect that the player has changed + // we should not use the client's spawnpoint value. This is because the spawnpoint + // value is not saved on the client when SSC is enabled. Hence, we have to assert + // the server-saved spawnpoint value until we can detect that the player has changed // his spawn. Once we detect the spawnpoint changed, the client's spawnpoint value // becomes the correct one to use. // - // Note that spawnpoint changes (right-clicking beds) are not broadcasted to the - // server. Hence, the only way to detect spawnpoint changes is from the + // Note that spawnpoint changes (right-clicking beds) are not broadcasted to the + // server. Hence, the only way to detect spawnpoint changes is from the // PlayerSpawn packet. // handle initial connection @@ -2766,13 +2770,13 @@ namespace TShockAPI args.Player.initialClientSpawnX = spawnX; args.Player.initialClientSpawnY = spawnY; - // we first let the game handle completing the connection (state 3 => 10), - // then we will spawn the player at the saved spawnpoint in the next second, + // we first let the game handle completing the connection (state 3 => 10), + // then we will spawn the player at the saved spawnpoint in the next second, // by reasserting the correct spawnpoint value return false; } - // once we detect the client has changed his spawnpoint in the current session, + // once we detect the client has changed his spawnpoint in the current session, // the client spawnpoint value will be correct for the rest of the session if (args.Player.spawnSynced || args.Player.initialClientSpawnX != spawnX || args.Player.initialClientSpawnY != spawnY) { @@ -2784,11 +2788,11 @@ namespace TShockAPI // spawn the player before teleporting NetMessage.SendData((int)PacketTypes.PlayerSpawn, -1, args.Player.Index, null, args.Player.Index, (int)PlayerSpawnContext.ReviveFromDeath); - // the player has not changed his spawnpoint yet, so we assert the server-saved spawnpoint + // the player has not changed his spawnpoint yet, so we assert the server-saved spawnpoint // by teleporting the player instead of letting the game use the client's incorrect spawnpoint. TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleSpawn force ssc teleport for {0} at ({1},{2})", args.Player.Name, args.TPlayer.SpawnX, args.TPlayer.SpawnY)); args.Player.TeleportSpawnpoint(); - + args.TPlayer.respawnTimer = respawnTimer; args.TPlayer.numberOfDeathsPVE = numberOfDeathsPVE; args.TPlayer.numberOfDeathsPVP = numberOfDeathsPVP; @@ -3886,7 +3890,7 @@ namespace TShockAPI if (type == 0 && !args.Player.HasPermission(Permissions.rod)) { TShock.Log.ConsoleDebug(GetString("GetDataHandlers / HandleTeleport rejected rod type {0} {1}", args.Player.Name, type)); - args.Player.SendErrorMessage(GetString("You do not have permission to teleport using items.")); // Was going to write using RoD but Hook of Disonnance and Potion of Return both use the same teleport packet as RoD. + args.Player.SendErrorMessage(GetString("You do not have permission to teleport using items.")); // Was going to write using RoD but Hook of Disonnance and Potion of Return both use the same teleport packet as RoD. args.Player.Teleport(args.TPlayer.position.X, args.TPlayer.position.Y); // Suggest renaming rod permission unless someone plans to add separate perms for the other 2 tp items. return true; } @@ -4418,7 +4422,7 @@ namespace TShockAPI TEDisplayDoll displayDoll = tileEntity as TEDisplayDoll; if (displayDoll != null) { - oldItem = displayDoll._items[slot]; + //oldItem = displayDoll._items[slot]; if (isDye) oldItem = displayDoll._dyes[slot]; diff --git a/TShockAPI/Handlers/NetModules/CreativeUnlocksHandler.cs b/TShockAPI/Handlers/NetModules/CreativeUnlocksHandler.cs index 92aff26b..62d349d3 100644 --- a/TShockAPI/Handlers/NetModules/CreativeUnlocksHandler.cs +++ b/TShockAPI/Handlers/NetModules/CreativeUnlocksHandler.cs @@ -15,10 +15,12 @@ namespace TShockAPI.Handlers.NetModules /// An unknown field. If this does not have a value of '0' the packet should be rejected. /// public byte UnknownField { get; set; } + /// /// ID of the item being sacrificed /// public ushort ItemId { get; set; } + /// /// Stack size of the item being sacrificed /// @@ -49,10 +51,11 @@ namespace TShockAPI.Handlers.NetModules /// public void HandlePacket(TSPlayer player, out bool rejectPacket) { - if (!Main.GameModeInfo.IsJourneyMode) + if (!Main.IsJourneyMode) { TShock.Log.ConsoleDebug( - GetString($"NetModuleHandler received attempt to unlock sacrifice while not in journey mode from {player.Name}") + GetString( + $"NetModuleHandler received attempt to unlock sacrifice while not in journey mode from {player.Name}") ); rejectPacket = true; @@ -62,7 +65,8 @@ namespace TShockAPI.Handlers.NetModules if (UnknownField != 0) { TShock.Log.ConsoleDebug( - GetString($"CreativeUnlocksHandler received non-vanilla unlock request. Random field value: {UnknownField} but should be 0 from {player.Name}") + GetString( + $"CreativeUnlocksHandler received non-vanilla unlock request. Random field value: {UnknownField} but should be 0 from {player.Name}") ); rejectPacket = true; @@ -78,7 +82,8 @@ namespace TShockAPI.Handlers.NetModules var totalSacrificed = TShock.ResearchDatastore.SacrificeItem(ItemId, Amount, player); - var response = NetCreativeUnlocksModule.SerializeItemSacrifice(ItemId, totalSacrificed); + var response = + NetCreativeUnlocksPlayerReportModule.SerializeSacrificeRequest(player.Index, ItemId, totalSacrificed); NetManager.Instance.Broadcast(response); rejectPacket = false; diff --git a/TShockAPI/ItemBans.cs b/TShockAPI/ItemBans.cs index df0d36b0..ffa35845 100644 --- a/TShockAPI/ItemBans.cs +++ b/TShockAPI/ItemBans.cs @@ -88,7 +88,7 @@ namespace TShockAPI UnTaint(player); // No matter the player type, we do a check when a player is holding an item that's banned. - if (DataModel.ItemIsBanned(EnglishLanguage.GetItemNameById(player.TPlayer.inventory[player.TPlayer.selectedItem].netID), player)) + if (DataModel.ItemIsBanned(EnglishLanguage.GetItemNameById(player.TPlayer.inventory[player.TPlayer.selectedItem].type), player)) { string itemName = player.TPlayer.inventory[player.TPlayer.selectedItem].Name; player.Disable(GetString($"holding banned item: {itemName}"), disableFlags); @@ -157,7 +157,7 @@ namespace TShockAPI TSPlayer player = args.Player; string itemName = player.TPlayer.inventory[args.SelectedItem].Name; - if (DataModel.ItemIsBanned(EnglishLanguage.GetItemNameById(player.TPlayer.inventory[args.SelectedItem].netID), args.Player)) + if (DataModel.ItemIsBanned(EnglishLanguage.GetItemNameById(player.TPlayer.inventory[args.SelectedItem].type), args.Player)) { player.TPlayer.controlUseItem = false; player.Disable(GetString($"holding banned item: {itemName}"), disableFlags); @@ -204,7 +204,7 @@ namespace TShockAPI return; } - if (DataModel.ItemIsBanned(EnglishLanguage.GetItemNameById(args.Player.SelectedItem.netID), args.Player)) + if (DataModel.ItemIsBanned(EnglishLanguage.GetItemNameById(args.Player.SelectedItem.type), args.Player)) { args.Player.SendTileSquareCentered(args.X, args.Y, 4); args.Handled = true; diff --git a/TShockAPI/NetItem.cs b/TShockAPI/NetItem.cs index 0f0dc6e3..70c794de 100644 --- a/TShockAPI/NetItem.cs +++ b/TShockAPI/NetItem.cs @@ -94,37 +94,71 @@ namespace TShockAPI /// /// 180 - The inventory size (inventory, held item, armour, dies, coins, ammo, piggy, safe, and trash) /// - public static readonly int MaxInventory = InventorySlots + ArmorSlots + DyeSlots + MiscEquipSlots + MiscDyeSlots + PiggySlots + - SafeSlots + ForgeSlots + VoidSlots + TrashSlots + (LoadoutArmorSlots * 3) + + public static readonly int MaxInventory = InventorySlots + ArmorSlots + DyeSlots + MiscEquipSlots + + MiscDyeSlots + PiggySlots + + SafeSlots + ForgeSlots + VoidSlots + TrashSlots + + (LoadoutArmorSlots * 3) + (LoadoutDyeSlots * 3); public static readonly Tuple InventoryIndex = new Tuple(0, InventorySlots); - public static readonly Tuple ArmorIndex = new Tuple(InventoryIndex.Item2, InventoryIndex.Item2 + ArmorSlots); - public static readonly Tuple DyeIndex = new Tuple(ArmorIndex.Item2, ArmorIndex.Item2 + DyeSlots); - public static readonly Tuple MiscEquipIndex = new Tuple(DyeIndex.Item2, DyeIndex.Item2 + MiscEquipSlots); - public static readonly Tuple MiscDyeIndex = new Tuple(MiscEquipIndex.Item2, MiscEquipIndex.Item2 + MiscDyeSlots); - public static readonly Tuple PiggyIndex = new Tuple(MiscDyeIndex.Item2, MiscDyeIndex.Item2 + PiggySlots); - public static readonly Tuple SafeIndex = new Tuple(PiggyIndex.Item2, PiggyIndex.Item2 + SafeSlots); - public static readonly Tuple TrashIndex = new Tuple(SafeIndex.Item2, SafeIndex.Item2 + TrashSlots); - public static readonly Tuple ForgeIndex = new Tuple(TrashIndex.Item2, TrashIndex.Item2 + ForgeSlots); - public static readonly Tuple VoidIndex = new Tuple(ForgeIndex.Item2, ForgeIndex.Item2 + VoidSlots); - public static readonly Tuple Loadout1Armor = new Tuple(VoidIndex.Item2, VoidIndex.Item2 + LoadoutArmorSlots); - public static readonly Tuple Loadout1Dye = new Tuple(Loadout1Armor.Item2, Loadout1Armor.Item2 + LoadoutDyeSlots); + public static readonly Tuple ArmorIndex = + new Tuple(InventoryIndex.Item2, InventoryIndex.Item2 + ArmorSlots); - public static readonly Tuple Loadout2Armor = new Tuple(Loadout1Dye.Item2, Loadout1Dye.Item2 + LoadoutArmorSlots); - public static readonly Tuple Loadout2Dye = new Tuple(Loadout2Armor.Item2, Loadout2Armor.Item2 + LoadoutDyeSlots); + public static readonly Tuple DyeIndex = + new Tuple(ArmorIndex.Item2, ArmorIndex.Item2 + DyeSlots); - public static readonly Tuple Loadout3Armor = new Tuple(Loadout2Dye.Item2, Loadout2Dye.Item2 + LoadoutArmorSlots); - public static readonly Tuple Loadout3Dye = new Tuple(Loadout3Armor.Item2, Loadout3Armor.Item2 + LoadoutDyeSlots); + public static readonly Tuple MiscEquipIndex = + new Tuple(DyeIndex.Item2, DyeIndex.Item2 + MiscEquipSlots); + + public static readonly Tuple MiscDyeIndex = + new Tuple(MiscEquipIndex.Item2, MiscEquipIndex.Item2 + MiscDyeSlots); + + public static readonly Tuple PiggyIndex = + new Tuple(MiscDyeIndex.Item2, MiscDyeIndex.Item2 + PiggySlots); + + public static readonly Tuple SafeIndex = + new Tuple(PiggyIndex.Item2, PiggyIndex.Item2 + SafeSlots); + + public static readonly Tuple TrashIndex = + new Tuple(SafeIndex.Item2, SafeIndex.Item2 + TrashSlots); + + public static readonly Tuple ForgeIndex = + new Tuple(TrashIndex.Item2, TrashIndex.Item2 + ForgeSlots); + + public static readonly Tuple VoidIndex = + new Tuple(ForgeIndex.Item2, ForgeIndex.Item2 + VoidSlots); + + public static readonly Tuple Loadout1Armor = + new Tuple(VoidIndex.Item2, VoidIndex.Item2 + LoadoutArmorSlots); + + public static readonly Tuple Loadout1Dye = + new Tuple(Loadout1Armor.Item2, Loadout1Armor.Item2 + LoadoutDyeSlots); + + public static readonly Tuple Loadout2Armor = + new Tuple(Loadout1Dye.Item2, Loadout1Dye.Item2 + LoadoutArmorSlots); + + public static readonly Tuple Loadout2Dye = + new Tuple(Loadout2Armor.Item2, Loadout2Armor.Item2 + LoadoutDyeSlots); + + public static readonly Tuple Loadout3Armor = + new Tuple(Loadout2Dye.Item2, Loadout2Dye.Item2 + LoadoutArmorSlots); + + public static readonly Tuple Loadout3Dye = + new Tuple(Loadout3Armor.Item2, Loadout3Armor.Item2 + LoadoutDyeSlots); [JsonProperty("netID")] private int _netId; + [JsonProperty("prefix")] private byte _prefixId; + [JsonProperty("stack")] private int _stack; + [JsonProperty("favorited")] + private bool _favorited; + /// /// Gets the net ID. /// @@ -149,17 +183,28 @@ namespace TShockAPI get { return _stack; } } + /// + /// Gets the favorited. + /// + public bool Favorited + { + get { return _favorited; } + } + + /// /// Creates a new . /// /// The net ID. /// The stack. /// The prefix ID. - public NetItem(int netId, int stack = 1, byte prefixId = 0) + /// The favorited. + public NetItem(int netId, int stack = 1, byte prefixId = 0, bool favorited = false) { _netId = netId; _stack = stack; _prefixId = prefixId; + _favorited = favorited; } /// @@ -168,9 +213,10 @@ namespace TShockAPI /// Item in the game. public NetItem(Item item) { - _netId = item.netID; + _netId = item.type; _stack = item.stack; _prefixId = item.prefix; + _favorited = item.favorited; } /// @@ -184,6 +230,7 @@ namespace TShockAPI item.netDefaults(_netId); item.stack = _stack; item.prefix = _prefixId; + item.favorited = _favorited; return item; } @@ -194,7 +241,7 @@ namespace TShockAPI /// public override string ToString() { - return String.Format("{0},{1},{2}", _netId, _stack, _prefixId); + return String.Format("{0},{1},{2},{3}", _netId, _stack, _prefixId, _favorited ? 1 : 0); } /// @@ -216,8 +263,9 @@ namespace TShockAPI int netId = Int32.Parse(comp[0]); int stack = Int32.Parse(comp[1]); byte prefixId = Byte.Parse(comp[2]); + bool favorited = Int32.Parse(comp[3]) == 1; - return new NetItem(netId, stack, prefixId); + return new NetItem(netId, stack, prefixId, favorited); } /// @@ -229,7 +277,7 @@ namespace TShockAPI { return item == null ? new NetItem() - : new NetItem(item.netID, item.stack, item.prefix); + : new NetItem(item.type, item.stack, item.prefix, item.favorited); } } } diff --git a/TShockAPI/PlayerData.cs b/TShockAPI/PlayerData.cs index 1ab5430f..cba60116 100644 --- a/TShockAPI/PlayerData.cs +++ b/TShockAPI/PlayerData.cs @@ -39,6 +39,8 @@ namespace TShockAPI public int spawnY = -1; public int? extraSlot; public int? skinVariant; + public int? voiceVariant; + public float? voicePitchOffset; public int? hair; public byte hairDye; public Color? hairColor; @@ -130,6 +132,8 @@ namespace TShockAPI this.spawnY = player.TPlayer.SpawnY; extraSlot = player.TPlayer.extraAccessory ? 1 : 0; this.skinVariant = player.TPlayer.skinVariant; + this.voiceVariant = player.TPlayer.voiceVariant; + this.voicePitchOffset = player.TPlayer.voicePitchOffset; this.hair = player.TPlayer.hair; this.hairDye = player.TPlayer.hairDye; this.hairColor = player.TPlayer.hairColor; @@ -304,6 +308,10 @@ namespace TShockAPI player.TPlayer.extraAccessory = extraSlot.Value == 1 ? true : false; if (this.skinVariant != null) player.TPlayer.skinVariant = this.skinVariant.Value; + if (this.voiceVariant != null) + player.TPlayer.voiceVariant = this.voiceVariant.Value; + if (this.voicePitchOffset != null) + player.TPlayer.voicePitchOffset = this.voicePitchOffset.Value; if (this.hair != null) player.TPlayer.hair = this.hair.Value; if (this.hairColor != null) @@ -333,10 +341,11 @@ namespace TShockAPI //0-58 player.TPlayer.inventory[i].netDefaults(this.inventory[i].NetId); - if (player.TPlayer.inventory[i].netID != 0) + if (player.TPlayer.inventory[i].type!= 0) { player.TPlayer.inventory[i].stack = this.inventory[i].Stack; player.TPlayer.inventory[i].prefix = this.inventory[i].PrefixId; + player.TPlayer.inventory[i].favorited = this.inventory[i].Favorited; } } else if (i < NetItem.ArmorIndex.Item2) @@ -345,7 +354,7 @@ namespace TShockAPI var index = i - NetItem.ArmorIndex.Item1; player.TPlayer.armor[index].netDefaults(this.inventory[i].NetId); - if (player.TPlayer.armor[index].netID != 0) + if (player.TPlayer.armor[index].type != 0) { player.TPlayer.armor[index].stack = this.inventory[i].Stack; player.TPlayer.armor[index].prefix = (byte)this.inventory[i].PrefixId; @@ -357,7 +366,7 @@ namespace TShockAPI var index = i - NetItem.DyeIndex.Item1; player.TPlayer.dye[index].netDefaults(this.inventory[i].NetId); - if (player.TPlayer.dye[index].netID != 0) + if (player.TPlayer.dye[index].type != 0) { player.TPlayer.dye[index].stack = this.inventory[i].Stack; player.TPlayer.dye[index].prefix = (byte)this.inventory[i].PrefixId; @@ -369,7 +378,7 @@ namespace TShockAPI var index = i - NetItem.MiscEquipIndex.Item1; player.TPlayer.miscEquips[index].netDefaults(this.inventory[i].NetId); - if (player.TPlayer.miscEquips[index].netID != 0) + if (player.TPlayer.miscEquips[index].type != 0) { player.TPlayer.miscEquips[index].stack = this.inventory[i].Stack; player.TPlayer.miscEquips[index].prefix = (byte)this.inventory[i].PrefixId; @@ -381,7 +390,7 @@ namespace TShockAPI var index = i - NetItem.MiscDyeIndex.Item1; player.TPlayer.miscDyes[index].netDefaults(this.inventory[i].NetId); - if (player.TPlayer.miscDyes[index].netID != 0) + if (player.TPlayer.miscDyes[index].type != 0) { player.TPlayer.miscDyes[index].stack = this.inventory[i].Stack; player.TPlayer.miscDyes[index].prefix = (byte)this.inventory[i].PrefixId; @@ -393,7 +402,7 @@ namespace TShockAPI var index = i - NetItem.PiggyIndex.Item1; player.TPlayer.bank.item[index].netDefaults(this.inventory[i].NetId); - if (player.TPlayer.bank.item[index].netID != 0) + if (player.TPlayer.bank.item[index].type != 0) { player.TPlayer.bank.item[index].stack = this.inventory[i].Stack; player.TPlayer.bank.item[index].prefix = (byte)this.inventory[i].PrefixId; @@ -405,7 +414,7 @@ namespace TShockAPI var index = i - NetItem.SafeIndex.Item1; player.TPlayer.bank2.item[index].netDefaults(this.inventory[i].NetId); - if (player.TPlayer.bank2.item[index].netID != 0) + if (player.TPlayer.bank2.item[index].type != 0) { player.TPlayer.bank2.item[index].stack = this.inventory[i].Stack; player.TPlayer.bank2.item[index].prefix = (byte)this.inventory[i].PrefixId; @@ -417,7 +426,7 @@ namespace TShockAPI var index = i - NetItem.TrashIndex.Item1; player.TPlayer.trashItem.netDefaults(this.inventory[i].NetId); - if (player.TPlayer.trashItem.netID != 0) + if (player.TPlayer.trashItem.type != 0) { player.TPlayer.trashItem.stack = this.inventory[i].Stack; player.TPlayer.trashItem.prefix = (byte)this.inventory[i].PrefixId; @@ -429,7 +438,7 @@ namespace TShockAPI var index = i - NetItem.ForgeIndex.Item1; player.TPlayer.bank3.item[index].netDefaults(this.inventory[i].NetId); - if (player.TPlayer.bank3.item[index].netID != 0) + if (player.TPlayer.bank3.item[index].type != 0) { player.TPlayer.bank3.item[index].stack = this.inventory[i].Stack; player.TPlayer.bank3.item[index].Prefix((byte)this.inventory[i].PrefixId); @@ -441,7 +450,7 @@ namespace TShockAPI var index = i - NetItem.VoidIndex.Item1; player.TPlayer.bank4.item[index].netDefaults(this.inventory[i].NetId); - if (player.TPlayer.bank4.item[index].netID != 0) + if (player.TPlayer.bank4.item[index].type != 0) { player.TPlayer.bank4.item[index].stack = this.inventory[i].Stack; player.TPlayer.bank4.item[index].Prefix((byte)this.inventory[i].PrefixId); @@ -452,7 +461,7 @@ namespace TShockAPI var index = i - NetItem.Loadout1Armor.Item1; player.TPlayer.Loadouts[0].Armor[index].netDefaults(this.inventory[i].NetId); - if (player.TPlayer.Loadouts[0].Armor[index].netID != 0) + if (player.TPlayer.Loadouts[0].Armor[index].type != 0) { player.TPlayer.Loadouts[0].Armor[index].stack = this.inventory[i].Stack; player.TPlayer.Loadouts[0].Armor[index].Prefix((byte)this.inventory[i].PrefixId); @@ -463,7 +472,7 @@ namespace TShockAPI var index = i - NetItem.Loadout1Dye.Item1; player.TPlayer.Loadouts[0].Dye[index].netDefaults(this.inventory[i].NetId); - if (player.TPlayer.Loadouts[0].Dye[index].netID != 0) + if (player.TPlayer.Loadouts[0].Dye[index].type != 0) { player.TPlayer.Loadouts[0].Dye[index].stack = this.inventory[i].Stack; player.TPlayer.Loadouts[0].Dye[index].Prefix((byte)this.inventory[i].PrefixId); @@ -474,7 +483,7 @@ namespace TShockAPI var index = i - NetItem.Loadout2Armor.Item1; player.TPlayer.Loadouts[1].Armor[index].netDefaults(this.inventory[i].NetId); - if (player.TPlayer.Loadouts[1].Armor[index].netID != 0) + if (player.TPlayer.Loadouts[1].Armor[index].type != 0) { player.TPlayer.Loadouts[1].Armor[index].stack = this.inventory[i].Stack; player.TPlayer.Loadouts[1].Armor[index].Prefix((byte)this.inventory[i].PrefixId); @@ -485,7 +494,7 @@ namespace TShockAPI var index = i - NetItem.Loadout2Dye.Item1; player.TPlayer.Loadouts[1].Dye[index].netDefaults(this.inventory[i].NetId); - if (player.TPlayer.Loadouts[1].Dye[index].netID != 0) + if (player.TPlayer.Loadouts[1].Dye[index].type != 0) { player.TPlayer.Loadouts[1].Dye[index].stack = this.inventory[i].Stack; player.TPlayer.Loadouts[1].Dye[index].Prefix((byte)this.inventory[i].PrefixId); @@ -496,7 +505,7 @@ namespace TShockAPI var index = i - NetItem.Loadout3Armor.Item1; player.TPlayer.Loadouts[2].Armor[index].netDefaults(this.inventory[i].NetId); - if (player.TPlayer.Loadouts[2].Armor[index].netID != 0) + if (player.TPlayer.Loadouts[2].Armor[index].type != 0) { player.TPlayer.Loadouts[2].Armor[index].stack = this.inventory[i].Stack; player.TPlayer.Loadouts[2].Armor[index].Prefix((byte)this.inventory[i].PrefixId); @@ -507,7 +516,7 @@ namespace TShockAPI var index = i - NetItem.Loadout3Dye.Item1; player.TPlayer.Loadouts[2].Dye[index].netDefaults(this.inventory[i].NetId); - if (player.TPlayer.Loadouts[2].Dye[index].netID != 0) + if (player.TPlayer.Loadouts[2].Dye[index].type != 0) { player.TPlayer.Loadouts[2].Dye[index].stack = this.inventory[i].Stack; player.TPlayer.Loadouts[2].Dye[index].Prefix((byte)this.inventory[i].PrefixId); @@ -708,7 +717,7 @@ namespace TShockAPI NetMessage.SendData(39, player.Index, -1, NetworkText.Empty, 400); - if (Main.GameModeInfo.IsJourneyMode) + if (Main.IsJourneyMode) { var sacrificedItems = TShock.ResearchDatastore.GetSacrificedItems(); for(int i = 0; i < ItemID.Count; i++) @@ -719,7 +728,7 @@ namespace TShockAPI amount = sacrificedItems[i]; } - var response = NetCreativeUnlocksModule.SerializeItemSacrifice(i, amount); + var response = NetCreativeUnlocksPlayerReportModule.SerializeSacrificeRequest(player.Index,i, amount); NetManager.Instance.SendToClient(response, player.Index); } } diff --git a/TShockAPI/Rest/RestManager.cs b/TShockAPI/Rest/RestManager.cs index 5dd2ff20..0b420d45 100644 --- a/TShockAPI/Rest/RestManager.cs +++ b/TShockAPI/Rest/RestManager.cs @@ -989,7 +989,7 @@ namespace TShockAPI {"muted", player.mute }, {"position", player.TileX + "," + player.TileY}, {"inventory", string.Join(", ", inventory.Select(p => (p.Name + ":" + p.stack)))}, - {"armor", string.Join(", ", equipment.Select(p => (p.netID + ":" + p.prefix)))}, + {"armor", string.Join(", ", equipment.Select(p => (p.type + ":" + p.prefix)))}, {"dyes", string.Join(", ", dyes.Select(p => (p.Name)))}, {"buffs", string.Join(", ", player.TPlayer.buffType)} }; diff --git a/TShockAPI/Sockets/LinuxTcpSocket.cs b/TShockAPI/Sockets/LinuxTcpSocket.cs index 5a95794b..d2a0acaf 100644 --- a/TShockAPI/Sockets/LinuxTcpSocket.cs +++ b/TShockAPI/Sockets/LinuxTcpSocket.cs @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -using System; +using System; using System.Collections.Generic; using System.Net; using System.Net.Sockets; @@ -123,10 +123,6 @@ namespace TShockAPI.Sockets } } - void ISocket.SendQueuedPackets() - { - } - void ISocket.AsyncSend(byte[] data, int offset, int size, SocketSendCallback callback, object state) { byte[] array = LegacyNetBufferPool.RequestBuffer(data, offset, size); diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 52d319fc..ccd74de3 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -494,9 +494,9 @@ namespace TShockAPI // From above: this is slots 0-58 in the inventory. // 0-58 Item item = new Item(); - if (inventory[i] != null && inventory[i].netID != 0) + if (inventory[i] != null && inventory[i].type != 0) { - item.netDefaults(inventory[i].netID); + item.netDefaults(inventory[i].type); item.Prefix(inventory[i].prefix); item.AffixName(); if (inventory[i].stack > item.maxStack || inventory[i].stack < 0) @@ -514,9 +514,9 @@ namespace TShockAPI // 59-78 var index = i - NetItem.ArmorIndex.Item1; Item item = new Item(); - if (armor[index] != null && armor[index].netID != 0) + if (armor[index] != null && armor[index].type != 0) { - item.netDefaults(armor[index].netID); + item.netDefaults(armor[index].type); item.Prefix(armor[index].prefix); item.AffixName(); if (armor[index].stack > item.maxStack || armor[index].stack < 0) @@ -534,9 +534,9 @@ namespace TShockAPI // 79-88 var index = i - NetItem.DyeIndex.Item1; Item item = new Item(); - if (dye[index] != null && dye[index].netID != 0) + if (dye[index] != null && dye[index].type != 0) { - item.netDefaults(dye[index].netID); + item.netDefaults(dye[index].type); item.Prefix(dye[index].prefix); item.AffixName(); if (dye[index].stack > item.maxStack || dye[index].stack < 0) @@ -554,9 +554,9 @@ namespace TShockAPI // 89-93 var index = i - NetItem.MiscEquipIndex.Item1; Item item = new Item(); - if (miscEquips[index] != null && miscEquips[index].netID != 0) + if (miscEquips[index] != null && miscEquips[index].type != 0) { - item.netDefaults(miscEquips[index].netID); + item.netDefaults(miscEquips[index].type); item.Prefix(miscEquips[index].prefix); item.AffixName(); if (miscEquips[index].stack > item.maxStack || miscEquips[index].stack < 0) @@ -574,9 +574,9 @@ namespace TShockAPI // 93-98 var index = i - NetItem.MiscDyeIndex.Item1; Item item = new Item(); - if (miscDyes[index] != null && miscDyes[index].netID != 0) + if (miscDyes[index] != null && miscDyes[index].type != 0) { - item.netDefaults(miscDyes[index].netID); + item.netDefaults(miscDyes[index].type); item.Prefix(miscDyes[index].prefix); item.AffixName(); if (miscDyes[index].stack > item.maxStack || miscDyes[index].stack < 0) @@ -594,9 +594,9 @@ namespace TShockAPI // 98-138 var index = i - NetItem.PiggyIndex.Item1; Item item = new Item(); - if (piggy[index] != null && piggy[index].netID != 0) + if (piggy[index] != null && piggy[index].type != 0) { - item.netDefaults(piggy[index].netID); + item.netDefaults(piggy[index].type); item.Prefix(piggy[index].prefix); item.AffixName(); @@ -615,9 +615,9 @@ namespace TShockAPI // 138-178 var index = i - NetItem.SafeIndex.Item1; Item item = new Item(); - if (safe[index] != null && safe[index].netID != 0) + if (safe[index] != null && safe[index].type != 0) { - item.netDefaults(safe[index].netID); + item.netDefaults(safe[index].type); item.Prefix(safe[index].prefix); item.AffixName(); @@ -635,9 +635,9 @@ namespace TShockAPI { // 178-179 Item item = new Item(); - if (trash != null && trash.netID != 0) + if (trash != null && trash.type != 0) { - item.netDefaults(trash.netID); + item.netDefaults(trash.type); item.Prefix(trash.prefix); item.AffixName(); @@ -656,9 +656,9 @@ namespace TShockAPI // 179-220 var index = i - NetItem.ForgeIndex.Item1; Item item = new Item(); - if (forge[index] != null && forge[index].netID != 0) + if (forge[index] != null && forge[index].type != 0) { - item.netDefaults(forge[index].netID); + item.netDefaults(forge[index].type); item.Prefix(forge[index].prefix); item.AffixName(); @@ -677,9 +677,9 @@ namespace TShockAPI // 220-260 var index = i - NetItem.VoidIndex.Item1; Item item = new Item(); - if (voidVault[index] != null && voidVault[index].netID != 0) + if (voidVault[index] != null && voidVault[index].type != 0) { - item.netDefaults(voidVault[index].netID); + item.netDefaults(voidVault[index].type); item.Prefix(voidVault[index].prefix); item.AffixName(); @@ -697,9 +697,9 @@ namespace TShockAPI { var index = i - NetItem.Loadout1Armor.Item1; Item item = new Item(); - if (loadout1Armor[index] != null && loadout1Armor[index].netID != 0) + if (loadout1Armor[index] != null && loadout1Armor[index].type != 0) { - item.netDefaults(loadout1Armor[index].netID); + item.netDefaults(loadout1Armor[index].type); item.Prefix(loadout1Armor[index].prefix); item.AffixName(); @@ -717,9 +717,9 @@ namespace TShockAPI { var index = i - NetItem.Loadout1Dye.Item1; Item item = new Item(); - if (loadout1Dye[index] != null && loadout1Dye[index].netID != 0) + if (loadout1Dye[index] != null && loadout1Dye[index].type != 0) { - item.netDefaults(loadout1Dye[index].netID); + item.netDefaults(loadout1Dye[index].type); item.Prefix(loadout1Dye[index].prefix); item.AffixName(); @@ -737,9 +737,9 @@ namespace TShockAPI { var index = i - NetItem.Loadout2Armor.Item1; Item item = new Item(); - if (loadout2Armor[index] != null && loadout2Armor[index].netID != 0) + if (loadout2Armor[index] != null && loadout2Armor[index].type != 0) { - item.netDefaults(loadout2Armor[index].netID); + item.netDefaults(loadout2Armor[index].type); item.Prefix(loadout2Armor[index].prefix); item.AffixName(); @@ -757,9 +757,9 @@ namespace TShockAPI { var index = i - NetItem.Loadout2Dye.Item1; Item item = new Item(); - if (loadout2Dye[index] != null && loadout2Dye[index].netID != 0) + if (loadout2Dye[index] != null && loadout2Dye[index].type != 0) { - item.netDefaults(loadout2Dye[index].netID); + item.netDefaults(loadout2Dye[index].type); item.Prefix(loadout2Dye[index].prefix); item.AffixName(); @@ -777,9 +777,9 @@ namespace TShockAPI { var index = i - NetItem.Loadout3Armor.Item1; Item item = new Item(); - if (loadout3Armor[index] != null && loadout3Armor[index].netID != 0) + if (loadout3Armor[index] != null && loadout3Armor[index].type != 0) { - item.netDefaults(loadout3Armor[index].netID); + item.netDefaults(loadout3Armor[index].type); item.Prefix(loadout3Armor[index].prefix); item.AffixName(); @@ -797,9 +797,9 @@ namespace TShockAPI { var index = i - NetItem.Loadout3Dye.Item1; Item item = new Item(); - if (loadout3Dye[index] != null && loadout3Dye[index].netID != 0) + if (loadout3Dye[index] != null && loadout3Dye[index].type != 0) { - item.netDefaults(loadout3Dye[index].netID); + item.netDefaults(loadout3Dye[index].type); item.Prefix(loadout3Dye[index].prefix); item.AffixName(); @@ -1476,7 +1476,7 @@ namespace TShockAPI } /// - /// Teleports the player to their spawnpoint. + /// Teleports the player to their spawnpoint. /// Teleports to main spawnpoint if their bed is not active. /// Supports SSC. /// @@ -1485,7 +1485,7 @@ namespace TShockAPI // NOTE: it is vanilla behaviour to not permanently override the spawnpoint if the bed spawn is broken/invalid int x = TPlayer.SpawnX; int y = TPlayer.SpawnY; - if ((x == -1 && y == -1) || + if ((x == -1 && y == -1) || !Main.tile[x, y - 1].active() || Main.tile[x, y - 1].type != TileID.Beds || !WorldGen.StartRoomCheck(x, y - 1)) { x = Main.spawnTileX; @@ -1632,7 +1632,7 @@ namespace TShockAPI { Client.TileSections[i, j] = isLoaded; } - } + } } else { @@ -1759,7 +1759,7 @@ namespace TShockAPI private Item GiveItemDirectly_FillIntoOccupiedSlot(Item item, int slot) { var inv = this.TPlayer.inventory; - if (inv[slot].type <= 0 || inv[slot].stack >= inv[slot].maxStack || !item.IsTheSameAs(inv[slot])) + if (inv[slot].type <= 0 || inv[slot].stack >= inv[slot].maxStack || item.IsNotTheSameAs(inv[slot])) return item; if (item.stack + inv[slot].stack <= inv[slot].maxStack) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index dbfc7bbb..9d448376 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -62,7 +62,7 @@ namespace TShockAPI /// VersionNum - The version number the TerrariaAPI will return back to the API. We just use the Assembly info. public static readonly Version VersionNum = Assembly.GetExecutingAssembly().GetName().Version; /// VersionCodename - The version codename is displayed when the server starts. Inspired by software codenames conventions. - public static readonly string VersionCodename = "Hopefully SSC works somewhat correctly now edition"; + public static readonly string VersionCodename = "!!! You are using a dangerous testing version !!!"; /// SavePath - This is the path TShock saves its data in. This path is relative to the TerrariaServer.exe (not in ServerPlugins). public static string SavePath = "tshock"; @@ -1028,7 +1028,7 @@ namespace TShockAPI Console.WriteLine(GetString("This token will display until disabled by verification. ({0}setup)", Commands.Specifier)); Console.ResetColor(); } - + Log.ConsoleError(GetString("!!! You are using a dangerous testing version !!!")); Regions.Reload(); Warps.ReloadWarps(); diff --git a/TShockAPI/TShockAPI.csproj b/TShockAPI/TShockAPI.csproj index 954858a1..1a8d7bf3 100644 --- a/TShockAPI/TShockAPI.csproj +++ b/TShockAPI/TShockAPI.csproj @@ -32,7 +32,9 @@ - + + BCryptNext + diff --git a/TShockAPI/Utils.cs b/TShockAPI/Utils.cs index 7a3cad6c..0731fa8b 100644 --- a/TShockAPI/Utils.cs +++ b/TShockAPI/Utils.cs @@ -931,7 +931,7 @@ namespace TShockAPI /// The NetID surrounded by the item tag with proper stack/prefix data. public string ItemTag(Item item) { - int netID = item.netID; + int netID = item.type; int stack = item.stack; int prefix = item.prefix; string options = stack > 1 ? "/s" + stack : prefix != 0 ? "/p" + prefix : ""; diff --git a/TShockLauncher/TShockLauncher.csproj b/TShockLauncher/TShockLauncher.csproj index 95b85859..ef059a14 100644 --- a/TShockLauncher/TShockLauncher.csproj +++ b/TShockLauncher/TShockLauncher.csproj @@ -51,6 +51,7 @@ PreserveNewest true + diff --git a/lib/OTAPI.Runtime.dll b/lib/OTAPI.Runtime.dll index 59436338..4f657926 100644 Binary files a/lib/OTAPI.Runtime.dll and b/lib/OTAPI.Runtime.dll differ diff --git a/lib/OTAPI.dll b/lib/OTAPI.dll index ac47492c..48c1dab1 100644 Binary files a/lib/OTAPI.dll and b/lib/OTAPI.dll differ