public static void DebuffBank(PacketContent pc, ref Bank bankToFill) { for (int i = 0; i < Constants.MAX_BANK; i++) { bankToFill.items[i].id = pc.ReadLong(); bankToFill.items[i].amount = pc.ReadLong(); } }
public void DebuffBank(ref Bank bankToFill) { for (int i = 0; i < Constants.MAX_BANK; i++) { bankToFill.items[i].id = ReadLong(); bankToFill.items[i].amount = ReadLong(); } }
public void BufferPlayerBank(ref Bank playerBank) { for (int i = 0; i < Constants.MAX_BANK; i++) { WriteLong(playerBank.items[i].id); WriteLong(playerBank.items[i].amount); } }
public void SavePlayerBank(string loginName, ref Bank bankToSave) { string path = AppDomain.CurrentDomain.BaseDirectory + "data\\banks\\" + loginName + ".bin"; while (IsFileLocked(path)) { System.Threading.Thread.Sleep(100); } using (BinaryWriter writer = new BinaryWriter(File.Open(path, FileMode.OpenOrCreate))) { for (int i = 0; i < Constants.MAX_BANK; i++) { writer.Write(bankToSave.items[i].id); writer.Write(bankToSave.items[i].amount); } } return; }
public bool LoadPlayerBank(string loginName, ref Bank bankToLoad) { string path = AppDomain.CurrentDomain.BaseDirectory + "data\\banks\\" + loginName + ".bin"; if (File.Exists(path)) { while (IsFileLocked(path)) { System.Threading.Thread.Sleep(100); } using (BinaryReader reader = new BinaryReader(File.Open(path, FileMode.Open))) { for (int i = 0; i < Constants.MAX_BANK; i++) { bankToLoad.items[i].id = reader.ReadInt32(); bankToLoad.items[i].amount = reader.ReadInt32(); } } return true; } return false; }
private static void PreSavePlayer(PacketContent pc) { //byte[] temp = data.getContent(); //AccountsManager.SavePacket("davemax", ref temp); AccountsManager file = new AccountsManager(_form); string playerLoginName = pc.ReadString(); Player playerToSave = new Player(0); DebuffPlayer(pc, ref playerToSave); file.SavePlayer(playerLoginName, ref playerToSave); Bank bankToSave = new Bank(0); DebuffBank(pc, ref bankToSave); file.SavePlayerBank(playerLoginName, ref bankToSave); if (!updatingPlayers) appendLog(playerLoginName + "'s account & bank saved."); else updatedPlayerList += playerLoginName + ", "; }
public static bool SendServer_RegisterPlayer(ServerDetails server, string loginName, string loginToken, ref Player player, ref Bank playerBank) { PacketsProcessor sendBuffer = new PacketsProcessor((int)GameSendPackets.RegisterNewPlayer); sendBuffer.WriteString(loginToken); sendBuffer.WriteString(loginName); sendBuffer.BufferPlayer(ref player); sendBuffer.BufferPlayerBank(ref playerBank); sendBuffer.FinishPacking(); //Testing packet //byte[] temp = sendBuffer.GetSendBytes(); //AccountsManager.SavePacket("davemax", ref temp); return SendPacket(sendBuffer, server.socket); }
public static bool RegisterNewPlayer(int serverIndex, string loginName, string loginToken, ref Player player, ref Bank playerBank) { ServerDetails server = AuthenticationServer.GetServerByIndex(serverIndex); if (server == null) return false; return SendServer_RegisterPlayer(server, loginName, loginToken, ref player, ref playerBank); }