From 809067c899204ad9329fa8f953a3ac238d446606 Mon Sep 17 00:00:00 2001 From: Ilya Osadchiy Date: Fri, 22 Jan 2021 22:12:39 +0000 Subject: [PATCH 1/5] LUA bind of introduction info --- src/script/binding/player.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/script/binding/player.cpp b/src/script/binding/player.cpp index 87485169..dcaf81e3 100644 --- a/src/script/binding/player.cpp +++ b/src/script/binding/player.cpp @@ -26,6 +26,8 @@ namespace binding { auto player() -> Binding { return luabind::class_("Player") + .def("knows", &Player::knows) + .def("getCustomNameOf", &Player::getCustomNameOf) .enum_("player_language")[luabind::value("german", static_cast(Language::german)), luabind::value("english", static_cast(Language::english))] .enum_("quest_availability")[luabind::value("questAvailable", static_cast(questAvailable)), From 05f25e726f6a38f128a650a11675c8a9373d3cfc Mon Sep 17 00:00:00 2001 From: Ilya Osadchiy Date: Fri, 29 Jan 2021 21:30:13 +0000 Subject: [PATCH 2/5] Expose char description from DB to scripts --- src/Player.cpp | 8 +++++++- src/Player.hpp | 8 ++++++++ src/script/binding/player.cpp | 4 ++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Player.cpp b/src/Player.cpp index e067190f..26fb299c 100644 --- a/src/Player.cpp +++ b/src/Player.cpp @@ -813,6 +813,8 @@ void Player::check_logindata() { charQuery.addColumn("chars", "chr_lastsavetime"); charQuery.addColumn("chars", "chr_sex"); charQuery.addColumn("chars", "chr_race"); + charQuery.addColumn("chars", "chr_shortdesc_de"); + charQuery.addColumn("chars", "chr_shortdesc_us"); charQuery.addEqualCondition("chars", "chr_name", getName()); charQuery.addServerTable("chars"); @@ -836,6 +838,8 @@ void Player::check_logindata() { lastsavetime = charRow["chr_lastsavetime"].as(); setAttribute(Character::sex, charRow["chr_sex"].as()); setRace(charRow["chr_race"].as()); + descriptionEn = charRow["chr_shortdesc_us"].as(); + descriptionDe = charRow["chr_shortdesc_de"].as(); // first we check the status since we already retrieved it switch (status) { @@ -1080,7 +1084,9 @@ auto Player::save() noexcept -> bool { query.addAssignColumn("chr_lastip", last_ip); query.addAssignColumn("chr_onlinetime", onlinetime + lastsavetime - logintime); query.addAssignColumn("chr_lastsavetime", lastsavetime); - + query.addAssignColumn("chr_shortdesc_us", descriptionEn); + query.addAssignColumn("chr_shortdesc_de", descriptionDe); + if (status != 0) { query.addAssignColumn("chr_statustime", statustime); query.addAssignColumn("chr_statusgm", statusgm); diff --git a/src/Player.hpp b/src/Player.hpp index 5f0b3453..f0e691c0 100644 --- a/src/Player.hpp +++ b/src/Player.hpp @@ -141,8 +141,16 @@ class Player : public Character { CLIENTCOMMANDLIST immediateCommands; CLIENTCOMMANDLIST queuedCommands; std::mutex commandMutex; + TYPE_OF_ENGLISH descriptionEn; + TYPE_OF_GERMAN descriptionDe; public: + + auto getDescriptionEn() const -> TYPE_OF_ENGLISH { return descriptionEn; } + void setDescriptionEn(const TYPE_OF_ENGLISH& descrEn) {descriptionEn = descrEn; } + auto getDescriptionDe() const -> TYPE_OF_GERMAN { return descriptionDe; } + void setDescriptionDe(const TYPE_OF_GERMAN& descrDe) {descriptionDe = descrDe; } + void receiveCommand(const ClientCommandPointer &cmd); void stopAttack() override; diff --git a/src/script/binding/player.cpp b/src/script/binding/player.cpp index dcaf81e3..3a14cf10 100644 --- a/src/script/binding/player.cpp +++ b/src/script/binding/player.cpp @@ -28,6 +28,10 @@ auto player() -> Binding { return luabind::class_("Player") .def("knows", &Player::knows) .def("getCustomNameOf", &Player::getCustomNameOf) + .def("getDescriptionEn", &Player::getDescriptionEn) + .def("setDescriptionEn", &Player::setDescriptionEn) + .def("getDescriptionDe", &Player::getDescriptionDe) + .def("setDescriptionDe", &Player::setDescriptionDe) .enum_("player_language")[luabind::value("german", static_cast(Language::german)), luabind::value("english", static_cast(Language::english))] .enum_("quest_availability")[luabind::value("questAvailable", static_cast(questAvailable)), From d14b6b802740c7a99b1301f5d4f2edde44adb6c9 Mon Sep 17 00:00:00 2001 From: Ilya Osadchiy Date: Fri, 12 Feb 2021 20:57:01 +0000 Subject: [PATCH 3/5] Clang format --- src/Player.cpp | 2 +- src/Player.hpp | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Player.cpp b/src/Player.cpp index 26fb299c..a8d1b642 100644 --- a/src/Player.cpp +++ b/src/Player.cpp @@ -1086,7 +1086,7 @@ auto Player::save() noexcept -> bool { query.addAssignColumn("chr_lastsavetime", lastsavetime); query.addAssignColumn("chr_shortdesc_us", descriptionEn); query.addAssignColumn("chr_shortdesc_de", descriptionDe); - + if (status != 0) { query.addAssignColumn("chr_statustime", statustime); query.addAssignColumn("chr_statusgm", statusgm); diff --git a/src/Player.hpp b/src/Player.hpp index f0e691c0..e01adc75 100644 --- a/src/Player.hpp +++ b/src/Player.hpp @@ -145,11 +145,10 @@ class Player : public Character { TYPE_OF_GERMAN descriptionDe; public: - auto getDescriptionEn() const -> TYPE_OF_ENGLISH { return descriptionEn; } - void setDescriptionEn(const TYPE_OF_ENGLISH& descrEn) {descriptionEn = descrEn; } + void setDescriptionEn(const TYPE_OF_ENGLISH& descrEn) { descriptionEn = descrEn; } auto getDescriptionDe() const -> TYPE_OF_GERMAN { return descriptionDe; } - void setDescriptionDe(const TYPE_OF_GERMAN& descrDe) {descriptionDe = descrDe; } + void setDescriptionDe(const TYPE_OF_GERMAN& descrDe) { descriptionDe = descrDe; } void receiveCommand(const ClientCommandPointer &cmd); From c5b58a97e8994e87cf07746cc52ea9bb74a5e2f3 Mon Sep 17 00:00:00 2001 From: Ilya Osadchiy Date: Fri, 12 Feb 2021 20:59:34 +0000 Subject: [PATCH 4/5] Clang format --- src/Player.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Player.hpp b/src/Player.hpp index e01adc75..680309cb 100644 --- a/src/Player.hpp +++ b/src/Player.hpp @@ -146,9 +146,9 @@ class Player : public Character { public: auto getDescriptionEn() const -> TYPE_OF_ENGLISH { return descriptionEn; } - void setDescriptionEn(const TYPE_OF_ENGLISH& descrEn) { descriptionEn = descrEn; } + void setDescriptionEn(const TYPE_OF_ENGLISH &descrEn) { descriptionEn = descrEn; } auto getDescriptionDe() const -> TYPE_OF_GERMAN { return descriptionDe; } - void setDescriptionDe(const TYPE_OF_GERMAN& descrDe) { descriptionDe = descrDe; } + void setDescriptionDe(const TYPE_OF_GERMAN &descrDe) { descriptionDe = descrDe; } void receiveCommand(const ClientCommandPointer &cmd); From d2a1775d700e70b2f3f304752c7b75232c05e5ed Mon Sep 17 00:00:00 2001 From: Ilya Osadchiy Date: Fri, 12 Feb 2021 21:09:14 +0000 Subject: [PATCH 5/5] Clang format --- src/Player.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Player.hpp b/src/Player.hpp index 680309cb..7fc55e5e 100644 --- a/src/Player.hpp +++ b/src/Player.hpp @@ -147,7 +147,7 @@ class Player : public Character { public: auto getDescriptionEn() const -> TYPE_OF_ENGLISH { return descriptionEn; } void setDescriptionEn(const TYPE_OF_ENGLISH &descrEn) { descriptionEn = descrEn; } - auto getDescriptionDe() const -> TYPE_OF_GERMAN { return descriptionDe; } + auto getDescriptionDe() const -> TYPE_OF_GERMAN { return descriptionDe; } void setDescriptionDe(const TYPE_OF_GERMAN &descrDe) { descriptionDe = descrDe; } void receiveCommand(const ClientCommandPointer &cmd);