public void RxMsgFromClient(Player.Player player, byte[] msg) { if (msg[0] == 0x01 && msg.Length == 1) { // Keepalive byte[] omsg = {0xFF}; player.SendMsgToClient(omsg); } else if (msg[0] == 0x05 && msg[1] == 0x03) { // FLPACKET_CLIENT_REQUESTCHARINFO player.Log.AddLog(LogType.FL_MSG, "FLPACKET_CLIENT_REQUESTCHARINFO"); player.SendCharInfoRequestResponse(); } else if (msg[0] == 0x06 && msg[1] == 0x03) { // FLPACKET_CLIENT_SELECTCHARACTER var nameBefore = player.Name; var pos = 2; var charfilename = FLMsgType.GetAsciiStringLen16(msg, ref pos); var acct = CharacterDB.Database.GetOneAccount(player.AccountID, charfilename); var result = player.LoadCharFile(acct, player.Log); if (result != null) { player.Log.AddLog(LogType.ERROR, "error: cannot load character accdir={0} charfile={1} reason={2}", acct.CharName, result); return; } player.Log.AddLog(LogType.GENERAL, "FLPACKET_CLIENT_SELECTCHARACTER charfilename={0} name={1} system={2}", charfilename, player.Name, player.Ship.System.Nickname); if (player.Ship != null && player.Ship.Objid != 0) player.Runner.DelSimObject(player.Ship); player.OnCharacterSelected(nameBefore == player.Name, nameBefore == null); player.Update(); } else if (msg[0] == 0x39 && msg[1] == 0x03) { player.Log.AddLog(LogType.FL_MSG, "FLPACKET_CLIENT_CREATENEWCHAR"); // New character int pos = 2; string charname = FLMsgType.GetUnicodeStringLen16(msg, ref pos); //TODO: do nothing when charname exists? if (CharacterDB.Database.GetAccount(@"CharName", charname) != null) return; CharacterDB.Database.AddAccount(player.AccountID, charname); //string charfile = player.Runner.Server.AcctPath + // Path.DirectorySeparatorChar + FLMsgType.FLNameToFile(player.AccountID) + // Path.DirectorySeparatorChar + FLMsgType.FLNameToFile(charname) + ".fl"; //if (!File.Exists(charfile)) //{ // var file = // new FLDataFile(player.Runner.Server.AcctPath + Path.DirectorySeparatorChar + "default.fl", true); // file.AddSetting("Player", "name", new object[] {FLUtility.EncodeUnicodeHex(charname)}); // file.SaveSettings(charfile, false); //} player.SendCharInfoRequestResponse(); } else if (msg[0] == 0x3a && msg[1] == 0x03) { player.Log.AddLog(LogType.FL_MSG, "FLPACKET_CLIENT_DESTROYCHAR"); // Delete character var pos = 2; var charfile = FLMsgType.GetAsciiStringLen16(msg, ref pos); CharacterDB.Database.DelAccount(player.AccountID,charfile); player.SendCharInfoRequestResponse(); } else { // Unexpected packet. Log and ignore it. player.Log.AddLog(LogType.ERROR, "Unexpected message: client rx", player.DPSess, msg); } }
/// <summary> /// Send the current player list and list of characters this player /// has in their account. /// </summary> /// <param name="player"></param> public void EnterState(Player.Player player) { player.PlayerAccount = null; player.SendCharInfoRequestResponse(); }