make high client ID assignment optional
This commit is contained in:
@@ -142,6 +142,11 @@ static void command_arrow(shared_ptr<ServerState>, shared_ptr<Lobby> l,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void command_dbgid(shared_ptr<ServerState>, shared_ptr<Lobby>,
|
||||||
|
shared_ptr<Client> c, const std::u16string&) {
|
||||||
|
c->prefer_high_lobby_client_id = !c->prefer_high_lobby_client_id;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Lobby commands
|
// Lobby commands
|
||||||
|
|
||||||
@@ -692,6 +697,7 @@ static const unordered_map<u16string, ChatCommandDefinition> chat_commands({
|
|||||||
{u"$bbchar" , {command_convert_char_to_bb, u"Usage:\nbbchar <user> <pass> <1-4>"}},
|
{u"$bbchar" , {command_convert_char_to_bb, u"Usage:\nbbchar <user> <pass> <1-4>"}},
|
||||||
// {u"$bank", {command_bank , u"Usage:\nbank <bank name>"}},
|
// {u"$bank", {command_bank , u"Usage:\nbank <bank name>"}},
|
||||||
{u"$cheat" , {command_cheat , u"Usage:\ncheat"}},
|
{u"$cheat" , {command_cheat , u"Usage:\ncheat"}},
|
||||||
|
{u"$dbgid" , {command_dbgid , u"Usage:\ndngid"}},
|
||||||
{u"$edit" , {command_edit , u"Usage:\nedit <stat> <value>"}},
|
{u"$edit" , {command_edit , u"Usage:\nedit <stat> <value>"}},
|
||||||
{u"$event" , {command_lobby_event , u"Usage:\nevent <name>"}},
|
{u"$event" , {command_lobby_event , u"Usage:\nevent <name>"}},
|
||||||
{u"$infhp" , {command_infinite_hp , u"Usage:\ninfhp"}},
|
{u"$infhp" , {command_infinite_hp , u"Usage:\ninfhp"}},
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ Client::Client(
|
|||||||
lobby_id(0),
|
lobby_id(0),
|
||||||
lobby_client_id(0),
|
lobby_client_id(0),
|
||||||
lobby_arrow_color(0),
|
lobby_arrow_color(0),
|
||||||
|
prefer_high_lobby_client_id(false),
|
||||||
next_exp_value(0),
|
next_exp_value(0),
|
||||||
override_section_id(-1),
|
override_section_id(-1),
|
||||||
infinite_hp(false),
|
infinite_hp(false),
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ struct Client {
|
|||||||
uint32_t lobby_id; // which lobby is this person in?
|
uint32_t lobby_id; // which lobby is this person in?
|
||||||
uint8_t lobby_client_id; // which client number is this person?
|
uint8_t lobby_client_id; // which client number is this person?
|
||||||
uint8_t lobby_arrow_color; // lobby arrow color ID
|
uint8_t lobby_arrow_color; // lobby arrow color ID
|
||||||
|
bool prefer_high_lobby_client_id;
|
||||||
ClientGameData game_data;
|
ClientGameData game_data;
|
||||||
|
|
||||||
// Miscellaneous (used by chat commands)
|
// Miscellaneous (used by chat commands)
|
||||||
|
|||||||
+3
-3
@@ -57,9 +57,9 @@ size_t Lobby::count_clients() const {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lobby::add_client(shared_ptr<Client> c, bool reverse_indexes) {
|
void Lobby::add_client(shared_ptr<Client> c) {
|
||||||
ssize_t index;
|
ssize_t index;
|
||||||
if (reverse_indexes) {
|
if (c->prefer_high_lobby_client_id) {
|
||||||
for (index = max_clients - 1; index >= 0; index--) {
|
for (index = max_clients - 1; index >= 0; index--) {
|
||||||
if (!this->clients[index].get()) {
|
if (!this->clients[index].get()) {
|
||||||
this->clients[index] = c;
|
this->clients[index] = c;
|
||||||
@@ -85,7 +85,7 @@ void Lobby::add_client(shared_ptr<Client> c, bool reverse_indexes) {
|
|||||||
c->lobby_id = this->lobby_id;
|
c->lobby_id = this->lobby_id;
|
||||||
|
|
||||||
// If there's no one else in the lobby, set the leader id as well
|
// If there's no one else in the lobby, set the leader id as well
|
||||||
if (index == (max_clients - 1) * reverse_indexes) {
|
if (index == (max_clients - 1) * c->prefer_high_lobby_client_id) {
|
||||||
for (index = 0; index < max_clients; index++) {
|
for (index = 0; index < max_clients; index++) {
|
||||||
if (this->clients[index].get() && this->clients[index] != c) {
|
if (this->clients[index].get() && this->clients[index] != c) {
|
||||||
break;
|
break;
|
||||||
|
|||||||
+1
-1
@@ -80,7 +80,7 @@ struct Lobby {
|
|||||||
size_t count_clients() const;
|
size_t count_clients() const;
|
||||||
bool any_client_loading() const;
|
bool any_client_loading() const;
|
||||||
|
|
||||||
void add_client(std::shared_ptr<Client> c, bool reverse_indexes = true);
|
void add_client(std::shared_ptr<Client> c);
|
||||||
void remove_client(std::shared_ptr<Client> c);
|
void remove_client(std::shared_ptr<Client> c);
|
||||||
|
|
||||||
void move_client_to_lobby(std::shared_ptr<Lobby> dest_lobby,
|
void move_client_to_lobby(std::shared_ptr<Lobby> dest_lobby,
|
||||||
|
|||||||
Reference in New Issue
Block a user