Exemplo n.º 1
0
        public FrostbiteClient(FrostbiteConnection connection) {
            Connection = connection;
            Connection.PacketReceived += new FrostbiteConnection.PacketDispatchHandler(Connection_PacketRecieved);
            Connection.PacketCacheIntercept += new FrostbiteConnection.PacketCacheDispatchHandler(Connection_PacketCacheIntercept);
            // Register.

            Login += new EmptyParamterHandler(FrostbiteClient_Login);
            Version += new VersionHandler(FrostbiteClient_Version);

            VersionNumberToFriendlyName = new Dictionary<string, string>();

            ResponseDelegates = new Dictionary<string, ResponsePacketHandler>() {
                #region Global/Login

                {"login.plainText", DispatchLoginPlainTextResponse},
                {"login.hashed", DispatchLoginHashedResponse},
                {"logout", DispatchLogoutResponse},
                {"quit", DispatchQuitResponse},
                {"version", DispatchVersionResponse},
                {"eventsEnabled", DispatchEventsEnabledResponse},
                {"help", DispatchHelpResponse},
                {"admin.runScript", DispatchAdminRunScriptResponse},
                {"punkBuster.pb_sv_command", DispatchPunkbusterPbSvCommandResponse},
                {"serverInfo", DispatchServerInfoResponse},
                {"admin.say", DispatchAdminSayResponse},
                {"admin.yell", DispatchAdminYellResponse},

                #endregion

                #region Map list functions

                {"admin.restartMap", DispatchAdminRestartRoundResponse},
                {"admin.supportedMaps", DispatchAdminSupportedMapsResponse},
                {"admin.getPlaylists", DispatchAdminGetPlaylistsResponse},
                {"admin.listPlayers", DispatchAdminListPlayersResponse},
                {"admin.endRound", DispatchAdminEndRoundResponse},
                {"admin.runNextRound", DispatchAdminRunNextRoundResponse},
                {"admin.restartRound", DispatchAdminRestartRoundResponse},

                #endregion

                #region Banlist

                {"banList.add", DispatchBanListAddResponse},
                {"banList.remove", DispatchBanListRemoveResponse},
                {"banList.clear", DispatchBanListClearResponse},
                {"banList.save", DispatchBanListSaveResponse},
                {"banList.load", DispatchBanListLoadResponse},
                {"banList.list", DispatchBanListListResponse},

                #endregion

                #region Text Chat Moderation

                {"textChatModerationList.addPlayer", DispatchTextChatModerationAddPlayerResponse},
                {"textChatModerationList.removePlayer", DispatchTextChatModerationListRemovePlayerResponse},
                {"textChatModerationList.clear", DispatchTextChatModerationListClearResponse},
                {"textChatModerationList.save", DispatchTextChatModerationListSaveResponse},
                {"textChatModerationList.load", DispatchTextChatModerationListLoadResponse},
                {"textChatModerationList.list", DispatchTextChatModerationListListResponse},

                #endregion

                {"vars.textChatModerationMode", DispatchVarsTextChatModerationModeResponse},
                {"vars.textChatSpamTriggerCount", DispatchVarsTextChatSpamTriggerCountResponse},
                {"vars.textChatSpamDetectionTime", DispatchVarsTextChatSpamDetectionTimeResponse},
                {"vars.textChatSpamCoolDownTime", DispatchVarsTextChatSpamCoolDownTimeResponse},

                #region Maplist

                {"mapList.configFile", DispatchMapListConfigFileResponse},
                {"mapList.load", DispatchMapListLoadResponse},
                {"mapList.save", DispatchMapListSaveResponse},
                {"mapList.list", DispatchMapListListResponse},
                {"mapList.clear", DispatchMapListClearResponse},
                {"mapList.append", DispatchMapListAppendResponse},
                {"mapList.nextLevelIndex", DispatchMapListNextLevelIndexResponse},
                {"mapList.remove", DispatchMapListRemoveResponse},
                {"mapList.insert", DispatchMapListInsertResponse},

                #endregion

                // Details
                {"vars.serverName", DispatchVarsServerNameResponse},
                {"vars.serverDescription", DispatchVarsServerDescriptionResponse},
                {"vars.bannerUrl", DispatchVarsBannerUrlResponse},

                // Configuration
                {"vars.adminPassword", DispatchVarsAdminPasswordResponse},
                {"vars.gamePassword", DispatchVarsGamePasswordResponse},
                {"vars.punkBuster", DispatchVarsPunkbusterResponse},
                {"vars.ranked", DispatchVarsRankedResponse},
                {"vars.playerLimit", DispatchVarsPlayerLimitResponse},
                {"vars.currentPlayerLimit", DispatchVarsCurrentPlayerLimitResponse},
                {"vars.maxPlayerLimit", DispatchVarsMaxPlayerLimitResponse},
                {"vars.idleTimeout", DispatchVarsIdleTimeoutResponse},
                {"vars.profanityFilter", DispatchVarsProfanityFilterResponse},
                
                // Gameplay
                {"vars.friendlyFire", DispatchVarsFriendlyFireResponse},
                {"vars.hardCore", DispatchVarsHardCoreResponse},

                #region Team killing

                {"vars.teamKillCountForKick", DispatchVarsTeamKillCountForKickResponse},
                {"vars.teamKillValueForKick", DispatchVarsTeamKillValueForKickResponse},
                {"vars.teamKillValueIncrease", DispatchVarsTeamKillValueIncreaseResponse},
                {"vars.teamKillValueDecreasePerSecond", DispatchVarsTeamKillValueDecreasePerSecondResponse},

                #endregion

                #region Level vars

                {"levelVars.set", DispatchLevelVarsSetResponse},
                {"levelVars.get", DispatchLevelVarsGetResponse},
                {"levelVars.evaluate", DispatchLevelVarsEvaluateResponse},
                {"levelVars.clear", DispatchLevelVarsClearResponse},
                {"levelVars.list", DispatchLevelVarsListResponse},

                #endregion

                {"admin.kickPlayer", DispatchAdminKickPlayerResponse},
                {"admin.killPlayer", DispatchAdminKillPlayerResponse},
                {"admin.movePlayer", DispatchAdminMovePlayerResponse},
                {"admin.shutDown", DispatchAdminShutDownResponse},
            };

            RequestDelegates = new Dictionary<string, RequestPacketHandler>() {
                {"player.onJoin", DispatchPlayerOnJoinRequest},
                {"player.onLeave", DispatchPlayerOnLeaveRequest},
                {"player.onDisconnect", DispatchPlayerOnDisconnectRequest},
                {"player.onAuthenticated", DispatchPlayerOnAuthenticatedRequest},
                {"player.onKill", DispatchPlayerOnKillRequest},
                {"player.onChat", DispatchPlayerOnChatRequest},
                {"player.onKicked", DispatchPlayerOnKickedRequest},
                {"player.onTeamChange", DispatchPlayerOnTeamChangeRequest},
                {"player.onSquadChange", DispatchPlayerOnSquadChangeRequest},
                {"player.onSpawn", DispatchPlayerOnSpawnRequest},
                {"server.onLoadingLevel", DispatchServerOnLoadingLevelRequest},
                {"server.onLevelStarted", DispatchServerOnLevelStartedRequest},
                {"server.onLevelLoaded", DispatchServerOnLevelLoadedRequest},
                {"server.onRoundOver", DispatchServerOnRoundOverRequest},
                {"server.onRoundOverPlayers", DispatchServerOnRoundOverPlayersRequest},
                {"server.onRoundOverTeamScores", DispatchServerOnRoundOverTeamScoresRequest},
                {"punkBuster.onMessage", DispatchPunkBusterOnMessageRequest},
            };

            GetPacketsPattern = new Regex(@"^punkBuster\.pb_sv_command|^version|^help|^serverInfo|^admin\.listPlayers|^listPlayers|^admin\.supportMaps|^admin\.getPlaylists|^admin\.currentLevel|^mapList\.nextLevelIndex|^mapList\.list|^textChatModerationList\.list|^banList\.list|^levelVars\.list|^levelVars\.evaluate|^levelVars\.get|^vars\.[a-zA-Z]*?$");
        }
Exemplo n.º 2
0
        private void AssignEventHandlers() {
            if (Game != null) {
                Game.Login += new FrostbiteClient.EmptyParamterHandler(Game_Login);
                Game.LoginFailure += new FrostbiteClient.AuthenticationFailureHandler(Game_LoginFailure);
                Game.Logout += new FrostbiteClient.EmptyParamterHandler(Game_Logout);

                Game.ListPlayers += OnListPlayers;
                Game.PlayerLeft += OnPlayerLeft;
                Game.PunkbusterMessage += OnPunkbusterMessage;

                // this.Game.ServerInfo += this.OnServerInfo;

                Game.BanListList += new FrostbiteClient.BanListListHandler(PRoConClient_BanListList);
                Game.TextChatModerationListAddPlayer += new FrostbiteClient.TextChatModerationListAddPlayerHandler(Game_TextChatModerationListAddPlayer);
                Game.TextChatModerationListRemovePlayer += new FrostbiteClient.TextChatModerationListRemovePlayerHandler(Game_TextChatModerationListRemovePlayer);
                Game.TextChatModerationListClear += new FrostbiteClient.EmptyParamterHandler(Game_TextChatModerationListClear);
                Game.TextChatModerationListList += new FrostbiteClient.TextChatModerationListListHandler(Game_TextChatModerationListList);
                Game.PlayerLimit += OnPlayerLimit;

                Game.ReservedSlotsList += new FrostbiteClient.ReservedSlotsListHandler(PRoConClient_ReservedSlotsList);
                Game.ReservedSlotsPlayerAdded += new FrostbiteClient.ReservedSlotsPlayerHandler(PRoConClient_ReservedSlotsPlayerAdded);
                Game.ReservedSlotsPlayerRemoved += new FrostbiteClient.ReservedSlotsPlayerHandler(PRoConClient_ReservedSlotsPlayerRemoved);

                Game.ResponseError += new FrostbiteClient.ResponseErrorHandler(PRoConClient_ResponseError);

                PluginsCompiled += new EmptyParamterHandler(ProConClient_PluginsCompiled);

                Game.PlayerSpawned += new FrostbiteClient.PlayerSpawnedHandler(PRoConClient_PlayerSpawned);
                Game.PlayerKilled += new FrostbiteClient.PlayerKilledHandler(PRoConClient_PlayerKilled);
            }
        }