Exemplo n.º 1
0
        public Player(TcpClient client)
        {
            TcpClient = client;

            TcpClient.NoDelay = true;

            ProcessReceiveThread = new Thread(ProcessReceive);
            _receiveBuffer       = new Byte[TcpClient.ReceiveBufferSize];
            IpAddress            = ((IPEndPoint)TcpClient.Client.RemoteEndPoint).Address.ToString();

            Program.ServerForm.MainLog.WriteMessage(String.Format("Connection from {0}.", IpAddress), Color.Black);

            Disconnect       = false;
            DisconnectReason = Resources.Strings_Disconnect.LostConnection;

            Ping        = 0;
            Serial      = "Not_Found";
            LastArenaId = 255;

            Flags = PlayerFlag.None;
            PreferredArenaMode  = ArenaRuleset.ArenaMode.Normal;
            PreferredArenaRules = ArenaRuleset.ArenaRule.None;
            PreferredEventExp   = 0;

            _pingInterval   = new Interval(0, false);
            _pingTime       = 0;
            _pingSamples    = 0;
            PingInitialized = false;

            lock (PlayerManager.Players.SyncRoot)
            {
                PlayerId = PlayerManager.Players.AvailableId;

                if (PlayerId == 0)
                {
                    Network.Send(this, GamePacket.Outgoing.Login.Error(Subscription.ErrorType.ServerFull));
                    Network.Disconnect(this);
                    return;
                }

                PlayerManager.Players.Add(this);
            }

            ProcessReceiveThread.Start();
        }
Exemplo n.º 2
0
            public static Int64 Created(Int32 arenaId, Int32 tableId, Int32 creationTime, Int32 playerCount, Int32 highestPlayerCount, Int32 maxPlayers, Arena.State currentState, Arena.State endState, String shortName, String longName, Int32 founderCharId, Int32 duration, Int32 levelRange, ArenaRuleset.ArenaMode mode, ArenaRuleset.ArenaRule rules)
            {
                try
                {
                    using (MySqlConnection sqlConnection = new MySqlConnection(ConnectionString))
                    {
                        sqlConnection.Open();

                        if (sqlConnection.State == ConnectionState.Open)
                        {
                            MySqlCommand sqlCommand = new MySqlCommand
                            {
                                Connection  = sqlConnection,
                                CommandText = Resources.Strings_MySQL.NonQuery_Insert_Matches_New
                            };

                            sqlCommand.Parameters.AddWithValue("@arenaid", arenaId);
                            sqlCommand.Parameters.AddWithValue("@tableid", tableId);
                            sqlCommand.Parameters.AddWithValue("@creation_time", creationTime);
                            sqlCommand.Parameters.AddWithValue("@player_count", playerCount);
                            sqlCommand.Parameters.AddWithValue("@highest_player_count", highestPlayerCount);
                            sqlCommand.Parameters.AddWithValue("@max_players", maxPlayers);
                            sqlCommand.Parameters.AddWithValue("@current_state", (Int32)currentState);
                            sqlCommand.Parameters.AddWithValue("@end_state", (Int32)endState);
                            sqlCommand.Parameters.AddWithValue("@short_name", shortName);
                            sqlCommand.Parameters.AddWithValue("@long_name", longName);
                            sqlCommand.Parameters.AddWithValue("@founder_charid", founderCharId);
                            sqlCommand.Parameters.AddWithValue("@duration", duration);
                            sqlCommand.Parameters.AddWithValue("@level_range", levelRange);
                            sqlCommand.Parameters.AddWithValue("@mode", (Int32)mode);
                            sqlCommand.Parameters.AddWithValue("@rules", (Int32)rules);

                            Int64 sqlResult = sqlCommand.ExecuteNonQuery();

                            if (sqlResult >= 1)
                            {
                                return(sqlCommand.LastInsertedId);
                            }
                            return(0);
                        }

                        throw new Exception(Resources.Strings_MySQL.Error_Connecting);
                    }
                }
                catch (Exception ex)
                {
                    Program.ServerForm.MainLog.WriteMessage(ex.Message, Color.Red);
                }

                return(0);
            }