public PluginDetails GetPluginDetailsCon(string strClassName) { var spdReturnDetails = new PluginDetails(); spdReturnDetails.ClassName = strClassName; spdReturnDetails.Name = InvokeOnLoaded_String(strClassName, "GetPluginName"); spdReturnDetails.Author = InvokeOnLoaded_String(strClassName, "GetPluginAuthor"); spdReturnDetails.Version = InvokeOnLoaded_String(strClassName, "GetPluginVersion"); spdReturnDetails.Website = InvokeOnLoaded_String(strClassName, "GetPluginWebsite"); spdReturnDetails.Description = InvokeOnLoaded_String(strClassName, "GetPluginDescription"); // a bit rough but for the moment... //spdReturnDetails.DisplayPluginVariables = this.InvokeOnLoaded_CPluginVariables(strClassName, "GetDisplayPluginVariables"); spdReturnDetails.PluginVariables = InvokeOnLoaded_CPluginVariables(strClassName, "GetPluginVariables"); return spdReturnDetails; }
private bool HandleEventPacket(Packet cpBeforePacketDispatch, bool blCancelPacket) { if (cpBeforePacketDispatch.Words.Count >= 1 && String.Compare(cpBeforePacketDispatch.Words[0], "procon.shutdown", true) == 0) { //this.SendPacket(new Packet(true, true, cpBeforePacketDispatch.SequenceNumber, new List<string>() { "OK" })); State = ConnectionState.Error; Connection_ConnectionFailure(Game.Connection, new Exception("The PRoCon layer has been shutdown by the host")); Shutdown(); blCancelPacket = true; } else if (cpBeforePacketDispatch.Words.Count >= 2 && String.Compare(cpBeforePacketDispatch.Words[0], "procon.account.onLogin", true) == 0) { //this.SendPacket(new Packet(true, true, cpBeforePacketDispatch.SequenceNumber, new List<string>() { "OK" })); // Also able to get their privs as well if needed? //this.m_uscParent.OnRemoteAccountLoggedIn(cpBeforePacketDispatch.Words[1], true); if (RemoteAccountLoggedIn != null) { FrostbiteConnection.RaiseEvent(RemoteAccountLoggedIn.GetInvocationList(), this, cpBeforePacketDispatch.Words[1], true); } blCancelPacket = true; } else if (cpBeforePacketDispatch.Words.Count >= 2 && String.Compare(cpBeforePacketDispatch.Words[0], "procon.account.onLogout", true) == 0) { //this.SendPacket(new Packet(true, true, cpBeforePacketDispatch.SequenceNumber, new List<string>() { "OK" })); if (RemoteAccountLoggedIn != null) { FrostbiteConnection.RaiseEvent(RemoteAccountLoggedIn.GetInvocationList(), this, cpBeforePacketDispatch.Words[1], false); } blCancelPacket = true; } else if (cpBeforePacketDispatch.Words.Count >= 3 && String.Compare(cpBeforePacketDispatch.Words[0], "procon.account.onUidRegistered", true) == 0) { if (m_dicUsernamesToUids.ContainsKey(cpBeforePacketDispatch.Words[2]) == true) { m_dicUsernamesToUids[cpBeforePacketDispatch.Words[2]] = cpBeforePacketDispatch.Words[1]; } else { m_dicUsernamesToUids.Add(cpBeforePacketDispatch.Words[2], cpBeforePacketDispatch.Words[1]); } blCancelPacket = true; } else if (cpBeforePacketDispatch.Words.Count >= 2 && String.Compare(cpBeforePacketDispatch.Words[0], "procon.account.onCreated", true) == 0) { //this.SendPacket(new Packet(true, true, cpBeforePacketDispatch.SequenceNumber, new List<string>() { "OK" })); if (RemoteAccountCreated != null) { FrostbiteConnection.RaiseEvent(RemoteAccountCreated.GetInvocationList(), this, cpBeforePacketDispatch.Words[1]); } blCancelPacket = true; } else if (cpBeforePacketDispatch.Words.Count >= 2 && String.Compare(cpBeforePacketDispatch.Words[0], "procon.account.onDeleted", true) == 0) { //this.SendPacket(new Packet(true, true, cpBeforePacketDispatch.SequenceNumber, new List<string>() { "OK" })); if (RemoteAccountDeleted != null) { FrostbiteConnection.RaiseEvent(RemoteAccountDeleted.GetInvocationList(), this, cpBeforePacketDispatch.Words[1]); } blCancelPacket = true; } else if (cpBeforePacketDispatch.Words.Count >= 3 && String.Compare(cpBeforePacketDispatch.Words[0], "procon.account.onAltered", true) == 0) { //this.SendPacket(new Packet(true, true, cpBeforePacketDispatch.SequenceNumber, new List<string>() { "OK" })); UInt32 ui32Privileges = 0; if (UInt32.TryParse(cpBeforePacketDispatch.Words[2], out ui32Privileges) == true) { var spPrivs = new CPrivileges(); spPrivs.PrivilegesFlags = ui32Privileges; if (ProconPrivileges != null && String.Compare(cpBeforePacketDispatch.Words[1], Username) == 0) { Privileges = spPrivs; FrostbiteConnection.RaiseEvent(ProconPrivileges.GetInvocationList(), this, spPrivs); } if (RemoteAccountAltered != null) { FrostbiteConnection.RaiseEvent(RemoteAccountAltered.GetInvocationList(), this, cpBeforePacketDispatch.Words[1], spPrivs); } } blCancelPacket = true; } else if (cpBeforePacketDispatch.Words.Count >= 2 && String.Compare(cpBeforePacketDispatch.Words[0], "procon.packages.onDownloading", true) == 0) { if (PackageDownloading != null) { FrostbiteConnection.RaiseEvent(PackageDownloading.GetInvocationList(), this, cpBeforePacketDispatch.Words[1]); } blCancelPacket = true; } else if (cpBeforePacketDispatch.Words.Count >= 2 && String.Compare(cpBeforePacketDispatch.Words[0], "procon.packages.onDownloaded", true) == 0) { if (PackageDownloaded != null) { FrostbiteConnection.RaiseEvent(PackageDownloaded.GetInvocationList(), this, cpBeforePacketDispatch.Words[1]); } blCancelPacket = true; } else if (cpBeforePacketDispatch.Words.Count >= 2 && String.Compare(cpBeforePacketDispatch.Words[0], "procon.packages.onInstalling", true) == 0) { if (PackageInstalling != null) { FrostbiteConnection.RaiseEvent(PackageInstalling.GetInvocationList(), this, cpBeforePacketDispatch.Words[1]); } blCancelPacket = true; } else if (cpBeforePacketDispatch.Words.Count >= 3 && String.Compare(cpBeforePacketDispatch.Words[0], "procon.packages.onDownloadError", true) == 0) { if (PackageDownloadError != null) { FrostbiteConnection.RaiseEvent(PackageDownloadError.GetInvocationList(), this, cpBeforePacketDispatch.Words[1], cpBeforePacketDispatch.Words[2]); } blCancelPacket = true; } else if (cpBeforePacketDispatch.Words.Count >= 3 && String.Compare(cpBeforePacketDispatch.Words[0], "procon.packages.onInstalled", true) == 0) { bool restartRequired = false; if (bool.TryParse(cpBeforePacketDispatch.Words[2], out restartRequired) == true) { if (PackageInstalled != null) { FrostbiteConnection.RaiseEvent(PackageInstalled.GetInvocationList(), this, cpBeforePacketDispatch.Words[1], restartRequired); } } blCancelPacket = true; } else if (cpBeforePacketDispatch.Words.Count >= 3 && String.Compare(cpBeforePacketDispatch.Words[0], "procon.chat.onConsole", true) == 0) { long logTime = 0L; if (long.TryParse(cpBeforePacketDispatch.Words[1], out logTime) == true) { if (ReadRemoteChatConsole != null) { FrostbiteConnection.RaiseEvent(ReadRemoteChatConsole.GetInvocationList(), this, DateTime.FromBinary(logTime), cpBeforePacketDispatch.Words[2]); } } } else if (cpBeforePacketDispatch.Words.Count >= 3 && String.Compare(cpBeforePacketDispatch.Words[0], "procon.plugin.onConsole", true) == 0) { long logTime = 0L; if (long.TryParse(cpBeforePacketDispatch.Words[1], out logTime) == true) { if (ReadRemotePluginConsole != null) { FrostbiteConnection.RaiseEvent(ReadRemotePluginConsole.GetInvocationList(), this, DateTime.FromBinary(logTime), cpBeforePacketDispatch.Words[2]); } } } else if (cpBeforePacketDispatch.Words.Count >= 3 && String.Compare(cpBeforePacketDispatch.Words[0], "procon.plugin.onVariablesAltered", true) == 0) { //this.SendPacket(new Packet(true, true, cpBeforePacketDispatch.SequenceNumber, new List<string>() { "OK" })); int i = 1; var lstVariables = new List<CPluginVariable>(); string strClassName = cpBeforePacketDispatch.Words[i++]; int iTotalVariables = 0; if (int.TryParse(cpBeforePacketDispatch.Words[i++], out iTotalVariables) == true && i + (iTotalVariables * 3) <= cpBeforePacketDispatch.Words.Count) { for (int x = 0; x < (iTotalVariables * 3); x += 3) { lstVariables.Add(new CPluginVariable(cpBeforePacketDispatch.Words[i++], cpBeforePacketDispatch.Words[i++], cpBeforePacketDispatch.Words[i++])); } } if (RemotePluginVariables != null) { FrostbiteConnection.RaiseEvent(RemotePluginVariables.GetInvocationList(), this, strClassName, lstVariables); } blCancelPacket = true; } else if (cpBeforePacketDispatch.Words.Count >= 1 && String.Compare(cpBeforePacketDispatch.Words[0], "procon.plugin.onLoaded", true) == 0) { //this.SendPacket(new Packet(true, true, cpBeforePacketDispatch.SequenceNumber, new List<string>() { "OK" })); int i = 1; if (i + 6 <= cpBeforePacketDispatch.Words.Count) { var spdLoaded = new PluginDetails(); spdLoaded.ClassName = cpBeforePacketDispatch.Words[i++]; spdLoaded.Name = cpBeforePacketDispatch.Words[i++]; spdLoaded.Author = cpBeforePacketDispatch.Words[i++]; spdLoaded.Website = cpBeforePacketDispatch.Words[i++]; spdLoaded.Version = cpBeforePacketDispatch.Words[i++]; spdLoaded.Description = cpBeforePacketDispatch.Words[i++]; spdLoaded.DisplayPluginVariables = new List<CPluginVariable>(); spdLoaded.PluginVariables = new List<CPluginVariable>(); // Not used here. int iTotalVariables = 0; if (int.TryParse(cpBeforePacketDispatch.Words[i++], out iTotalVariables) == true && i + (iTotalVariables * 3) <= cpBeforePacketDispatch.Words.Count) { for (int x = 0; x < (iTotalVariables * 3); x += 3) { spdLoaded.DisplayPluginVariables.Add(new CPluginVariable(cpBeforePacketDispatch.Words[i++], cpBeforePacketDispatch.Words[i++], cpBeforePacketDispatch.Words[i++])); } } if (RemotePluginLoaded != null) { FrostbiteConnection.RaiseEvent(RemotePluginLoaded.GetInvocationList(), this, spdLoaded); } } blCancelPacket = true; } else if (cpBeforePacketDispatch.Words.Count >= 3 && String.Compare(cpBeforePacketDispatch.Words[0], "procon.plugin.onEnabled", true) == 0) { //this.SendPacket(new Packet(true, true, cpBeforePacketDispatch.SequenceNumber, new List<string>() { "OK" })); bool blEnabled = false; if (bool.TryParse(cpBeforePacketDispatch.Words[2], out blEnabled) == true && RemotePluginEnabled != null) { FrostbiteConnection.RaiseEvent(RemotePluginEnabled.GetInvocationList(), this, cpBeforePacketDispatch.Words[1], blEnabled); } blCancelPacket = true; } else if (cpBeforePacketDispatch.Words.Count >= 4 && String.Compare(cpBeforePacketDispatch.Words[0], "procon.admin.onSay", true) == 0) { //this.SendPacket(new Packet(true, true, cpBeforePacketDispatch.SequenceNumber, new List<string>() { "OK" })); if (ProconAdminSaying != null) { FrostbiteConnection.RaiseEvent(ProconAdminSaying.GetInvocationList(), this, cpBeforePacketDispatch.Words[1], cpBeforePacketDispatch.Words[2], new CPlayerSubset(cpBeforePacketDispatch.Words.GetRange(3, cpBeforePacketDispatch.Words.Count - 3))); } if (PassLayerEvent != null) { FrostbiteConnection.RaiseEvent(PassLayerEvent.GetInvocationList(), this, cpBeforePacketDispatch); } blCancelPacket = true; } // MoHW R-6 hack else if (cpBeforePacketDispatch.Words.Count >= 4 && Game.GameType == "MOHW" && String.Compare(cpBeforePacketDispatch.Words[0], "procon.admin.onYell", true) == 0) { // this.SendPacket(new Packet(true, true, cpBeforePacketDispatch.SequenceNumber, new List<string>() { "OK" })); int iDisplayDuration = 0; if (ProconAdminYelling != null) { FrostbiteConnection.RaiseEvent(ProconAdminYelling.GetInvocationList(), this, cpBeforePacketDispatch.Words[1], cpBeforePacketDispatch.Words[2], iDisplayDuration, new CPlayerSubset(cpBeforePacketDispatch.Words.GetRange(4, cpBeforePacketDispatch.Words.Count - 4))); } if (PassLayerEvent != null) { FrostbiteConnection.RaiseEvent(PassLayerEvent.GetInvocationList(), this, cpBeforePacketDispatch); } blCancelPacket = true; } // hack end else if (cpBeforePacketDispatch.Words.Count >= 5 && String.Compare(cpBeforePacketDispatch.Words[0], "procon.admin.onYell", true) == 0) { // this.SendPacket(new Packet(true, true, cpBeforePacketDispatch.SequenceNumber, new List<string>() { "OK" })); int iDisplayDuration = 0; if (int.TryParse(cpBeforePacketDispatch.Words[3], out iDisplayDuration) == true) { if (ProconAdminYelling != null) { FrostbiteConnection.RaiseEvent(ProconAdminYelling.GetInvocationList(), this, cpBeforePacketDispatch.Words[1], cpBeforePacketDispatch.Words[2], iDisplayDuration, new CPlayerSubset(cpBeforePacketDispatch.Words.GetRange(4, cpBeforePacketDispatch.Words.Count - 4))); } if (PassLayerEvent != null) { FrostbiteConnection.RaiseEvent(PassLayerEvent.GetInvocationList(), this, cpBeforePacketDispatch); } } blCancelPacket = true; } // bf3 player.ping else if (Game.GameType == "BF3" && cpBeforePacketDispatch.Words.Count >= 3 && String.Compare(cpBeforePacketDispatch.Words[0], "procon.admin.onPlayerPinged", true) == 0) { int iPing = 0; string strSoldierName = cpBeforePacketDispatch.Words[1]; if (int.TryParse(cpBeforePacketDispatch.Words[2], out iPing) == true) { if (iPing == 65535) { iPing = -1; } if (ProconAdminPinging != null) { FrostbiteConnection.RaiseEvent(ProconAdminPinging.GetInvocationList(), this, strSoldierName, iPing); } if (PassLayerEvent != null) { FrostbiteConnection.RaiseEvent(PassLayerEvent.GetInvocationList(), this, cpBeforePacketDispatch); } } blCancelPacket = true; } else if (cpBeforePacketDispatch.Words.Count >= 3 && String.Compare(cpBeforePacketDispatch.Words[0], "procon.updated", true) == 0) { //this.SendPacket(new Packet(true, true, cpBeforePacketDispatch.SequenceNumber, new List<string>() { "OK" })); foreach (var registerUid in m_dicUsernamesToUids) { if (String.Compare(cpBeforePacketDispatch.Words[1], registerUid.Value) == 0) { InstigatingAccountName = registerUid.Key; break; } } // Only parse it if the UID is different from this connections registered UID. if (String.Compare(cpBeforePacketDispatch.Words[1], ProconEventsUid) != 0) { var lstAssumedRequestPacket = new List<string>(cpBeforePacketDispatch.Words); lstAssumedRequestPacket.RemoveRange(0, 2); var cpAssumedRequestPacket = new Packet(false, false, 0, lstAssumedRequestPacket); var cpAssumedResponsePacket = new Packet(false, true, 0, new List<string>() { "OK" }); Game.DispatchResponsePacket(Game.Connection, cpAssumedResponsePacket, cpAssumedRequestPacket); cpAssumedRequestPacket = null; cpAssumedResponsePacket = null; if (PassLayerEvent != null) { FrostbiteConnection.RaiseEvent(PassLayerEvent.GetInvocationList(), this, cpBeforePacketDispatch); } } blCancelPacket = true; } else if (cpBeforePacketDispatch.Words.Count >= 2 && String.Compare(cpBeforePacketDispatch.Words[0], "procon.battlemap.onZoneRemoved", true) == 0) { if (MapZoneDeleted != null) { FrostbiteConnection.RaiseEvent(MapZoneDeleted.GetInvocationList(), this, new MapZoneDrawing(cpBeforePacketDispatch.Words[1], String.Empty, String.Empty, null, true)); } } else if (cpBeforePacketDispatch.Words.Count >= 4 && String.Compare(cpBeforePacketDispatch.Words[0], "procon.battlemap.onZoneCreated", true) == 0) { //this.SendPacket(new Packet(true, true, cpBeforePacketDispatch.SequenceNumber, new List<string>() { "OK" })); int iPoints = 0; if (int.TryParse(cpBeforePacketDispatch.Words[3], out iPoints) == true) { var points = new Point3D[iPoints]; for (int i = 0; i < iPoints; i++) { points[i] = new Point3D(cpBeforePacketDispatch.Words[3 + i * 3 + 1], cpBeforePacketDispatch.Words[3 + i * 3 + 2], cpBeforePacketDispatch.Words[3 + i * 3 + 3]); } if (MapZoneCreated != null) { FrostbiteConnection.RaiseEvent(MapZoneCreated.GetInvocationList(), this, new MapZoneDrawing(cpBeforePacketDispatch.Words[1], cpBeforePacketDispatch.Words[2], String.Empty, points, true)); } } blCancelPacket = true; } else if (cpBeforePacketDispatch.Words.Count >= 3 && String.Compare(cpBeforePacketDispatch.Words[0], "procon.battlemap.onZoneModified", true) == 0) { //this.SendPacket(new Packet(true, true, cpBeforePacketDispatch.SequenceNumber, new List<string>() { "OK" })); int iPoints = 0; if (int.TryParse(cpBeforePacketDispatch.Words[3], out iPoints) == true) { var points = new Point3D[iPoints]; for (int i = 0; i < iPoints; i++) { points[i] = new Point3D(cpBeforePacketDispatch.Words[3 + i * 3 + 1], cpBeforePacketDispatch.Words[3 + i * 3 + 2], cpBeforePacketDispatch.Words[3 + i * 3 + 3]); } if (MapZoneModified != null) { FrostbiteConnection.RaiseEvent(MapZoneModified.GetInvocationList(), this, new MapZoneDrawing(cpBeforePacketDispatch.Words[1], String.Empty, cpBeforePacketDispatch.Words[2], points, true)); } } blCancelPacket = true; } else if (cpBeforePacketDispatch.Words.Count >= 3 && String.Compare(cpBeforePacketDispatch.Words[0], "procon.vars.onAltered", true) == 0) { //this.SendPacket(new Packet(true, true, cpBeforePacketDispatch.SequenceNumber, new List<string>() { "OK" })); SV_Variables.SetVariable(cpBeforePacketDispatch.Words[1], cpBeforePacketDispatch.Words[2]); if (ReceiveProconVariable != null) { FrostbiteConnection.RaiseEvent(ReceiveProconVariable.GetInvocationList(), this, cpBeforePacketDispatch.Words[1], cpBeforePacketDispatch.Words[2]); } blCancelPacket = true; } else { // if (blCommandConnection == false) Pass everything else onto any connected clients.. if (PassLayerEvent != null) { FrostbiteConnection.RaiseEvent(PassLayerEvent.GetInvocationList(), this, cpBeforePacketDispatch); } } return blCancelPacket; }
public PluginDetails GetPluginDetails(string strClassName) { PluginDetails spdReturnDetails = new PluginDetails(); spdReturnDetails.ClassName = strClassName; spdReturnDetails.Name = this.InvokeOnLoaded_String(strClassName, "GetPluginName"); spdReturnDetails.Author = this.InvokeOnLoaded_String(strClassName, "GetPluginAuthor"); spdReturnDetails.Version = this.InvokeOnLoaded_String(strClassName, "GetPluginVersion"); spdReturnDetails.Website = this.InvokeOnLoaded_String(strClassName, "GetPluginWebsite"); spdReturnDetails.Description = this.InvokeOnLoaded_String(strClassName, "GetPluginDescription"); spdReturnDetails.DisplayPluginVariables = this.InvokeOnLoaded_CPluginVariables(strClassName, "GetDisplayPluginVariables"); spdReturnDetails.PluginVariables = this.InvokeOnLoaded_CPluginVariables(strClassName, "GetPluginVariables"); return spdReturnDetails; }
private bool HandleResponsePacket(Packet cpBeforePacketDispatch, bool blCancelUpdateEvent, bool blCancelPacket) { if (Game != null) { Packet cpRequestPacket = Game.Connection.GetRequestPacket(cpBeforePacketDispatch); if (cpRequestPacket != null) { if (cpBeforePacketDispatch.Words.Count >= 1 && String.Compare(cpBeforePacketDispatch.Words[0], "InvalidUsername", true) == 0) { if (LoginFailure != null) { FrostbiteConnection.RaiseEvent(LoginFailure.GetInvocationList(), this, cpBeforePacketDispatch.Words[0]); } Shutdown(); State = ConnectionState.Error; blCancelPacket = true; } else if (cpRequestPacket.Words.Count >= 1 && String.Compare(cpRequestPacket.Words[0], "procon.version", true) == 0 && cpBeforePacketDispatch.Words.Count >= 2) { try { ConnectedLayerVersion = new Version(cpBeforePacketDispatch.Words[1]); if (ProconVersion != null) { FrostbiteConnection.RaiseEvent(ProconVersion.GetInvocationList(), this, ConnectedLayerVersion); } } catch (Exception) { } blCancelPacket = true; } else if (cpRequestPacket.Words.Count >= 1 && String.Compare(cpRequestPacket.Words[0], "procon.privileges", true) == 0 && cpBeforePacketDispatch.Words.Count >= 2) { UInt32 ui32Privileges = 0; if (UInt32.TryParse(cpBeforePacketDispatch.Words[1], out ui32Privileges) == true) { var spPrivs = new CPrivileges(); spPrivs.PrivilegesFlags = ui32Privileges; Privileges = spPrivs; if (ProconPrivileges != null) { FrostbiteConnection.RaiseEvent(ProconPrivileges.GetInvocationList(), this, spPrivs); } } blCancelPacket = true; } else if (cpRequestPacket.Words.Count >= 2 && String.Compare(cpRequestPacket.Words[0], "procon.registerUid", true) == 0 && cpBeforePacketDispatch.Words.Count >= 1) { if (String.Compare(cpBeforePacketDispatch.Words[0], "OK", true) == 0 && cpRequestPacket.Words.Count >= 3) { ProconEventsUid = cpRequestPacket.Words[2]; } else if (String.Compare(cpBeforePacketDispatch.Words[0], "ProconUidConflict", true) == 0) { // Conflict in our UID, just hash and send another one. // Then go to vegas. SendRequest(new List<string>() { "procon.registerUid", "true", FrostbiteClient.GeneratePasswordHash(Encoding.ASCII.GetBytes(DateTime.Now.ToString("HH:mm:ss ff")), _username) }); } blCancelPacket = true; } else if (cpRequestPacket.Words.Count >= 1 && String.Compare(cpRequestPacket.Words[0], "procon.account.listAccounts", true) == 0) { UInt32 ui32Privileges = 0; for (int i = 1; i < cpBeforePacketDispatch.Words.Count; i += 2) { if (UInt32.TryParse(cpBeforePacketDispatch.Words[i + 1], out ui32Privileges) == true) { var spPrivs = new CPrivileges(); spPrivs.PrivilegesFlags = ui32Privileges; if (RemoteAccountCreated != null && RemoteAccountAltered != null) { FrostbiteConnection.RaiseEvent(RemoteAccountCreated.GetInvocationList(), this, cpBeforePacketDispatch.Words[i]); FrostbiteConnection.RaiseEvent(RemoteAccountAltered.GetInvocationList(), this, cpBeforePacketDispatch.Words[i], spPrivs); } } } blCancelPacket = true; } else if (cpRequestPacket.Words.Count >= 1 && String.Compare(cpRequestPacket.Words[0], "procon.battlemap.listZones", true) == 0 && cpBeforePacketDispatch.Words.Count >= 2 && String.Compare(cpBeforePacketDispatch.Words[0], "OK", true) == 0) { var zones = new List<MapZoneDrawing>(); int iZones = 0; int iOffset = 1; if (int.TryParse(cpBeforePacketDispatch.Words[iOffset++], out iZones) == true) { for (int iZoneCount = 0; iZoneCount < iZones; iZoneCount++) { string uid = String.Empty; string level = String.Empty; string tags = String.Empty; var points = new List<Point3D>(); if (iOffset + 4 < cpBeforePacketDispatch.Words.Count) { uid = cpBeforePacketDispatch.Words[iOffset++]; level = cpBeforePacketDispatch.Words[iOffset++]; tags = cpBeforePacketDispatch.Words[iOffset++]; int iZonePoints = 0; if (int.TryParse(cpBeforePacketDispatch.Words[iOffset++], out iZonePoints) == true && iOffset + iZonePoints * 3 <= cpBeforePacketDispatch.Words.Count) { for (int iZonePointCount = 0; iZonePointCount < iZonePoints && iOffset + 3 <= cpBeforePacketDispatch.Words.Count; iZonePointCount++) { points.Add(new Point3D(cpBeforePacketDispatch.Words[iOffset++], cpBeforePacketDispatch.Words[iOffset++], cpBeforePacketDispatch.Words[iOffset++])); } } } zones.Add(new MapZoneDrawing(uid, level, tags, points.ToArray(), true)); } } if (ListMapZones != null) { FrostbiteConnection.RaiseEvent(ListMapZones.GetInvocationList(), this, zones); } blCancelPacket = true; } else if (cpRequestPacket.Words.Count >= 1 && String.Compare(cpRequestPacket.Words[0], "procon.account.setPassword", true) == 0 && cpBeforePacketDispatch.Words.Count >= 1 && String.Compare(cpBeforePacketDispatch.Words[0], "OK", true) == 0) { if (RemoteAccountChangePassword != null) { FrostbiteConnection.RaiseEvent(RemoteAccountChangePassword.GetInvocationList(), this); } blCancelPacket = true; } else if (cpRequestPacket.Words.Count >= 1 && String.Compare(cpRequestPacket.Words[0], "procon.account.listLoggedIn", true) == 0) { bool containsUids = (cpRequestPacket.Words.Count >= 2 && String.Compare(cpRequestPacket.Words[1], "uids") == 0); if (RemoteAccountLoggedIn != null) { for (int i = 1; i < cpBeforePacketDispatch.Words.Count; i++) { FrostbiteConnection.RaiseEvent(RemoteAccountLoggedIn.GetInvocationList(), this, cpBeforePacketDispatch.Words[i], true); if (containsUids == true && i + 1 < cpBeforePacketDispatch.Words.Count) { if (m_dicUsernamesToUids.ContainsKey(cpBeforePacketDispatch.Words[i]) == true) { m_dicUsernamesToUids[cpBeforePacketDispatch.Words[i]] = cpBeforePacketDispatch.Words[i + 1]; } else { m_dicUsernamesToUids.Add(cpBeforePacketDispatch.Words[i], cpBeforePacketDispatch.Words[i + 1]); } i++; } } } blCancelPacket = true; } else if (cpRequestPacket.Words.Count >= 1 && String.Compare(cpRequestPacket.Words[0], "procon.plugin.listEnabled", true) == 0) { if (RemoteEnabledPlugins != null) { var lstEnabledPlugins = new List<string>(cpBeforePacketDispatch.Words); lstEnabledPlugins.RemoveAt(0); FrostbiteConnection.RaiseEvent(RemoteEnabledPlugins.GetInvocationList(), this, lstEnabledPlugins); } blCancelPacket = true; } else if (cpRequestPacket.Words.Count >= 1 && String.Compare(cpRequestPacket.Words[0], "procon.vars", true) == 0 && cpBeforePacketDispatch.Words.Count >= 3) { SV_Variables.SetVariable(cpBeforePacketDispatch.Words[1], cpBeforePacketDispatch.Words[2]); if (ReceiveProconVariable != null) { FrostbiteConnection.RaiseEvent(ReceiveProconVariable.GetInvocationList(), this, cpBeforePacketDispatch.Words[1], cpBeforePacketDispatch.Words[2]); } // Dispatch to plugins. } else if (cpRequestPacket.Words.Count >= 1 && String.Compare(cpRequestPacket.Words[0], "procon.plugin.listLoaded", true) == 0) { if (RemoteLoadedPlugins != null) { int i = 0; if (cpBeforePacketDispatch.Words.Count >= 1 && String.Compare(cpBeforePacketDispatch.Words[i++], "OK", true) == 0) { var dicLoadedPlugins = new Dictionary<string, PluginDetails>(); while (i + 6 <= cpBeforePacketDispatch.Words.Count) { var spdLoaded = new PluginDetails(); spdLoaded.ClassName = cpBeforePacketDispatch.Words[i++]; spdLoaded.Name = cpBeforePacketDispatch.Words[i++]; spdLoaded.Author = cpBeforePacketDispatch.Words[i++]; spdLoaded.Website = cpBeforePacketDispatch.Words[i++]; spdLoaded.Version = cpBeforePacketDispatch.Words[i++]; spdLoaded.Description = cpBeforePacketDispatch.Words[i++]; spdLoaded.DisplayPluginVariables = new List<CPluginVariable>(); spdLoaded.PluginVariables = new List<CPluginVariable>(); // Not used here. int iTotalVariables = 0; if (int.TryParse(cpBeforePacketDispatch.Words[i++], out iTotalVariables) == true && i + (iTotalVariables * 3) <= cpBeforePacketDispatch.Words.Count) { for (int x = 0; x < (iTotalVariables * 3); x += 3) { spdLoaded.DisplayPluginVariables.Add(new CPluginVariable(cpBeforePacketDispatch.Words[i++], cpBeforePacketDispatch.Words[i++], cpBeforePacketDispatch.Words[i++])); } } if (dicLoadedPlugins.ContainsKey(spdLoaded.ClassName) == false) { dicLoadedPlugins.Add(spdLoaded.ClassName, spdLoaded); } } FrostbiteConnection.RaiseEvent(RemoteLoadedPlugins.GetInvocationList(), this, dicLoadedPlugins); } } blCancelPacket = true; } else if (cpRequestPacket.Words.Count >= 2 && String.Compare(cpRequestPacket.Words[0], "login.hashed", true) == 0 && cpBeforePacketDispatch.Words.Count >= 1 && String.Compare(cpBeforePacketDispatch.Words[0], "InsufficientPrivileges", true) == 0) { if (LoginFailure != null) { FrostbiteConnection.RaiseEvent(LoginFailure.GetInvocationList(), this, cpBeforePacketDispatch.Words[0]); } Shutdown(); State = ConnectionState.Error; blCancelPacket = true; } else if (cpRequestPacket.Words.Count >= 2 && String.Compare(cpRequestPacket.Words[0], "procon.login.username", true) == 0 && cpBeforePacketDispatch.Words.Count >= 1 && (String.Compare(cpBeforePacketDispatch.Words[0], "OK", true) == 0 || String.Compare(cpBeforePacketDispatch.Words[0], "UnknownCommand", true) == 0)) { //this.send(new Packet(true, true, cpBeforePacketDispatch.SequenceNumber, new List<string>() { "procon.login.requestUsername", this.m_strUsername })); // This is the first command we would recieve so now we know we're connected through a PRoCon layer. if (LoginAttempt != null) { FrostbiteConnection.RaiseEvent(LoginAttempt.GetInvocationList(), this); } Game.SendLoginHashedPacket(Password); if (String.Compare(cpBeforePacketDispatch.Words[0], "OK", true) == 0) { IsPRoConConnection = true; Game.IsLayered = true; } else { IsPRoConConnection = false; Username = ""; } blCancelPacket = true; } else if (cpRequestPacket.Words.Count >= 2 && String.Compare(cpRequestPacket.Words[0], "procon.login.username", true) == 0 && cpBeforePacketDispatch.Words.Count >= 1 && String.Compare(cpBeforePacketDispatch.Words[0], "InsufficientPrivileges", true) == 0) { // The servers just told us off, try and login normally. if (LoginFailure != null) { FrostbiteConnection.RaiseEvent(LoginFailure.GetInvocationList(), this, cpBeforePacketDispatch.Words[0]); } Shutdown(); State = ConnectionState.Error; blCancelPacket = true; } else if (cpRequestPacket.Words.Count >= 3 && String.Compare(cpRequestPacket.Words[0], "admin.say", true) == 0 && m_dicForwardedPackets.ContainsKey(cpBeforePacketDispatch.SequenceNumber) == true) { if (m_dicForwardedPackets[cpBeforePacketDispatch.SequenceNumber].m_lstWords.Count >= 4 && String.Compare(m_dicForwardedPackets[cpBeforePacketDispatch.SequenceNumber].m_lstWords[0], "procon.admin.say", true) == 0) { m_dicForwardedPackets[cpBeforePacketDispatch.SequenceNumber].m_lstWords[0] = "procon.admin.onSay"; if (IsPRoConConnection == false) { List<string> lstWords = m_dicForwardedPackets[cpBeforePacketDispatch.SequenceNumber].m_lstWords; if (ProconAdminSaying != null) { FrostbiteConnection.RaiseEvent(ProconAdminSaying.GetInvocationList(), this, lstWords[1], lstWords[2], new CPlayerSubset(lstWords.GetRange(3, lstWords.Count - 3))); } } if (PassLayerEvent != null) { FrostbiteConnection.RaiseEvent(PassLayerEvent.GetInvocationList(), this, new Packet(true, false, cpRequestPacket.SequenceNumber, m_dicForwardedPackets[cpBeforePacketDispatch.SequenceNumber].m_lstWords)); } // Send to all logged in layer clients m_dicForwardedPackets.Remove(cpBeforePacketDispatch.SequenceNumber); blCancelPacket = true; blCancelUpdateEvent = true; } } else if (cpRequestPacket.Words.Count >= 4 && String.Compare(cpRequestPacket.Words[0], "admin.yell", true) == 0 && m_dicForwardedPackets.ContainsKey(cpBeforePacketDispatch.SequenceNumber) == true) { if (m_dicForwardedPackets[cpBeforePacketDispatch.SequenceNumber].m_lstWords.Count >= 5 && String.Compare(m_dicForwardedPackets[cpBeforePacketDispatch.SequenceNumber].m_lstWords[0], "procon.admin.yell", true) == 0) { m_dicForwardedPackets[cpBeforePacketDispatch.SequenceNumber].m_lstWords[0] = "procon.admin.onYell"; // If we're at the top of the tree, simulate the event coming from a layer above. if (IsPRoConConnection == false) { List<string> lstWords = m_dicForwardedPackets[cpBeforePacketDispatch.SequenceNumber].m_lstWords; int iDisplayDuration = 0; if (int.TryParse(lstWords[3], out iDisplayDuration) == true) { if (ProconAdminYelling != null) { FrostbiteConnection.RaiseEvent(ProconAdminYelling.GetInvocationList(), this, lstWords[1], lstWords[2], iDisplayDuration, new CPlayerSubset(lstWords.GetRange(4, lstWords.Count - 4))); } } } // Send to all logged in layer clients if (PassLayerEvent != null) { FrostbiteConnection.RaiseEvent(PassLayerEvent.GetInvocationList(), this, new Packet(true, false, cpRequestPacket.SequenceNumber, m_dicForwardedPackets[cpBeforePacketDispatch.SequenceNumber].m_lstWords)); } m_dicForwardedPackets.Remove(cpBeforePacketDispatch.SequenceNumber); blCancelPacket = true; blCancelUpdateEvent = true; } } // MoHW R-6 hack else if (cpRequestPacket.Words.Count >= 3 && Game.GameType == "MOHW" && String.Compare(cpRequestPacket.Words[0], "admin.yell", true) == 0 && m_dicForwardedPackets.ContainsKey(cpBeforePacketDispatch.SequenceNumber) == true) { if (m_dicForwardedPackets[cpBeforePacketDispatch.SequenceNumber].m_lstWords.Count >= 4 && String.Compare(m_dicForwardedPackets[cpBeforePacketDispatch.SequenceNumber].m_lstWords[0], "procon.admin.yell", true) == 0) { m_dicForwardedPackets[cpBeforePacketDispatch.SequenceNumber].m_lstWords[0] = "procon.admin.onYell"; // If we're at the top of the tree, simulate the event coming from a layer above. if (IsPRoConConnection == false) { List<string> lstWords = m_dicForwardedPackets[cpBeforePacketDispatch.SequenceNumber].m_lstWords; int iDisplayDuration = 0; if (int.TryParse(lstWords[3], out iDisplayDuration) == true) { iDisplayDuration = 0; if (ProconAdminYelling != null) { FrostbiteConnection.RaiseEvent(ProconAdminYelling.GetInvocationList(), this, lstWords[1], lstWords[2], iDisplayDuration, new CPlayerSubset(lstWords.GetRange(4, lstWords.Count - 4))); } } } // Send to all logged in layer clients if (PassLayerEvent != null) { FrostbiteConnection.RaiseEvent(PassLayerEvent.GetInvocationList(), this, new Packet(true, false, cpRequestPacket.SequenceNumber, m_dicForwardedPackets[cpBeforePacketDispatch.SequenceNumber].m_lstWords)); } m_dicForwardedPackets.Remove(cpBeforePacketDispatch.SequenceNumber); blCancelPacket = true; blCancelUpdateEvent = true; } } // end hack // BF3 player.ping else if (cpRequestPacket.Words.Count >= 2 && Game.GameType == "BF3" && String.Compare(cpRequestPacket.Words[0], "player.ping", true) == 0 && String.Compare(cpBeforePacketDispatch.Words[0], "OK", true) == 0) { string strProconEventsUid = String.Empty; var lstProconUpdatedWords = new List<string>(cpRequestPacket.Words); lstProconUpdatedWords.Insert(0, "procon.admin.onPlayerPinged"); lstProconUpdatedWords.RemoveAt(1); lstProconUpdatedWords.Add(cpBeforePacketDispatch.Words[1]); // Now we pass on the packet to all the clients as an event so they can remain in sync. // Don't pass on anything regarding login if ((lstProconUpdatedWords.Count >= 4 && (String.Compare(lstProconUpdatedWords[2], "login.plainText", true) == 0 || String.Compare(lstProconUpdatedWords[2], "login.hashed", true) == 0)) == false) { if (PassLayerEvent != null) { FrostbiteConnection.RaiseEvent(PassLayerEvent.GetInvocationList(), this, new Packet(true, false, cpRequestPacket.SequenceNumber, lstProconUpdatedWords)); } } } if (blCancelUpdateEvent == false) { string strProconEventsUid = String.Empty; // If a layer client sent this packet.. if (m_dicForwardedPackets.ContainsKey(cpBeforePacketDispatch.SequenceNumber) == true) { if (m_dicForwardedPackets[cpBeforePacketDispatch.SequenceNumber].m_sender != null) { (m_dicForwardedPackets[cpBeforePacketDispatch.SequenceNumber].m_sender).OnServerForwardedResponse(new Packet(false, true, m_dicForwardedPackets[cpBeforePacketDispatch.SequenceNumber].m_ui32OriginalSequence, new List<string>(cpBeforePacketDispatch.Words))); strProconEventsUid = (m_dicForwardedPackets[cpBeforePacketDispatch.SequenceNumber].m_sender).ProconEventsUid; InstigatingAccountName = m_dicForwardedPackets[cpBeforePacketDispatch.SequenceNumber].m_sender.Username; } // Unregister the sequence and packet. m_dicForwardedPackets.Remove(cpBeforePacketDispatch.SequenceNumber); } // IF the command was not a request for a list (it's a GET operation only, // as in it only lists or retrieves information and will never be set.) if (Game != null && Game.GetPacketsPattern.IsMatch(cpRequestPacket.ToString()) == false) { // && cpBeforePacketDispatch.Words.Count >= 1 && String.Compare(cpBeforePacketDispatch.Words[0], "OK") == 0) { var lstProconUpdatedWords = new List<string>(cpRequestPacket.Words); lstProconUpdatedWords.Insert(0, "procon.updated"); lstProconUpdatedWords.Insert(1, strProconEventsUid); // Now we pass on the packet to all the clients as an event so they can remain in sync. // Don't pass on anything regarding login if ((lstProconUpdatedWords.Count >= 4 && (String.Compare(lstProconUpdatedWords[2], "login.plainText", true) == 0 || String.Compare(lstProconUpdatedWords[2], "login.hashed", true) == 0)) == false) { if (PassLayerEvent != null) { FrostbiteConnection.RaiseEvent(PassLayerEvent.GetInvocationList(), this, new Packet(true, false, cpRequestPacket.SequenceNumber, lstProconUpdatedWords)); } } } } } } return blCancelPacket; }
private void Plugins_PluginVariableAltered(PluginDetails spdNewDetails) { SaveConnectionConfig(); }
private PluginDetails uscPlugins_GetPluginDetails(string strClassName) { PluginDetails spdReturn = new PluginDetails(); spdReturn.ClassName = strClassName; spdReturn.Name = strClassName; if (this.m_prcConnection.PluginsManager != null) { spdReturn = this.m_prcConnection.PluginsManager.GetPluginDetails(strClassName); } return spdReturn; }
private void uscPlugins_PluginLoaded(PluginDetails spdPlugin) { }
private void uscPlugins_PluginVariablesAltered(PluginDetails spdPlugin) { }
private void Plugins_PluginVariableAltered(PluginDetails spdNewDetails) { this.InvokeIfRequired(() => this.uscPlugins.RefreshPlugin()); }
/* public void SetRemoteEnabledPlugins(List<string> lstClassNames) { } */ private void m_prcClient_RemotePluginLoaded(PRoConClient sender, PluginDetails spdDetails) { this.InvokeIfRequired(() => { if (this.m_dicRemotePlugins.ContainsKey(spdDetails.ClassName) == true) { this.m_dicRemotePlugins[spdDetails.ClassName] = spdDetails; } else { this.m_dicRemotePlugins.Add(spdDetails.ClassName, spdDetails); } this.m_blUpdatingPlugins = true; this.uscPlugins.SetLoadedPlugins(new List<string>(this.m_dicRemotePlugins.Keys)); this.m_blUpdatingPlugins = false; }); }