mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-24 01:08:21 +00:00
[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:
@@ -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()
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user