Esempio n. 1
0
 protected override void DispatchPlayerOnSpawnRequest(FrostbiteConnection sender, Packet cpRequestPacket) {
     if (cpRequestPacket.Words.Count >= 9) {
         if (this.PlayerSpawned != null) {
             FrostbiteConnection.RaiseEvent(this.PlayerSpawned.GetInvocationList(), this, cpRequestPacket.Words[1], cpRequestPacket.Words[2], cpRequestPacket.Words.GetRange(3, 3), cpRequestPacket.Words.GetRange(6, 3)); // new Inventory(cpRequestPacket.Words[3], cpRequestPacket.Words[4], cpRequestPacket.Words[5], cpRequestPacket.Words[6], cpRequestPacket.Words[7], cpRequestPacket.Words[8]));
         }
     }
 }
Esempio n. 2
0
        protected virtual void DispatchVarsRoundStartReadyPlayersNeeded(FrostbiteConnection sender, Packet cpRecievedPacket, Packet cpRequestPacket) {
            if (cpRequestPacket.Words.Count >= 1) {
                var handler = this.RoundStartReadyPlayersNeeded;

                if (handler != null) {
                    if (cpRecievedPacket.Words.Count == 2) {
                        handler(this, Convert.ToInt32(cpRecievedPacket.Words[1]));
                    }
                    else if (cpRequestPacket.Words.Count >= 2) {
                        handler(this, Convert.ToInt32(cpRequestPacket.Words[1]));
                    }
                }
            }
        }
        public void SendAsync(Packet cpPacket) {
            try {
                byte[] a_bBytePacket = cpPacket.EncodePacket();

                this.m_tcpStream.BeginWrite(a_bBytePacket, 0, a_bBytePacket.Length, this.SendAsyncCallback, cpPacket);

            }
            catch (SocketException) {
                // TO DO: Error reporting, possibly in a log file.
                this.Shutdown();
            }
            catch (Exception) {
                this.Shutdown();
            }
        }
Esempio n. 4
0
 // Events
 public virtual void DispatchRequestPacket(FrostbiteConnection sender, Packet cpRequestPacket) {
     if (cpRequestPacket.Words.Count >= 1) {
         if (RequestDelegates.ContainsKey(cpRequestPacket.Words[0]) == true) {
             RequestDelegates[cpRequestPacket.Words[0]](sender, cpRequestPacket);
         }
     }
 }
Esempio n. 5
0
 protected virtual void DispatchServerOnRoundOverTeamScoresRequest(FrostbiteConnection sender, Packet cpRequestPacket) {
     if (cpRequestPacket.Words.Count >= 2) {
         cpRequestPacket.Words.RemoveAt(0);
         if (RoundOverTeamScores != null) {
             this.RoundOverTeamScores(this, TeamScore.GetTeamScores(cpRequestPacket.Words));
         }
     }
 }
Esempio n. 6
0
        protected virtual void DispatchServerOnRoundOverRequest(FrostbiteConnection sender, Packet cpRequestPacket) {
            if (cpRequestPacket.Words.Count >= 2) {
                int iTeamID = 0;

                if (int.TryParse(cpRequestPacket.Words[1], out iTeamID) == true) {
                    if (RoundOver != null) {
                        this.RoundOver(this, iTeamID);
                    }
                }
            }
        }
Esempio n. 7
0
        protected virtual void DispatchServerOnLevelLoadedRequest(FrostbiteConnection sender, Packet cpRequestPacket) {
            if (cpRequestPacket.Words.Count >= 5) {
                if (LevelLoaded != null) {
                    int iRoundsPlayed = 0, iRoundsTotal = 0;

                    if (int.TryParse(cpRequestPacket.Words[3], out iRoundsPlayed) == true && int.TryParse(cpRequestPacket.Words[4], out iRoundsTotal) == true) {
                        this.LevelLoaded(this, cpRequestPacket.Words[1], cpRequestPacket.Words[2], iRoundsPlayed, iRoundsTotal);
                    }
                }
            }
        }
Esempio n. 8
0
        protected virtual void DispatchPlayerOnSquadChangeRequest(FrostbiteConnection sender, Packet cpRequestPacket) {
            if (cpRequestPacket.Words.Count >= 4) {
                int iTeamID = 0, iSquadID = 0;

                if (int.TryParse(cpRequestPacket.Words[2], out iTeamID) == true && int.TryParse(cpRequestPacket.Words[3], out iSquadID) == true) {
                    if (PlayerChangedSquad != null) {
                        this.PlayerChangedSquad(this, cpRequestPacket.Words[1], iTeamID, iSquadID);
                    }
                }
            }
        }
Esempio n. 9
0
 protected virtual void DispatchPlayerOnKickedRequest(FrostbiteConnection sender, Packet cpRequestPacket) {
     if (cpRequestPacket.Words.Count >= 3) {
         if (PlayerKicked != null) {
             this.PlayerKicked(this, cpRequestPacket.Words[1], cpRequestPacket.Words[2]);
         }
     }
 }
Esempio n. 10
0
        protected virtual void DispatchLevelVarsEvaluateResponse(FrostbiteConnection sender, Packet cpRecievedPacket, Packet cpRequestPacket) {
            if (cpRecievedPacket.Words.Count >= 2 && cpRequestPacket.Words.Count >= 2) {
                var request = new LevelVariable(new LevelVariableContext(String.Empty, String.Empty), cpRequestPacket.Words[1], cpRecievedPacket.Words[1]);

                if (LevelVariablesEvaluate != null) {
                    this.LevelVariablesEvaluate(this, request, null);
                }
            }
        }
Esempio n. 11
0
        protected virtual void DispatchLevelVarsGetResponse(FrostbiteConnection sender, Packet cpRecievedPacket, Packet cpRequestPacket) {
            if (cpRecievedPacket.Words.Count >= 2 && cpRequestPacket.Words.Count >= 2) {
                LevelVariable request = LevelVariable.ExtractContextVariable(false, cpRequestPacket.Words.GetRange(1, cpRequestPacket.Words.Count - 1));

                request.RawValue = cpRecievedPacket.Words[1];

                if (LevelVariablesGet != null) {
                    this.LevelVariablesGet(this, request, null);
                }
            }
        }
Esempio n. 12
0
 protected virtual void DispatchVarsTextChatModerationModeResponse(FrostbiteConnection sender, Packet cpRecievedPacket, Packet cpRequestPacket) {
     if (cpRequestPacket.Words.Count >= 1) {
         if (TextChatModerationMode != null) {
             if (cpRecievedPacket.Words.Count == 2) {
                 this.TextChatModerationMode(this, TextChatModerationEntry.GetServerModerationLevelType(cpRecievedPacket.Words[1]));
             }
             else if (cpRequestPacket.Words.Count >= 2) {
                 this.TextChatModerationMode(this, TextChatModerationEntry.GetServerModerationLevelType(cpRequestPacket.Words[1]));
             }
         }
     }
 }
Esempio n. 13
0
 protected virtual void DispatchVarsTextChatSpamCoolDownTimeResponse(FrostbiteConnection sender, Packet cpRecievedPacket, Packet cpRequestPacket) {
     if (cpRequestPacket.Words.Count >= 1) {
         if (TextChatSpamCoolDownTime != null) {
             if (cpRecievedPacket.Words.Count == 2) {
                 this.TextChatSpamCoolDownTime(this, Convert.ToInt32(cpRecievedPacket.Words[1]));
             }
             else if (cpRequestPacket.Words.Count >= 2) {
                 this.TextChatSpamCoolDownTime(this, Convert.ToInt32(cpRequestPacket.Words[1]));
             }
         }
     }
 }
Esempio n. 14
0
 protected virtual void DispatchVarsServerNameResponse(FrostbiteConnection sender, Packet cpRecievedPacket, Packet cpRequestPacket) {
     if (cpRequestPacket.Words.Count >= 1) {
         if (ServerName != null) {
             if (cpRecievedPacket.Words.Count == 2) {
                 this.ServerName(this, cpRecievedPacket.Words[1]);
             }
             else if (cpRequestPacket.Words.Count >= 2) {
                 this.ServerName(this, cpRequestPacket.Words[1]);
             }
         }
     }
 }
Esempio n. 15
0
 protected virtual void DispatchVarsProfanityFilterResponse(FrostbiteConnection sender, Packet cpRecievedPacket, Packet cpRequestPacket) {
     if (cpRequestPacket.Words.Count >= 1) {
         if (ProfanityFilter != null) {
             if (cpRecievedPacket.Words.Count == 2) {
                 this.ProfanityFilter(this, Convert.ToBoolean(cpRecievedPacket.Words[1]));
             }
             else if (cpRequestPacket.Words.Count >= 2) {
                 this.ProfanityFilter(this, Convert.ToBoolean(cpRequestPacket.Words[1]));
             }
         }
     }
 }
Esempio n. 16
0
        protected virtual void DispatchPlayerOnKillRequest(FrostbiteConnection sender, Packet cpRequestPacket) {
            if (cpRequestPacket.Words.Count >= 11) {
                if (PlayerKilled != null) {
                    bool headshot = false;

                    if (bool.TryParse(cpRequestPacket.Words[4], out headshot) == true) {
                        this.PlayerKilled(this, cpRequestPacket.Words[1], cpRequestPacket.Words[2], cpRequestPacket.Words[3], headshot, new Point3D(cpRequestPacket.Words[5], cpRequestPacket.Words[7], cpRequestPacket.Words[6]), new Point3D(cpRequestPacket.Words[8], cpRequestPacket.Words[10], cpRequestPacket.Words[9]));
                    }
                }
            }
        }
Esempio n. 17
0
        protected virtual void DispatchPlayerOnChatRequest(FrostbiteConnection sender, Packet cpRequestPacket) {
            if (cpRequestPacket.Words.Count >= 3) {
                int iTeamID = 0, iSquadID = 0;

                if (cpRequestPacket.Words.Count == 3) {
                    // < R9 Support.
                    if (GlobalChat != null) {
                        this.GlobalChat(this, cpRequestPacket.Words[1], cpRequestPacket.Words[2]);
                    }
                    if (TeamChat != null) {
                        this.TeamChat(this, cpRequestPacket.Words[1], cpRequestPacket.Words[2], 0);
                    }
                    if (SquadChat != null) {
                        this.SquadChat(this, cpRequestPacket.Words[1], cpRequestPacket.Words[2], 0, 0);
                    }
                }
                else if (cpRequestPacket.Words.Count == 4 && (String.Compare(cpRequestPacket.Words[3], "all", StringComparison.OrdinalIgnoreCase) == 0 || String.Compare(cpRequestPacket.Words[3], "unknown", StringComparison.OrdinalIgnoreCase) == 0)) {
                    // "unknown" because of BF4 beta
                    if (GlobalChat != null) {
                        this.GlobalChat(this, cpRequestPacket.Words[1], cpRequestPacket.Words[2]);
                    }
                }
                else if (cpRequestPacket.Words.Count >= 5 && String.Compare(cpRequestPacket.Words[3], "team", StringComparison.OrdinalIgnoreCase) == 0 && int.TryParse(cpRequestPacket.Words[4], out iTeamID) == true) {
                    if (this.TeamChat != null) {
                        this.TeamChat(this, cpRequestPacket.Words[1], cpRequestPacket.Words[2], iTeamID);
                    }
                }
                else if (cpRequestPacket.Words.Count >= 5 && String.Compare(cpRequestPacket.Words[3], "player", StringComparison.OrdinalIgnoreCase) == 0) {
                    if (this.PlayerChat != null) {
                        this.PlayerChat(this, cpRequestPacket.Words[1], cpRequestPacket.Words[2], cpRequestPacket.Words[4]);
                    }
                }
                else if (cpRequestPacket.Words.Count >= 6 && String.Compare(cpRequestPacket.Words[3], "squad", StringComparison.OrdinalIgnoreCase) == 0 && int.TryParse(cpRequestPacket.Words[4], out iTeamID) == true && int.TryParse(cpRequestPacket.Words[5], out iSquadID) == true) {
                    if (SquadChat != null) {
                        this.SquadChat(this, cpRequestPacket.Words[1], cpRequestPacket.Words[2], iTeamID, iSquadID);
                    }
                }

                cpRequestPacket.Words.RemoveAt(0);
                if (Chat != null) {
                    this.Chat(this, cpRequestPacket.Words);
                }
            }
        }
Esempio n. 18
0
        protected virtual void DispatchLevelVarsClearResponse(FrostbiteConnection sender, Packet cpRecievedPacket, Packet cpRequestPacket) {
            if (cpRequestPacket.Words.Count >= 2) {
                LevelVariable request = LevelVariable.ExtractContextVariable(false, cpRequestPacket.Words.GetRange(1, cpRequestPacket.Words.Count - 1));

                if (LevelVariablesClear != null) {
                    this.LevelVariablesClear(this, request);
                }
            }
        }
Esempio n. 19
0
        protected virtual void DispatchPlayerOnTeamChangeRequest(FrostbiteConnection sender, Packet cpRequestPacket) {
            if (cpRequestPacket.Words.Count >= 4) {
                int iTeamID = 0, iSquadID = 0;

                // TO DO: Specs say TeamId and SquadId which is a little odd..
                if (int.TryParse(cpRequestPacket.Words[2], out iTeamID) == true && int.TryParse(cpRequestPacket.Words[3], out iSquadID) == true) {
                    if (PlayerChangedTeam != null) {
                        this.PlayerChangedTeam(this, cpRequestPacket.Words[1], iTeamID, iSquadID);
                    }
                }
            }
        }
Esempio n. 20
0
        protected virtual void DispatchLevelVarsListResponse(FrostbiteConnection sender, Packet cpRecievedPacket, Packet cpRequestPacket) {
            if (cpRecievedPacket.Words.Count >= 2 && cpRequestPacket.Words.Count >= 2) {
                LevelVariable varRequestContext = LevelVariable.ExtractContextVariable(false, cpRequestPacket.Words.GetRange(1, cpRequestPacket.Words.Count - 1));

                var lstVariables = new List<LevelVariable>();

                int iMatchedVariables = 0;

                if (int.TryParse(cpRecievedPacket.Words[1], out iMatchedVariables) == true) {
                    for (int i = 0; i < iMatchedVariables && ((i + 1) * 4 + 2) <= cpRecievedPacket.Words.Count; i++) {
                        lstVariables.Add(LevelVariable.ExtractContextVariable(true, cpRecievedPacket.Words.GetRange(i * 4 + 2, 4)));
                    }

                    if (LevelVariablesList != null) {
                        this.LevelVariablesList(this, varRequestContext, lstVariables);
                    }
                }
            }
        }
Esempio n. 21
0
 protected virtual void DispatchPlayerOnSpawnRequest(FrostbiteConnection sender, Packet cpRequestPacket) {
     if (cpRequestPacket.Words.Count >= 9) {
         if (PlayerSpawned != null) {
             this.PlayerSpawned(this, cpRequestPacket.Words[1], cpRequestPacket.Words[2], cpRequestPacket.Words.GetRange(3, 3), cpRequestPacket.Words.GetRange(6, 3)); // new Inventory(cpRequestPacket.Words[3], cpRequestPacket.Words[4], cpRequestPacket.Words[5], cpRequestPacket.Words[6], cpRequestPacket.Words[7], cpRequestPacket.Words[8]));
         }
     }
 }
Esempio n. 22
0
        protected virtual void DispatchAdminMovePlayerResponse(FrostbiteConnection sender, Packet cpRecievedPacket, Packet cpRequestPacket) {
            if (PlayerMovedByAdmin != null) {
                if (cpRequestPacket.Words.Count >= 5) {
                    int desinationTeamId;
                    int destinationSquadId;
                    bool forceKilled;

                    if (int.TryParse(cpRequestPacket.Words[2], out desinationTeamId) == true && int.TryParse(cpRequestPacket.Words[3], out destinationSquadId) == true && bool.TryParse(cpRequestPacket.Words[4], out forceKilled) == true) {
                        this.PlayerMovedByAdmin(this, cpRequestPacket.Words[1], desinationTeamId, destinationSquadId, forceKilled);
                    }
                }
            }
        }
Esempio n. 23
0
 protected virtual void DispatchServerOnLevelStartedRequest(FrostbiteConnection sender, Packet cpRequestPacket) {
     if (cpRequestPacket.Words.Count >= 1) {
         if (LevelStarted != null) {
             this.LevelStarted(this);
         }
     }
 }
Esempio n. 24
0
 protected virtual void DispatchAdminKillPlayerResponse(FrostbiteConnection sender, Packet cpRecievedPacket, Packet cpRequestPacket) {
     if (PlayerKilledByAdmin != null) {
         if (cpRequestPacket.Words.Count >= 2) {
             this.PlayerKilledByAdmin(this, cpRequestPacket.Words[1]);
         }
     }
 }
Esempio n. 25
0
 protected virtual void DispatchServerOnRoundOverPlayersRequest(FrostbiteConnection sender, Packet cpRequestPacket) {
     if (cpRequestPacket.Words.Count >= 2) {
         cpRequestPacket.Words.RemoveAt(0);
         if (RoundOverPlayers != null) {
             this.RoundOverPlayers(this, CPlayerInfo.GetPlayerList(cpRequestPacket.Words));
         }
     }
 }
Esempio n. 26
0
        // Command
        public virtual void DispatchResponsePacket(FrostbiteConnection sender, Packet cpRecievedPacket, Packet cpRequestPacket) {
            if (cpRecievedPacket.Words.Count >= 1 && String.Compare(cpRecievedPacket.Words[0], "OK", StringComparison.OrdinalIgnoreCase) == 0) {
                if (ResponseDelegates.ContainsKey(cpRequestPacket.Words[0]) == true) {
                    ResponseDelegates[cpRequestPacket.Words[0]](sender, cpRecievedPacket, cpRequestPacket);
                }
            }
            else if (cpRecievedPacket.Words.Count >= 1 && (String.Compare(cpRecievedPacket.Words[0], "InvalidPassword", StringComparison.OrdinalIgnoreCase) == 0 || String.Compare(cpRecievedPacket.Words[0], "InvalidPasswordHash", StringComparison.OrdinalIgnoreCase) == 0) && cpRequestPacket.Words.Count >= 1 && (String.Compare(cpRequestPacket.Words[0], "login.hashed", StringComparison.OrdinalIgnoreCase) == 0 || String.Compare(cpRequestPacket.Words[0], "login.plaintext", StringComparison.OrdinalIgnoreCase) == 0)) {
                IsLoggedIn = false;

                if (LoginFailure != null) {
                    this.LoginFailure(this, cpRecievedPacket.Words[0]);
                }

                Shutdown();
            }
            else if (cpRecievedPacket.Words.Count >= 3 && String.Compare(cpRecievedPacket.Words[0], "ScriptError", StringComparison.OrdinalIgnoreCase) == 0 && cpRequestPacket.Words.Count >= 2) {
                if (RunScriptError != null) {
                    this.RunScriptError(this, "", Convert.ToInt32(cpRecievedPacket.Words[1]), cpRecievedPacket.Words[2]);
                }
            }
            else if (cpRecievedPacket.Words.Count == 1 && String.Compare(cpRecievedPacket.Words[0], "ExecutedOnNextRound", StringComparison.OrdinalIgnoreCase) == 0) {
                if (ResponseDelegates.ContainsKey(cpRequestPacket.Words[0]) == true) {
                    ResponseDelegates[cpRequestPacket.Words[0]](sender, cpRecievedPacket, cpRequestPacket);
                }
            }
            // Else it is an error..
            else
            {
                // InvalidArguments
                // TooLongMessage
                // InvalidDuration
                // InvalidFileName
                // InvalidLevelName
                // More...
                if (ResponseError != null)
                {
                    this.ResponseError(this, cpRequestPacket, cpRecievedPacket.Words[0]);
                }
            }
        }
Esempio n. 27
0
 protected virtual void DispatchPunkBusterOnMessageRequest(FrostbiteConnection sender, Packet cpRequestPacket) {
     if (cpRequestPacket.Words.Count >= 2) {
         if (PunkbusterMessage != null) {
             this.PunkbusterMessage(this, cpRequestPacket.Words[1]);
         }
     }
 }
Esempio n. 28
0
 protected virtual void DispatchPlayerOnJoinRequest(FrostbiteConnection sender, Packet cpRequestPacket) {
     if (cpRequestPacket.Words.Count >= 2) {
         if (PlayerJoin != null && cpRequestPacket.Words[1].Length > 0) {
             this.PlayerJoin(this, cpRequestPacket.Words[1]);
         }
     }
 }
Esempio n. 29
0
 private void m_prcClient_ResponseError(FrostbiteClient sender, Packet originalRequest, string errorMessage) {
     InvokeOnAllEnabled("OnResponseError", new List<string>(originalRequest.Words), errorMessage);
 }
Esempio n. 30
0
        protected virtual void DispatchPlayerOnLeaveRequest(FrostbiteConnection sender, Packet cpRequestPacket) {
            // Backwards compatability
            //else if (cpRequestPacket.Words.Count == 2 && String.Compare(cpRequestPacket.Words[0], "player.onLeave", true) == 0) {
            //    if (this.PlayerLeft != null) {
            //        this.PlayerLeft(this, cpRequestPacket.Words[1], null);
            //    }
            //}
            if (cpRequestPacket.Words.Count >= 3) {
                if (PlayerLeft != null) {
                    CPlayerInfo cpiPlayer = null;

                    List<CPlayerInfo> lstPlayers = CPlayerInfo.GetPlayerList(cpRequestPacket.Words.GetRange(2, cpRequestPacket.Words.Count - 2));

                    if (lstPlayers.Count > 0) {
                        cpiPlayer = lstPlayers[0];
                    }

                    this.PlayerLeft(this, cpRequestPacket.Words[1], cpiPlayer);
                }
            }
        }