@@ -39,7 +39,6 @@ void send_auth_challenge(ClientContext& ctx);
3939void send_auth_result (ClientContext& ctx, protocol::Result result);
4040void handle_authentication (ClientContext& ctx);
4141void handle_queue_update (ClientContext& ctx, const QueuePosition& event);
42- void handle_queue_success (ClientContext& ctx);
4342void auth_success (ClientContext& ctx);
4443void auth_queue (ClientContext& ctx);
4544void prove_session (ClientContext& ctx, const Botan::BigInt& key);
@@ -197,18 +196,13 @@ void prove_session(ClientContext& ctx, const Botan::BigInt& key) {
197196 .username = auth_ctx.packet ->username
198197 };
199198
200- // todo, allowing for multiple realms to connect to a single world server
201- // will require an external service to keep track of available slots
202- unsigned int active_players = 0 ;
203- const auto & config = ctx.cfg_store .config_tls ();
204-
205- if (active_players < config.max_slots ) {
199+ ctx.cancel_timer ();
200+
201+ if (ctx.queue .enqueue (ctx.handler ().uuid (), 0 ) == RealmQueue::Result::success) {
206202 auth_success (ctx);
207203 } else {
208- auth_queue (ctx);
204+ auth_state (ctx, State::in_queue );
209205 }
210-
211- ++active_players;
212206}
213207
214208void send_auth_challenge (ClientContext& ctx) {
@@ -248,26 +242,14 @@ void send_addon_data(ClientContext& ctx) {
248242 ctx.send (response);
249243}
250244
251- void auth_queue (ClientContext& ctx) {
252- LOG_TRACE (ctx.logger , log_func);
253-
254- const auto & uuid = ctx.handler ().uuid ();
255- auto & dispatcher = ctx.dispatcher ;
256-
257- ctx.queue .enqueue (uuid);
258- ctx.cancel_timer ();
259- auth_state (ctx, State::in_queue);
260-
261- CLIENT_DEBUG (ctx, " Added to queue, position {}" , ctx.queue .poll (uuid));
262- }
263-
264245void auth_success (ClientContext& ctx) {
265246 LOG_TRACE (ctx.logger , log_func);
266247
267248 send_auth_result (ctx, protocol::Result::auth_ok);
268249 send_addon_data (ctx);
269250 auth_state (ctx, State::success);
270251 ctx.state_update (ClientState::cs_character_list);
252+ ctx.set_active ();
271253
272254 CLIENT_DEBUG (ctx, " Authenticated as {}" , ctx.account ->username );
273255}
@@ -333,7 +315,7 @@ void handle_event(ClientContext& ctx, const Event& event) {
333315 handle_queue_update (ctx, event.as <QueuePosition>());
334316 break ;
335317 case queue_success:
336- handle_queue_success (ctx);
318+ auth_success (ctx);
337319 break ;
338320 default :
339321 break ;
0 commit comments