add safety for erroneous AC commands from clients
This commit is contained in:
+4
-2
@@ -58,10 +58,12 @@ struct Client {
|
|||||||
DCV1 = 0x0010,
|
DCV1 = 0x0010,
|
||||||
// Client is loading into a game
|
// Client is loading into a game
|
||||||
LOADING = 0x0020,
|
LOADING = 0x0020,
|
||||||
|
// Client is loading a quest
|
||||||
|
LOADING_QUEST = 0x0040,
|
||||||
// Client is in the information menu (login server only)
|
// Client is in the information menu (login server only)
|
||||||
IN_INFORMATION_MENU = 0x0040,
|
IN_INFORMATION_MENU = 0x0080,
|
||||||
// Client is at the welcome message (login server only)
|
// Client is at the welcome message (login server only)
|
||||||
AT_WELCOME_MESSAGE = 0x0080,
|
AT_WELCOME_MESSAGE = 0x0100,
|
||||||
|
|
||||||
// Note: There isn't a good way to detect Episode 3 until the player data is
|
// Note: There isn't a good way to detect Episode 3 until the player data is
|
||||||
// sent (via a 61 command), so the IS_EPISODE_3 flag is set in that handler
|
// sent (via a 61 command), so the IS_EPISODE_3 flag is set in that handler
|
||||||
|
|||||||
+1
-1
@@ -41,7 +41,7 @@ bool Lobby::any_client_loading() const {
|
|||||||
if (!this->clients[x].get()) {
|
if (!this->clients[x].get()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (this->clients[x]->flags & Client::Flag::LOADING) {
|
if (this->clients[x]->flags & (Client::Flag::LOADING | Client::Flag::LOADING_QUEST)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -894,7 +894,7 @@ void process_menu_selection(shared_ptr<ServerState> s, shared_ptr<Client> c,
|
|||||||
send_quest_file(l->clients[x], bin_basename, *bin_contents, false, false);
|
send_quest_file(l->clients[x], bin_basename, *bin_contents, false, false);
|
||||||
send_quest_file(l->clients[x], dat_basename, *dat_contents, false, false);
|
send_quest_file(l->clients[x], dat_basename, *dat_contents, false, false);
|
||||||
|
|
||||||
l->clients[x]->flags |= Client::Flag::LOADING;
|
l->clients[x]->flags |= Client::Flag::LOADING_QUEST;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -1012,7 +1012,13 @@ void process_quest_ready(shared_ptr<ServerState> s, shared_ptr<Client> c,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
c->flags &= ~Client::Flag::LOADING;
|
// If this client is NOT loading, they should not send an AC. Sending an AC to
|
||||||
|
// a client that isn't waiting to start a quest will crash the client, so we
|
||||||
|
// have to be careful not to do so.
|
||||||
|
if (!(c->flags & Client::Flag::LOADING_QUEST)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
c->flags &= ~Client::Flag::LOADING_QUEST;
|
||||||
|
|
||||||
// check if any client is still loading
|
// check if any client is still loading
|
||||||
// TODO: we need to handle clients disconnecting while loading. probably
|
// TODO: we need to handle clients disconnecting while loading. probably
|
||||||
@@ -1022,7 +1028,7 @@ void process_quest_ready(shared_ptr<ServerState> s, shared_ptr<Client> c,
|
|||||||
if (!l->clients[x]) {
|
if (!l->clients[x]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (l->clients[x]->flags & Client::Flag::LOADING) {
|
if (l->clients[x]->flags & Client::Flag::LOADING_QUEST) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user