Exemple #1
0
        private void ServerStatusResponse(NetAddress address, Message msg)
        {
            var infoString = new InfoString(msg.ReadStringLineAsString());

            if (this.globalServers.ContainsKey(address))
            {
                var serverInfo = this.globalServers[address];
                if (infoString["version"].Contains("v1.03"))
                {
                    serverInfo.Version = ClientVersion.JO_v1_03;
                }
                this.serverRefreshTimeout = Common.Milliseconds + ServerBrowser.RefreshTimeout;
            }
        }
Exemple #2
0
 internal void SetConfigstringInfo(InfoString info)
 {
     if (info.Count <= 0)
     {
         return;
     }
     this.Protocol   = (ProtocolVersion)info["protocol"].Atoi();
     this.HostName   = info["sv_hostname"];
     this.MapName    = info["mapname"];
     this.MaxClients = info["sv_maxclients"].Atoi();
     this.MinPing    = info["sv_minping"].Atoi();
     this.MaxPing    = info["sv_maxping"].Atoi();
     this.InfoSet    = true;
 }
Exemple #3
0
        private void ServerInfoPacket(NetAddress address, Message msg)
        {
            var infoString = new InfoString(msg.ReadStringAsString());

            if (this.globalServers.ContainsKey(address))
            {
                var serverInfo = this.globalServers[address];
                if (serverInfo.InfoSet)
                {
                    return;
                }
                serverInfo.Ping = (int)(Common.Milliseconds - serverInfo.Start);
                serverInfo.SetInfo(infoString);
                if (serverInfo.Protocol == ProtocolVersion.Protocol15)
                {
                    this.OutOfBandPrint(serverInfo.Address, "getstatus");
                }
                this.serverRefreshTimeout = Common.Milliseconds + ServerBrowser.RefreshTimeout;
            }
        }
Exemple #4
0
        public virtual void HandleInfoPacket(ServerInfo serverInfo, InfoString info)
        {
            switch (serverInfo.Protocol)
            {
            case ProtocolVersion.Protocol25:
                serverInfo.Version = ClientVersion.JA_v1_00;
                break;

            case ProtocolVersion.Protocol26:
                serverInfo.Version = ClientVersion.JA_v1_01;
                break;
            }
            if (info.Count <= 0)
            {
                return;
            }
            serverInfo.GameType      = (GameType)info["gametype"].Atoi();
            serverInfo.NeedPassword  = info["needpass"].Atoi() != 0;
            serverInfo.TrueJedi      = info["truejedi"].Atoi() != 0;
            serverInfo.WeaponDisable = info["wdisable"].Atoi() != 0;
            serverInfo.ForceDisable  = info["fdisable"].Atoi() != 0;
        }
Exemple #5
0
        private unsafe void ParseGamestate(Message msg)
        {
            this.connectPacketCount = 0;
            this.ClearState();
            this.serverCommandSequence = msg.ReadLong();
            this.gameState.DataCount   = 1;
            ServerCommandOperation cmd;

            while (true)
            {
                cmd = (ServerCommandOperation)msg.ReadByte();
                //JO doesn't have setgame command, the rest commands match
                if (this.IsJO() && cmd >= ServerCommandOperation.SetGame)
                {
                    cmd++;
                }
                if (cmd == ServerCommandOperation.EOF)
                {
                    break;
                }
                else if (cmd == ServerCommandOperation.Configstring)
                {
                    int i = msg.ReadShort();
                    if (i < 0 || i > GameState.MaxConfigstrings)
                    {
                        throw new JKClientException("configstring > MaxConfigStrings");
                    }
                    sbyte [] s   = msg.ReadBigString();
                    int      len = Common.StrLen(s);
                    if (len + 1 + this.gameState.DataCount > GameState.MaxGameStateChars)
                    {
                        throw new JKClientException("MaxGameStateChars exceeded");
                    }
                    if (i == GameState.ServerInfo)
                    {
                        string serverInfoCSStr = Common.ToString(s);
                        var    infoString      = new InfoString(serverInfoCSStr);
                        if (this.Protocol == ProtocolVersion.Protocol15 && infoString["version"].Contains("v1.03"))
                        {
                            this.Version = ClientVersion.JO_v1_03;
                        }
                        string gamename = infoString["gamename"];
                        if (gamename.Contains("Szlakiem Jedi RPE") ||
                            gamename.Contains("Open Jedi Project") ||
                            gamename.Contains("OJP Enhanced") ||
                            gamename.Contains("OJP Basic") ||
                            gamename.Contains("OJRP"))
                        {
                            this.gameMod = GameMod.OJP;
                        }
                        else if (gamename.Contains("Movie Battles II"))
                        {
                            this.gameMod = GameMod.MBII;
                        }
                        else
                        {
                            this.gameMod = GameMod.Base;
                        }
                    }
                    this.gameState.StringOffsets[i] = this.gameState.DataCount;
                    fixed(sbyte *stringData = this.gameState.StringData)
                    {
                        Marshal.Copy((byte[])(Array)s, 0, (IntPtr)(stringData + this.gameState.DataCount), len + 1);
                    }

                    this.gameState.DataCount += len + 1;
                }
                else if (cmd == ServerCommandOperation.Baseline)
                {
                    int newnum = msg.ReadBits(Common.GEntitynumBits);
                    if (newnum < 0 || newnum >= Common.MaxGEntities)
                    {
                        throw new JKClientException($"Baseline number out of range: {newnum}");
                    }

                    fixed(EntityState *nes = &EntityState.Null)
                    {
                        fixed(EntityState *bl = &this.entityBaselines[newnum])
                        {
                            msg.ReadDeltaEntity(nes, bl, newnum, this.Version, this.gameMod);
                        }
                    }
                }
                else
                {
                    throw new JKClientException("ParseGamestate: bad command byte");
                }
            }
            this.ServerInfoChangedCallback?.Invoke(this.ServerInfo);
            this.clientNum    = msg.ReadLong();
            this.checksumFeed = msg.ReadLong();
            if (!this.IsJO())
            {
                this.ParseRMG(msg);
            }
            this.SystemInfoChanged();
            this.InitCGame();
        }
Exemple #6
0
 public virtual void HandleStatusResponse(ServerInfo serverInfo, InfoString info)
 {
 }
Exemple #7
0
 public virtual void SetExtraConfigstringInfo(ServerInfo serverInfo, InfoString info)
 {
     switch (serverInfo.Protocol)
     {
     case ProtocolVersion.Protocol15 when info["version"].Contains("v1.03"):