Merge branch 'master' into develop
Some checks are pending
Build / Linux (push) Waiting to run
Build / Windows (push) Waiting to run

This commit is contained in:
KimLS 2026-05-07 20:56:48 -07:00
commit 7d98b10c18
8 changed files with 80 additions and 121 deletions

View File

@ -380,118 +380,59 @@ std::string Strings::NumberToWords(unsigned long long int n)
return res;
}
std::string Strings::Money(uint64 platinum, uint64 gold, uint64 silver, uint64 copper)
{
std::string money_string = "Unknown";
if (copper && silver && gold && platinum) { // CSGP
money_string = fmt::format(
"{} platinum, {} gold, {} silver, and {} copper",
Strings::Commify(std::to_string(platinum)),
Strings::Commify(std::to_string(gold)),
Strings::Commify(std::to_string(silver)),
Strings::Commify(std::to_string(copper))
);
std::string Strings::Money(uint64 platinum, uint64 gold, uint64 silver, uint64 copper, bool commify) {
uint64 values[] = { platinum, gold, silver, copper };
const char* names[] = { " platinum", " gold", " silver", " copper" };
std::vector<std::string> parts;
for (int i = 0; i < 4; ++i) {
if (values[i] > 0) {
std::string s = std::to_string(values[i]);
parts.push_back((commify ? Strings::Commify(s) : s) + names[i]);
}
}
else if (copper && silver && !gold && platinum) { // CSP
money_string = fmt::format(
"{} platinum, {} silver, and {} copper",
Strings::Commify(std::to_string(platinum)),
Strings::Commify(std::to_string(silver)),
Strings::Commify(std::to_string(copper))
);
if (parts.empty()) return "0 copper";
if (parts.size() == 1) return parts[0];
std::string result;
for (size_t i = 0; i < parts.size(); ++i) {
result += parts[i];
if (i < parts.size() - 2) {
result += ", ";
}
else if (i == parts.size() - 2) {
// Oxford comma logic: ", and " for 3+ items, " and " for 2
result += (parts.size() > 2) ? ", and " : " and ";
}
}
else if (copper && silver && gold && !platinum) { // CSG
money_string = fmt::format(
"{} gold, {} silver, and {} copper",
Strings::Commify(std::to_string(gold)),
Strings::Commify(std::to_string(silver)),
Strings::Commify(std::to_string(copper))
);
}
else if (copper && !silver && !gold && platinum) { // CP
money_string = fmt::format(
"{} platinum and {} copper",
Strings::Commify(std::to_string(platinum)),
Strings::Commify(std::to_string(copper))
);
}
else if (copper && silver && !gold && !platinum) { // CS
money_string = fmt::format(
"{} silver and {} copper",
Strings::Commify(std::to_string(silver)),
Strings::Commify(std::to_string(copper))
);
}
else if (!copper && silver && gold && platinum) { // SGP
money_string = fmt::format(
"{} platinum, {} gold, and {} silver",
Strings::Commify(std::to_string(platinum)),
Strings::Commify(std::to_string(gold)),
Strings::Commify(std::to_string(silver))
);
}
else if (!copper && silver && !gold && platinum) { // SP
money_string = fmt::format(
"{} platinum and {} silver",
Strings::Commify(std::to_string(platinum)),
Strings::Commify(std::to_string(silver))
);
}
else if (!copper && silver && gold && !platinum) { // SG
money_string = fmt::format(
"{} gold and {} silver",
Strings::Commify(std::to_string(gold)),
Strings::Commify(std::to_string(silver))
);
}
else if (copper && !silver && gold && platinum) { // CGP
money_string = fmt::format(
"{} platinum, {} gold, and {} copper",
Strings::Commify(std::to_string(platinum)),
Strings::Commify(std::to_string(gold)),
Strings::Commify(std::to_string(copper))
);
}
else if (copper && !silver && gold && !platinum) { // CG
money_string = fmt::format(
"{} gold and {} copper",
Strings::Commify(std::to_string(gold)),
Strings::Commify(std::to_string(copper))
);
}
else if (!copper && !silver && gold && platinum) { // GP
money_string = fmt::format(
"{} platinum and {} gold",
Strings::Commify(std::to_string(platinum)),
Strings::Commify(std::to_string(gold))
);
}
else if (!copper && !silver && !gold && platinum) { // P
money_string = fmt::format(
"{} platinum",
Strings::Commify(std::to_string(platinum))
);
}
else if (!copper && !silver && gold && !platinum) { // G
money_string = fmt::format(
"{} gold",
Strings::Commify(std::to_string(gold))
);
}
else if (!copper && silver && !gold && !platinum) { // S
money_string = fmt::format(
"{} silver",
Strings::Commify(std::to_string(silver))
);
}
else if (copper && !silver && !gold && !platinum) { // C
money_string = fmt::format(
"{} copper",
Strings::Commify(std::to_string(copper))
);
}
return money_string;
return result;
}
std::string Strings::MoneyShort(uint64 copper, bool commify) {
// Matches merchant format
uint64 values[] = {
copper / 1000,
(copper / 100) % 10,
(copper / 10) % 10,
copper % 10
};
const char* names[] = { " platinum", " gold", " silver", " copper" };
std::string result;
for (int i = 0; i < 4; ++i) {
if (values[i] > 0) {
if (!result.empty()) result += " ";
std::string s = std::to_string(values[i]);
result += (commify ? Strings::Commify(s) : s) + names[i];
}
}
return result.empty() ? "0 copper" : result;
}
std::string Strings::SecondsToTime(int duration, bool is_milliseconds)
{
if (duration <= 0) {

View File

@ -62,7 +62,8 @@ public:
static std::string Join(const std::vector<std::string> &ar, const std::string &delim);
static std::string Join(const std::vector<uint32_t> &ar, const std::string &delim);
static std::string MillisecondsToTime(int duration);
static std::string Money(uint64 platinum, uint64 gold = 0, uint64 silver = 0, uint64 copper = 0);
static std::string Money(uint64 platinum, uint64 gold = 0, uint64 silver = 0, uint64 copper = 0, bool commify = true);
static std::string MoneyShort(uint64 copper = 0, bool commify = true); // Matches merchant format when commify is false
static std::string NumberToWords(unsigned long long int n);
static std::string Repeat(std::string s, int n);
static std::string Replace(std::string subject, const std::string &search, const std::string &replace);

View File

@ -37,3 +37,13 @@ target_include_directories(loginserver PRIVATE ..)
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
set_property(TARGET loginserver PROPERTY FOLDER executables/servers)
# vcpkg doesn't copy legacy.dll automatically because it is loaded at runtime, not via the import table.
if(WIN32 AND DEFINED VCPKG_INSTALLED_DIR AND DEFINED VCPKG_TARGET_TRIPLET)
add_custom_command(TARGET loginserver POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"$<IF:$<CONFIG:Debug>,${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/bin/legacy.dll,${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/bin/legacy.dll>"
"$<TARGET_FILE_DIR:loginserver>/legacy.dll"
VERBATIM
)
endif()

View File

@ -182,6 +182,18 @@ static OSSL_PROVIDER *s_default_provider = nullptr;
bool eqcrypt_init()
{
#ifdef EQEMU_USE_OPENSSL
#ifdef _WIN32
// Set OpenSSL default provider search path to the executable directory.
char* exe_path = nullptr;
if (_get_pgmptr(&exe_path) == 0 && exe_path != nullptr && *exe_path != '\0') {
std::string exe_dir{exe_path};
if (auto sep = exe_dir.find_last_of("\\/"); sep != std::string::npos) {
exe_dir.resize(sep);
OSSL_PROVIDER_set_default_search_path(nullptr, exe_dir.c_str());
}
}
#endif
if (!s_default_provider) {
s_default_provider = OSSL_PROVIDER_load(nullptr, "default");
}

View File

@ -159,6 +159,7 @@ void start_web_server()
int main(int argc, char **argv)
{
RegisterExecutablePlatform(ExePlatformLogin);
EQEmuLogSys::Instance()->LoadLogSettingsDefaults();
set_exception_handler();
if (!eqcrypt_init()) {
@ -166,12 +167,6 @@ int main(int argc, char **argv)
return 1;
}
LogInfo("Logging System Init");
if (argc == 1) {
EQEmuLogSys::Instance()->LoadLogSettingsDefaults();
}
PathManager::Instance()->Init();
// command handler

View File

@ -775,7 +775,7 @@ void helper_send_usage_required_bots(Client *bot_owner, uint16 spell_type)
bot_owner->Message(Chat::Green, "%s", description.c_str());
}
void SendSpellTypeWindow(Client* c, const Seperator* sep) {
void SendSpellTypeWindow(Client* c, const Seperator* sep, bool short_names) {
std::string arg0 = sep->arg[0];
std::string arg1 = sep->arg[1];
@ -828,7 +828,7 @@ void SendSpellTypeWindow(Client* c, const Seperator* sep) {
std::string popup_text = DialogueWindow::TableRow(
DialogueWindow::TableCell(DialogueWindow::ColorMessage(goldenrod, spell_type_field))
+
DialogueWindow::TableCell((!arg0.compare("^spelltypeids") ? DialogueWindow::ColorMessage(goldenrod, id_field) : DialogueWindow::ColorMessage(goldenrod, shortname_field)))
DialogueWindow::TableCell((!short_names ? DialogueWindow::ColorMessage(goldenrod, id_field) : DialogueWindow::ColorMessage(goldenrod, shortname_field)))
);
popup_text += DialogueWindow::TableRow(
@ -845,7 +845,7 @@ void SendSpellTypeWindow(Client* c, const Seperator* sep) {
popup_text += DialogueWindow::TableRow(
DialogueWindow::TableCell(DialogueWindow::ColorMessage(forest_green, Bot::GetSpellTypeNameByID(i)))
+
DialogueWindow::TableCell((!arg0.compare("^spelltypeids") ? DialogueWindow::ColorMessage(slate_blue, std::to_string(i)) : DialogueWindow::ColorMessage(slate_blue, Bot::GetSpellTypeShortNameByID(i))))
DialogueWindow::TableCell((!short_names ? DialogueWindow::ColorMessage(slate_blue, std::to_string(i)) : DialogueWindow::ColorMessage(slate_blue, Bot::GetSpellTypeShortNameByID(i))))
);
}

View File

@ -1182,4 +1182,4 @@ bool helper_is_help_or_usage(const char* arg);
bool helper_no_available_bots(Client *bot_owner, Bot *my_bot = nullptr);
void helper_send_available_subcommands(Client *bot_owner, const char* command_simile, std::vector<const char*> subcommand_list);
void helper_send_usage_required_bots(Client *bot_owner, uint16 spell_type);
void SendSpellTypeWindow(Client* c, const Seperator* sep);
void SendSpellTypeWindow(Client* c, const Seperator* sep, bool short_names = false);

View File

@ -24,5 +24,5 @@ void bot_command_spelltype_ids(Client* c, const Seperator* sep)
void bot_command_spelltype_names(Client* c, const Seperator* sep)
{
SendSpellTypeWindow(c, sep);
SendSpellTypeWindow(c, sep, true);
}