mirror of
https://github.com/diamante0018/BlackOpsPlugin.git
synced 2025-04-22 11:05:43 +00:00
Improve some code here and there
This commit is contained in:
parent
e6be5e0427
commit
2735a0fdf9
@ -15,11 +15,11 @@ bool out_of_band_print_hk(game::netsrc_t src, game::netadr_s to,
|
||||
return game::NET_OutOfBandPrint(src, to, msg);
|
||||
}
|
||||
|
||||
const auto errorMsg =
|
||||
const auto error_msg =
|
||||
std::format("error\nPermanently banned\nDiscord: {}\nWebsite: {}",
|
||||
sv_discord->current.string, sv_clanWebsite->current.string);
|
||||
|
||||
return game::NET_OutOfBandPrint(src, to, errorMsg.data());
|
||||
return game::NET_OutOfBandPrint(src, to, error_msg.data());
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
@ -23,7 +23,7 @@ void load_bot_data() {
|
||||
}
|
||||
|
||||
rapidjson::Document obj;
|
||||
rapidjson::ParseResult result =
|
||||
const rapidjson::ParseResult result =
|
||||
obj.Parse(utils::io::read_file("bots/bots.json").data());
|
||||
|
||||
if (!result || !obj.IsObject()) {
|
||||
@ -46,8 +46,8 @@ const char* sv_bot_name_random_stub() {
|
||||
load_bot_data();
|
||||
}
|
||||
|
||||
static auto bot_id = 0;
|
||||
if (!bot_names.empty()) {
|
||||
static size_t bot_id = 0;
|
||||
bot_id %= bot_names.size();
|
||||
const auto& entry = bot_names.at(bot_id++);
|
||||
return entry.first.data();
|
||||
@ -61,9 +61,9 @@ int build_connect_string(char* buf, const char* connect_string,
|
||||
int port) {
|
||||
// Default
|
||||
auto clan_tag = "3arc"s;
|
||||
for (const auto& entry : bot_names) {
|
||||
if (entry.first == name) {
|
||||
clan_tag = entry.second;
|
||||
for (const auto& [bot_name, tag] : bot_names) {
|
||||
if (bot_name == name) {
|
||||
clan_tag = tag;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -34,10 +34,10 @@ void unmute_player(const game::client_s* cl) {
|
||||
utils::string::va("%c \"You were unmuted\"", 0x65));
|
||||
}
|
||||
|
||||
void client_command(int clientNumber) {
|
||||
void client_command(int client_number) {
|
||||
char buf[1024] = {0};
|
||||
|
||||
if (game::g_entities[clientNumber].client == nullptr) {
|
||||
if (game::g_entities[client_number].client == nullptr) {
|
||||
// Not in game
|
||||
return;
|
||||
}
|
||||
@ -46,14 +46,14 @@ void client_command(int clientNumber) {
|
||||
|
||||
std::unique_lock<std::mutex> _(chat_mutex);
|
||||
if (utils::string::starts_with(buf, "say") &&
|
||||
mute_list.contains(game::svs_clients[clientNumber].xuid)) {
|
||||
mute_list.contains(game::svs_clients[client_number].xuid)) {
|
||||
game::SV_GameSendServerCommand(
|
||||
clientNumber, game::SV_CMD_CAN_IGNORE,
|
||||
client_number, game::SV_CMD_CAN_IGNORE,
|
||||
utils::string::va("%c \"You are muted\"", 0x65));
|
||||
return;
|
||||
}
|
||||
|
||||
game::ClientCommand(clientNumber);
|
||||
game::ClientCommand(client_number);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@ -79,7 +79,7 @@ private:
|
||||
if (client == nullptr)
|
||||
return;
|
||||
|
||||
auto* gentity = client->gentity;
|
||||
auto* const gentity = client->gentity;
|
||||
assert(gentity != nullptr);
|
||||
|
||||
if (gentity->client == nullptr)
|
||||
|
@ -16,8 +16,9 @@ void main_handler() {
|
||||
params params = {};
|
||||
|
||||
const auto command = utils::string::to_lower(params[0]);
|
||||
if (handlers.find(command) != handlers.end()) {
|
||||
handlers[command](params);
|
||||
|
||||
if (const auto got = handlers.find(command); got != handlers.end()) {
|
||||
got->second(params);
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,7 +56,7 @@ void add_raw(const char* name, void (*callback)()) {
|
||||
void add(const char* name, const std::function<void(const params&)>& callback) {
|
||||
const auto command = utils::string::to_lower(name);
|
||||
|
||||
if (handlers.find(command) == handlers.end()) {
|
||||
if (!handlers.contains(name)) {
|
||||
add_raw(name, main_handler);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user