/// <summary> /// </summary> /// <param name="server"> /// </param> /// <returns> /// </returns> public ZoneClient Create(ZoneServer server) { ZoneClient zc = new ZoneClient(server, this.messageSerializer, this.bus); zc.zoneBus = server.zoneBus; return(new ZoneClient(server, this.messageSerializer, this.bus)); }
protected override void HandleAppPacket(AppPacket packet) { switch ((WorldOp)packet.Opcode) { case WorldOp.GuildsList: break; case WorldOp.LogServer: case WorldOp.ApproveWorld: case WorldOp.EnterWorld: case WorldOp.ExpansionInfo: break; case WorldOp.SendCharInfo: var chars = new CharacterSelect(packet.Data); CharacterList?.Invoke(this, chars.Characters); break; case WorldOp.MessageOfTheDay: MOTD?.Invoke(this, Encoding.ASCII.GetString(packet.Data)); break; case WorldOp.ZoneServerInfo: var info = packet.Get <ZoneServerInfo>(); ZoneServer?.Invoke(this, info); break; default: WriteLine($"Unhandled packet in WorldStream: {(WorldOp)packet.Opcode} (0x{packet.Opcode:X04})"); Hexdump(packet.Data); break; } }
//Moves actor to new zone, and sends packets to spawn at the given coords. public void DoZoneServerChange(Session session, uint destinationZoneId, string destinationPrivateArea, byte spawnType, float spawnX, float spawnY, float spawnZ, float spawnRotation) { ZoneServer zs = GetZoneServer(destinationZoneId); if (zs == null) { return; } session.currentZoneId = destinationZoneId; //Intrazone change, just update the id if (zs.Equals(session.routing1)) { return; } if (zs.isConnected) { session.routing1.SendSessionEnd(session, destinationZoneId, destinationPrivateArea, spawnType, spawnX, spawnY, spawnZ, spawnRotation); } else if (zs.Connect()) { session.routing1.SendSessionEnd(session, destinationZoneId, destinationPrivateArea, spawnType, spawnX, spawnY, spawnZ, spawnRotation); } else { session.routing1.SendPacket(ErrorPacket.BuildPacket(session, 1)); } }
/// <summary> /// </summary> /// <param name="zoneServer"> /// </param> /// <param name="playfieldIdentity"> /// </param> public Playfield(ZoneServer zoneServer, Identity playfieldIdentity) : base(Identity.None, playfieldIdentity) { this.server = zoneServer; this.playfieldBus = BusSetup.StartWith <AsyncConfiguration>().Construct(); this.memBusDisposeContainer.Add( this.playfieldBus.Subscribe <IMSendAOtomationMessageToClient>(SendAOtomationMessageToClient)); this.memBusDisposeContainer.Add( this.playfieldBus.Subscribe <IMSendAOtomationMessageToPlayfield>(this.SendAOtomationMessageToPlayfield)); this.memBusDisposeContainer.Add( this.playfieldBus.Subscribe <IMSendAOtomationMessageToPlayfieldOthers>( this.SendAOtomationMessageToPlayfieldOthers)); this.memBusDisposeContainer.Add( this.playfieldBus.Subscribe <IMSendAOtomationMessageBodyToClient>(this.SendAOtomationMessageBodyToClient)); this.memBusDisposeContainer.Add( this.playfieldBus.Subscribe <IMSendAOtomationMessageBodiesToClient>( this.SendAOtomationMessageBodiesToClient)); this.memBusDisposeContainer.Add(this.playfieldBus.Subscribe <IMSendPlayerSCFUs>(this.SendSCFUsToClient)); this.memBusDisposeContainer.Add(this.playfieldBus.Subscribe <IMExecuteFunction>(this.ExecuteFunction)); this.heartBeat = new Timer(this.HeartBeatTimer, null, 10, 0); this.statels = PlayfieldLoader.PFData[this.Identity.Instance].Statels; this.LoadMobSpawns(playfieldIdentity); this.LoadVendors(playfieldIdentity); this.LoadStaticDynels(playfieldIdentity); }
/////////////////////////////////////////////////// // Member Functions /////////////////////////////////////////////////// /// <summary> /// Generic constructor /// </summary> public Database(ZoneServer server, ConfigSetting config, LogClient logger) { _server = server; _config = config; _conn = new ClientConn <Database>(new S2CPacketFactory <Database>(), this); _syncStart = new ManualResetEvent(false); _logger = logger; _conn._logger = logger; }
/// <summary> /// </summary> /// <returns> /// </returns> private static bool CheckZoneServerCreation() { try { zoneServer = Container.GetInstance <ZoneServer>(); } catch (Exception) { return(false); } return(true); }
/// <summary> /// </summary> /// <returns> /// </returns> private static bool CheckZoneServerCreation() { try { zoneServer = new ZoneServer(); } catch (Exception e) { LogUtil.ErrorException(e); return(false); } return(true); }
public void Load(ZoneServer server) { Log.write("Loading loot tables..."); _rand = new Random(); _lootTables = new Dictionary <int, LootTable>(); string[] tables = Directory.GetFiles(System.Environment.CurrentDirectory + "/Loot/", "*.xml"); foreach (string table in tables) { LootTable newTable = new LootTable(table); _lootTables.Add(newTable.botID, newTable); } }
protected override void HandleAppPacket(AppPacket packet) { WriteLine($"Foo? {(WorldOp) packet.Opcode}"); switch ((WorldOp)packet.Opcode) { case WorldOp.GuildsList: break; case WorldOp.LogServer: case WorldOp.ApproveWorld: case WorldOp.EnterWorld: case WorldOp.ExpansionInfo: break; case WorldOp.SendCharInfo: var chars = new CharacterSelect(packet.Data); CharacterList?.Invoke(this, chars.Characters); break; case WorldOp.MessageOfTheDay: MOTD?.Invoke(this, Encoding.ASCII.GetString(packet.Data)); break; case WorldOp.ZoneServerInfo: var info = packet.Get <ZoneServerInfo>(); ZoneServer?.Invoke(this, info); break; case WorldOp.SetChatServer: case WorldOp.SetChatServer2: ChatServerList?.Invoke(this, packet.Data); break; case WorldOp.PostEnterWorld: // The emu doesn't do anything with ApproveWorld and WorldClientReady so we may be able to just skip them both. Send(AppPacket.Create(WorldOp.ApproveWorld)); Send(AppPacket.Create(WorldOp.WorldClientReady)); break; case WorldOp.ApproveName: CharacterCreateNameApproval?.Invoke(this, packet.Data[0] == 1); break; default: WriteLine($"Unhandled packet in WorldStream: {(WorldOp) packet.Opcode} (0x{packet.Opcode:X04})"); Hexdump(packet.Data); break; } }
public void LoadZoneServerList() { mZoneServerList = new Dictionary <string, ZoneServer>(); using (MySqlConnection conn = new MySqlConnection(String.Format("Server={0}; Port={1}; Database={2}; UID={3}; Password={4}", ConfigConstants.DATABASE_HOST, ConfigConstants.DATABASE_PORT, ConfigConstants.DATABASE_NAME, ConfigConstants.DATABASE_USERNAME, ConfigConstants.DATABASE_PASSWORD))) { try { conn.Open(); string query = @" SELECT id, serverIp, serverPort FROM server_zones WHERE serverIp IS NOT NULL"; MySqlCommand cmd = new MySqlCommand(query, conn); using (MySqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { uint id = reader.GetUInt32(0); string ip = reader.GetString(1); int port = reader.GetInt32(2); string address = ip + ":" + port; if (!mZoneServerList.ContainsKey(address)) { ZoneServer zone = new ZoneServer(ip, port, id); mZoneServerList.Add(address, zone); } else { mZoneServerList[address].AddLoadedZone(id); } } } } catch (MySqlException e) { Console.WriteLine(e); } finally { conn.Dispose(); } } }
/////////////////////////////////////////////////// // Member Functions /////////////////////////////////////////////////// /// <summary> /// Generic Constructor /// </summary> public Pathfinder(ZoneServer server, LogClient logger) { _logger = logger; lvlInfo = server._assets.Level; pathingQueue = new BlockingCollection <PathfindReq>(); //Create a boolean representation of our map byte[] map = new byte[lvlInfo.Width * lvlInfo.Height]; for (int i = 0; i < lvlInfo.Height; ++i) { for (int j = 0; j < lvlInfo.Width; ++j) { //Write in the blocked tile map[(i * lvlInfo.Width) + j] = lvlInfo.Tiles[(i * lvlInfo.Width) + j].Blocked ? (byte)1 : (byte)0; } } pathHandleClr0 = createMapContext(map, lvlInfo.Width, lvlInfo.Height); //Block tiles for clearance int clearance = 2; for (int i = 0; i < lvlInfo.Height; ++i) { for (int j = 0; j < lvlInfo.Width; ++j) { if (lvlInfo.Tiles[(i * lvlInfo.Width) + j].Blocked) { //Block tiles around it for clearance int yMax = Math.Min(lvlInfo.Height - 1, (i + clearance + 1)); int xMax = Math.Min(lvlInfo.Width - 1, (j + clearance + 1)); for (int y = Math.Max(0, i - clearance); y < yMax; ++y) { for (int x = Math.Max(0, j - clearance); x < xMax; ++x) { map[(y * lvlInfo.Width) + x] = (byte)1; } } } } } //Initialize our pathfinder pathHandleClr2 = createMapContext(map, lvlInfo.Width, lvlInfo.Height); }
private void LoadWorldServers() { _zoneaccounts.Clear(); try { String accounts = File.ReadAllText("zoneservers.txt"); string[] accountlines = accounts.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); foreach (string accountline in accountlines) { if (String.IsNullOrEmpty(accountline)) { continue; } Debug.Log("Parsing: " + accountline); string[] accountdetails = accountline.Split('|'); ZoneServer zoneserver = new ZoneServer(); zoneserver.username = accountdetails[0]; zoneserver.password = accountdetails[1]; _zoneaccounts.Add(zoneserver); } } catch (FileNotFoundException filenotfoundexception) { File.WriteAllText("zoneservers.txt", "zonetest|password" + Environment.NewLine); ZoneServer zoneserver = new ZoneServer(); zoneserver.username = "******"; zoneserver.password = "******"; _zoneaccounts.Add(zoneserver); } catch (IsolatedStorageException isolatedstoragexception) { File.WriteAllText("zoneservers.txt", "zonetest|password" + Environment.NewLine); ZoneServer zoneserver = new ZoneServer(); zoneserver.username = "******"; zoneserver.password = "******"; _zoneaccounts.Add(zoneserver); } }
/// <summary> /// </summary> /// <param name="zoneServer"> /// </param> private Playfield(ZoneServer zoneServer) { this.server = zoneServer; this.playfieldBus = BusSetup.StartWith <AsyncConfiguration>().Construct(); this.memBusDisposeContainer.Add( this.playfieldBus.Subscribe <IMSendAOtomationMessageToClient>(SendAOtomationMessageToClient)); this.memBusDisposeContainer.Add( this.playfieldBus.Subscribe <IMSendAOtomationMessageToPlayfield>(this.SendAOtomationMessageToPlayfield)); this.memBusDisposeContainer.Add( this.playfieldBus.Subscribe <IMSendAOtomationMessageToPlayfieldOthers>( this.SendAOtomationMessageToPlayfieldOthers)); this.memBusDisposeContainer.Add( this.playfieldBus.Subscribe <IMSendAOtomationMessageBodyToClient>(this.SendAOtomationMessageBodyToClient)); this.memBusDisposeContainer.Add( this.playfieldBus.Subscribe <IMSendAOtomationMessageBodiesToClient>( this.SendAOtomationMessageBodiesToClient)); this.memBusDisposeContainer.Add(this.playfieldBus.Subscribe <IMSendPlayerSCFUs>(this.SendSCFUsToClient)); this.memBusDisposeContainer.Add(this.playfieldBus.Subscribe <IMExecuteFunction>(this.ExecuteFunction)); this.Entities = new Pool(); this.heartBeat = new Timer(this.HeartBeatTimer, null, 10, 0); }
protected override void HandleAppPacket(AppPacket packet) { switch ((WorldOp)packet.Opcode) { case WorldOp.GuildsList: UnityEngine.Debug.Log("World: GuildsList"); break; case WorldOp.LogServer: UnityEngine.Debug.Log("World: ApproveWorld"); break; case WorldOp.ApproveWorld: UnityEngine.Debug.Log("World: ApproveWorld"); break; case WorldOp.EnterWorld: UnityEngine.Debug.Log("World: EnterWorld"); break; case WorldOp.ExpansionInfo: UnityEngine.Debug.Log("World: ExpansionInfo"); break; case WorldOp.SendCharInfo: var chars = new CharacterSelect(packet.Data); CharacterList?.Invoke(this, chars.Characters); UnityEngine.Debug.Log("World: SendCharInfo"); break; case WorldOp.MessageOfTheDay: MOTD?.Invoke(this, Encoding.ASCII.GetString(packet.Data)); UnityEngine.Debug.Log("World: MOTD"); break; case WorldOp.ZoneServerInfo: var info = packet.Get <ZoneServerInfo>(); ZoneServer?.Invoke(this, info); UnityEngine.Debug.Log("World: ZoneServerInfo"); break; case WorldOp.SetChatServer: UnityEngine.Debug.Log("World: SetChatServer"); break; case WorldOp.SetChatServer2: ChatServerList?.Invoke(this, packet.Data); UnityEngine.Debug.Log("World: SetChatSErver2"); break; case WorldOp.PostEnterWorld: // The emu doesn't do anything with ApproveWorld and WorldClientReady so we may be able to just skip them both. Send(AppPacket.Create(WorldOp.ApproveWorld, null)); Send(AppPacket.Create(WorldOp.WorldClientReady, null)); UnityEngine.Debug.Log("World: ApproveWorld/WorldClientReady"); break; case WorldOp.ApproveName: CharacterCreateNameApproval?.Invoke(this, packet.Data[0]); UnityEngine.Debug.Log("World: ApproveName"); break; default: UnityEngine.Debug.LogError($"Unhandled packet in WorldStream: {(WorldOp)packet.Opcode} (0x{packet.Opcode:X04})"); Hexdump(packet.Data); break; } }
/// <summary> /// </summary> /// <param name="zoneServer"> /// </param> /// <param name="playfieldIdentity"> /// </param> public Playfield(ZoneServer zoneServer, Identity playfieldIdentity) : this(zoneServer) { this.Identity = playfieldIdentity; this.statels = PlayfieldLoader.PFData[this.Identity.Instance].Statels; }
/// <summary> /// Handles the login request packet sent by the client /// </summary> static public void Handle_CS_Login(CS_Login pkt, Client <Player> client) { //Let's escalate our client's status to player! ZoneServer server = (client._handler as ZoneServer); // check for excessive joins to zone from same IP if (pkt.bCreateAlias != true && server._connections.ContainsKey(client._ipe.Address)) { Helpers.Login_Response(client, SC_Login.Login_Result.Failed, "Please wait 10 seconds before logging in again."); Log.write(TLog.Warning, "Possible throttler removed: {0}", client._ipe.ToString()); return; } else if (!server._connections.ContainsKey(client._ipe.Address)) { server._connections.Add(client._ipe.Address, DateTime.Now.AddSeconds(10)); } //Check their client version and UIDs //TODO: find out what the UIDs are and what an invalid UID might look like, and reject spoofed ones if (pkt.Version != Helpers._serverVersion || pkt.UID1 <= 10000 || pkt.UID2 <= 10000 || pkt.UID3 <= 10000) { Log.write(TLog.Warning, "Suspicious login packet from {0} : Version ({1}) UID1({2}) UID2({3}) UID3({4})", pkt.Username, pkt.Version, pkt.UID1, pkt.UID2, pkt.UID3); } String alias = pkt.Username; //Check alias for illegal characters if (String.IsNullOrWhiteSpace(alias)) { Helpers.Login_Response(client, SC_Login.Login_Result.Failed, "Alias cannot be blank."); return; } try { //Temporary till we find the login bug if (!char.IsLetterOrDigit(alias, 0) || char.IsWhiteSpace(alias, 0) || char.IsWhiteSpace(alias, alias.Length - 1) || alias != Logic_Text.RemoveIllegalCharacters(alias)) { //Boot him.. Helpers.Login_Response(client, SC_Login.Login_Result.Failed, "Alias contains illegal characters, must start with a letter or number and cannot end with a space."); return; } } catch (ArgumentOutOfRangeException) { Log.write(TLog.Warning, "Player login name is {0}", alias); Helpers.Login_Response(client, SC_Login.Login_Result.Failed, "Alias contains illegal characters, must start with a letter or number and cannot end with a space."); return; } if (alias.Length > 64) { //Change this if alias.name in the db is changed.. currently at varchar(64) Helpers.Login_Response(client, SC_Login.Login_Result.Failed, "Alias length is too long."); return; } //Are we in permission mode? if (server._config["server/permitMode"].boolValue && !Logic_Permit.checkPermit(alias)) { Helpers.Login_Response(client, SC_Login.Login_Result.Failed, "Zone is in permission only mode."); return; } Player newPlayer = server.newPlayer(client, alias); //If it failed for some reason, present a failure message if (newPlayer == null) { Helpers.Login_Response(client, SC_Login.Login_Result.Failed, "Login Failure, Zone is full."); Log.write(TLog.Error, "New player is null possibly due to zone being full."); return; } newPlayer._UID1 = pkt.UID1; newPlayer._UID2 = pkt.UID2; newPlayer._UID3 = pkt.UID3; //Are we in standalone mode? if (server.IsStandalone) { //Always first time setup in standalone mode newPlayer.assignFirstTimeStats(false); //Success! Let him in. Helpers.Login_Response(client, SC_Login.Login_Result.Success, "This server is currently in stand-alone mode. Your character's scores and stats will not be saved."); } else { //Defer the request to the database server CS_PlayerLogin <Data.Database> plogin = new CS_PlayerLogin <Data.Database>(); plogin.bCreateAlias = pkt.bCreateAlias; plogin.player = newPlayer.toInstance(); plogin.alias = alias; plogin.ticketid = pkt.TicketID; plogin.UID1 = pkt.UID1; plogin.UID2 = pkt.UID2; plogin.UID3 = pkt.UID3; plogin.NICInfo = pkt.NICInfo; plogin.ipaddress = pkt._client._ipe.Address.ToString().Trim(); server._db.send(plogin); } }
// Events raised by various actions of the managed mobs. Subscribed to by the Zone Server internal MobManager(ZoneServer zoneSvr) { _zoneSvr = zoneSvr; Init(); }
public void OnReceiveSubPacketFromZone(ZoneServer zoneServer, SubPacket subpacket) { uint sessionId = subpacket.header.targetId; Session session = GetSession(sessionId); subpacket.DebugPrintSubPacket(); if (subpacket.gameMessage.opcode >= 0x1000) { //subpacket.DebugPrintSubPacket(); switch (subpacket.gameMessage.opcode) { //Session Begin Confirm case 0x1000: SessionBeginConfirmPacket beginConfirmPacket = new SessionBeginConfirmPacket(subpacket.data); if (beginConfirmPacket.invalidPacket || beginConfirmPacket.errorCode == 0) { Program.Log.Error("Session {0} had a error beginning session.", beginConfirmPacket.sessionId); } break; //Session End Confirm case 0x1001: SessionEndConfirmPacket endConfirmPacket = new SessionEndConfirmPacket(subpacket.data); if (!endConfirmPacket.invalidPacket && endConfirmPacket.errorCode == 0) { //Check destination, if != 0, update route and start new session if (endConfirmPacket.destinationZone != 0) { session.routing1 = Server.GetServer().GetWorldManager().GetZoneServer(endConfirmPacket.destinationZone); session.routing1.SendSessionStart(session); } else { RemoveSession(Session.Channel.ZONE, endConfirmPacket.sessionId); RemoveSession(Session.Channel.CHAT, endConfirmPacket.sessionId); } } else { Program.Log.Error("Session {0} had an error ending session.", endConfirmPacket.sessionId); } break; //Zone Change Request case 0x1002: WorldRequestZoneChangePacket zoneChangePacket = new WorldRequestZoneChangePacket(subpacket.data); if (!zoneChangePacket.invalidPacket) { GetWorldManager().DoZoneServerChange(session, zoneChangePacket.destinationZoneId, "", zoneChangePacket.destinationSpawnType, zoneChangePacket.destinationX, zoneChangePacket.destinationY, zoneChangePacket.destinationZ, zoneChangePacket.destinationRot); } break; //Change leader or kick case 0x1020: PartyModifyPacket partyModifyPacket = new PartyModifyPacket(subpacket.data); Party pt = mWorldManager.GetPartyManager().GetParty(subpacket.header.targetId); if (pt.GetMemberCount() <= 1) { return; } if (partyModifyPacket.command == PartyModifyPacket.MODIFY_LEADER) { pt.SetLeaderPlayerRequest(GetSession(subpacket.header.sourceId), partyModifyPacket.name); } else if (partyModifyPacket.command == PartyModifyPacket.MODIFY_KICKPLAYER) { pt.KickPlayerRequest(GetSession(subpacket.header.sourceId), partyModifyPacket.name); } else if (partyModifyPacket.command == PartyModifyPacket.MODIFY_LEADER + 2) { pt.SetLeaderPlayerRequest(GetSession(subpacket.header.sourceId), partyModifyPacket.actorId); } else if (partyModifyPacket.command == PartyModifyPacket.MODIFY_KICKPLAYER + 2) { pt.KickPlayerRequest(GetSession(subpacket.header.sourceId), partyModifyPacket.actorId); } break; //Party Resign or Disband case 0x1021: PartyLeavePacket partyLeavePacket = new PartyLeavePacket(subpacket.data); Party leavePt = mWorldManager.GetPartyManager().GetParty(subpacket.header.sourceId); if (!partyLeavePacket.isDisband) { leavePt.LeavePlayerRequest(GetSession(subpacket.header.sourceId)); } else { leavePt.DisbandPlayerRequest(GetSession(subpacket.header.sourceId)); } break; //Party Invite Request case 0x1022: PartyInvitePacket partyInvitePacket = new PartyInvitePacket(subpacket.data); if (partyInvitePacket.command == 1) { mWorldManager.ProcessPartyInvite(GetSession(subpacket.header.sourceId), partyInvitePacket.actorId); } else if (partyInvitePacket.command == 0) { Session inviteeByNamesSession = GetSession(partyInvitePacket.name); if (inviteeByNamesSession != null) { mWorldManager.ProcessPartyInvite(GetSession(subpacket.header.sourceId), inviteeByNamesSession.sessionId); } else { //Show not found msg } } break; //Group Invite Result case 0x1023: GroupInviteResultPacket groupInviteResultPacket = new GroupInviteResultPacket(subpacket.data); switch (groupInviteResultPacket.groupType) { case 0x2711: mWorldManager.ProcessPartyInviteResult(GetSession(subpacket.header.sourceId), groupInviteResultPacket.result); break; case 0x2712: mWorldManager.ProcessLinkshellInviteResult(GetSession(subpacket.header.sourceId), groupInviteResultPacket.result); break; } break; //Linkshell create request case 0x1025: CreateLinkshellPacket createLinkshellPacket = new CreateLinkshellPacket(subpacket.data); mWorldManager.GetLinkshellManager().CreateLinkshell(createLinkshellPacket.name, createLinkshellPacket.crestid, createLinkshellPacket.master); break; //Linkshell modify request case 0x1026: ModifyLinkshellPacket modifyLinkshellPacket = new ModifyLinkshellPacket(subpacket.data); switch (modifyLinkshellPacket.argCode) { case 0: break; case 1: mWorldManager.GetLinkshellManager().ChangeLinkshellCrest(modifyLinkshellPacket.currentName, modifyLinkshellPacket.crestid); break; case 2: mWorldManager.GetLinkshellManager().ChangeLinkshellMaster(modifyLinkshellPacket.currentName, modifyLinkshellPacket.master); break; } break; //Linkshell delete request case 0x1027: DeleteLinkshellPacket deleteLinkshellPacket = new DeleteLinkshellPacket(subpacket.data); mWorldManager.GetLinkshellManager().DeleteLinkshell(deleteLinkshellPacket.name); break; //Linkshell set active case 0x1028: LinkshellChangePacket linkshellChangePacket = new LinkshellChangePacket(subpacket.data); mWorldManager.ProcessLinkshellSetActive(GetSession(subpacket.header.sourceId), linkshellChangePacket.lsName); break; //Linkshell invite member case 0x1029: LinkshellInvitePacket linkshellInvitePacket = new LinkshellInvitePacket(subpacket.data); mWorldManager.ProcessLinkshellInvite(GetSession(subpacket.header.sourceId), linkshellInvitePacket.lsName, linkshellInvitePacket.actorId); break; //Linkshell cancel invite case 0x1030: LinkshellInviteCancelPacket linkshellInviteCancelPacket = new LinkshellInviteCancelPacket(subpacket.data); mWorldManager.ProcessLinkshellInviteCancel(GetSession(subpacket.header.sourceId)); break; //Linkshell resign/kicked case 0x1031: LinkshellLeavePacket linkshellLeavePacket = new LinkshellLeavePacket(subpacket.data); Linkshell lsLeave = mWorldManager.GetLinkshellManager().GetLinkshell(linkshellLeavePacket.lsName); if (linkshellLeavePacket.isKicked) { lsLeave.KickRequest(GetSession(subpacket.header.sourceId), linkshellLeavePacket.kickedName); } else { lsLeave.LeaveRequest(GetSession(subpacket.header.sourceId)); } break; //Linkshell rank change case 0x1032: LinkshellRankChangePacket linkshellRankChangePacket = new LinkshellRankChangePacket(subpacket.data); Linkshell lsRankChange = mWorldManager.GetLinkshellManager().GetLinkshell(linkshellRankChangePacket.lsName); lsRankChange.RankChangeRequest(GetSession(subpacket.header.sourceId), linkshellRankChangePacket.name, linkshellRankChangePacket.rank); break; } } else if (mZoneSessionList.ContainsKey(sessionId)) { ClientConnection conn = mZoneSessionList[sessionId].clientConnection; conn.QueuePacket(subpacket); conn.FlushQueuedSendPackets(); } }
/// <summary> /// </summary> /// <param name="server"> /// </param> /// <returns> /// </returns> public ZoneClient Create(ZoneServer server) { return(new ZoneClient(server, this.messageSerializer, this.bus)); }
/// <summary> /// </summary> /// <param name="args"> /// </param> private static void Main(string[] args) { bool processedargs = false; LogUtil.SetupConsoleLogging(LogLevel.Debug); LogUtil.SetupFileLogging("${basedir}/ZoneEngineLog.txt", LogLevel.Trace); SettingsOverride.LoadCustomSettings("NBug.ZoneEngine.Config"); Settings.WriteLogToDisk = true; AppDomain.CurrentDomain.UnhandledException += Handler.UnhandledException; TaskScheduler.UnobservedTaskException += Handler.UnobservedTaskException; csc = new ScriptCompiler(); // TODO: ADD More Handlers. Console.Title = "CellAO " + AssemblyInfoclass.Title + " Console. Version: " + AssemblyInfoclass.Description + " " + AssemblyInfoclass.AssemblyVersion + " " + AssemblyInfoclass.Trademark; ConsoleText ct = new ConsoleText(); ct.TextRead("main.txt"); Console.Write("Loading "); Console.ForegroundColor = ConsoleColor.DarkGreen; Console.Write(AssemblyInfoclass.Title + " "); Console.ForegroundColor = ConsoleColor.White; Console.Write(AssemblyInfoclass.Description); Console.ResetColor(); Console.WriteLine("..."); zoneServer = Container.GetInstance <ZoneServer>(); int Port = Convert.ToInt32(Config.Instance.CurrentConfig.ZonePort); try { if (Config.Instance.CurrentConfig.ListenIP == "0.0.0.0") { zoneServer.TcpEndPoint = new IPEndPoint(IPAddress.Any, Port); } else { zoneServer.TcpIP = IPAddress.Parse(Config.Instance.CurrentConfig.ListenIP); } } catch { ct.TextRead("ip_config_parse_error.txt"); Console.ReadKey(); return; } string consoleCommand; ct.TextRead("zone_consolecommands.txt"); // removed CheckDBs here, added commands check and updatedb (updatedb will change to a versioning while (true) { if (!processedargs) { if (args.Length == 1) { if (args[0].ToLower() == "/autostart") { ct.TextRead("autostart.txt"); csc.Compile(false); StartTheServer(); } } processedargs = true; } Console.Write("\nServer Command >>"); consoleCommand = Console.ReadLine(); switch (consoleCommand.ToLower()) { case "start": if (zoneServer.Running) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Zone Server is already running"); Console.ResetColor(); break; } // TODO: Add Sql Check. csc.Compile(false); StartTheServer(); break; case "startm": // Multiple dll compile if (zoneServer.Running) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Zone Server is already running"); Console.ResetColor(); break; } // TODO: Add Sql Check. csc.Compile(true); StartTheServer(); break; case "stop": if (!zoneServer.Running) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Zone Server is not running"); Console.ResetColor(); break; } zoneServer.Stop(); break; case "check": case "updatedb": using (SqlWrapper sqltester = new SqlWrapper()) { sqltester.CheckDBs(); Console.ResetColor(); } break; case "exit": case "quit": if (zoneServer.Running) { zoneServer.Stop(); } Process.GetCurrentProcess().Kill(); break; case "ls": // list all available scripts, dont remove it since it does what it should Console.WriteLine("Available scripts"); /* Old Lua way * string[] files = Directory.GetFiles("Scripts");*/ try { string[] files = Directory.GetFiles("Scripts", "*.cs", SearchOption.AllDirectories); if (files.Length == 0) { Console.WriteLine("No scripts were found."); break; } Console.ForegroundColor = ConsoleColor.Green; foreach (string s in files) { Console.WriteLine(s); } } catch (Exception) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Scripts folder not found."); } Console.ResetColor(); break; case "ping": // ChatCom.Server.Ping(); Console.WriteLine("Ping is disabled till we can fix it"); break; case "running": if (zoneServer.Running) { Console.WriteLine("Zone Server is Running"); break; } Console.WriteLine("Zone Server not Running"); break; case "online": if (zoneServer.Running) { Console.ForegroundColor = ConsoleColor.White; lock (zoneServer.Clients) { foreach (Client c in zoneServer.Clients) { Console.WriteLine("Character " + c.Character.Name + " online"); } } Console.ResetColor(); } break; default: ct.TextRead("zone_consolecmdsdefault.txt"); break; } } }
/// <summary> /// </summary> /// <param name="ZoneServer"> /// </param> /// <returns> /// </returns> public Client Create(ZoneServer ZoneServer) { return(new Client(ZoneServer, this.messageSerializer, this.bus)); }