public static void SendUpdateRecipeToAll(int RecipeNum) { ByteStream buffer; buffer = new ByteStream(4); buffer.WriteInt32((int)Packets.ServerPackets.SUpdateRecipe); buffer.WriteInt32(RecipeNum); S_General.AddDebug("Sent SMSG: SUpdateRecipe To All"); buffer.WriteString((Microsoft.VisualBasic.Strings.Trim(Recipe[RecipeNum].Name))); buffer.WriteInt32(Recipe[RecipeNum].RecipeType); buffer.WriteInt32(Recipe[RecipeNum].MakeItemNum); buffer.WriteInt32(Recipe[RecipeNum].MakeItemAmount); for (var i = 1; i <= Constants.MAX_INGREDIENT; i++) { buffer.WriteInt32(Recipe[RecipeNum].Ingredients[i].ItemNum); buffer.WriteInt32(Recipe[RecipeNum].Ingredients[i].Value); } buffer.WriteInt32(Recipe[RecipeNum].CreateTime); S_NetworkConfig.SendDataToAll(ref buffer.Data, buffer.Head); buffer.Dispose(); }
public static void SendResourceCacheTo(int index, int Resource_num) { int i; int mapnum; ByteStream buffer = new ByteStream(4); mapnum = S_Players.GetPlayerMap(index); buffer.WriteInt32((int)Packets.ServerPackets.SResourceCache); buffer.WriteInt32(ResourceCache[mapnum].ResourceCount); S_General.AddDebug("Sent SMSG: SResourcesCache"); if (ResourceCache[mapnum].ResourceCount > 0) { var loopTo = ResourceCache[mapnum].ResourceCount; for (i = 0; i <= loopTo; i++) { buffer.WriteInt32(ResourceCache[mapnum].ResourceData[i].ResourceState); buffer.WriteInt32(ResourceCache[mapnum].ResourceData[i].X); buffer.WriteInt32(ResourceCache[mapnum].ResourceData[i].Y); } } S_NetworkConfig.Socket.SendDataTo(index, buffer.Data, buffer.Head); buffer.Dispose(); }
public static void Packet_StartCraft(int index, ref byte[] data) { int recipeindex; int amount; ByteStream buffer = new ByteStream(data); S_General.AddDebug("Recieved CMSG: CStartCraft"); recipeindex = buffer.ReadInt32(); amount = buffer.ReadInt32(); if (modTypes.TempPlayer[index].IsCrafting == false) { return; } if (recipeindex == 0 || amount == 0) { return; } if (!CheckLearnedRecipe(index, recipeindex)) { return; } StartCraft(index, recipeindex, amount); buffer.Dispose(); }
public static void SendUpdateAnimationToAll(int AnimationNum) { ByteStream buffer = new ByteStream(4); buffer.WriteInt32((int)Packets.ServerPackets.SUpdateAnimation); buffer.WriteBlock(AnimationData(AnimationNum)); // buffer.WriteInt32(AnimationNum) // For i = 0 To UBound(Animation(AnimationNum).Frames) // buffer.WriteInt32(Animation(AnimationNum).Frames(i)) // Next // For i = 0 To UBound(Animation(AnimationNum).LoopCount) // buffer.WriteInt32(Animation(AnimationNum).LoopCount(i)) // Next // For i = 0 To UBound(Animation(AnimationNum).LoopTime) // buffer.WriteInt32(Animation(AnimationNum).LoopTime(i)) // Next // buffer.WriteString((Animation(AnimationNum).Name)) // buffer.WriteString((Animation(AnimationNum).Sound)) // For i = 0 To UBound(Animation(AnimationNum).Sprite) // buffer.WriteInt32(Animation(AnimationNum).Sprite(i)) // Next S_General.AddDebug("Sent SMSG: SUpdateAnimation To All"); S_NetworkConfig.SendDataToAll(ref buffer.Data, buffer.Head); buffer.Dispose(); }
public static void Packet_SaveAnimation(int index, ref byte[] data) { int AnimNum; ByteStream buffer = new ByteStream(data); S_General.AddDebug("Recieved EMSG: SaveAnimation"); AnimNum = buffer.ReadInt32(); var loopTo = Information.UBound(Types.Animation[AnimNum].Frames); // Update the Animation for (var i = 0; i <= loopTo; i++) { Types.Animation[AnimNum].Frames[i] = buffer.ReadInt32(); } var loopTo1 = Information.UBound(Types.Animation[AnimNum].LoopCount); for (int i = 0; i <= loopTo1; i++) { Types.Animation[AnimNum].LoopCount[i] = buffer.ReadInt32(); } var loopTo2 = Information.UBound(Types.Animation[AnimNum].LoopTime); for (int i = 0; i <= loopTo2; i++) { Types.Animation[AnimNum].LoopTime[i] = buffer.ReadInt32(); } Types.Animation[AnimNum].Name = buffer.ReadString(); Types.Animation[AnimNum].Sound = buffer.ReadString(); if (Types.Animation[AnimNum].Name == null) { Types.Animation[AnimNum].Name = ""; } if (Types.Animation[AnimNum].Sound == null) { Types.Animation[AnimNum].Sound = ""; } var loopTo3 = Information.UBound(Types.Animation[AnimNum].Sprite); for (var i = 0; i <= loopTo3; i++) { Types.Animation[AnimNum].Sprite[i] = buffer.ReadInt32(); } buffer.Dispose(); // Save it SaveAnimation(AnimNum); SendUpdateAnimationToAll(AnimNum); modDatabase.Addlog(S_Players.GetPlayerLogin(index) + " saved Animation #" + AnimNum + ".", S_Constants.ADMIN_LOG); }
public static void SendUpdateResourceToAll(int ResourceNum) { ByteStream buffer = new ByteStream(4); buffer.WriteInt32((int)Packets.ServerPackets.SUpdateResource); buffer.WriteBlock(ResourceData(ResourceNum)); S_General.AddDebug("Sent SMSG: SUpdateResource"); S_NetworkConfig.SendDataToAll(ref buffer.Data, buffer.Head); buffer.Dispose(); }
public static void SendOpenCraft(int index) { ByteStream buffer; buffer = new ByteStream(4); buffer.WriteInt32((int)Packets.ServerPackets.SOpenCraft); S_General.AddDebug("Sent SMSG: SOpenCraft"); S_NetworkConfig.Socket.SendDataTo(index, buffer.Data, buffer.Head); buffer.Dispose(); }
public static void SendUpdateItemToAll(int itemNum) { ByteStream buffer; buffer = new ByteStream(4); buffer.WriteInt32((byte)Packets.ServerPackets.SUpdateItem); buffer.WriteBlock(ItemData(itemNum)); S_General.AddDebug("Sent SMSG: SUpdateItem To All"); S_NetworkConfig.SendDataToAll(ref buffer.Data, buffer.Head); buffer.Dispose(); }
public static void SendTimeTo(int index) { ByteStream buffer = new ByteStream(4); buffer.WriteInt32((int)Packets.ServerPackets.STime); buffer.WriteByte((byte)Time.Instance.TimeOfDay); S_NetworkConfig.Socket.SendDataTo(index, buffer.Data, buffer.Head); S_General.AddDebug("Sent SMSG: STime"); S_General.AddDebug(" Player: " + S_Players.GetPlayerName(index) + " : " + " Time Of Day: " + Time.Instance.TimeOfDay); buffer.Dispose(); }
public static void SendGameClockTo(int index) { ByteStream buffer = new ByteStream(4); buffer.WriteInt32((int)Packets.ServerPackets.SClock); buffer.WriteInt32((int)Time.Instance.GameSpeed); buffer.WriteBytes(BitConverter.GetBytes(Time.Instance._Time.Ticks)); S_NetworkConfig.Socket.SendDataTo(index, buffer.Data, buffer.Head); S_General.AddDebug("Sent SMSG: SClock"); S_General.AddDebug(" Player: " + S_Players.GetPlayerName(index) + " : " + " GameSpeed: " + Time.Instance.GameSpeed + " Instance Time Ticks: " + Time.Instance._Time.Ticks); buffer.Dispose(); }
public static void Packet_EditAnimation(int index, ref byte[] data) { S_General.AddDebug("Recieved EMSG: RequestEditAnimation"); // Prevent hacking if (S_Players.GetPlayerAccess(index) < (int)Enums.AdminType.Developer) { return; } var Buffer = new ByteStream(4); Buffer.WriteInt32((int)Packets.ServerPackets.SAnimationEditor); S_NetworkConfig.Socket.SendDataTo(index, Buffer.Data, Buffer.Head); Buffer.Dispose(); }
public static void SendAnimation(int mapNum, int Anim, int X, int Y, byte LockType = 0, int Lockindex = 0) { ByteStream buffer = new ByteStream(4); buffer.WriteInt32((int)Packets.ServerPackets.SAnimation); buffer.WriteInt32(Anim); buffer.WriteInt32(X); buffer.WriteInt32(Y); buffer.WriteInt32(LockType); buffer.WriteInt32(Lockindex); S_General.AddDebug("Sent SMSG: SAnimation"); S_NetworkConfig.SendDataToMap(mapNum, ref buffer.Data, buffer.Head); buffer.Dispose(); }
public static void Packet_SaveResource(int index, ref byte[] data) { int resourcenum; ByteStream buffer = new ByteStream(data); S_General.AddDebug("Recieved EMSG: SaveResource"); // Prevent hacking if (S_Players.GetPlayerAccess(index) < (int)Enums.AdminType.Developer) { return; } resourcenum = buffer.ReadInt32(); // Prevent hacking if (resourcenum <= 0 || resourcenum > Constants.MAX_RESOURCES) { return; } Types.Resource[resourcenum].Animation = buffer.ReadInt32(); Types.Resource[resourcenum].EmptyMessage = buffer.ReadString(); Types.Resource[resourcenum].ExhaustedImage = buffer.ReadInt32(); Types.Resource[resourcenum].Health = buffer.ReadInt32(); Types.Resource[resourcenum].ExpReward = buffer.ReadInt32(); Types.Resource[resourcenum].ItemReward = buffer.ReadInt32(); Types.Resource[resourcenum].Name = buffer.ReadString(); Types.Resource[resourcenum].ResourceImage = buffer.ReadInt32(); Types.Resource[resourcenum].ResourceType = buffer.ReadInt32(); Types.Resource[resourcenum].RespawnTime = buffer.ReadInt32(); Types.Resource[resourcenum].SuccessMessage = buffer.ReadString(); Types.Resource[resourcenum].LvlRequired = buffer.ReadInt32(); Types.Resource[resourcenum].ToolRequired = buffer.ReadInt32(); Types.Resource[resourcenum].Walkthrough = Convert.ToBoolean(buffer.ReadInt32()); // Save it SendUpdateResourceToAll(resourcenum); SaveResource(resourcenum); modDatabase.Addlog(S_Players.GetPlayerLogin(index) + " saved Resource #" + resourcenum + ".", S_Constants.ADMIN_LOG); buffer.Dispose(); }
public static void SendPlayerRecipes(int index) { int i; ByteStream buffer; buffer = new ByteStream(4); buffer.WriteInt32((int)Packets.ServerPackets.SSendPlayerRecipe); S_General.AddDebug("Sent SMSG: SSendPlayerRecipe"); for (i = 1; i <= Constants.MAX_RECIPE; i++) { buffer.WriteInt32(modTypes.Player[index].Character[modTypes.TempPlayer[index].CurChar].RecipeLearned[i]); } S_NetworkConfig.Socket.SendDataTo(index, buffer.Data, buffer.Head); buffer.Dispose(); }
public static void Packet_SaveRecipe(int index, ref byte[] data) { int n; // Prevent hacking if (S_Players.GetPlayerAccess(index) < (int)Enums.AdminType.Developer) { return; } ByteStream buffer = new ByteStream(data); S_General.AddDebug("Recieved EMSG: SaveRecipe"); // recipe index n = buffer.ReadInt32(); // Update the Recipe Recipe[n].Name = buffer.ReadString(); Recipe[n].RecipeType = (byte)buffer.ReadInt32(); Recipe[n].MakeItemNum = buffer.ReadInt32(); Recipe[n].MakeItemAmount = buffer.ReadInt32(); for (var i = 1; i <= Constants.MAX_INGREDIENT; i++) { Recipe[n].Ingredients[i].ItemNum = buffer.ReadInt32(); Recipe[n].Ingredients[i].Value = buffer.ReadInt32(); } Recipe[n].CreateTime = (byte)buffer.ReadInt32(); // save SaveRecipe(n); // send to all SendUpdateRecipeToAll(n); buffer.Dispose(); }
public static void SendMapItemsToAll(int mapNum) { int i; ByteStream buffer; buffer = new ByteStream(4); buffer.WriteInt32((int)Packets.ServerPackets.SMapItemData); S_General.AddDebug("Sent SMSG: SMapItemData To All"); for (i = 1; i <= Constants.MAX_MAP_ITEMS; i++) { buffer.WriteInt32(modTypes.MapItem[mapNum, i].Num); buffer.WriteInt32(modTypes.MapItem[mapNum, i].Value); buffer.WriteInt32(modTypes.MapItem[mapNum, i].X); buffer.WriteInt32(modTypes.MapItem[mapNum, i].Y); } S_NetworkConfig.SendDataToMap(mapNum, ref buffer.Data, buffer.Head); buffer.Dispose(); }
public static void Packet_DropItem(int index, ref byte[] data) { int InvNum; int Amount; ByteStream buffer = new ByteStream(data); S_General.AddDebug("Recieved CMSG: CMapDropItem"); InvNum = buffer.ReadInt32(); Amount = buffer.ReadInt32(); buffer.Dispose(); if (modTypes.TempPlayer[index].InBank || Convert.ToBoolean(modTypes.TempPlayer[index].InShop)) { return; } // Prevent hacking if (InvNum < 1 || InvNum > Constants.MAX_INV) { return; } if (S_Players.GetPlayerInvItemNum(index, InvNum) < 1 || S_Players.GetPlayerInvItemNum(index, InvNum) > Constants.MAX_ITEMS) { return; } if (Types.Item[S_Players.GetPlayerInvItemNum(index, InvNum)].Type == (int)Enums.ItemType.Currency || Types.Item[S_Players.GetPlayerInvItemNum(index, InvNum)].Stackable == 1) { if (Amount < 1 || Amount > S_Players.GetPlayerInvItemValue(index, InvNum)) { return; } } // everything worked out fine S_Players.PlayerMapDropItem(index, InvNum, Amount); }
public static void SpawnItemSlot(int MapItemSlot, int itemNum, int ItemVal, int mapNum, int x, int y) { int i; ByteStream buffer = new ByteStream(4); // Check for subscript out of range if (MapItemSlot <= 0 || MapItemSlot > Constants.MAX_MAP_ITEMS || itemNum < 0 || itemNum > Constants.MAX_ITEMS || mapNum <= 0 || mapNum > S_Instances.MAX_CACHED_MAPS) { return; } i = MapItemSlot; if (i != 0) { if (itemNum >= 0 && itemNum <= Constants.MAX_ITEMS) { modTypes.MapItem[mapNum, i].Num = itemNum; modTypes.MapItem[mapNum, i].Value = ItemVal; modTypes.MapItem[mapNum, i].X = (byte)x; modTypes.MapItem[mapNum, i].Y = (byte)y; buffer.WriteInt32((int)Packets.ServerPackets.SSpawnItem); buffer.WriteInt32(i); buffer.WriteInt32(itemNum); buffer.WriteInt32(ItemVal); buffer.WriteInt32(x); buffer.WriteInt32(y); S_General.AddDebug("Sent SMSG: SSpawnItem MapItemSlot"); S_NetworkConfig.SendDataToMap(mapNum, ref buffer.Data, buffer.Head); } } buffer.Dispose(); }
public static void Packet_RequestAnimations(int index, ref byte[] data) { S_General.AddDebug("Recieved CMSG: CRequestAnimations"); SendAnimations(index); }
public static void Packet_RequestResources(int index, ref byte[] data) { S_General.AddDebug("Recieved CMSG: CRequestResources"); SendResources(index); }
public static void Packet_GetItem(int index, ref byte[] data) { S_General.AddDebug("Recieved CMSG: CMapGetItem"); S_Players.PlayerMapGetItem(index); }
public static void Packet_CloseCraft(int index, ref byte[] data) { S_General.AddDebug("Recieved CMSG: CCloseCraft"); modTypes.TempPlayer[index].IsCrafting = false; }
public static void BidOnAuction(int Index, int Bid, int AuctionNum) { // Obvious if (AuctionNum == 0) { return; } // Lets make sure the auction even exists! if (Auction[AuctionNum].Owner == string.Empty) { S_NetworkSend.PlayerMsg(Index, "Auction no longer exists!", (int)Enums.ColorType.Red); return; } // Make sure they have enough money! if (S_Players.HasItem(Index, 1) < Bid) { S_NetworkSend.PlayerMsg(Index, "You Don't Have Enough Money To Make This Bid!", (int)Enums.ColorType.Red); return; } if (Bid < Auction[AuctionNum].Price) { S_NetworkSend.PlayerMsg(Index, "You Haven't Met This Bids Minimum Price!", (int)Enums.ColorType.Red); return; } if (Bid > Auction[AuctionNum].Bid) { // Give the previous bidder his $$ back if (Auction[AuctionNum].LastBidder != string.Empty) { GivePrevBid(Auction[AuctionNum].LastBidder, Auction[AuctionNum].Bid); } else { // Something went south, most likely a account deletion. Log it just incase S_General.AddDebug("Auction Failed To Find A Player And Return " + Bid + " To Them!"); } Auction[AuctionNum].Bid = Bid; Auction[AuctionNum].LastBidder = S_Players.GetPlayerName(Index); S_Players.TakeInvItem(Index, 1, Bid); S_NetworkSend.PlayerMsg(Index, "You have successfully bid " + Bid, (int)Enums.ColorType.Red); // Lets check if we won! if (Bid >= Auction[AuctionNum].MaxBid) { S_NetworkSend.PlayerMsg(Index, "You Have Won " + Types.Item[Auction[AuctionNum].Item].Name.Trim() + " !", (int)Enums.ColorType.Red); S_Players.GiveInvItem(Index, Auction[AuctionNum].Item, 0, true); // Should be working but may need work: if (Auction[AuctionNum].OwnerID != 0) { S_NetworkSend.PlayerMsg(Auction[AuctionNum].OwnerID, "Your Auction has sold: " + Types.Item[Auction[AuctionNum].Item].Name.Trim() + " !", (int)Enums.ColorType.Red); S_Players.GiveInvItem(Auction[AuctionNum].OwnerID, 1, Auction[AuctionNum].Bid, true); } else { AuctionSoldOut(AuctionNum); } DestroyAuction(AuctionNum); S_NetworkSend.SendAuctions(); } else { // We are not quite there yet S_NetworkSend.PlayerMsg(Index, "You Are " + (Auction[AuctionNum].MaxBid - Bid) + " Away from winning this auction!", (int)Enums.ColorType.Red); } } else { S_NetworkSend.PlayerMsg(Index, "Sorry, You Are " + (Auction[AuctionNum].Bid - Bid) + " Away from making a bid!", (int)Enums.ColorType.Red); } }
public static void Packet_SaveItem(int index, ref byte[] data) { int n; ByteStream buffer = new ByteStream(data); S_General.AddDebug("Recieved EMSG: SaveItem"); // Prevent hacking if (S_Players.GetPlayerAccess(index) < (int)Enums.AdminType.Developer) { return; } n = buffer.ReadInt32(); if (n < 0 || n > Constants.MAX_ITEMS) { return; } // Update the item Types.Item[n].AccessReq = buffer.ReadInt32(); for (var i = 0; i <= (int)Enums.StatType.Count - 1; i++) { Types.Item[n].Add_Stat[i] = (byte)buffer.ReadInt32(); } Types.Item[n].Animation = buffer.ReadInt32(); Types.Item[n].BindType = (byte)buffer.ReadInt32(); Types.Item[n].ClassReq = buffer.ReadInt32(); Types.Item[n].Data1 = buffer.ReadInt32(); Types.Item[n].Data2 = buffer.ReadInt32(); Types.Item[n].Data3 = buffer.ReadInt32(); Types.Item[n].TwoHanded = buffer.ReadInt32(); Types.Item[n].LevelReq = buffer.ReadInt32(); Types.Item[n].Mastery = (byte)buffer.ReadInt32(); Types.Item[n].Name = Microsoft.VisualBasic.Strings.Trim(buffer.ReadString()); Types.Item[n].Paperdoll = buffer.ReadInt32(); Types.Item[n].Pic = buffer.ReadInt32(); Types.Item[n].Price = buffer.ReadInt32(); Types.Item[n].Rarity = (byte)buffer.ReadInt32(); Types.Item[n].Speed = buffer.ReadInt32(); Types.Item[n].Randomize = (byte)buffer.ReadInt32(); Types.Item[n].RandomMin = (byte)buffer.ReadInt32(); Types.Item[n].RandomMax = (byte)buffer.ReadInt32(); Types.Item[n].Stackable = (byte)buffer.ReadInt32(); Types.Item[n].Description = Microsoft.VisualBasic.Strings.Trim(buffer.ReadString()); for (var i = 0; i <= (int)Enums.StatType.Count - 1; i++) { Types.Item[n].Stat_Req[i] = (byte)buffer.ReadInt32(); } Types.Item[n].Type = (byte)buffer.ReadInt32(); Types.Item[n].SubType = (byte)buffer.ReadInt32(); Types.Item[n].ItemLevel = (byte)buffer.ReadInt32(); // Housing Types.Item[n].FurnitureWidth = buffer.ReadInt32(); Types.Item[n].FurnitureHeight = buffer.ReadInt32(); for (var a = 0; a <= 3; a++) { for (var b = 0; b <= 3; b++) { Types.Item[n].FurnitureBlocks[a, b] = buffer.ReadInt32(); Types.Item[n].FurnitureFringe[a, b] = buffer.ReadInt32(); } } Types.Item[n].KnockBack = (byte)buffer.ReadInt32(); Types.Item[n].KnockBackTiles = (byte)buffer.ReadInt32(); Types.Item[n].Projectile = buffer.ReadInt32(); Types.Item[n].Ammo = buffer.ReadInt32(); // Save it SendUpdateItemToAll(n); SaveItem(n); modDatabase.Addlog(S_Players.GetPlayerLogin(index) + " saved item #" + n + ".", S_Constants.ADMIN_LOG); buffer.Dispose(); }