simplify if checks

This commit is contained in:
David Markowitz 2024-04-03 04:04:02 -07:00
parent 02847c6849
commit 6c2f113604

View File

@ -123,18 +123,14 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& chat, Entity*
if (entity->GetGMLevel() >= commandHandle.requiredLevel) { if (entity->GetGMLevel() >= commandHandle.requiredLevel) {
if (commandHandle.requiredLevel > eGameMasterLevel::CIVILIAN) Database::Get()->InsertSlashCommandUsage(entity->GetObjectID(), input); if (commandHandle.requiredLevel > eGameMasterLevel::CIVILIAN) Database::Get()->InsertSlashCommandUsage(entity->GetObjectID(), input);
commandHandle.handle(entity, sysAddr, args); commandHandle.handle(entity, sysAddr, args);
} else { } else if (entity->GetGMLevel() != eGameMasterLevel::CIVILIAN) {
// We don't need to tell civilians they aren't high enough level // We don't need to tell civilians they aren't high enough level
if (entity->GetGMLevel() != eGameMasterLevel::CIVILIAN) {
error = "You are not high enough GM level to use \"" + command + "\""; error = "You are not high enough GM level to use \"" + command + "\"";
} }
} } else if (entity->GetGMLevel() == eGameMasterLevel::CIVILIAN) {
} else {
// We don't need to tell civilians commands don't exist // We don't need to tell civilians commands don't exist
if (entity->GetGMLevel() == eGameMasterLevel::CIVILIAN) {
error = "Command " + command + " does not exist!"; error = "Command " + command + " does not exist!";
} }
}
if (!error.empty()) { if (!error.empty()) {
GameMessages::SendSlashCommandFeedbackText(entity, GeneralUtils::ASCIIToUTF16(error)); GameMessages::SendSlashCommandFeedbackText(entity, GeneralUtils::ASCIIToUTF16(error));