don't send spectator commands during loading
This commit is contained in:
@@ -199,7 +199,7 @@ void Server::send(const void* data, size_t size) const {
|
|||||||
|
|
||||||
send_command(l, 0xC9, 0x00, data, size);
|
send_command(l, 0xC9, 0x00, data, size);
|
||||||
for (auto watcher_l : l->watcher_lobbies) {
|
for (auto watcher_l : l->watcher_lobbies) {
|
||||||
send_command(watcher_l, 0xC9, 0x00, data, size);
|
send_command_if_not_loading(watcher_l, 0xC9, 0x00, data, size);
|
||||||
}
|
}
|
||||||
if (l->battle_record && l->battle_record->writable()) {
|
if (l->battle_record && l->battle_record->writable()) {
|
||||||
l->battle_record->add_command(
|
l->battle_record->add_command(
|
||||||
@@ -2120,7 +2120,7 @@ void Server::handle_6xB3x40_map_list_request(const string& data) {
|
|||||||
w.write(list_data);
|
w.write(list_data);
|
||||||
send_command(l, 0x6C, 0x00, w.str());
|
send_command(l, 0x6C, 0x00, w.str());
|
||||||
for (auto watcher_l : l->watcher_lobbies) {
|
for (auto watcher_l : l->watcher_lobbies) {
|
||||||
send_command(watcher_l, 0x6C, 0x00, w.str());
|
send_command_if_not_loading(watcher_l, 0x6C, 0x00, w.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (l->battle_record && l->battle_record->writable()) {
|
if (l->battle_record && l->battle_record->writable()) {
|
||||||
@@ -2144,7 +2144,7 @@ void Server::handle_6xB3x41_map_request(const string& data) {
|
|||||||
auto out_cmd = this->prepare_6xB6x41_map_definition(base->last_chosen_map);
|
auto out_cmd = this->prepare_6xB6x41_map_definition(base->last_chosen_map);
|
||||||
send_command(l, 0x6C, 0x00, out_cmd);
|
send_command(l, 0x6C, 0x00, out_cmd);
|
||||||
for (auto watcher_l : l->watcher_lobbies) {
|
for (auto watcher_l : l->watcher_lobbies) {
|
||||||
send_command(watcher_l, 0x6C, 0x00, out_cmd);
|
send_command_if_not_loading(watcher_l, 0x6C, 0x00, out_cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (l->battle_record && l->battle_record->writable()) {
|
if (l->battle_record && l->battle_record->writable()) {
|
||||||
|
|||||||
@@ -76,6 +76,16 @@ void send_command_excluding_client(shared_ptr<Lobby> l, shared_ptr<Client> c,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void send_command_if_not_loading(shared_ptr<Lobby> l,
|
||||||
|
uint16_t command, uint32_t flag, const void* data, size_t size) {
|
||||||
|
for (auto& client : l->clients) {
|
||||||
|
if (!client || (client->flags & Client::Flag::LOADING)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
send_command(client, command, flag, data, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void send_command(shared_ptr<Lobby> l, uint16_t command, uint32_t flag,
|
void send_command(shared_ptr<Lobby> l, uint16_t command, uint32_t flag,
|
||||||
const void* data, size_t size) {
|
const void* data, size_t size) {
|
||||||
send_command_excluding_client(l, nullptr, command, flag, data, size);
|
send_command_excluding_client(l, nullptr, command, flag, data, size);
|
||||||
|
|||||||
@@ -51,6 +51,18 @@ inline void send_command_excluding_client(std::shared_ptr<Lobby> l,
|
|||||||
send_command_excluding_client(l, c, command, flag, nullptr, 0);
|
send_command_excluding_client(l, c, command, flag, nullptr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void send_command_if_not_loading(std::shared_ptr<Lobby> l,
|
||||||
|
uint16_t command, uint32_t flag, const void* data, size_t size);
|
||||||
|
inline void send_command_if_not_loading(std::shared_ptr<Lobby> l,
|
||||||
|
uint16_t command, uint32_t flag, const string& data) {
|
||||||
|
send_command_if_not_loading(l, command, flag, data.data(), data.size());
|
||||||
|
}
|
||||||
|
template <typename StructT>
|
||||||
|
inline void send_command_if_not_loading(std::shared_ptr<Lobby> l,
|
||||||
|
uint16_t command, uint32_t flag, const StructT& data) {
|
||||||
|
send_command_if_not_loading(l, command, flag, &data, sizeof(data));
|
||||||
|
}
|
||||||
|
|
||||||
void send_command(std::shared_ptr<Lobby> l, uint16_t command, uint32_t flag,
|
void send_command(std::shared_ptr<Lobby> l, uint16_t command, uint32_t flag,
|
||||||
const void* data, size_t size);
|
const void* data, size_t size);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user