[Languages] Cleanup language constants, use repositories (#3838)

* [Languages] Cleanup languages constants

# Notes
- Cleanup formatting and logic where necessary.
- Cleaned up constants to use a namespace with `constexpr` instead.
- Changed `LoadCharacterLanguages` to use a repository instead.

* Lua GroupMessage uint8/language_id

* Lua More uint8/language_id
This commit is contained in:
Alex King
2024-01-06 23:17:10 -05:00
committed by GitHub
parent 43c4b13978
commit 122fe398b4
34 changed files with 393 additions and 393 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ void command_chat(Client *c, const Seperator *sep)
auto channel_id = static_cast<uint8>(Strings::ToUnsignedInt(sep->arg[1]));
std::string message = sep->argplus[2];
if (!worldserver.SendChannelMessage(0, 0, channel_id, 0, 0, 100, message.c_str())) {
if (!worldserver.SendChannelMessage(0, 0, channel_id, 0, Language::CommonTongue, Language::MaxValue, message.c_str())) {
c->Message(Chat::White, "World server is disconnected.");
}
}
+1 -2
View File
@@ -1,11 +1,10 @@
#include "../../client.h"
#include "../../common/languages.h"
void FindLanguage(Client *c, const Seperator *sep)
{
if (sep->IsNumber(2)) {
const auto language_id = Strings::ToInt(sep->arg[2]);
if (EQ::ValueWithin(language_id, LANG_COMMON_TONGUE, LANG_UNKNOWN)) {
if (EQ::ValueWithin(language_id, Language::CommonTongue, Language::Unknown27)) {
c->Message(
Chat::White,
fmt::format(
+14 -15
View File
@@ -1,43 +1,42 @@
#include "../../client.h"
#include "../../../common/languages.h"
#include "../../../common/data_verification.h"
void SetLanguage(Client *c, const Seperator *sep)
{
const auto arguments = sep->argnum;
const int arguments = sep->argnum;
if (arguments < 3 || !sep->IsNumber(2) || !sep->IsNumber(3)) {
c->Message(Chat::White, "Usage: #set language [Language ID] [Language Value]");
c->Message(Chat::White, "Usage: #set language [Language ID] [Language Skill]");
c->Message(Chat::White, "Language ID = 0 to 27");
c->Message(Chat::White, "Language Value = 0 to 100");
c->Message(Chat::White, "Language Skill = 0 to 100");
return;
}
auto t = c;
Client* t = c;
if (c->GetTarget() && c->GetTarget()->IsClient()) {
t = c->GetTarget()->CastToClient();
}
const int language_id = Strings::ToInt(sep->arg[2]);
const int language_value = Strings::ToInt(sep->arg[3]);
const uint8 language_id = Strings::ToInt(sep->arg[2]);
const uint8 language_skill = Strings::ToInt(sep->arg[3]);
if (
!EQ::ValueWithin(language_id, LANG_COMMON_TONGUE, LANG_UNKNOWN) ||
!EQ::ValueWithin(language_value, 0, MAX_LANGUAGE_SKILL)
!EQ::ValueWithin(language_id, Language::CommonTongue, Language::Unknown27) ||
!EQ::ValueWithin(language_skill, 0, Language::MaxValue)
) {
c->Message(Chat::White, "Usage: #set language [Language ID] [Language Value]");
c->Message(Chat::White, "Usage: #set language [Language ID] [Language Skill]");
c->Message(Chat::White, "Language ID = 0 to 27");
c->Message(Chat::White, "Language Value = 0 to 100");
c->Message(Chat::White, "Language Skill = 0 to 100");
return;
}
LogInfo(
"Set language request from [{}], Target: [{}] Language ID: [{}] Language Value: [{}]",
"Set language request from [{}], Target: [{}] Language ID: [{}] Language Skill: [{}]",
c->GetCleanName(),
c->GetTargetDescription(t),
language_id,
language_value
language_skill
);
t->SetLanguageSkill(language_id, language_value);
t->SetLanguageSkill(language_id, language_skill);
if (c != t) {
c->Message(
@@ -46,7 +45,7 @@ void SetLanguage(Client *c, const Seperator *sep)
"Set {} ({}) to {} for {}.",
EQ::constants::GetLanguageName(language_id),
language_id,
language_value,
language_skill,
c->GetTargetDescription(t)
).c_str()
);